From 81a164e2d9919ac3a7842d5b90cd8b1dfc2a1e9a Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Wed, 8 Jul 2015 19:48:51 +0200 Subject: [PATCH] *: read and ignore srcdest routes on ZAPI Since zebra might be sending srcdest routes down to the various daemons, they need to understand the presence of the field at the very least. Sadly, that's also the best we can do at this point since none of the protocols has support for handling srcdest routes. The only consistent thing to do is to ignore them throughout. If an administrator wants to have the srcdest route as non-srcdest in a protocol, setting a non-srcdest static route (possibly blackhole) is probably the best way to go. Signed-off-by: David Lamparter --- bgpd/bgp_zebra.c | 14 +++++++++++++- bgpd/rfapi/vnc_zebra.c | 14 +++++++++++++- ldpd/ldp_zebra.c | 11 +++++++++++ ospf6d/ospf6_zebra.c | 14 +++++++++++++- ripngd/ripng_zebra.c | 14 +++++++++++++- 5 files changed, 63 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 7c778122b9..822f459c28 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -706,7 +706,7 @@ zebra_read_ipv6 (int command, struct zclient *zclient, zebra_size_t length, struct stream *s; struct zapi_ipv6 api; struct in6_addr nexthop; - struct prefix_ipv6 p; + struct prefix_ipv6 p, src_p; unsigned int ifindex; int i; struct bgp *bgp; @@ -730,6 +730,18 @@ zebra_read_ipv6 (int command, struct zclient *zclient, zebra_size_t length, p.prefixlen = MIN(IPV6_MAX_PREFIXLEN, stream_getc (s)); stream_get (&p.prefix, s, PSIZE (p.prefixlen)); + memset (&src_p, 0, sizeof (struct prefix_ipv6)); + src_p.family = AF_INET6; + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_SRCPFX)) + { + src_p.prefixlen = stream_getc (s); + stream_get (&src_p.prefix, s, PSIZE (src_p.prefixlen)); + } + + if (src_p.prefixlen) + /* we completely ignore srcdest routes for now. */ + return 0; + /* Nexthop, ifindex, distance, metric. */ if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) { diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index d659e964cd..85baa13301 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -433,7 +433,7 @@ vnc_zebra_read_ipv6 ( struct stream *s; struct zapi_ipv6 api; struct in6_addr nexthop; - struct prefix_ipv6 p; + struct prefix_ipv6 p, src_p; s = zclient->ibuf; memset (&nexthop, 0, sizeof (struct in6_addr)); @@ -449,6 +449,18 @@ vnc_zebra_read_ipv6 ( p.prefixlen = stream_getc (s); stream_get (&p.prefix, s, PSIZE (p.prefixlen)); + memset (&src_p, 0, sizeof (struct prefix_ipv6)); + src_p.family = AF_INET6; + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_SRCPFX)) + { + src_p.prefixlen = stream_getc (s); + stream_get (&src_p.prefix, s, PSIZE (src_p.prefixlen)); + } + + if (src_p.prefixlen) + /* we completely ignore srcdest routes for now. */ + return 0; + /* Nexthop, ifindex, distance, metric. */ if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) { diff --git a/ldpd/ldp_zebra.c b/ldpd/ldp_zebra.c index a233cb72e7..8e7c6e27f9 100644 --- a/ldpd/ldp_zebra.c +++ b/ldpd/ldp_zebra.c @@ -398,6 +398,17 @@ ldp_zebra_read_route(int command, struct zclient *zclient, zebra_size_t length, (kr.af == AF_INET6 && IN6_IS_SCOPE_EMBED(&kr.prefix.v6))) return (0); + if (kr.af == AF_INET6 && + CHECK_FLAG(message_flags, ZAPI_MESSAGE_SRCPFX)) { + uint8_t src_prefixlen; + + src_prefixlen = stream_getc(s); + + /* we completely ignore srcdest routes for now. */ + if (src_prefixlen) + return (0); + } + nhnum = stream_getc(s); nhmark = stream_get_getp(s); stream_set_getp(s, nhmark + nhnum * (nhlen + 5)); diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index c20311e92f..76bee9cf55 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -217,7 +217,7 @@ ospf6_zebra_read_ipv6 (int command, struct zclient *zclient, struct stream *s; struct zapi_ipv6 api; unsigned long ifindex; - struct prefix_ipv6 p; + struct prefix_ipv6 p, src_p; struct in6_addr *nexthop; if (ospf6 == NULL) @@ -240,6 +240,18 @@ ospf6_zebra_read_ipv6 (int command, struct zclient *zclient, p.prefixlen = MIN(IPV6_MAX_PREFIXLEN, stream_getc (s)); stream_get (&p.prefix, s, PSIZE (p.prefixlen)); + memset (&src_p, 0, sizeof (struct prefix_ipv6)); + src_p.family = AF_INET6; + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_SRCPFX)) + { + src_p.prefixlen = stream_getc (s); + stream_get (&src_p.prefix, s, PSIZE (src_p.prefixlen)); + } + + if (src_p.prefixlen) + /* we completely ignore srcdest routes for now. */ + return 0; + /* Nexthop, ifindex, distance, metric. */ if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) { diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index 970aa14df6..964af81d1f 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -140,7 +140,7 @@ ripng_zebra_read_ipv6 (int command, struct zclient *zclient, struct zapi_ipv6 api; unsigned long ifindex; struct in6_addr nexthop; - struct prefix_ipv6 p; + struct prefix_ipv6 p, src_p; s = zclient->ibuf; ifindex = 0; @@ -158,6 +158,18 @@ ripng_zebra_read_ipv6 (int command, struct zclient *zclient, p.prefixlen = MIN(IPV6_MAX_PREFIXLEN, stream_getc (s)); stream_get (&p.prefix, s, PSIZE (p.prefixlen)); + memset (&src_p, 0, sizeof (struct prefix_ipv6)); + src_p.family = AF_INET6; + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_SRCPFX)) + { + src_p.prefixlen = stream_getc (s); + stream_get (&src_p.prefix, s, PSIZE (src_p.prefixlen)); + } + + if (src_p.prefixlen) + /* we completely ignore srcdest routes for now. */ + return 0; + /* Nexthop, ifindex, distance, metric. */ if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) { -- 2.39.5