diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2019-01-11 22:20:13 +0100 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2019-01-14 14:41:33 +0100 |
commit | 49db7a7b055d69a8d3892a9171912b8b0f00aa45 (patch) | |
tree | cf173e30c23a4a5b682b3c15242e31615a540ec8 /zebra | |
parent | Merge pull request #3567 from donaldsharp/cleanup_route_table_creation (diff) | |
download | frr-49db7a7b055d69a8d3892a9171912b8b0f00aa45.tar.xz frr-49db7a7b055d69a8d3892a9171912b8b0f00aa45.zip |
lib, zebra: add AFI parameter to the ZEBRA_REDISTRIBUTE_DEFAULT_* messages
Some daemons like ospfd and isisd have the ability to advertise a
default route to their peers only if one exists in the RIB. This
is what the "default-information originate" commands do when used
without the "always" parameter.
For that to work, these daemons use the ZEBRA_REDISTRIBUTE_DEFAULT_ADD
message to request default route information to zebra. The problem
is that this message didn't have an AFI parameter, so a default route
from any address-family would satisfy the requests from both daemons
(e.g. ::/0 would trigger ospfd to advertise a default route to its
peers, and 0.0.0.0/0 would trigger isisd to advertise a default route
to its IPv6 peers).
Fix this by adding an AFI parameter to the
ZEBRA_REDISTRIBUTE_DEFAULT_{ADD,DELETE} messages and making the
corresponding code changes.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'zebra')
-rw-r--r-- | zebra/redistribute.c | 38 | ||||
-rw-r--r-- | zebra/zapi_msg.c | 5 | ||||
-rw-r--r-- | zebra/zserv.c | 10 | ||||
-rw-r--r-- | zebra/zserv.h | 2 |
4 files changed, 44 insertions, 11 deletions
diff --git a/zebra/redistribute.c b/zebra/redistribute.c index f48fc6add..b9c1f0aef 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -177,7 +177,8 @@ void redistribute_update(const struct prefix *p, const struct prefix *src_p, send_redistribute = 0; if (is_default_prefix(p) - && vrf_bitmap_check(client->redist_default, re->vrf_id)) + && vrf_bitmap_check(client->redist_default[afi], + re->vrf_id)) send_redistribute = 1; else if (vrf_bitmap_check(client->redist[afi][ZEBRA_ROUTE_ALL], re->vrf_id)) @@ -246,7 +247,8 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p, for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) { if ((is_default_prefix(p) - && vrf_bitmap_check(client->redist_default, re->vrf_id)) + && vrf_bitmap_check(client->redist_default[afi], + re->vrf_id)) || vrf_bitmap_check(client->redist[afi][ZEBRA_ROUTE_ALL], re->vrf_id) || (re->instance @@ -354,13 +356,41 @@ stream_failure: void zebra_redistribute_default_add(ZAPI_HANDLER_ARGS) { - vrf_bitmap_set(client->redist_default, zvrf_id(zvrf)); + afi_t afi = 0; + + STREAM_GETC(msg, afi); + + if (afi == 0 || afi >= AFI_MAX) { + flog_warn(EC_ZEBRA_REDISTRIBUTE_UNKNOWN_AF, + "%s: Specified afi %u does not exist", + __PRETTY_FUNCTION__, afi); + return; + } + + vrf_bitmap_set(client->redist_default[afi], zvrf_id(zvrf)); zebra_redistribute_default(client, zvrf_id(zvrf)); + +stream_failure: + return; } void zebra_redistribute_default_delete(ZAPI_HANDLER_ARGS) { - vrf_bitmap_unset(client->redist_default, zvrf_id(zvrf)); + afi_t afi = 0; + + STREAM_GETC(msg, afi); + + if (afi == 0 || afi >= AFI_MAX) { + flog_warn(EC_ZEBRA_REDISTRIBUTE_UNKNOWN_AF, + "%s: Specified afi %u does not exist", + __PRETTY_FUNCTION__, afi); + return; + } + + vrf_bitmap_unset(client->redist_default[afi], zvrf_id(zvrf)); + +stream_failure: + return; } /* Interface up information. */ diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index faa0eb90e..15f9da0cb 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1702,10 +1702,11 @@ static void zread_vrf_unregister(ZAPI_HANDLER_ARGS) int i; afi_t afi; - for (afi = AFI_IP; afi < AFI_MAX; afi++) + for (afi = AFI_IP; afi < AFI_MAX; afi++) { for (i = 0; i < ZEBRA_ROUTE_MAX; i++) vrf_bitmap_unset(client->redist[afi][i], zvrf_id(zvrf)); - vrf_bitmap_unset(client->redist_default, zvrf_id(zvrf)); + vrf_bitmap_unset(client->redist_default[afi], zvrf_id(zvrf)); + } vrf_bitmap_unset(client->ifinfo, zvrf_id(zvrf)); vrf_bitmap_unset(client->ridinfo, zvrf_id(zvrf)); } diff --git a/zebra/zserv.c b/zebra/zserv.c index a48505a51..502186d22 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -616,11 +616,12 @@ static void zserv_client_free(struct zserv *client) pthread_mutex_destroy(&client->ibuf_mtx); /* Free bitmaps. */ - for (afi_t afi = AFI_IP; afi < AFI_MAX; afi++) + for (afi_t afi = AFI_IP; afi < AFI_MAX; afi++) { for (int i = 0; i < ZEBRA_ROUTE_MAX; i++) vrf_bitmap_free(client->redist[afi][i]); - vrf_bitmap_free(client->redist_default); + vrf_bitmap_free(client->redist_default[afi]); + } vrf_bitmap_free(client->ifinfo); vrf_bitmap_free(client->ridinfo); @@ -700,10 +701,11 @@ static struct zserv *zserv_client_create(int sock) memory_order_relaxed); /* Initialize flags */ - for (afi = AFI_IP; afi < AFI_MAX; afi++) + for (afi = AFI_IP; afi < AFI_MAX; afi++) { for (i = 0; i < ZEBRA_ROUTE_MAX; i++) client->redist[afi][i] = vrf_bitmap_init(); - client->redist_default = vrf_bitmap_init(); + client->redist_default[afi] = vrf_bitmap_init(); + } client->ifinfo = vrf_bitmap_init(); client->ridinfo = vrf_bitmap_init(); diff --git a/zebra/zserv.h b/zebra/zserv.h index f0b8934ae..041485cdc 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -87,7 +87,7 @@ struct zserv { vrf_bitmap_t redist[AFI_MAX][ZEBRA_ROUTE_MAX]; /* Redistribute default route flag. */ - vrf_bitmap_t redist_default; + vrf_bitmap_t redist_default[AFI_MAX]; /* Interface information. */ vrf_bitmap_t ifinfo; |