From: Christian Franke Date: Sat, 1 Oct 2016 19:43:17 +0000 (+0200) Subject: ripd: add support for route tags X-Git-Tag: frr-2.0-rc1~168 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=9471675f21f3f7d9cec41c32854477f96a5ce323;p=matthieu%2Ffrr.git ripd: add support for route tags Signed-off-by: Christian Franke --- diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 604343be89..359549ed80 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -640,7 +640,7 @@ rip_apply_address_add (struct connected *ifc) if ((rip_enable_if_lookup(ifc->ifp->name) >= 0) || (rip_enable_network_lookup2(ifc) >= 0)) rip_redistribute_add(ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE, - &address, ifc->ifp->ifindex, NULL, 0, 0); + &address, ifc->ifp->ifindex, NULL, 0, 0, 0); } @@ -951,7 +951,7 @@ rip_connect_set (struct interface *ifp, int set) (rip_enable_network_lookup2(connected) >= 0)) rip_redistribute_add (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE, &address, connected->ifp->ifindex, - NULL, 0, 0); + NULL, 0, 0, 0); } else { rip_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE, @@ -959,7 +959,7 @@ rip_connect_set (struct interface *ifp, int set) if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT)) rip_redistribute_add (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_REDISTRIBUTE, &address, connected->ifp->ifindex, - NULL, 0, 0); + NULL, 0, 0, 0); } } } diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 23f2adf82c..3f7c7a3e4d 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -91,6 +91,12 @@ rip_zebra_ipv4_send (struct route_node *rp, u_char cmd) api.distance = rinfo->distance; } + if (rinfo->tag) + { + SET_FLAG (api.message, ZAPI_MESSAGE_TAG); + api.tag = rinfo->tag; + } + zapi_ipv4_route (cmd, zclient, (struct prefix_ipv4 *)&rp->p, &api); @@ -176,10 +182,15 @@ rip_zebra_read_ipv4 (int command, struct zclient *zclient, zebra_size_t length, else api.metric = 0; + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_TAG)) + api.tag = stream_getl (s); + else + api.tag = 0; + /* Then fetch IPv4 prefixes. */ if (command == ZEBRA_REDISTRIBUTE_IPV4_ADD) rip_redistribute_add (api.type, RIP_ROUTE_REDISTRIBUTE, &p, ifindex, - &nexthop, api.metric, api.distance); + &nexthop, api.metric, api.distance, api.tag); else if (command == ZEBRA_REDISTRIBUTE_IPV4_DEL) rip_redistribute_delete (api.type, RIP_ROUTE_REDISTRIBUTE, &p, ifindex); @@ -614,7 +625,7 @@ DEFUN (rip_default_information_originate, rip->default_information = 1; rip_redistribute_add (ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p, 0, - NULL, 0, 0); + NULL, 0, 0, 0); } return CMD_SUCCESS; diff --git a/ripd/ripd.c b/ripd/ripd.c index 220297e835..395a7f7822 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -1513,7 +1513,8 @@ rip_send_packet (u_char * buf, int size, struct sockaddr_in *to, void rip_redistribute_add (int type, int sub_type, struct prefix_ipv4 *p, ifindex_t ifindex, struct in_addr *nexthop, - unsigned int metric, unsigned char distance) + unsigned int metric, unsigned char distance, + route_tag_t tag) { int ret; struct route_node *rp = NULL; @@ -1534,6 +1535,8 @@ rip_redistribute_add (int type, int sub_type, struct prefix_ipv4 *p, newinfo.metric = 1; newinfo.external_metric = metric; newinfo.distance = distance; + if (tag <= UINT16_MAX) /* RIP only supports 16 bit tags */ + newinfo.tag = tag; newinfo.rp = rp; if (nexthop) newinfo.nexthop = *nexthop; @@ -2945,7 +2948,7 @@ DEFUN (rip_route, node->info = (void *)1; - rip_redistribute_add (ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0, NULL, 0, 0); + rip_redistribute_add (ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0, NULL, 0, 0, 0); return CMD_SUCCESS; } diff --git a/ripd/ripd.h b/ripd/ripd.h index 2d5bd98de8..3de23ec334 100644 --- a/ripd/ripd.h +++ b/ripd/ripd.h @@ -403,7 +403,8 @@ extern int rip_neighbor_lookup (struct sockaddr_in *); extern int rip_redistribute_check (int); extern void rip_redistribute_add (int, int, struct prefix_ipv4 *, ifindex_t, - struct in_addr *, unsigned int, unsigned char); + struct in_addr *, unsigned int, unsigned char, + route_tag_t); extern void rip_redistribute_delete (int, int, struct prefix_ipv4 *, ifindex_t); extern void rip_redistribute_withdraw (int); extern void rip_zebra_ipv4_add (struct route_node *);