ipv6: only generate one new serial number per fib mutation
authorHannes Frederic Sowa <hannes@stressinduktion.org>
Mon, 6 Oct 2014 17:58:36 +0000 (19:58 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Oct 2014 04:02:30 +0000 (00:02 -0400)
Cc: YOSHIFUJI Hideaki <hideaki@yoshifuji.org>
Cc: Martin Lau <kafai@fb.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/ip6_fib.c

index 332f1e0ff8e2c8363151cb7d15dad7ddc4eb3045..be9cb09b05f71e789745269609ed01eb5f97e68d 100644 (file)
@@ -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);