Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1405052 > unrolled thread

[PATCH] ip_tunnel: enclose a code block in macro IS_ENABLED(CONFIG_IPV6)

Started byHaishuang Yan <yanhaishuang@cmss.chinamobile.com>
First post2016-05-23 01:00 +0200
Last post2016-05-23 03:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ip_tunnel: enclose a code block in macro IS_ENABLED(CONFIG_IPV6) Haishuang Yan <yanhaishuang@cmss.chinamobile.com> - 2016-05-23 01:00 +0200
    Re: [PATCH] ip_tunnel: enclose a code block in macro IS_ENABLED(CONFIG_IPV6) Alexander Duyck <alexander.duyck@gmail.com> - 2016-05-23 03:10 +0200

#1405052 — [PATCH] ip_tunnel: enclose a code block in macro IS_ENABLED(CONFIG_IPV6)

FromHaishuang Yan <yanhaishuang@cmss.chinamobile.com>
Date2016-05-23 01:00 +0200
Subject[PATCH] ip_tunnel: enclose a code block in macro IS_ENABLED(CONFIG_IPV6)
Message-ID<rBKvL-6po-5@gated-at.bofh.it>
For ipv6 case, enclose the code block in macro IS_ENABLED(CONFIG_IPV6).

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/ipv4/ip_tunnel.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index a69ed94..5f3c8de 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -665,10 +665,13 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 		if (skb->protocol == htons(ETH_P_IP)) {
 			tos = inner_iph->tos;
 			connected = false;
-		} else if (skb->protocol == htons(ETH_P_IPV6)) {
+		}
+#if IS_ENABLED(CONFIG_IPV6)
+		else if (skb->protocol == htons(ETH_P_IPV6)) {
 			tos = ipv6_get_dsfield((const struct ipv6hdr *)inner_iph);
 			connected = false;
 		}
+#endif
 	}
 
 	init_tunnel_flow(&fl4, protocol, dst, tnl_params->saddr,
-- 
1.8.3.1

[toc] | [next] | [standalone]


#1405060

FromAlexander Duyck <alexander.duyck@gmail.com>
Date2016-05-23 03:10 +0200
Message-ID<rBMxA-7Na-5@gated-at.bofh.it>
In reply to#1405052
On Sun, May 22, 2016 at 3:53 PM, Haishuang Yan
<yanhaishuang@cmss.chinamobile.com> wrote:
> For ipv6 case, enclose the code block in macro IS_ENABLED(CONFIG_IPV6).
>
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
> ---
>  net/ipv4/ip_tunnel.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
> index a69ed94..5f3c8de 100644
> --- a/net/ipv4/ip_tunnel.c
> +++ b/net/ipv4/ip_tunnel.c
> @@ -665,10 +665,13 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
>                 if (skb->protocol == htons(ETH_P_IP)) {
>                         tos = inner_iph->tos;
>                         connected = false;
> -               } else if (skb->protocol == htons(ETH_P_IPV6)) {
> +               }
> +#if IS_ENABLED(CONFIG_IPV6)
> +               else if (skb->protocol == htons(ETH_P_IPV6)) {
>                         tos = ipv6_get_dsfield((const struct ipv6hdr *)inner_iph);
>                         connected = false;
>                 }
> +#endif
>         }
>
>         init_tunnel_flow(&fl4, protocol, dst, tnl_params->saddr,
>

You could just place the "#if IS_ENABLED" block before the "} else if
(..) {" piece and the "#endif" before the closing brace and this
becomes much easier to look at.

Also is there any specific reason for needing to wrap this code?  It
isn't clear from your patch description, and from what I can tell the
code that you are wrapping should be defined in all cases since it is
defined in header files anyway.

- Alex

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web