Skip to content

Commit

Permalink
ipv4: ip_forward: perform skb->pkt_type check at the beginning
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Denis Kirjanov authored and David S. Miller committed Feb 13, 2014
1 parent 2045cea commit d4f2fa6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/ipv4/ip_forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);

/*
Expand Down

0 comments on commit d4f2fa6

Please sign in to comment.