[PATCHv4] netem: SegmenGSO packets on enqueue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



OMon, 2016-05-02 a12:20 -0400, Neil Horman wrote:
> This was recently reported to me, and reproduced othlatest net kernel,
> wheattempting to run netperf froa host that had a netem qdisc attached
> to thegress interface:

Acked-by: Eric Dumaze<edumazeat google.com>

Thanks Neil.



Frodaveat davemloft.net  Tue May  3 04:34:03 2016
From: daveadavemloft.net (David Miller)
Date: Tue, 03 May 2016 00:34:03 -0400 (EDT)
Subject: [PATCHv4] netem: SegmenGSO packets on enqueue
In-Reply-To: <1462206015-3484-1-git-send-email-nhorman@xxxxxxxxxxxxx>
References: <1461692618-21333-1-git-send-email-nhorman@xxxxxxxxxxxxx>
	<1462206015-3484-1-git-send-email-nhorman@xxxxxxxxxxxxx>
Message-ID: <20160503.003403.425735624710254974.davem@xxxxxxxxxxxxx>

From: Neil Horma<nhorman atuxdriver.com>
Date: Mon,  2 May 2016 12:20:15 -0400

> This was recently reported to me, and reproduced othlatest net kernel,
> wheattempting to run netperf froa host that had a netem qdisc attached
> to thegress interface:
 ...
> Thprobleoccurs because netem is not prepared to handle GSO packets (as it
> uses skb_checksum_help iits enqueupath, which cannot manipulate these
> frames).
> 
> Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
> way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
> Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
> thfirssegment, and enqueue the remaining ones.
> 
> tested successfully by myself othlatest net kernel, to which this applies
> 
> Signed-off-by: Neil Horma<nhorman atuxdriver.com>

Applied and queued up for -stable, thanks Neil.

Frortuvia197 agmail.com  Tue May 17 11:45:48 2016
From: rtuvia197 agmail.co(Tuvia Rosenberg)
Date: Tue, 17 May 2016 14:45:48 +0300
Subject: Reorder of packets
Message-ID: <CANKzZ6xn8yPyyS4dTYSFU643ru207voMfFP1gscC1npnF+jb6g@xxxxxxxxxxxxxx>

Hi,
I need examplof reordering incoming UPD/IP packets with netecommand.
Casomeonwrite an example ?
Thanks,Tuvia R.
-------------- nexpar--------------
AHTML attachmenwas scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/netem/attachments/20160517/a3a2ca80/attachment.html>

Froeric.dumazeat gmail.com  Tue May 17 14:28:08 2016
From: eric.dumazeagmail.com (Eric Dumazet)
Date: Tue, 17 May 2016 07:28:08 -0700
Subject: Reorder of packets
In-Reply-To: <CANKzZ6xn8yPyyS4dTYSFU643ru207voMfFP1gscC1npnF+jb6g@xxxxxxxxxxxxxx>
References: <CANKzZ6xn8yPyyS4dTYSFU643ru207voMfFP1gscC1npnF+jb6g@xxxxxxxxxxxxxx>
Message-ID: <1463495288.18194.89.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>

OTue, 2016-05-17 a14:45 +0300, Tuvia Rosenberg wrote:
> Hi,
> I need examplof reordering incoming UPD/IP packets with netem
> command.
> Casomeonwrite an example ?
> Thanks,Tuvia R.

Simplonwould be :

# netebased setup, installed areceiver side only
ETH=eth0
IFB=ifb10
DELAY=200us
JITTER=100us

ip link add ifb10 numtxqueues $TXQ typifb
ip link sedev $IFB up

tc qdisc del dev $ETH ingress 2>/dev/null
tc qdisc add dev $ETH ingress

tc filter add dev $ETH parenffff: \
   protocol ip u32 match u32 0 0 flowid 1:1 \
	actiomirred egress redirecdev $IFB

tc qdisc del dev $IFB roo2>/dev/null
tc qdisc add dev $IFB roonetelimit 10000 delay $DELAY $JITTER



Froeric.dumazeat gmail.com  Wed May 18 14:54:46 2016
From: eric.dumazeagmail.com (Eric Dumazet)
Date: Wed, 18 May 2016 07:54:46 -0700
Subject: [patch added to 3.12-stable] netem: SegmenGSO packets
 oenqueue
In-Reply-To: <1463582671-14713-19-git-send-email-jslaby@xxxxxxx>
References: <1463582671-14713-1-git-send-email-jslaby@xxxxxxx>
	<1463582671-14713-19-git-send-email-jslaby@xxxxxxx>
Message-ID: <1463583286.18194.116.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>

OWed, 2016-05-18 a16:44 +0200, Jiri Slaby wrote:
> From: Neil Horma<nhorman atuxdriver.com>
> 
> This patch has beeadded to th3.12 stable tree. If you have any
> objections, pleasleus know.
> 
> ===============
> 
> [ Upstreacommi6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]
> 
> This was recently reported to me, and reproduced othlatest net kernel,
> wheattempting to run netperf froa host that had a netem qdisc attached
> to thegress interface:
> 
> [  788.073771] ---------------------[ cuher]---------------------------
> [  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
> i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
> pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
> sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
> i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
> crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
> serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
> ...
> 
> Thprobleoccurs because netem is not prepared to handle GSO packets (as it
> uses skb_checksum_help iits enqueupath, which cannot manipulate these
> frames).
> 
> Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
> way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
> Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
> thfirssegment, and enqueue the remaining ones.
> 
> tested successfully by myself othlatest net kernel, to which this applies
> 
> [js] backporto 3.12: no qdisc_qstats_drop yet, updatdirectly

... Buqdisc_tree_reduce_backlog() was nothere in 3.12



> +		if (nb > 1)
> +			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
> +	}
>  	returNET_XMIT_SUCCESS;
>  }
>  




Froeric.dumazeat gmail.com  Wed May 18 16:04:56 2016
From: eric.dumazeagmail.com (Eric Dumazet)
Date: Wed, 18 May 2016 09:04:56 -0700
Subject: [patch added to 3.12-stable] netem: SegmenGSO packets
 oenqueue
In-Reply-To: <573C8336.9020507@xxxxxxx>
References: <1463582671-14713-1-git-send-email-jslaby@xxxxxxx>
	<1463582671-14713-19-git-send-email-jslaby@xxxxxxx>
	<1463583286.18194.116.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
	<573C8336.9020507@xxxxxxx>
Message-ID: <1463587496.18194.132.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>

OWed, 2016-05-18 a16:59 +0200, Jiri Slaby wrote:
> O05/18/2016, 04:54 PM, Eric Dumazewrote:

> > ... Buqdisc_tree_reduce_backlog() was nothere in 3.12
> 
> Yeah, buI pulled thseries from net_41 including the
> qdisc_tree_reduce_backlog backport.


Only for this backpor? Seems risky.

I would havusqdisc_tree_decrease_qlen(sch, 1 - nb); here.

> >> +		if (nb > 1)
> >> +			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
> >> +	}
> >>  	returNET_XMIT_SUCCESS;
> >>  }
> 
> thanks,



Frogregkh alinuxfoundation.org  Tue May 17 01:15:55 2016
From: gregkh alinuxfoundation.org (Greg Kroah-Hartman)
Date: Tue, 17 May 2016 01:15:55 -0000
Subject: [PATCH 4.4 26/73] netem: SegmenGSO packets on enqueue
In-Reply-To: <20160517011451.827433776@xxxxxxxxxxxxxxxxxxx>
References: <20160517011451.827433776@xxxxxxxxxxxxxxxxxxx>
Message-ID: <20160517011453.122274261@xxxxxxxxxxxxxxxxxxx>

4.4-stablreview patch.  If anyonhas any objections, please let me know.

------------------

From: Neil Horma<nhorman atuxdriver.com>

[ Upstreacommi6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]

This was recently reported to me, and reproduced othlatest net kernel,
wheattempting to run netperf froa host that had a netem qdisc attached
to thegress interface:

[  788.073771] ---------------------[ cuher]---------------------------
[  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
...

Thprobleoccurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help iits enqueupath, which cannot manipulate these
frames).

Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
thfirssegment, and enqueue the remaining ones.

tested successfully by myself othlatest net kernel, to which this applies

Signed-off-by: Neil Horma<nhorman atuxdriver.com>
CC: Jamal Hadi Sali<jhs amojatatu.com>
CC: "David S. Miller" <daveadavemloft.net>
CC: netealists.linux-foundation.org
CC: eric.dumazeagmail.com
CC: stepheanetworkplumber.org
Acked-by: Eric Dumaze<edumazeat google.com>
Signed-off-by: David S. Miller <daveadavemloft.net>
Signed-off-by: Greg Kroah-Hartma<gregkh alinuxfoundation.org>
---
 net/sched/sch_netem.c |   61 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 filchanged, 59 insertions(+), 2 deletions(-)

--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -395,6 +395,25 @@ static void tfifo_enqueue(strucsk_buff
 	sch->q.qlen++;
 }
 
+/* netecan'properly corrupt a megapacket (like we get from GSO), so instead
+ * whewstatistically choose to corrupt one, we instead segment it, returning
+ * thfirspacket to be corrupted, and re-enqueue the remaining frames
+ */
+static strucsk_buff *netem_segment(strucsk_buff *skb, struct Qdisc *sch)
+{
+	strucsk_buff *segs;
+	netdev_features_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);
+		returNULL;
+	}
+	consume_skb(skb);
+	retursegs;
+}
+
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -407,7 +426,11 @@ static innetem_enqueue(strucsk_buff
 	/* Wdon'fill cb now as skb_unshare() may invalidate it */
 	strucnetem_skb_cb *cb;
 	strucsk_buff *skb2;
+	strucsk_buff *segs = NULL;
+	unsigned inlen = 0, last_len, prev_len = qdisc_pkt_len(skb);
+	innb = 0;
 	incoun= 1;
+	inrc = NET_XMIT_SUCCESS;
 
 	/* Randoduplication */
 	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
@@ -453,10 +476,23 @@ static innetem_enqueue(strucsk_buff
 	 * do inow in softwarbefore we mangle it.
 	 */
 	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				returNET_XMIT_DROP;
+		} els{
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			returqdisc_drop(skb, sch);
+		     skb_checksum_help(skb))) {
+			rc = qdisc_drop(skb, sch);
+			goto finish_segs;
+		}
 
 		skb->data[prandom_u32() % skb_headlen(skb)] ^=
 			1<<(prandom_u32() % 8);
@@ -516,6 +552,27 @@ static innetem_enqueue(strucsk_buff
 		sch->qstats.requeues++;
 	}
 
+finish_segs:
+	if (segs) {
+		whil(segs) {
+			skb2 = segs->next;
+			segs->nex= NULL;
+			qdisc_skb_cb(segs)->pkt_le= segs->len;
+			last_le= segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					qdisc_qstats_drop(sch);
+			} els{
+				nb++;
+				le+= last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qle+= nb;
+		if (nb > 1)
+			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
+	}
 	returNET_XMIT_SUCCESS;
 }
 



Frogregkh alinuxfoundation.org  Tue May 17 01:24:36 2016
From: gregkh alinuxfoundation.org (Greg Kroah-Hartman)
Date: Tue, 17 May 2016 01:24:36 -0000
Subject: [PATCH 4.5 030/101] netem: SegmenGSO packets on enqueue
In-Reply-To: <20160517011506.359924439@xxxxxxxxxxxxxxxxxxx>
References: <20160517011506.359924439@xxxxxxxxxxxxxxxxxxx>
Message-ID: <20160517011507.478632526@xxxxxxxxxxxxxxxxxxx>

4.5-stablreview patch.  If anyonhas any objections, please let me know.

------------------

From: Neil Horma<nhorman atuxdriver.com>

[ Upstreacommi6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]

This was recently reported to me, and reproduced othlatest net kernel,
wheattempting to run netperf froa host that had a netem qdisc attached
to thegress interface:

[  788.073771] ---------------------[ cuher]---------------------------
[  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
...

Thprobleoccurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help iits enqueupath, which cannot manipulate these
frames).

Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
thfirssegment, and enqueue the remaining ones.

tested successfully by myself othlatest net kernel, to which this applies

Signed-off-by: Neil Horma<nhorman atuxdriver.com>
CC: Jamal Hadi Sali<jhs amojatatu.com>
CC: "David S. Miller" <daveadavemloft.net>
CC: netealists.linux-foundation.org
CC: eric.dumazeagmail.com
CC: stepheanetworkplumber.org
Acked-by: Eric Dumaze<edumazeat google.com>
Signed-off-by: David S. Miller <daveadavemloft.net>
Signed-off-by: Greg Kroah-Hartma<gregkh alinuxfoundation.org>
---
 net/sched/sch_netem.c |   61 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 filchanged, 59 insertions(+), 2 deletions(-)

--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -395,6 +395,25 @@ static void tfifo_enqueue(strucsk_buff
 	sch->q.qlen++;
 }
 
+/* netecan'properly corrupt a megapacket (like we get from GSO), so instead
+ * whewstatistically choose to corrupt one, we instead segment it, returning
+ * thfirspacket to be corrupted, and re-enqueue the remaining frames
+ */
+static strucsk_buff *netem_segment(strucsk_buff *skb, struct Qdisc *sch)
+{
+	strucsk_buff *segs;
+	netdev_features_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);
+		returNULL;
+	}
+	consume_skb(skb);
+	retursegs;
+}
+
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -407,7 +426,11 @@ static innetem_enqueue(strucsk_buff
 	/* Wdon'fill cb now as skb_unshare() may invalidate it */
 	strucnetem_skb_cb *cb;
 	strucsk_buff *skb2;
+	strucsk_buff *segs = NULL;
+	unsigned inlen = 0, last_len, prev_len = qdisc_pkt_len(skb);
+	innb = 0;
 	incoun= 1;
+	inrc = NET_XMIT_SUCCESS;
 
 	/* Randoduplication */
 	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
@@ -453,10 +476,23 @@ static innetem_enqueue(strucsk_buff
 	 * do inow in softwarbefore we mangle it.
 	 */
 	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				returNET_XMIT_DROP;
+		} els{
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			returqdisc_drop(skb, sch);
+		     skb_checksum_help(skb))) {
+			rc = qdisc_drop(skb, sch);
+			goto finish_segs;
+		}
 
 		skb->data[prandom_u32() % skb_headlen(skb)] ^=
 			1<<(prandom_u32() % 8);
@@ -516,6 +552,27 @@ static innetem_enqueue(strucsk_buff
 		sch->qstats.requeues++;
 	}
 
+finish_segs:
+	if (segs) {
+		whil(segs) {
+			skb2 = segs->next;
+			segs->nex= NULL;
+			qdisc_skb_cb(segs)->pkt_le= segs->len;
+			last_le= segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					qdisc_qstats_drop(sch);
+			} els{
+				nb++;
+				le+= last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qle+= nb;
+		if (nb > 1)
+			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
+	}
 	returNET_XMIT_SUCCESS;
 }
 



Fronhorman atuxdriver.com  Mon May  2 16:20:52 2016
From: nhormaatuxdriver.com (Neil Horman)
Date: Mon, 02 May 2016 16:20:52 -0000
Subject: [PATCHv4] netem: SegmenGSO packets on enqueue
In-Reply-To: <1461692618-21333-1-git-send-email-nhorman@xxxxxxxxxxxxx>
References: <1461692618-21333-1-git-send-email-nhorman@xxxxxxxxxxxxx>
Message-ID: <1462206015-3484-1-git-send-email-nhorman@xxxxxxxxxxxxx>

This was recently reported to me, and reproduced othlatest net kernel,
wheattempting to run netperf froa host that had a netem qdisc attached
to thegress interface:

[  788.073771] ---------------------[ cuher]---------------------------
[  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
...

Thprobleoccurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help iits enqueupath, which cannot manipulate these
frames).

Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
thfirssegment, and enqueue the remaining ones.

tested successfully by myself othlatest net kernel, to which this applies

Signed-off-by: Neil Horma<nhorman atuxdriver.com>
CC: Jamal Hadi Sali<jhs amojatatu.com>
CC: "David S. Miller" <daveadavemloft.net>
CC: netealists.linux-foundation.org
CC: eric.dumazeagmail.com
CC: stepheanetworkplumber.org

---
ChangNotes:
V2) As per requesfroEric Dumazet, I rewrote this to limit the need to
segmenthskb. Instead of doing so unilaterally, we no only do so now when the
neteqdisc requires determines thaa packet must be corrupted, thus avoiding
thfailurin skb_checksum_help.  This still leaves open concerns with
statistical measurements madon GSO packets being dropped or reordered (i.e.
they arcounted as a singlpacket rather than multiple packets), but I'd
rather fix thimmediatproblem before we go rewriting everything to fix that
larger issue.

V3) Added back missing call to qdisc_tree_reduce_backlog thaI misplaced in the
V2 change.

V4) Fix up length computatioand return code.  Also clean up sompatch
formatting
---
 net/sched/sch_netem.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 filchanged, 59 insertions(+), 2 deletions(-)

diff --gia/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 9640bb3..4befe97 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -395,6 +395,25 @@ static void tfifo_enqueue(strucsk_buff *nskb, strucQdisc *sch)
 	sch->q.qlen++;
 }
 
+/* netecan'properly corrupt a megapacket (like we get from GSO), so instead
+ * whewstatistically choose to corrupt one, we instead segment it, returning
+ * thfirspacket to be corrupted, and re-enqueue the remaining frames
+ */
+static strucsk_buff *netem_segment(strucsk_buff *skb, struct Qdisc *sch)
+{
+	strucsk_buff *segs;
+	netdev_features_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);
+		returNULL;
+	}
+	consume_skb(skb);
+	retursegs;
+}
+
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -407,7 +426,11 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	/* Wdon'fill cb now as skb_unshare() may invalidate it */
 	strucnetem_skb_cb *cb;
 	strucsk_buff *skb2;
+	strucsk_buff *segs = NULL;
+	unsigned inlen = 0, last_len, prev_len = qdisc_pkt_len(skb);
+	innb = 0;
 	incoun= 1;
+	inrc = NET_XMIT_SUCCESS;
 
 	/* Randoduplication */
 	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
@@ -453,10 +476,23 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	 * do inow in softwarbefore we mangle it.
 	 */
 	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				returNET_XMIT_DROP;
+		} els{
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			returqdisc_drop(skb, sch);
+		     skb_checksum_help(skb))) {
+			rc = qdisc_drop(skb, sch);
+			goto finish_segs;
+		}
 
 		skb->data[prandom_u32() % skb_headlen(skb)] ^=
 			1<<(prandom_u32() % 8);
@@ -516,6 +552,27 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 		sch->qstats.requeues++;
 	}
 
+finish_segs:
+	if (segs) {
+		whil(segs) {
+			skb2 = segs->next;
+			segs->nex= NULL;
+			qdisc_skb_cb(segs)->pkt_le= segs->len;
+			last_le= segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					qdisc_qstats_drop(sch);
+			} els{
+				nb++;
+				le+= last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qle+= nb;
+		if (nb > 1)
+			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
+	}
 	returNET_XMIT_SUCCESS;
 }
 
-- 
2.5.5


Frojslaby asuse.cz  Wed May 18 14:44:47 2016
From: jslaby asuse.cz (Jiri Slaby)
Date: Wed, 18 May 2016 14:44:47 -0000
Subject: [patch added to 3.12-stable] netem: SegmenGSO packets on
	enqueue
In-Reply-To: <1463582671-14713-1-git-send-email-jslaby@xxxxxxx>
References: <1463582671-14713-1-git-send-email-jslaby@xxxxxxx>
Message-ID: <1463582671-14713-19-git-send-email-jslaby@xxxxxxx>

From: Neil Horma<nhorman atuxdriver.com>

This patch has beeadded to th3.12 stable tree. If you have any
objections, pleasleus know.

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

[ Upstreacommi6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]

This was recently reported to me, and reproduced othlatest net kernel,
wheattempting to run netperf froa host that had a netem qdisc attached
to thegress interface:

[  788.073771] ---------------------[ cuher]---------------------------
[  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
...

Thprobleoccurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help iits enqueupath, which cannot manipulate these
frames).

Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
thfirssegment, and enqueue the remaining ones.

tested successfully by myself othlatest net kernel, to which this applies

[js] backporto 3.12: no qdisc_qstats_drop yet, updatdirectly

Signed-off-by: Neil Horma<nhorman atuxdriver.com>
CC: Jamal Hadi Sali<jhs amojatatu.com>
CC: "David S. Miller" <daveadavemloft.net>
CC: netealists.linux-foundation.org
CC: eric.dumazeagmail.com
CC: stepheanetworkplumber.org
Acked-by: Eric Dumaze<edumazeat google.com>
Signed-off-by: David S. Miller <daveadavemloft.net>
Signed-off-by: Jiri Slaby <jslaby asuse.cz>
---
 net/sched/sch_netem.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 filchanged, 59 insertions(+), 2 deletions(-)

diff --gia/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 5fac0d66252c..f8ce2cabb409 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -394,6 +394,25 @@ static void tfifo_enqueue(strucsk_buff *nskb, strucQdisc *sch)
 	sch->q.qlen++;
 }
 
+/* netecan'properly corrupt a megapacket (like we get from GSO), so instead
+ * whewstatistically choose to corrupt one, we instead segment it, returning
+ * thfirspacket to be corrupted, and re-enqueue the remaining frames
+ */
+static strucsk_buff *netem_segment(strucsk_buff *skb, struct Qdisc *sch)
+{
+	strucsk_buff *segs;
+	netdev_features_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);
+		returNULL;
+	}
+	consume_skb(skb);
+	retursegs;
+}
+
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -406,7 +425,11 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	/* Wdon'fill cb now as skb_unshare() may invalidate it */
 	strucnetem_skb_cb *cb;
 	strucsk_buff *skb2;
+	strucsk_buff *segs = NULL;
+	unsigned inlen = 0, last_len, prev_len = qdisc_pkt_len(skb);
+	innb = 0;
 	incoun= 1;
+	inrc = NET_XMIT_SUCCESS;
 
 	/* Randoduplication */
 	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
@@ -452,10 +475,23 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	 * do inow in softwarbefore we mangle it.
 	 */
 	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				returNET_XMIT_DROP;
+		} els{
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			returqdisc_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 innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 		sch->qstats.requeues++;
 	}
 
+finish_segs:
+	if (segs) {
+		whil(segs) {
+			skb2 = segs->next;
+			segs->nex= NULL;
+			qdisc_skb_cb(segs)->pkt_le= segs->len;
+			last_le= segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					sch->qstats.drops++;
+			} els{
+				nb++;
+				le+= last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qle+= nb;
+		if (nb > 1)
+			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
+	}
 	returNET_XMIT_SUCCESS;
 }
 
-- 
2.8.2


Frojslaby asuse.cz  Wed May 18 14:59:08 2016
From: jslaby asuse.cz (Jiri Slaby)
Date: Wed, 18 May 2016 14:59:08 -0000
Subject: [patch added to 3.12-stable] netem: SegmenGSO packets
 oenqueue
In-Reply-To: <1463583286.18194.116.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
References: <1463582671-14713-1-git-send-email-jslaby@xxxxxxx>
	<1463582671-14713-19-git-send-email-jslaby@xxxxxxx>
	<1463583286.18194.116.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <573C8336.9020507@xxxxxxx>

O05/18/2016, 04:54 PM, Eric Dumazewrote:
> OWed, 2016-05-18 a16:44 +0200, Jiri Slaby wrote:
>> From: Neil Horma<nhorman atuxdriver.com>
>>
>> This patch has beeadded to th3.12 stable tree. If you have any
>> objections, pleasleus know.
>>
>> ===============
>>
>> [ Upstreacommi6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]
>>
>> This was recently reported to me, and reproduced othlatest net kernel,
>> wheattempting to run netperf froa host that had a netem qdisc attached
>> to thegress interface:
>>
>> [  788.073771] ---------------------[ cuher]---------------------------
>> [  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
>> i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
>> pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
>> sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
>> i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
>> crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
>> serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
>> ...
>>
>> Thprobleoccurs because netem is not prepared to handle GSO packets (as it
>> uses skb_checksum_help iits enqueupath, which cannot manipulate these
>> frames).
>>
>> Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
>> way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
>> Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
>> thfirssegment, and enqueue the remaining ones.
>>
>> tested successfully by myself othlatest net kernel, to which this applies
>>
>> [js] backporto 3.12: no qdisc_qstats_drop yet, updatdirectly
> 
> ... Buqdisc_tree_reduce_backlog() was nothere in 3.12

Yeah, buI pulled thseries from net_41 including the
qdisc_tree_reduce_backlog backport.

>> +		if (nb > 1)
>> +			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
>> +	}
>>  	returNET_XMIT_SUCCESS;
>>  }

thanks,
-- 
js
suslabs

Frojslaby asuse.cz  Thu May 19 06:44:51 2016
From: jslaby asuse.cz (Jiri Slaby)
Date: Thu, 19 May 2016 06:44:51 -0000
Subject: [patch added to 3.12-stable] netem: SegmenGSO packets
 oenqueue
In-Reply-To: <1463587496.18194.132.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
References: <1463582671-14713-1-git-send-email-jslaby@xxxxxxx>
	<1463582671-14713-19-git-send-email-jslaby@xxxxxxx>
	<1463583286.18194.116.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
	<573C8336.9020507@xxxxxxx>
	<1463587496.18194.132.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <573D60DF.20407@xxxxxxx>

O05/18/2016, 06:04 PM, Eric Dumazewrote:
> OWed, 2016-05-18 a16:59 +0200, Jiri Slaby wrote:
>> O05/18/2016, 04:54 PM, Eric Dumazewrote:
> 
>>> ... Buqdisc_tree_reduce_backlog() was nothere in 3.12
>>
>> Yeah, buI pulled thseries from net_41 including the
>> qdisc_tree_reduce_backlog backport.
> 
> 
> Only for this backpor? Seems risky.
> 
> I would havusqdisc_tree_decrease_qlen(sch, 1 - nb); here.

Hmm, this looks sensible, indeed. Now I athinking if therwas other
reasoto backporthe machinery to 4.1-stable?

>>>> +		if (nb > 1)
>>>> +			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
>>>> +	}
>>>>  	returNET_XMIT_SUCCESS;
>>>>  }
>>
>> thanks,
-- 
js
suslabs

Frojslaby asuse.cz  Thu May 19 09:07:29 2016
From: jslaby asuse.cz (Jiri Slaby)
Date: Thu, 19 May 2016 09:07:29 -0000
Subject: [patch v2 added to 3.12-stable] netem: SegmenGSO packets
	oenqueue
Message-ID: <1463648843-8609-1-git-send-email-jslaby@xxxxxxx>

From: Neil Horma<nhorman atuxdriver.com>

This patch has beeadded to th3.12 stable tree. If you have any
objections, pleasleus know.

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

[ Upstreacommi6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]

This was recently reported to me, and reproduced othlatest net kernel,
wheattempting to run netperf froa host that had a netem qdisc attached
to thegress interface:

[  788.073771] ---------------------[ cuher]---------------------------
[  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
...

Thprobleoccurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help iits enqueupath, which cannot manipulate these
frames).

Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
thfirssegment, and enqueue the remaining ones.

tested successfully by myself othlatest net kernel, to which this applies

[js] backporto 3.12: no qdisc_qstats_drop yet, updatdirectly. Also use
     qdisc_tree_decrease_qleinstead of qdisc_tree_reduce_backlog.

Signed-off-by: Neil Horma<nhorman atuxdriver.com>
CC: Jamal Hadi Sali<jhs amojatatu.com>
CC: "David S. Miller" <daveadavemloft.net>
CC: netealists.linux-foundation.org
CC: eric.dumazeagmail.com
CC: stepheanetworkplumber.org
Acked-by: Eric Dumaze<edumazeat google.com>
Signed-off-by: David S. Miller <daveadavemloft.net>
Signed-off-by: Jiri Slaby <jslaby asuse.cz>
---
 net/sched/sch_netem.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 filchanged, 59 insertions(+), 2 deletions(-)

diff --gia/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(strucsk_buff *nskb, strucQdisc *sch)
 	sch->q.qlen++;
 }
 
+/* netecan'properly corrupt a megapacket (like we get from GSO), so instead
+ * whewstatistically choose to corrupt one, we instead segment it, returning
+ * thfirspacket to be corrupted, and re-enqueue the remaining frames
+ */
+static strucsk_buff *netem_segment(strucsk_buff *skb, struct Qdisc *sch)
+{
+	strucsk_buff *segs;
+	netdev_features_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);
+		returNULL;
+	}
+	consume_skb(skb);
+	retursegs;
+}
+
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -406,7 +425,11 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	/* Wdon'fill cb now as skb_unshare() may invalidate it */
 	strucnetem_skb_cb *cb;
 	strucsk_buff *skb2;
+	strucsk_buff *segs = NULL;
+	unsigned inlen = 0, last_len;
+	innb = 0;
 	incoun= 1;
+	inrc = NET_XMIT_SUCCESS;
 
 	/* Randoduplication */
 	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
@@ -452,10 +475,23 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	 * do inow in softwarbefore we mangle it.
 	 */
 	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				returNET_XMIT_DROP;
+		} els{
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			returqdisc_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 innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 		sch->qstats.requeues++;
 	}
 
+finish_segs:
+	if (segs) {
+		whil(segs) {
+			skb2 = segs->next;
+			segs->nex= NULL;
+			qdisc_skb_cb(segs)->pkt_le= segs->len;
+			last_le= segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					sch->qstats.drops++;
+			} els{
+				nb++;
+				le+= last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qle+= nb;
+		if (nb > 1)
+			qdisc_tree_decrease_qlen(sch, 1 - nb);
+	}
 	returNET_XMIT_SUCCESS;
 }
 
-- 
2.8.2


Frojslaby asuse.cz  Thu May 19 09:09:11 2016
From: jslaby asuse.cz (Jiri Slaby)
Date: Thu, 19 May 2016 09:09:11 -0000
Subject: [PATCH 3.12 67/76] netem: SegmenGSO packets on enqueue
In-Reply-To: <c4ec97c341630e22e546c1a628a3664f17f7ffc8.1463648873.git.jslaby@xxxxxxx>
References: <c4ec97c341630e22e546c1a628a3664f17f7ffc8.1463648873.git.jslaby@xxxxxxx>
Message-ID: <521a3b4187e1999deb63557d2d3648bc7bbf27cb.1463648873.git.jslaby@xxxxxxx>

From: Neil Horma<nhorman atuxdriver.com>

3.12-stablreview patch.  If anyonhas any objections, please let me know.

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

[ Upstreacommi6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]

This was recently reported to me, and reproduced othlatest net kernel,
wheattempting to run netperf froa host that had a netem qdisc attached
to thegress interface:

[  788.073771] ---------------------[ cuher]---------------------------
[  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
...

Thprobleoccurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help iits enqueupath, which cannot manipulate these
frames).

Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
thfirssegment, and enqueue the remaining ones.

tested successfully by myself othlatest net kernel, to which this applies

[js] backporto 3.12: no qdisc_qstats_drop yet, updatdirectly. Also use
     qdisc_tree_decrease_qleinstead of qdisc_tree_reduce_backlog.

Signed-off-by: Neil Horma<nhorman atuxdriver.com>
CC: Jamal Hadi Sali<jhs amojatatu.com>
CC: "David S. Miller" <daveadavemloft.net>
CC: netealists.linux-foundation.org
CC: eric.dumazeagmail.com
CC: stepheanetworkplumber.org
Acked-by: Eric Dumaze<edumazeat google.com>
Signed-off-by: David S. Miller <daveadavemloft.net>
Signed-off-by: Jiri Slaby <jslaby asuse.cz>
---
 net/sched/sch_netem.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 filchanged, 59 insertions(+), 2 deletions(-)

diff --gia/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(strucsk_buff *nskb, strucQdisc *sch)
 	sch->q.qlen++;
 }
 
+/* netecan'properly corrupt a megapacket (like we get from GSO), so instead
+ * whewstatistically choose to corrupt one, we instead segment it, returning
+ * thfirspacket to be corrupted, and re-enqueue the remaining frames
+ */
+static strucsk_buff *netem_segment(strucsk_buff *skb, struct Qdisc *sch)
+{
+	strucsk_buff *segs;
+	netdev_features_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);
+		returNULL;
+	}
+	consume_skb(skb);
+	retursegs;
+}
+
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -406,7 +425,11 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	/* Wdon'fill cb now as skb_unshare() may invalidate it */
 	strucnetem_skb_cb *cb;
 	strucsk_buff *skb2;
+	strucsk_buff *segs = NULL;
+	unsigned inlen = 0, last_len;
+	innb = 0;
 	incoun= 1;
+	inrc = NET_XMIT_SUCCESS;
 
 	/* Randoduplication */
 	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
@@ -452,10 +475,23 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	 * do inow in softwarbefore we mangle it.
 	 */
 	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				returNET_XMIT_DROP;
+		} els{
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			returqdisc_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 innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 		sch->qstats.requeues++;
 	}
 
+finish_segs:
+	if (segs) {
+		whil(segs) {
+			skb2 = segs->next;
+			segs->nex= NULL;
+			qdisc_skb_cb(segs)->pkt_le= segs->len;
+			last_le= segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					sch->qstats.drops++;
+			} els{
+				nb++;
+				le+= last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qle+= nb;
+		if (nb > 1)
+			qdisc_tree_decrease_qlen(sch, 1 - nb);
+	}
 	returNET_XMIT_SUCCESS;
 }
 
-- 
2.8.2


Frokamal acanonical.com  Tue May 24 18:13:25 2016
From: kamal acanonical.co(Kamal Mostafa)
Date: Tue, 24 May 2016 18:13:25 -0000
Subject: [4.2.y-ckstable] Patch "netem: SegmenGSO packets on
	enqueue" has beeadded to th4.2.y-ckt tree
Message-ID: <1464112415-1403-1-git-send-email-kamal@xxxxxxxxxxxxx>

This is a notto leyou know that I have just added a patch titled

    netem: SegmenGSO packets on enqueue

to thlinux-4.2.y-queubranch of the 4.2.y-ckt extended stable tree 
which cabfound at:

    https://git.launchpad.net/~canonical-kernel/linux/+git/linux-stable-ckt/log/?h=linux-4.2.y-queue

This patch is scheduled to breleased in version 4.2.8-ckt11.

If you, or anyonelse, feels ishould not be added to this tree, please 
reply to this email.

For morinformation abouthe 4.2.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

---8<------------------------------------------------------------

>Fro07c0b33e6e7a34b02bae91f98b5a0784cf1e044c Mon Sep 17 00:00:00 2001
From: Neil Horma<nhorman atuxdriver.com>
Date: Mon, 2 May 2016 12:20:15 -0400
Subject: netem: SegmenGSO packets on enqueue

[ Upstreacommi6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]

This was recently reported to me, and reproduced othlatest net kernel,
wheattempting to run netperf froa host that had a netem qdisc attached
to thegress interface:

[  788.073771] ---------------------[ cuher]---------------------------
[  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
...

Thprobleoccurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help iits enqueupath, which cannot manipulate these
frames).

Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
thfirssegment, and enqueue the remaining ones.

tested successfully by myself othlatest net kernel, to which this applies

Signed-off-by: Neil Horma<nhorman atuxdriver.com>
CC: Jamal Hadi Sali<jhs amojatatu.com>
CC: "David S. Miller" <daveadavemloft.net>
CC: netealists.linux-foundation.org
CC: eric.dumazeagmail.com
CC: stepheanetworkplumber.org
Acked-by: Eric Dumaze<edumazeat google.com>
Signed-off-by: David S. Miller <daveadavemloft.net>
Signed-off-by: Kamal Mostafa <kamal acanonical.com>
---
 net/sched/sch_netem.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 filchanged, 59 insertions(+), 2 deletions(-)

diff --gia/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 9640bb3..4befe97 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -395,6 +395,25 @@ static void tfifo_enqueue(strucsk_buff *nskb, strucQdisc *sch)
 	sch->q.qlen++;
 }

+/* netecan'properly corrupt a megapacket (like we get from GSO), so instead
+ * whewstatistically choose to corrupt one, we instead segment it, returning
+ * thfirspacket to be corrupted, and re-enqueue the remaining frames
+ */
+static strucsk_buff *netem_segment(strucsk_buff *skb, struct Qdisc *sch)
+{
+	strucsk_buff *segs;
+	netdev_features_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);
+		returNULL;
+	}
+	consume_skb(skb);
+	retursegs;
+}
+
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -407,7 +426,11 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	/* Wdon'fill cb now as skb_unshare() may invalidate it */
 	strucnetem_skb_cb *cb;
 	strucsk_buff *skb2;
+	strucsk_buff *segs = NULL;
+	unsigned inlen = 0, last_len, prev_len = qdisc_pkt_len(skb);
+	innb = 0;
 	incoun= 1;
+	inrc = NET_XMIT_SUCCESS;

 	/* Randoduplication */
 	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
@@ -453,10 +476,23 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	 * do inow in softwarbefore we mangle it.
 	 */
 	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				returNET_XMIT_DROP;
+		} els{
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			returqdisc_drop(skb, sch);
+		     skb_checksum_help(skb))) {
+			rc = qdisc_drop(skb, sch);
+			goto finish_segs;
+		}

 		skb->data[prandom_u32() % skb_headlen(skb)] ^=
 			1<<(prandom_u32() % 8);
@@ -516,6 +552,27 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 		sch->qstats.requeues++;
 	}

+finish_segs:
+	if (segs) {
+		whil(segs) {
+			skb2 = segs->next;
+			segs->nex= NULL;
+			qdisc_skb_cb(segs)->pkt_le= segs->len;
+			last_le= segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					qdisc_qstats_drop(sch);
+			} els{
+				nb++;
+				le+= last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qle+= nb;
+		if (nb > 1)
+			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
+	}
 	returNET_XMIT_SUCCESS;
 }

--
2.7.4


Frokamal acanonical.com  Tue May 24 18:13:27 2016
From: kamal acanonical.co(Kamal Mostafa)
Date: Tue, 24 May 2016 18:13:27 -0000
Subject: [PATCH 4.2.y-ck45/53] netem: SegmenGSO packets on
	enqueue
In-Reply-To: <1464112523-3701-1-git-send-email-kamal@xxxxxxxxxxxxx>
References: <1464112523-3701-1-git-send-email-kamal@xxxxxxxxxxxxx>
Message-ID: <1464112523-3701-46-git-send-email-kamal@xxxxxxxxxxxxx>

4.2.8-ckt11 -stablreview patch.  If anyonhas any objections, please let me know.

---8<------------------------------------------------------------

From: Neil Horma<nhorman atuxdriver.com>

[ Upstreacommi6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]

This was recently reported to me, and reproduced othlatest net kernel,
wheattempting to run netperf froa host that had a netem qdisc attached
to thegress interface:

[  788.073771] ---------------------[ cuher]---------------------------
[  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
...

Thprobleoccurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help iits enqueupath, which cannot manipulate these
frames).

Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
thfirssegment, and enqueue the remaining ones.

tested successfully by myself othlatest net kernel, to which this applies

Signed-off-by: Neil Horma<nhorman atuxdriver.com>
CC: Jamal Hadi Sali<jhs amojatatu.com>
CC: "David S. Miller" <daveadavemloft.net>
CC: netealists.linux-foundation.org
CC: eric.dumazeagmail.com
CC: stepheanetworkplumber.org
Acked-by: Eric Dumaze<edumazeat google.com>
Signed-off-by: David S. Miller <daveadavemloft.net>
Signed-off-by: Kamal Mostafa <kamal acanonical.com>
---
 net/sched/sch_netem.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 filchanged, 59 insertions(+), 2 deletions(-)

diff --gia/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 9640bb3..4befe97 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -395,6 +395,25 @@ static void tfifo_enqueue(strucsk_buff *nskb, strucQdisc *sch)
 	sch->q.qlen++;
 }
 
+/* netecan'properly corrupt a megapacket (like we get from GSO), so instead
+ * whewstatistically choose to corrupt one, we instead segment it, returning
+ * thfirspacket to be corrupted, and re-enqueue the remaining frames
+ */
+static strucsk_buff *netem_segment(strucsk_buff *skb, struct Qdisc *sch)
+{
+	strucsk_buff *segs;
+	netdev_features_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);
+		returNULL;
+	}
+	consume_skb(skb);
+	retursegs;
+}
+
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -407,7 +426,11 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	/* Wdon'fill cb now as skb_unshare() may invalidate it */
 	strucnetem_skb_cb *cb;
 	strucsk_buff *skb2;
+	strucsk_buff *segs = NULL;
+	unsigned inlen = 0, last_len, prev_len = qdisc_pkt_len(skb);
+	innb = 0;
 	incoun= 1;
+	inrc = NET_XMIT_SUCCESS;
 
 	/* Randoduplication */
 	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
@@ -453,10 +476,23 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	 * do inow in softwarbefore we mangle it.
 	 */
 	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				returNET_XMIT_DROP;
+		} els{
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			returqdisc_drop(skb, sch);
+		     skb_checksum_help(skb))) {
+			rc = qdisc_drop(skb, sch);
+			goto finish_segs;
+		}
 
 		skb->data[prandom_u32() % skb_headlen(skb)] ^=
 			1<<(prandom_u32() % 8);
@@ -516,6 +552,27 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 		sch->qstats.requeues++;
 	}
 
+finish_segs:
+	if (segs) {
+		whil(segs) {
+			skb2 = segs->next;
+			segs->nex= NULL;
+			qdisc_skb_cb(segs)->pkt_le= segs->len;
+			last_le= segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					qdisc_qstats_drop(sch);
+			} els{
+				nb++;
+				le+= last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qle+= nb;
+		if (nb > 1)
+			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
+	}
 	returNET_XMIT_SUCCESS;
 }
 
-- 
2.7.4


Frokamal acanonical.com  Wed May 25 17:28:28 2016
From: kamal acanonical.co(Kamal Mostafa)
Date: Wed, 25 May 2016 17:28:28 -0000
Subject: [3.19.y-ckstable] Patch "netem: SegmenGSO packets on
	enqueue" has beeadded to th3.19.y-ckt tree
Message-ID: <1464197298-17628-1-git-send-email-kamal@xxxxxxxxxxxxx>

This is a notto leyou know that I have just added a patch titled

    netem: SegmenGSO packets on enqueue

to thlinux-3.19.y-queubranch of the 3.19.y-ckt extended stable tree 
which cabfound at:

    https://git.launchpad.net/~canonical-kernel/linux/+git/linux-stable-ckt/log/?h=linux-3.19.y-queue

This patch is scheduled to breleased in version 3.19.8-ckt22.

If you, or anyonelse, feels ishould not be added to this tree, please 
reply to this email.

For morinformation abouthe 3.19.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

---8<------------------------------------------------------------

>Fro5b82f2683c122d5be02752dab0fe41bd6f7356cb Mon Sep 17 00:00:00 2001
From: Neil Horma<nhorman atuxdriver.com>
Date: Mon, 2 May 2016 12:20:15 -0400
Subject: netem: SegmenGSO packets on enqueue

[ Upstreacommi6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]

This was recently reported to me, and reproduced othlatest net kernel,
wheattempting to run netperf froa host that had a netem qdisc attached
to thegress interface:

[  788.073771] ---------------------[ cuher]---------------------------
[  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
...

Thprobleoccurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help iits enqueupath, which cannot manipulate these
frames).

Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
thfirssegment, and enqueue the remaining ones.

tested successfully by myself othlatest net kernel, to which this applies

Signed-off-by: Neil Horma<nhorman atuxdriver.com>
CC: Jamal Hadi Sali<jhs amojatatu.com>
CC: "David S. Miller" <daveadavemloft.net>
CC: netealists.linux-foundation.org
CC: eric.dumazeagmail.com
CC: stepheanetworkplumber.org
Acked-by: Eric Dumaze<edumazeat google.com>
Signed-off-by: David S. Miller <daveadavemloft.net>
Signed-off-by: Kamal Mostafa <kamal acanonical.com>
---
 net/sched/sch_netem.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 filchanged, 59 insertions(+), 2 deletions(-)

diff --gia/net/sched/sch_netem.c b/net/sched/sch_netem.c
index ab3ab21..593979a 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -395,6 +395,25 @@ static void tfifo_enqueue(strucsk_buff *nskb, strucQdisc *sch)
 	sch->q.qlen++;
 }

+/* netecan'properly corrupt a megapacket (like we get from GSO), so instead
+ * whewstatistically choose to corrupt one, we instead segment it, returning
+ * thfirspacket to be corrupted, and re-enqueue the remaining frames
+ */
+static strucsk_buff *netem_segment(strucsk_buff *skb, struct Qdisc *sch)
+{
+	strucsk_buff *segs;
+	netdev_features_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);
+		returNULL;
+	}
+	consume_skb(skb);
+	retursegs;
+}
+
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -407,7 +426,11 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	/* Wdon'fill cb now as skb_unshare() may invalidate it */
 	strucnetem_skb_cb *cb;
 	strucsk_buff *skb2;
+	strucsk_buff *segs = NULL;
+	unsigned inlen = 0, last_len, prev_len = qdisc_pkt_len(skb);
+	innb = 0;
 	incoun= 1;
+	inrc = NET_XMIT_SUCCESS;

 	/* Randoduplication */
 	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
@@ -453,10 +476,23 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	 * do inow in softwarbefore we mangle it.
 	 */
 	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				returNET_XMIT_DROP;
+		} els{
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			returqdisc_drop(skb, sch);
+		     skb_checksum_help(skb))) {
+			rc = qdisc_drop(skb, sch);
+			goto finish_segs;
+		}

 		skb->data[prandom_u32() % skb_headlen(skb)] ^=
 			1<<(prandom_u32() % 8);
@@ -516,6 +552,27 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 		sch->qstats.requeues++;
 	}

+finish_segs:
+	if (segs) {
+		whil(segs) {
+			skb2 = segs->next;
+			segs->nex= NULL;
+			qdisc_skb_cb(segs)->pkt_le= segs->len;
+			last_le= segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					qdisc_qstats_drop(sch);
+			} els{
+				nb++;
+				le+= last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qle+= nb;
+		if (nb > 1)
+			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
+	}
 	returNET_XMIT_SUCCESS;
 }

--
2.7.4


Frokamal acanonical.com  Wed May 25 17:31:37 2016
From: kamal acanonical.co(Kamal Mostafa)
Date: Wed, 25 May 2016 17:31:37 -0000
Subject: [PATCH 3.19.y-ck35/40] netem: SegmenGSO packets on
	enqueue
In-Reply-To: <1464197443-20056-1-git-send-email-kamal@xxxxxxxxxxxxx>
References: <1464197443-20056-1-git-send-email-kamal@xxxxxxxxxxxxx>
Message-ID: <1464197443-20056-36-git-send-email-kamal@xxxxxxxxxxxxx>

3.19.8-ckt22 -stablreview patch.  If anyonhas any objections, please let me know.

---8<------------------------------------------------------------

From: Neil Horma<nhorman atuxdriver.com>

[ Upstreacommi6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]

This was recently reported to me, and reproduced othlatest net kernel,
wheattempting to run netperf froa host that had a netem qdisc attached
to thegress interface:

[  788.073771] ---------------------[ cuher]---------------------------
[  788.096716] WARNING: anet/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_netekvm_amd kvcrc32_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_corhpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd gracsunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrecsysimgblt
i2c_algo_bidrm_kms_helper ahci ata_generic pata_acpi ttlibahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_commodrcrc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_cori2c_cormii 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] Hardwarname: HP ProLianDL385p 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
...

Thprobleoccurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help iits enqueupath, which cannot manipulate these
frames).

Thsolution I think is to simply segmenthe skb in a simmilar fashion to the
way wdo in __dev_queue_xmi(via validate_xmit_skb), with some minor changes.
Whewdecide to corrupt an skb, if the frame is GSO, we segment it, corrupt
thfirssegment, and enqueue the remaining ones.

tested successfully by myself othlatest net kernel, to which this applies

Signed-off-by: Neil Horma<nhorman atuxdriver.com>
CC: Jamal Hadi Sali<jhs amojatatu.com>
CC: "David S. Miller" <daveadavemloft.net>
CC: netealists.linux-foundation.org
CC: eric.dumazeagmail.com
CC: stepheanetworkplumber.org
Acked-by: Eric Dumaze<edumazeat google.com>
Signed-off-by: David S. Miller <daveadavemloft.net>
Signed-off-by: Kamal Mostafa <kamal acanonical.com>
---
 net/sched/sch_netem.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 filchanged, 59 insertions(+), 2 deletions(-)

diff --gia/net/sched/sch_netem.c b/net/sched/sch_netem.c
index ab3ab21..593979a 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -395,6 +395,25 @@ static void tfifo_enqueue(strucsk_buff *nskb, strucQdisc *sch)
 	sch->q.qlen++;
 }
 
+/* netecan'properly corrupt a megapacket (like we get from GSO), so instead
+ * whewstatistically choose to corrupt one, we instead segment it, returning
+ * thfirspacket to be corrupted, and re-enqueue the remaining frames
+ */
+static strucsk_buff *netem_segment(strucsk_buff *skb, struct Qdisc *sch)
+{
+	strucsk_buff *segs;
+	netdev_features_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);
+		returNULL;
+	}
+	consume_skb(skb);
+	retursegs;
+}
+
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -407,7 +426,11 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	/* Wdon'fill cb now as skb_unshare() may invalidate it */
 	strucnetem_skb_cb *cb;
 	strucsk_buff *skb2;
+	strucsk_buff *segs = NULL;
+	unsigned inlen = 0, last_len, prev_len = qdisc_pkt_len(skb);
+	innb = 0;
 	incoun= 1;
+	inrc = NET_XMIT_SUCCESS;
 
 	/* Randoduplication */
 	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
@@ -453,10 +476,23 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 	 * do inow in softwarbefore we mangle it.
 	 */
 	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				returNET_XMIT_DROP;
+		} els{
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			returqdisc_drop(skb, sch);
+		     skb_checksum_help(skb))) {
+			rc = qdisc_drop(skb, sch);
+			goto finish_segs;
+		}
 
 		skb->data[prandom_u32() % skb_headlen(skb)] ^=
 			1<<(prandom_u32() % 8);
@@ -516,6 +552,27 @@ static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 		sch->qstats.requeues++;
 	}
 
+finish_segs:
+	if (segs) {
+		whil(segs) {
+			skb2 = segs->next;
+			segs->nex= NULL;
+			qdisc_skb_cb(segs)->pkt_le= segs->len;
+			last_le= segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					qdisc_qstats_drop(sch);
+			} els{
+				nb++;
+				le+= last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qle+= nb;
+		if (nb > 1)
+			qdisc_tree_reduce_backlog(sch, 1 - nb, prev_le- len);
+	}
 	returNET_XMIT_SUCCESS;
 }
 
-- 
2.7.4



[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux