summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorG.Balaji <balajig81@gmail.com>2011-11-26 21:59:32 +0400
committerDenis Ovsienko <infrastation@yandex.ru>2012-01-23 14:30:42 +0400
commitcddf391bf6839e9f093cef15508669c1f3f92122 (patch)
tree38dfaa5a7b98776ba67bb8a812beec8724810839
parent5a616c08ce089e25dc0e8da920727af4d11279bf (diff)
zebra: IPv4 MP-BGP Routes addition and deletion
This patch contains the following: 1. Addition of IPv4 SAFI_MULTICAST BGP routes into the RTM's RIB. 2. Deletion of IPv4 SAFI_MULTICAST BGP routes from the RTM's RIB.
-rw-r--r--zebra/connected.c4
-rw-r--r--zebra/kernel_socket.c2
-rw-r--r--zebra/rib.h6
-rw-r--r--zebra/rt_netlink.c6
-rw-r--r--zebra/rtread_getmsg.c2
-rw-r--r--zebra/rtread_proc.c2
-rw-r--r--zebra/zebra_rib.c18
-rw-r--r--zebra/zebra_vty.c82
-rw-r--r--zebra/zserv.c8
9 files changed, 111 insertions, 19 deletions
diff --git a/zebra/connected.c b/zebra/connected.c
index 95399fa1..8db2d367 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -189,7 +189,7 @@ connected_up_ipv4 (struct interface *ifp, struct connected *ifc)
return;
rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, NULL, ifp->ifindex,
- RT_TABLE_MAIN, ifp->metric, 0);
+ RT_TABLE_MAIN, ifp->metric, 0, SAFI_UNICAST);
rib_update ();
}
@@ -295,7 +295,7 @@ connected_down_ipv4 (struct interface *ifp, struct connected *ifc)
return;
/* Same logic as for connected_up_ipv4(): push the changes into the head. */
- rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0);
+ rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0, SAFI_UNICAST);
rib_update ();
}
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index e7ceea54..1ad2a811 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -912,7 +912,7 @@ rtm_read (struct rt_msghdr *rtm)
|| rtm->rtm_type == RTM_ADD
|| rtm->rtm_type == RTM_CHANGE)
rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags,
- &p, &gate.sin.sin_addr, NULL, 0, 0, 0, 0);
+ &p, &gate.sin.sin_addr, NULL, 0, 0, 0, 0, SAFI_UNICAST);
else
rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags,
&p, &gate.sin.sin_addr, 0, 0);
diff --git a/zebra/rib.h b/zebra/rib.h
index 20a206ea..27a2de69 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -249,13 +249,13 @@ extern struct route_table *vrf_static_table (afi_t afi, safi_t safi, u_int32_t i
extern int rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, struct in_addr *src,
unsigned int ifindex, u_int32_t vrf_id,
- u_int32_t, u_char);
+ u_int32_t, u_char, safi_t);
-extern int rib_add_ipv4_multipath (struct prefix_ipv4 *, struct rib *);
+extern int rib_add_ipv4_multipath (struct prefix_ipv4 *, struct rib *, safi_t);
extern int rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, unsigned int ifindex,
- u_int32_t);
+ u_int32_t, safi_t safi);
extern struct rib *rib_match_ipv4 (struct in_addr);
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index a09e459c..8e1285db 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -723,7 +723,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h)
memcpy (&p.prefix, dest, 4);
p.prefixlen = rtm->rtm_dst_len;
- rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, flags, &p, gate, src, index, table, metric, 0);
+ rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, flags, &p, gate, src, index, table, metric, 0, SAFI_UNICAST);
}
#ifdef HAVE_IPV6
if (rtm->rtm_family == AF_INET6)
@@ -867,9 +867,9 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h)
}
if (h->nlmsg_type == RTM_NEWROUTE)
- rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, src, index, table, metric, 0);
+ rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, src, index, table, metric, 0, SAFI_UNICAST);
else
- rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, index, table);
+ rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, index, table, SAFI_UNICAST);
}
#ifdef HAVE_IPV6
diff --git a/zebra/rtread_getmsg.c b/zebra/rtread_getmsg.c
index 3e065c6f..81bf0de6 100644
--- a/zebra/rtread_getmsg.c
+++ b/zebra/rtread_getmsg.c
@@ -90,7 +90,7 @@ handle_route_entry (mib2_ipRouteEntry_t *routeEntry)
gateway.s_addr = routeEntry->ipRouteNextHop;
rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &prefix,
- &gateway, NULL, 0, 0, 0, 0);
+ &gateway, NULL, 0, 0, 0, 0, SAFI_UNICAST);
}
void
diff --git a/zebra/rtread_proc.c b/zebra/rtread_proc.c
index 1de435a4..07e8491a 100644
--- a/zebra/rtread_proc.c
+++ b/zebra/rtread_proc.c
@@ -96,7 +96,7 @@ proc_route_read (void)
p.prefixlen = ip_masklen (tmpmask);
sscanf (gate, "%lX", (unsigned long *)&gateway);
- rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p, &gateway, NULL, 0, 0, 0, 0);
+ rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p, &gateway, NULL, 0, 0, 0, 0, SAFI_UNICAST);
}
fclose (fp);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index d239501d..a366cf1f 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -90,6 +90,11 @@ vrf_alloc (const char *name)
vrf->table[AFI_IP6][SAFI_UNICAST] = route_table_init ();
vrf->stable[AFI_IP][SAFI_UNICAST] = route_table_init ();
vrf->stable[AFI_IP6][SAFI_UNICAST] = route_table_init ();
+ vrf->table[AFI_IP][SAFI_MULTICAST] = route_table_init ();
+ vrf->table[AFI_IP6][SAFI_MULTICAST] = route_table_init ();
+ vrf->stable[AFI_IP][SAFI_MULTICAST] = route_table_init ();
+ vrf->stable[AFI_IP6][SAFI_MULTICAST] = route_table_init ();
+
return vrf;
}
@@ -1493,7 +1498,7 @@ int
rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, struct in_addr *src,
unsigned int ifindex, u_int32_t vrf_id,
- u_int32_t metric, u_char distance)
+ u_int32_t metric, u_char distance, safi_t safi)
{
struct rib *rib;
struct rib *same = NULL;
@@ -1502,7 +1507,7 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct nexthop *nexthop;
/* Lookup table. */
- table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
+ table = vrf_table (AFI_IP, safi, 0);
if (! table)
return 0;
@@ -1751,7 +1756,7 @@ void rib_lookup_and_pushup (struct prefix_ipv4 * p)
}
int
-rib_add_ipv4_multipath (struct prefix_ipv4 *p, struct rib *rib)
+rib_add_ipv4_multipath (struct prefix_ipv4 *p, struct rib *rib, safi_t safi)
{
struct route_table *table;
struct route_node *rn;
@@ -1759,9 +1764,10 @@ rib_add_ipv4_multipath (struct prefix_ipv4 *p, struct rib *rib)
struct nexthop *nexthop;
/* Lookup table. */
- table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
+ table = vrf_table (AFI_IP, safi, 0);
if (! table)
return 0;
+
/* Make it sure prefixlen is applied to the prefix. */
apply_mask_ipv4 (p);
@@ -1824,7 +1830,7 @@ rib_add_ipv4_multipath (struct prefix_ipv4 *p, struct rib *rib)
/* XXX factor with rib_delete_ipv6 */
int
rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
- struct in_addr *gate, unsigned int ifindex, u_int32_t vrf_id)
+ struct in_addr *gate, unsigned int ifindex, u_int32_t vrf_id, safi_t safi)
{
struct route_table *table;
struct route_node *rn;
@@ -1836,7 +1842,7 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
char buf2[INET_ADDRSTRLEN];
/* Lookup table. */
- table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
+ table = vrf_table (AFI_IP, safi, 0);
if (! table)
return 0;
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 05485a13..1785fec0 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -1947,6 +1947,81 @@ DEFUN (show_ipv6_route_summary,
return CMD_SUCCESS;
}
+/*
+ * Show IP mroute command to dump the BGP Multicast
+ * routing table
+ */
+DEFUN (show_ip_mroute,
+ show_ip_mroute_cmd,
+ "show ip mroute",
+ SHOW_STR
+ IP_STR
+ "IP Multicast routing table\n")
+{
+ struct route_table *table;
+ struct route_node *rn;
+ struct rib *rib;
+ int first = 1;
+
+ table = vrf_table (AFI_IP, SAFI_MULTICAST, 0);
+ if (! table)
+ return CMD_SUCCESS;
+
+ /* Show all IPv4 routes. */
+ for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rib = rn->info; rib; rib = rib->next)
+ {
+ if (first)
+ {
+ vty_out (vty, SHOW_ROUTE_V4_HEADER, VTY_NEWLINE, VTY_NEWLINE,
+ VTY_NEWLINE);
+ first = 0;
+ }
+ vty_show_ip_route (vty, rn, rib);
+ }
+ return CMD_SUCCESS;
+}
+
+/*
+ * Show IPv6 mroute command.Used to dump
+ * the Multicast routing table.
+ */
+
+DEFUN (show_ipv6_mroute,
+ show_ipv6_mroute_cmd,
+ "show ipv6 mroute",
+ SHOW_STR
+ IP_STR
+ "IPv6 Multicast routing table\n")
+{
+ struct route_table *table;
+ struct route_node *rn;
+ struct rib *rib;
+ int first = 1;
+
+ table = vrf_table (AFI_IP6, SAFI_MULTICAST, 0);
+ if (! table)
+ return CMD_SUCCESS;
+
+ /* Show all IPv6 route. */
+ for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rib = rn->info; rib; rib = rib->next)
+ {
+ if (first)
+ {
+ vty_out (vty, SHOW_ROUTE_V6_HEADER, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
+ first = 0;
+ }
+ vty_show_ipv6_route (vty, rn, rib);
+ }
+ return CMD_SUCCESS;
+}
+
+
+
+
+
+
/* Write IPv6 static route configuration. */
static int
static_config_ipv6 (struct vty *vty)
@@ -2089,6 +2164,10 @@ zebra_vty_init (void)
install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
+ install_element (VIEW_NODE, &show_ip_mroute_cmd);
+ install_element (ENABLE_NODE, &show_ip_mroute_cmd);
+
+
#ifdef HAVE_IPV6
install_element (CONFIG_NODE, &ipv6_route_cmd);
install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
@@ -2118,5 +2197,8 @@ zebra_vty_init (void)
install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd);
+
+ install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
+ install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
#endif /* HAVE_IPV6 */
}
diff --git a/zebra/zserv.c b/zebra/zserv.c
index ec8cbf2b..310c6ce6 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -750,6 +750,8 @@ zread_ipv4_add (struct zserv *client, u_short length)
struct stream *s;
unsigned int ifindex;
u_char ifname_len;
+ safi_t safi;
+
/* Get input stream. */
s = client->ibuf;
@@ -761,6 +763,7 @@ zread_ipv4_add (struct zserv *client, u_short length)
rib->type = stream_getc (s);
rib->flags = stream_getc (s);
message = stream_getc (s);
+ safi = stream_getw (s);
rib->uptime = time (NULL);
/* IPv4 prefix. */
@@ -812,7 +815,7 @@ zread_ipv4_add (struct zserv *client, u_short length)
/* Table */
rib->table=zebrad.rtm_table_default;
- rib_add_ipv4_multipath (&p, rib);
+ rib_add_ipv4_multipath (&p, rib, safi);
return 0;
}
@@ -838,6 +841,7 @@ zread_ipv4_delete (struct zserv *client, u_short length)
api.type = stream_getc (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
+ api.safi = stream_getw (s);
/* IPv4 prefix. */
memset (&p, 0, sizeof (struct prefix_ipv4));
@@ -886,7 +890,7 @@ zread_ipv4_delete (struct zserv *client, u_short length)
api.metric = 0;
rib_delete_ipv4 (api.type, api.flags, &p, &nexthop, ifindex,
- client->rtm_table);
+ client->rtm_table, api.safi);
return 0;
}