]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: send ZAPI IPv6 source prefix
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 24 Apr 2014 15:30:26 +0000 (17:30 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Mon, 30 Jan 2017 12:47:04 +0000 (13:47 +0100)
This introduces ZAPI_MESSAGE_SRCPFX, and if set adds a source prefix
field to ZAPI IPv6 route messages sent from daemons to zebra.  The
function calls all have a new prefix_ipv6 * argument specifying the
source, or NULL.  All daemons currently supply NULL.

Zebra support for processing the field was added in the previous patch,
however, zebra does not do anything useful with the value yet.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
bgpd/bgp_zebra.c
bgpd/rfapi/vnc_zebra.c
isisd/isis_zebra.c
lib/zclient.c
lib/zclient.h
ospf6d/ospf6_zebra.c
ripngd/ripng_zebra.c

index 8bc7bd3025b245835fef970c904a01d439c03ff8..7c778122b9a96ca1fe814a8d9c39235b14158cb0 100644 (file)
@@ -1587,7 +1587,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp,
 
           zapi_ipv6_route (valid_nh_count ?
                            ZEBRA_IPV6_ROUTE_ADD : ZEBRA_IPV6_ROUTE_DELETE,
-                           zclient, (struct prefix_ipv6 *) p, &api);
+                           zclient, (struct prefix_ipv6 *) p, NULL, &api);
         }
     }
 }
@@ -1725,7 +1725,7 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi)
        }
 
       zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, 
-                       (struct prefix_ipv6 *) p, &api);
+                       (struct prefix_ipv6 *) p, NULL, &api);
     }
 }
 
index 608bc6d3c775706c4c19474e6376a96b3cf6cd2f..d659e964cdc83f65a0769b98e802b4897c874fc5 100644 (file)
@@ -582,7 +582,7 @@ vnc_zebra_route_msg (
 
       zapi_ipv6_route ((add ? ZEBRA_IPV6_NEXTHOP_ADD :
                         ZEBRA_IPV6_NEXTHOP_DELETE), zclient_vnc,
-                       (struct prefix_ipv6 *) p, &api);
+                       (struct prefix_ipv6 *) p, NULL, &api);
     }
   else
     {
index dfb9b4d7abee659a333edf3c3412d7cbb0defc94..e7bd99c3e84d073f669805c6055671b398fed948 100644 (file)
@@ -424,7 +424,7 @@ isis_zebra_route_add_ipv6 (struct prefix *prefix,
       prefix6.family = AF_INET6;
       prefix6.prefixlen = prefix->prefixlen;
       memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr));
-      zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, &prefix6, &api);
+      zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, &prefix6, NULL, &api);
       SET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
       UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC);
     }
@@ -505,7 +505,7 @@ isis_zebra_route_del_ipv6 (struct prefix *prefix,
       prefix6.family = AF_INET6;
       prefix6.prefixlen = prefix->prefixlen;
       memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr));
-      zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, &prefix6, &api);
+      zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, &prefix6, NULL, &api);
       UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
     }
 
index 42fa41c9c82b653703bb288c751326c60914a859..92662fd70ffe0b51d8e2c0406e3a5c27112be0bd 100644 (file)
@@ -854,12 +854,15 @@ zapi_ipv4_route_ipv6_nexthop (u_char cmd, struct zclient *zclient,
 
 int
 zapi_ipv6_route (u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p,
-              struct zapi_ipv6 *api)
+                struct prefix_ipv6 *src_p, struct zapi_ipv6 *api)
 {
   int i;
   int psize;
   struct stream *s;
 
+  /* either we have !SRCPFX && src_p == NULL, or SRCPFX && src_p != NULL */
+  assert (!(api->message & ZAPI_MESSAGE_SRCPFX) == !src_p);
+
   /* Reset stream. */
   s = zclient->obuf;
   stream_reset (s);
@@ -878,6 +881,13 @@ zapi_ipv6_route (u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p,
   stream_putc (s, p->prefixlen);
   stream_write (s, (u_char *)&p->prefix, psize);
 
+  if (CHECK_FLAG (api->message, ZAPI_MESSAGE_SRCPFX))
+    {
+      psize = PSIZE (src_p->prefixlen);
+      stream_putc (s, src_p->prefixlen);
+      stream_write (s, (u_char *)&src_p->prefix, psize);
+    }
+
   /* Nexthop, ifindex, distance and metric information. */
   if (CHECK_FLAG (api->message, ZAPI_MESSAGE_NEXTHOP))
     {
index 7808fd804f73e5150d8abd7671d83b5f219f6a56..6b1a18a311868db2ad679247fef6c59c7a0d67c7 100644 (file)
@@ -246,7 +246,8 @@ struct zapi_ipv6
 };
 
 extern int zapi_ipv6_route (u_char cmd, struct zclient *zclient, 
-                     struct prefix_ipv6 *p, struct zapi_ipv6 *api);
+                     struct prefix_ipv6 *p, struct prefix_ipv6 *src_p,
+                     struct zapi_ipv6 *api);
 extern int zapi_ipv4_route_ipv6_nexthop (u_char, struct zclient *,
                                          struct prefix_ipv4 *, struct zapi_ipv6 *);
 
index a5303fb1b8717c996f00c6cd4e3fd9d8cd9af8bf..c20311e92f117c6ee152fd3ad84cf72ed1b1fb0e 100644 (file)
@@ -463,9 +463,9 @@ ospf6_zebra_route_update (int type, struct ospf6_route *request)
   api.distance = ospf6_distance_apply (dest, request);
 
   if (type == REM)
-    ret = zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, dest, &api);
+    ret = zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, dest, NULL, &api);
   else
-    ret = zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, dest, &api);
+    ret = zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, dest, NULL, &api);
 
   if (ret < 0)
     zlog_err ("zapi_ipv6_route() %s failed: %s",
@@ -527,7 +527,7 @@ ospf6_zebra_add_discard (struct ospf6_route *request)
 
          dest = (struct prefix_ipv6 *) &request->prefix;
 
-         zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, dest, &api);
+         zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, dest, NULL, &api);
 
          if (IS_OSPF6_DEBUG_ZEBRA (SEND))
            zlog_debug ("Zebra: Route add discard %s/%d",
@@ -572,7 +572,7 @@ ospf6_zebra_delete_discard (struct ospf6_route *request)
 
          dest = (struct prefix_ipv6 *) &request->prefix;
 
-         zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, dest, &api);
+         zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, dest, NULL, &api);
 
          if (IS_OSPF6_DEBUG_ZEBRA (SEND))
            zlog_debug ("Zebra: Route delete discard %s/%d",
index 5de785a6b8a88bfed56a8714fd33cce14a5c3a55..970aa14df6b5a8c9c280ee81a780d35ce22e8cec 100644 (file)
@@ -99,7 +99,7 @@ ripng_zebra_ipv6_send (struct route_node *rp, u_char cmd)
         }
 
       zapi_ipv6_route (cmd, zclient,
-                       (struct prefix_ipv6 *)&rp->p, &api);
+                       (struct prefix_ipv6 *)&rp->p, NULL, &api);
 
       if (IS_RIPNG_DEBUG_ZEBRA)
         {