diff options
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/pktgen.c | 298 |
1 files changed, 159 insertions, 139 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index ad41f06c13ca..51b1e61d3029 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -163,13 +163,14 @@ | |||
163 | #include <asm/byteorder.h> | 163 | #include <asm/byteorder.h> |
164 | #include <linux/rcupdate.h> | 164 | #include <linux/rcupdate.h> |
165 | #include <linux/bitops.h> | 165 | #include <linux/bitops.h> |
166 | #include <asm/io.h> | 166 | #include <linux/io.h> |
167 | #include <linux/timex.h> | ||
168 | #include <linux/uaccess.h> | ||
167 | #include <asm/dma.h> | 169 | #include <asm/dma.h> |
168 | #include <asm/uaccess.h> | ||
169 | #include <asm/div64.h> /* do_div */ | 170 | #include <asm/div64.h> /* do_div */ |
170 | #include <asm/timex.h> | ||
171 | 171 | ||
172 | #define VERSION "pktgen v2.70: Packet Generator for packet performance testing.\n" | 172 | #define VERSION \ |
173 | "pktgen v2.70: Packet Generator for packet performance testing.\n" | ||
173 | 174 | ||
174 | #define IP_NAME_SZ 32 | 175 | #define IP_NAME_SZ 32 |
175 | #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */ | 176 | #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */ |
@@ -207,7 +208,7 @@ | |||
207 | #define PKTGEN_MAGIC 0xbe9be955 | 208 | #define PKTGEN_MAGIC 0xbe9be955 |
208 | #define PG_PROC_DIR "pktgen" | 209 | #define PG_PROC_DIR "pktgen" |
209 | #define PGCTRL "pgctrl" | 210 | #define PGCTRL "pgctrl" |
210 | static struct proc_dir_entry *pg_proc_dir = NULL; | 211 | static struct proc_dir_entry *pg_proc_dir; |
211 | 212 | ||
212 | #define MAX_CFLOWS 65536 | 213 | #define MAX_CFLOWS 65536 |
213 | 214 | ||
@@ -232,9 +233,9 @@ struct pktgen_dev { | |||
232 | */ | 233 | */ |
233 | struct proc_dir_entry *entry; /* proc file */ | 234 | struct proc_dir_entry *entry; /* proc file */ |
234 | struct pktgen_thread *pg_thread;/* the owner */ | 235 | struct pktgen_thread *pg_thread;/* the owner */ |
235 | struct list_head list; /* Used for chaining in the thread's run-queue */ | 236 | struct list_head list; /* chaining in the thread's run-queue */ |
236 | 237 | ||
237 | int running; /* if this changes to false, the test will stop */ | 238 | int running; /* if false, the test will stop */ |
238 | 239 | ||
239 | /* If min != max, then we will either do a linear iteration, or | 240 | /* If min != max, then we will either do a linear iteration, or |
240 | * we will do a random selection from within the range. | 241 | * we will do a random selection from within the range. |
@@ -252,15 +253,16 @@ struct pktgen_dev { | |||
252 | __u64 count; /* Default No packets to send */ | 253 | __u64 count; /* Default No packets to send */ |
253 | __u64 sofar; /* How many pkts we've sent so far */ | 254 | __u64 sofar; /* How many pkts we've sent so far */ |
254 | __u64 tx_bytes; /* How many bytes we've transmitted */ | 255 | __u64 tx_bytes; /* How many bytes we've transmitted */ |
255 | __u64 errors; /* Errors when trying to transmit, pkts will be re-sent */ | 256 | __u64 errors; /* Errors when trying to transmit, |
257 | pkts will be re-sent */ | ||
256 | 258 | ||
257 | /* runtime counters relating to clone_skb */ | 259 | /* runtime counters relating to clone_skb */ |
258 | 260 | ||
259 | __u64 allocated_skbs; | 261 | __u64 allocated_skbs; |
260 | __u32 clone_count; | 262 | __u32 clone_count; |
261 | int last_ok; /* Was last skb sent? | 263 | int last_ok; /* Was last skb sent? |
262 | * Or a failed transmit of some sort? This will keep | 264 | * Or a failed transmit of some sort? |
263 | * sequence numbers in order, for example. | 265 | * This will keep sequence numbers in order |
264 | */ | 266 | */ |
265 | ktime_t next_tx; | 267 | ktime_t next_tx; |
266 | ktime_t started_at; | 268 | ktime_t started_at; |
@@ -269,11 +271,14 @@ struct pktgen_dev { | |||
269 | 271 | ||
270 | __u32 seq_num; | 272 | __u32 seq_num; |
271 | 273 | ||
272 | int clone_skb; /* Use multiple SKBs during packet gen. If this number | 274 | int clone_skb; /* |
273 | * is greater than 1, then that many copies of the same | 275 | * Use multiple SKBs during packet gen. |
274 | * packet will be sent before a new packet is allocated. | 276 | * If this number is greater than 1, then |
275 | * For instance, if you want to send 1024 identical packets | 277 | * that many copies of the same packet will be |
276 | * before creating a new packet, set clone_skb to 1024. | 278 | * sent before a new packet is allocated. |
279 | * If you want to send 1024 identical packets | ||
280 | * before creating a new packet, | ||
281 | * set clone_skb to 1024. | ||
277 | */ | 282 | */ |
278 | 283 | ||
279 | char dst_min[IP_NAME_SZ]; /* IP, ie 1.2.3.4 */ | 284 | char dst_min[IP_NAME_SZ]; /* IP, ie 1.2.3.4 */ |
@@ -305,8 +310,10 @@ struct pktgen_dev { | |||
305 | __u16 udp_dst_max; /* exclusive, dest UDP port */ | 310 | __u16 udp_dst_max; /* exclusive, dest UDP port */ |
306 | 311 | ||
307 | /* DSCP + ECN */ | 312 | /* DSCP + ECN */ |
308 | __u8 tos; /* six most significant bits of (former) IPv4 TOS are for dscp codepoint */ | 313 | __u8 tos; /* six MSB of (former) IPv4 TOS |
309 | __u8 traffic_class; /* ditto for the (former) Traffic Class in IPv6 (see RFC 3260, sec. 4) */ | 314 | are for dscp codepoint */ |
315 | __u8 traffic_class; /* ditto for the (former) Traffic Class in IPv6 | ||
316 | (see RFC 3260, sec. 4) */ | ||
310 | 317 | ||
311 | /* MPLS */ | 318 | /* MPLS */ |
312 | unsigned nr_labels; /* Depth of stack, 0 = no MPLS */ | 319 | unsigned nr_labels; /* Depth of stack, 0 = no MPLS */ |
@@ -347,15 +354,17 @@ struct pktgen_dev { | |||
347 | */ | 354 | */ |
348 | __u16 pad; /* pad out the hh struct to an even 16 bytes */ | 355 | __u16 pad; /* pad out the hh struct to an even 16 bytes */ |
349 | 356 | ||
350 | struct sk_buff *skb; /* skb we are to transmit next, mainly used for when we | 357 | struct sk_buff *skb; /* skb we are to transmit next, used for when we |
351 | * are transmitting the same one multiple times | 358 | * are transmitting the same one multiple times |
352 | */ | 359 | */ |
353 | struct net_device *odev; /* The out-going device. Note that the device should | 360 | struct net_device *odev; /* The out-going device. |
354 | * have it's pg_info pointer pointing back to this | 361 | * Note that the device should have it's |
355 | * device. This will be set when the user specifies | 362 | * pg_info pointer pointing back to this |
356 | * the out-going device name (not when the inject is | 363 | * device. |
357 | * started as it used to do.) | 364 | * Set when the user specifies the out-going |
358 | */ | 365 | * device name (not when the inject is |
366 | * started as it used to do.) | ||
367 | */ | ||
359 | struct flow_state *flows; | 368 | struct flow_state *flows; |
360 | unsigned cflows; /* Concurrent flows (config) */ | 369 | unsigned cflows; /* Concurrent flows (config) */ |
361 | unsigned lflow; /* Flow length (config) */ | 370 | unsigned lflow; /* Flow length (config) */ |
@@ -380,13 +389,14 @@ struct pktgen_hdr { | |||
380 | }; | 389 | }; |
381 | 390 | ||
382 | struct pktgen_thread { | 391 | struct pktgen_thread { |
383 | spinlock_t if_lock; | 392 | spinlock_t if_lock; /* for list of devices */ |
384 | struct list_head if_list; /* All device here */ | 393 | struct list_head if_list; /* All device here */ |
385 | struct list_head th_list; | 394 | struct list_head th_list; |
386 | struct task_struct *tsk; | 395 | struct task_struct *tsk; |
387 | char result[512]; | 396 | char result[512]; |
388 | 397 | ||
389 | /* Field for thread to receive "posted" events terminate, stop ifs etc. */ | 398 | /* Field for thread to receive "posted" events terminate, |
399 | stop ifs etc. */ | ||
390 | 400 | ||
391 | u32 control; | 401 | u32 control; |
392 | int cpu; | 402 | int cpu; |
@@ -453,8 +463,8 @@ static int pgctrl_show(struct seq_file *seq, void *v) | |||
453 | return 0; | 463 | return 0; |
454 | } | 464 | } |
455 | 465 | ||
456 | static ssize_t pgctrl_write(struct file *file, const char __user * buf, | 466 | static ssize_t pgctrl_write(struct file *file, const char __user *buf, |
457 | size_t count, loff_t * ppos) | 467 | size_t count, loff_t *ppos) |
458 | { | 468 | { |
459 | int err = 0; | 469 | int err = 0; |
460 | char data[128]; | 470 | char data[128]; |
@@ -545,11 +555,14 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
545 | " daddr: %s min_daddr: %s max_daddr: %s\n", b1, | 555 | " daddr: %s min_daddr: %s max_daddr: %s\n", b1, |
546 | b2, b3); | 556 | b2, b3); |
547 | 557 | ||
548 | } else | 558 | } else { |
559 | seq_printf(seq, | ||
560 | " dst_min: %s dst_max: %s\n", | ||
561 | pkt_dev->dst_min, pkt_dev->dst_max); | ||
549 | seq_printf(seq, | 562 | seq_printf(seq, |
550 | " dst_min: %s dst_max: %s\n src_min: %s src_max: %s\n", | 563 | " src_min: %s src_max: %s\n", |
551 | pkt_dev->dst_min, pkt_dev->dst_max, pkt_dev->src_min, | 564 | pkt_dev->src_min, pkt_dev->src_max); |
552 | pkt_dev->src_max); | 565 | } |
553 | 566 | ||
554 | seq_puts(seq, " src_mac: "); | 567 | seq_puts(seq, " src_mac: "); |
555 | 568 | ||
@@ -561,7 +574,8 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
561 | seq_printf(seq, "%pM\n", pkt_dev->dst_mac); | 574 | seq_printf(seq, "%pM\n", pkt_dev->dst_mac); |
562 | 575 | ||
563 | seq_printf(seq, | 576 | seq_printf(seq, |
564 | " udp_src_min: %d udp_src_max: %d udp_dst_min: %d udp_dst_max: %d\n", | 577 | " udp_src_min: %d udp_src_max: %d" |
578 | " udp_dst_min: %d udp_dst_max: %d\n", | ||
565 | pkt_dev->udp_src_min, pkt_dev->udp_src_max, | 579 | pkt_dev->udp_src_min, pkt_dev->udp_src_max, |
566 | pkt_dev->udp_dst_min, pkt_dev->udp_dst_max); | 580 | pkt_dev->udp_dst_min, pkt_dev->udp_dst_max); |
567 | 581 | ||
@@ -577,23 +591,21 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
577 | i == pkt_dev->nr_labels-1 ? "\n" : ", "); | 591 | i == pkt_dev->nr_labels-1 ? "\n" : ", "); |
578 | } | 592 | } |
579 | 593 | ||
580 | if (pkt_dev->vlan_id != 0xffff) { | 594 | if (pkt_dev->vlan_id != 0xffff) |
581 | seq_printf(seq, " vlan_id: %u vlan_p: %u vlan_cfi: %u\n", | 595 | seq_printf(seq, " vlan_id: %u vlan_p: %u vlan_cfi: %u\n", |
582 | pkt_dev->vlan_id, pkt_dev->vlan_p, pkt_dev->vlan_cfi); | 596 | pkt_dev->vlan_id, pkt_dev->vlan_p, |
583 | } | 597 | pkt_dev->vlan_cfi); |
584 | 598 | ||
585 | if (pkt_dev->svlan_id != 0xffff) { | 599 | if (pkt_dev->svlan_id != 0xffff) |
586 | seq_printf(seq, " svlan_id: %u vlan_p: %u vlan_cfi: %u\n", | 600 | seq_printf(seq, " svlan_id: %u vlan_p: %u vlan_cfi: %u\n", |
587 | pkt_dev->svlan_id, pkt_dev->svlan_p, pkt_dev->svlan_cfi); | 601 | pkt_dev->svlan_id, pkt_dev->svlan_p, |
588 | } | 602 | pkt_dev->svlan_cfi); |
589 | 603 | ||
590 | if (pkt_dev->tos) { | 604 | if (pkt_dev->tos) |
591 | seq_printf(seq, " tos: 0x%02x\n", pkt_dev->tos); | 605 | seq_printf(seq, " tos: 0x%02x\n", pkt_dev->tos); |
592 | } | ||
593 | 606 | ||
594 | if (pkt_dev->traffic_class) { | 607 | if (pkt_dev->traffic_class) |
595 | seq_printf(seq, " traffic_class: 0x%02x\n", pkt_dev->traffic_class); | 608 | seq_printf(seq, " traffic_class: 0x%02x\n", pkt_dev->traffic_class); |
596 | } | ||
597 | 609 | ||
598 | seq_printf(seq, " Flags: "); | 610 | seq_printf(seq, " Flags: "); |
599 | 611 | ||
@@ -696,7 +708,8 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
696 | } | 708 | } |
697 | 709 | ||
698 | 710 | ||
699 | static int hex32_arg(const char __user *user_buffer, unsigned long maxlen, __u32 *num) | 711 | static int hex32_arg(const char __user *user_buffer, unsigned long maxlen, |
712 | __u32 *num) | ||
700 | { | 713 | { |
701 | int i = 0; | 714 | int i = 0; |
702 | *num = 0; | 715 | *num = 0; |
@@ -846,9 +859,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
846 | /* Read variable name */ | 859 | /* Read variable name */ |
847 | 860 | ||
848 | len = strn_len(&user_buffer[i], sizeof(name) - 1); | 861 | len = strn_len(&user_buffer[i], sizeof(name) - 1); |
849 | if (len < 0) { | 862 | if (len < 0) |
850 | return len; | 863 | return len; |
851 | } | 864 | |
852 | memset(name, 0, sizeof(name)); | 865 | memset(name, 0, sizeof(name)); |
853 | if (copy_from_user(name, &user_buffer[i], len)) | 866 | if (copy_from_user(name, &user_buffer[i], len)) |
854 | return -EFAULT; | 867 | return -EFAULT; |
@@ -872,9 +885,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
872 | 885 | ||
873 | if (!strcmp(name, "min_pkt_size")) { | 886 | if (!strcmp(name, "min_pkt_size")) { |
874 | len = num_arg(&user_buffer[i], 10, &value); | 887 | len = num_arg(&user_buffer[i], 10, &value); |
875 | if (len < 0) { | 888 | if (len < 0) |
876 | return len; | 889 | return len; |
877 | } | 890 | |
878 | i += len; | 891 | i += len; |
879 | if (value < 14 + 20 + 8) | 892 | if (value < 14 + 20 + 8) |
880 | value = 14 + 20 + 8; | 893 | value = 14 + 20 + 8; |
@@ -889,9 +902,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
889 | 902 | ||
890 | if (!strcmp(name, "max_pkt_size")) { | 903 | if (!strcmp(name, "max_pkt_size")) { |
891 | len = num_arg(&user_buffer[i], 10, &value); | 904 | len = num_arg(&user_buffer[i], 10, &value); |
892 | if (len < 0) { | 905 | if (len < 0) |
893 | return len; | 906 | return len; |
894 | } | 907 | |
895 | i += len; | 908 | i += len; |
896 | if (value < 14 + 20 + 8) | 909 | if (value < 14 + 20 + 8) |
897 | value = 14 + 20 + 8; | 910 | value = 14 + 20 + 8; |
@@ -908,9 +921,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
908 | 921 | ||
909 | if (!strcmp(name, "pkt_size")) { | 922 | if (!strcmp(name, "pkt_size")) { |
910 | len = num_arg(&user_buffer[i], 10, &value); | 923 | len = num_arg(&user_buffer[i], 10, &value); |
911 | if (len < 0) { | 924 | if (len < 0) |
912 | return len; | 925 | return len; |
913 | } | 926 | |
914 | i += len; | 927 | i += len; |
915 | if (value < 14 + 20 + 8) | 928 | if (value < 14 + 20 + 8) |
916 | value = 14 + 20 + 8; | 929 | value = 14 + 20 + 8; |
@@ -925,9 +938,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
925 | 938 | ||
926 | if (!strcmp(name, "debug")) { | 939 | if (!strcmp(name, "debug")) { |
927 | len = num_arg(&user_buffer[i], 10, &value); | 940 | len = num_arg(&user_buffer[i], 10, &value); |
928 | if (len < 0) { | 941 | if (len < 0) |
929 | return len; | 942 | return len; |
930 | } | 943 | |
931 | i += len; | 944 | i += len; |
932 | debug = value; | 945 | debug = value; |
933 | sprintf(pg_result, "OK: debug=%u", debug); | 946 | sprintf(pg_result, "OK: debug=%u", debug); |
@@ -936,9 +949,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
936 | 949 | ||
937 | if (!strcmp(name, "frags")) { | 950 | if (!strcmp(name, "frags")) { |
938 | len = num_arg(&user_buffer[i], 10, &value); | 951 | len = num_arg(&user_buffer[i], 10, &value); |
939 | if (len < 0) { | 952 | if (len < 0) |
940 | return len; | 953 | return len; |
941 | } | 954 | |
942 | i += len; | 955 | i += len; |
943 | pkt_dev->nfrags = value; | 956 | pkt_dev->nfrags = value; |
944 | sprintf(pg_result, "OK: frags=%u", pkt_dev->nfrags); | 957 | sprintf(pg_result, "OK: frags=%u", pkt_dev->nfrags); |
@@ -946,9 +959,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
946 | } | 959 | } |
947 | if (!strcmp(name, "delay")) { | 960 | if (!strcmp(name, "delay")) { |
948 | len = num_arg(&user_buffer[i], 10, &value); | 961 | len = num_arg(&user_buffer[i], 10, &value); |
949 | if (len < 0) { | 962 | if (len < 0) |
950 | return len; | 963 | return len; |
951 | } | 964 | |
952 | i += len; | 965 | i += len; |
953 | if (value == 0x7FFFFFFF) | 966 | if (value == 0x7FFFFFFF) |
954 | pkt_dev->delay = ULLONG_MAX; | 967 | pkt_dev->delay = ULLONG_MAX; |
@@ -961,9 +974,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
961 | } | 974 | } |
962 | if (!strcmp(name, "udp_src_min")) { | 975 | if (!strcmp(name, "udp_src_min")) { |
963 | len = num_arg(&user_buffer[i], 10, &value); | 976 | len = num_arg(&user_buffer[i], 10, &value); |
964 | if (len < 0) { | 977 | if (len < 0) |
965 | return len; | 978 | return len; |
966 | } | 979 | |
967 | i += len; | 980 | i += len; |
968 | if (value != pkt_dev->udp_src_min) { | 981 | if (value != pkt_dev->udp_src_min) { |
969 | pkt_dev->udp_src_min = value; | 982 | pkt_dev->udp_src_min = value; |
@@ -974,9 +987,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
974 | } | 987 | } |
975 | if (!strcmp(name, "udp_dst_min")) { | 988 | if (!strcmp(name, "udp_dst_min")) { |
976 | len = num_arg(&user_buffer[i], 10, &value); | 989 | len = num_arg(&user_buffer[i], 10, &value); |
977 | if (len < 0) { | 990 | if (len < 0) |
978 | return len; | 991 | return len; |
979 | } | 992 | |
980 | i += len; | 993 | i += len; |
981 | if (value != pkt_dev->udp_dst_min) { | 994 | if (value != pkt_dev->udp_dst_min) { |
982 | pkt_dev->udp_dst_min = value; | 995 | pkt_dev->udp_dst_min = value; |
@@ -987,9 +1000,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
987 | } | 1000 | } |
988 | if (!strcmp(name, "udp_src_max")) { | 1001 | if (!strcmp(name, "udp_src_max")) { |
989 | len = num_arg(&user_buffer[i], 10, &value); | 1002 | len = num_arg(&user_buffer[i], 10, &value); |
990 | if (len < 0) { | 1003 | if (len < 0) |
991 | return len; | 1004 | return len; |
992 | } | 1005 | |
993 | i += len; | 1006 | i += len; |
994 | if (value != pkt_dev->udp_src_max) { | 1007 | if (value != pkt_dev->udp_src_max) { |
995 | pkt_dev->udp_src_max = value; | 1008 | pkt_dev->udp_src_max = value; |
@@ -1000,9 +1013,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1000 | } | 1013 | } |
1001 | if (!strcmp(name, "udp_dst_max")) { | 1014 | if (!strcmp(name, "udp_dst_max")) { |
1002 | len = num_arg(&user_buffer[i], 10, &value); | 1015 | len = num_arg(&user_buffer[i], 10, &value); |
1003 | if (len < 0) { | 1016 | if (len < 0) |
1004 | return len; | 1017 | return len; |
1005 | } | 1018 | |
1006 | i += len; | 1019 | i += len; |
1007 | if (value != pkt_dev->udp_dst_max) { | 1020 | if (value != pkt_dev->udp_dst_max) { |
1008 | pkt_dev->udp_dst_max = value; | 1021 | pkt_dev->udp_dst_max = value; |
@@ -1013,9 +1026,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1013 | } | 1026 | } |
1014 | if (!strcmp(name, "clone_skb")) { | 1027 | if (!strcmp(name, "clone_skb")) { |
1015 | len = num_arg(&user_buffer[i], 10, &value); | 1028 | len = num_arg(&user_buffer[i], 10, &value); |
1016 | if (len < 0) { | 1029 | if (len < 0) |
1017 | return len; | 1030 | return len; |
1018 | } | 1031 | |
1019 | i += len; | 1032 | i += len; |
1020 | pkt_dev->clone_skb = value; | 1033 | pkt_dev->clone_skb = value; |
1021 | 1034 | ||
@@ -1024,9 +1037,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1024 | } | 1037 | } |
1025 | if (!strcmp(name, "count")) { | 1038 | if (!strcmp(name, "count")) { |
1026 | len = num_arg(&user_buffer[i], 10, &value); | 1039 | len = num_arg(&user_buffer[i], 10, &value); |
1027 | if (len < 0) { | 1040 | if (len < 0) |
1028 | return len; | 1041 | return len; |
1029 | } | 1042 | |
1030 | i += len; | 1043 | i += len; |
1031 | pkt_dev->count = value; | 1044 | pkt_dev->count = value; |
1032 | sprintf(pg_result, "OK: count=%llu", | 1045 | sprintf(pg_result, "OK: count=%llu", |
@@ -1035,9 +1048,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1035 | } | 1048 | } |
1036 | if (!strcmp(name, "src_mac_count")) { | 1049 | if (!strcmp(name, "src_mac_count")) { |
1037 | len = num_arg(&user_buffer[i], 10, &value); | 1050 | len = num_arg(&user_buffer[i], 10, &value); |
1038 | if (len < 0) { | 1051 | if (len < 0) |
1039 | return len; | 1052 | return len; |
1040 | } | 1053 | |
1041 | i += len; | 1054 | i += len; |
1042 | if (pkt_dev->src_mac_count != value) { | 1055 | if (pkt_dev->src_mac_count != value) { |
1043 | pkt_dev->src_mac_count = value; | 1056 | pkt_dev->src_mac_count = value; |
@@ -1049,9 +1062,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1049 | } | 1062 | } |
1050 | if (!strcmp(name, "dst_mac_count")) { | 1063 | if (!strcmp(name, "dst_mac_count")) { |
1051 | len = num_arg(&user_buffer[i], 10, &value); | 1064 | len = num_arg(&user_buffer[i], 10, &value); |
1052 | if (len < 0) { | 1065 | if (len < 0) |
1053 | return len; | 1066 | return len; |
1054 | } | 1067 | |
1055 | i += len; | 1068 | i += len; |
1056 | if (pkt_dev->dst_mac_count != value) { | 1069 | if (pkt_dev->dst_mac_count != value) { |
1057 | pkt_dev->dst_mac_count = value; | 1070 | pkt_dev->dst_mac_count = value; |
@@ -1065,9 +1078,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1065 | char f[32]; | 1078 | char f[32]; |
1066 | memset(f, 0, 32); | 1079 | memset(f, 0, 32); |
1067 | len = strn_len(&user_buffer[i], sizeof(f) - 1); | 1080 | len = strn_len(&user_buffer[i], sizeof(f) - 1); |
1068 | if (len < 0) { | 1081 | if (len < 0) |
1069 | return len; | 1082 | return len; |
1070 | } | 1083 | |
1071 | if (copy_from_user(f, &user_buffer[i], len)) | 1084 | if (copy_from_user(f, &user_buffer[i], len)) |
1072 | return -EFAULT; | 1085 | return -EFAULT; |
1073 | i += len; | 1086 | i += len; |
@@ -1166,9 +1179,8 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1166 | } | 1179 | } |
1167 | if (!strcmp(name, "dst_min") || !strcmp(name, "dst")) { | 1180 | if (!strcmp(name, "dst_min") || !strcmp(name, "dst")) { |
1168 | len = strn_len(&user_buffer[i], sizeof(pkt_dev->dst_min) - 1); | 1181 | len = strn_len(&user_buffer[i], sizeof(pkt_dev->dst_min) - 1); |
1169 | if (len < 0) { | 1182 | if (len < 0) |
1170 | return len; | 1183 | return len; |
1171 | } | ||
1172 | 1184 | ||
1173 | if (copy_from_user(buf, &user_buffer[i], len)) | 1185 | if (copy_from_user(buf, &user_buffer[i], len)) |
1174 | return -EFAULT; | 1186 | return -EFAULT; |
@@ -1188,9 +1200,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1188 | } | 1200 | } |
1189 | if (!strcmp(name, "dst_max")) { | 1201 | if (!strcmp(name, "dst_max")) { |
1190 | len = strn_len(&user_buffer[i], sizeof(pkt_dev->dst_max) - 1); | 1202 | len = strn_len(&user_buffer[i], sizeof(pkt_dev->dst_max) - 1); |
1191 | if (len < 0) { | 1203 | if (len < 0) |
1192 | return len; | 1204 | return len; |
1193 | } | 1205 | |
1194 | 1206 | ||
1195 | if (copy_from_user(buf, &user_buffer[i], len)) | 1207 | if (copy_from_user(buf, &user_buffer[i], len)) |
1196 | return -EFAULT; | 1208 | return -EFAULT; |
@@ -1301,9 +1313,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1301 | } | 1313 | } |
1302 | if (!strcmp(name, "src_min")) { | 1314 | if (!strcmp(name, "src_min")) { |
1303 | len = strn_len(&user_buffer[i], sizeof(pkt_dev->src_min) - 1); | 1315 | len = strn_len(&user_buffer[i], sizeof(pkt_dev->src_min) - 1); |
1304 | if (len < 0) { | 1316 | if (len < 0) |
1305 | return len; | 1317 | return len; |
1306 | } | 1318 | |
1307 | if (copy_from_user(buf, &user_buffer[i], len)) | 1319 | if (copy_from_user(buf, &user_buffer[i], len)) |
1308 | return -EFAULT; | 1320 | return -EFAULT; |
1309 | buf[len] = 0; | 1321 | buf[len] = 0; |
@@ -1322,9 +1334,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1322 | } | 1334 | } |
1323 | if (!strcmp(name, "src_max")) { | 1335 | if (!strcmp(name, "src_max")) { |
1324 | len = strn_len(&user_buffer[i], sizeof(pkt_dev->src_max) - 1); | 1336 | len = strn_len(&user_buffer[i], sizeof(pkt_dev->src_max) - 1); |
1325 | if (len < 0) { | 1337 | if (len < 0) |
1326 | return len; | 1338 | return len; |
1327 | } | 1339 | |
1328 | if (copy_from_user(buf, &user_buffer[i], len)) | 1340 | if (copy_from_user(buf, &user_buffer[i], len)) |
1329 | return -EFAULT; | 1341 | return -EFAULT; |
1330 | buf[len] = 0; | 1342 | buf[len] = 0; |
@@ -1348,9 +1360,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1348 | memcpy(old_dmac, pkt_dev->dst_mac, ETH_ALEN); | 1360 | memcpy(old_dmac, pkt_dev->dst_mac, ETH_ALEN); |
1349 | 1361 | ||
1350 | len = strn_len(&user_buffer[i], sizeof(valstr) - 1); | 1362 | len = strn_len(&user_buffer[i], sizeof(valstr) - 1); |
1351 | if (len < 0) { | 1363 | if (len < 0) |
1352 | return len; | 1364 | return len; |
1353 | } | 1365 | |
1354 | memset(valstr, 0, sizeof(valstr)); | 1366 | memset(valstr, 0, sizeof(valstr)); |
1355 | if (copy_from_user(valstr, &user_buffer[i], len)) | 1367 | if (copy_from_user(valstr, &user_buffer[i], len)) |
1356 | return -EFAULT; | 1368 | return -EFAULT; |
@@ -1390,9 +1402,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1390 | memcpy(old_smac, pkt_dev->src_mac, ETH_ALEN); | 1402 | memcpy(old_smac, pkt_dev->src_mac, ETH_ALEN); |
1391 | 1403 | ||
1392 | len = strn_len(&user_buffer[i], sizeof(valstr) - 1); | 1404 | len = strn_len(&user_buffer[i], sizeof(valstr) - 1); |
1393 | if (len < 0) { | 1405 | if (len < 0) |
1394 | return len; | 1406 | return len; |
1395 | } | 1407 | |
1396 | memset(valstr, 0, sizeof(valstr)); | 1408 | memset(valstr, 0, sizeof(valstr)); |
1397 | if (copy_from_user(valstr, &user_buffer[i], len)) | 1409 | if (copy_from_user(valstr, &user_buffer[i], len)) |
1398 | return -EFAULT; | 1410 | return -EFAULT; |
@@ -1433,9 +1445,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1433 | 1445 | ||
1434 | if (!strcmp(name, "flows")) { | 1446 | if (!strcmp(name, "flows")) { |
1435 | len = num_arg(&user_buffer[i], 10, &value); | 1447 | len = num_arg(&user_buffer[i], 10, &value); |
1436 | if (len < 0) { | 1448 | if (len < 0) |
1437 | return len; | 1449 | return len; |
1438 | } | 1450 | |
1439 | i += len; | 1451 | i += len; |
1440 | if (value > MAX_CFLOWS) | 1452 | if (value > MAX_CFLOWS) |
1441 | value = MAX_CFLOWS; | 1453 | value = MAX_CFLOWS; |
@@ -1447,9 +1459,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1447 | 1459 | ||
1448 | if (!strcmp(name, "flowlen")) { | 1460 | if (!strcmp(name, "flowlen")) { |
1449 | len = num_arg(&user_buffer[i], 10, &value); | 1461 | len = num_arg(&user_buffer[i], 10, &value); |
1450 | if (len < 0) { | 1462 | if (len < 0) |
1451 | return len; | 1463 | return len; |
1452 | } | 1464 | |
1453 | i += len; | 1465 | i += len; |
1454 | pkt_dev->lflow = value; | 1466 | pkt_dev->lflow = value; |
1455 | sprintf(pg_result, "OK: flowlen=%u", pkt_dev->lflow); | 1467 | sprintf(pg_result, "OK: flowlen=%u", pkt_dev->lflow); |
@@ -1458,9 +1470,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1458 | 1470 | ||
1459 | if (!strcmp(name, "queue_map_min")) { | 1471 | if (!strcmp(name, "queue_map_min")) { |
1460 | len = num_arg(&user_buffer[i], 5, &value); | 1472 | len = num_arg(&user_buffer[i], 5, &value); |
1461 | if (len < 0) { | 1473 | if (len < 0) |
1462 | return len; | 1474 | return len; |
1463 | } | 1475 | |
1464 | i += len; | 1476 | i += len; |
1465 | pkt_dev->queue_map_min = value; | 1477 | pkt_dev->queue_map_min = value; |
1466 | sprintf(pg_result, "OK: queue_map_min=%u", pkt_dev->queue_map_min); | 1478 | sprintf(pg_result, "OK: queue_map_min=%u", pkt_dev->queue_map_min); |
@@ -1469,9 +1481,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1469 | 1481 | ||
1470 | if (!strcmp(name, "queue_map_max")) { | 1482 | if (!strcmp(name, "queue_map_max")) { |
1471 | len = num_arg(&user_buffer[i], 5, &value); | 1483 | len = num_arg(&user_buffer[i], 5, &value); |
1472 | if (len < 0) { | 1484 | if (len < 0) |
1473 | return len; | 1485 | return len; |
1474 | } | 1486 | |
1475 | i += len; | 1487 | i += len; |
1476 | pkt_dev->queue_map_max = value; | 1488 | pkt_dev->queue_map_max = value; |
1477 | sprintf(pg_result, "OK: queue_map_max=%u", pkt_dev->queue_map_max); | 1489 | sprintf(pg_result, "OK: queue_map_max=%u", pkt_dev->queue_map_max); |
@@ -1503,9 +1515,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1503 | 1515 | ||
1504 | if (!strcmp(name, "vlan_id")) { | 1516 | if (!strcmp(name, "vlan_id")) { |
1505 | len = num_arg(&user_buffer[i], 4, &value); | 1517 | len = num_arg(&user_buffer[i], 4, &value); |
1506 | if (len < 0) { | 1518 | if (len < 0) |
1507 | return len; | 1519 | return len; |
1508 | } | 1520 | |
1509 | i += len; | 1521 | i += len; |
1510 | if (value <= 4095) { | 1522 | if (value <= 4095) { |
1511 | pkt_dev->vlan_id = value; /* turn on VLAN */ | 1523 | pkt_dev->vlan_id = value; /* turn on VLAN */ |
@@ -1530,9 +1542,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1530 | 1542 | ||
1531 | if (!strcmp(name, "vlan_p")) { | 1543 | if (!strcmp(name, "vlan_p")) { |
1532 | len = num_arg(&user_buffer[i], 1, &value); | 1544 | len = num_arg(&user_buffer[i], 1, &value); |
1533 | if (len < 0) { | 1545 | if (len < 0) |
1534 | return len; | 1546 | return len; |
1535 | } | 1547 | |
1536 | i += len; | 1548 | i += len; |
1537 | if ((value <= 7) && (pkt_dev->vlan_id != 0xffff)) { | 1549 | if ((value <= 7) && (pkt_dev->vlan_id != 0xffff)) { |
1538 | pkt_dev->vlan_p = value; | 1550 | pkt_dev->vlan_p = value; |
@@ -1545,9 +1557,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1545 | 1557 | ||
1546 | if (!strcmp(name, "vlan_cfi")) { | 1558 | if (!strcmp(name, "vlan_cfi")) { |
1547 | len = num_arg(&user_buffer[i], 1, &value); | 1559 | len = num_arg(&user_buffer[i], 1, &value); |
1548 | if (len < 0) { | 1560 | if (len < 0) |
1549 | return len; | 1561 | return len; |
1550 | } | 1562 | |
1551 | i += len; | 1563 | i += len; |
1552 | if ((value <= 1) && (pkt_dev->vlan_id != 0xffff)) { | 1564 | if ((value <= 1) && (pkt_dev->vlan_id != 0xffff)) { |
1553 | pkt_dev->vlan_cfi = value; | 1565 | pkt_dev->vlan_cfi = value; |
@@ -1560,9 +1572,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1560 | 1572 | ||
1561 | if (!strcmp(name, "svlan_id")) { | 1573 | if (!strcmp(name, "svlan_id")) { |
1562 | len = num_arg(&user_buffer[i], 4, &value); | 1574 | len = num_arg(&user_buffer[i], 4, &value); |
1563 | if (len < 0) { | 1575 | if (len < 0) |
1564 | return len; | 1576 | return len; |
1565 | } | 1577 | |
1566 | i += len; | 1578 | i += len; |
1567 | if ((value <= 4095) && ((pkt_dev->vlan_id != 0xffff))) { | 1579 | if ((value <= 4095) && ((pkt_dev->vlan_id != 0xffff))) { |
1568 | pkt_dev->svlan_id = value; /* turn on SVLAN */ | 1580 | pkt_dev->svlan_id = value; /* turn on SVLAN */ |
@@ -1587,9 +1599,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1587 | 1599 | ||
1588 | if (!strcmp(name, "svlan_p")) { | 1600 | if (!strcmp(name, "svlan_p")) { |
1589 | len = num_arg(&user_buffer[i], 1, &value); | 1601 | len = num_arg(&user_buffer[i], 1, &value); |
1590 | if (len < 0) { | 1602 | if (len < 0) |
1591 | return len; | 1603 | return len; |
1592 | } | 1604 | |
1593 | i += len; | 1605 | i += len; |
1594 | if ((value <= 7) && (pkt_dev->svlan_id != 0xffff)) { | 1606 | if ((value <= 7) && (pkt_dev->svlan_id != 0xffff)) { |
1595 | pkt_dev->svlan_p = value; | 1607 | pkt_dev->svlan_p = value; |
@@ -1602,9 +1614,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1602 | 1614 | ||
1603 | if (!strcmp(name, "svlan_cfi")) { | 1615 | if (!strcmp(name, "svlan_cfi")) { |
1604 | len = num_arg(&user_buffer[i], 1, &value); | 1616 | len = num_arg(&user_buffer[i], 1, &value); |
1605 | if (len < 0) { | 1617 | if (len < 0) |
1606 | return len; | 1618 | return len; |
1607 | } | 1619 | |
1608 | i += len; | 1620 | i += len; |
1609 | if ((value <= 1) && (pkt_dev->svlan_id != 0xffff)) { | 1621 | if ((value <= 1) && (pkt_dev->svlan_id != 0xffff)) { |
1610 | pkt_dev->svlan_cfi = value; | 1622 | pkt_dev->svlan_cfi = value; |
@@ -1618,9 +1630,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1618 | if (!strcmp(name, "tos")) { | 1630 | if (!strcmp(name, "tos")) { |
1619 | __u32 tmp_value = 0; | 1631 | __u32 tmp_value = 0; |
1620 | len = hex32_arg(&user_buffer[i], 2, &tmp_value); | 1632 | len = hex32_arg(&user_buffer[i], 2, &tmp_value); |
1621 | if (len < 0) { | 1633 | if (len < 0) |
1622 | return len; | 1634 | return len; |
1623 | } | 1635 | |
1624 | i += len; | 1636 | i += len; |
1625 | if (len == 2) { | 1637 | if (len == 2) { |
1626 | pkt_dev->tos = tmp_value; | 1638 | pkt_dev->tos = tmp_value; |
@@ -1634,9 +1646,9 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1634 | if (!strcmp(name, "traffic_class")) { | 1646 | if (!strcmp(name, "traffic_class")) { |
1635 | __u32 tmp_value = 0; | 1647 | __u32 tmp_value = 0; |
1636 | len = hex32_arg(&user_buffer[i], 2, &tmp_value); | 1648 | len = hex32_arg(&user_buffer[i], 2, &tmp_value); |
1637 | if (len < 0) { | 1649 | if (len < 0) |
1638 | return len; | 1650 | return len; |
1639 | } | 1651 | |
1640 | i += len; | 1652 | i += len; |
1641 | if (len == 2) { | 1653 | if (len == 2) { |
1642 | pkt_dev->traffic_class = tmp_value; | 1654 | pkt_dev->traffic_class = tmp_value; |
@@ -1906,13 +1918,14 @@ static int pktgen_device_event(struct notifier_block *unused, | |||
1906 | return NOTIFY_DONE; | 1918 | return NOTIFY_DONE; |
1907 | } | 1919 | } |
1908 | 1920 | ||
1909 | static struct net_device *pktgen_dev_get_by_name(struct pktgen_dev *pkt_dev, const char *ifname) | 1921 | static struct net_device *pktgen_dev_get_by_name(struct pktgen_dev *pkt_dev, |
1922 | const char *ifname) | ||
1910 | { | 1923 | { |
1911 | char b[IFNAMSIZ+5]; | 1924 | char b[IFNAMSIZ+5]; |
1912 | int i = 0; | 1925 | int i = 0; |
1913 | 1926 | ||
1914 | for(i=0; ifname[i] != '@'; i++) { | 1927 | for (i = 0; ifname[i] != '@'; i++) { |
1915 | if(i == IFNAMSIZ) | 1928 | if (i == IFNAMSIZ) |
1916 | break; | 1929 | break; |
1917 | 1930 | ||
1918 | b[i] = ifname[i]; | 1931 | b[i] = ifname[i]; |
@@ -1979,7 +1992,7 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev) | |||
1979 | printk(KERN_WARNING "pktgen: WARNING: Requested " | 1992 | printk(KERN_WARNING "pktgen: WARNING: Requested " |
1980 | "queue_map_min (zero-based) (%d) exceeds valid range " | 1993 | "queue_map_min (zero-based) (%d) exceeds valid range " |
1981 | "[0 - %d] for (%d) queues on %s, resetting\n", | 1994 | "[0 - %d] for (%d) queues on %s, resetting\n", |
1982 | pkt_dev->queue_map_min, (ntxq ?: 1)- 1, ntxq, | 1995 | pkt_dev->queue_map_min, (ntxq ?: 1) - 1, ntxq, |
1983 | pkt_dev->odev->name); | 1996 | pkt_dev->odev->name); |
1984 | pkt_dev->queue_map_min = ntxq - 1; | 1997 | pkt_dev->queue_map_min = ntxq - 1; |
1985 | } | 1998 | } |
@@ -1987,7 +2000,7 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev) | |||
1987 | printk(KERN_WARNING "pktgen: WARNING: Requested " | 2000 | printk(KERN_WARNING "pktgen: WARNING: Requested " |
1988 | "queue_map_max (zero-based) (%d) exceeds valid range " | 2001 | "queue_map_max (zero-based) (%d) exceeds valid range " |
1989 | "[0 - %d] for (%d) queues on %s, resetting\n", | 2002 | "[0 - %d] for (%d) queues on %s, resetting\n", |
1990 | pkt_dev->queue_map_max, (ntxq ?: 1)- 1, ntxq, | 2003 | pkt_dev->queue_map_max, (ntxq ?: 1) - 1, ntxq, |
1991 | pkt_dev->odev->name); | 2004 | pkt_dev->odev->name); |
1992 | pkt_dev->queue_map_max = ntxq - 1; | 2005 | pkt_dev->queue_map_max = ntxq - 1; |
1993 | } | 2006 | } |
@@ -2028,7 +2041,8 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev) | |||
2028 | */ | 2041 | */ |
2029 | 2042 | ||
2030 | rcu_read_lock(); | 2043 | rcu_read_lock(); |
2031 | if ((idev = __in6_dev_get(pkt_dev->odev)) != NULL) { | 2044 | idev = __in6_dev_get(pkt_dev->odev); |
2045 | if (idev) { | ||
2032 | struct inet6_ifaddr *ifp; | 2046 | struct inet6_ifaddr *ifp; |
2033 | 2047 | ||
2034 | read_lock_bh(&idev->lock); | 2048 | read_lock_bh(&idev->lock); |
@@ -2181,7 +2195,7 @@ static void get_ipsec_sa(struct pktgen_dev *pkt_dev, int flow) | |||
2181 | if (x) { | 2195 | if (x) { |
2182 | pkt_dev->flows[flow].x = x; | 2196 | pkt_dev->flows[flow].x = x; |
2183 | set_pkt_overhead(pkt_dev); | 2197 | set_pkt_overhead(pkt_dev); |
2184 | pkt_dev->pkt_overhead+=x->props.header_len; | 2198 | pkt_dev->pkt_overhead += x->props.header_len; |
2185 | } | 2199 | } |
2186 | 2200 | ||
2187 | } | 2201 | } |
@@ -2320,18 +2334,18 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2320 | 2334 | ||
2321 | if (!(pkt_dev->flags & F_IPV6)) { | 2335 | if (!(pkt_dev->flags & F_IPV6)) { |
2322 | 2336 | ||
2323 | if ((imn = ntohl(pkt_dev->saddr_min)) < (imx = | 2337 | imn = ntohl(pkt_dev->saddr_min); |
2324 | ntohl(pkt_dev-> | 2338 | imx = ntohl(pkt_dev->saddr_max); |
2325 | saddr_max))) { | 2339 | if (imn < imx) { |
2326 | __u32 t; | 2340 | __u32 t; |
2327 | if (pkt_dev->flags & F_IPSRC_RND) | 2341 | if (pkt_dev->flags & F_IPSRC_RND) |
2328 | t = random32() % (imx - imn) + imn; | 2342 | t = random32() % (imx - imn) + imn; |
2329 | else { | 2343 | else { |
2330 | t = ntohl(pkt_dev->cur_saddr); | 2344 | t = ntohl(pkt_dev->cur_saddr); |
2331 | t++; | 2345 | t++; |
2332 | if (t > imx) { | 2346 | if (t > imx) |
2333 | t = imn; | 2347 | t = imn; |
2334 | } | 2348 | |
2335 | } | 2349 | } |
2336 | pkt_dev->cur_saddr = htonl(t); | 2350 | pkt_dev->cur_saddr = htonl(t); |
2337 | } | 2351 | } |
@@ -2442,7 +2456,7 @@ static int pktgen_output_ipsec(struct sk_buff *skb, struct pktgen_dev *pkt_dev) | |||
2442 | if (err) | 2456 | if (err) |
2443 | goto error; | 2457 | goto error; |
2444 | 2458 | ||
2445 | x->curlft.bytes +=skb->len; | 2459 | x->curlft.bytes += skb->len; |
2446 | x->curlft.packets++; | 2460 | x->curlft.packets++; |
2447 | error: | 2461 | error: |
2448 | spin_unlock(&x->lock); | 2462 | spin_unlock(&x->lock); |
@@ -2474,11 +2488,11 @@ static int process_ipsec(struct pktgen_dev *pkt_dev, | |||
2474 | int ret; | 2488 | int ret; |
2475 | __u8 *eth; | 2489 | __u8 *eth; |
2476 | nhead = x->props.header_len - skb_headroom(skb); | 2490 | nhead = x->props.header_len - skb_headroom(skb); |
2477 | if (nhead >0) { | 2491 | if (nhead > 0) { |
2478 | ret = pskb_expand_head(skb, nhead, 0, GFP_ATOMIC); | 2492 | ret = pskb_expand_head(skb, nhead, 0, GFP_ATOMIC); |
2479 | if (ret < 0) { | 2493 | if (ret < 0) { |
2480 | printk(KERN_ERR "Error expanding " | 2494 | printk(KERN_ERR "Error expanding " |
2481 | "ipsec packet %d\n",ret); | 2495 | "ipsec packet %d\n", ret); |
2482 | goto err; | 2496 | goto err; |
2483 | } | 2497 | } |
2484 | } | 2498 | } |
@@ -2488,13 +2502,13 @@ static int process_ipsec(struct pktgen_dev *pkt_dev, | |||
2488 | ret = pktgen_output_ipsec(skb, pkt_dev); | 2502 | ret = pktgen_output_ipsec(skb, pkt_dev); |
2489 | if (ret) { | 2503 | if (ret) { |
2490 | printk(KERN_ERR "Error creating ipsec " | 2504 | printk(KERN_ERR "Error creating ipsec " |
2491 | "packet %d\n",ret); | 2505 | "packet %d\n", ret); |
2492 | goto err; | 2506 | goto err; |
2493 | } | 2507 | } |
2494 | /* restore ll */ | 2508 | /* restore ll */ |
2495 | eth = (__u8 *) skb_push(skb, ETH_HLEN); | 2509 | eth = (__u8 *) skb_push(skb, ETH_HLEN); |
2496 | memcpy(eth, pkt_dev->hh, 12); | 2510 | memcpy(eth, pkt_dev->hh, 12); |
2497 | *(u16 *) & eth[12] = protocol; | 2511 | *(u16 *) ð[12] = protocol; |
2498 | } | 2512 | } |
2499 | } | 2513 | } |
2500 | return 1; | 2514 | return 1; |
@@ -2507,9 +2521,9 @@ err: | |||
2507 | static void mpls_push(__be32 *mpls, struct pktgen_dev *pkt_dev) | 2521 | static void mpls_push(__be32 *mpls, struct pktgen_dev *pkt_dev) |
2508 | { | 2522 | { |
2509 | unsigned i; | 2523 | unsigned i; |
2510 | for (i = 0; i < pkt_dev->nr_labels; i++) { | 2524 | for (i = 0; i < pkt_dev->nr_labels; i++) |
2511 | *mpls++ = pkt_dev->labels[i] & ~MPLS_STACK_BOTTOM; | 2525 | *mpls++ = pkt_dev->labels[i] & ~MPLS_STACK_BOTTOM; |
2512 | } | 2526 | |
2513 | mpls--; | 2527 | mpls--; |
2514 | *mpls |= MPLS_STACK_BOTTOM; | 2528 | *mpls |= MPLS_STACK_BOTTOM; |
2515 | } | 2529 | } |
@@ -2676,8 +2690,9 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, | |||
2676 | } | 2690 | } |
2677 | } | 2691 | } |
2678 | 2692 | ||
2679 | /* Stamp the time, and sequence number, convert them to network byte order */ | 2693 | /* Stamp the time, and sequence number, |
2680 | 2694 | * convert them to network byte order | |
2695 | */ | ||
2681 | if (pgh) { | 2696 | if (pgh) { |
2682 | struct timeval timestamp; | 2697 | struct timeval timestamp; |
2683 | 2698 | ||
@@ -2931,7 +2946,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, | |||
2931 | udph = udp_hdr(skb); | 2946 | udph = udp_hdr(skb); |
2932 | 2947 | ||
2933 | memcpy(eth, pkt_dev->hh, 12); | 2948 | memcpy(eth, pkt_dev->hh, 12); |
2934 | *(__be16 *) & eth[12] = protocol; | 2949 | *(__be16 *) ð[12] = protocol; |
2935 | 2950 | ||
2936 | /* Eth + IPh + UDPh + mpls */ | 2951 | /* Eth + IPh + UDPh + mpls */ |
2937 | datalen = pkt_dev->cur_pkt_size - 14 - | 2952 | datalen = pkt_dev->cur_pkt_size - 14 - |
@@ -3025,8 +3040,10 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, | |||
3025 | } | 3040 | } |
3026 | } | 3041 | } |
3027 | 3042 | ||
3028 | /* Stamp the time, and sequence number, convert them to network byte order */ | 3043 | /* Stamp the time, and sequence number, |
3029 | /* should we update cloned packets too ? */ | 3044 | * convert them to network byte order |
3045 | * should we update cloned packets too ? | ||
3046 | */ | ||
3030 | if (pgh) { | 3047 | if (pgh) { |
3031 | struct timeval timestamp; | 3048 | struct timeval timestamp; |
3032 | 3049 | ||
@@ -3174,7 +3191,8 @@ static void pktgen_run_all_threads(void) | |||
3174 | 3191 | ||
3175 | mutex_unlock(&pktgen_thread_lock); | 3192 | mutex_unlock(&pktgen_thread_lock); |
3176 | 3193 | ||
3177 | schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ | 3194 | /* Propagate thread->control */ |
3195 | schedule_timeout_interruptible(msecs_to_jiffies(125)); | ||
3178 | 3196 | ||
3179 | pktgen_wait_all_threads_run(); | 3197 | pktgen_wait_all_threads_run(); |
3180 | } | 3198 | } |
@@ -3192,7 +3210,8 @@ static void pktgen_reset_all_threads(void) | |||
3192 | 3210 | ||
3193 | mutex_unlock(&pktgen_thread_lock); | 3211 | mutex_unlock(&pktgen_thread_lock); |
3194 | 3212 | ||
3195 | schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ | 3213 | /* Propagate thread->control */ |
3214 | schedule_timeout_interruptible(msecs_to_jiffies(125)); | ||
3196 | 3215 | ||
3197 | pktgen_wait_all_threads_run(); | 3216 | pktgen_wait_all_threads_run(); |
3198 | } | 3217 | } |
@@ -3485,7 +3504,8 @@ static int pktgen_thread_worker(void *arg) | |||
3485 | init_waitqueue_head(&t->queue); | 3504 | init_waitqueue_head(&t->queue); |
3486 | complete(&t->start_done); | 3505 | complete(&t->start_done); |
3487 | 3506 | ||
3488 | pr_debug("pktgen: starting pktgen/%d: pid=%d\n", cpu, task_pid_nr(current)); | 3507 | pr_debug("pktgen: starting pktgen/%d: pid=%d\n", |
3508 | cpu, task_pid_nr(current)); | ||
3489 | 3509 | ||
3490 | set_current_state(TASK_INTERRUPTIBLE); | 3510 | set_current_state(TASK_INTERRUPTIBLE); |
3491 | 3511 | ||