netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] ipv4: ip_forward: perform skb->pkt_type check at the beginning
@ 2014-02-12  8:10 Denis Kirjanov
  2014-02-12 14:25 ` Sergei Shtylyov
  2014-02-12 14:44 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Denis Kirjanov @ 2014-02-12  8:10 UTC (permalink / raw)
  To: davem, netdev; +Cc: Denis Kirjanov

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>
---
 net/ipv4/ip_forward.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index e9f1217..1a07056 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -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);
 
 	/*
-- 
1.8.3.2

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

* Re: [PATCH net-next] ipv4: ip_forward: perform skb->pkt_type check at the beginning
  2014-02-12  8:10 [PATCH net-next] ipv4: ip_forward: perform skb->pkt_type check at the beginning Denis Kirjanov
@ 2014-02-12 14:25 ` Sergei Shtylyov
  2014-02-12 14:44 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2014-02-12 14:25 UTC (permalink / raw)
  To: Denis Kirjanov, davem, netdev

Hello.

On 12-02-2014 12:10, Denis Kirjanov wrote:

> 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>
> ---
>   net/ipv4/ip_forward.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)

> diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
> index e9f1217..1a07056 100644
> --- a/net/ipv4/ip_forward.c
> +++ b/net/ipv4/ip_forward.c
> @@ -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;
> +

    Please indent the code with tabs, not spaces.

>   	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;
> -

    Like it was here.

WBR, Sergei

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

* Re: [PATCH net-next] ipv4: ip_forward: perform skb->pkt_type check at the beginning
  2014-02-12  8:10 [PATCH net-next] ipv4: ip_forward: perform skb->pkt_type check at the beginning Denis Kirjanov
  2014-02-12 14:25 ` Sergei Shtylyov
@ 2014-02-12 14:44 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-02-12 14:44 UTC (permalink / raw)
  To: kda; +Cc: netdev

From: Denis Kirjanov <kda@linux-powerpc.org>
Date: Wed, 12 Feb 2014 12:10:32 +0400

> +    /* that should never happen */
> +    if (skb->pkt_type != PACKET_HOST)
> +        goto drop;
> +

At a minimum, this is not formatted properly.  You are using spaces
instead of TAB characters.

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

end of thread, other threads:[~2014-02-12 14:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-12  8:10 [PATCH net-next] ipv4: ip_forward: perform skb->pkt_type check at the beginning Denis Kirjanov
2014-02-12 14:25 ` Sergei Shtylyov
2014-02-12 14:44 ` David Miller

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