* [PATCH net-next 0/5] ipv6: cleanup after rt6_genid removal
@ 2014-10-06 8:52 Hannes Frederic Sowa
2014-10-06 8:52 ` [PATCH net-next 1/5] ipv6: minor fib6 cleanups like type safety, bool conversion, inline removal Hannes Frederic Sowa
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-10-06 8:52 UTC (permalink / raw)
To: netdev; +Cc: hideaki, kafai
Leftover patches after rt6_genid removal after 705f1c869d577c ("ipv6:
remove rt6i_genid").
Major two changes are:
* keep fib6_sernum per namespace to reduce number of flushes in case
system has high number of namespaces
* make fn_sernum updates cheaper
Hannes Frederic Sowa (5):
ipv6: minor fib6 cleanups like type safety, bool conversion, inline
removal
ipv6: make rt_sernum atomic and serial number fields ordinary ints
ipv6: only generate one new serial number per fib mutation
ipv6: make fib6 serial number per namespace
ipv6: don't walk node's leaf during serial number update
include/net/ip6_fib.h | 16 +++++--
include/net/netns/ipv6.h | 2 +-
net/ipv6/af_inet6.c | 2 +-
net/ipv6/ip6_fib.c | 106 +++++++++++++++++++++++++----------------------
4 files changed, 71 insertions(+), 55 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH net-next 1/5] ipv6: minor fib6 cleanups like type safety, bool conversion, inline removal
2014-10-06 8:52 [PATCH net-next 0/5] ipv6: cleanup after rt6_genid removal Hannes Frederic Sowa
@ 2014-10-06 8:52 ` Hannes Frederic Sowa
2014-10-06 17:23 ` Cong Wang
2014-10-06 8:52 ` [PATCH net-next 2/5] ipv6: make rt_sernum atomic and serial number fields ordinary ints Hannes Frederic Sowa
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-10-06 8:52 UTC (permalink / raw)
To: netdev; +Cc: hideaki, kafai
Cc: YOSHIFUJI Hideaki <hideaki@yoshifuji.org>
Cc: Martin Lau <kafai@fb.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
include/net/ip6_fib.h | 14 ++++++++++++--
net/ipv6/ip6_fib.c | 35 +++++++++++++----------------------
2 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index cf485f9..f4e6b3e 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -202,12 +202,22 @@ static inline void ip6_rt_put(struct rt6_info *rt)
dst_release(&rt->dst);
}
+enum fib_walk_state_t {
+#ifdef CONFIG_IPV6_SUBTREES
+ FWS_S,
+#endif
+ FWS_L,
+ FWS_R,
+ FWS_C,
+ FWS_U
+};
+
struct fib6_walker_t {
struct list_head lh;
struct fib6_node *root, *node;
struct rt6_info *leaf;
- unsigned char state;
- unsigned char prune;
+ enum fib_walk_state_t state;
+ bool prune;
unsigned int skip;
unsigned int count;
int (*func)(struct fib6_walker_t *);
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 97b9fa8..92f53db 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -46,16 +46,6 @@
static struct kmem_cache *fib6_node_kmem __read_mostly;
-enum fib_walk_state_t {
-#ifdef CONFIG_IPV6_SUBTREES
- FWS_S,
-#endif
- FWS_L,
- FWS_R,
- FWS_C,
- FWS_U
-};
-
struct fib6_cleaner_t {
struct fib6_walker_t w;
struct net *net;
@@ -91,20 +81,21 @@ static void fib6_gc_timer_cb(unsigned long arg);
static LIST_HEAD(fib6_walkers);
#define FOR_WALKERS(w) list_for_each_entry(w, &fib6_walkers, lh)
-static inline void fib6_walker_link(struct fib6_walker_t *w)
+static void fib6_walker_link(struct fib6_walker_t *w)
{
write_lock_bh(&fib6_walker_lock);
list_add(&w->lh, &fib6_walkers);
write_unlock_bh(&fib6_walker_lock);
}
-static inline void fib6_walker_unlink(struct fib6_walker_t *w)
+static void fib6_walker_unlink(struct fib6_walker_t *w)
{
write_lock_bh(&fib6_walker_lock);
list_del(&w->lh);
write_unlock_bh(&fib6_walker_lock);
}
-static __inline__ u32 fib6_new_sernum(void)
+
+static u32 fib6_new_sernum(void)
{
u32 n = ++rt_sernum;
if ((__s32)n <= 0)
@@ -128,7 +119,7 @@ static __inline__ u32 fib6_new_sernum(void)
# define BITOP_BE32_SWIZZLE 0
#endif
-static __inline__ __be32 addr_bit_set(const void *token, int fn_bit)
+static __be32 addr_bit_set(const void *token, int fn_bit)
{
const __be32 *addr = token;
/*
@@ -142,7 +133,7 @@ static __inline__ __be32 addr_bit_set(const void *token, int fn_bit)
addr[fn_bit >> 5];
}
-static __inline__ struct fib6_node *node_alloc(void)
+static struct fib6_node *node_alloc(void)
{
struct fib6_node *fn;
@@ -151,12 +142,12 @@ static __inline__ struct fib6_node *node_alloc(void)
return fn;
}
-static __inline__ void node_free(struct fib6_node *fn)
+static void node_free(struct fib6_node *fn)
{
kmem_cache_free(fib6_node_kmem, fn);
}
-static __inline__ void rt6_release(struct rt6_info *rt)
+static void rt6_release(struct rt6_info *rt)
{
if (atomic_dec_and_test(&rt->rt6i_ref))
dst_free(&rt->dst);
@@ -627,7 +618,7 @@ insert_above:
return ln;
}
-static inline bool rt6_qualify_for_ecmp(struct rt6_info *rt)
+static bool rt6_qualify_for_ecmp(struct rt6_info *rt)
{
return (rt->rt6i_flags & (RTF_GATEWAY|RTF_ADDRCONF|RTF_DYNAMIC)) ==
RTF_GATEWAY;
@@ -820,7 +811,7 @@ add:
return 0;
}
-static __inline__ void fib6_start_gc(struct net *net, struct rt6_info *rt)
+static void fib6_start_gc(struct net *net, struct rt6_info *rt)
{
if (!timer_pending(&net->ipv6.ip6_fib_timer) &&
(rt->rt6i_flags & (RTF_EXPIRES | RTF_CACHE)))
@@ -1554,7 +1545,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
static void fib6_clean_tree(struct net *net, struct fib6_node *root,
int (*func)(struct rt6_info *, void *arg),
- int prune, void *arg)
+ bool prune, void *arg)
{
struct fib6_cleaner_t c;
@@ -1583,7 +1574,7 @@ void fib6_clean_all(struct net *net, int (*func)(struct rt6_info *, void *arg),
hlist_for_each_entry_rcu(table, head, tb6_hlist) {
write_lock_bh(&table->tb6_lock);
fib6_clean_tree(net, &table->tb6_root,
- func, 0, arg);
+ func, false, arg);
write_unlock_bh(&table->tb6_lock);
}
}
@@ -1602,7 +1593,7 @@ static int fib6_prune_clone(struct rt6_info *rt, void *arg)
static void fib6_prune_clones(struct net *net, struct fib6_node *fn)
{
- fib6_clean_tree(net, fn, fib6_prune_clone, 1, NULL);
+ fib6_clean_tree(net, fn, fib6_prune_clone, true, NULL);
}
static int fib6_update_sernum(struct rt6_info *rt, void *arg)
--
1.9.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 2/5] ipv6: make rt_sernum atomic and serial number fields ordinary ints
2014-10-06 8:52 [PATCH net-next 0/5] ipv6: cleanup after rt6_genid removal Hannes Frederic Sowa
2014-10-06 8:52 ` [PATCH net-next 1/5] ipv6: minor fib6 cleanups like type safety, bool conversion, inline removal Hannes Frederic Sowa
@ 2014-10-06 8:52 ` Hannes Frederic Sowa
2014-10-06 17:26 ` Cong Wang
2014-10-06 8:52 ` [PATCH net-next 3/5] ipv6: only generate one new serial number per fib mutation Hannes Frederic Sowa
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-10-06 8:52 UTC (permalink / raw)
To: netdev; +Cc: hideaki, kafai
Cc: YOSHIFUJI Hideaki <hideaki@yoshifuji.org>
Cc: Martin Lau <kafai@fb.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
include/net/ip6_fib.h | 2 +-
net/ipv6/ip6_fib.c | 23 +++++++++++++----------
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index f4e6b3e..ee07f92 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -64,7 +64,7 @@ struct fib6_node {
__u16 fn_bit; /* bit key */
__u16 fn_flags;
- __u32 fn_sernum;
+ int fn_sernum;
struct rt6_info *rr_ptr;
};
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 92f53db..bfad469 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -74,7 +74,7 @@ static int fib6_walk_continue(struct fib6_walker_t *w);
* result of redirects, path MTU changes, etc.
*/
-static __u32 rt_sernum;
+static atomic_t rt_sernum = ATOMIC_INIT(1);
static void fib6_gc_timer_cb(unsigned long arg);
@@ -95,12 +95,15 @@ static void fib6_walker_unlink(struct fib6_walker_t *w)
write_unlock_bh(&fib6_walker_lock);
}
-static u32 fib6_new_sernum(void)
+static int fib6_new_sernum(void)
{
- u32 n = ++rt_sernum;
- if ((__s32)n <= 0)
- rt_sernum = n = 1;
- return n;
+ int new, old;
+
+ do {
+ old = atomic_read(&rt_sernum);
+ new = old < INT_MAX ? old + 1 : 1;
+ } while (atomic_cmpxchg(&rt_sernum, old, new) != old);
+ return new;
}
/*
@@ -421,7 +424,7 @@ static struct fib6_node *fib6_add_1(struct fib6_node *root,
struct rt6key *key;
int bit;
__be32 dir = 0;
- __u32 sernum = fib6_new_sernum();
+ int sernum = fib6_new_sernum();
RT6_TRACE("fib6_add_1\n");
@@ -1598,7 +1601,7 @@ static void fib6_prune_clones(struct net *net, struct fib6_node *fn)
static int fib6_update_sernum(struct rt6_info *rt, void *arg)
{
- __u32 sernum = *(__u32 *)arg;
+ int sernum = *(__u32 *)arg;
if (rt->rt6i_node &&
rt->rt6i_node->fn_sernum != sernum)
@@ -1609,7 +1612,7 @@ static int fib6_update_sernum(struct rt6_info *rt, void *arg)
static void fib6_flush_trees(struct net *net)
{
- __u32 new_sernum = fib6_new_sernum();
+ int new_sernum = fib6_new_sernum();
fib6_clean_all(net, fib6_update_sernum, &new_sernum);
}
@@ -1822,7 +1825,7 @@ struct ipv6_route_iter {
struct fib6_walker_t w;
loff_t skip;
struct fib6_table *tbl;
- __u32 sernum;
+ int sernum;
};
static int ipv6_route_seq_show(struct seq_file *seq, void *v)
--
1.9.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 3/5] ipv6: only generate one new serial number per fib mutation
2014-10-06 8:52 [PATCH net-next 0/5] ipv6: cleanup after rt6_genid removal Hannes Frederic Sowa
2014-10-06 8:52 ` [PATCH net-next 1/5] ipv6: minor fib6 cleanups like type safety, bool conversion, inline removal Hannes Frederic Sowa
2014-10-06 8:52 ` [PATCH net-next 2/5] ipv6: make rt_sernum atomic and serial number fields ordinary ints Hannes Frederic Sowa
@ 2014-10-06 8:52 ` Hannes Frederic Sowa
2014-10-06 8:52 ` [PATCH net-next 4/5] ipv6: make fib6 serial number per namespace Hannes Frederic Sowa
2014-10-06 8:52 ` [PATCH net-next 5/5] ipv6: don't walk node's leaf during serial number update Hannes Frederic Sowa
4 siblings, 0 replies; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-10-06 8:52 UTC (permalink / raw)
To: netdev; +Cc: hideaki, kafai
Cc: YOSHIFUJI Hideaki <hideaki@yoshifuji.org>
Cc: Martin Lau <kafai@fb.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
net/ipv6/ip6_fib.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index bfad469..a55a072 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -417,14 +417,13 @@ out:
static struct fib6_node *fib6_add_1(struct fib6_node *root,
struct in6_addr *addr, int plen,
int offset, int allow_create,
- int replace_required)
+ int replace_required, int sernum)
{
struct fib6_node *fn, *in, *ln;
struct fib6_node *pn = NULL;
struct rt6key *key;
int bit;
__be32 dir = 0;
- int sernum = fib6_new_sernum();
RT6_TRACE("fib6_add_1\n");
@@ -842,6 +841,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info,
int err = -ENOMEM;
int allow_create = 1;
int replace_required = 0;
+ int sernum = fib6_new_sernum();
if (info->nlh) {
if (!(info->nlh->nlmsg_flags & NLM_F_CREATE))
@@ -854,7 +854,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info,
fn = fib6_add_1(root, &rt->rt6i_dst.addr, rt->rt6i_dst.plen,
offsetof(struct rt6_info, rt6i_dst), allow_create,
- replace_required);
+ replace_required, sernum);
if (IS_ERR(fn)) {
err = PTR_ERR(fn);
fn = NULL;
@@ -888,14 +888,14 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info,
sfn->leaf = info->nl_net->ipv6.ip6_null_entry;
atomic_inc(&info->nl_net->ipv6.ip6_null_entry->rt6i_ref);
sfn->fn_flags = RTN_ROOT;
- sfn->fn_sernum = fib6_new_sernum();
+ sfn->fn_sernum = sernum;
/* Now add the first leaf node to new subtree */
sn = fib6_add_1(sfn, &rt->rt6i_src.addr,
rt->rt6i_src.plen,
offsetof(struct rt6_info, rt6i_src),
- allow_create, replace_required);
+ allow_create, replace_required, sernum);
if (IS_ERR(sn)) {
/* If it is failed, discard just allocated
@@ -914,7 +914,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info,
sn = fib6_add_1(fn->subtree, &rt->rt6i_src.addr,
rt->rt6i_src.plen,
offsetof(struct rt6_info, rt6i_src),
- allow_create, replace_required);
+ allow_create, replace_required, sernum);
if (IS_ERR(sn)) {
err = PTR_ERR(sn);
--
1.9.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 4/5] ipv6: make fib6 serial number per namespace
2014-10-06 8:52 [PATCH net-next 0/5] ipv6: cleanup after rt6_genid removal Hannes Frederic Sowa
` (2 preceding siblings ...)
2014-10-06 8:52 ` [PATCH net-next 3/5] ipv6: only generate one new serial number per fib mutation Hannes Frederic Sowa
@ 2014-10-06 8:52 ` Hannes Frederic Sowa
2014-10-06 8:52 ` [PATCH net-next 5/5] ipv6: don't walk node's leaf during serial number update Hannes Frederic Sowa
4 siblings, 0 replies; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-10-06 8:52 UTC (permalink / raw)
To: netdev; +Cc: hideaki, kafai
Try to reduce number of possible fn_sernum mutation by constraining them
to their namespace.
Also remove rt_genid which I forgot to remove in 705f1c869d577c ("ipv6:
remove rt6i_genid").
Cc: YOSHIFUJI Hideaki <hideaki@yoshifuji.org>
Cc: Martin Lau <kafai@fb.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
include/net/netns/ipv6.h | 2 +-
net/ipv6/af_inet6.c | 2 +-
net/ipv6/ip6_fib.c | 13 ++++++-------
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
index eade27a..69ae41f 100644
--- a/include/net/netns/ipv6.h
+++ b/include/net/netns/ipv6.h
@@ -76,7 +76,7 @@ struct netns_ipv6 {
#endif
#endif
atomic_t dev_addr_genid;
- atomic_t rt_genid;
+ atomic_t fib6_sernum;
};
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 34f726f..e8c4400 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -766,7 +766,7 @@ static int __net_init inet6_net_init(struct net *net)
net->ipv6.sysctl.icmpv6_time = 1*HZ;
net->ipv6.sysctl.flowlabel_consistency = 1;
net->ipv6.sysctl.auto_flowlabels = 0;
- atomic_set(&net->ipv6.rt_genid, 0);
+ atomic_set(&net->ipv6.fib6_sernum, 1);
err = ipv6_init_mibs(net);
if (err)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index a55a072..6c10c26 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -74,8 +74,6 @@ static int fib6_walk_continue(struct fib6_walker_t *w);
* result of redirects, path MTU changes, etc.
*/
-static atomic_t rt_sernum = ATOMIC_INIT(1);
-
static void fib6_gc_timer_cb(unsigned long arg);
static LIST_HEAD(fib6_walkers);
@@ -95,14 +93,15 @@ static void fib6_walker_unlink(struct fib6_walker_t *w)
write_unlock_bh(&fib6_walker_lock);
}
-static int fib6_new_sernum(void)
+static int fib6_new_sernum(struct net *net)
{
int new, old;
do {
- old = atomic_read(&rt_sernum);
+ old = atomic_read(&net->ipv6.fib6_sernum);
new = old < INT_MAX ? old + 1 : 1;
- } while (atomic_cmpxchg(&rt_sernum, old, new) != old);
+ } while (atomic_cmpxchg(&net->ipv6.fib6_sernum,
+ old, new) != old);
return new;
}
@@ -841,7 +840,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info,
int err = -ENOMEM;
int allow_create = 1;
int replace_required = 0;
- int sernum = fib6_new_sernum();
+ int sernum = fib6_new_sernum(info->nl_net);
if (info->nlh) {
if (!(info->nlh->nlmsg_flags & NLM_F_CREATE))
@@ -1612,7 +1611,7 @@ static int fib6_update_sernum(struct rt6_info *rt, void *arg)
static void fib6_flush_trees(struct net *net)
{
- int new_sernum = fib6_new_sernum();
+ int new_sernum = fib6_new_sernum(net);
fib6_clean_all(net, fib6_update_sernum, &new_sernum);
}
--
1.9.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 5/5] ipv6: don't walk node's leaf during serial number update
2014-10-06 8:52 [PATCH net-next 0/5] ipv6: cleanup after rt6_genid removal Hannes Frederic Sowa
` (3 preceding siblings ...)
2014-10-06 8:52 ` [PATCH net-next 4/5] ipv6: make fib6 serial number per namespace Hannes Frederic Sowa
@ 2014-10-06 8:52 ` Hannes Frederic Sowa
2014-10-06 17:58 ` Cong Wang
4 siblings, 1 reply; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-10-06 8:52 UTC (permalink / raw)
To: netdev; +Cc: hideaki, kafai
Cc: YOSHIFUJI Hideaki <hideaki@yoshifuji.org>
Cc: Martin Lau <kafai@fb.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
net/ipv6/ip6_fib.c | 47 ++++++++++++++++++++++++++++++-----------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 6c10c26..f36207f 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -50,6 +50,7 @@ struct fib6_cleaner_t {
struct fib6_walker_t w;
struct net *net;
int (*func)(struct rt6_info *, void *arg);
+ int sernum;
void *arg;
};
@@ -105,6 +106,10 @@ static int fib6_new_sernum(struct net *net)
return new;
}
+enum {
+ FIB6_NO_SERNUM_CHANGE = 0,
+};
+
/*
* Auxiliary address test functions for the radix tree.
*
@@ -1514,6 +1519,16 @@ static int fib6_clean_node(struct fib6_walker_t *w)
.nl_net = c->net,
};
+ if (c->sernum != FIB6_NO_SERNUM_CHANGE &&
+ w->node->fn_sernum != c->sernum)
+ w->node->fn_sernum = c->sernum;
+
+ if (!c->func) {
+ WARN_ON_ONCE(c->sernum == FIB6_NO_SERNUM_CHANGE);
+ w->leaf = NULL;
+ return 0;
+ }
+
for (rt = w->leaf; rt; rt = rt->dst.rt6_next) {
res = c->func(rt, c->arg);
if (res < 0) {
@@ -1547,7 +1562,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
static void fib6_clean_tree(struct net *net, struct fib6_node *root,
int (*func)(struct rt6_info *, void *arg),
- bool prune, void *arg)
+ bool prune, int sernum, void *arg)
{
struct fib6_cleaner_t c;
@@ -1557,14 +1572,16 @@ static void fib6_clean_tree(struct net *net, struct fib6_node *root,
c.w.count = 0;
c.w.skip = 0;
c.func = func;
+ c.sernum = sernum;
c.arg = arg;
c.net = net;
fib6_walk(&c.w);
}
-void fib6_clean_all(struct net *net, int (*func)(struct rt6_info *, void *arg),
- void *arg)
+static void __fib6_clean_all(struct net *net,
+ int (*func)(struct rt6_info *, void *),
+ int sernum, void *arg)
{
struct fib6_table *table;
struct hlist_head *head;
@@ -1576,13 +1593,19 @@ void fib6_clean_all(struct net *net, int (*func)(struct rt6_info *, void *arg),
hlist_for_each_entry_rcu(table, head, tb6_hlist) {
write_lock_bh(&table->tb6_lock);
fib6_clean_tree(net, &table->tb6_root,
- func, false, arg);
+ func, false, sernum, arg);
write_unlock_bh(&table->tb6_lock);
}
}
rcu_read_unlock();
}
+void fib6_clean_all(struct net *net, int (*func)(struct rt6_info *, void *),
+ void *arg)
+{
+ __fib6_clean_all(net, func, FIB6_NO_SERNUM_CHANGE, arg);
+}
+
static int fib6_prune_clone(struct rt6_info *rt, void *arg)
{
if (rt->rt6i_flags & RTF_CACHE) {
@@ -1595,25 +1618,15 @@ static int fib6_prune_clone(struct rt6_info *rt, void *arg)
static void fib6_prune_clones(struct net *net, struct fib6_node *fn)
{
- fib6_clean_tree(net, fn, fib6_prune_clone, true, NULL);
-}
-
-static int fib6_update_sernum(struct rt6_info *rt, void *arg)
-{
- int sernum = *(__u32 *)arg;
-
- if (rt->rt6i_node &&
- rt->rt6i_node->fn_sernum != sernum)
- rt->rt6i_node->fn_sernum = sernum;
-
- return 0;
+ fib6_clean_tree(net, fn, fib6_prune_clone, true,
+ FIB6_NO_SERNUM_CHANGE, NULL);
}
static void fib6_flush_trees(struct net *net)
{
int new_sernum = fib6_new_sernum(net);
- fib6_clean_all(net, fib6_update_sernum, &new_sernum);
+ __fib6_clean_all(net, NULL, new_sernum, NULL);
}
/*
--
1.9.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 1/5] ipv6: minor fib6 cleanups like type safety, bool conversion, inline removal
2014-10-06 8:52 ` [PATCH net-next 1/5] ipv6: minor fib6 cleanups like type safety, bool conversion, inline removal Hannes Frederic Sowa
@ 2014-10-06 17:23 ` Cong Wang
0 siblings, 0 replies; 11+ messages in thread
From: Cong Wang @ 2014-10-06 17:23 UTC (permalink / raw)
To: Hannes Frederic Sowa; +Cc: netdev, hideaki, kafai
On Mon, Oct 6, 2014 at 1:52 AM, Hannes Frederic Sowa
<hannes@stressinduktion.org> wrote:
> diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
> index cf485f9..f4e6b3e 100644
> --- a/include/net/ip6_fib.h
> +++ b/include/net/ip6_fib.h
> @@ -202,12 +202,22 @@ static inline void ip6_rt_put(struct rt6_info *rt)
> dst_release(&rt->dst);
> }
>
> +enum fib_walk_state_t {
> +#ifdef CONFIG_IPV6_SUBTREES
> + FWS_S,
> +#endif
> + FWS_L,
> + FWS_R,
> + FWS_C,
> + FWS_U
> +};
> +
> struct fib6_walker_t {
While you are on it, I think these *_t types don't actually need "_t",
they are not typedef's anyway. But this definitely could be a folllowup patch.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 2/5] ipv6: make rt_sernum atomic and serial number fields ordinary ints
2014-10-06 8:52 ` [PATCH net-next 2/5] ipv6: make rt_sernum atomic and serial number fields ordinary ints Hannes Frederic Sowa
@ 2014-10-06 17:26 ` Cong Wang
0 siblings, 0 replies; 11+ messages in thread
From: Cong Wang @ 2014-10-06 17:26 UTC (permalink / raw)
To: Hannes Frederic Sowa; +Cc: netdev, hideaki, kafai
On Mon, Oct 6, 2014 at 1:52 AM, Hannes Frederic Sowa
<hannes@stressinduktion.org> wrote:
> @@ -1598,7 +1601,7 @@ static void fib6_prune_clones(struct net *net, struct fib6_node *fn)
>
> static int fib6_update_sernum(struct rt6_info *rt, void *arg)
> {
> - __u32 sernum = *(__u32 *)arg;
> + int sernum = *(__u32 *)arg;
Should be *(int *) arg?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 5/5] ipv6: don't walk node's leaf during serial number update
2014-10-06 8:52 ` [PATCH net-next 5/5] ipv6: don't walk node's leaf during serial number update Hannes Frederic Sowa
@ 2014-10-06 17:58 ` Cong Wang
2014-10-06 18:02 ` Hannes Frederic Sowa
0 siblings, 1 reply; 11+ messages in thread
From: Cong Wang @ 2014-10-06 17:58 UTC (permalink / raw)
To: Hannes Frederic Sowa; +Cc: netdev, hideaki, kafai
On Mon, Oct 6, 2014 at 1:52 AM, Hannes Frederic Sowa
<hannes@stressinduktion.org> wrote:
> @@ -105,6 +106,10 @@ static int fib6_new_sernum(struct net *net)
> return new;
> }
>
> +enum {
> + FIB6_NO_SERNUM_CHANGE = 0,
> +};
> +
Not sure if it worth an enum definition... seems overkill for me.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 5/5] ipv6: don't walk node's leaf during serial number update
2014-10-06 17:58 ` Cong Wang
@ 2014-10-06 18:02 ` Hannes Frederic Sowa
2014-10-06 18:27 ` Cong Wang
0 siblings, 1 reply; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-10-06 18:02 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, hideaki, kafai
On Mo, 2014-10-06 at 10:58 -0700, Cong Wang wrote:
> On Mon, Oct 6, 2014 at 1:52 AM, Hannes Frederic Sowa
> <hannes@stressinduktion.org> wrote:
> > @@ -105,6 +106,10 @@ static int fib6_new_sernum(struct net *net)
> > return new;
> > }
> >
> > +enum {
> > + FIB6_NO_SERNUM_CHANGE = 0,
> > +};
> > +
>
> Not sure if it worth an enum definition... seems overkill for me.
Yeah, maybe, I was used to do it like that in user space because of
debuggers.
I think it is ok, also I just send v2 with your proposed changes.
If you have a strong opinion about that, let me know. ;)
Thanks a lot for the review,
Hannes
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 5/5] ipv6: don't walk node's leaf during serial number update
2014-10-06 18:02 ` Hannes Frederic Sowa
@ 2014-10-06 18:27 ` Cong Wang
0 siblings, 0 replies; 11+ messages in thread
From: Cong Wang @ 2014-10-06 18:27 UTC (permalink / raw)
To: Hannes Frederic Sowa; +Cc: netdev, hideaki, kafai
On Mon, Oct 6, 2014 at 11:02 AM, Hannes Frederic Sowa
<hannes@stressinduktion.org> wrote:
> On Mo, 2014-10-06 at 10:58 -0700, Cong Wang wrote:
>> On Mon, Oct 6, 2014 at 1:52 AM, Hannes Frederic Sowa
>> <hannes@stressinduktion.org> wrote:
>> > @@ -105,6 +106,10 @@ static int fib6_new_sernum(struct net *net)
>> > return new;
>> > }
>> >
>> > +enum {
>> > + FIB6_NO_SERNUM_CHANGE = 0,
>> > +};
>> > +
>>
>> Not sure if it worth an enum definition... seems overkill for me.
>
> Yeah, maybe, I was used to do it like that in user space because of
> debuggers.
>
> I think it is ok, also I just send v2 with your proposed changes.
> If you have a strong opinion about that, let me know. ;)
No, I don't. :)
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-10-06 18:27 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-06 8:52 [PATCH net-next 0/5] ipv6: cleanup after rt6_genid removal Hannes Frederic Sowa
2014-10-06 8:52 ` [PATCH net-next 1/5] ipv6: minor fib6 cleanups like type safety, bool conversion, inline removal Hannes Frederic Sowa
2014-10-06 17:23 ` Cong Wang
2014-10-06 8:52 ` [PATCH net-next 2/5] ipv6: make rt_sernum atomic and serial number fields ordinary ints Hannes Frederic Sowa
2014-10-06 17:26 ` Cong Wang
2014-10-06 8:52 ` [PATCH net-next 3/5] ipv6: only generate one new serial number per fib mutation Hannes Frederic Sowa
2014-10-06 8:52 ` [PATCH net-next 4/5] ipv6: make fib6 serial number per namespace Hannes Frederic Sowa
2014-10-06 8:52 ` [PATCH net-next 5/5] ipv6: don't walk node's leaf during serial number update Hannes Frederic Sowa
2014-10-06 17:58 ` Cong Wang
2014-10-06 18:02 ` Hannes Frederic Sowa
2014-10-06 18:27 ` Cong Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.