From: David Lamparter Date: Thu, 24 Apr 2014 15:30:26 +0000 (+0200) Subject: lib: send ZAPI IPv6 source prefix X-Git-Tag: frr-3.0-branchpoint~59^2~9 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=d75f3b00e74de3350202848d62b2bfbcdd1c0dae;p=mirror%2Ffrr.git lib: send ZAPI IPv6 source prefix 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 --- diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 8bc7bd3025..7c778122b9 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -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); } } diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index 608bc6d3c7..d659e964cd 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -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 { diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index dfb9b4d7ab..e7bd99c3e8 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -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); } diff --git a/lib/zclient.c b/lib/zclient.c index 42fa41c9c8..92662fd70f 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -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)) { diff --git a/lib/zclient.h b/lib/zclient.h index 7808fd804f..6b1a18a311 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -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 *); diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index a5303fb1b8..c20311e92f 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -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", diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index 5de785a6b8..970aa14df6 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -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) {