netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipv6: ip6mr: Recalc UDP checksum before forwarding
@ 2017-12-13 11:20 Brendan McGrath
  2017-12-13 17:21 ` Marcelo Ricardo Leitner
  2017-12-13 17:52 ` Eric Dumazet
  0 siblings, 2 replies; 7+ messages in thread
From: Brendan McGrath @ 2017-12-13 11:20 UTC (permalink / raw)
  To: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev,
	linux-kernel
  Cc: Brendan McGrath

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) {
+		struct udphdr *uh = udp_hdr(skb);
+		udp6_set_csum(false, skb, &ipv6_hdr(skb)->saddr,
+					&ipv6_hdr(skb)->daddr, ntohs(uh->len));
+	}
+
 	IP6CB(skb)->flags |= IP6SKB_FORWARDED;
 
 	return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD,
-- 
2.7.4

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

end of thread, other threads:[~2017-12-16 12:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-13 11:20 [PATCH] ipv6: ip6mr: Recalc UDP checksum before forwarding Brendan McGrath
2017-12-13 17:21 ` Marcelo Ricardo Leitner
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

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