diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/zclient.c | 33 | ||||
-rw-r--r-- | lib/zclient.h | 9 |
2 files changed, 25 insertions, 17 deletions
diff --git a/lib/zclient.c b/lib/zclient.c index 0d531ce7..8be9d040 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -405,10 +405,10 @@ 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_ + * Alternatively, if the route is a blackhole route (indicated to zapi + * by ZAPI_MESSAGE_BLACKHOLE), then Nexthop count is set to 1 and _no_ * nexthop information is provided, and the message describes a prefix - * to blackhole or reject route. + * to blackhole route. * * If ZAPI_MESSAGE_DISTANCE is set, the distance value is written as a 1 * byte value. @@ -424,8 +424,18 @@ zapi_ipv4_route (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p, { int i; int psize; + int blackhole = 0; struct stream *s; + /* blackhole routes are sent as containing a single nexthop + * of type blackhole. */ + if (CHECK_FLAG (api->message, ZAPI_MESSAGE_BLACKHOLE)) + { + blackhole = 1; + UNSET_FLAG (api->message, ZAPI_MESSAGE_BLACKHOLE); + SET_FLAG (api->message, ZAPI_MESSAGE_NEXTHOP); + } + /* Reset stream. */ s = zclient->obuf; stream_reset (s); @@ -443,17 +453,14 @@ zapi_ipv4_route (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p, stream_write (s, (u_char *) & p->prefix, psize); /* Nexthop, ifindex, distance and metric information. */ - if (CHECK_FLAG (api->message, ZAPI_MESSAGE_NEXTHOP)) + if (blackhole) { - if (CHECK_FLAG (api->flags, ZEBRA_FLAG_BLACKHOLE)) - { - stream_putc (s, 1); - stream_putc (s, ZEBRA_NEXTHOP_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, 1); + stream_putc (s, ZEBRA_NEXTHOP_BLACKHOLE); + } + else if (CHECK_FLAG (api->message, ZAPI_MESSAGE_NEXTHOP)) + { + stream_putc (s, api->nexthop_num + api->ifindex_num); for (i = 0; i < api->nexthop_num; i++) { diff --git a/lib/zclient.h b/lib/zclient.h index 6a63ffa4..7cce73f5 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -85,10 +85,11 @@ struct zclient }; /* Zebra API message flag. */ -#define ZAPI_MESSAGE_NEXTHOP 0x01 -#define ZAPI_MESSAGE_IFINDEX 0x02 -#define ZAPI_MESSAGE_DISTANCE 0x04 -#define ZAPI_MESSAGE_METRIC 0x08 +#define ZAPI_MESSAGE_NEXTHOP 0x01 +#define ZAPI_MESSAGE_IFINDEX 0x02 +#define ZAPI_MESSAGE_DISTANCE 0x04 +#define ZAPI_MESSAGE_METRIC 0x08 +#define ZAPI_MESSAGE_BLACKHOLE 0x10 /* only for zapi_ipv4_route */ /* Zserv protocol message header */ struct zserv_header |