Patchwork [2/5] pktgen: set different default min_pkt_size for different protocols

login
register
mail settings
Submitter Amerigo Wang
Date Oct. 9, 2012, 10:05 a.m.
Message ID <1349777131-4425-2-git-send-email-amwang@redhat.com>
Download mbox | patch
Permalink /patch/190255/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Amerigo Wang - Oct. 9, 2012, 10:05 a.m.
ETH_ZLEN is too small for IPv6, so this default value is not
suitable.

Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
---
 net/core/pktgen.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
David Miller - Oct. 9, 2012, 5:55 p.m.
From: Cong Wang <amwang@redhat.com>
Date: Tue,  9 Oct 2012 18:05:28 +0800

> ETH_ZLEN is too small for IPv6, so this default value is not
> suitable.
> 
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Cong Wang <amwang@redhat.com>

pkt_dev->max_pkt_size is no longer being initialized.

At least set it to whatever you compute in pkt_dev->min_pkt_size
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Amerigo Wang - Oct. 10, 2012, 2:19 a.m.
On Tue, 2012-10-09 at 13:55 -0400, David Miller wrote:
> From: Cong Wang <amwang@redhat.com>
> Date: Tue,  9 Oct 2012 18:05:28 +0800
> 
> > ETH_ZLEN is too small for IPv6, so this default value is not
> > suitable.
> > 
> > Cc: David S. Miller <davem@davemloft.net>
> > Signed-off-by: Cong Wang <amwang@redhat.com>
> 
> pkt_dev->max_pkt_size is no longer being initialized.
> 
> At least set it to whatever you compute in pkt_dev->min_pkt_size

Oops, I forgot it. Will send an updated version.

Thanks!

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index e356b8d..16921c3 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -248,8 +248,8 @@  struct pktgen_dev {
 	int removal_mark;	/* non-zero => the device is marked for
 				 * removal by worker thread */
 
-	int min_pkt_size;	/* = ETH_ZLEN; */
-	int max_pkt_size;	/* = ETH_ZLEN; */
+	int min_pkt_size;
+	int max_pkt_size;
 	int pkt_overhead;	/* overhead for MPLS, VLANs, IPSEC etc */
 	int nfrags;
 	struct page *page;
@@ -2036,10 +2036,16 @@  static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
 	/* Set up Dest MAC */
 	memcpy(&(pkt_dev->hh[0]), pkt_dev->dst_mac, ETH_ALEN);
 
-	/* Set up pkt size */
-	pkt_dev->cur_pkt_size = pkt_dev->min_pkt_size;
-
 	if (pkt_dev->flags & F_IPV6) {
+		if (pkt_dev->min_pkt_size == 0) {
+			pkt_dev->min_pkt_size = 14 + sizeof(struct ipv6hdr)
+						+ sizeof(struct udphdr)
+						+ sizeof(struct pktgen_hdr)
+						+ pkt_dev->pkt_overhead;
+		}
+
+		pkt_dev->cur_pkt_size = pkt_dev->min_pkt_size;
+
 		/*
 		 * Skip this automatic address setting until locks or functions
 		 * gets exported
@@ -2086,6 +2092,14 @@  static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
 		}
 #endif
 	} else {
+		if (pkt_dev->min_pkt_size == 0) {
+			pkt_dev->min_pkt_size = 14 + sizeof(struct iphdr)
+						+ sizeof(struct udphdr)
+						+ sizeof(struct pktgen_hdr)
+						+ pkt_dev->pkt_overhead;
+		}
+		pkt_dev->cur_pkt_size = pkt_dev->min_pkt_size;
+
 		pkt_dev->saddr_min = 0;
 		pkt_dev->saddr_max = 0;
 		if (strlen(pkt_dev->src_min) == 0) {
@@ -3548,8 +3562,6 @@  static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
 	}
 
 	pkt_dev->removal_mark = 0;
-	pkt_dev->min_pkt_size = ETH_ZLEN;
-	pkt_dev->max_pkt_size = ETH_ZLEN;
 	pkt_dev->nfrags = 0;
 	pkt_dev->delay = pg_delay_d;
 	pkt_dev->count = pg_count_d;