diff mbox

[net-next] ipv6: ip6_forward: perform skb->pkt_type check at the beginning

Message ID 1394428220-9955-1-git-send-email-roy.qing.li@gmail.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Li RongQing March 10, 2014, 5:10 a.m. UTC
From: Li RongQing <roy.qing.li@gmail.com> 

Packets which have L2 address different from ours should be
already filtered before entering into ip6_forward().

Perform that check at the beginning to avoid processing such packets.
And use unlikely to optimise.

Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
 net/ipv6/ip6_output.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

David Miller March 11, 2014, 1:49 a.m. UTC | #1
From: roy.qing.li@gmail.com
Date: Mon, 10 Mar 2014 13:10:20 +0800

> From: Li RongQing <roy.qing.li@gmail.com> 
> 
> Packets which have L2 address different from ours should be
> already filtered before entering into ip6_forward().
> 
> Perform that check at the beginning to avoid processing such packets.
> And use unlikely to optimise.
> 
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>

Based upon Eric's feedback for your ipv4 patch, please remove
the unlikely() for this ipv6 one.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 2bc1070..90dd551 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -367,6 +367,9 @@  int ip6_forward(struct sk_buff *skb)
 	if (net->ipv6.devconf_all->forwarding == 0)
 		goto error;
 
+	if (unlikely(skb->pkt_type != PACKET_HOST))
+		goto drop;
+
 	if (skb_warn_if_lro(skb))
 		goto drop;
 
@@ -376,9 +379,6 @@  int ip6_forward(struct sk_buff *skb)
 		goto drop;
 	}
 
-	if (skb->pkt_type != PACKET_HOST)
-		goto drop;
-
 	skb_forward_csum(skb);
 
 	/*