From 68caeec49bc884a254fde04b635a1585f8925322 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sun, 13 Aug 2017 06:52:24 +0200 Subject: [PATCH] interfaces: show a warning if we don't have permissions for ethtool ioctls --- src/daemon/interfaces-linux.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/daemon/interfaces-linux.c b/src/daemon/interfaces-linux.c index b61d1293..98b52678 100644 --- a/src/daemon/interfaces-linux.c +++ b/src/daemon/interfaces-linux.c @@ -495,7 +495,16 @@ iflinux_ethtool_glink(struct lldpd *cfg, const char *ifname, struct ethtool_link if (rc == 0) { nwords = -ecmd.req.link_mode_masks_nwords; log_debug("interfaces", "glinksettings nwords is %" PRId8, nwords); - } else nwords = -1; + } else { + static int once = 0; + if (errno == EPERM && !once) { + log_warn("interfaces", + "cannot get ethtool link information " + "with GLINKSETTINGS (requires 4.9+)"); + once = 1; + } + nwords = -1; + } } if (nwords > 0) { memset(&ecmd, 0, sizeof(ecmd)); @@ -543,6 +552,14 @@ iflinux_ethtool_glink(struct lldpd *cfg, const char *ifname, struct ethtool_link uset->base.duplex = ethc.duplex; uset->base.port = ethc.port; uset->base.autoneg = ethc.autoneg; + } else { + static int once = 0; + if (errno == EPERM && !once) { + log_warn("interfaces", + "cannot get ethtool link information " + "with GSET (requires 2.6.19+)"); + once = 1; + } } end: return rc; -- 2.39.5