* [PATCH ethtool 1/2] ethtool: Use inet_aton() to parse IPv4 addresses for RX n-tuple control
@ 2010-07-22 19:11 Ben Hutchings
2010-07-22 19:12 ` [PATCH ethtool 2/2] ethtool: Remove specification of number bases for RX-ntuple parameters Ben Hutchings
2010-08-04 20:36 ` [PATCH ethtool 1/2] ethtool: Use inet_aton() to parse IPv4 addresses for RX n-tuple control Jeff Garzik
0 siblings, 2 replies; 4+ messages in thread
From: Ben Hutchings @ 2010-07-22 19:11 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
Note that inet_aton() allows the address to be specified as a single
32-bit number in the same formats as strtoull(), so this is backward-
compatible.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
ethtool.8 | 9 +++++----
ethtool.c | 25 +++++++++++++++----------
2 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/ethtool.8 b/ethtool.8
index b0b3c8d..d0cbc93 100644
--- a/ethtool.8
+++ b/ethtool.8
@@ -676,16 +676,17 @@ Configure Rx ntuple filters and actions
.RE
.TP
.BI src-ip \ addr
-Includes the source IP address, specified in hex.
+Includes the source IP address, specified using dotted-quad notation
+or as a single 32-bit number.
.TP
.BI src-ip-mask \ mask
-Specify a mask for the source IP address, specified in hex.
+Specify a mask for the source IP address.
.TP
.BI dst-ip \ addr
-Includes the destination IP address, specified in hex.
+Includes the destination IP address.
.TP
.BI dst-ip-mask \ mask
-Specify a mask for the destination IP address, specified in hex.
+Specify a mask for the destination IP address.
.TP
.BI src-port \ port
Includes the source port, specified in decimal.
diff --git a/ethtool.c b/ethtool.c
index 4ab1a41..eef76f9 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -40,6 +40,10 @@
#include <limits.h>
#include <ctype.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
#include <linux/sockios.h>
#include "ethtool-util.h"
@@ -404,7 +408,7 @@ typedef enum {
CMDL_U32,
CMDL_U64,
CMDL_BE16,
- CMDL_BE32,
+ CMDL_IP4,
CMDL_STR,
CMDL_FLAG,
} cmdline_type_t;
@@ -412,7 +416,7 @@ typedef enum {
struct cmdline_info {
const char *name;
cmdline_type_t type;
- /* Points to int (BOOL), s32, u16, u32 (U32/FLAG), u64 or
+ /* Points to int (BOOL), s32, u16, u32 (U32/FLAG/IP4), u64 or
* char * (STR). For FLAG, the value accumulates all flags
* to be set. */
void *wanted_val;
@@ -497,10 +501,10 @@ static struct cmdline_info cmdline_coalesce[] = {
};
static struct cmdline_info cmdline_ntuple[] = {
- { "src-ip", CMDL_BE32, &ntuple_fs.h_u.tcp_ip4_spec.ip4src, NULL },
- { "src-ip-mask", CMDL_BE32, &ntuple_fs.m_u.tcp_ip4_spec.ip4src, NULL },
- { "dst-ip", CMDL_BE32, &ntuple_fs.h_u.tcp_ip4_spec.ip4dst, NULL },
- { "dst-ip-mask", CMDL_BE32, &ntuple_fs.m_u.tcp_ip4_spec.ip4dst, NULL },
+ { "src-ip", CMDL_IP4, &ntuple_fs.h_u.tcp_ip4_spec.ip4src, NULL },
+ { "src-ip-mask", CMDL_IP4, &ntuple_fs.m_u.tcp_ip4_spec.ip4src, NULL },
+ { "dst-ip", CMDL_IP4, &ntuple_fs.h_u.tcp_ip4_spec.ip4dst, NULL },
+ { "dst-ip-mask", CMDL_IP4, &ntuple_fs.m_u.tcp_ip4_spec.ip4dst, NULL },
{ "src-port", CMDL_BE16, &ntuple_fs.h_u.tcp_ip4_spec.psrc, NULL },
{ "src-port-mask", CMDL_BE16, &ntuple_fs.m_u.tcp_ip4_spec.psrc, NULL },
{ "dst-port", CMDL_BE16, &ntuple_fs.h_u.tcp_ip4_spec.pdst, NULL },
@@ -645,11 +649,12 @@ static void parse_generic_cmdline(int argc, char **argp,
0xffff));
break;
}
- case CMDL_BE32: {
+ case CMDL_IP4: {
u32 *p = info[idx].wanted_val;
- *p = cpu_to_be32(
- get_uint_range(argp[i], 0,
- 0xffffffff));
+ struct in_addr in;
+ if (!inet_aton(argp[i], &in))
+ show_usage(1);
+ *p = in.s_addr;
break;
}
case CMDL_FLAG: {
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH ethtool 2/2] ethtool: Remove specification of number bases for RX-ntuple parameters
2010-07-22 19:11 [PATCH ethtool 1/2] ethtool: Use inet_aton() to parse IPv4 addresses for RX n-tuple control Ben Hutchings
@ 2010-07-22 19:12 ` Ben Hutchings
2010-08-04 20:36 ` [PATCH ethtool 1/2] ethtool: Use inet_aton() to parse IPv4 addresses for RX n-tuple control Jeff Garzik
1 sibling, 0 replies; 4+ messages in thread
From: Ben Hutchings @ 2010-07-22 19:12 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
The numeric parameters for RX n-tuple filters may be specified as
either decimal or hexadecimal with a '0x' prefix, like most other
numeric parameters.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
ethtool.8 | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/ethtool.8 b/ethtool.8
index d0cbc93..98b57fb 100644
--- a/ethtool.8
+++ b/ethtool.8
@@ -689,28 +689,28 @@ Includes the destination IP address.
Specify a mask for the destination IP address.
.TP
.BI src-port \ port
-Includes the source port, specified in decimal.
+Includes the source port.
.TP
.BI src-port-mask \ mask
-Specify a mask for the source port, specified in hex.
+Specify a mask for the source port.
.TP
.BI dst-port \ port
-Includes the destination port, specified in decimal.
+Includes the destination port.
.TP
.BI dst-port-mask \ mask
-Specify a mask for the destination port, specified in hex.
+Specify a mask for the destination port.
.TP
.BI vlan \ VLAN-tag
-Includes the VLAN tag, specified in hex.
+Includes the VLAN tag.
.TP
.BI vlan-mask \ mask
-Specify a mask for the VLAN tag, specified in hex.
+Specify a mask for the VLAN tag.
.TP
.BI user-def \ data
-Includes 64-bits of user-specific data, specified in hex.
+Includes 64-bits of user-specific data.
.TP
.BI user-def-mask \ mask
-Specify a mask for the user-specific data, specified in hex.
+Specify a mask for the user-specific data.
.TP
.BI action \ N
Specifies either the Rx queue to send packets to, or to drop
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH ethtool 1/2] ethtool: Use inet_aton() to parse IPv4 addresses for RX n-tuple control
2010-07-22 19:11 [PATCH ethtool 1/2] ethtool: Use inet_aton() to parse IPv4 addresses for RX n-tuple control Ben Hutchings
2010-07-22 19:12 ` [PATCH ethtool 2/2] ethtool: Remove specification of number bases for RX-ntuple parameters Ben Hutchings
@ 2010-08-04 20:36 ` Jeff Garzik
2010-08-04 20:51 ` Ben Hutchings
1 sibling, 1 reply; 4+ messages in thread
From: Jeff Garzik @ 2010-08-04 20:36 UTC (permalink / raw)
To: Ben Hutchings; +Cc: netdev, linux-net-drivers
FYI, I'm about to roll a new ethtool release for kernel 2.6.35. Are
these two patches the only outstanding ones? (they look good, will be
applied)
Jeff
P.S. The maintainer address is jgarzik@pobox.com, my standard kernel
address. jgarzik@redhat.com has a much higher latency, as it doesn't
get used very much.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH ethtool 1/2] ethtool: Use inet_aton() to parse IPv4 addresses for RX n-tuple control
2010-08-04 20:36 ` [PATCH ethtool 1/2] ethtool: Use inet_aton() to parse IPv4 addresses for RX n-tuple control Jeff Garzik
@ 2010-08-04 20:51 ` Ben Hutchings
0 siblings, 0 replies; 4+ messages in thread
From: Ben Hutchings @ 2010-08-04 20:51 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
On Wed, 2010-08-04 at 16:36 -0400, Jeff Garzik wrote:
> FYI, I'm about to roll a new ethtool release for kernel 2.6.35. Are
> these two patches the only outstanding ones? (they look good, will be
> applied)
Yes, those are the only ones.
> P.S. The maintainer address is jgarzik@pobox.com, my standard kernel
> address. jgarzik@redhat.com has a much higher latency, as it doesn't
> get used very much.
Sorry about that. I've changed my git-format-patch config accordingly.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-04 20:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-22 19:11 [PATCH ethtool 1/2] ethtool: Use inet_aton() to parse IPv4 addresses for RX n-tuple control Ben Hutchings
2010-07-22 19:12 ` [PATCH ethtool 2/2] ethtool: Remove specification of number bases for RX-ntuple parameters Ben Hutchings
2010-08-04 20:36 ` [PATCH ethtool 1/2] ethtool: Use inet_aton() to parse IPv4 addresses for RX n-tuple control Jeff Garzik
2010-08-04 20:51 ` Ben Hutchings
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).