From 3fa113f00cf15f8248db399b6da7210e8db3ceb4 Mon Sep 17 00:00:00 2001 From: radhika Date: Fri, 6 Jan 2017 12:54:25 -0800 Subject: [PATCH] bgpd, zebra: Fix for ignored non-default VRF single-hop BFD status messages in Quagga MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Ticket: CM-13425 Reviewed By: Donald, Kanna Testing Done: Unit, Min tests, PTM Smoke and Nightly, BGP Smoke Issue: BFD status up/down not reflected in the Quagga for non-default VRF single-hop BFD sessions. Root Cause: PTM doesn’t keep track of VRF for Single hop BFD sessions since they are interface-based sessions. The status up/down messages to the quagga for single hop sessions do not have VRF information. In zebra daemon, the interface search based on the interface name extracted from the BFD status message is done across all VRFs. So, the search does not fail in zebra daemon. But, the interface search in bgpd/ospd is done per vrf and default VRF is used for search if no VRF is sent in the status message. So, the search fails and the BFD status changes are ignored. Fix: The VRF information is extracted from the interface if VRF is not sent in the BFD status messages in zebra daemon and passed to bgpd/ospfd. The interface search will not fail since the appropriate VRF is passed to bgpd/ospfd and BFD satus changes are not ignored. Signed-off-by: Radhika Mahankali --- bgpd/bgp_bfd.c | 8 ++++---- zebra/zebra_ptm.c | 14 +++++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index ad221d922d..4f76fd17fb 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -311,14 +311,14 @@ bgp_bfd_dest_update (int command, struct zclient *zclient, prefix2str(&dp, buf[0], sizeof(buf[0])); if (ifp) { - zlog_debug("Zebra: interface %s bfd destination %s %s", - ifp->name, buf[0], bfd_get_status_str(status)); + zlog_debug("Zebra: vrf %d interface %s bfd destination %s %s", + vrf_id, ifp->name, buf[0], bfd_get_status_str(status)); } else { prefix2str(&sp, buf[1], sizeof(buf[1])); - zlog_debug("Zebra: source %s bfd destination %s %s", - buf[1], buf[0], bfd_get_status_str(status)); + zlog_debug("Zebra: vrf %d source %s bfd destination %s %s", + vrf_id, buf[1], buf[0], bfd_get_status_str(status)); } } diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index c5223199a4..a633ce6332 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -459,6 +459,7 @@ zebra_ptm_handle_bfd_msg(void *arg, void *in_ctxt, struct interface *ifp) char vrf_str[64]; struct prefix dest_prefix; struct prefix src_prefix; + vrf_id_t vrf_id; ptm_lib_find_key_in_msg(in_ctxt, ZEBRA_PTM_BFDSTATUS_STR, bfdst_str); @@ -491,7 +492,8 @@ zebra_ptm_handle_bfd_msg(void *arg, void *in_ctxt, struct interface *ifp) } if (IS_ZEBRA_DEBUG_EVENT) - zlog_debug("%s: Recv Port [%s] bfd status [%s] vrf [%s] peer [%s] local [%s]", + zlog_debug("%s: Recv Port [%s] bfd status [%s] vrf [%s]" + " peer [%s] local [%s]", __func__, ifp ? ifp->name : "N/A", bfdst_str, vrf_str, dest_str, src_str); @@ -510,12 +512,18 @@ zebra_ptm_handle_bfd_msg(void *arg, void *in_ctxt, struct interface *ifp) } } + if (!strcmp(ZEBRA_PTM_INVALID_VRF, vrf_str) && ifp) { + vrf_id = ifp->vrf_id; + } else { + vrf_id = vrf_name_to_id(vrf_str); + } + if (!strcmp (bfdst_str, ZEBRA_PTM_BFDSTATUS_DOWN_STR)) { if_bfd_session_update(ifp, &dest_prefix, &src_prefix, BFD_STATUS_DOWN, - vrf_name_to_id(vrf_str)); + vrf_id); } else { if_bfd_session_update(ifp, &dest_prefix, &src_prefix, BFD_STATUS_UP, - vrf_name_to_id(vrf_str)); + vrf_id); } return 0; -- 2.39.5