pktgen: add ttl option for pktgen
Subsystems (3)
PATCH 1/1 pktgen: add ttl option for pktgen
I think it is useful to add ttl option for pktgen, for example if a some ISP want to test its network quality, it could set ttl so that the tested links get the packet while end users won't get it.
Also, add a blank line after declarations in pktgen.c
--- Documentation/networking/pktgen.txt | 2 +- net/core/pktgen.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletions(-)
Documentation/networking/pktgen.txt +1 -1
@@ -180,7 +180,7 @@ Examples: pgset "vlan_id 9999" > 4095 remove vlan and svlan tags pgset "svlan 9999" > 4095 remove svlan tag - + pgset "ttl xx" set former IPv4 TTL field (default 32) pgset "tos XX" set former IPv4 TOS field (e.g. "tos 28" for AF11 no ECN, default 00) pgset "traffic_class XX" set former IPv6 TRAFFIC CLASS (e.g. "traffic_class B8" for EF no ECN, default 00)
net/core/pktgen.c +24 -0
@@ -318,6 +318,8 @@ struct pktgen_dev {__u16 udp_dst_min;/* inclusive, dest UDP port */ __u16 udp_dst_max;/* exclusive, dest UDP port */ +__u8 ttl;/* time to live */ +/* DSCP + ECN */ __u8 tos;/* six MSB of (former) IPv4 TOS are for dscp codepoint */
@@ -606,6 +608,8 @@ static int pktgen_if_show(struct seq_file *seq, void *v) pkt_dev->svlan_id, pkt_dev->svlan_p, pkt_dev->svlan_cfi); +seq_printf (seq," ttl: 0x%02x\n" , pkt_dev->ttl); +if (pkt_dev->tos)seq_printf (seq," tos: 0x%02x\n" , pkt_dev->tos);
@@ -1667,8 +1671,26 @@ static ssize_t pktgen_if_write(struct file *file,return count; } +if (!strcmp (name,"ttl" )) { +__u32 tmp_value =0 ; + + len =hex32_arg (&user_buffer[i],2 , &tmp_value); +if (len <0 ) +return len; + + i += len; +if (len ==2 ) { + pkt_dev->ttl = tmp_value; +sprintf (pg_result,"OK: ttl=0x%02x" , pkt_dev->ttl); + }else { +sprintf (pg_result,"ERROR: tos must be 00-ff" ); + } +return count; + } +if (!strcmp (name,"tos" )) {__u32 tmp_value =0 ; + len =hex32_arg (&user_buffer[i],2 , &tmp_value);if (len <0 )return len;
@@ -1685,6 +1707,7 @@ static ssize_t pktgen_if_write(struct file *file,if (!strcmp (name,"traffic_class" )) {__u32 tmp_value =0 ; + len =hex32_arg (&user_buffer[i],2 , &tmp_value);if (len <0 )return len;
@@ -3558,6 +3581,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname) pkt_dev->udp_src_max =9 ; pkt_dev->udp_dst_min =9 ; pkt_dev->udp_dst_max =9 ; + pkt_dev->ttl =32 ; pkt_dev->vlan_p =0 ; pkt_dev->vlan_cfi =0 ; pkt_dev->vlan_id =0xffff ;
Signature · 1 line
1.7.1
Quoted 4 lines · On Wed, 30 Jul 2014 16:21:26 +0800 Zhouyi Zhou <[email protected]> wrote:
I think it is useful to add ttl option for pktgen, for example if a some ISP want to test its network quality, it could set ttl so that the tested links get the packet while end users won't get it.
It seems you're missing
net/core/pktgen.c +1 -1
@@ -2799,7 +2799,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, iph->ihl =5 ; iph->version =4 ; - iph->ttl =32 ; + iph->ttl = pkt_dev->ttl; iph->tos = pkt_dev->tos; iph->protocol =IPPROTO_UDP ;/* UDP */ iph->saddr = pkt_dev->cur_saddr;
Thanks for reviewing.
I did miss it.
Quoted 28 lines
-----Original Messages-----
From: "Dmitry Popov" <[email protected]>
Sent Time: Wednesday, July 30, 2014
To: "Zhouyi Zhou" <[email protected]>
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], "Zhouyi Zhou" <[email protected]>
Subject: Re: [PATCH net-next] pktgen: add ttl option for pktgenQuoted 4 lines · On Wed, 30 Jul 2014 16:21:26 +0800 Zhouyi Zhou <[email protected]> wrote:
I think it is useful to add ttl option for pktgen, for example if a some ISP want to test its network quality, it could set ttl so that the tested links get the packet while end users won't get it.
It seems you're missing
net/core/pktgen.c +1
-1@@ -2799,7 +2799,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, iph->ihl =5 ; iph->version =4 ; - iph->ttl =32 ; + iph->ttl = pkt_dev->ttl; iph->tos = pkt_dev->tos; iph->protocol =IPPROTO_UDP ;/* UDP */ iph->saddr = pkt_dev->cur_saddr;