netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: f.cachereul@init-sys.com
Cc: jchapman@katalix.com, netdev@vger.kernel.org
Subject: Re: [PATCH next] l2tp: add support for IPv4-mapped IPv6 addresses
Date: Mon, 30 Sep 2013 21:57:32 -0700 (PDT)	[thread overview]
Message-ID: <20130930.215732.511217838898717901.davem@davemloft.net> (raw)
In-Reply-To: <5245694D.3070105@init-sys.com>

From: François Cachereul <f.cachereul@init-sys.com>
Date: Fri, 27 Sep 2013 13:17:33 +0200

> @@ -1620,6 +1621,10 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
>  	int err;
>  	struct socket *sock = NULL;
>  	struct sock *sk = NULL;
> +#if IS_ENABLED(CONFIG_IPV6)
> +	struct inet_sock *inet = NULL;
> +	struct ipv6_pinfo *np = NULL;
> +#endif
 ...
> +#if IS_ENABLED(CONFIG_IPV6)
> +	np = inet6_sk(sk);
> +	if (sk->sk_family == PF_INET6 &&
> +	    ipv6_addr_v4mapped(&np->saddr) &&
> +	    ipv6_addr_v4mapped(&np->daddr)) {
> +		tunnel->v4mapped = true;
> +		inet = inet_sk(sk);
> +		inet->inet_saddr = np->saddr.s6_addr32[3];
> +		inet->inet_rcv_saddr = np->rcv_saddr.s6_addr32[3];
> +		inet->inet_daddr = np->daddr.s6_addr32[3];
> +	} else {
> +		tunnel->v4mapped = false;
> +	}
> +#endif

You only need one ifdef here, get rid of the top level variable
declarations and then just go:

#if IS_ENABLED(CONFIG_IPV6)
	if (sk->sk_family == PF_INET6) {
		struct ipv6_pinfo *np = inet6_sk(sk);

		if (ipv6_addr_v4mapped(&np->saddr) &&
		    ipv6_addr_v4mapped(&np->daddr)) {
			struct inet_sock *inet = inet_sk(sk);

			tunnel->v4mapped = true;
			inet->inet_saddr = np->saddr.s6_addr32[3];
			inet->inet_rcv_saddr = np->rcv_saddr.s6_addr32[3];
			inet->inet_daddr = np->daddr.s6_addr32[3];
		} else {
			tunnel->v4mapped = false;
		}
	}
#endif

      reply	other threads:[~2013-10-01  4:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-27 11:17 [PATCH next] l2tp: add support for IPv4-mapped IPv6 addresses François Cachereul
2013-10-01  4:57 ` David Miller [this message]

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=20130930.215732.511217838898717901.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=f.cachereul@init-sys.com \
    --cc=jchapman@katalix.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).