netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix handling of GRO skbs in forwarding path
@ 2014-01-25 22:48 Florian Westphal
  2014-01-25 22:48 ` [PATCH 1/2] net: add and use skb_gso_transport_seglen() Florian Westphal
  2014-01-25 22:48 ` [PATCH 2/2] net: ip, ipv6: handle gso skbs in forwarding path Florian Westphal
  0 siblings, 2 replies; 32+ messages in thread
From: Florian Westphal @ 2014-01-25 22:48 UTC (permalink / raw)
  To: netdev; +Cc: eric.dumazet

Marcelo Ricardo Leitner reported problems when the forwarding link
path has a lower mtu than the incoming link if the inbound interface
supports GRO.

Currently GSO/GRO skbs bypass all dst MTU checks, i.e. forwarding of
such skbs fails in case the outgoing link mtu is smaller than the one
of the incoming interface: We neither generate an icmp error nor will
the packet be fragmented if ipv4 would permit it.

The first patch moves part of Eric Dumazets skb_gso_seglen helper from
sch_tbf to skbuff core for re-use in forwarding path.

The 2nd change then alters forwarding path to handle GRO skbs.

It is not 100% correct, since the icmp error will contain the headers
of the GRO skb instead of the original/segmented one, but it seems to
work fine in my (limited) tests.

Software segmentation is done for ipv4 if the DF bit is not set.

If you think this is -next material just set patchwork state to
"deferred", I'll resend then once -next is open again.

 include/linux/skbuff.h |   18 +++++++++++++++
 net/core/skbuff.c      |   26 +++++++++++++++++++++
 net/ipv4/ip_forward.c  |   58 +++++++++++++++++++++++++++++++++++++++++++++++--
 net/ipv6/ip6_output.c  |   18 +++++++++++++--
 net/sched/sch_tbf.c    |   12 ++--------
 5 files changed, 119 insertions(+), 13 deletions(-)

^ permalink raw reply	[flat|nested] 32+ messages in thread
* [PATCH 1/2] net: add and use skb_gso_transport_seglen()
@ 2014-01-27  8:22 Florian Westphal
  2014-01-27  8:22 ` [PATCH 2/2] net: ip, ipv6: handle gso skbs in forwarding path Florian Westphal
  0 siblings, 1 reply; 32+ messages in thread
From: Florian Westphal @ 2014-01-27  8:22 UTC (permalink / raw)
  To: netdev; +Cc: Florian Westphal

This moves part of Eric Dumazets skb_gso_seglen helper from tbf sched to
skbuff core so it may be reused by upcoming ip forwarding path patch.

Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 No changes since V2, resending since patch 2/2 had issues
 and I don't see 1/2 in net tree.

 Changes since V1:
  suggestions from Eric Dumazet:
  - don't use uapi udp.h
  - remove tcp.h include from tbf, its not needed anymore

 include/linux/skbuff.h |  1 +
 net/core/skbuff.c      | 25 +++++++++++++++++++++++++
 net/sched/sch_tbf.c    | 13 +++----------
 3 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 1f689e6..f589c9a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2456,6 +2456,7 @@ void skb_zerocopy(struct sk_buff *to, const struct sk_buff *from,
 void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len);
 int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen);
 void skb_scrub_packet(struct sk_buff *skb, bool xnet);
+unsigned int skb_gso_transport_seglen(const struct sk_buff *skb);
 struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features);
 
 struct skb_checksum_ops {
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 8f519db..9ae6d11 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -47,6 +47,8 @@
 #include <linux/in.h>
 #include <linux/inet.h>
 #include <linux/slab.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
 #include <linux/netdevice.h>
 #ifdef CONFIG_NET_CLS_ACT
 #include <net/pkt_sched.h>
@@ -3916,3 +3918,26 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet)
 	nf_reset_trace(skb);
 }
 EXPORT_SYMBOL_GPL(skb_scrub_packet);
+
+/**
+ * skb_gso_transport_seglen - Return length of individual segments of a gso packet
+ *
+ * @skb: GSO skb
+ *
+ * skb_gso_transport_seglen is used to determine the real size of the
+ * individual segments, including Layer4 headers (TCP/UDP).
+ *
+ * The MAC/L2 or network (IP, IPv6) headers are not accounted for.
+ */
+unsigned int skb_gso_transport_seglen(const struct sk_buff *skb)
+{
+	const struct skb_shared_info *shinfo = skb_shinfo(skb);
+	unsigned int hdr_len;
+
+	if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
+		hdr_len = tcp_hdrlen(skb);
+	else
+		hdr_len = sizeof(struct udphdr);
+	return hdr_len + shinfo->gso_size;
+}
+EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index fbba5b0..1cb413f 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -21,7 +21,6 @@
 #include <net/netlink.h>
 #include <net/sch_generic.h>
 #include <net/pkt_sched.h>
-#include <net/tcp.h>
 
 
 /*	Simple Token Bucket Filter.
@@ -148,16 +147,10 @@ static u64 psched_ns_t2l(const struct psched_ratecfg *r,
  * Return length of individual segments of a gso packet,
  * including all headers (MAC, IP, TCP/UDP)
  */
-static unsigned int skb_gso_seglen(const struct sk_buff *skb)
+static unsigned int skb_gso_mac_seglen(const struct sk_buff *skb)
 {
 	unsigned int hdr_len = skb_transport_header(skb) - skb_mac_header(skb);
-	const struct skb_shared_info *shinfo = skb_shinfo(skb);
-
-	if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
-		hdr_len += tcp_hdrlen(skb);
-	else
-		hdr_len += sizeof(struct udphdr);
-	return hdr_len + shinfo->gso_size;
+	return hdr_len + skb_gso_transport_seglen(skb);
 }
 
 /* GSO packet is too big, segment it so that tbf can transmit
@@ -202,7 +195,7 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 	int ret;
 
 	if (qdisc_pkt_len(skb) > q->max_size) {
-		if (skb_is_gso(skb) && skb_gso_seglen(skb) <= q->max_size)
+		if (skb_is_gso(skb) && skb_gso_mac_seglen(skb) <= q->max_size)
 			return tbf_segment(skb, sch);
 		return qdisc_reshape_fail(skb, sch);
 	}
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread
* [PATCH stable 3.4.y 0/2] gso/gro forwarding changeset
@ 2014-02-22  9:33 Florian Westphal
  2014-02-22  9:33 ` [PATCH 2/2] net: ip, ipv6: handle gso skbs in forwarding path Florian Westphal
  0 siblings, 1 reply; 32+ messages in thread
From: Florian Westphal @ 2014-02-22  9:33 UTC (permalink / raw)
  To: netdev

Dropped the 2nd patch of the series (addition of netif_skb_dev_features)
for the longterm-backport.

The forward path will use 0 feature mask instead.
I think it is preferable to keep the changeset smaller for these kernels.

Should apply to 3.2.y as well.

Let me know if you disagree and would like to have netif_skb_dev_features
backport too.

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

end of thread, other threads:[~2014-02-22  9:37 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-25 22:48 [PATCH 0/2] Fix handling of GRO skbs in forwarding path Florian Westphal
2014-01-25 22:48 ` [PATCH 1/2] net: add and use skb_gso_transport_seglen() Florian Westphal
2014-01-26  1:28   ` Eric Dumazet
2014-01-26  9:19     ` Florian Westphal
2014-01-25 22:48 ` [PATCH 2/2] net: ip, ipv6: handle gso skbs in forwarding path Florian Westphal
2014-01-26  1:37   ` Eric Dumazet
2014-01-26  9:22     ` Florian Westphal
  -- strict thread matches above, loose matches on Subject: below --
2014-01-27  8:22 [PATCH 1/2] net: add and use skb_gso_transport_seglen() Florian Westphal
2014-01-27  8:22 ` [PATCH 2/2] net: ip, ipv6: handle gso skbs in forwarding path Florian Westphal
2014-01-27  8:34   ` David Miller
2014-01-27  8:36     ` Florian Westphal
2014-01-27 18:22   ` Eric Dumazet
2014-01-27 20:58     ` David Miller
2014-01-27 21:08       ` David Miller
2014-01-28  0:27     ` Hannes Frederic Sowa
2014-01-28  9:12       ` Florian Westphal
2014-01-29 10:53       ` Florian Westphal
2014-01-29 11:04         ` Hannes Frederic Sowa
2014-01-28  8:57     ` Florian Westphal
2014-01-28 16:34       ` Eric Dumazet
2014-01-28 17:15         ` Florian Westphal
2014-01-28 17:30           ` Eric Dumazet
2014-01-28 17:37             ` Florian Westphal
2014-01-29 11:00         ` Florian Westphal
2014-02-09  2:55         ` Herbert Xu
2014-02-10 12:23           ` Florian Westphal
2014-02-10 12:31             ` Herbert Xu
2014-02-10 12:43               ` Florian Westphal
2014-02-10 12:50                 ` Herbert Xu
2014-02-10 13:08                   ` Eric Dumazet
2014-02-10 13:15                 ` Eric Dumazet
2014-02-10 13:12               ` Eric Dumazet
2014-02-22  9:33 [PATCH stable 3.4.y 0/2] gso/gro forwarding changeset Florian Westphal
2014-02-22  9:33 ` [PATCH 2/2] net: ip, ipv6: handle gso skbs in forwarding path Florian Westphal

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