hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/samples/pktgen/pktgen_sample01_simple.sh
....@@ -22,13 +22,21 @@
2222 # Example enforce param "-m" for dst_mac
2323 [ -z "$DST_MAC" ] && usage && err 2 "Must specify -m dst_mac"
2424 [ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely
25
+if [ -n "$DEST_IP" ]; then
26
+ validate_addr${IP6} $DEST_IP
27
+ read -r DST_MIN DST_MAX <<< $(parse_addr${IP6} $DEST_IP)
28
+fi
29
+if [ -n "$DST_PORT" ]; then
30
+ read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
31
+ validate_ports $UDP_DST_MIN $UDP_DST_MAX
32
+fi
2533
2634 # Base Config
2735 DELAY="0" # Zero means max speed
2836
2937 # Flow variation random source port between min and max
30
-UDP_MIN=9
31
-UDP_MAX=109
38
+UDP_SRC_MIN=9
39
+UDP_SRC_MAX=109
3240
3341 # General cleanup everything since last run
3442 # (especially important if other threads were configured by other scripts)
....@@ -57,12 +65,20 @@
5765
5866 # Destination
5967 pg_set $DEV "dst_mac $DST_MAC"
60
-pg_set $DEV "dst$IP6 $DEST_IP"
68
+pg_set $DEV "dst${IP6}_min $DST_MIN"
69
+pg_set $DEV "dst${IP6}_max $DST_MAX"
70
+
71
+if [ -n "$DST_PORT" ]; then
72
+ # Single destination port or random port range
73
+ pg_set $DEV "flag UDPDST_RND"
74
+ pg_set $DEV "udp_dst_min $UDP_DST_MIN"
75
+ pg_set $DEV "udp_dst_max $UDP_DST_MAX"
76
+fi
6177
6278 # Setup random UDP port src range
6379 pg_set $DEV "flag UDPSRC_RND"
64
-pg_set $DEV "udp_src_min $UDP_MIN"
65
-pg_set $DEV "udp_src_max $UDP_MAX"
80
+pg_set $DEV "udp_src_min $UDP_SRC_MIN"
81
+pg_set $DEV "udp_src_max $UDP_SRC_MAX"
6682
6783 # start_run
6884 echo "Running... ctrl^C to stop" >&2