ripd: add support for route tags
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 240c968..7521fc7 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -634,7 +634,7 @@
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);
}
@@ -945,7 +945,7 @@
(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,
@@ -953,7 +953,7 @@
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 2670ff7..0b51af5 100644
--- a/ripd/rip_zebra.c
+++ b/ripd/rip_zebra.c
@@ -90,6 +90,12 @@
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);
@@ -173,11 +179,16 @@
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_IPV4_ROUTE_ADD)
rip_redistribute_add (api.type, RIP_ROUTE_REDISTRIBUTE, &p, ifindex,
- &nexthop, api.metric, api.distance);
- else
+ &nexthop, api.metric, api.distance, api.tag);
+ else
rip_redistribute_delete (api.type, RIP_ROUTE_REDISTRIBUTE, &p, ifindex);
return 0;
@@ -612,7 +623,7 @@
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 da9e7b0..848d801 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -1510,7 +1510,8 @@
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;
@@ -1531,6 +1532,8 @@
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;
@@ -2939,7 +2942,7 @@
node->info = (char *)"static";
- 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 9dba1a5..4f82525 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -400,8 +400,9 @@
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);
+extern void rip_redistribute_add (int, int, struct prefix_ipv4 *, ifindex_t,
+ 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 *);