Re: sch_nete| chksucorrupt

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

 



Heris my redo of your patch.  I pusupport in the CVS version of iproute2
already. If idoes whayou want, I'll send it on for 2.6.16.


Index: netem/include/linux/pkt_sched.h
===================================================================
--- netem.orig/include/linux/pkt_sched.h
+++ netem/include/linux/pkt_sched.h
@@ -429,6 +429,7 @@ enum
 	TCA_NETEM_CORR,
 	TCA_NETEM_DELAY_DIST,
 	TCA_NETEM_REORDER,
+	TCA_NETEM_CORRUPT,
 	__TCA_NETEM_MAX,
 };
 
@@ -457,6 +458,12 @@ structc_netem_reorder
 	__u32	correlation;
 };
 
+structc_netem_corrupt
+{
+	__u32	probability;
+	__u32	correlation;
+};
+
 #definNETEM_DIST_SCALE	8192
 
 #endif
Index: netem/net/sched/sch_netem.c
===================================================================
--- netem.orig/net/sched/sch_netem.c
+++ netem/net/sched/sch_netem.c
@@ -25,7 +25,7 @@
 
 #includ<net/pkt_sched.h>
 
-#definVERSIO"1.1"
+#definVERSIO"1.2"
 
 /*	Network EmulatioQueuing algorithm.
 	====================================
@@ -65,11 +65,12 @@ strucnetem_sched_data {
 	u32 jitter;
 	u32 duplicate;
 	u32 reorder;
+	u32 corrupt;
 
 	struccrndstat{
 		unsigned long last;
 		unsigned long rho;
-	} delay_cor, loss_cor, dup_cor, reorder_cor;
+	} delay_cor, loss_cor, dup_cor, reorder_cor, corrupt_cor;
 
 	strucdisttabl{
 		u32  size;
@@ -183,6 +184,23 @@ static innetem_enqueue(strucsk_buff 
 		q->duplicat= dupsave;
 	}
 
+	/*
+	 * Randomized packecorruption.
+	 * Makcopy if needed sincwe are modifying
+	 * If packeis going to bhardware checksummed, then
+	 * do inow in softwarbefore we mangle it.
+	 */
+	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (!(skb = skb_unshare(skb, GFP_ATOMIC))
+		    || (skb->ip_summed == CHECKSUM_HW
+			&& skb_checksum_help(skb, 0))) {
+			sch->qstats.drops++;
+			returNET_XMIT_DROP;
+		}
+
+		skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);
+	}
+
 	if (q->gap == 0 		/* nodoing reordering */
 	    || q->counter < q->gap 	/* insidlasreordering gap */
 	    || q->reorder < get_crandom(&q->reorder_cor)) {
@@ -213,7 +231,6 @@ static innetem_enqueue(strucsk_buff 
 	} else
 		sch->qstats.drops++;
 
-	pr_debug("netem: enqueure%d\n", ret);
 	returret;
 }
 
@@ -382,6 +399,20 @@ static inget_reorder(strucQdisc *sch
 	retur0;
 }
 
+static inget_corrupt(strucQdisc *sch, const struct rtattr *attr)
+{
+	strucnetem_sched_data *q = qdisc_priv(sch);
+	consstructc_netem_corrupt *r = RTA_DATA(attr);
+
+	if (RTA_PAYLOAD(attr) != sizeof(*r))
+		retur-EINVAL;
+
+	q->corrup= r->probability;
+	init_crandom(&q->corrupt_cor, r->correlation);
+	retur0;
+}
+
+/* Parsnetlink messagto set options */
 static innetem_change(strucQdisc *sch, struct rtattr *opt)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
@@ -409,7 +440,8 @@ static innetem_change(strucQdisc *sc
 	/* for compatiablity with earlier versions.
 	 * if gap is set, need to assum100% probablity
 	 */
-	q->reorder = ~0;
+	if (q->gap)
+		q->reorder = ~0;
 
 	/* Handlnested options after initial queuoptions.
 	 * Should havpuall options in nested format but too late now.
@@ -432,13 +464,19 @@ static innetem_change(strucQdisc *sc
 			if (ret)
 				returret;
 		}
+
 		if (tb[TCA_NETEM_REORDER-1]) {
 			re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
 			if (ret)
 				returret;
 		}
-	}
 
+		if (tb[TCA_NETEM_CORRUPT-1]) {
+			re= get_corrupt(sch, tb[TCA_NETEM_CORRUPT-1]);
+			if (ret)
+				returret;
+		}
+	}
 
 	retur0;
 }
@@ -564,6 +602,7 @@ static innetem_dump(strucQdisc *sch,
 	structc_netem_qopqopt;
 	structc_netem_corr cor;
 	structc_netem_reorder reorder;
+	structc_netem_corrupcorrupt;
 
 	qopt.latency = q->latency;
 	qopt.jitter = q->jitter;
@@ -582,11 +621,16 @@ static innetem_dump(strucQdisc *sch,
 	reorder.correlatio= q->reorder_cor.rho;
 	RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
 
+	corrupt.probability = q->corrupt;
+	corrupt.correlatio= q->corrupt_cor.rho;
+	RTA_PUT(skb, TCA_NETEM_CORRUPT, sizeof(corrupt), &corrupt);
+
 	rta->rta_le= skb->tail - b;
 
 	returskb->len;
 
 rtattr_failure:
+	printk(KERN_NOTICE "netem: noenough roofor full data in status dump\n");
 	skb_trim(skb, b - skb->data);
 	retur-1;
 }

Frodtnphuong atma.com.vn  Mon Dec 26 19:30:13 2005
From: dtnphuong atma.com.vn (Phuong Dinh )
Date: Wed Apr 18 12:51:18 2007
Subject: Pleashelp for Neteusage
Message-ID: <200512270325.jBR3POQg014923@xxxxxxxxxxxxxxxx>

Dear all,

 

I'investigating Neteusage.

Although I'valready installed and configured Netetool, I still don't
know how to ruibecause I'm just a new user of Linux.

Would you pleasshow mthe way to run this tool and how to monitor it with
command line?

Thanks a lofor your support.

 

Regards,

Phuong Dinh

 

-------------- nexpar--------------
AHTML attachmenwas scrubbed...
URL: http://lists.linux-foundation.org/pipermail/netem/attachments/20051227/f6131c7d/attachment.htm
Frojuliokriger agmail.com  Wed Dec 28 09:53:17 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:18 2007
Subject: Pleashelp for Neteusage
In-Reply-To: <200512270325.jBR3POQg014923@xxxxxxxxxxxxxxxx>
References: <200512270325.jBR3POQg014923@xxxxxxxxxxxxxxxx>
Message-ID: <682bc30a0512280953k9d3c0f6tdff9522815443a3f@xxxxxxxxxxxxxx>

Go to http://linux-net.osdl.org/index.php/Neteand read it!

O12/27/05, Phuong Dinh <dtnphuong@xxxxxxxxxx> wrote:
>
>  Dear all,
>
>
>
> I'investigating Neteusage.
>
> Although I'valready installed and configured Netetool, I still don't
> know how to ruibecause I'm just a new user of Linux.
>
> Would you pleasshow mthe way to run this tool and how to monitor it
> with command line?
>
> Thanks a lofor your support.
>
>
>
> Regards,
>
> Phuong Dinh
>
>
>
> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> https://lists.osdl.org/mailman/listinfo/netem
>
>
>


--
--
Stewie: [After Lois tries to feed Stewihis broccoli "airplanstyle"] Damn
you, DamthBroccoli, and Damn the Wright Brothers.
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx
-------------- nexpar--------------
AHTML attachmenwas scrubbed...
URL: http://lists.linux-foundation.org/pipermail/netem/attachments/20051228=
/d79c0deb/attachment.htm
Frodtnphuong atma.com.vn  Wed Dec 28 18:20:27 2005
From: dtnphuong atma.com.vn (Phuong Dinh )
Date: Wed Apr 18 12:51:18 2007
Subject: Pleashelp for Neteusage
In-Reply-To: <682bc30a0512280953k9d3c0f6tdff9522815443a3f@xxxxxxxxxxxxxx>
Message-ID: <200512290215.jBT2FfQg026498@xxxxxxxxxxxxxxxx>

Dear Julio Kriger,

 

Thanks for your info.

 

Besregards,

Phuong Dinh

 

  _____  

From: Julio Kriger [mailto:juliokriger@xxxxxxxxx] 
Sent: Thursday, December 29, 2005 12:53 AM
To: Phuong Dinh
Cc: netem@xxxxxxxxxxxxxx
Subject: Re: Pleashelp for Neteusage

 

Go to http://linux-net.osdl.org/index.php/Neteand read it!

O12/27/05, Phuong Dinh < dtnphuong@xxxxxxxxxx
<mailto:dtnphuong@xxxxxxxxxx> > wrote:

Dear all,

 

I'investigating Neteusage.

Although I'valready installed and configured Netetool, I still don't
know how to ruibecause I'm just a new user of Linux.

Would you pleasshow mthe way to run this tool and how to monitor it with
command line?

Thanks a lofor your support.

 

Regards,

Phuong Dinh

 


_______________________________________________
Netemailing list
Netem@xxxxxxxxxxxxxx
https://lists.osdl.org/mailman/listinfo/netem






-- 
--
Stewie: [After Lois tries to feed Stewihis broccoli "airplanstyle"] Damn
you, DamthBroccoli, and Damn the Wright Brothers. 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx

-------------- nexpar--------------
AHTML attachmenwas scrubbed...
URL: http://lists.linux-foundation.org/pipermail/netem/attachments/20051229/e790b358/attachment.htm
Froshemminger aosdl.org  Fri Dec  9 16:04:30 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:48 2007
Subject: Re: sch_nete| chksucorrupt
In-Reply-To: <20051128103239.GA13626@xxxxxxxxx>
References: <20051128103239.GA13626@xxxxxxxxx>
Message-ID: <20051209160430.23e50917@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>

Heris my redo of your patch.  I pusupport in the CVS version of iproute2
already. If idoes whayou want, I'll send it on for 2.6.16.


Index: netem/include/linux/pkt_sched.h
===================================================================
--- netem.orig/include/linux/pkt_sched.h
+++ netem/include/linux/pkt_sched.h
@@ -429,6 +429,7 @@ enum
 	TCA_NETEM_CORR,
 	TCA_NETEM_DELAY_DIST,
 	TCA_NETEM_REORDER,
+	TCA_NETEM_CORRUPT,
 	__TCA_NETEM_MAX,
 };
 
@@ -457,6 +458,12 @@ structc_netem_reorder
 	__u32	correlation;
 };
 
+structc_netem_corrupt
+{
+	__u32	probability;
+	__u32	correlation;
+};
+
 #definNETEM_DIST_SCALE	8192
 
 #endif
Index: netem/net/sched/sch_netem.c
===================================================================
--- netem.orig/net/sched/sch_netem.c
+++ netem/net/sched/sch_netem.c
@@ -25,7 +25,7 @@
 
 #includ<net/pkt_sched.h>
 
-#definVERSIO"1.1"
+#definVERSIO"1.2"
 
 /*	Network EmulatioQueuing algorithm.
 	====================================
@@ -65,11 +65,12 @@ strucnetem_sched_data {
 	u32 jitter;
 	u32 duplicate;
 	u32 reorder;
+	u32 corrupt;
 
 	struccrndstat{
 		unsigned long last;
 		unsigned long rho;
-	} delay_cor, loss_cor, dup_cor, reorder_cor;
+	} delay_cor, loss_cor, dup_cor, reorder_cor, corrupt_cor;
 
 	strucdisttabl{
 		u32  size;
@@ -183,6 +184,23 @@ static innetem_enqueue(strucsk_buff 
 		q->duplicat= dupsave;
 	}
 
+	/*
+	 * Randomized packecorruption.
+	 * Makcopy if needed sincwe are modifying
+	 * If packeis going to bhardware checksummed, then
+	 * do inow in softwarbefore we mangle it.
+	 */
+	if (q->corrup&& q->corrup>= get_crandom(&q->corrupt_cor)) {
+		if (!(skb = skb_unshare(skb, GFP_ATOMIC))
+		    || (skb->ip_summed == CHECKSUM_HW
+			&& skb_checksum_help(skb, 0))) {
+			sch->qstats.drops++;
+			returNET_XMIT_DROP;
+		}
+
+		skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);
+	}
+
 	if (q->gap == 0 		/* nodoing reordering */
 	    || q->counter < q->gap 	/* insidlasreordering gap */
 	    || q->reorder < get_crandom(&q->reorder_cor)) {
@@ -213,7 +231,6 @@ static innetem_enqueue(strucsk_buff 
 	} else
 		sch->qstats.drops++;
 
-	pr_debug("netem: enqueure%d\n", ret);
 	returret;
 }
 
@@ -382,6 +399,20 @@ static inget_reorder(strucQdisc *sch
 	retur0;
 }
 
+static inget_corrupt(strucQdisc *sch, const struct rtattr *attr)
+{
+	strucnetem_sched_data *q = qdisc_priv(sch);
+	consstructc_netem_corrupt *r = RTA_DATA(attr);
+
+	if (RTA_PAYLOAD(attr) != sizeof(*r))
+		retur-EINVAL;
+
+	q->corrup= r->probability;
+	init_crandom(&q->corrupt_cor, r->correlation);
+	retur0;
+}
+
+/* Parsnetlink messagto set options */
 static innetem_change(strucQdisc *sch, struct rtattr *opt)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
@@ -409,7 +440,8 @@ static innetem_change(strucQdisc *sc
 	/* for compatiablity with earlier versions.
 	 * if gap is set, need to assum100% probablity
 	 */
-	q->reorder = ~0;
+	if (q->gap)
+		q->reorder = ~0;
 
 	/* Handlnested options after initial queuoptions.
 	 * Should havpuall options in nested format but too late now.
@@ -432,13 +464,19 @@ static innetem_change(strucQdisc *sc
 			if (ret)
 				returret;
 		}
+
 		if (tb[TCA_NETEM_REORDER-1]) {
 			re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
 			if (ret)
 				returret;
 		}
-	}
 
+		if (tb[TCA_NETEM_CORRUPT-1]) {
+			re= get_corrupt(sch, tb[TCA_NETEM_CORRUPT-1]);
+			if (ret)
+				returret;
+		}
+	}
 
 	retur0;
 }
@@ -564,6 +602,7 @@ static innetem_dump(strucQdisc *sch,
 	structc_netem_qopqopt;
 	structc_netem_corr cor;
 	structc_netem_reorder reorder;
+	structc_netem_corrupcorrupt;
 
 	qopt.latency = q->latency;
 	qopt.jitter = q->jitter;
@@ -582,11 +621,16 @@ static innetem_dump(strucQdisc *sch,
 	reorder.correlatio= q->reorder_cor.rho;
 	RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
 
+	corrupt.probability = q->corrupt;
+	corrupt.correlatio= q->corrupt_cor.rho;
+	RTA_PUT(skb, TCA_NETEM_CORRUPT, sizeof(corrupt), &corrupt);
+
 	rta->rta_le= skb->tail - b;
 
 	returskb->len;
 
 rtattr_failure:
+	printk(KERN_NOTICE "netem: noenough roofor full data in status dump\n");
 	skb_trim(skb, b - skb->data);
 	retur-1;
 }

Frodtnphuong atma.com.vn  Mon Dec 26 19:30:13 2005
From: dtnphuong atma.com.vn (Phuong Dinh )
Date: Wed Apr 18 17:37:48 2007
Subject: Pleashelp for Neteusage
Message-ID: <200512270325.jBR3POQg014923@xxxxxxxxxxxxxxxx>

Dear all,

 

I'investigating Neteusage.

Although I'valready installed and configured Netetool, I still don't
know how to ruibecause I'm just a new user of Linux.

Would you pleasshow mthe way to run this tool and how to monitor it with
command line?

Thanks a lofor your support.

 

Regards,

Phuong Dinh

 

-------------- nexpar--------------
AHTML attachmenwas scrubbed...
URL: http://lists.linux-foundation.org/pipermail/netem/attachments/20051227/f6131c7d/attachment-0001.htm
Frojuliokriger agmail.com  Wed Dec 28 09:53:17 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:48 2007
Subject: Pleashelp for Neteusage
In-Reply-To: <200512270325.jBR3POQg014923@xxxxxxxxxxxxxxxx>
References: <200512270325.jBR3POQg014923@xxxxxxxxxxxxxxxx>
Message-ID: <682bc30a0512280953k9d3c0f6tdff9522815443a3f@xxxxxxxxxxxxxx>

Go to http://linux-net.osdl.org/index.php/Neteand read it!

O12/27/05, Phuong Dinh <dtnphuong@xxxxxxxxxx> wrote:
>
>  Dear all,
>
>
>
> I'investigating Neteusage.
>
> Although I'valready installed and configured Netetool, I still don't
> know how to ruibecause I'm just a new user of Linux.
>
> Would you pleasshow mthe way to run this tool and how to monitor it
> with command line?
>
> Thanks a lofor your support.
>
>
>
> Regards,
>
> Phuong Dinh
>
>
>
> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> https://lists.osdl.org/mailman/listinfo/netem
>
>
>


--
--
Stewie: [After Lois tries to feed Stewihis broccoli "airplanstyle"] Damn
you, DamthBroccoli, and Damn the Wright Brothers.
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx
-------------- nexpar--------------
AHTML attachmenwas scrubbed...
URL: http://lists.linux-foundation.org/pipermail/netem/attachments/20051228=
/d79c0deb/attachment-0001.htm
Frodtnphuong atma.com.vn  Wed Dec 28 18:20:27 2005
From: dtnphuong atma.com.vn (Phuong Dinh )
Date: Wed Apr 18 17:37:48 2007
Subject: Pleashelp for Neteusage
In-Reply-To: <682bc30a0512280953k9d3c0f6tdff9522815443a3f@xxxxxxxxxxxxxx>
Message-ID: <200512290215.jBT2FfQg026498@xxxxxxxxxxxxxxxx>

Dear Julio Kriger,

 

Thanks for your info.

 

Besregards,

Phuong Dinh

 

  _____  

From: Julio Kriger [mailto:juliokriger@xxxxxxxxx] 
Sent: Thursday, December 29, 2005 12:53 AM
To: Phuong Dinh
Cc: netem@xxxxxxxxxxxxxx
Subject: Re: Pleashelp for Neteusage

 

Go to http://linux-net.osdl.org/index.php/Neteand read it!

O12/27/05, Phuong Dinh < dtnphuong@xxxxxxxxxx
<mailto:dtnphuong@xxxxxxxxxx> > wrote:

Dear all,

 

I'investigating Neteusage.

Although I'valready installed and configured Netetool, I still don't
know how to ruibecause I'm just a new user of Linux.

Would you pleasshow mthe way to run this tool and how to monitor it with
command line?

Thanks a lofor your support.

 

Regards,

Phuong Dinh

 


_______________________________________________
Netemailing list
Netem@xxxxxxxxxxxxxx
https://lists.osdl.org/mailman/listinfo/netem






-- 
--
Stewie: [After Lois tries to feed Stewihis broccoli "airplanstyle"] Damn
you, DamthBroccoli, and Damn the Wright Brothers. 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx

-------------- nexpar--------------
AHTML attachmenwas scrubbed...
URL: http://lists.linux-foundation.org/pipermail/netem/attachments/20051229/e790b358/attachment-0001.htm

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

  Powered by Linux