From: David Decotigny <ddecotig@gmail.com>
To: netdev@vger.kernel.org
Cc: Jeff Garzik <jgarzik@pobox.com>,
Ben Hutchings <ben@decadent.org.uk>,
David Miller <davem@redhat.com>,
Vidya Sagar Ravipati <vidya@cumulusnetworks.com>,
Joe Perches <joe@perches.com>,
David Decotigny <decot@googlers.com>
Subject: [ethtool PATCH v7 2/2] ethtool: use netlink socket when AF_INET not available
Date: Mon, 9 May 2016 10:00:04 -0700 [thread overview]
Message-ID: <1462813204-14338-3-git-send-email-ddecotig@gmail.com> (raw)
In-Reply-To: <1462813204-14338-1-git-send-email-ddecotig@gmail.com>
From: David Decotigny <decot@googlers.com>
To benefit from this, kernel commit 025c68186e07 ("netlink: add support
for NIC driver ioctls") is needed.
Signed-off-by: David Decotigny <decot@googlers.com>
---
configure.ac | 2 +-
ethtool.c | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 3105415..47d2a0f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@ AM_PROG_CC_C_O
dnl Checks for libraries.
dnl Checks for header files.
-AC_CHECK_HEADERS(sys/ioctl.h)
+AC_CHECK_HEADERS(sys/ioctl.h linux/netlink.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_MSG_CHECKING([whether <linux/types.h> defines big-endian types])
diff --git a/ethtool.c b/ethtool.c
index cb3d971..314b1b8 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -42,6 +42,9 @@
#include <arpa/inet.h>
#include <linux/sockios.h>
+#ifdef HAVE_LINUX_NETLINK_H
+# include <linux/netlink.h>
+#endif
#ifndef MAX_ADDR_LEN
#define MAX_ADDR_LEN 32
@@ -4645,6 +4648,10 @@ opt_found:
/* Open control socket. */
ctx.fd = socket(AF_INET, SOCK_DGRAM, 0);
+#ifdef HAVE_LINUX_NETLINK_H
+ if (ctx.fd < 0)
+ ctx.fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
+#endif
if (ctx.fd < 0) {
perror("Cannot get control socket");
return 70;
--
2.8.0.rc3.226.g39d4020
next prev parent reply other threads:[~2016-05-09 17:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-09 17:00 [ethtool PATCH v7 0/2] add support for new ETHTOOL_xLINKSETTINGS ioctls David Decotigny
2016-05-09 17:00 ` [ethtool PATCH v7 1/2] ethtool.c: add support for " David Decotigny
2016-05-09 17:00 ` David Decotigny [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-06-10 0:55 [ethtool PATCH v7 0/2] add support for new " David Decotigny
2016-06-10 0:55 ` [ethtool PATCH v7 2/2] ethtool: use netlink socket when AF_INET not available David Decotigny
2016-05-02 17:00 [ethtool PATCH v7 0/2] add support for new ETHTOOL_xLINKSETTINGS ioctls David Decotigny
2016-05-02 17:00 ` [ethtool PATCH v7 2/2] ethtool: use netlink socket when AF_INET not available David Decotigny
2016-04-22 16:48 [ethtool PATCH v7 0/2] add support for new ETHTOOL_xLINKSETTINGS ioctls David Decotigny
2016-04-22 16:48 ` [ethtool PATCH v7 2/2] ethtool: use netlink socket when AF_INET not available David Decotigny
2016-03-25 16:21 [ethtool PATCH v7 0/2] add support for new ETHTOOL_xLINKSETTINGS ioctls David Decotigny
2016-03-25 16:21 ` [ethtool PATCH v7 2/2] ethtool: use netlink socket when AF_INET not available David Decotigny
2016-06-26 8:57 ` Ben Hutchings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462813204-14338-3-git-send-email-ddecotig@gmail.com \
--to=ddecotig@gmail.com \
--cc=ben@decadent.org.uk \
--cc=davem@redhat.com \
--cc=decot@googlers.com \
--cc=jgarzik@pobox.com \
--cc=joe@perches.com \
--cc=netdev@vger.kernel.org \
--cc=vidya@cumulusnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).