aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorJamal Hadi Salim <hadi@cyberus.ca>2007-07-03 01:39:50 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-07-11 01:16:26 -0400
commit16dab72f65a6aab0aa72866e00c91b58a2794082 (patch)
tree2e0b5871e75b9b4cef7c38d2d783147b942086ae /net/core
parenteef6caf8a916f32f8d9b2a02d4fa7674736c00ac (diff)
[PKTGEN]: Centralize packet overhead tracking
Track the extra packet overhead for VLAN tags, MPLS, IPSEC etc Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca> Signed-off-by: Robert Olsson <robert.olsson@its.uu.se> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/pktgen.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index dffe067e7a7b..9f0a780aa916 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -228,6 +228,7 @@ struct pktgen_dev {
228 228
229 int min_pkt_size; /* = ETH_ZLEN; */ 229 int min_pkt_size; /* = ETH_ZLEN; */
230 int max_pkt_size; /* = ETH_ZLEN; */ 230 int max_pkt_size; /* = ETH_ZLEN; */
231 int pkt_overhead; /* overhead for MPLS, VLANs, IPSEC etc */
231 int nfrags; 232 int nfrags;
232 __u32 delay_us; /* Default delay */ 233 __u32 delay_us; /* Default delay */
233 __u32 delay_ns; 234 __u32 delay_ns;
@@ -2075,6 +2076,13 @@ static void spin(struct pktgen_dev *pkt_dev, __u64 spin_until_us)
2075 pkt_dev->idle_acc += now - start; 2076 pkt_dev->idle_acc += now - start;
2076} 2077}
2077 2078
2079static inline void set_pkt_overhead(struct pktgen_dev *pkt_dev)
2080{
2081 pkt_dev->pkt_overhead += pkt_dev->nr_labels*sizeof(u32);
2082 pkt_dev->pkt_overhead += VLAN_TAG_SIZE(pkt_dev);
2083 pkt_dev->pkt_overhead += SVLAN_TAG_SIZE(pkt_dev);
2084}
2085
2078/* Increment/randomize headers according to flags and current values 2086/* Increment/randomize headers according to flags and current values
2079 * for IP src/dest, UDP src/dst port, MAC-Addr src/dst 2087 * for IP src/dest, UDP src/dst port, MAC-Addr src/dst
2080 */ 2088 */
@@ -2323,9 +2331,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2323 2331
2324 datalen = (odev->hard_header_len + 16) & ~0xf; 2332 datalen = (odev->hard_header_len + 16) & ~0xf;
2325 skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + datalen + 2333 skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + datalen +
2326 pkt_dev->nr_labels*sizeof(u32) + 2334 pkt_dev->pkt_overhead, GFP_ATOMIC);
2327 VLAN_TAG_SIZE(pkt_dev) + SVLAN_TAG_SIZE(pkt_dev),
2328 GFP_ATOMIC);
2329 if (!skb) { 2335 if (!skb) {
2330 sprintf(pkt_dev->result, "No memory"); 2336 sprintf(pkt_dev->result, "No memory");
2331 return NULL; 2337 return NULL;
@@ -2368,7 +2374,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2368 2374
2369 /* Eth + IPh + UDPh + mpls */ 2375 /* Eth + IPh + UDPh + mpls */
2370 datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 - 2376 datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 -
2371 pkt_dev->nr_labels*sizeof(u32) - VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev); 2377 pkt_dev->pkt_overhead;
2372 if (datalen < sizeof(struct pktgen_hdr)) 2378 if (datalen < sizeof(struct pktgen_hdr))
2373 datalen = sizeof(struct pktgen_hdr); 2379 datalen = sizeof(struct pktgen_hdr);
2374 2380
@@ -2391,8 +2397,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2391 iph->check = ip_fast_csum((void *)iph, iph->ihl); 2397 iph->check = ip_fast_csum((void *)iph, iph->ihl);
2392 skb->protocol = protocol; 2398 skb->protocol = protocol;
2393 skb->mac_header = (skb->network_header - ETH_HLEN - 2399 skb->mac_header = (skb->network_header - ETH_HLEN -
2394 pkt_dev->nr_labels * sizeof(u32) - 2400 pkt_dev->pkt_overhead);
2395 VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev));
2396 skb->dev = odev; 2401 skb->dev = odev;
2397 skb->pkt_type = PACKET_HOST; 2402 skb->pkt_type = PACKET_HOST;
2398 2403
@@ -2662,9 +2667,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2662 mod_cur_headers(pkt_dev); 2667 mod_cur_headers(pkt_dev);
2663 2668
2664 skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16 + 2669 skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16 +
2665 pkt_dev->nr_labels*sizeof(u32) + 2670 pkt_dev->pkt_overhead, GFP_ATOMIC);
2666 VLAN_TAG_SIZE(pkt_dev) + SVLAN_TAG_SIZE(pkt_dev),
2667 GFP_ATOMIC);
2668 if (!skb) { 2671 if (!skb) {
2669 sprintf(pkt_dev->result, "No memory"); 2672 sprintf(pkt_dev->result, "No memory");
2670 return NULL; 2673 return NULL;
@@ -2708,7 +2711,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2708 /* Eth + IPh + UDPh + mpls */ 2711 /* Eth + IPh + UDPh + mpls */
2709 datalen = pkt_dev->cur_pkt_size - 14 - 2712 datalen = pkt_dev->cur_pkt_size - 14 -
2710 sizeof(struct ipv6hdr) - sizeof(struct udphdr) - 2713 sizeof(struct ipv6hdr) - sizeof(struct udphdr) -
2711 pkt_dev->nr_labels*sizeof(u32) - VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev); 2714 pkt_dev->pkt_overhead;
2712 2715
2713 if (datalen < sizeof(struct pktgen_hdr)) { 2716 if (datalen < sizeof(struct pktgen_hdr)) {
2714 datalen = sizeof(struct pktgen_hdr); 2717 datalen = sizeof(struct pktgen_hdr);
@@ -2738,8 +2741,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2738 ipv6_addr_copy(&iph->saddr, &pkt_dev->cur_in6_saddr); 2741 ipv6_addr_copy(&iph->saddr, &pkt_dev->cur_in6_saddr);
2739 2742
2740 skb->mac_header = (skb->network_header - ETH_HLEN - 2743 skb->mac_header = (skb->network_header - ETH_HLEN -
2741 pkt_dev->nr_labels * sizeof(u32) - 2744 pkt_dev->pkt_overhead);
2742 VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev));
2743 skb->protocol = protocol; 2745 skb->protocol = protocol;
2744 skb->dev = odev; 2746 skb->dev = odev;
2745 skb->pkt_type = PACKET_HOST; 2747 skb->pkt_type = PACKET_HOST;
@@ -2857,6 +2859,7 @@ static void pktgen_run(struct pktgen_thread *t)
2857 pkt_dev->started_at = getCurUs(); 2859 pkt_dev->started_at = getCurUs();
2858 pkt_dev->next_tx_us = getCurUs(); /* Transmit immediately */ 2860 pkt_dev->next_tx_us = getCurUs(); /* Transmit immediately */
2859 pkt_dev->next_tx_ns = 0; 2861 pkt_dev->next_tx_ns = 0;
2862 set_pkt_overhead(pkt_dev);
2860 2863
2861 strcpy(pkt_dev->result, "Starting"); 2864 strcpy(pkt_dev->result, "Starting");
2862 started++; 2865 started++;