]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ripd: add support for route tags
authorChristian Franke <chris@opensourcerouting.org>
Sat, 1 Oct 2016 19:43:17 +0000 (21:43 +0200)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 8 Oct 2016 01:05:05 +0000 (21:05 -0400)
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
ripd/rip_interface.c
ripd/rip_zebra.c
ripd/ripd.c
ripd/ripd.h

index 604343be896e3c18fe16c0cd591d0cf2900c3c13..359549ed80c04fb9fb993043701777e5e0060eaa 100644 (file)
@@ -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);
         }
     }
 }
index 23f2adf82c8266d9f3e01635c5eb2c192f0b2d16..3f7c7a3e4d1d57a350e5b48cb89c974f375a7089 100644 (file)
@@ -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;
index 220297e8356c8eeb2eaf8841fe2459d7ad9dcbcf..395a7f782202f43d834006e528f60e2b9c80c897 100644 (file)
@@ -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;
 }
index 2d5bd98de8795bf13c24dbb8372233cfa272a4a9..3de23ec33443bfb2303b1c276c9c57caf3b568fa 100644 (file)
@@ -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 *);