[quagga-dev 11778] [PATCH 03/13] lib: send ZAPI IPv6 source prefix

David Lamparter equinox at opensourcerouting.org
Sat Nov 22 06:42:43 GMT 2014


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 at opensourcerouting.org>
---
 babeld/kernel.c      |  2 +-
 bgpd/bgp_zebra.c     |  4 ++--
 isisd/isis_zebra.c   |  4 ++--
 lib/zclient.c        | 12 +++++++++++-
 lib/zclient.h        |  5 +++--
 ospf6d/ospf6_zebra.c |  4 ++--
 ripngd/ripng_zebra.c |  4 ++--
 7 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/babeld/kernel.c b/babeld/kernel.c
index efbb700..cff51ba 100644
--- a/babeld/kernel.c
+++ b/babeld/kernel.c
@@ -252,7 +252,7 @@ kernel_route_v6(int add, const unsigned char *pref, unsigned short plen,
            add ? "adding" : "removing" );
     return zapi_ipv6_route (add ? ZEBRA_IPV6_ROUTE_ADD :
                                   ZEBRA_IPV6_ROUTE_DELETE,
-                            zclient, &quagga_prefix, &api);
+                            zclient, &quagga_prefix, NULL, &api);
 }
 
 int
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index f18d916..0ba51b4 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -822,7 +822,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp, sa
 	}
 
       zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, 
-                       (struct prefix_ipv6 *) p, &api);
+                       (struct prefix_ipv6 *) p, NULL, &api);
     }
 #endif /* HAVE_IPV6 */
 }
@@ -939,7 +939,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);
     }
 #endif /* HAVE_IPV6 */
 }
diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c
index 2df7462..4492e14 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -392,7 +392,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);
     }
@@ -471,7 +471,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);
     }
 
diff --git a/lib/zclient.c b/lib/zclient.c
index 3b5477e..5e63e8c 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -522,12 +522,15 @@ zapi_ipv4_route (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p,
 #ifdef HAVE_IPV6
 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);
@@ -545,6 +548,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))
     {
diff --git a/lib/zclient.h b/lib/zclient.h
index 8c90132..f2e22e0 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -184,8 +184,9 @@ struct zapi_ipv6
   u_int32_t metric;
 };
 
-extern int zapi_ipv6_route (u_char cmd, struct zclient *zclient, 
-                     struct prefix_ipv6 *p, struct zapi_ipv6 *api);
+extern int zapi_ipv6_route (u_char cmd, struct zclient *zclient,
+			    struct prefix_ipv6 *p, struct prefix_ipv6 *src_p,
+			    struct zapi_ipv6 *api);
 #endif /* HAVE_IPV6 */
 
 #endif /* _ZEBRA_ZCLIENT_H */
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index 85f7064..9a5c149 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -471,9 +471,9 @@ ospf6_zebra_route_update (int type, struct ospf6_route *request)
 
   dest = (struct prefix_ipv6 *) &request->prefix;
   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",
diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c
index 68f37be..25caa46 100644
--- a/ripngd/ripng_zebra.c
+++ b/ripngd/ripng_zebra.c
@@ -63,7 +63,7 @@ ripng_zebra_ipv6_add (struct prefix_ipv6 *p, struct in6_addr *nexthop,
       SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
       api.metric = metric;
       
-      zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, p, &api);
+      zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, p, NULL, &api);
     }
 }
 
@@ -86,7 +86,7 @@ ripng_zebra_ipv6_delete (struct prefix_ipv6 *p, struct in6_addr *nexthop,
       api.ifindex_num = 1;
       api.ifindex = &ifindex;
 
-      zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, p, &api);
+      zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, p, NULL, &api);
     }
 }
 
-- 
1.8.5.5





More information about the Quagga-dev mailing list