netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init()
@ 2015-07-24 10:28 Nicolas Dichtel
  2015-07-24 10:28 ` [PATCH net-next 2/2] lwtunnel: change prototype of lwtunnel_state_get() Nicolas Dichtel
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Nicolas Dichtel @ 2015-07-24 10:28 UTC (permalink / raw)
  To: davem; +Cc: netdev, Nicolas Dichtel, Thomas Graf, Roopa Prabhu

We need to copy this field (ip6_rt_cache_alloc() and ip6_rt_pcpu_alloc()
use ip6_rt_copy_init() to build a dst).

CC: Thomas Graf <tgraf@suug.ch>
CC: Roopa Prabhu <roopa@cumulusnetworks.com>
Fixes: 19e42e451506 ("ipv6: support for fib route lwtunnel encap attributes")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv6/route.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 67b2367126f3..ac01ab0886a5 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2164,6 +2164,10 @@ static void ip6_rt_copy_init(struct rt6_info *rt, struct rt6_info *ort)
 #endif
 	rt->rt6i_prefsrc = ort->rt6i_prefsrc;
 	rt->rt6i_table = ort->rt6i_table;
+	if (ort->rt6i_lwtstate) {
+		lwtunnel_state_get(ort->rt6i_lwtstate);
+		rt->rt6i_lwtstate = ort->rt6i_lwtstate;
+	}
 }
 
 #ifdef CONFIG_IPV6_ROUTE_INFO
-- 
2.4.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 2/2] lwtunnel: change prototype of lwtunnel_state_get()
  2015-07-24 10:28 [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init() Nicolas Dichtel
@ 2015-07-24 10:28 ` Nicolas Dichtel
  2015-07-24 10:41   ` Thomas Graf
                     ` (2 more replies)
  2015-07-24 10:40 ` [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init() Thomas Graf
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 8+ messages in thread
From: Nicolas Dichtel @ 2015-07-24 10:28 UTC (permalink / raw)
  To: davem; +Cc: netdev, Nicolas Dichtel, Thomas Graf, Roopa Prabhu

It saves some lines and simplify a bit the code when the state is returning
by this function. It's also useful to handle a NULL entry.

To avoid too long lines, I've also renamed lwtunnel_state_get() and
lwtunnel_state_put() to lwtstate_get() and lwtstate_put().

CC: Thomas Graf <tgraf@suug.ch>
CC: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 include/net/lwtunnel.h   | 16 +++++++++++-----
 net/ipv4/fib_semantics.c |  9 ++++-----
 net/ipv4/route.c         |  9 ++-------
 net/ipv6/ip6_fib.c       |  2 +-
 net/ipv6/route.c         |  8 ++------
 5 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/include/net/lwtunnel.h b/include/net/lwtunnel.h
index bd72e82b45a1..78376da1afa2 100644
--- a/include/net/lwtunnel.h
+++ b/include/net/lwtunnel.h
@@ -37,12 +37,16 @@ extern const struct lwtunnel_encap_ops __rcu *
 		lwtun_encaps[LWTUNNEL_ENCAP_MAX+1];
 
 #ifdef CONFIG_LWTUNNEL
-static inline void lwtunnel_state_get(struct lwtunnel_state *lws)
+static inline struct lwtunnel_state *
+lwtstate_get(struct lwtunnel_state *lws)
 {
-	atomic_inc(&lws->refcnt);
+	if (lws)
+		atomic_inc(&lws->refcnt);
+
+	return lws;
 }
 
-static inline void lwtunnel_state_put(struct lwtunnel_state *lws)
+static inline void lwtstate_put(struct lwtunnel_state *lws)
 {
 	if (!lws)
 		return;
@@ -76,11 +80,13 @@ int lwtunnel_output6(struct sock *sk, struct sk_buff *skb);
 
 #else
 
-static inline void lwtunnel_state_get(struct lwtunnel_state *lws)
+static inline struct lwtunnel_state *
+lwtstate_get(struct lwtunnel_state *lws)
 {
+	return lws;
 }
 
-static inline void lwtunnel_state_put(struct lwtunnel_state *lws)
+static inline void lwtstate_put(struct lwtunnel_state *lws)
 {
 }
 
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 6754c64b2fe0..7226df887531 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -209,7 +209,7 @@ static void free_fib_info_rcu(struct rcu_head *head)
 	change_nexthops(fi) {
 		if (nexthop_nh->nh_dev)
 			dev_put(nexthop_nh->nh_dev);
-		lwtunnel_state_put(nexthop_nh->nh_lwtstate);
+		lwtstate_put(nexthop_nh->nh_lwtstate);
 		free_nh_exceptions(nexthop_nh);
 		rt_fibinfo_free_cpus(nexthop_nh->nh_pcpu_rth_output);
 		rt_fibinfo_free(&nexthop_nh->nh_rth_input);
@@ -512,8 +512,8 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
 							   nla, &lwtstate);
 				if (ret)
 					goto errout;
-				lwtunnel_state_get(lwtstate);
-				nexthop_nh->nh_lwtstate = lwtstate;
+				nexthop_nh->nh_lwtstate =
+					lwtstate_get(lwtstate);
 			}
 		}
 
@@ -969,8 +969,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
 			if (err)
 				goto failure;
 
-			lwtunnel_state_get(lwtstate);
-			nh->nh_lwtstate = lwtstate;
+			nh->nh_lwtstate = lwtstate_get(lwtstate);
 		}
 		nh->nh_oif = cfg->fc_oif;
 		nh->nh_gw = cfg->fc_gw;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 519ec232818d..11096396ef4a 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1358,7 +1358,7 @@ static void ipv4_dst_destroy(struct dst_entry *dst)
 		list_del(&rt->rt_uncached);
 		spin_unlock_bh(&ul->lock);
 	}
-	lwtunnel_state_put(rt->rt_lwtstate);
+	lwtstate_put(rt->rt_lwtstate);
 }
 
 void rt_flush_dev(struct net_device *dev)
@@ -1407,12 +1407,7 @@ static void rt_set_nexthop(struct rtable *rt, __be32 daddr,
 #ifdef CONFIG_IP_ROUTE_CLASSID
 		rt->dst.tclassid = nh->nh_tclassid;
 #endif
-		if (nh->nh_lwtstate) {
-			lwtunnel_state_get(nh->nh_lwtstate);
-			rt->rt_lwtstate = nh->nh_lwtstate;
-		} else {
-			rt->rt_lwtstate = NULL;
-		}
+		rt->rt_lwtstate = lwtstate_get(nh->nh_lwtstate);
 		if (unlikely(fnhe))
 			cached = rt_bind_exception(rt, fnhe, daddr);
 		else if (!(rt->dst.flags & DST_NOCACHE))
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index d715f2e0c4e7..5693b5eb8482 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -178,7 +178,7 @@ static void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
 static void rt6_release(struct rt6_info *rt)
 {
 	if (atomic_dec_and_test(&rt->rt6i_ref)) {
-		lwtunnel_state_put(rt->rt6i_lwtstate);
+		lwtstate_put(rt->rt6i_lwtstate);
 		rt6_free_pcpu(rt);
 		dst_free(&rt->dst);
 	}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index ac01ab0886a5..894cb18cd8ca 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1778,8 +1778,7 @@ int ip6_route_add(struct fib6_config *cfg)
 					   cfg->fc_encap, &lwtstate);
 		if (err)
 			goto out;
-		lwtunnel_state_get(lwtstate);
-		rt->rt6i_lwtstate = lwtstate;
+		rt->rt6i_lwtstate = lwtstate_get(lwtstate);
 		if (lwtunnel_output_redirect(rt->rt6i_lwtstate))
 			rt->dst.output = lwtunnel_output6;
 	}
@@ -2164,10 +2163,7 @@ static void ip6_rt_copy_init(struct rt6_info *rt, struct rt6_info *ort)
 #endif
 	rt->rt6i_prefsrc = ort->rt6i_prefsrc;
 	rt->rt6i_table = ort->rt6i_table;
-	if (ort->rt6i_lwtstate) {
-		lwtunnel_state_get(ort->rt6i_lwtstate);
-		rt->rt6i_lwtstate = ort->rt6i_lwtstate;
-	}
+	rt->rt6i_lwtstate = lwtstate_get(ort->rt6i_lwtstate);
 }
 
 #ifdef CONFIG_IPV6_ROUTE_INFO
-- 
2.4.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init()
  2015-07-24 10:28 [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init() Nicolas Dichtel
  2015-07-24 10:28 ` [PATCH net-next 2/2] lwtunnel: change prototype of lwtunnel_state_get() Nicolas Dichtel
@ 2015-07-24 10:40 ` Thomas Graf
  2015-07-24 13:40 ` roopa
  2015-07-27  8:03 ` David Miller
  3 siblings, 0 replies; 8+ messages in thread
From: Thomas Graf @ 2015-07-24 10:40 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: davem, netdev, Roopa Prabhu

On 07/24/15 at 12:28pm, Nicolas Dichtel wrote:
> We need to copy this field (ip6_rt_cache_alloc() and ip6_rt_pcpu_alloc()
> use ip6_rt_copy_init() to build a dst).
> 
> CC: Thomas Graf <tgraf@suug.ch>
> CC: Roopa Prabhu <roopa@cumulusnetworks.com>
> Fixes: 19e42e451506 ("ipv6: support for fib route lwtunnel encap attributes")
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Acked-by: Thomas Graf <tgraf@suug.ch>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/2] lwtunnel: change prototype of lwtunnel_state_get()
  2015-07-24 10:28 ` [PATCH net-next 2/2] lwtunnel: change prototype of lwtunnel_state_get() Nicolas Dichtel
@ 2015-07-24 10:41   ` Thomas Graf
  2015-07-24 13:53   ` roopa
  2015-07-27  8:03   ` David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: Thomas Graf @ 2015-07-24 10:41 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: davem, netdev, Roopa Prabhu

On 07/24/15 at 12:28pm, Nicolas Dichtel wrote:
> It saves some lines and simplify a bit the code when the state is returning
> by this function. It's also useful to handle a NULL entry.
> 
> To avoid too long lines, I've also renamed lwtunnel_state_get() and
> lwtunnel_state_put() to lwtstate_get() and lwtstate_put().
> 
> CC: Thomas Graf <tgraf@suug.ch>
> CC: Roopa Prabhu <roopa@cumulusnetworks.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Acked-by: Thomas Graf <tgraf@suug.ch>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init()
  2015-07-24 10:28 [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init() Nicolas Dichtel
  2015-07-24 10:28 ` [PATCH net-next 2/2] lwtunnel: change prototype of lwtunnel_state_get() Nicolas Dichtel
  2015-07-24 10:40 ` [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init() Thomas Graf
@ 2015-07-24 13:40 ` roopa
  2015-07-27  8:03 ` David Miller
  3 siblings, 0 replies; 8+ messages in thread
From: roopa @ 2015-07-24 13:40 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: davem, netdev, Thomas Graf

On 7/24/15, 3:28 AM, Nicolas Dichtel wrote:
> We need to copy this field (ip6_rt_cache_alloc() and ip6_rt_pcpu_alloc()
> use ip6_rt_copy_init() to build a dst).
>
> CC: Thomas Graf <tgraf@suug.ch>
> CC: Roopa Prabhu <roopa@cumulusnetworks.com>
> Fixes: 19e42e451506 ("ipv6: support for fib route lwtunnel encap attributes")
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>

Thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/2] lwtunnel: change prototype of lwtunnel_state_get()
  2015-07-24 10:28 ` [PATCH net-next 2/2] lwtunnel: change prototype of lwtunnel_state_get() Nicolas Dichtel
  2015-07-24 10:41   ` Thomas Graf
@ 2015-07-24 13:53   ` roopa
  2015-07-27  8:03   ` David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: roopa @ 2015-07-24 13:53 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: davem, netdev, Thomas Graf

On 7/24/15, 3:28 AM, Nicolas Dichtel wrote:
> It saves some lines and simplify a bit the code when the state is returning
> by this function. It's also useful to handle a NULL entry.
>
> To avoid too long lines, I've also renamed lwtunnel_state_get() and
> lwtunnel_state_put() to lwtstate_get() and lwtstate_put().
>
> CC: Thomas Graf <tgraf@suug.ch>
> CC: Roopa Prabhu <roopa@cumulusnetworks.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>

thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init()
  2015-07-24 10:28 [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init() Nicolas Dichtel
                   ` (2 preceding siblings ...)
  2015-07-24 13:40 ` roopa
@ 2015-07-27  8:03 ` David Miller
  3 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2015-07-27  8:03 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: netdev, tgraf, roopa

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Fri, 24 Jul 2015 12:28:35 +0200

> We need to copy this field (ip6_rt_cache_alloc() and ip6_rt_pcpu_alloc()
> use ip6_rt_copy_init() to build a dst).
> 
> CC: Thomas Graf <tgraf@suug.ch>
> CC: Roopa Prabhu <roopa@cumulusnetworks.com>
> Fixes: 19e42e451506 ("ipv6: support for fib route lwtunnel encap attributes")
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Applied.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/2] lwtunnel: change prototype of lwtunnel_state_get()
  2015-07-24 10:28 ` [PATCH net-next 2/2] lwtunnel: change prototype of lwtunnel_state_get() Nicolas Dichtel
  2015-07-24 10:41   ` Thomas Graf
  2015-07-24 13:53   ` roopa
@ 2015-07-27  8:03   ` David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2015-07-27  8:03 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: netdev, tgraf, roopa

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Fri, 24 Jul 2015 12:28:36 +0200

> It saves some lines and simplify a bit the code when the state is returning
> by this function. It's also useful to handle a NULL entry.
> 
> To avoid too long lines, I've also renamed lwtunnel_state_get() and
> lwtunnel_state_put() to lwtstate_get() and lwtstate_put().
> 
> CC: Thomas Graf <tgraf@suug.ch>
> CC: Roopa Prabhu <roopa@cumulusnetworks.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Applied.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-07-27  8:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-24 10:28 [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init() Nicolas Dichtel
2015-07-24 10:28 ` [PATCH net-next 2/2] lwtunnel: change prototype of lwtunnel_state_get() Nicolas Dichtel
2015-07-24 10:41   ` Thomas Graf
2015-07-24 13:53   ` roopa
2015-07-27  8:03   ` David Miller
2015-07-24 10:40 ` [PATCH net-next 1/2] ipv6: copy lwtstate in ip6_rt_copy_init() Thomas Graf
2015-07-24 13:40 ` roopa
2015-07-27  8:03 ` David Miller

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).