diff options
author | Amerigo Wang <amwang@redhat.com> | 2012-10-09 13:48:17 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-10-10 22:33:30 -0400 |
commit | 68bf9f0b91ed4440951312cf7d4ffa70b9e8cf73 (patch) | |
tree | 7cadb1cdf9994926cd8c573bdc63b619b256178d /net/core | |
parent | 5aa8b572007c4bca1e6d3dd4c4820f1ae49d6bb2 (diff) |
pktgen: set different default min_pkt_size for different protocols
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/pktgen.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index e356b8d52bad..98ee54963553 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -248,8 +248,8 @@ struct pktgen_dev { | |||
248 | int removal_mark; /* non-zero => the device is marked for | 248 | int removal_mark; /* non-zero => the device is marked for |
249 | * removal by worker thread */ | 249 | * removal by worker thread */ |
250 | 250 | ||
251 | int min_pkt_size; /* = ETH_ZLEN; */ | 251 | int min_pkt_size; |
252 | int max_pkt_size; /* = ETH_ZLEN; */ | 252 | int max_pkt_size; |
253 | int pkt_overhead; /* overhead for MPLS, VLANs, IPSEC etc */ | 253 | int pkt_overhead; /* overhead for MPLS, VLANs, IPSEC etc */ |
254 | int nfrags; | 254 | int nfrags; |
255 | struct page *page; | 255 | struct page *page; |
@@ -2036,10 +2036,14 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev) | |||
2036 | /* Set up Dest MAC */ | 2036 | /* Set up Dest MAC */ |
2037 | memcpy(&(pkt_dev->hh[0]), pkt_dev->dst_mac, ETH_ALEN); | 2037 | memcpy(&(pkt_dev->hh[0]), pkt_dev->dst_mac, ETH_ALEN); |
2038 | 2038 | ||
2039 | /* Set up pkt size */ | ||
2040 | pkt_dev->cur_pkt_size = pkt_dev->min_pkt_size; | ||
2041 | |||
2042 | if (pkt_dev->flags & F_IPV6) { | 2039 | if (pkt_dev->flags & F_IPV6) { |
2040 | if (pkt_dev->min_pkt_size == 0) { | ||
2041 | pkt_dev->min_pkt_size = 14 + sizeof(struct ipv6hdr) | ||
2042 | + sizeof(struct udphdr) | ||
2043 | + sizeof(struct pktgen_hdr) | ||
2044 | + pkt_dev->pkt_overhead; | ||
2045 | } | ||
2046 | |||
2043 | /* | 2047 | /* |
2044 | * Skip this automatic address setting until locks or functions | 2048 | * Skip this automatic address setting until locks or functions |
2045 | * gets exported | 2049 | * gets exported |
@@ -2086,6 +2090,13 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev) | |||
2086 | } | 2090 | } |
2087 | #endif | 2091 | #endif |
2088 | } else { | 2092 | } else { |
2093 | if (pkt_dev->min_pkt_size == 0) { | ||
2094 | pkt_dev->min_pkt_size = 14 + sizeof(struct iphdr) | ||
2095 | + sizeof(struct udphdr) | ||
2096 | + sizeof(struct pktgen_hdr) | ||
2097 | + pkt_dev->pkt_overhead; | ||
2098 | } | ||
2099 | |||
2089 | pkt_dev->saddr_min = 0; | 2100 | pkt_dev->saddr_min = 0; |
2090 | pkt_dev->saddr_max = 0; | 2101 | pkt_dev->saddr_max = 0; |
2091 | if (strlen(pkt_dev->src_min) == 0) { | 2102 | if (strlen(pkt_dev->src_min) == 0) { |
@@ -2111,6 +2122,10 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev) | |||
2111 | pkt_dev->daddr_max = in_aton(pkt_dev->dst_max); | 2122 | pkt_dev->daddr_max = in_aton(pkt_dev->dst_max); |
2112 | } | 2123 | } |
2113 | /* Initialize current values. */ | 2124 | /* Initialize current values. */ |
2125 | pkt_dev->cur_pkt_size = pkt_dev->min_pkt_size; | ||
2126 | if (pkt_dev->min_pkt_size > pkt_dev->max_pkt_size) | ||
2127 | pkt_dev->max_pkt_size = pkt_dev->min_pkt_size; | ||
2128 | |||
2114 | pkt_dev->cur_dst_mac_offset = 0; | 2129 | pkt_dev->cur_dst_mac_offset = 0; |
2115 | pkt_dev->cur_src_mac_offset = 0; | 2130 | pkt_dev->cur_src_mac_offset = 0; |
2116 | pkt_dev->cur_saddr = pkt_dev->saddr_min; | 2131 | pkt_dev->cur_saddr = pkt_dev->saddr_min; |
@@ -3548,8 +3563,6 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname) | |||
3548 | } | 3563 | } |
3549 | 3564 | ||
3550 | pkt_dev->removal_mark = 0; | 3565 | pkt_dev->removal_mark = 0; |
3551 | pkt_dev->min_pkt_size = ETH_ZLEN; | ||
3552 | pkt_dev->max_pkt_size = ETH_ZLEN; | ||
3553 | pkt_dev->nfrags = 0; | 3566 | pkt_dev->nfrags = 0; |
3554 | pkt_dev->delay = pg_delay_d; | 3567 | pkt_dev->delay = pg_delay_d; |
3555 | pkt_dev->count = pg_count_d; | 3568 | pkt_dev->count = pg_count_d; |