diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/nexthop.h | 7 | ||||
| -rw-r--r-- | lib/zclient.c | 32 | ||||
| -rw-r--r-- | lib/zclient.h | 15 |
3 files changed, 27 insertions, 27 deletions
diff --git a/lib/nexthop.h b/lib/nexthop.h index e7804379f1..12a1203a8f 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -43,6 +43,13 @@ enum nexthop_types_t { NEXTHOP_TYPE_BLACKHOLE, /* Null0 nexthop. */ }; +enum blackhole_type { + BLACKHOLE_UNSPEC = 0, + BLACKHOLE_NULL, + BLACKHOLE_REJECT, + BLACKHOLE_ADMINPROHIB, +}; + /* Nexthop label structure. */ struct nexthop_label { u_int8_t num_labels; diff --git a/lib/zclient.c b/lib/zclient.c index 72fa2679b3..992b254939 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -621,10 +621,9 @@ static int zclient_connect(struct thread *t) * | IPv4 Nexthop address or Interface Index number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * - * Alternatively, if the flags field has ZEBRA_FLAG_BLACKHOLE or - * ZEBRA_FLAG_REJECT is set then Nexthop count is set to 1, then _no_ - * nexthop information is provided, and the message describes a prefix - * to blackhole or reject route. + * Alternatively, if the route is a blackhole route, then Nexthop count + * is set to 1 and a nexthop of type NEXTHOP_TYPE_BLACKHOLE is the sole + * nexthop. * * The original struct zapi_ipv4, zapi_ipv4_route() and zread_ipv4_*() * infrastructure was built around the traditional (32-bit "gate OR @@ -692,14 +691,7 @@ int zapi_ipv4_route(u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p, /* Nexthop, ifindex, distance and metric information. */ if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) { - /* traditional 32-bit data units */ - if (CHECK_FLAG(api->flags, ZEBRA_FLAG_BLACKHOLE)) { - stream_putc(s, 1); - stream_putc(s, NEXTHOP_TYPE_BLACKHOLE); - /* XXX assert(api->nexthop_num == 0); */ - /* XXX assert(api->ifindex_num == 0); */ - } else - stream_putc(s, api->nexthop_num + api->ifindex_num); + stream_putc(s, api->nexthop_num + api->ifindex_num); for (i = 0; i < api->nexthop_num; i++) { stream_putc(s, NEXTHOP_TYPE_IPV4); @@ -769,13 +761,7 @@ int zapi_ipv4_route_ipv6_nexthop(u_char cmd, struct zclient *zclient, /* Nexthop, ifindex, distance and metric information. */ if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) { - if (CHECK_FLAG(api->flags, ZEBRA_FLAG_BLACKHOLE)) { - stream_putc(s, 1); - stream_putc(s, NEXTHOP_TYPE_BLACKHOLE); - /* XXX assert(api->nexthop_num == 0); */ - /* XXX assert(api->ifindex_num == 0); */ - } else - stream_putc(s, api->nexthop_num + api->ifindex_num); + stream_putc(s, api->nexthop_num + api->ifindex_num); for (i = 0; i < api->nexthop_num; i++) { stream_putc(s, NEXTHOP_TYPE_IPV6); @@ -855,13 +841,7 @@ int zapi_ipv6_route(u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p, /* Nexthop, ifindex, distance and metric information. */ if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) { - if (CHECK_FLAG(api->flags, ZEBRA_FLAG_BLACKHOLE)) { - stream_putc(s, 1); - stream_putc(s, NEXTHOP_TYPE_BLACKHOLE); - /* XXX assert(api->nexthop_num == 0); */ - /* XXX assert(api->ifindex_num == 0); */ - } else - stream_putc(s, api->nexthop_num + api->ifindex_num); + stream_putc(s, api->nexthop_num + api->ifindex_num); for (i = 0; i < api->nexthop_num; i++) { stream_putc(s, NEXTHOP_TYPE_IPV6); diff --git a/lib/zclient.h b/lib/zclient.h index 7c4780201e..e05e9d8ad9 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -222,7 +222,10 @@ struct zserv_header { struct zapi_nexthop { enum nexthop_types_t type; ifindex_t ifindex; - union g_addr gate; + union { + union g_addr gate; + enum blackhole_type bh_type; + }; /* MPLS labels for BGP-LU or Segment Routing */ uint8_t label_num; @@ -429,4 +432,14 @@ extern int zclient_route_send(u_char, struct zclient *, struct zapi_route *); extern int zapi_route_encode(u_char, struct stream *, struct zapi_route *); extern int zapi_route_decode(struct stream *, struct zapi_route *); +static inline void zapi_route_set_blackhole(struct zapi_route *api, + enum blackhole_type bh_type) +{ + api->nexthop_num = 1; + api->nexthops[0].type = NEXTHOP_TYPE_BLACKHOLE; + api->nexthops[0].bh_type = bh_type; + SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP); +}; + + #endif /* _ZEBRA_ZCLIENT_H */ |
