Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ethtool: link up ethnl_header_policy as a nested policy

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>

authored by

Jakub Kicinski and committed by
David S. Miller
329d9c33 ff419afa

+58 -29
+4 -2
net/ethtool/cabletest.c
··· 12 12 #define MAX_CABLE_LENGTH_CM (150 * 100) 13 13 14 14 const struct nla_policy ethnl_cable_test_act_policy[] = { 15 - [ETHTOOL_A_CABLE_TEST_HEADER] = { .type = NLA_NESTED }, 15 + [ETHTOOL_A_CABLE_TEST_HEADER] = 16 + NLA_POLICY_NESTED(ethnl_header_policy), 16 17 }; 17 18 18 19 static int ethnl_cable_test_started(struct phy_device *phydev, u8 cmd) ··· 219 218 }; 220 219 221 220 const struct nla_policy ethnl_cable_test_tdr_act_policy[] = { 222 - [ETHTOOL_A_CABLE_TEST_TDR_HEADER] = { .type = NLA_NESTED }, 221 + [ETHTOOL_A_CABLE_TEST_TDR_HEADER] = 222 + NLA_POLICY_NESTED(ethnl_header_policy), 223 223 [ETHTOOL_A_CABLE_TEST_TDR_CFG] = { .type = NLA_NESTED }, 224 224 }; 225 225
+4 -2
net/ethtool/channels.c
··· 18 18 container_of(__reply_base, struct channels_reply_data, base) 19 19 20 20 const struct nla_policy ethnl_channels_get_policy[] = { 21 - [ETHTOOL_A_CHANNELS_HEADER] = { .type = NLA_NESTED }, 21 + [ETHTOOL_A_CHANNELS_HEADER] = 22 + NLA_POLICY_NESTED(ethnl_header_policy), 22 23 }; 23 24 24 25 static int channels_prepare_data(const struct ethnl_req_info *req_base, ··· 101 100 /* CHANNELS_SET */ 102 101 103 102 const struct nla_policy ethnl_channels_set_policy[] = { 104 - [ETHTOOL_A_CHANNELS_HEADER] = { .type = NLA_NESTED }, 103 + [ETHTOOL_A_CHANNELS_HEADER] = 104 + NLA_POLICY_NESTED(ethnl_header_policy), 105 105 [ETHTOOL_A_CHANNELS_RX_COUNT] = { .type = NLA_U32 }, 106 106 [ETHTOOL_A_CHANNELS_TX_COUNT] = { .type = NLA_U32 }, 107 107 [ETHTOOL_A_CHANNELS_OTHER_COUNT] = { .type = NLA_U32 },
+4 -2
net/ethtool/coalesce.c
··· 52 52 __CHECK_SUPPORTED_OFFSET(COALESCE_RATE_SAMPLE_INTERVAL); 53 53 54 54 const struct nla_policy ethnl_coalesce_get_policy[] = { 55 - [ETHTOOL_A_COALESCE_HEADER] = { .type = NLA_NESTED }, 55 + [ETHTOOL_A_COALESCE_HEADER] = 56 + NLA_POLICY_NESTED(ethnl_header_policy), 56 57 }; 57 58 58 59 static int coalesce_prepare_data(const struct ethnl_req_info *req_base, ··· 191 190 /* COALESCE_SET */ 192 191 193 192 const struct nla_policy ethnl_coalesce_set_policy[] = { 194 - [ETHTOOL_A_COALESCE_HEADER] = { .type = NLA_NESTED }, 193 + [ETHTOOL_A_COALESCE_HEADER] = 194 + NLA_POLICY_NESTED(ethnl_header_policy), 195 195 [ETHTOOL_A_COALESCE_RX_USECS] = { .type = NLA_U32 }, 196 196 [ETHTOOL_A_COALESCE_RX_MAX_FRAMES] = { .type = NLA_U32 }, 197 197 [ETHTOOL_A_COALESCE_RX_USECS_IRQ] = { .type = NLA_U32 },
+4 -2
net/ethtool/debug.c
··· 17 17 container_of(__reply_base, struct debug_reply_data, base) 18 18 19 19 const struct nla_policy ethnl_debug_get_policy[] = { 20 - [ETHTOOL_A_DEBUG_HEADER] = { .type = NLA_NESTED }, 20 + [ETHTOOL_A_DEBUG_HEADER] = 21 + NLA_POLICY_NESTED(ethnl_header_policy), 21 22 }; 22 23 23 24 static int debug_prepare_data(const struct ethnl_req_info *req_base, ··· 78 77 /* DEBUG_SET */ 79 78 80 79 const struct nla_policy ethnl_debug_set_policy[] = { 81 - [ETHTOOL_A_DEBUG_HEADER] = { .type = NLA_NESTED }, 80 + [ETHTOOL_A_DEBUG_HEADER] = 81 + NLA_POLICY_NESTED(ethnl_header_policy), 82 82 [ETHTOOL_A_DEBUG_MSGMASK] = { .type = NLA_NESTED }, 83 83 }; 84 84
+4 -2
net/ethtool/eee.c
··· 20 20 container_of(__reply_base, struct eee_reply_data, base) 21 21 22 22 const struct nla_policy ethnl_eee_get_policy[] = { 23 - [ETHTOOL_A_EEE_HEADER] = { .type = NLA_NESTED }, 23 + [ETHTOOL_A_EEE_HEADER] = 24 + NLA_POLICY_NESTED(ethnl_header_policy), 24 25 }; 25 26 26 27 static int eee_prepare_data(const struct ethnl_req_info *req_base, ··· 123 122 /* EEE_SET */ 124 123 125 124 const struct nla_policy ethnl_eee_set_policy[] = { 126 - [ETHTOOL_A_EEE_HEADER] = { .type = NLA_NESTED }, 125 + [ETHTOOL_A_EEE_HEADER] = 126 + NLA_POLICY_NESTED(ethnl_header_policy), 127 127 [ETHTOOL_A_EEE_MODES_OURS] = { .type = NLA_NESTED }, 128 128 [ETHTOOL_A_EEE_ENABLED] = { .type = NLA_U8 }, 129 129 [ETHTOOL_A_EEE_TX_LPI_ENABLED] = { .type = NLA_U8 },
+4 -2
net/ethtool/features.c
··· 21 21 container_of(__reply_base, struct features_reply_data, base) 22 22 23 23 const struct nla_policy ethnl_features_get_policy[] = { 24 - [ETHTOOL_A_FEATURES_HEADER] = { .type = NLA_NESTED }, 24 + [ETHTOOL_A_FEATURES_HEADER] = 25 + NLA_POLICY_NESTED(ethnl_header_policy), 25 26 }; 26 27 27 28 static void ethnl_features_to_bitmap32(u32 *dest, netdev_features_t src) ··· 126 125 /* FEATURES_SET */ 127 126 128 127 const struct nla_policy ethnl_features_set_policy[] = { 129 - [ETHTOOL_A_FEATURES_HEADER] = { .type = NLA_NESTED }, 128 + [ETHTOOL_A_FEATURES_HEADER] = 129 + NLA_POLICY_NESTED(ethnl_header_policy), 130 130 [ETHTOOL_A_FEATURES_WANTED] = { .type = NLA_NESTED }, 131 131 }; 132 132
+4 -2
net/ethtool/linkinfo.c
··· 17 17 container_of(__reply_base, struct linkinfo_reply_data, base) 18 18 19 19 const struct nla_policy ethnl_linkinfo_get_policy[] = { 20 - [ETHTOOL_A_LINKINFO_HEADER] = { .type = NLA_NESTED }, 20 + [ETHTOOL_A_LINKINFO_HEADER] = 21 + NLA_POLICY_NESTED(ethnl_header_policy), 21 22 }; 22 23 23 24 static int linkinfo_prepare_data(const struct ethnl_req_info *req_base, ··· 88 87 /* LINKINFO_SET */ 89 88 90 89 const struct nla_policy ethnl_linkinfo_set_policy[] = { 91 - [ETHTOOL_A_LINKINFO_HEADER] = { .type = NLA_NESTED }, 90 + [ETHTOOL_A_LINKINFO_HEADER] = 91 + NLA_POLICY_NESTED(ethnl_header_policy), 92 92 [ETHTOOL_A_LINKINFO_PORT] = { .type = NLA_U8 }, 93 93 [ETHTOOL_A_LINKINFO_PHYADDR] = { .type = NLA_U8 }, 94 94 [ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] = { .type = NLA_U8 },
+4 -2
net/ethtool/linkmodes.c
··· 19 19 container_of(__reply_base, struct linkmodes_reply_data, base) 20 20 21 21 const struct nla_policy ethnl_linkmodes_get_policy[] = { 22 - [ETHTOOL_A_LINKMODES_HEADER] = { .type = NLA_NESTED }, 22 + [ETHTOOL_A_LINKMODES_HEADER] = 23 + NLA_POLICY_NESTED(ethnl_header_policy), 23 24 }; 24 25 25 26 static int linkmodes_prepare_data(const struct ethnl_req_info *req_base, ··· 267 266 }; 268 267 269 268 const struct nla_policy ethnl_linkmodes_set_policy[] = { 270 - [ETHTOOL_A_LINKMODES_HEADER] = { .type = NLA_NESTED }, 269 + [ETHTOOL_A_LINKMODES_HEADER] = 270 + NLA_POLICY_NESTED(ethnl_header_policy), 271 271 [ETHTOOL_A_LINKMODES_AUTONEG] = { .type = NLA_U8 }, 272 272 [ETHTOOL_A_LINKMODES_OURS] = { .type = NLA_NESTED }, 273 273 [ETHTOOL_A_LINKMODES_SPEED] = { .type = NLA_U32 },
+2 -1
net/ethtool/linkstate.c
··· 21 21 container_of(__reply_base, struct linkstate_reply_data, base) 22 22 23 23 const struct nla_policy ethnl_linkstate_get_policy[] = { 24 - [ETHTOOL_A_LINKSTATE_HEADER] = { .type = NLA_NESTED }, 24 + [ETHTOOL_A_LINKSTATE_HEADER] = 25 + NLA_POLICY_NESTED(ethnl_header_policy), 25 26 }; 26 27 27 28 static int linkstate_get_sqi(struct net_device *dev)
+1 -1
net/ethtool/netlink.c
··· 9 9 static bool ethnl_ok __read_mostly; 10 10 static u32 ethnl_bcast_seq; 11 11 12 - static const struct nla_policy ethnl_header_policy[] = { 12 + const struct nla_policy ethnl_header_policy[] = { 13 13 [ETHTOOL_A_HEADER_DEV_INDEX] = { .type = NLA_U32 }, 14 14 [ETHTOOL_A_HEADER_DEV_NAME] = { .type = NLA_NUL_STRING, 15 15 .len = ALTIFNAMSIZ - 1 },
+1
net/ethtool/netlink.h
··· 345 345 extern const struct ethnl_request_ops ethnl_eee_request_ops; 346 346 extern const struct ethnl_request_ops ethnl_tsinfo_request_ops; 347 347 348 + extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1]; 348 349 extern const struct nla_policy ethnl_strset_get_policy[ETHTOOL_A_STRSET_STRINGSETS + 1]; 349 350 extern const struct nla_policy ethnl_linkinfo_get_policy[ETHTOOL_A_LINKINFO_HEADER + 1]; 350 351 extern const struct nla_policy ethnl_linkinfo_set_policy[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL + 1];
+4 -2
net/ethtool/pause.c
··· 17 17 container_of(__reply_base, struct pause_reply_data, base) 18 18 19 19 const struct nla_policy ethnl_pause_get_policy[] = { 20 - [ETHTOOL_A_PAUSE_HEADER] = { .type = NLA_NESTED }, 20 + [ETHTOOL_A_PAUSE_HEADER] = 21 + NLA_POLICY_NESTED(ethnl_header_policy), 21 22 }; 22 23 23 24 static void ethtool_stats_init(u64 *stats, unsigned int n) ··· 136 135 /* PAUSE_SET */ 137 136 138 137 const struct nla_policy ethnl_pause_set_policy[] = { 139 - [ETHTOOL_A_PAUSE_HEADER] = { .type = NLA_NESTED }, 138 + [ETHTOOL_A_PAUSE_HEADER] = 139 + NLA_POLICY_NESTED(ethnl_header_policy), 140 140 [ETHTOOL_A_PAUSE_AUTONEG] = { .type = NLA_U8 }, 141 141 [ETHTOOL_A_PAUSE_RX] = { .type = NLA_U8 }, 142 142 [ETHTOOL_A_PAUSE_TX] = { .type = NLA_U8 },
+4 -2
net/ethtool/privflags.c
··· 19 19 container_of(__reply_base, struct privflags_reply_data, base) 20 20 21 21 const struct nla_policy ethnl_privflags_get_policy[] = { 22 - [ETHTOOL_A_PRIVFLAGS_HEADER] = { .type = NLA_NESTED }, 22 + [ETHTOOL_A_PRIVFLAGS_HEADER] = 23 + NLA_POLICY_NESTED(ethnl_header_policy), 23 24 }; 24 25 25 26 static int ethnl_get_priv_flags_info(struct net_device *dev, ··· 134 133 /* PRIVFLAGS_SET */ 135 134 136 135 const struct nla_policy ethnl_privflags_set_policy[] = { 137 - [ETHTOOL_A_PRIVFLAGS_HEADER] = { .type = NLA_NESTED }, 136 + [ETHTOOL_A_PRIVFLAGS_HEADER] = 137 + NLA_POLICY_NESTED(ethnl_header_policy), 138 138 [ETHTOOL_A_PRIVFLAGS_FLAGS] = { .type = NLA_NESTED }, 139 139 }; 140 140
+4 -2
net/ethtool/rings.c
··· 16 16 container_of(__reply_base, struct rings_reply_data, base) 17 17 18 18 const struct nla_policy ethnl_rings_get_policy[] = { 19 - [ETHTOOL_A_RINGS_HEADER] = { .type = NLA_NESTED }, 19 + [ETHTOOL_A_RINGS_HEADER] = 20 + NLA_POLICY_NESTED(ethnl_header_policy), 20 21 }; 21 22 22 23 static int rings_prepare_data(const struct ethnl_req_info *req_base, ··· 99 98 /* RINGS_SET */ 100 99 101 100 const struct nla_policy ethnl_rings_set_policy[] = { 102 - [ETHTOOL_A_RINGS_HEADER] = { .type = NLA_NESTED }, 101 + [ETHTOOL_A_RINGS_HEADER] = 102 + NLA_POLICY_NESTED(ethnl_header_policy), 103 103 [ETHTOOL_A_RINGS_RX] = { .type = NLA_U32 }, 104 104 [ETHTOOL_A_RINGS_RX_MINI] = { .type = NLA_U32 }, 105 105 [ETHTOOL_A_RINGS_RX_JUMBO] = { .type = NLA_U32 },
+2 -1
net/ethtool/strset.c
··· 100 100 container_of(__reply_base, struct strset_reply_data, base) 101 101 102 102 const struct nla_policy ethnl_strset_get_policy[] = { 103 - [ETHTOOL_A_STRSET_HEADER] = { .type = NLA_NESTED }, 103 + [ETHTOOL_A_STRSET_HEADER] = 104 + NLA_POLICY_NESTED(ethnl_header_policy), 104 105 [ETHTOOL_A_STRSET_STRINGSETS] = { .type = NLA_NESTED }, 105 106 }; 106 107
+2 -1
net/ethtool/tsinfo.c
··· 19 19 container_of(__reply_base, struct tsinfo_reply_data, base) 20 20 21 21 const struct nla_policy ethnl_tsinfo_get_policy[] = { 22 - [ETHTOOL_A_TSINFO_HEADER] = { .type = NLA_NESTED }, 22 + [ETHTOOL_A_TSINFO_HEADER] = 23 + NLA_POLICY_NESTED(ethnl_header_policy), 23 24 }; 24 25 25 26 static int tsinfo_prepare_data(const struct ethnl_req_info *req_base,
+2 -1
net/ethtool/tunnels.c
··· 9 9 #include "netlink.h" 10 10 11 11 const struct nla_policy ethnl_tunnel_info_get_policy[] = { 12 - [ETHTOOL_A_TUNNEL_INFO_HEADER] = { .type = NLA_NESTED }, 12 + [ETHTOOL_A_TUNNEL_INFO_HEADER] = 13 + NLA_POLICY_NESTED(ethnl_header_policy), 13 14 }; 14 15 15 16 static_assert(ETHTOOL_UDP_TUNNEL_TYPE_VXLAN == ilog2(UDP_TUNNEL_TYPE_VXLAN));
+4 -2
net/ethtool/wol.c
··· 18 18 container_of(__reply_base, struct wol_reply_data, base) 19 19 20 20 const struct nla_policy ethnl_wol_get_policy[] = { 21 - [ETHTOOL_A_WOL_HEADER] = { .type = NLA_NESTED }, 21 + [ETHTOOL_A_WOL_HEADER] = 22 + NLA_POLICY_NESTED(ethnl_header_policy), 22 23 }; 23 24 24 25 static int wol_prepare_data(const struct ethnl_req_info *req_base, ··· 97 96 /* WOL_SET */ 98 97 99 98 const struct nla_policy ethnl_wol_set_policy[] = { 100 - [ETHTOOL_A_WOL_HEADER] = { .type = NLA_NESTED }, 99 + [ETHTOOL_A_WOL_HEADER] = 100 + NLA_POLICY_NESTED(ethnl_header_policy), 101 101 [ETHTOOL_A_WOL_MODES] = { .type = NLA_NESTED }, 102 102 [ETHTOOL_A_WOL_SOPASS] = { .type = NLA_BINARY, 103 103 .len = SOPASS_MAX },