From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Decotigny Subject: [ethtool PATCH v7 2/2] ethtool: use netlink socket when AF_INET not available Date: Fri, 25 Mar 2016 09:21:02 -0700 Message-ID: <1458922862-98024-3-git-send-email-ddecotig@gmail.com> References: <1458922862-98024-1-git-send-email-ddecotig@gmail.com> Cc: Jeff Garzik , Ben Hutchings , David Miller , Vidya Sagar Ravipati , Joe Perches , David Decotigny To: netdev@vger.kernel.org Return-path: Received: from mail-pa0-f68.google.com ([209.85.220.68]:34427 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753472AbcCYQVP (ORCPT ); Fri, 25 Mar 2016 12:21:15 -0400 Received: by mail-pa0-f68.google.com with SMTP id hj7so7109049pac.1 for ; Fri, 25 Mar 2016 09:21:14 -0700 (PDT) In-Reply-To: <1458922862-98024-1-git-send-email-ddecotig@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: From: David Decotigny To benefit from this, kernel commit 025c68186e07 ("netlink: add support for NIC driver ioctls") is needed. Signed-off-by: David Decotigny --- 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 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 #include +#ifdef HAVE_LINUX_NETLINK_H +# include +#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