ipv4: ip_forward: perform skb->pkt_type check at the beginning
authorDenis Kirjanov <kda@linux-powerpc.org>
Thu, 13 Feb 2014 04:58:56 +0000 (08:58 +0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Feb 2014 23:35:56 +0000 (18:35 -0500)
Packets which have L2 address different from ours should be
already filtered before entering into ip_forward().

Perform that check at the beginning to avoid processing such packets.

Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_forward.c

index e9f1217a8afdaf2559ce3fd7d134489994faf440..d9d929042a8999edab9598df495ddf40e434a238 100644 (file)
@@ -59,6 +59,10 @@ int ip_forward(struct sk_buff *skb)
        struct rtable *rt;      /* Route we use */
        struct ip_options *opt  = &(IPCB(skb)->opt);
 
+       /* that should never happen */
+       if (skb->pkt_type != PACKET_HOST)
+               goto drop;
+
        if (skb_warn_if_lro(skb))
                goto drop;
 
@@ -68,9 +72,6 @@ int ip_forward(struct sk_buff *skb)
        if (IPCB(skb)->opt.router_alert && ip_call_ra_chain(skb))
                return NET_RX_SUCCESS;
 
-       if (skb->pkt_type != PACKET_HOST)
-               goto drop;
-
        skb_forward_csum(skb);
 
        /*