From f13fdc673c1a51df0cda0952da390f4d10a0ecd7 Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Thu, 14 Oct 2021 21:06:38 +0300 Subject: [PATCH] zebra: fix ptm message processing When PTM sends a "cbl status" message it specifies the interface name but not the VRF name. It is fine for VRF-lite, but doesn't work for netns because it's possible to have multiple interfaces with the same name. Be more restrictive in this case and return an error instead of randomly using of the interface with the specified name. Signed-off-by: Igor Ryzhov --- zebra/zebra_ptm.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index e17465b112..ec68f585e3 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -609,7 +609,17 @@ static int zebra_ptm_handle_msg_cb(void *arg, void *in_ctxt) } if (strcmp(ZEBRA_PTM_INVALID_PORT_NAME, port_str)) { - ifp = if_lookup_by_name_all_vrf(port_str); + struct vrf *vrf; + int count = 0; + + RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) { + ifp = if_lookup_by_name_vrf(ifname, vrf); + if (ifp) { + count++; + if (!vrf_is_backend_netns()) + break; + } + } if (!ifp) { flog_warn(EC_ZEBRA_UNKNOWN_INTERFACE, @@ -617,6 +627,12 @@ static int zebra_ptm_handle_msg_cb(void *arg, void *in_ctxt) __func__, port_str); return -1; } + if (count > 1) { + flog_warn(EC_ZEBRA_UNKNOWN_INTERFACE, + "%s: multiple interface with name %s", + __func__, port_str); + return -1; + } } ptm_lib_find_key_in_msg(in_ctxt, ZEBRA_PTM_CBL_STR, cbl_str);