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 <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2021-10-14 21:06:38 +03:00
parent 4030e1867b
commit f13fdc673c

View File

@ -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);