Skip to content

Commit

Permalink
kernel: small changes from v6 review
Browse files Browse the repository at this point in the history
- minor documentation improvements
- rename ethnl_parse_header() parameter nest to header
- drop cleanup mention in ethnl_fill_reply_header() description
- fix ethnl_reply_init() error path
- make ethnl_update_binary() parameter dst void pointer

Rebase to net-next commit dbcdb61aaf1a.
  • Loading branch information
mkubecek committed Jul 3, 2019
1 parent 5d582d5 commit f742b9d
Show file tree
Hide file tree
Showing 45 changed files with 174 additions and 175 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ utility (based on master branch).

The patch sets are based on commits

- kernel: 337d1ccb3dc9
- kernel: dbcdb61aaf1a
- ethtool: 2bce6d9cb08e
- iproute2: 3efdd4366772
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From b6e0aefbcb58297b3ec0a12ee4be8e5194eee61a Mon Sep 17 00:00:00 2001
From a2091b53a0af671c5ced763833f41075cdb83a79 Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Wed, 6 Mar 2019 08:20:31 +0100
Subject: [PATCH 01/44] rtnetlink: provide permanent hardware address in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From d0c23ac629c4a0343acc9f09484e078962c55402 Mon Sep 17 00:00:00 2001
From d3ba344447a75cf2d7844dad6ae81115143d8b3c Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Thu, 27 Jun 2019 08:24:23 +0200
Subject: [PATCH 02/44] netlink: rename nl80211_validate_nested() to
Expand Down
2 changes: 1 addition & 1 deletion kernel/0003-ethtool-move-to-its-own-directory.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From ce3a28d37e0e617140e118489d48696fab739bf8 Mon Sep 17 00:00:00 2001
From 483850ce76b90301a44d0a3856452188fd584504 Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Sun, 13 May 2018 02:35:53 +0200
Subject: [PATCH 03/44] ethtool: move to its own directory
Expand Down
26 changes: 13 additions & 13 deletions kernel/0004-ethtool-introduce-ethtool-netlink-interface.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From e7fa3ad7e9cf4d7a8f9a2085e3166f7260845b0a Mon Sep 17 00:00:00 2001
From 79f30246807df8e83829a18bc0936d7e2b9aeb3e Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Fri, 10 Nov 2017 15:12:24 +0100
Subject: [PATCH 04/44] ethtool: introduce ethtool netlink interface
Expand Down Expand Up @@ -27,7 +27,7 @@ Signed-off-by: Michal Kubecek <mkubecek@suse.cz>

diff --git a/Documentation/networking/ethtool-netlink.txt b/Documentation/networking/ethtool-netlink.txt
new file mode 100644
index 000000000000..97c369aa290b
index 000000000000..028c29eeed93
--- /dev/null
+++ b/Documentation/networking/ethtool-netlink.txt
@@ -0,0 +1,208 @@
Expand Down Expand Up @@ -93,17 +93,17 @@ index 000000000000..97c369aa290b
+
+Optional info mask allows to ask only for a part of data provided by GET
+request types. If omitted or zero, all data is returned. The two flag bitmaps
+allow enabling requestoptions; ETHTOOL_A_HEADER_GFLAGS are global flags common
+for all request types, flags recognized in ETHTOOL_A_HEADER_RFLAGS and their
+interpretation are specific for each request type. Global flags are
+allow enabling request options; ETHTOOL_A_HEADER_GFLAGS are global flags
+common for all request types, flags recognized in ETHTOOL_A_HEADER_RFLAGS and
+their interpretation are specific for each request type. Global flags are
+
+ ETHTOOL_RF_COMPACT use compact format bitsets in reply
+ ETHTOOL_RF_REPLY send optional reply (SET and ACT requests)
+
+Request specific flags are described with each request type. For both flag
+attributes, new flags should follow the general idea that if the flag is not
+set, the behaviour is the same as (or closer to) the behaviour before it was
+introduced.
+set, the behaviour is backward compatible, i.e. requests from old clients not
+aware of the flag should be interpreted the way the client expects.
+
+
+List of message types
Expand All @@ -127,12 +127,12 @@ index 000000000000..97c369aa290b
+information for all devices supporting the request.
+
+If the data can be also modified, corresponding "SET" message with the same
+layout as "GET" reply is used to request changes. Only attributes where
+a change is requested are included in such request (also, not all attributes
+may be changed). Replies to most "SET" request consist only of error code and
+extack; if kernel provides additional data, it is sent in the form of
+corresponding "SET_REPLY" message (if ETHTOOL_RF_REPLY flag was set in request
+header).
+layout as corresponding "GET_REPLY" is used to request changes. Only
+attributes where a change is requested are included in such request (also, not
+all attributes may be changed). Replies to most "SET" request consist only of
+error code and extack; if kernel provides additional data, it is sent in the
+form of corresponding "SET_REPLY" message (if ETHTOOL_RF_REPLY flag was set in
+request header).
+
+Data modification also triggers sending a "NTF" message with a notification.
+These usually bear only a subset of attributes which was affected by the
Expand Down
31 changes: 15 additions & 16 deletions kernel/0005-ethtool-helper-functions-for-netlink-interface.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 44957b13e8edbced71aca893908d184eb9e57341 Mon Sep 17 00:00:00 2001
From f860dae65ee82ea1d09cae5db2bc07b3276ec361 Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Fri, 10 Nov 2017 15:34:56 +0100
Subject: [PATCH 05/44] ethtool: helper functions for netlink interface
Expand All @@ -10,9 +10,9 @@ structure members from request attributes (to be used for *_SET requests).
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
include/uapi/linux/ethtool_netlink.h | 23 ++++
net/ethtool/netlink.c | 173 +++++++++++++++++++++++++++
net/ethtool/netlink.c | 172 +++++++++++++++++++++++++++
net/ethtool/netlink.h | 145 ++++++++++++++++++++++
3 files changed, 341 insertions(+)
3 files changed, 340 insertions(+)

diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h
index 9a0fbd4f85d9..ffd7db0848ef 100644
Expand Down Expand Up @@ -49,10 +49,10 @@ index 9a0fbd4f85d9..ffd7db0848ef 100644
#define ETHTOOL_GENL_NAME "ethtool"
#define ETHTOOL_GENL_VERSION 1
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 3c98b41f04e5..e13f29bbd625 100644
index 3c98b41f04e5..12a46e3b1043 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -1,8 +1,181 @@
@@ -1,8 +1,180 @@
// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note

+#include <net/sock.h>
Expand All @@ -74,7 +74,7 @@ index 3c98b41f04e5..e13f29bbd625 100644
+/**
+ * ethnl_parse_header() - parse request header
+ * @req_info: structure to put results into
+ * @nest: nest attribute with request header
+ * @header: nest attribute with request header
+ * @net: request netns
+ * @extack: netlink extack for error reporting
+ * @policy: netlink attribute policy to validate header; use
Expand All @@ -90,7 +90,7 @@ index 3c98b41f04e5..e13f29bbd625 100644
+ * Return: 0 on success or negative error code
+ */
+int ethnl_parse_header(struct ethnl_req_info *req_info,
+ const struct nlattr *nest, struct net *net,
+ const struct nlattr *header, struct net *net,
+ struct netlink_ext_ack *extack,
+ const struct nla_policy *policy, bool require_dev)
+{
Expand All @@ -99,11 +99,11 @@ index 3c98b41f04e5..e13f29bbd625 100644
+ struct net_device *dev = NULL;
+ int ret;
+
+ if (!nest) {
+ if (!header) {
+ NL_SET_ERR_MSG(extack, "request header missing");
+ return -EINVAL;
+ }
+ ret = nla_parse_nested(tb, ETHTOOL_A_HEADER_MAX, nest,
+ ret = nla_parse_nested(tb, ETHTOOL_A_HEADER_MAX, header,
+ policy ?: dflt_header_policy, extack);
+ if (ret < 0)
+ return ret;
Expand All @@ -123,7 +123,7 @@ index 3c98b41f04e5..e13f29bbd625 100644
+ if (devname_attr &&
+ strncmp(dev->name, nla_data(devname_attr), IFNAMSIZ)) {
+ dev_put(dev);
+ NL_SET_ERR_MSG_ATTR(extack, nest,
+ NL_SET_ERR_MSG_ATTR(extack, header,
+ "ifindex and name do not match");
+ return -ENODEV;
+ }
Expand All @@ -135,7 +135,7 @@ index 3c98b41f04e5..e13f29bbd625 100644
+ return -ENODEV;
+ }
+ } else if (require_dev) {
+ NL_SET_ERR_MSG_ATTR(extack, nest,
+ NL_SET_ERR_MSG_ATTR(extack, header,
+ "neither ifindex nor name specified");
+ return -EINVAL;
+ }
Expand All @@ -161,7 +161,6 @@ index 3c98b41f04e5..e13f29bbd625 100644
+ * @attrtype: attribute type to use for the nest
+ *
+ * Create a nested attribute with attributes describing given network device.
+ * Clean up on error.
+ *
+ * Return: 0 on success, error value (-EMSGSIZE only) on error
+ */
Expand Down Expand Up @@ -219,23 +218,23 @@ index 3c98b41f04e5..e13f29bbd625 100644
+
+ ret = ethnl_fill_reply_header(skb, dev, hdr_attrtype);
+ if (ret < 0)
+ goto err;
+ goto err_free;
+ }
+ return skb;
+
+err_free:
+ nlmsg_free(skb);
+err:
+ if (info)
+ GENL_SET_ERR_MSG(info, "failed to setup reply message");
+err:
+ return NULL;
+}
+
/* genetlink setup */

static const struct genl_ops ethtool_genl_ops[] = {
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 257ae55ccc82..5510eb7054b3 100644
index 257ae55ccc82..71fca54f9c03 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -6,5 +6,150 @@
Expand Down Expand Up @@ -308,7 +307,7 @@ index 257ae55ccc82..5510eb7054b3 100644
+ return true;
+}
+
+static inline bool ethnl_update_binary(u8 *dst, unsigned int len,
+static inline bool ethnl_update_binary(void *dst, unsigned int len,
+ struct nlattr *attr)
+{
+ if (!attr)
Expand Down
10 changes: 5 additions & 5 deletions kernel/0006-ethtool-netlink-bitset-handling.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From cb614bebee1686293127194e8f7ced72955c7c7f Mon Sep 17 00:00:00 2001
From 7af50c79d7fb1a19e878c0852ee0b11339bf7dcb Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Mon, 13 Nov 2017 12:58:03 +0100
Subject: [PATCH 06/44] ethtool: netlink bitset handling
Expand Down Expand Up @@ -41,11 +41,11 @@ Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
create mode 100644 net/ethtool/bitset.h

diff --git a/Documentation/networking/ethtool-netlink.txt b/Documentation/networking/ethtool-netlink.txt
index 97c369aa290b..4636682c551f 100644
index 028c29eeed93..b02b6b5d3660 100644
--- a/Documentation/networking/ethtool-netlink.txt
+++ b/Documentation/networking/ethtool-netlink.txt
@@ -73,6 +73,67 @@ set, the behaviour is the same as (or closer to) the behaviour before it was
introduced.
@@ -73,6 +73,67 @@ set, the behaviour is backward compatible, i.e. requests from old clients not
aware of the flag should be interpreted the way the client expects.


+Bit sets
Expand Down Expand Up @@ -827,7 +827,7 @@ index 000000000000..761d0c47fe23
+
+#endif /* _NET_ETHTOOL_BITSET_H */
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 5510eb7054b3..7f1b9ec1ace7 100644
index 71fca54f9c03..979c1456e001 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -20,6 +20,15 @@ struct sk_buff *ethnl_reply_init(size_t payload, struct net_device *dev, u8 cmd,
Expand Down
10 changes: 5 additions & 5 deletions kernel/0007-ethtool-support-for-netlink-notifications.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 4dcac81783de8686edefa262a1db75f9e961b123 Mon Sep 17 00:00:00 2001
From f8a04b244dd5304a5ed4ee047ec827f3bb1ab662 Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Wed, 11 Jul 2018 14:19:52 -0400
Subject: [PATCH 07/44] ethtool: support for netlink notifications
Expand Down Expand Up @@ -77,7 +77,7 @@ index 805f314f4454..8938a1f09057 100644
+
#endif /* _UAPI_LINUX_ETHTOOL_NETLINK_H_ */
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index e13f29bbd625..a7a0bfe1818c 100644
index 12a46e3b1043..f599cc5a5cd4 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -6,6 +6,8 @@
Expand All @@ -89,7 +89,7 @@ index e13f29bbd625..a7a0bfe1818c 100644
static const struct nla_policy dflt_header_policy[ETHTOOL_A_HEADER_MAX + 1] = {
[ETHTOOL_A_HEADER_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_HEADER_DEV_INDEX] = { .type = NLA_U32 },
@@ -176,11 +178,41 @@ struct sk_buff *ethnl_reply_init(size_t payload, struct net_device *dev, u8 cmd,
@@ -175,11 +177,41 @@ struct sk_buff *ethnl_reply_init(size_t payload, struct net_device *dev, u8 cmd,
return NULL;
}

Expand Down Expand Up @@ -131,7 +131,7 @@ index e13f29bbd625..a7a0bfe1818c 100644
static struct genl_family ethtool_genl_family = {
.name = ETHTOOL_GENL_NAME,
.version = ETHTOOL_GENL_VERSION,
@@ -188,6 +220,8 @@ static struct genl_family ethtool_genl_family = {
@@ -187,6 +219,8 @@ static struct genl_family ethtool_genl_family = {
.parallel_ops = true,
.ops = ethtool_genl_ops,
.n_ops = ARRAY_SIZE(ethtool_genl_ops),
Expand All @@ -140,7 +140,7 @@ index e13f29bbd625..a7a0bfe1818c 100644
};

/* module setup */
@@ -199,6 +233,7 @@ static int __init ethnl_init(void)
@@ -198,6 +232,7 @@ static int __init ethnl_init(void)
ret = genl_register_family(&ethtool_genl_family);
if (WARN(ret < 0, "ethtool: genetlink family registration failed"))
return ret;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 0647ac484dac2c655d0e4260d81e86405688ff5b Mon Sep 17 00:00:00 2001
From 0808723bd825a73f67d9cbc07f11cbe8523657bb Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Fri, 15 Feb 2019 11:50:56 +0100
Subject: [PATCH 08/44] ethtool: move string arrays into common file
Expand Down
8 changes: 4 additions & 4 deletions kernel/0009-ethtool-generic-handlers-for-GET-requests.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 4faa0ce52dfe02c9cde5a46012b16c9af6764c5e Mon Sep 17 00:00:00 2001
From e7d2195bd95966bc00a989211ee66b425112f02d Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Tue, 24 Jul 2018 21:22:00 +0200
Subject: [PATCH 09/44] ethtool: generic handlers for GET requests
Expand Down Expand Up @@ -33,10 +33,10 @@ Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2 files changed, 465 insertions(+)

diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index a7a0bfe1818c..6d326cc25aac 100644
index f599cc5a5cd4..9b55a1a03180 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -178,6 +178,343 @@ struct sk_buff *ethnl_reply_init(size_t payload, struct net_device *dev, u8 cmd,
@@ -177,6 +177,343 @@ struct sk_buff *ethnl_reply_init(size_t payload, struct net_device *dev, u8 cmd,
return NULL;
}

Expand Down Expand Up @@ -381,7 +381,7 @@ index a7a0bfe1818c..6d326cc25aac 100644

typedef void (*ethnl_notify_handler_t)(struct net_device *dev,
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 7f1b9ec1ace7..6a9695c3b0c6 100644
index 979c1456e001..d34558bb7e83 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -143,8 +143,32 @@ static inline unsigned int ethnl_reply_header_size(void)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 3c30527bef64c030078a1e305613080bb372cbe6 Mon Sep 17 00:00:00 2001
From bd67aee27efb08bd9481b0d44b3340d43c663f66 Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Mon, 23 Jul 2018 12:32:56 +0200
Subject: [PATCH 10/44] ethtool: provide string sets with STRSET_GET request
Expand Down Expand Up @@ -32,7 +32,7 @@ Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
create mode 100644 net/ethtool/strset.c

diff --git a/Documentation/networking/ethtool-netlink.txt b/Documentation/networking/ethtool-netlink.txt
index 4636682c551f..21e5030734aa 100644
index b02b6b5d3660..684cb532b71c 100644
--- a/Documentation/networking/ethtool-netlink.txt
+++ b/Documentation/networking/ethtool-netlink.txt
@@ -148,6 +148,14 @@ according to message purpose:
Expand Down Expand Up @@ -229,18 +229,18 @@ index 11782306593b..11ceb00821b3 100644
-ethtool_nl-y := netlink.o bitset.o
+ethtool_nl-y := netlink.o bitset.o strset.o
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 6d326cc25aac..41d7fedd3dd6 100644
index 9b55a1a03180..a3237528cac7 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -199,6 +199,7 @@ struct ethnl_dump_ctx {
@@ -198,6 +198,7 @@ struct ethnl_dump_ctx {
};

static const struct get_request_ops *get_requests[__ETHTOOL_MSG_USER_CNT] = {
+ [ETHTOOL_MSG_STRSET_GET] = &strset_request_ops,
};

static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb)
@@ -544,6 +545,13 @@ EXPORT_SYMBOL(ethtool_notify);
@@ -543,6 +544,13 @@ EXPORT_SYMBOL(ethtool_notify);
/* genetlink setup */

static const struct genl_ops ethtool_genl_ops[] = {
Expand All @@ -255,7 +255,7 @@ index 6d326cc25aac..41d7fedd3dd6 100644

static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 6a9695c3b0c6..2352fd9c17c3 100644
index d34558bb7e83..eec805b98670 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -289,4 +289,8 @@ struct get_request_ops {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 1e1bf53de26780ecc0e448aa07dc429ef590798a Mon Sep 17 00:00:00 2001
From 80c9a40730dcc8d82a1b0e29e4378b2a8f035815 Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Sat, 16 Feb 2019 11:50:07 +0100
Subject: [PATCH 11/44] ethtool: provide link mode names as a string set
Expand Down Expand Up @@ -59,7 +59,7 @@ index 4e4e28e77c7a..6ad298224352 100644
ETH_SS_COUNT
};
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 41d7fedd3dd6..cba1f2259248 100644
index a3237528cac7..11da3ec5bf19 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -8,6 +8,86 @@ static struct genl_family ethtool_genl_family;
Expand Down Expand Up @@ -149,7 +149,7 @@ index 41d7fedd3dd6..cba1f2259248 100644
static const struct nla_policy dflt_header_policy[ETHTOOL_A_HEADER_MAX + 1] = {
[ETHTOOL_A_HEADER_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_HEADER_DEV_INDEX] = { .type = NLA_U32 },
@@ -575,6 +655,9 @@ static int __init ethnl_init(void)
@@ -574,6 +654,9 @@ static int __init ethnl_init(void)
{
int ret;

Expand All @@ -160,7 +160,7 @@ index 41d7fedd3dd6..cba1f2259248 100644
if (WARN(ret < 0, "ethtool: genetlink family registration failed"))
return ret;
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 2352fd9c17c3..d85b1edc1b91 100644
index eec805b98670..69985fa4028f 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -10,6 +10,8 @@
Expand Down
Loading

0 comments on commit f742b9d

Please sign in to comment.