aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/pktgen.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2006-11-14 23:48:11 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:22:49 -0500
commit252e33467a3b016f20dd8df12269cef3b167f21e (patch)
treed8ea541988b3352dd832df8a9e6ab5ca195e3528 /net/core/pktgen.c
parent448c31aa34b5ee947d322e8747c4cf801fc4c104 (diff)
[NET] net/core: Annotations.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/pktgen.c')
-rw-r--r--net/core/pktgen.c68
1 files changed, 32 insertions, 36 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 733d86d0a4fb..1897a3a385d8 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -207,7 +207,7 @@ static struct proc_dir_entry *pg_proc_dir = NULL;
207#define SVLAN_TAG_SIZE(x) ((x)->svlan_id == 0xffff ? 0 : 4) 207#define SVLAN_TAG_SIZE(x) ((x)->svlan_id == 0xffff ? 0 : 4)
208 208
209struct flow_state { 209struct flow_state {
210 __u32 cur_daddr; 210 __be32 cur_daddr;
211 int count; 211 int count;
212}; 212};
213 213
@@ -282,10 +282,10 @@ struct pktgen_dev {
282 /* If we're doing ranges, random or incremental, then this 282 /* If we're doing ranges, random or incremental, then this
283 * defines the min/max for those ranges. 283 * defines the min/max for those ranges.
284 */ 284 */
285 __u32 saddr_min; /* inclusive, source IP address */ 285 __be32 saddr_min; /* inclusive, source IP address */
286 __u32 saddr_max; /* exclusive, source IP address */ 286 __be32 saddr_max; /* exclusive, source IP address */
287 __u32 daddr_min; /* inclusive, dest IP address */ 287 __be32 daddr_min; /* inclusive, dest IP address */
288 __u32 daddr_max; /* exclusive, dest IP address */ 288 __be32 daddr_max; /* exclusive, dest IP address */
289 289
290 __u16 udp_src_min; /* inclusive, source UDP port */ 290 __u16 udp_src_min; /* inclusive, source UDP port */
291 __u16 udp_src_max; /* exclusive, source UDP port */ 291 __u16 udp_src_max; /* exclusive, source UDP port */
@@ -317,8 +317,8 @@ struct pktgen_dev {
317 317
318 __u32 cur_dst_mac_offset; 318 __u32 cur_dst_mac_offset;
319 __u32 cur_src_mac_offset; 319 __u32 cur_src_mac_offset;
320 __u32 cur_saddr; 320 __be32 cur_saddr;
321 __u32 cur_daddr; 321 __be32 cur_daddr;
322 __u16 cur_udp_dst; 322 __u16 cur_udp_dst;
323 __u16 cur_udp_src; 323 __u16 cur_udp_src;
324 __u32 cur_pkt_size; 324 __u32 cur_pkt_size;
@@ -350,10 +350,10 @@ struct pktgen_dev {
350}; 350};
351 351
352struct pktgen_hdr { 352struct pktgen_hdr {
353 __u32 pgh_magic; 353 __be32 pgh_magic;
354 __u32 seq_num; 354 __be32 seq_num;
355 __u32 tv_sec; 355 __be32 tv_sec;
356 __u32 tv_usec; 356 __be32 tv_usec;
357}; 357};
358 358
359struct pktgen_thread { 359struct pktgen_thread {
@@ -2160,7 +2160,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
2160 for(i = 0; i < pkt_dev->nr_labels; i++) 2160 for(i = 0; i < pkt_dev->nr_labels; i++)
2161 if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM) 2161 if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM)
2162 pkt_dev->labels[i] = MPLS_STACK_BOTTOM | 2162 pkt_dev->labels[i] = MPLS_STACK_BOTTOM |
2163 (pktgen_random() & 2163 ((__force __be32)pktgen_random() &
2164 htonl(0x000fffff)); 2164 htonl(0x000fffff));
2165 } 2165 }
2166 2166
@@ -2220,29 +2220,25 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
2220 if (pkt_dev->cflows && pkt_dev->flows[flow].count != 0) { 2220 if (pkt_dev->cflows && pkt_dev->flows[flow].count != 0) {
2221 pkt_dev->cur_daddr = pkt_dev->flows[flow].cur_daddr; 2221 pkt_dev->cur_daddr = pkt_dev->flows[flow].cur_daddr;
2222 } else { 2222 } else {
2223 2223 imn = ntohl(pkt_dev->daddr_min);
2224 if ((imn = ntohl(pkt_dev->daddr_min)) < (imx = 2224 imx = ntohl(pkt_dev->daddr_max);
2225 ntohl(pkt_dev-> 2225 if (imn < imx) {
2226 daddr_max)))
2227 {
2228 __u32 t; 2226 __u32 t;
2227 __be32 s;
2229 if (pkt_dev->flags & F_IPDST_RND) { 2228 if (pkt_dev->flags & F_IPDST_RND) {
2230 2229
2231 t = ((pktgen_random() % (imx - imn)) + 2230 t = pktgen_random() % (imx - imn) + imn;
2232 imn); 2231 s = htonl(t);
2233 t = htonl(t);
2234 2232
2235 while (LOOPBACK(t) || MULTICAST(t) 2233 while (LOOPBACK(s) || MULTICAST(s)
2236 || BADCLASS(t) || ZERONET(t) 2234 || BADCLASS(s) || ZERONET(s)
2237 || LOCAL_MCAST(t)) { 2235 || LOCAL_MCAST(s)) {
2238 t = ((pktgen_random() % 2236 t = (pktgen_random() %
2239 (imx - imn)) + imn); 2237 (imx - imn)) + imn;
2240 t = htonl(t); 2238 s = htonl(t);
2241 } 2239 }
2242 pkt_dev->cur_daddr = t; 2240 pkt_dev->cur_daddr = s;
2243 } 2241 } else {
2244
2245 else {
2246 t = ntohl(pkt_dev->cur_daddr); 2242 t = ntohl(pkt_dev->cur_daddr);
2247 t++; 2243 t++;
2248 if (t > imx) { 2244 if (t > imx) {
@@ -2270,7 +2266,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
2270 2266
2271 for (i = 0; i < 4; i++) { 2267 for (i = 0; i < 4; i++) {
2272 pkt_dev->cur_in6_daddr.s6_addr32[i] = 2268 pkt_dev->cur_in6_daddr.s6_addr32[i] =
2273 ((pktgen_random() | 2269 (((__force __be32)pktgen_random() |
2274 pkt_dev->min_in6_daddr.s6_addr32[i]) & 2270 pkt_dev->min_in6_daddr.s6_addr32[i]) &
2275 pkt_dev->max_in6_daddr.s6_addr32[i]); 2271 pkt_dev->max_in6_daddr.s6_addr32[i]);
2276 } 2272 }
@@ -2377,7 +2373,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2377 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); 2373 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr));
2378 2374
2379 memcpy(eth, pkt_dev->hh, 12); 2375 memcpy(eth, pkt_dev->hh, 12);
2380 *(u16 *) & eth[12] = protocol; 2376 *(__be16 *) & eth[12] = protocol;
2381 2377
2382 /* Eth + IPh + UDPh + mpls */ 2378 /* Eth + IPh + UDPh + mpls */
2383 datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 - 2379 datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 -
@@ -2497,7 +2493,7 @@ static unsigned int scan_ip6(const char *s, char ip[16])
2497 char suffix[16]; 2493 char suffix[16];
2498 unsigned int prefixlen = 0; 2494 unsigned int prefixlen = 0;
2499 unsigned int suffixlen = 0; 2495 unsigned int suffixlen = 0;
2500 __u32 tmp; 2496 __be32 tmp;
2501 2497
2502 for (i = 0; i < 16; i++) 2498 for (i = 0; i < 16; i++)
2503 ip[i] = 0; 2499 ip[i] = 0;
@@ -2713,7 +2709,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2713 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); 2709 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr));
2714 2710
2715 memcpy(eth, pkt_dev->hh, 12); 2711 memcpy(eth, pkt_dev->hh, 12);
2716 *(u16 *) & eth[12] = protocol; 2712 *(__be16 *) & eth[12] = protocol;
2717 2713
2718 /* Eth + IPh + UDPh + mpls */ 2714 /* Eth + IPh + UDPh + mpls */
2719 datalen = pkt_dev->cur_pkt_size - 14 - 2715 datalen = pkt_dev->cur_pkt_size - 14 -
@@ -2732,11 +2728,11 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2732 udph->len = htons(datalen + sizeof(struct udphdr)); 2728 udph->len = htons(datalen + sizeof(struct udphdr));
2733 udph->check = 0; /* No checksum */ 2729 udph->check = 0; /* No checksum */
2734 2730
2735 *(u32 *) iph = __constant_htonl(0x60000000); /* Version + flow */ 2731 *(__be32 *) iph = __constant_htonl(0x60000000); /* Version + flow */
2736 2732
2737 if (pkt_dev->traffic_class) { 2733 if (pkt_dev->traffic_class) {
2738 /* Version + traffic class + flow (0) */ 2734 /* Version + traffic class + flow (0) */
2739 *(u32 *)iph |= htonl(0x60000000 | (pkt_dev->traffic_class << 20)); 2735 *(__be32 *)iph |= htonl(0x60000000 | (pkt_dev->traffic_class << 20));
2740 } 2736 }
2741 2737
2742 iph->hop_limit = 32; 2738 iph->hop_limit = 32;