summaryrefslogtreecommitdiffstats
path: root/lib/netns_linux.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 /lib/netns_linux.c
parentzebra: local mac entries populated in correct netnamespace (diff)
downloadfrr-2961d0601c7d168eed5bbe8e95f80a642f9cb4b5.tar.xz
frr-2961d0601c7d168eed5bbe8e95f80a642f9cb4b5.zip
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 'lib/netns_linux.c')
-rw-r--r--lib/netns_linux.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/netns_linux.c b/lib/netns_linux.c
index 0109b3db6..e8d549b4e 100644
--- a/lib/netns_linux.c
+++ b/lib/netns_linux.c
@@ -51,7 +51,7 @@ static struct ns *ns_lookup_name_internal(const char *name);
RB_GENERATE(ns_head, ns, entry, ns_compare)
-struct ns_head ns_tree = RB_INITIALIZER(&ns_tree);
+static struct ns_head ns_tree = RB_INITIALIZER(&ns_tree);
static struct ns *default_ns;
static int ns_current_ns_fd;
@@ -379,12 +379,20 @@ struct ns *ns_lookup(ns_id_t ns_id)
return ns_lookup_internal(ns_id);
}
-void ns_walk_func(int (*func)(struct ns *))
+void ns_walk_func(int (*func)(struct ns *,
+ void *param_in,
+ void **param_out),
+ void *param_in,
+ void **param_out)
{
struct ns *ns = NULL;
+ int ret;
- RB_FOREACH (ns, ns_head, &ns_tree)
- func(ns);
+ RB_FOREACH (ns, ns_head, &ns_tree) {
+ ret = func(ns, param_in, param_out);
+ if (ret == NS_WALK_STOP)
+ return;
+ }
}
const char *ns_get_name(struct ns *ns)