From 94758e6681f1983e0807493eb72a3bd6e7817f88 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Mon, 28 Aug 2017 06:01:13 +0200 Subject: [PATCH] lib, zebra: carry blackhole type over ZAPI Allow daemons to add blackholes of specific types (reject/drop.) Signed-off-by: David Lamparter --- lib/zclient.c | 2 ++ zebra/zserv.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/zclient.c b/lib/zclient.c index 992b254939..910e05cb47 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -928,6 +928,7 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api) stream_putc(s, api_nh->type); switch (api_nh->type) { case NEXTHOP_TYPE_BLACKHOLE: + stream_putc(s, api_nh->bh_type); break; case NEXTHOP_TYPE_IPV4: stream_put_in_addr(s, &api_nh->gate.ipv4); @@ -1040,6 +1041,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api) api_nh->type = stream_getc(s); switch (api_nh->type) { case NEXTHOP_TYPE_BLACKHOLE: + api_nh->bh_type = stream_getc(s); break; case NEXTHOP_TYPE_IPV4: api_nh->gate.ipv4.s_addr = stream_get_ipv4(s); diff --git a/zebra/zserv.c b/zebra/zserv.c index 46dfe37818..d60c8c9368 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -626,6 +626,7 @@ int zsend_redistribute_route(int cmd, struct zserv *client, struct prefix *p, api_nh->type = nexthop->type; switch (nexthop->type) { case NEXTHOP_TYPE_BLACKHOLE: + api_nh->bh_type = nexthop->bh_type; break; case NEXTHOP_TYPE_IPV4: api_nh->gate.ipv4 = nexthop->gate.ipv4; @@ -1051,7 +1052,6 @@ static int zread_route_add(struct zserv *client, u_short length, struct route_entry *re; struct nexthop *nexthop = NULL; int i, ret; - enum blackhole_type bh_type = BLACKHOLE_NULL; s = client->ibuf; if (zapi_route_decode(s, &api) < 0) @@ -1094,7 +1094,8 @@ static int zread_route_add(struct zserv *client, u_short length, api_nh->ifindex); break; case NEXTHOP_TYPE_BLACKHOLE: - route_entry_nexthop_blackhole_add(re, bh_type); + route_entry_nexthop_blackhole_add(re, + api_nh->bh_type); break; } -- 2.39.5