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

rtnl: make ifla_policy static

The only place this is used outside rtnetlink.c is veth. So provide
wrapper function for this usage.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jiri Pirko and committed by
David S. Miller
f7b12606 e83abe37

+74 -69
+4 -4
drivers/net/veth.c
··· 14 14 #include <linux/etherdevice.h> 15 15 #include <linux/u64_stats_sync.h> 16 16 17 + #include <net/rtnetlink.h> 17 18 #include <net/dst.h> 18 19 #include <net/xfrm.h> 19 20 #include <linux/veth.h> ··· 324 323 325 324 nla_peer = data[VETH_INFO_PEER]; 326 325 ifmp = nla_data(nla_peer); 327 - err = nla_parse(peer_tb, IFLA_MAX, 328 - nla_data(nla_peer) + sizeof(struct ifinfomsg), 329 - nla_len(nla_peer) - sizeof(struct ifinfomsg), 330 - ifla_policy); 326 + err = rtnl_nla_parse_ifla(peer_tb, 327 + nla_data(nla_peer) + sizeof(struct ifinfomsg), 328 + nla_len(nla_peer) - sizeof(struct ifinfomsg)); 331 329 if (err < 0) 332 330 return err; 333 331
+1 -1
include/net/rtnetlink.h
··· 140 140 struct nlattr *tb[]); 141 141 int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm); 142 142 143 - extern const struct nla_policy ifla_policy[IFLA_MAX+1]; 143 + int rtnl_nla_parse_ifla(struct nlattr **tb, const struct nlattr *head, int len); 144 144 145 145 #define MODULE_ALIAS_RTNL_LINK(kind) MODULE_ALIAS("rtnl-link-" kind) 146 146
+69 -64
net/core/rtnetlink.c
··· 1121 1121 return -EMSGSIZE; 1122 1122 } 1123 1123 1124 + static const struct nla_policy ifla_policy[IFLA_MAX+1] = { 1125 + [IFLA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ-1 }, 1126 + [IFLA_ADDRESS] = { .type = NLA_BINARY, .len = MAX_ADDR_LEN }, 1127 + [IFLA_BROADCAST] = { .type = NLA_BINARY, .len = MAX_ADDR_LEN }, 1128 + [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) }, 1129 + [IFLA_MTU] = { .type = NLA_U32 }, 1130 + [IFLA_LINK] = { .type = NLA_U32 }, 1131 + [IFLA_MASTER] = { .type = NLA_U32 }, 1132 + [IFLA_CARRIER] = { .type = NLA_U8 }, 1133 + [IFLA_TXQLEN] = { .type = NLA_U32 }, 1134 + [IFLA_WEIGHT] = { .type = NLA_U32 }, 1135 + [IFLA_OPERSTATE] = { .type = NLA_U8 }, 1136 + [IFLA_LINKMODE] = { .type = NLA_U8 }, 1137 + [IFLA_LINKINFO] = { .type = NLA_NESTED }, 1138 + [IFLA_NET_NS_PID] = { .type = NLA_U32 }, 1139 + [IFLA_NET_NS_FD] = { .type = NLA_U32 }, 1140 + [IFLA_IFALIAS] = { .type = NLA_STRING, .len = IFALIASZ-1 }, 1141 + [IFLA_VFINFO_LIST] = {. type = NLA_NESTED }, 1142 + [IFLA_VF_PORTS] = { .type = NLA_NESTED }, 1143 + [IFLA_PORT_SELF] = { .type = NLA_NESTED }, 1144 + [IFLA_AF_SPEC] = { .type = NLA_NESTED }, 1145 + [IFLA_EXT_MASK] = { .type = NLA_U32 }, 1146 + [IFLA_PROMISCUITY] = { .type = NLA_U32 }, 1147 + [IFLA_NUM_TX_QUEUES] = { .type = NLA_U32 }, 1148 + [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 }, 1149 + [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_PORT_ID_LEN }, 1150 + }; 1151 + 1152 + static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { 1153 + [IFLA_INFO_KIND] = { .type = NLA_STRING }, 1154 + [IFLA_INFO_DATA] = { .type = NLA_NESTED }, 1155 + [IFLA_INFO_SLAVE_KIND] = { .type = NLA_STRING }, 1156 + [IFLA_INFO_SLAVE_DATA] = { .type = NLA_NESTED }, 1157 + }; 1158 + 1159 + static const struct nla_policy ifla_vfinfo_policy[IFLA_VF_INFO_MAX+1] = { 1160 + [IFLA_VF_INFO] = { .type = NLA_NESTED }, 1161 + }; 1162 + 1163 + static const struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = { 1164 + [IFLA_VF_MAC] = { .type = NLA_BINARY, 1165 + .len = sizeof(struct ifla_vf_mac) }, 1166 + [IFLA_VF_VLAN] = { .type = NLA_BINARY, 1167 + .len = sizeof(struct ifla_vf_vlan) }, 1168 + [IFLA_VF_TX_RATE] = { .type = NLA_BINARY, 1169 + .len = sizeof(struct ifla_vf_tx_rate) }, 1170 + [IFLA_VF_SPOOFCHK] = { .type = NLA_BINARY, 1171 + .len = sizeof(struct ifla_vf_spoofchk) }, 1172 + }; 1173 + 1174 + static const struct nla_policy ifla_port_policy[IFLA_PORT_MAX+1] = { 1175 + [IFLA_PORT_VF] = { .type = NLA_U32 }, 1176 + [IFLA_PORT_PROFILE] = { .type = NLA_STRING, 1177 + .len = PORT_PROFILE_MAX }, 1178 + [IFLA_PORT_VSI_TYPE] = { .type = NLA_BINARY, 1179 + .len = sizeof(struct ifla_port_vsi)}, 1180 + [IFLA_PORT_INSTANCE_UUID] = { .type = NLA_BINARY, 1181 + .len = PORT_UUID_MAX }, 1182 + [IFLA_PORT_HOST_UUID] = { .type = NLA_STRING, 1183 + .len = PORT_UUID_MAX }, 1184 + [IFLA_PORT_REQUEST] = { .type = NLA_U8, }, 1185 + [IFLA_PORT_RESPONSE] = { .type = NLA_U16, }, 1186 + }; 1187 + 1124 1188 static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) 1125 1189 { 1126 1190 struct net *net = sock_net(skb->sk); ··· 1234 1170 return skb->len; 1235 1171 } 1236 1172 1237 - const struct nla_policy ifla_policy[IFLA_MAX+1] = { 1238 - [IFLA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ-1 }, 1239 - [IFLA_ADDRESS] = { .type = NLA_BINARY, .len = MAX_ADDR_LEN }, 1240 - [IFLA_BROADCAST] = { .type = NLA_BINARY, .len = MAX_ADDR_LEN }, 1241 - [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) }, 1242 - [IFLA_MTU] = { .type = NLA_U32 }, 1243 - [IFLA_LINK] = { .type = NLA_U32 }, 1244 - [IFLA_MASTER] = { .type = NLA_U32 }, 1245 - [IFLA_CARRIER] = { .type = NLA_U8 }, 1246 - [IFLA_TXQLEN] = { .type = NLA_U32 }, 1247 - [IFLA_WEIGHT] = { .type = NLA_U32 }, 1248 - [IFLA_OPERSTATE] = { .type = NLA_U8 }, 1249 - [IFLA_LINKMODE] = { .type = NLA_U8 }, 1250 - [IFLA_LINKINFO] = { .type = NLA_NESTED }, 1251 - [IFLA_NET_NS_PID] = { .type = NLA_U32 }, 1252 - [IFLA_NET_NS_FD] = { .type = NLA_U32 }, 1253 - [IFLA_IFALIAS] = { .type = NLA_STRING, .len = IFALIASZ-1 }, 1254 - [IFLA_VFINFO_LIST] = {. type = NLA_NESTED }, 1255 - [IFLA_VF_PORTS] = { .type = NLA_NESTED }, 1256 - [IFLA_PORT_SELF] = { .type = NLA_NESTED }, 1257 - [IFLA_AF_SPEC] = { .type = NLA_NESTED }, 1258 - [IFLA_EXT_MASK] = { .type = NLA_U32 }, 1259 - [IFLA_PROMISCUITY] = { .type = NLA_U32 }, 1260 - [IFLA_NUM_TX_QUEUES] = { .type = NLA_U32 }, 1261 - [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 }, 1262 - [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_PORT_ID_LEN }, 1263 - }; 1264 - EXPORT_SYMBOL(ifla_policy); 1265 - 1266 - static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { 1267 - [IFLA_INFO_KIND] = { .type = NLA_STRING }, 1268 - [IFLA_INFO_DATA] = { .type = NLA_NESTED }, 1269 - [IFLA_INFO_SLAVE_KIND] = { .type = NLA_STRING }, 1270 - [IFLA_INFO_SLAVE_DATA] = { .type = NLA_NESTED }, 1271 - }; 1272 - 1273 - static const struct nla_policy ifla_vfinfo_policy[IFLA_VF_INFO_MAX+1] = { 1274 - [IFLA_VF_INFO] = { .type = NLA_NESTED }, 1275 - }; 1276 - 1277 - static const struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = { 1278 - [IFLA_VF_MAC] = { .type = NLA_BINARY, 1279 - .len = sizeof(struct ifla_vf_mac) }, 1280 - [IFLA_VF_VLAN] = { .type = NLA_BINARY, 1281 - .len = sizeof(struct ifla_vf_vlan) }, 1282 - [IFLA_VF_TX_RATE] = { .type = NLA_BINARY, 1283 - .len = sizeof(struct ifla_vf_tx_rate) }, 1284 - [IFLA_VF_SPOOFCHK] = { .type = NLA_BINARY, 1285 - .len = sizeof(struct ifla_vf_spoofchk) }, 1286 - }; 1287 - 1288 - static const struct nla_policy ifla_port_policy[IFLA_PORT_MAX+1] = { 1289 - [IFLA_PORT_VF] = { .type = NLA_U32 }, 1290 - [IFLA_PORT_PROFILE] = { .type = NLA_STRING, 1291 - .len = PORT_PROFILE_MAX }, 1292 - [IFLA_PORT_VSI_TYPE] = { .type = NLA_BINARY, 1293 - .len = sizeof(struct ifla_port_vsi)}, 1294 - [IFLA_PORT_INSTANCE_UUID] = { .type = NLA_BINARY, 1295 - .len = PORT_UUID_MAX }, 1296 - [IFLA_PORT_HOST_UUID] = { .type = NLA_STRING, 1297 - .len = PORT_UUID_MAX }, 1298 - [IFLA_PORT_REQUEST] = { .type = NLA_U8, }, 1299 - [IFLA_PORT_RESPONSE] = { .type = NLA_U16, }, 1300 - }; 1173 + int rtnl_nla_parse_ifla(struct nlattr **tb, const struct nlattr *head, int len) 1174 + { 1175 + return nla_parse(tb, IFLA_MAX, head, len, ifla_policy); 1176 + } 1177 + EXPORT_SYMBOL(rtnl_nla_parse_ifla); 1301 1178 1302 1179 struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]) 1303 1180 {