linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Brendan McGrath <redmcg@redmandi.dyndns.org>
Cc: "David S . Miller" <davem@davemloft.net>,
	Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipv6: ip6mr: Recalc UDP checksum before forwarding
Date: Wed, 13 Dec 2017 15:21:40 -0200	[thread overview]
Message-ID: <20171213172140.GC3531@localhost.localdomain> (raw)
In-Reply-To: <1513164048-21368-1-git-send-email-redmcg@redmandi.dyndns.org>

Hi,

On Wed, Dec 13, 2017 at 10:20:48PM +1100, Brendan McGrath wrote:
> Currently, when forwarding from a Virtual Interface to a Physical
> Interface, ip_summed is set to a value of CHECKSUM_UNNECESSARY and
> the UDP checksum has not been calculated.
> 
> When the packet is then forwarded by a Multicast Router, the checksum
> value is left as is and therefore rejected by the receiving
> machine(s).
> 
> This patch ensures the checksum is recalculated before forwarding.
> 
> Signed-off-by: Brendan McGrath <redmcg@redmandi.dyndns.org>
> ---
> 
> It's a bit ugly putting UDP specific code in this spot - but I'm not
> aware of any other protocols that are:
> a) multicast;
> b) forwarded; and
> c) checksummed
> 
>  net/ipv6/ip6mr.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
> index 890f9bda..ee4370a 100644
> --- a/net/ipv6/ip6mr.c
> +++ b/net/ipv6/ip6mr.c
> @@ -2077,6 +2077,13 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt,
>  	ipv6h = ipv6_hdr(skb);
>  	ipv6h->hop_limit--;
>  
> +	if (ipv6h->nexthdr == NEXTHDR_UDP &&
> +					skb->ip_summed != CHECKSUM_PARTIAL) {
	    ^

This indentation is wrong. The 2nd line should start right after the (
column in the 1st line, like:
+	if (ipv6h->nexthdr == NEXTHDR_UDP &&
+	    skb->ip_summed != CHECKSUM_PARTIAL) {
Adjust with spaces as needed.

Running the patch through scripts/checkpatch.pl before posting will
catch these.

> +		struct udphdr *uh = udp_hdr(skb);
> +		udp6_set_csum(false, skb, &ipv6_hdr(skb)->saddr,
> +					&ipv6_hdr(skb)->daddr, ntohs(uh->len));
                              ^  same deal here.

> +	}
> +
>  	IP6CB(skb)->flags |= IP6SKB_FORWARDED;
>  
>  	return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD,
> -- 
> 2.7.4
> 

  reply	other threads:[~2017-12-13 17:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 11:20 [PATCH] ipv6: ip6mr: Recalc UDP checksum before forwarding Brendan McGrath
2017-12-13 17:21 ` Marcelo Ricardo Leitner [this message]
2017-12-13 17:52 ` Eric Dumazet
2017-12-13 19:02   ` Brendan McGrath
2017-12-14 11:37   ` [PATCHv2] " Brendan McGrath
2017-12-15 18:27     ` David Miller
2017-12-16 12:19       ` Brendan McGrath

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=20171213172140.GC3531@localhost.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=redmcg@redmandi.dyndns.org \
    --cc=yoshfuji@linux-ipv6.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).