ethtool: link up ethnl_header_policy as a nested policy
authorJakub Kicinski <kuba@kernel.org>
Mon, 5 Oct 2020 22:07:36 +0000 (15:07 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Oct 2020 13:25:55 +0000 (06:25 -0700)
To get the most out of parsing by the core, and to allow dumping
full policies we need to specify which policy applies to nested
attrs. For headers it's ethnl_header_policy.

$ sed -i 's@\(ETHTOOL_A_.*HEADER\].*=\) { .type = NLA_NESTED },@\1\n\t\tNLA_POLICY_NESTED(ethnl_header_policy),@' net/ethtool/*

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
18 files changed:
net/ethtool/cabletest.c
net/ethtool/channels.c
net/ethtool/coalesce.c
net/ethtool/debug.c
net/ethtool/eee.c
net/ethtool/features.c
net/ethtool/linkinfo.c
net/ethtool/linkmodes.c
net/ethtool/linkstate.c
net/ethtool/netlink.c
net/ethtool/netlink.h
net/ethtool/pause.c
net/ethtool/privflags.c
net/ethtool/rings.c
net/ethtool/strset.c
net/ethtool/tsinfo.c
net/ethtool/tunnels.c
net/ethtool/wol.c

index 6f3328b..63560bb 100644 (file)
@@ -12,7 +12,8 @@
 #define MAX_CABLE_LENGTH_CM (150 * 100)
 
 const struct nla_policy ethnl_cable_test_act_policy[] = {
-       [ETHTOOL_A_CABLE_TEST_HEADER]           = { .type = NLA_NESTED },
+       [ETHTOOL_A_CABLE_TEST_HEADER]           =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int ethnl_cable_test_started(struct phy_device *phydev, u8 cmd)
@@ -218,7 +219,8 @@ static const struct nla_policy cable_test_tdr_act_cfg_policy[] = {
 };
 
 const struct nla_policy ethnl_cable_test_tdr_act_policy[] = {
-       [ETHTOOL_A_CABLE_TEST_TDR_HEADER]       = { .type = NLA_NESTED },
+       [ETHTOOL_A_CABLE_TEST_TDR_HEADER]       =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_CABLE_TEST_TDR_CFG]          = { .type = NLA_NESTED },
 };
 
index 2a0cea0..5635604 100644 (file)
@@ -18,7 +18,8 @@ struct channels_reply_data {
        container_of(__reply_base, struct channels_reply_data, base)
 
 const struct nla_policy ethnl_channels_get_policy[] = {
-       [ETHTOOL_A_CHANNELS_HEADER]             = { .type = NLA_NESTED },
+       [ETHTOOL_A_CHANNELS_HEADER]             =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int channels_prepare_data(const struct ethnl_req_info *req_base,
@@ -100,7 +101,8 @@ const struct ethnl_request_ops ethnl_channels_request_ops = {
 /* CHANNELS_SET */
 
 const struct nla_policy ethnl_channels_set_policy[] = {
-       [ETHTOOL_A_CHANNELS_HEADER]             = { .type = NLA_NESTED },
+       [ETHTOOL_A_CHANNELS_HEADER]             =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_CHANNELS_RX_COUNT]           = { .type = NLA_U32 },
        [ETHTOOL_A_CHANNELS_TX_COUNT]           = { .type = NLA_U32 },
        [ETHTOOL_A_CHANNELS_OTHER_COUNT]        = { .type = NLA_U32 },
index c46d424..1d6bc13 100644 (file)
@@ -52,7 +52,8 @@ __CHECK_SUPPORTED_OFFSET(COALESCE_TX_MAX_FRAMES_HIGH);
 __CHECK_SUPPORTED_OFFSET(COALESCE_RATE_SAMPLE_INTERVAL);
 
 const struct nla_policy ethnl_coalesce_get_policy[] = {
-       [ETHTOOL_A_COALESCE_HEADER]             = { .type = NLA_NESTED },
+       [ETHTOOL_A_COALESCE_HEADER]             =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int coalesce_prepare_data(const struct ethnl_req_info *req_base,
@@ -190,7 +191,8 @@ const struct ethnl_request_ops ethnl_coalesce_request_ops = {
 /* COALESCE_SET */
 
 const struct nla_policy ethnl_coalesce_set_policy[] = {
-       [ETHTOOL_A_COALESCE_HEADER]             = { .type = NLA_NESTED },
+       [ETHTOOL_A_COALESCE_HEADER]             =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_COALESCE_RX_USECS]           = { .type = NLA_U32 },
        [ETHTOOL_A_COALESCE_RX_MAX_FRAMES]      = { .type = NLA_U32 },
        [ETHTOOL_A_COALESCE_RX_USECS_IRQ]       = { .type = NLA_U32 },
index dbd3243..f99912d 100644 (file)
@@ -17,7 +17,8 @@ struct debug_reply_data {
        container_of(__reply_base, struct debug_reply_data, base)
 
 const struct nla_policy ethnl_debug_get_policy[] = {
-       [ETHTOOL_A_DEBUG_HEADER]        = { .type = NLA_NESTED },
+       [ETHTOOL_A_DEBUG_HEADER]        =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int debug_prepare_data(const struct ethnl_req_info *req_base,
@@ -77,7 +78,8 @@ const struct ethnl_request_ops ethnl_debug_request_ops = {
 /* DEBUG_SET */
 
 const struct nla_policy ethnl_debug_set_policy[] = {
-       [ETHTOOL_A_DEBUG_HEADER]        = { .type = NLA_NESTED },
+       [ETHTOOL_A_DEBUG_HEADER]        =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_DEBUG_MSGMASK]       = { .type = NLA_NESTED },
 };
 
index d40a573..901b7de 100644 (file)
@@ -20,7 +20,8 @@ struct eee_reply_data {
        container_of(__reply_base, struct eee_reply_data, base)
 
 const struct nla_policy ethnl_eee_get_policy[] = {
-       [ETHTOOL_A_EEE_HEADER]          = { .type = NLA_NESTED },
+       [ETHTOOL_A_EEE_HEADER]          =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int eee_prepare_data(const struct ethnl_req_info *req_base,
@@ -122,7 +123,8 @@ const struct ethnl_request_ops ethnl_eee_request_ops = {
 /* EEE_SET */
 
 const struct nla_policy ethnl_eee_set_policy[] = {
-       [ETHTOOL_A_EEE_HEADER]          = { .type = NLA_NESTED },
+       [ETHTOOL_A_EEE_HEADER]          =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_EEE_MODES_OURS]      = { .type = NLA_NESTED },
        [ETHTOOL_A_EEE_ENABLED]         = { .type = NLA_U8 },
        [ETHTOOL_A_EEE_TX_LPI_ENABLED]  = { .type = NLA_U8 },
index 920386c..8ee4cdb 100644 (file)
@@ -21,7 +21,8 @@ struct features_reply_data {
        container_of(__reply_base, struct features_reply_data, base)
 
 const struct nla_policy ethnl_features_get_policy[] = {
-       [ETHTOOL_A_FEATURES_HEADER]     = { .type = NLA_NESTED },
+       [ETHTOOL_A_FEATURES_HEADER]     =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static void ethnl_features_to_bitmap32(u32 *dest, netdev_features_t src)
@@ -125,7 +126,8 @@ const struct ethnl_request_ops ethnl_features_request_ops = {
 /* FEATURES_SET */
 
 const struct nla_policy ethnl_features_set_policy[] = {
-       [ETHTOOL_A_FEATURES_HEADER]     = { .type = NLA_NESTED },
+       [ETHTOOL_A_FEATURES_HEADER]     =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_FEATURES_WANTED]     = { .type = NLA_NESTED },
 };
 
index 0c91618..b918398 100644 (file)
@@ -17,7 +17,8 @@ struct linkinfo_reply_data {
        container_of(__reply_base, struct linkinfo_reply_data, base)
 
 const struct nla_policy ethnl_linkinfo_get_policy[] = {
-       [ETHTOOL_A_LINKINFO_HEADER]             = { .type = NLA_NESTED },
+       [ETHTOOL_A_LINKINFO_HEADER]             =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int linkinfo_prepare_data(const struct ethnl_req_info *req_base,
@@ -87,7 +88,8 @@ const struct ethnl_request_ops ethnl_linkinfo_request_ops = {
 /* LINKINFO_SET */
 
 const struct nla_policy ethnl_linkinfo_set_policy[] = {
-       [ETHTOOL_A_LINKINFO_HEADER]             = { .type = NLA_NESTED },
+       [ETHTOOL_A_LINKINFO_HEADER]             =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_LINKINFO_PORT]               = { .type = NLA_U8 },
        [ETHTOOL_A_LINKINFO_PHYADDR]            = { .type = NLA_U8 },
        [ETHTOOL_A_LINKINFO_TP_MDIX_CTRL]       = { .type = NLA_U8 },
index dcef79b..c5bcb9a 100644 (file)
@@ -19,7 +19,8 @@ struct linkmodes_reply_data {
        container_of(__reply_base, struct linkmodes_reply_data, base)
 
 const struct nla_policy ethnl_linkmodes_get_policy[] = {
-       [ETHTOOL_A_LINKMODES_HEADER]            = { .type = NLA_NESTED },
+       [ETHTOOL_A_LINKMODES_HEADER]            =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int linkmodes_prepare_data(const struct ethnl_req_info *req_base,
@@ -266,7 +267,8 @@ static const struct link_mode_info link_mode_params[] = {
 };
 
 const struct nla_policy ethnl_linkmodes_set_policy[] = {
-       [ETHTOOL_A_LINKMODES_HEADER]            = { .type = NLA_NESTED },
+       [ETHTOOL_A_LINKMODES_HEADER]            =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_LINKMODES_AUTONEG]           = { .type = NLA_U8 },
        [ETHTOOL_A_LINKMODES_OURS]              = { .type = NLA_NESTED },
        [ETHTOOL_A_LINKMODES_SPEED]             = { .type = NLA_U32 },
index fc36e73..fb676f3 100644 (file)
@@ -21,7 +21,8 @@ struct linkstate_reply_data {
        container_of(__reply_base, struct linkstate_reply_data, base)
 
 const struct nla_policy ethnl_linkstate_get_policy[] = {
-       [ETHTOOL_A_LINKSTATE_HEADER]            = { .type = NLA_NESTED },
+       [ETHTOOL_A_LINKSTATE_HEADER]            =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int linkstate_get_sqi(struct net_device *dev)
index b8369ea..10567e6 100644 (file)
@@ -9,7 +9,7 @@ static struct genl_family ethtool_genl_family;
 static bool ethnl_ok __read_mostly;
 static u32 ethnl_bcast_seq;
 
-static const struct nla_policy ethnl_header_policy[] = {
+const struct nla_policy ethnl_header_policy[] = {
        [ETHTOOL_A_HEADER_DEV_INDEX]    = { .type = NLA_U32 },
        [ETHTOOL_A_HEADER_DEV_NAME]     = { .type = NLA_NUL_STRING,
                                            .len = ALTIFNAMSIZ - 1 },
index 2cfbc01..281d793 100644 (file)
@@ -345,6 +345,7 @@ extern const struct ethnl_request_ops ethnl_pause_request_ops;
 extern const struct ethnl_request_ops ethnl_eee_request_ops;
 extern const struct ethnl_request_ops ethnl_tsinfo_request_ops;
 
+extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1];
 extern const struct nla_policy ethnl_strset_get_policy[ETHTOOL_A_STRSET_STRINGSETS + 1];
 extern const struct nla_policy ethnl_linkinfo_get_policy[ETHTOOL_A_LINKINFO_HEADER + 1];
 extern const struct nla_policy ethnl_linkinfo_set_policy[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL + 1];
index 084798d..bf4013a 100644 (file)
@@ -17,7 +17,8 @@ struct pause_reply_data {
        container_of(__reply_base, struct pause_reply_data, base)
 
 const struct nla_policy ethnl_pause_get_policy[] = {
-       [ETHTOOL_A_PAUSE_HEADER]                = { .type = NLA_NESTED },
+       [ETHTOOL_A_PAUSE_HEADER]                =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static void ethtool_stats_init(u64 *stats, unsigned int n)
@@ -135,7 +136,8 @@ const struct ethnl_request_ops ethnl_pause_request_ops = {
 /* PAUSE_SET */
 
 const struct nla_policy ethnl_pause_set_policy[] = {
-       [ETHTOOL_A_PAUSE_HEADER]                = { .type = NLA_NESTED },
+       [ETHTOOL_A_PAUSE_HEADER]                =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_PAUSE_AUTONEG]               = { .type = NLA_U8 },
        [ETHTOOL_A_PAUSE_RX]                    = { .type = NLA_U8 },
        [ETHTOOL_A_PAUSE_TX]                    = { .type = NLA_U8 },
index 050d3d4..fc9f3be 100644 (file)
@@ -19,7 +19,8 @@ struct privflags_reply_data {
        container_of(__reply_base, struct privflags_reply_data, base)
 
 const struct nla_policy ethnl_privflags_get_policy[] = {
-       [ETHTOOL_A_PRIVFLAGS_HEADER]            = { .type = NLA_NESTED },
+       [ETHTOOL_A_PRIVFLAGS_HEADER]            =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int ethnl_get_priv_flags_info(struct net_device *dev,
@@ -133,7 +134,8 @@ const struct ethnl_request_ops ethnl_privflags_request_ops = {
 /* PRIVFLAGS_SET */
 
 const struct nla_policy ethnl_privflags_set_policy[] = {
-       [ETHTOOL_A_PRIVFLAGS_HEADER]            = { .type = NLA_NESTED },
+       [ETHTOOL_A_PRIVFLAGS_HEADER]            =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_PRIVFLAGS_FLAGS]             = { .type = NLA_NESTED },
 };
 
index da5d904..4e09781 100644 (file)
@@ -16,7 +16,8 @@ struct rings_reply_data {
        container_of(__reply_base, struct rings_reply_data, base)
 
 const struct nla_policy ethnl_rings_get_policy[] = {
-       [ETHTOOL_A_RINGS_HEADER]                = { .type = NLA_NESTED },
+       [ETHTOOL_A_RINGS_HEADER]                =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int rings_prepare_data(const struct ethnl_req_info *req_base,
@@ -98,7 +99,8 @@ const struct ethnl_request_ops ethnl_rings_request_ops = {
 /* RINGS_SET */
 
 const struct nla_policy ethnl_rings_set_policy[] = {
-       [ETHTOOL_A_RINGS_HEADER]                = { .type = NLA_NESTED },
+       [ETHTOOL_A_RINGS_HEADER]                =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_RINGS_RX]                    = { .type = NLA_U32 },
        [ETHTOOL_A_RINGS_RX_MINI]               = { .type = NLA_U32 },
        [ETHTOOL_A_RINGS_RX_JUMBO]              = { .type = NLA_U32 },
index 0219957..0734e83 100644 (file)
@@ -100,7 +100,8 @@ struct strset_reply_data {
        container_of(__reply_base, struct strset_reply_data, base)
 
 const struct nla_policy ethnl_strset_get_policy[] = {
-       [ETHTOOL_A_STRSET_HEADER]       = { .type = NLA_NESTED },
+       [ETHTOOL_A_STRSET_HEADER]       =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_STRSET_STRINGSETS]   = { .type = NLA_NESTED },
 };
 
index 6f050b8..63b5814 100644 (file)
@@ -19,7 +19,8 @@ struct tsinfo_reply_data {
        container_of(__reply_base, struct tsinfo_reply_data, base)
 
 const struct nla_policy ethnl_tsinfo_get_policy[] = {
-       [ETHTOOL_A_TSINFO_HEADER]               = { .type = NLA_NESTED },
+       [ETHTOOL_A_TSINFO_HEADER]               =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int tsinfo_prepare_data(const struct ethnl_req_info *req_base,
index 48a5295..e7f2ee0 100644 (file)
@@ -9,7 +9,8 @@
 #include "netlink.h"
 
 const struct nla_policy ethnl_tunnel_info_get_policy[] = {
-       [ETHTOOL_A_TUNNEL_INFO_HEADER]          = { .type = NLA_NESTED },
+       [ETHTOOL_A_TUNNEL_INFO_HEADER]          =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static_assert(ETHTOOL_UDP_TUNNEL_TYPE_VXLAN == ilog2(UDP_TUNNEL_TYPE_VXLAN));
index 7671089..ada7df2 100644 (file)
@@ -18,7 +18,8 @@ struct wol_reply_data {
        container_of(__reply_base, struct wol_reply_data, base)
 
 const struct nla_policy ethnl_wol_get_policy[] = {
-       [ETHTOOL_A_WOL_HEADER]          = { .type = NLA_NESTED },
+       [ETHTOOL_A_WOL_HEADER]          =
+               NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
 static int wol_prepare_data(const struct ethnl_req_info *req_base,
@@ -96,7 +97,8 @@ const struct ethnl_request_ops ethnl_wol_request_ops = {
 /* WOL_SET */
 
 const struct nla_policy ethnl_wol_set_policy[] = {
-       [ETHTOOL_A_WOL_HEADER]          = { .type = NLA_NESTED },
+       [ETHTOOL_A_WOL_HEADER]          =
+               NLA_POLICY_NESTED(ethnl_header_policy),
        [ETHTOOL_A_WOL_MODES]           = { .type = NLA_NESTED },
        [ETHTOOL_A_WOL_SOPASS]          = { .type = NLA_BINARY,
                                            .len = SOPASS_MAX },