netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: David Miller <davem@davemloft.net>
Cc: Kieran Mansley <kmansley@solarflare.com>,
	Stephen Hemminger <shemminger@vyatta.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH 1/2] Disable forwarding of LRO skbs
Date: Wed, 30 Apr 2008 22:51:26 +0100	[thread overview]
Message-ID: <20080430215125.GD14219@solarflare.com> (raw)
In-Reply-To: <20080430214845.GC14219@solarflare.com>

Add skb_warn_if_lro() to test whether an skb was received with LRO and
warn if so.

Change br_forward(), ip_forward() and ip6_forward() to call
skb_warn_if_lro() and discard the skb if it returns true.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 11fd9f2..18644cd 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1701,6 +1701,8 @@ static inline int skb_is_gso_v6(const struct sk_buff *skb)
 	return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6;
 }
 
+extern bool skb_warn_if_lro(const struct sk_buff *skb);
+
 static inline void skb_forward_csum(struct sk_buff *skb)
 {
 	/* Unfortunately we don't support this one.  Any brave souls? */
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 4fe605f..bfd80c6 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2582,6 +2582,15 @@ bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off)
 	return true;
 }
 
+bool skb_warn_if_lro(const struct sk_buff *skb)
+{
+	bool ret = unlikely(skb_is_gso(skb));
+	if (ret && net_ratelimit())
+		pr_warning("%s: received packets cannot be forwarded"
+			   " while LRO is enabled\n", skb->dev->name);
+	return ret;
+}
+
 EXPORT_SYMBOL(___pskb_trim);
 EXPORT_SYMBOL(__kfree_skb);
 EXPORT_SYMBOL(kfree_skb);
@@ -2615,6 +2624,7 @@ EXPORT_SYMBOL(skb_seq_read);
 EXPORT_SYMBOL(skb_abort_seq_read);
 EXPORT_SYMBOL(skb_find_text);
 EXPORT_SYMBOL(skb_append_datato_frags);
+EXPORT_SYMBOL(skb_warn_if_lro);
 
 EXPORT_SYMBOL_GPL(skb_to_sgvec);
 EXPORT_SYMBOL_GPL(skb_cow_data);
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index bdd7c35..cfee7c2 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -91,7 +91,7 @@ void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
 /* called with rcu_read_lock */
 void br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
 {
-	if (should_deliver(to, skb)) {
+	if (!skb_warn_if_lro(skb) && should_deliver(to, skb)) {
 		__br_forward(to, skb);
 		return;
 	}
diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index 4813c39..a6e4cfa 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -58,6 +58,9 @@ int ip_forward(struct sk_buff *skb)
 	struct rtable *rt;	/* Route we use */
 	struct ip_options * opt	= &(IPCB(skb)->opt);
 
+	if (skb_warn_if_lro(skb))
+		goto drop;
+
 	if (!xfrm4_policy_check(NULL, XFRM_POLICY_FWD, skb))
 		goto drop;
 
@@ -85,7 +88,7 @@ int ip_forward(struct sk_buff *skb)
 	if (opt->is_strictroute && rt->rt_dst != rt->rt_gateway)
 		goto sr_failed;
 
-	if (unlikely(skb->len > dst_mtu(&rt->u.dst) && !skb_is_gso(skb) &&
+	if (unlikely(skb->len > dst_mtu(&rt->u.dst) &&
 		     (ip_hdr(skb)->frag_off & htons(IP_DF))) && !skb->local_df) {
 		IP_INC_STATS(IPSTATS_MIB_FRAGFAILS);
 		icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 0af2e05..c7f4eec 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -409,6 +409,9 @@ int ip6_forward(struct sk_buff *skb)
 	if (ipv6_devconf.forwarding == 0)
 		goto error;
 
+	if (skb_warn_if_lro(skb))
+		goto drop;
+
 	if (!xfrm6_policy_check(NULL, XFRM_POLICY_FWD, skb)) {
 		IP6_INC_STATS(ip6_dst_idev(dst), IPSTATS_MIB_INDISCARDS);
 		goto drop;

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.

  reply	other threads:[~2008-04-30 21:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-30 21:48 [PATCH 0/2] Disable forwarding of LRO skbs Ben Hutchings
2008-04-30 21:51 ` Ben Hutchings [this message]
2008-05-01  9:51   ` [PATCH 1/2] " David Miller
2008-04-30 21:54 ` [PATCH 2/2] " Ben Hutchings
2008-04-30 21:58 ` [PATCH 0/2] " David Miller
2008-05-01 10:19   ` Herbert Xu
2008-05-01 10:34     ` David Miller
2008-05-01 10:38       ` Herbert Xu
2008-05-01 10:45         ` Herbert Xu
2008-05-01 10:52           ` David Miller
2008-05-01 10:55             ` Herbert Xu
2008-05-01 11:04               ` Kieran Mansley
2008-05-01 10:51         ` David Miller
2008-05-01 10:53           ` Herbert Xu
2008-05-01 11:00     ` Kieran Mansley
2008-05-01 11:06       ` Herbert Xu
2008-05-01 10:42 ` Herbert Xu
2008-05-01 11:02   ` Ben Hutchings
2008-05-01 11:08     ` Kieran Mansley
2008-05-01 11:12       ` Herbert Xu
2008-05-01 11:18         ` Kieran Mansley
2008-05-01 11:37           ` Herbert Xu
2008-05-01 12:08             ` Ben Hutchings
2008-05-01 12:19               ` Herbert Xu
2008-05-12 14:48                 ` Ben Hutchings
2008-05-01 14:06     ` Herbert Xu
2008-06-15  0:51       ` Ben Hutchings
2008-06-15  1:46         ` Ben Hutchings
2008-06-15  3:38           ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080430215125.GD14219@solarflare.com \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=kmansley@solarflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).