* [PATCH net-next] pktgen: add ttl option for pktgen
@ 2014-07-30 8:21 Zhouyi Zhou
2014-07-30 10:51 ` Dmitry Popov
0 siblings, 1 reply; 3+ messages in thread
From: Zhouyi Zhou @ 2014-07-30 8:21 UTC (permalink / raw)
To: rdunlap, davem, minipli, brouer, steffen.klassert, fan.du,
dborkman, fengguang.wu, tgraf, linux-doc, linux-kernel, netdev
Cc: Zhouyi Zhou, Zhouyi Zhou
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
Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
---
Documentation/networking/pktgen.txt | 2 +-
net/core/pktgen.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/Documentation/networking/pktgen.txt b/Documentation/networking/pktgen.txt
index 0dffc6e..abad388 100644
--- a/Documentation/networking/pktgen.txt
+++ b/Documentation/networking/pktgen.txt
@@ -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)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8b849dd..54cb750 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -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;
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] pktgen: add ttl option for pktgen
2014-07-30 8:21 [PATCH net-next] pktgen: add ttl option for pktgen Zhouyi Zhou
@ 2014-07-30 10:51 ` Dmitry Popov
2014-07-30 12:49 ` Zhouyi Zhou
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Popov @ 2014-07-30 10:51 UTC (permalink / raw)
To: Zhouyi Zhou
Cc: rdunlap, davem, minipli, brouer, steffen.klassert, fan.du,
dborkman, fengguang.wu, tgraf, linux-doc, linux-kernel, netdev,
Zhouyi Zhou
On Wed, 30 Jul 2014 16:21:26 +0800
Zhouyi Zhou <zhouzhouyi@gmail.com> 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
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -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;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Re: [PATCH net-next] pktgen: add ttl option for pktgen
2014-07-30 10:51 ` Dmitry Popov
@ 2014-07-30 12:49 ` Zhouyi Zhou
0 siblings, 0 replies; 3+ messages in thread
From: Zhouyi Zhou @ 2014-07-30 12:49 UTC (permalink / raw)
To: Dmitry Popov
Cc: Zhouyi Zhou, rdunlap, davem, minipli, brouer, steffen.klassert,
fan.du, dborkman, fengguang.wu, tgraf, linux-doc, linux-kernel,
netdev
Thanks for reviewing.
I did miss it.
> -----Original Messages-----
> From: "Dmitry Popov" <ixaphire@qrator.net>
> Sent Time: Wednesday, July 30, 2014
> To: "Zhouyi Zhou" <zhouzhouyi@gmail.com>
> Cc: rdunlap@infradead.org, davem@davemloft.net, minipli@googlemail.com, brouer@redhat.com, steffen.klassert@secunet.com, fan.du@windriver.com, dborkman@redhat.com, fengguang.wu@intel.com, tgraf@suug.ch, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, "Zhouyi Zhou" <yizhouzhou@ict.ac.cn>
> Subject: Re: [PATCH net-next] pktgen: add ttl option for pktgen
>
> On Wed, 30 Jul 2014 16:21:26 +0800
> Zhouyi Zhou <zhouzhouyi@gmail.com> 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
>
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -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;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-30 12:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-30 8:21 [PATCH net-next] pktgen: add ttl option for pktgen Zhouyi Zhou
2014-07-30 10:51 ` Dmitry Popov
2014-07-30 12:49 ` Zhouyi Zhou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox