netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ipv6: Fix protocol resubmission
@ 2015-05-29 20:04 Josh Hunt
  2015-05-29 20:27 ` Sergei Shtylyov
  0 siblings, 1 reply; 6+ messages in thread
From: Josh Hunt @ 2015-05-29 20:04 UTC (permalink / raw)
  To: davem; +Cc: netdev, tom, Josh Hunt

I came across this problem while trying to use UDP encapsulation with IPv6. The
change below fixes that, but it was not immediately apparent if there are any
other protocols relying on this broken behavior. FWIW the behavior below now
matches IPv4.

Josh

v2: Actually sets nexthdr so we can use it ;)

---

UDP encapsulation is broken on IPv6 because it expects when it returns a negative
value that the packet will be resubmitted to the stack with the handler corresponding
to the return value. The check currently looks for return values > 0 and then resubmits.

This patch fixes that check and also moves the resubmit label to take advantage of
the return code identifying the next protocol we want to process.

Signed-off-by: Josh Hunt <johunt@akamai.com>
---
 net/ipv6/ip6_input.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index f2e464e..e16c289 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -212,13 +212,13 @@ static int ip6_input_finish(struct sock *sk, struct sk_buff *skb)
 	 */
 
 	rcu_read_lock();
-resubmit:
 	idev = ip6_dst_idev(skb_dst(skb));
 	if (!pskb_pull(skb, skb_transport_offset(skb)))
 		goto discard;
 	nhoff = IP6CB(skb)->nhoff;
 	nexthdr = skb_network_header(skb)[nhoff];
 
+resubmit:
 	raw = raw6_local_deliver(skb, nexthdr);
 	ipprot = rcu_dereference(inet6_protos[nexthdr]);
 	if (ipprot) {
@@ -246,9 +246,10 @@ resubmit:
 			goto discard;
 
 		ret = ipprot->handler(skb);
-		if (ret > 0)
+		if (ret < 0) {
+			nexthdr = -ret;
 			goto resubmit;
-		else if (ret == 0)
+		} else if (ret == 0)
 			IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_INDELIVERS);
 	} else {
 		if (!raw) {
-- 
1.7.9.5

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

end of thread, other threads:[~2015-06-02 14:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-29 20:04 [PATCH v2] ipv6: Fix protocol resubmission Josh Hunt
2015-05-29 20:27 ` Sergei Shtylyov
2015-05-29 21:43   ` Josh Hunt
2015-05-29 21:48     ` Tom Herbert
2015-05-30  2:37       ` Josh Hunt
2015-06-02 14:32         ` Josh Hunt

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