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

net: add netlink_ext_ack argument to rtnl_link_ops.validate

Add support for extended error reporting.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Acked-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Matthias Schiffer and committed by
David S. Miller
a8b8a889 ad744b22

+63 -33
+2 -1
drivers/net/bonding/bond_netlink.c
··· 118 118 [IFLA_BOND_SLAVE_QUEUE_ID] = { .type = NLA_U16 }, 119 119 }; 120 120 121 - static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) 121 + static int bond_validate(struct nlattr *tb[], struct nlattr *data[], 122 + struct netlink_ext_ack *extack) 122 123 { 123 124 if (tb[IFLA_ADDRESS]) { 124 125 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
+2 -1
drivers/net/can/dev.c
··· 848 848 = { .len = sizeof(struct can_bittiming_const) }, 849 849 }; 850 850 851 - static int can_validate(struct nlattr *tb[], struct nlattr *data[]) 851 + static int can_validate(struct nlattr *tb[], struct nlattr *data[], 852 + struct netlink_ext_ack *extack) 852 853 { 853 854 bool is_can_fd = false; 854 855
+2 -1
drivers/net/dummy.c
··· 356 356 dev->max_mtu = ETH_MAX_MTU; 357 357 } 358 358 359 - static int dummy_validate(struct nlattr *tb[], struct nlattr *data[]) 359 + static int dummy_validate(struct nlattr *tb[], struct nlattr *data[], 360 + struct netlink_ext_ack *extack) 360 361 { 361 362 if (tb[IFLA_ADDRESS]) { 362 363 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
+2 -1
drivers/net/geneve.c
··· 1058 1058 [IFLA_GENEVE_UDP_ZERO_CSUM6_RX] = { .type = NLA_U8 }, 1059 1059 }; 1060 1060 1061 - static int geneve_validate(struct nlattr *tb[], struct nlattr *data[]) 1061 + static int geneve_validate(struct nlattr *tb[], struct nlattr *data[], 1062 + struct netlink_ext_ack *extack) 1062 1063 { 1063 1064 if (tb[IFLA_ADDRESS]) { 1064 1065 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
+2 -1
drivers/net/gtp.c
··· 698 698 [IFLA_GTP_ROLE] = { .type = NLA_U32 }, 699 699 }; 700 700 701 - static int gtp_validate(struct nlattr *tb[], struct nlattr *data[]) 701 + static int gtp_validate(struct nlattr *tb[], struct nlattr *data[], 702 + struct netlink_ext_ack *extack) 702 703 { 703 704 if (!data) 704 705 return -EINVAL;
+2 -1
drivers/net/ifb.c
··· 273 273 return 0; 274 274 } 275 275 276 - static int ifb_validate(struct nlattr *tb[], struct nlattr *data[]) 276 + static int ifb_validate(struct nlattr *tb[], struct nlattr *data[], 277 + struct netlink_ext_ack *extack) 277 278 { 278 279 if (tb[IFLA_ADDRESS]) { 279 280 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
+2 -1
drivers/net/ipvlan/ipvlan_main.c
··· 477 477 ); 478 478 } 479 479 480 - static int ipvlan_nl_validate(struct nlattr *tb[], struct nlattr *data[]) 480 + static int ipvlan_nl_validate(struct nlattr *tb[], struct nlattr *data[], 481 + struct netlink_ext_ack *extack) 481 482 { 482 483 if (data && data[IFLA_IPVLAN_MODE]) { 483 484 u16 mode = nla_get_u16(data[IFLA_IPVLAN_MODE]);
+2 -1
drivers/net/macsec.c
··· 3287 3287 return err; 3288 3288 } 3289 3289 3290 - static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[]) 3290 + static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[], 3291 + struct netlink_ext_ack *extack) 3291 3292 { 3292 3293 u64 csid = MACSEC_DEFAULT_CIPHER_ID; 3293 3294 u8 icv_len = DEFAULT_ICV_LEN;
+2 -1
drivers/net/macvlan.c
··· 1162 1162 kfree(port); 1163 1163 } 1164 1164 1165 - static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[]) 1165 + static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[], 1166 + struct netlink_ext_ack *extack) 1166 1167 { 1167 1168 if (tb[IFLA_ADDRESS]) { 1168 1169 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
+2 -1
drivers/net/nlmon.c
··· 127 127 dev->min_mtu = sizeof(struct nlmsghdr); 128 128 } 129 129 130 - static int nlmon_validate(struct nlattr *tb[], struct nlattr *data[]) 130 + static int nlmon_validate(struct nlattr *tb[], struct nlattr *data[], 131 + struct netlink_ext_ack *extack) 131 132 { 132 133 if (tb[IFLA_ADDRESS]) 133 134 return -EINVAL;
+2 -1
drivers/net/ppp/ppp_generic.c
··· 1061 1061 [IFLA_PPP_DEV_FD] = { .type = NLA_S32 }, 1062 1062 }; 1063 1063 1064 - static int ppp_nl_validate(struct nlattr *tb[], struct nlattr *data[]) 1064 + static int ppp_nl_validate(struct nlattr *tb[], struct nlattr *data[], 1065 + struct netlink_ext_ack *extack) 1065 1066 { 1066 1067 if (!data) 1067 1068 return -EINVAL;
+2 -1
drivers/net/team/team.c
··· 2110 2110 return register_netdevice(dev); 2111 2111 } 2112 2112 2113 - static int team_validate(struct nlattr *tb[], struct nlattr *data[]) 2113 + static int team_validate(struct nlattr *tb[], struct nlattr *data[], 2114 + struct netlink_ext_ack *extack) 2114 2115 { 2115 2116 if (tb[IFLA_ADDRESS]) { 2116 2117 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
+2 -1
drivers/net/tun.c
··· 1580 1580 /* Trivial set of netlink ops to allow deleting tun or tap 1581 1581 * device with netlink. 1582 1582 */ 1583 - static int tun_validate(struct nlattr *tb[], struct nlattr *data[]) 1583 + static int tun_validate(struct nlattr *tb[], struct nlattr *data[], 1584 + struct netlink_ext_ack *extack) 1584 1585 { 1585 1586 return -EINVAL; 1586 1587 }
+3 -2
drivers/net/veth.c
··· 329 329 * netlink interface 330 330 */ 331 331 332 - static int veth_validate(struct nlattr *tb[], struct nlattr *data[]) 332 + static int veth_validate(struct nlattr *tb[], struct nlattr *data[], 333 + struct netlink_ext_ack *extack) 333 334 { 334 335 if (tb[IFLA_ADDRESS]) { 335 336 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) ··· 375 374 if (err < 0) 376 375 return err; 377 376 378 - err = veth_validate(peer_tb, NULL); 377 + err = veth_validate(peer_tb, NULL, extack); 379 378 if (err < 0) 380 379 return err; 381 380
+2 -1
drivers/net/vrf.c
··· 1372 1372 dev->priv_flags |= IFF_NO_QUEUE; 1373 1373 } 1374 1374 1375 - static int vrf_validate(struct nlattr *tb[], struct nlattr *data[]) 1375 + static int vrf_validate(struct nlattr *tb[], struct nlattr *data[], 1376 + struct netlink_ext_ack *extack) 1376 1377 { 1377 1378 if (tb[IFLA_ADDRESS]) { 1378 1379 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
+2 -1
drivers/net/vxlan.c
··· 2711 2711 [IFLA_VXLAN_REMCSUM_NOPARTIAL] = { .type = NLA_FLAG }, 2712 2712 }; 2713 2713 2714 - static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[]) 2714 + static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[], 2715 + struct netlink_ext_ack *extack) 2715 2716 { 2716 2717 if (tb[IFLA_ADDRESS]) { 2717 2718 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) {
+2 -1
include/net/rtnetlink.h
··· 63 63 int maxtype; 64 64 const struct nla_policy *policy; 65 65 int (*validate)(struct nlattr *tb[], 66 - struct nlattr *data[]); 66 + struct nlattr *data[], 67 + struct netlink_ext_ack *extack); 67 68 68 69 int (*newlink)(struct net *src_net, 69 70 struct net_device *dev,
+2 -1
net/8021q/vlan_netlink.c
··· 39 39 NULL); 40 40 } 41 41 42 - static int vlan_validate(struct nlattr *tb[], struct nlattr *data[]) 42 + static int vlan_validate(struct nlattr *tb[], struct nlattr *data[], 43 + struct netlink_ext_ack *extack) 43 44 { 44 45 struct ifla_vlan_flags *flags; 45 46 u16 id;
+3 -1
net/bridge/br_netlink.c
··· 858 858 859 859 return err; 860 860 } 861 - static int br_validate(struct nlattr *tb[], struct nlattr *data[]) 861 + 862 + static int br_validate(struct nlattr *tb[], struct nlattr *data[], 863 + struct netlink_ext_ack *extack) 862 864 { 863 865 if (tb[IFLA_ADDRESS]) { 864 866 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
+1 -1
net/core/rtnetlink.c
··· 2582 2582 data = attr; 2583 2583 } 2584 2584 if (ops->validate) { 2585 - err = ops->validate(tb, data); 2585 + err = ops->validate(tb, data, extack); 2586 2586 if (err < 0) 2587 2587 return err; 2588 2588 }
+2 -1
net/ieee802154/6lowpan/core.c
··· 111 111 ldev->features |= NETIF_F_NETNS_LOCAL; 112 112 } 113 113 114 - static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[]) 114 + static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[], 115 + struct netlink_ext_ack *extack) 115 116 { 116 117 if (tb[IFLA_ADDRESS]) { 117 118 if (nla_len(tb[IFLA_ADDRESS]) != IEEE802154_ADDR_LEN)
+5 -3
net/ipv4/ip_gre.c
··· 779 779 .size = sizeof(struct ip_tunnel_net), 780 780 }; 781 781 782 - static int ipgre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[]) 782 + static int ipgre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[], 783 + struct netlink_ext_ack *extack) 783 784 { 784 785 __be16 flags; 785 786 ··· 803 802 return 0; 804 803 } 805 804 806 - static int ipgre_tap_validate(struct nlattr *tb[], struct nlattr *data[]) 805 + static int ipgre_tap_validate(struct nlattr *tb[], struct nlattr *data[], 806 + struct netlink_ext_ack *extack) 807 807 { 808 808 __be32 daddr; 809 809 ··· 825 823 } 826 824 827 825 out: 828 - return ipgre_tunnel_validate(tb, data); 826 + return ipgre_tunnel_validate(tb, data, extack); 829 827 } 830 828 831 829 static int ipgre_netlink_parms(struct net_device *dev,
+2 -1
net/ipv4/ip_vti.c
··· 465 465 .size = sizeof(struct ip_tunnel_net), 466 466 }; 467 467 468 - static int vti_tunnel_validate(struct nlattr *tb[], struct nlattr *data[]) 468 + static int vti_tunnel_validate(struct nlattr *tb[], struct nlattr *data[], 469 + struct netlink_ext_ack *extack) 469 470 { 470 471 return 0; 471 472 }
+2 -1
net/ipv4/ipip.c
··· 375 375 return ip_tunnel_init(dev); 376 376 } 377 377 378 - static int ipip_tunnel_validate(struct nlattr *tb[], struct nlattr *data[]) 378 + static int ipip_tunnel_validate(struct nlattr *tb[], struct nlattr *data[], 379 + struct netlink_ext_ack *extack) 379 380 { 380 381 u8 proto; 381 382
+5 -3
net/ipv6/ip6_gre.c
··· 1170 1170 .size = sizeof(struct ip6gre_net), 1171 1171 }; 1172 1172 1173 - static int ip6gre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[]) 1173 + static int ip6gre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[], 1174 + struct netlink_ext_ack *extack) 1174 1175 { 1175 1176 __be16 flags; 1176 1177 ··· 1189 1188 return 0; 1190 1189 } 1191 1190 1192 - static int ip6gre_tap_validate(struct nlattr *tb[], struct nlattr *data[]) 1191 + static int ip6gre_tap_validate(struct nlattr *tb[], struct nlattr *data[], 1192 + struct netlink_ext_ack *extack) 1193 1193 { 1194 1194 struct in6_addr daddr; 1195 1195 ··· 1211 1209 } 1212 1210 1213 1211 out: 1214 - return ip6gre_tunnel_validate(tb, data); 1212 + return ip6gre_tunnel_validate(tb, data, extack); 1215 1213 } 1216 1214 1217 1215
+2 -1
net/ipv6/ip6_tunnel.c
··· 1885 1885 return 0; 1886 1886 } 1887 1887 1888 - static int ip6_tnl_validate(struct nlattr *tb[], struct nlattr *data[]) 1888 + static int ip6_tnl_validate(struct nlattr *tb[], struct nlattr *data[], 1889 + struct netlink_ext_ack *extack) 1889 1890 { 1890 1891 u8 proto; 1891 1892
+2 -1
net/ipv6/ip6_vti.c
··· 907 907 return 0; 908 908 } 909 909 910 - static int vti6_validate(struct nlattr *tb[], struct nlattr *data[]) 910 + static int vti6_validate(struct nlattr *tb[], struct nlattr *data[], 911 + struct netlink_ext_ack *extack) 911 912 { 912 913 return 0; 913 914 }
+2 -1
net/ipv6/sit.c
··· 1406 1406 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel); 1407 1407 } 1408 1408 1409 - static int ipip6_validate(struct nlattr *tb[], struct nlattr *data[]) 1409 + static int ipip6_validate(struct nlattr *tb[], struct nlattr *data[], 1410 + struct netlink_ext_ack *extack) 1410 1411 { 1411 1412 u8 proto; 1412 1413