From: Michal Kubecek <mkubecek@suse.cz>
To: netdev@vger.kernel.org
Cc: David Miller <davem@davemloft.net>, Andrew Lunn <andrew@lunn.ch>,
Jakub Kicinski <jakub.kicinski@netronome.com>,
Jiri Pirko <jiri@resnulli.us>,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH net-next v3 17/21] ethtool: provide message level in GET_SETTINGS request
Date: Mon, 18 Feb 2019 19:22:49 +0100 (CET) [thread overview]
Message-ID: <3e11d2901feca6a4aa8460a63537f5e59204a14a.1550513384.git.mkubecek@suse.cz> (raw)
In-Reply-To: <cover.1550513384.git.mkubecek@suse.cz>
Add information about supported and enabled message levels to the
GET_SETTINGS reply when ETH_SETTINGS_IM_MSGLEVEL flag is set in the
request.
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
Documentation/networking/ethtool-netlink.txt | 7 ++++++-
include/linux/netdevice.h | 2 ++
include/uapi/linux/ethtool_netlink.h | 4 +++-
net/ethtool/settings.c | 16 ++++++++++++++++
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/Documentation/networking/ethtool-netlink.txt b/Documentation/networking/ethtool-netlink.txt
index 913df35cb762..057eb3213cfe 100644
--- a/Documentation/networking/ethtool-netlink.txt
+++ b/Documentation/networking/ethtool-netlink.txt
@@ -284,6 +284,7 @@ Info mask bits meaning:
ETH_SETTINGS_IM_LINKINFO link_ksettings except link modes
ETH_SETTINGS_IM_LINKMODES link modes from link_ksettings
ETH_SETTINGS_IM_WOLINFO struct ethtool_wolinfo
+ ETH_SETTINGS_IM_MSGLEVEL msglevel
Response contents:
@@ -302,6 +303,7 @@ Response contents:
ETHA_SETTINGS_WOL (nested) wake on LAN settings
ETHA_WOL_MODES (bitfield32) wake on LAN modes
ETHA_WOL_SOPASS (binary) SecureOn(tm) password
+ ETHA_SETTINGS_MSGLEVEL (bitfield32) debug level
Most of the attributes and their values have the same meaning as matching
members of the corresponding ioctl structures. For ETHA_SETTINGS_LINK_MODES,
@@ -311,6 +313,9 @@ ETHA_SETTINGS_PEER_MODES in the reply is a bit list.
For ETHA_WOL_MODES, selector reports wake on LAN modes supported by the
device and value enabled modes.
+For ETHA_SETTINGS_MSGLEVEL, selector reports all flags supported by kernel and
+value flags enabled for the device.
+
GET_SETTINGS request is allowed for unprivileged user but ETHA_SETTINGS_SOPASS
is only provided by kernel in response to privileged (netns CAP_NET_ADMIN)
requests.
@@ -335,7 +340,7 @@ ETHTOOL_GDRVINFO ETHNL_CMD_GET_INFO
ETHTOOL_GREGS n/a
ETHTOOL_GWOL ETHNL_CMD_GET_SETTINGS
ETHTOOL_SWOL n/a
-ETHTOOL_GMSGLVL n/a
+ETHTOOL_GMSGLVL ETHNL_CMD_GET_SETTINGS
ETHTOOL_SMSGLVL n/a
ETHTOOL_NWAY_RST n/a
ETHTOOL_GLINK n/a
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9a50a67f328f..a2ddfeb381bb 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3846,6 +3846,8 @@ enum {
NETIF_MSG_PKTDATA = 0x1000,
NETIF_MSG_HW = 0x2000,
NETIF_MSG_WOL = 0x4000,
+
+ NETIF_MSG_ALL = 0x7fff,
};
#define netif_msg_drv(p) ((p)->msg_enable & NETIF_MSG_DRV)
diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h
index ce9d6b48f814..360e20a73f19 100644
--- a/include/uapi/linux/ethtool_netlink.h
+++ b/include/uapi/linux/ethtool_netlink.h
@@ -202,6 +202,7 @@ enum {
ETHA_SETTINGS_LINK_MODES, /* bitset */
ETHA_SETTINGS_PEER_MODES, /* bitset */
ETHA_SETTINGS_WOL, /* nested */
+ ETHA_SETTINGS_MSGLEVEL, /* bitfield32 */
__ETHA_SETTINGS_CNT,
ETHA_SETTINGS_MAX = (__ETHA_SETTINGS_CNT - 1)
@@ -210,8 +211,9 @@ enum {
#define ETH_SETTINGS_IM_LINKINFO 0x01
#define ETH_SETTINGS_IM_LINKMODES 0x02
#define ETH_SETTINGS_IM_WOLINFO 0x04
+#define ETH_SETTINGS_IM_MSGLEVEL 0x08
-#define ETH_SETTINGS_IM_ALL 0x07
+#define ETH_SETTINGS_IM_ALL 0x0f
enum {
ETHA_LINKINFO_UNSPEC,
diff --git a/net/ethtool/settings.c b/net/ethtool/settings.c
index d296625edb2b..58cd2d19a75d 100644
--- a/net/ethtool/settings.c
+++ b/net/ethtool/settings.c
@@ -13,6 +13,7 @@ struct settings_data {
struct ethtool_link_ksettings ksettings;
struct ethtool_link_settings *lsettings;
struct ethtool_wolinfo wolinfo;
+ u32 msglevel;
bool lpm_empty;
};
@@ -25,6 +26,7 @@ static const struct nla_policy get_settings_policy[ETHA_SETTINGS_MAX + 1] = {
[ETHA_SETTINGS_LINK_MODES] = { .type = NLA_REJECT },
[ETHA_SETTINGS_PEER_MODES] = { .type = NLA_REJECT },
[ETHA_SETTINGS_WOL] = { .type = NLA_REJECT },
+ [ETHA_SETTINGS_MSGLEVEL] = { .type = NLA_REJECT },
};
static int parse_settings(struct common_req_info *req_info,
@@ -91,6 +93,7 @@ static int prepare_settings(struct common_req_info *req_info,
struct settings_data *data =
container_of(req_info, struct settings_data, reqinfo_base);
struct net_device *dev = data->repdata_base.dev;
+ const struct ethtool_ops *eops = dev->ethtool_ops;
u32 req_mask = req_info->req_mask;
int ret;
@@ -122,6 +125,12 @@ static int prepare_settings(struct common_req_info *req_info,
if (ret < 0)
req_mask &= ~ETH_SETTINGS_IM_WOLINFO;
}
+ if (req_mask & ETH_SETTINGS_IM_MSGLEVEL) {
+ if (eops->get_msglevel)
+ data->msglevel = eops->get_msglevel(dev);
+ else
+ req_mask &= ~ETH_SETTINGS_IM_MSGLEVEL;
+ }
ethnl_after_ops(dev);
data->repdata_base.info_mask = req_mask;
@@ -198,6 +207,8 @@ static int settings_size(const struct common_req_info *req_info)
}
if (info_mask & ETH_SETTINGS_IM_WOLINFO)
len += wol_size();
+ if (info_mask & ETH_SETTINGS_IM_MSGLEVEL)
+ len += nla_total_size(sizeof(struct nla_bitfield32));
return len;
}
@@ -308,6 +319,11 @@ static int fill_settings(struct sk_buff *skb,
if (ret < 0)
return ret;
}
+ if (info_mask & ETH_SETTINGS_IM_MSGLEVEL) {
+ if (nla_put_bitfield32(skb, ETHA_SETTINGS_MSGLEVEL,
+ data->msglevel, NETIF_MSG_ALL))
+ return -EMSGSIZE;
+ }
return 0;
}
--
2.20.1
next prev parent reply other threads:[~2019-02-18 18:22 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-18 18:21 [RFC PATCH net-next v3 00/21] ethtool netlink interface, part 1 Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 01/21] netlink: introduce nla_put_bitfield32() Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 02/21] ethtool: move to its own directory Michal Kubecek
2019-02-18 20:01 ` Jakub Kicinski
2019-02-18 18:21 ` [RFC PATCH net-next v3 03/21] ethtool: introduce ethtool netlink interface Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 04/21] ethtool: helper functions for " Michal Kubecek
2019-02-18 20:15 ` Jakub Kicinski
2019-02-19 13:07 ` Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 05/21] ethtool: netlink bitset handling Michal Kubecek
2019-02-20 2:27 ` Jakub Kicinski
2019-02-20 8:16 ` Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 06/21] ethtool: support for netlink notifications Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 07/21] ethtool: implement EVENT notifications Michal Kubecek
2019-02-18 23:46 ` Andrew Lunn
2019-02-19 7:02 ` Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 08/21] ethtool: generic handlers for GET requests Michal Kubecek
2019-02-20 2:42 ` Jakub Kicinski
2019-02-18 18:22 ` [RFC PATCH net-next v3 09/21] ethtool: move string arrays into common file Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 10/21] ethtool: provide string sets with GET_STRSET request Michal Kubecek
2019-02-20 2:56 ` Jakub Kicinski
2019-02-20 12:34 ` Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 11/21] ethtool: provide driver/device information in GET_INFO request Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 12/21] ethtool: provide permanent hardware address " Michal Kubecek
2019-02-19 10:24 ` Jiri Pirko
2019-02-19 11:36 ` Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 13/21] ethtool: provide timestamping information " Michal Kubecek
2019-02-20 3:00 ` Jakub Kicinski
2019-02-20 13:00 ` Michal Kubecek
2019-02-20 18:37 ` Jakub Kicinski
2019-02-18 18:22 ` [RFC PATCH net-next v3 14/21] ethtool: provide link mode names as a string set Michal Kubecek
2019-02-21 3:21 ` Florian Fainelli
2019-02-21 9:57 ` Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 15/21] ethtool: provide link settings and link modes in GET_SETTINGS request Michal Kubecek
2019-02-21 3:14 ` Florian Fainelli
2019-02-21 10:14 ` Michal Kubecek
2019-02-21 17:40 ` Florian Fainelli
2019-02-18 18:22 ` [RFC PATCH net-next v3 16/21] ethtool: provide WoL information " Michal Kubecek
2019-02-18 18:22 ` Michal Kubecek [this message]
2019-02-18 18:22 ` [RFC PATCH net-next v3 18/21] ethtool: provide link state " Michal Kubecek
2019-02-18 18:23 ` [RFC PATCH net-next v3 19/21] ethtool: provide device features " Michal Kubecek
2019-02-18 18:23 ` [RFC PATCH net-next v3 20/21] ethtool: provide private flags " Michal Kubecek
2019-02-18 18:23 ` [RFC PATCH net-next v3 21/21] ethtool: send netlink notifications about setting changes Michal Kubecek
2019-02-19 10:35 ` [RFC PATCH net-next v3 00/21] ethtool netlink interface, part 1 Jiri Pirko
2019-02-19 11:57 ` Michal Kubecek
2019-02-19 12:27 ` Jiri Pirko
2019-02-21 3:21 ` Florian Fainelli
2019-02-21 9:54 ` Michal Kubecek
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=3e11d2901feca6a4aa8460a63537f5e59204a14a.1550513384.git.mkubecek@suse.cz \
--to=mkubecek@suse.cz \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=jakub.kicinski@netronome.com \
--cc=jiri@resnulli.us \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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).