[patch net-2.6.25 2/2][NETNS] net: Add a helper function neigh_param_default_alloc
From: Daniel Lezcano <hidden>
Date: 2007-12-21 14:51:54
In the presence of multiple network namespaces the logic needed to allocate the a default parameter table is just barely non-trivial. So add a function to automate it to make everyone's life easier. Signed-off-by: Eric W. Biederman <redacted> Signed-off-by: Daniel Lezcano <redacted> --- include/net/neighbour.h | 1 + net/core/neighbour.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) Index: net-2.6.25/include/net/neighbour.h ===================================================================
--- net-2.6.25.orig/include/net/neighbour.h
+++ net-2.6.25/include/net/neighbour.h@@ -208,6 +208,7 @@ extern struct neighbour *neigh_event_ns struct net_device *dev); extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl); +extern struct neigh_parms *neigh_parms_alloc_default(struct neigh_table *tbl, struct net *net); extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms); extern void neigh_parms_destroy(struct neigh_parms *parms); extern unsigned long neigh_rand_reach_time(unsigned long base);
Index: net-2.6.25/net/core/neighbour.c ===================================================================
--- net-2.6.25.orig/net/core/neighbour.c
+++ net-2.6.25/net/core/neighbour.c@@ -1325,6 +1325,20 @@ struct neigh_parms *neigh_parms_alloc(st return p; } +struct neigh_parms *neigh_parms_alloc_default(struct neigh_table *tbl, + struct net *net) +{ + struct neigh_parms *parms; + if (net != &init_net) { + parms = neigh_parms_alloc(NULL, tbl); + release_net(parms->net); + parms->net = hold_net(net); + } + else + parms = neigh_parms_clone(&tbl->parms); + return parms; +} + static void neigh_rcu_free_parms(struct rcu_head *head) { struct neigh_parms *parms =
@@ -2787,6 +2801,7 @@ EXPORT_SYMBOL(neigh_ifdown); EXPORT_SYMBOL(neigh_lookup); EXPORT_SYMBOL(neigh_lookup_nodev); EXPORT_SYMBOL(neigh_parms_alloc); +EXPORT_SYMBOL(neigh_parms_alloc_default); EXPORT_SYMBOL(neigh_parms_release); EXPORT_SYMBOL(neigh_rand_reach_time); EXPORT_SYMBOL(neigh_resolve_output);
--