summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2023-01-19 14:26:53 +0200
committerDavid S. Miller <davem@davemloft.net>2023-01-23 10:58:12 +0000
commit7c494a7749a7d6ee95cfae6a8c109c5d63103d88 (patch)
treeb23f87fbe3023f82188481b1a393a9e5c6b6df90 /net
parente38553bdc377e3e7a6caa9dd9770d8b644d8dac3 (diff)
downloadlinux-stable-7c494a7749a7d6ee95cfae6a8c109c5d63103d88.tar.gz
linux-stable-7c494a7749a7d6ee95cfae6a8c109c5d63103d88.tar.bz2
linux-stable-7c494a7749a7d6ee95cfae6a8c109c5d63103d88.zip
net: ethtool: netlink: introduce ethnl_update_bool()
Due to the fact that the kernel-side data structures have been carried over from the ioctl-based ethtool, we are now in the situation where we have an ethnl_update_bool32() function, but the plain function that operates on a boolean value kept in an actual u8 netlink attribute doesn't exist. With new ethtool features that are exposed solely over netlink, the kernel data structures will use the "bool" type, so we will need this kind of helper. Introduce it now; it's needed for things like verify-disabled for the MAC merge configuration. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ethtool/netlink.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 3753787ba233..744b3ab966b0 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -112,6 +112,32 @@ static inline void ethnl_update_u8(u8 *dst, const struct nlattr *attr,
}
/**
+ * ethnl_update_bool() - update bool from NLA_U8 attribute
+ * @dst: value to update
+ * @attr: netlink attribute with new value or null
+ * @mod: pointer to bool for modification tracking
+ *
+ * Use the u8 value from NLA_U8 netlink attribute @attr to set bool variable
+ * pointed to by @dst to false (if zero) or 1 (if not); do nothing if @attr is
+ * null. Bool pointed to by @mod is set to true if this function changed the
+ * logical value of *dst, otherwise it is left as is.
+ */
+static inline void ethnl_update_bool(bool *dst, const struct nlattr *attr,
+ bool *mod)
+{
+ u8 val;
+
+ if (!attr)
+ return;
+ val = !!nla_get_u8(attr);
+ if (*dst == val)
+ return;
+
+ *dst = val;
+ *mod = true;
+}
+
+/**
* ethnl_update_bool32() - update u32 used as bool from NLA_U8 attribute
* @dst: value to update
* @attr: netlink attribute with new value or null