From a8a20c4e3c602fb132090178799813a2dfcf3c4a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 4 Feb 2019 11:45:31 -0500 Subject: [PATCH 1/3] zebra: Remove zclient->idinfo restrictions The restricting of data about interfaces was both inconsistent in application and allowed protocol developers to get into states where they did not have the expected data about an interface that they thought that they would. These restrictions and inconsistencies keep causing bugs that have to be sorted through. The latest iteration of this bug was that commit: f20b478ef3d25e153939516a473bb2e80603cbd5 Has caused pim to not receive interface up notifications( but it knows the interface is back in the vrf and it knows the relevant ip addresses on the interface as they were changed as part of an ifdown/ifup cycle ). Remove this restriction and allow the interface events to be propagated to all clients. Signed-off-by: Donald Sharp --- zebra/redistribute.c | 25 +++++++++++-------------- zebra/zapi_msg.c | 11 ----------- zebra/zebra_ptm_redistribute.c | 4 ---- zebra/zserv.c | 2 -- zebra/zserv.h | 3 --- 5 files changed, 11 insertions(+), 34 deletions(-) diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 9c3002e775..f98a4c02c3 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -406,12 +406,11 @@ void zebra_interface_up_update(struct interface *ifp) if (ifp->ptm_status || !ifp->ptm_enable) { for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, - client)) - if (vrf_bitmap_check(client->ifinfo, ifp->vrf_id)) { - zsend_interface_update(ZEBRA_INTERFACE_UP, - client, ifp); - zsend_interface_link_params(client, ifp); - } + client)) { + zsend_interface_update(ZEBRA_INTERFACE_UP, + client, ifp); + zsend_interface_link_params(client, ifp); + } } } @@ -440,12 +439,11 @@ void zebra_interface_add_update(struct interface *ifp) zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADD %s(%u)", ifp->name, ifp->vrf_id); - for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) - if (vrf_bitmap_check(client->ifinfo, ifp->vrf_id)) { - client->ifadd_cnt++; - zsend_interface_add(client, ifp); - zsend_interface_link_params(client, ifp); - } + for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) { + client->ifadd_cnt++; + zsend_interface_add(client, ifp); + zsend_interface_link_params(client, ifp); + } } void zebra_interface_delete_update(struct interface *ifp) @@ -814,6 +812,5 @@ void zebra_interface_parameters_update(struct interface *ifp) ifp->name, ifp->vrf_id); for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) - if (vrf_bitmap_check(client->ifinfo, ifp->vrf_id)) - zsend_interface_link_params(client, ifp); + zsend_interface_link_params(client, ifp); } diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 611d859aaa..3bf03039b1 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -209,12 +209,6 @@ int zsend_interface_link_params(struct zserv *client, struct interface *ifp) { struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ); - /* Check this client need interface information. */ - if (!vrf_bitmap_check(client->ifinfo, ifp->vrf_id)) { - stream_free(s); - return 0; - } - if (!ifp->link_params) { stream_free(s); return 0; @@ -1317,9 +1311,6 @@ static void zread_interface_add(ZAPI_HANDLER_ARGS) struct vrf *vrf; struct interface *ifp; - /* Interface information is needed. */ - vrf_bitmap_set(client->ifinfo, zvrf_id(zvrf)); - RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) { FOR_ALL_INTERFACES (vrf, ifp) { /* Skip pseudo interface. */ @@ -1336,7 +1327,6 @@ static void zread_interface_add(ZAPI_HANDLER_ARGS) /* Unregister zebra server interface information. */ static void zread_interface_delete(ZAPI_HANDLER_ARGS) { - vrf_bitmap_unset(client->ifinfo, zvrf_id(zvrf)); } void zserv_nexthop_num_warn(const char *caller, const struct prefix *p, @@ -1731,7 +1721,6 @@ static void zread_vrf_unregister(ZAPI_HANDLER_ARGS) vrf_bitmap_unset(client->redist[afi][i], 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/zebra_ptm_redistribute.c b/zebra/zebra_ptm_redistribute.c index 0c24c732a4..01d5114b9f 100644 --- a/zebra/zebra_ptm_redistribute.c +++ b/zebra/zebra_ptm_redistribute.c @@ -36,10 +36,6 @@ static int zsend_interface_bfd_update(int cmd, struct zserv *client, int blen; struct stream *s; - /* Check this client need interface information. */ - if (!vrf_bitmap_check(client->ifinfo, ifp->vrf_id)) - return 0; - s = stream_new(ZEBRA_MAX_PACKET_SIZ); zclient_create_header(s, cmd, vrf_id); diff --git a/zebra/zserv.c b/zebra/zserv.c index e4fc348b1a..ad052d6a70 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -626,7 +626,6 @@ static void zserv_client_free(struct zserv *client) vrf_bitmap_free(client->redist_default[afi]); } - vrf_bitmap_free(client->ifinfo); vrf_bitmap_free(client->ridinfo); XFREE(MTYPE_TMP, client); @@ -710,7 +709,6 @@ static struct zserv *zserv_client_create(int sock) client->redist[afi][i] = vrf_bitmap_init(); client->redist_default[afi] = vrf_bitmap_init(); } - client->ifinfo = vrf_bitmap_init(); client->ridinfo = vrf_bitmap_init(); /* by default, it's not a synchronous client */ diff --git a/zebra/zserv.h b/zebra/zserv.h index f7c4e3df73..ac016e65f3 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -89,9 +89,6 @@ struct zserv { /* Redistribute default route flag. */ vrf_bitmap_t redist_default[AFI_MAX]; - /* Interface information. */ - vrf_bitmap_t ifinfo; - /* Router-id information. */ vrf_bitmap_t ridinfo; From 22761baa25a8a519da0ad814a46fff6825eb87fb Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 4 Feb 2019 12:22:55 -0500 Subject: [PATCH 2/3] lib: Send interface request after initial hello Ask for all interface information after we have connected to zebra and sent the initial hello. Signed-off-by: Donald Sharp --- lib/zclient.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/zclient.c b/lib/zclient.c index a01da77669..9db1dd74f2 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -414,9 +414,6 @@ void zclient_send_reg_requests(struct zclient *zclient, vrf_id_t vrf_id) /* We need router-id information. */ zebra_message_send(zclient, ZEBRA_ROUTER_ID_ADD, vrf_id); - /* We need interface information. */ - zebra_message_send(zclient, ZEBRA_INTERFACE_ADD, vrf_id); - /* Set unwanted redistribute route. */ for (afi = AFI_IP; afi < AFI_MAX; afi++) vrf_bitmap_set(zclient->redist[afi][zclient->redist_default], @@ -481,9 +478,6 @@ void zclient_send_dereg_requests(struct zclient *zclient, vrf_id_t vrf_id) /* We need router-id information. */ zebra_message_send(zclient, ZEBRA_ROUTER_ID_DELETE, vrf_id); - /* We need interface information. */ - zebra_message_send(zclient, ZEBRA_INTERFACE_DELETE, vrf_id); - /* Set unwanted redistribute route. */ for (afi = AFI_IP; afi < AFI_MAX; afi++) vrf_bitmap_unset(zclient->redist[afi][zclient->redist_default], @@ -596,6 +590,8 @@ int zclient_start(struct zclient *zclient) zebra_hello_send(zclient); + zebra_message_send(zclient, ZEBRA_INTERFACE_ADD, VRF_DEFAULT); + /* Inform the successful connection. */ if (zclient->zebra_connected) (*zclient->zebra_connected)(zclient); From ee568318946ae5c567e483a9866a43c61fe737ad Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 2 Feb 2019 15:52:14 -0500 Subject: [PATCH 3/3] pimd: Pim is not respecting the move of an interface from old->new vrf PIM needed to be updated to move to the new vrf. Signed-off-by: Donald Sharp --- pimd/pim_zebra.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index b7111cf7bf..11ca6e8a10 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -267,6 +267,27 @@ static int pim_zebra_if_state_down(int command, struct zclient *zclient, return 0; } +static int pim_zebra_interface_vrf_update(int command, struct zclient *zclient, + zebra_size_t length, vrf_id_t vrf_id) +{ + struct interface *ifp; + vrf_id_t new_vrf_id; + + ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id, + &new_vrf_id); + if (!ifp) + return 0; + + if (PIM_DEBUG_ZEBRA) + zlog_debug("%s: %s updating from %u to %u", + __PRETTY_FUNCTION__, + ifp->name, vrf_id, new_vrf_id); + + if_update_to_new_vrf(ifp, new_vrf_id); + + return 0; +} + #ifdef PIM_DEBUG_IFADDR_DUMP static void dump_if_address(struct interface *ifp) { @@ -762,6 +783,7 @@ void pim_zebra_init(void) zclient->interface_down = pim_zebra_if_state_down; zclient->interface_address_add = pim_zebra_if_address_add; zclient->interface_address_delete = pim_zebra_if_address_del; + zclient->interface_vrf_update = pim_zebra_interface_vrf_update; zclient->nexthop_update = pim_parse_nexthop_update; zclient_init(zclient, ZEBRA_ROUTE_PIM, 0, &pimd_privs);