summaryrefslogtreecommitdiff
path: root/zebra/zebra_vxlan.c
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2019-12-20 17:51:37 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2020-09-11 18:26:23 +0200
commit2961d0601c7d168eed5bbe8e95f80a642f9cb4b5 (patch)
tree940c64d4ab3be5613752b36d78f027e28291324c /zebra/zebra_vxlan.c
parentb5fde6fd5c41b99ff205b1139490db49acab1667 (diff)
lib, zebra: reuse and adapt ns_list walk functionality
the walk routine is used by vxlan service to identify some contexts in each specific network namespace, when vrf netns backend is used. that walk mechanism is extended with some additional paramters to the walk routine. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'zebra/zebra_vxlan.c')
-rw-r--r--zebra/zebra_vxlan.c69
1 files changed, 38 insertions, 31 deletions
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 6332854e73..61498973e9 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -782,10 +782,11 @@ static void zl3vni_print_hash_detail(struct hash_bucket *bucket, void *data)
vty_out(vty, "\n");
}
-static int zvni_map_to_svi_ns(struct zebra_ns *zns,
+static int zvni_map_to_svi_ns(struct ns *ns,
void *_in_param,
void **_p_ifp)
{
+ struct zebra_ns *zns = ns->info;
struct route_node *rn;
struct zebra_from_svi_param *in_param =
(struct zebra_from_svi_param *)_in_param;
@@ -795,7 +796,7 @@ static int zvni_map_to_svi_ns(struct zebra_ns *zns,
struct zebra_if *zif;
if (!in_param)
- return ZNS_WALK_STOP;
+ return NS_WALK_STOP;
/* TODO: Optimize with a hash. */
for (rn = route_top(zns->if_table); rn; rn = route_next(rn)) {
@@ -812,10 +813,10 @@ static int zvni_map_to_svi_ns(struct zebra_ns *zns,
if (vl->vid == in_param->vid) {
if (p_ifp)
*p_ifp = tmp_if;
- return ZNS_WALK_STOP;
+ return NS_WALK_STOP;
}
}
- return ZNS_WALK_CONTINUE;
+ return NS_WALK_CONTINUE;
}
/* Map to SVI on bridge corresponding to specified VLAN. This can be one
@@ -850,8 +851,8 @@ struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if)
in_param.zif = NULL;
p_ifp = &tmp_if;
/* Identify corresponding VLAN interface. */
- zebra_ns_list_walk(zvni_map_to_svi_ns, (void *)&in_param,
- (void **)p_ifp);
+ ns_walk_func(zvni_map_to_svi_ns, (void *)&in_param,
+ (void **)p_ifp);
return tmp_if;
}
@@ -865,10 +866,11 @@ static int zebra_evpn_vxlan_del(zebra_evpn_t *zevpn)
return zebra_evpn_del(zevpn);
}
-static int zevpn_build_hash_table_zns(struct zebra_ns *zns,
+static int zevpn_build_hash_table_zns(struct ns *ns,
void *param_in __attribute__((unused)),
void **param_out __attribute__((unused)))
{
+ struct zebra_ns *zns = ns->info;
struct route_node *rn;
struct interface *ifp;
struct zebra_vrf *zvrf;
@@ -876,7 +878,7 @@ static int zevpn_build_hash_table_zns(struct zebra_ns *zns,
zvrf = zebra_vrf_get_evpn();
if (!zvrf)
- return ZNS_WALK_STOP;
+ return NS_WALK_STOP;
/* Walk VxLAN interfaces and create EVPN hash. */
for (rn = route_top(zns->if_table); rn; rn = route_next(rn)) {
@@ -972,7 +974,7 @@ static int zevpn_build_hash_table_zns(struct zebra_ns *zns,
zlog_debug(
"Failed to add EVPN hash, IF %s(%u) L2-VNI %u",
ifp->name, ifp->ifindex, vni);
- return ZNS_WALK_CONTINUE;
+ return NS_WALK_CONTINUE;
}
if (zevpn->local_vtep_ip.s_addr !=
@@ -1014,7 +1016,7 @@ static int zevpn_build_hash_table_zns(struct zebra_ns *zns,
}
}
}
- return ZNS_WALK_CONTINUE;
+ return NS_WALK_CONTINUE;
}
/*
@@ -1024,9 +1026,9 @@ static int zevpn_build_hash_table_zns(struct zebra_ns *zns,
static void zevpn_build_hash_table(void)
{
- zebra_ns_list_walk(zevpn_build_hash_table_zns,
- (void *)NULL,
- (void **)NULL);
+ ns_walk_func(zevpn_build_hash_table_zns,
+ (void *)NULL,
+ (void **)NULL);
}
/*
@@ -1659,10 +1661,11 @@ static int zl3vni_del(zebra_l3vni_t *zl3vni)
return 0;
}
-static int zl3vni_map_to_vxlan_if_zns(struct zebra_ns *zns,
- void *_zl3vni,
- void **_pifp)
+static int zl3vni_map_to_vxlan_if_ns(struct ns *ns,
+ void *_zl3vni,
+ void **_pifp)
{
+ struct zebra_ns *zns = ns->info;
zebra_l3vni_t *zl3vni = (zebra_l3vni_t *)_zl3vni;
struct route_node *rn = NULL;
struct interface *ifp = NULL;
@@ -1671,7 +1674,7 @@ static int zl3vni_map_to_vxlan_if_zns(struct zebra_ns *zns,
zvrf = zebra_vrf_get_evpn();
if (!zvrf)
- return ZNS_WALK_STOP;
+ return NS_WALK_STOP;
/* loop through all vxlan-interface */
for (rn = route_top(zns->if_table); rn; rn = route_next(rn)) {
@@ -1705,10 +1708,10 @@ static int zl3vni_map_to_vxlan_if_zns(struct zebra_ns *zns,
zl3vni->local_vtep_ip = vxl->vtep_ip;
if (_pifp)
*_pifp = (void *)ifp;
- return ZNS_WALK_STOP;
+ return NS_WALK_STOP;
}
- return ZNS_WALK_CONTINUE;
+ return NS_WALK_CONTINUE;
}
struct interface *zl3vni_map_to_vxlan_if(zebra_l3vni_t *zl3vni)
@@ -1718,8 +1721,8 @@ struct interface *zl3vni_map_to_vxlan_if(zebra_l3vni_t *zl3vni)
p_ifp = &ifp;
- zebra_ns_list_walk(zl3vni_map_to_vxlan_if_zns,
- (void *)zl3vni, (void **)p_ifp);
+ ns_walk_func(zl3vni_map_to_vxlan_if_ns,
+ (void *)zl3vni, (void **)p_ifp);
return ifp;
}
@@ -5521,20 +5524,24 @@ stream_failure:
return;
}
-static int macfdb_read_zns(struct zebra_ns *zns,
- void *_in_param __attribute__((unused)),
- void **out_param __attribute__((unused)))
+static int macfdb_read_ns(struct ns *ns,
+ void *_in_param __attribute__((unused)),
+ void **out_param __attribute__((unused)))
{
+ struct zebra_ns *zns = ns->info;
+
macfdb_read(zns);
- return ZNS_WALK_CONTINUE;
+ return NS_WALK_CONTINUE;
}
-static int neigh_read_zns(struct zebra_ns *zns,
- void *_in_param __attribute__((unused)),
- void **out_param __attribute__((unused)))
+static int neigh_read_ns(struct ns *ns,
+ void *_in_param __attribute__((unused)),
+ void **out_param __attribute__((unused)))
{
+ struct zebra_ns *zns = ns->info;
+
neigh_read(zns);
- return ZNS_WALK_CONTINUE;
+ return NS_WALK_CONTINUE;
}
/*
@@ -5588,10 +5595,10 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
zebra_evpn_gw_macip_add_for_evpn_hash, NULL);
/* Read the MAC FDB */
- zebra_ns_list_walk(macfdb_read_zns, NULL, NULL);
+ ns_walk_func(macfdb_read_ns, NULL, NULL);
/* Read neighbors */
- zebra_ns_list_walk(neigh_read_zns, NULL, NULL);
+ ns_walk_func(neigh_read_ns, NULL, NULL);
} else {
/* Cleanup VTEPs for all EVPNs - uninstall from
* kernel and free entries.