All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Neil Horman <nhorman@tuxdriver.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	"David S. Miller" <davem@davemloft.net>,
	netem@lists.linux-foundation.org, eric.dumazet@gmail.com,
	stephen@networkplumber.org, Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 67/76] netem: Segment GSO packets on enqueue
Date: Thu, 19 May 2016 11:08:29 +0200	[thread overview]
Message-ID: <521a3b4187e1999deb63557d2d3648bc7bbf27cb.1463648873.git.jslaby@suse.cz> (raw)
In-Reply-To: <c4ec97c341630e22e546c1a628a3664f17f7ffc8.1463648873.git.jslaby@suse.cz>
In-Reply-To: <cover.1463648873.git.jslaby@suse.cz>

From: Neil Horman <nhorman@tuxdriver.com>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

[ Upstream commit 6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]

This was recently reported to me, and reproduced on the latest net kernel,
when attempting to run netperf from a host that had a netem qdisc attached
to the egress interface:

[  788.073771] ---------------------[ cut here ]---------------------------
[  788.096716] WARNING: at net/core/dev.c:2253 skb_warn_bad_offload+0xcd/0xda()
[  788.129521] bnx2: caps=(0x00000001801949b3, 0x0000000000000000) len=2962
data_len=0 gso_size=1448 gso_type=1 ip_summed=3
[  788.182150] Modules linked in: sch_netem kvm_amd kvm crc32_pclmul ipmi_ssif
ghash_clmulni_intel sp5100_tco amd64_edac_mod aesni_intel lrw gf128mul
glue_helper ablk_helper edac_mce_amd cryptd pcspkr sg edac_core hpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdt ipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrect sysimgblt
i2c_algo_bit drm_kms_helper ahci ata_generic pata_acpi ttm libahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_common drm crc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_core i2c_core mii dm_mirror dm_region_hash dm_log
dm_mod
[  788.465294] CPU: 16 PID: 0 Comm: swapper/16 Tainted: G        W
------------   3.10.0-327.el7.x86_64 #1
[  788.511521] Hardware name: HP ProLiant DL385p Gen8, BIOS A28 12/17/2012
[  788.542260]  ffff880437c036b8 f7afc56532a53db9 ffff880437c03670
ffffffff816351f1
[  788.576332]  ffff880437c036a8 ffffffff8107b200 ffff880633e74200
ffff880231674000
[  788.611943]  0000000000000001 0000000000000003 0000000000000000
ffff880437c03710
[  788.647241] Call Trace:
[  788.658817]  <IRQ>  [<ffffffff816351f1>] dump_stack+0x19/0x1b
[  788.686193]  [<ffffffff8107b200>] warn_slowpath_common+0x70/0xb0
[  788.713803]  [<ffffffff8107b29c>] warn_slowpath_fmt+0x5c/0x80
[  788.741314]  [<ffffffff812f92f3>] ? ___ratelimit+0x93/0x100
[  788.767018]  [<ffffffff81637f49>] skb_warn_bad_offload+0xcd/0xda
[  788.796117]  [<ffffffff8152950c>] skb_checksum_help+0x17c/0x190
[  788.823392]  [<ffffffffa01463a1>] netem_enqueue+0x741/0x7c0 [sch_netem]
[  788.854487]  [<ffffffff8152cb58>] dev_queue_xmit+0x2a8/0x570
[  788.880870]  [<ffffffff8156ae1d>] ip_finish_output+0x53d/0x7d0
...

The problem occurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help in its enqueue path, which cannot manipulate these
frames).

The solution I think is to simply segment the skb in a simmilar fashion to the
way we do in __dev_queue_xmit (via validate_xmit_skb), with some minor changes.
When we decide to corrupt an skb, if the frame is GSO, we segment it, corrupt
the first segment, and enqueue the remaining ones.

tested successfully by myself on the latest net kernel, to which this applies

[js] backport to 3.12: no qdisc_qstats_drop yet, update directly. Also use
     qdisc_tree_decrease_qlen instead of qdisc_tree_reduce_backlog.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Jamal Hadi Salim <jhs@mojatatu.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: netem@lists.linux-foundation.org
CC: eric.dumazet@gmail.com
CC: stephen@networkplumber.org
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/sched/sch_netem.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 59 insertions(+), 2 deletions(-)

diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index b87e83d07478..14ac1a1e1bbf 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -394,6 +394,25 @@ static void tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch)
 	sch->q.qlen++;
 }
 
+/* netem can't properly corrupt a megapacket (like we get from GSO), so instead
+ * when we statistically choose to corrupt one, we instead segment it, returning
+ * the first packet to be corrupted, and re-enqueue the remaining frames
+ */
+static struct sk_buff *netem_segment(struct sk_buff *skb, struct Qdisc *sch)
+{
+	struct sk_buff *segs;
+	netdev_features_t features = netif_skb_features(skb);
+
+	segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
+
+	if (IS_ERR_OR_NULL(segs)) {
+		qdisc_reshape_fail(skb, sch);
+		return NULL;
+	}
+	consume_skb(skb);
+	return segs;
+}
+
 /*
  * Insert one skb into qdisc.
  * Note: parent depends on return value to account for queue length.
@@ -406,7 +425,11 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 	/* We don't fill cb now as skb_unshare() may invalidate it */
 	struct netem_skb_cb *cb;
 	struct sk_buff *skb2;
+	struct sk_buff *segs = NULL;
+	unsigned int len = 0, last_len;
+	int nb = 0;
 	int count = 1;
+	int rc = NET_XMIT_SUCCESS;
 
 	/* Random duplication */
 	if (q->duplicate && q->duplicate >= get_crandom(&q->dup_cor))
@@ -452,10 +475,23 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 	 * do it now in software before we mangle it.
 	 */
 	if (q->corrupt && q->corrupt >= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				return NET_XMIT_DROP;
+		} else {
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			return qdisc_drop(skb, sch);
+		     skb_checksum_help(skb))) {
+			rc = qdisc_drop(skb, sch);
+			goto finish_segs;
+		}
 
 		skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);
 	}
@@ -514,6 +550,27 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 		sch->qstats.requeues++;
 	}
 
+finish_segs:
+	if (segs) {
+		while (segs) {
+			skb2 = segs->next;
+			segs->next = NULL;
+			qdisc_skb_cb(segs)->pkt_len = segs->len;
+			last_len = segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					sch->qstats.drops++;
+			} else {
+				nb++;
+				len += last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qlen += nb;
+		if (nb > 1)
+			qdisc_tree_decrease_qlen(sch, 1 - nb);
+	}
 	return NET_XMIT_SUCCESS;
 }
 
-- 
2.8.2

  parent reply	other threads:[~2016-05-19  9:12 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 01/76] crypto: gcm - Fix rfc4543 decryption crash Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 02/76] ARM: OMAP2+: hwmod: Fix updating of sysconfig register Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 03/76] usb: xhci: fix wild pointers in xhci_mem_cleanup Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 04/76] usb: hcd: out of bounds access in for_each_companion Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 05/76] lib: lz4: fixed zram with lz4 on big endian machines Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 06/76] drm/qxl: fix cursor position with non-zero hotspot Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 07/76] nl80211: check netlink protocol in socket release notification Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 08/76] Input: gtco - fix crash on detecting device without endpoints Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 09/76] pinctrl: single: Fix pcs_parse_bits_in_pinctrl_entry to use __ffs than ffs Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 10/76] EDAC: i7core, sb_edac: Don't return NOTIFY_BAD from mce_decoder callback Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 11/76] ASoC: s3c24xx: use const snd_soc_component_driver pointer Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 12/76] ASoC: rt5640: Correct the digital interface data select Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 13/76] efi: Fix out-of-bounds read in variable_matches() Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 14/76] workqueue: fix ghost PENDING flag while doing MQ IO Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 15/76] paride: make 'verbose' parameter an 'int' again Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 16/76] fbdev: da8xx-fb: fix videomodes of lcd panels Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 17/76] misc/bmp085: Enable building as a module Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 18/76] rtc: vr41xx: Wire up alarm_irq_enable Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 19/76] drivers/misc/ad525x_dpot: AD5274 fix RDAC read back errors Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 20/76] serial: sh-sci: Remove cpufreq notifier to fix crash/deadlock Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 21/76] include/linux/poison.h: fix LIST_POISON{1,2} offset Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 22/76] Drivers: hv: vmbus: prevent cpu offlining on newer hypervisors Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 23/76] perf stat: Document --detailed option Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 24/76] ARM: OMAP3: Add cpuidle parameters table for omap3430 Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 25/76] bus: imx-weim: Take the 'status' property value into account Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 26/76] sunrpc/cache: drop reference when sunrpc_cache_pipe_upcall() detects a race Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 27/76] Revert "xfs: add capability check to free eofblocks ioctl" Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 28/76] mmc: sdhci: Allow for irq being shared Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 29/76] scsi: Avoid crashing if device uses DIX but adapter does not support it Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 30/76] cpuset: Fix potential deadlock w/ set_mems_allowed Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 31/76] compiler-gcc: disable -ftracer for __noclone functions Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 32/76] x86: LLVMLinux: Fix "incomplete type const struct x86cpu_device_id" Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 33/76] ipvs: correct initial offset of Call-ID header search in SIP persistence engine Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 34/76] nbd: ratelimit error msgs after socket close Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 35/76] clk: versatile: sp810: support reentrance Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 36/76] lpfc: fix misleading indentation Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 37/76] ARM: SoCFPGA: Fix secondary CPU startup in thumb2 kernel Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 38/76] proc: prevent accessing /proc/<PID>/environ until it's ready Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 39/76] batman-adv: Check skb size before using encapsulated ETH+VLAN header Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 40/76] batman-adv: Fix broadcast/ogm queue limit on a removed interface Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 41/76] batman-adv: Reduce refcnt of removed router when updating route Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 42/76] MAINTAINERS: Remove asterisk from EFI directory names Jiri Slaby
2016-05-19  9:08   ` Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 43/76] x86/sysfb_efi: Fix valid BAR address range check Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 44/76] ACPICA: Dispatcher: Update thread ID for recursive method calls Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 45/76] USB: serial: cp210x: add ID for Link ECU Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 46/76] USB: serial: cp210x: add Straizona Focusers device ids Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 47/76] iio: ak8975: Fix NULL pointer exception on early interrupt Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 48/76] Input: ads7846 - correct the value got from SPI Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 49/76] powerpc: scan_features() updates incorrect bits for REAL_LE Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 50/76] Input: i8042 - lower log level for "no controller" message Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 51/76] mm/balloon_compaction: redesign ballooned pages management Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 52/76] mm/balloon_compaction: fix deflation when compaction is disabled Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 53/76] crypto: hash - Fix page length clamping in hash walk Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 54/76] get_rock_ridge_filename(): handle malformed NM entries Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 55/76] Input: max8997-haptic - fix NULL pointer dereference Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 56/76] asmlinkage, pnp: Make variables used from assembler code visible Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 57/76] drm/radeon: fix PLL sharing on DCE6.1 (v2) Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 58/76] drm/i915: Bail out of pipe config compute loop on LPT Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 59/76] ARM: OMAP3: Fix booting with thumb2 kernel Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 60/76] net/route: enforce hoplimit max value Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 61/76] decnet: Do not build routes to devices without decnet private data Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 62/76] route: do not cache fib route info on local routes with oif Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 63/76] packet: fix heap info leak in PACKET_DIAG_MCLIST sock_diag interface Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 64/76] atl2: Disable unimplemented scatter/gather feature Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 65/76] ipv4/fib: don't warn when primary address is missing if in_dev is dead Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 66/76] net/mlx4_en: fix spurious timestamping callbacks Jiri Slaby
2016-05-19  9:08 ` Jiri Slaby [this message]
2016-05-19  9:08 ` [PATCH 3.12 68/76] net: fix infoleak in llc Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 69/76] net: fix infoleak in rtnetlink Jiri Slaby
2016-05-20 12:04   ` Vegard Nossum
     [not found]     ` <CABEk9YxT4eRBrEhkrCNHwM9yuFKRW4bBcrAfjgW0iyS0q3v65A@mail.gmail.com>
2016-05-20 14:25       ` Vegard Nossum
2016-05-20 16:45     ` David Miller
2016-05-21  0:43       ` Hannes Frederic Sowa
2016-05-19  9:08 ` [PATCH 3.12 70/76] VSOCK: do not disconnect socket when peer has shutdown SEND only Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 71/76] net: bridge: fix old ioctl unlocked net device walk Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 72/76] net: fix a kernel infoleak in x25 module Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 73/76] ASN.1: Fix non-match detection failure on data overrun Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 74/76] KEYS: Fix ASN.1 indefinite length object parsing Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 75/76] sched: Remove lockdep check in sched_move_task() Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 76/76] X.509: remove possible code fragility: enumeration values not handled Jiri Slaby
2016-05-19 13:52 ` [PATCH 3.12 00/76] 3.12.60-stable review Guenter Roeck
2016-05-23  9:49   ` Jiri Slaby
2016-05-24 12:58 ` Shuah Khan
2016-05-24 13:55   ` Jiri Slaby

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=521a3b4187e1999deb63557d2d3648bc7bbf27cb.1463648873.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netem@lists.linux-foundation.org \
    --cc=nhorman@tuxdriver.com \
    --cc=stable@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.