From: Hannes Frederic Sowa <hannes@stressinduktion.org>
To: netdev@vger.kernel.org
Cc: hideaki@yoshifuji.org, kafai@fb.com
Subject: [PATCH net-next 2/5] ipv6: make rt_sernum atomic and serial number fields ordinary ints
Date: Mon, 6 Oct 2014 10:52:11 +0200 [thread overview]
Message-ID: <c98d73f367912e2fa164ffa7f6cc0c7ecbd21de1.1412585163.git.hannes@stressinduktion.org> (raw)
In-Reply-To: <cover.1412585162.git.hannes@stressinduktion.org>
In-Reply-To: <cover.1412585162.git.hannes@stressinduktion.org>
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
next prev parent reply other threads:[~2014-10-06 8:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Hannes Frederic Sowa [this message]
2014-10-06 17:26 ` [PATCH net-next 2/5] ipv6: make rt_sernum atomic and serial number fields ordinary ints 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c98d73f367912e2fa164ffa7f6cc0c7ecbd21de1.1412585163.git.hannes@stressinduktion.org \
--to=hannes@stressinduktion.org \
--cc=hideaki@yoshifuji.org \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).