lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 30 Jul 2018 14:56:59 +0200 (CEST)
From:   Michal Kubecek <mkubecek@...e.cz>
To:     netdev@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org,
        "John W. Linville" <linville@...driver.com>
Subject: [RFC PATCH ethtool v2 15/23] netlink: add netlink handler for
 gchannels (-l)

Implement "ethtool -l <dev>" subcommand using netlink interface command
ETHNL_CMD_GET_PARAMS with ETH_PARAMS_IM_CHANNELS mask.

Signed-off-by: Michal Kubecek <mkubecek@...e.cz>
---
 ethtool.c         |  3 ++-
 netlink/extapi.h  |  1 +
 netlink/monitor.c |  5 +++++
 netlink/params.c  | 42 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/ethtool.c b/ethtool.c
index 3a12b7c0c7ce..2bcc1944ba29 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4882,6 +4882,7 @@ static int show_usage(struct cmd_context *ctx);
 #define nl_gcoalesce	NULL
 #define nl_gring	NULL
 #define nl_gpause	NULL
+#define nl_gchannels	NULL
 #endif
 
 static const struct option {
@@ -5033,7 +5034,7 @@ static const struct option {
 	{ "-W|--set-dump", 1, do_setfwdump, NULL,
 	  "Set dump flag of the device",
 	  "		N\n"},
-	{ "-l|--show-channels", 1, do_gchannels, NULL,
+	{ "-l|--show-channels", 1, do_gchannels, nl_gchannels,
 	  "Query Channels" },
 	{ "-L|--set-channels", 1, do_schannels, NULL,
 	  "Set Channels",
diff --git a/netlink/extapi.h b/netlink/extapi.h
index 3b918a443b96..fc027f62398c 100644
--- a/netlink/extapi.h
+++ b/netlink/extapi.h
@@ -21,6 +21,7 @@ int nl_sfeatures(struct cmd_context *ctx);
 int nl_gcoalesce(struct cmd_context *ctx);
 int nl_gring(struct cmd_context *ctx);
 int nl_gpause(struct cmd_context *ctx);
+int nl_gchannels(struct cmd_context *ctx);
 int nl_monitor(struct cmd_context *ctx);
 
 void monitor_usage();
diff --git a/netlink/monitor.c b/netlink/monitor.c
index 18e151980c3f..1b277606a78c 100644
--- a/netlink/monitor.c
+++ b/netlink/monitor.c
@@ -153,6 +153,11 @@ static struct monitor_option monitor_opts[] = {
 		.cmd		= ETHNL_CMD_SET_PARAMS,
 		.info_mask	= ETH_PARAMS_IM_PAUSE,
 	},
+	{
+		.pattern	= "-l|--show-channels|-L|--set-channels",
+		.cmd		= ETHNL_CMD_SET_PARAMS,
+		.info_mask	= ETH_PARAMS_IM_CHANNELS,
+	},
 };
 
 static bool pattern_match(const char *s, const char *pattern)
diff --git a/netlink/params.c b/netlink/params.c
index b45aac166dcd..81547492532f 100644
--- a/netlink/params.c
+++ b/netlink/params.c
@@ -105,6 +105,34 @@ static int show_pause(struct nl_context *nlctx, const struct nlattr *nest)
 	return 0;
 }
 
+static int show_channels(struct nl_context *nlctx, const struct nlattr *nest)
+{
+	const struct nlattr *tb[ETHA_CHANNELS_MAX + 1] = {};
+	DECLARE_ATTR_TB_INFO(tb);
+	int ret;
+
+	if (!nest)
+		return -EOPNOTSUPP;
+	ret = mnl_attr_parse_nested(nest, attr_cb, &tb_info);
+	if (ret < 0)
+		return ret;
+
+	printf("Channel parameters for %s:\n", nlctx->devname);
+	printf("Pre-set maximums:\n");
+	show_u32(tb[ETHA_CHANNELS_MAX_RX], "RX:\t\t");
+	show_u32(tb[ETHA_CHANNELS_MAX_TX], "TX:\t\t");
+	show_u32(tb[ETHA_CHANNELS_MAX_OTHER], "Other:\t\t");
+	show_u32(tb[ETHA_CHANNELS_MAX_COMBINED], "Combined:\t");
+	printf("Current hardware settings:\n");
+	show_u32(tb[ETHA_CHANNELS_RX_COUNT], "RX:\t\t");
+	show_u32(tb[ETHA_CHANNELS_TX_COUNT], "TX:\t\t");
+	show_u32(tb[ETHA_CHANNELS_OTHER_COUNT], "Other:\t\t");
+	show_u32(tb[ETHA_CHANNELS_COMBINED_COUNT], "Combined:\t");
+	putchar('\n');
+
+	return 0;
+}
+
 int params_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 {
 	const struct nlattr *tb[ETHA_PARAMS_MAX + 1] = {};
@@ -146,6 +174,15 @@ int params_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 			return MNL_CB_ERROR;
 		}
 	}
+	if (mask_ok(nlctx, ETH_PARAMS_IM_CHANNELS)) {
+		ret = show_channels(nlctx, tb[ETHA_PARAMS_CHANNELS]);
+		if ((ret < 0) && show_only(nlctx, ETH_PARAMS_IM_CHANNELS)) {
+			nlctx->exit_code = 1;
+			errno = -ret;
+			perror("Cannot get device channel parameters");
+			return MNL_CB_ERROR;
+		}
+	}
 
 	return MNL_CB_OK;
 }
@@ -177,3 +214,8 @@ int nl_gpause(struct cmd_context *ctx)
 {
 	return params_request(ctx, ETH_PARAMS_IM_PAUSE);
 }
+
+int nl_gchannels(struct cmd_context *ctx)
+{
+	return params_request(ctx, ETH_PARAMS_IM_CHANNELS);
+}
-- 
2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ