From 7c990878f20efff335c1211deda3ec50071ae2b5 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 1 Oct 2019 11:07:13 +0200 Subject: [PATCH] zebra: map vxlan interface to bridge interface with correct ns id an incoming bridge index has been found, that is linked with vxlan interface, and the search for that bridge interface is done. In vrf-lite, the search is done across the same default namespace, because bridge and vxlan may not be in the same vrf. But this behaviour is wrong when using vrf netns backend, as the bridge and the vxlan have to be in the same vrf ( hence in the same network namespace). To comply with that, use the netnamespace of the vxlan interface. Like that, the appropriate nsid is passed as parameter, and consequently, the search is correct, and the mac address passed to BGP will be ok too. Signed-off-by: Philippe Guibert --- zebra/zebra_l2.c | 14 ++++++++++---- zebra/zebra_l2.h | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/zebra/zebra_l2.c b/zebra/zebra_l2.c index e549d80a5c..d12fb3e30d 100644 --- a/zebra/zebra_l2.c +++ b/zebra/zebra_l2.c @@ -83,12 +83,14 @@ static void map_slaves_to_bridge(struct interface *br_if, int link) } /* Public functions */ -void zebra_l2_map_slave_to_bridge(struct zebra_l2info_brslave *br_slave) +void zebra_l2_map_slave_to_bridge(struct zebra_l2info_brslave *br_slave, + struct zebra_ns *zns) { struct interface *br_if; /* TODO: Handle change of master */ - br_if = if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT), + assert(zns); + br_if = if_lookup_by_index_per_ns(zebra_ns_lookup(zns->ns_id), br_slave->bridge_ifindex); if (br_if) br_slave->br_if = br_if; @@ -241,19 +243,23 @@ void zebra_l2if_update_bridge_slave(struct interface *ifp, { struct zebra_if *zif; ifindex_t old_bridge_ifindex; + struct zebra_vrf *zvrf; zif = ifp->info; assert(zif); + zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id); + if (!zvrf) + return; + old_bridge_ifindex = zif->brslave_info.bridge_ifindex; if (old_bridge_ifindex == bridge_ifindex) return; zif->brslave_info.bridge_ifindex = bridge_ifindex; - /* Set up or remove link with master */ if (bridge_ifindex != IFINDEX_INTERNAL) { - zebra_l2_map_slave_to_bridge(&zif->brslave_info); + zebra_l2_map_slave_to_bridge(&zif->brslave_info, zvrf->zns); /* In the case of VxLAN, invoke the handler for EVPN. */ if (zif->zif_type == ZEBRA_IF_VXLAN) zebra_vxlan_if_update(ifp, ZEBRA_VXLIF_MASTER_CHANGE); diff --git a/zebra/zebra_l2.h b/zebra/zebra_l2.h index 23875331f7..3e8de79951 100644 --- a/zebra/zebra_l2.h +++ b/zebra/zebra_l2.h @@ -81,7 +81,8 @@ union zebra_l2if_info { #define IS_ZEBRA_IF_BRIDGE_VLAN_AWARE(zif) ((zif)->l2info.br.vlan_aware == 1) -extern void zebra_l2_map_slave_to_bridge(struct zebra_l2info_brslave *br_slave); +extern void zebra_l2_map_slave_to_bridge(struct zebra_l2info_brslave *br_slave, + struct zebra_ns *zns); extern void zebra_l2_unmap_slave_from_bridge(struct zebra_l2info_brslave *br_slave); extern void -- 2.39.5