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>
This commit is contained in:
parent
ad744b223c
commit
a8b8a889e3
|
@ -118,7 +118,8 @@ static const struct nla_policy bond_slave_policy[IFLA_BOND_SLAVE_MAX + 1] = {
|
|||
[IFLA_BOND_SLAVE_QUEUE_ID] = { .type = NLA_U16 },
|
||||
};
|
||||
|
||||
static int bond_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int bond_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
|
||||
|
|
|
@ -848,7 +848,8 @@ static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = {
|
|||
= { .len = sizeof(struct can_bittiming_const) },
|
||||
};
|
||||
|
||||
static int can_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int can_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
bool is_can_fd = false;
|
||||
|
||||
|
|
|
@ -356,7 +356,8 @@ static void dummy_setup(struct net_device *dev)
|
|||
dev->max_mtu = ETH_MAX_MTU;
|
||||
}
|
||||
|
||||
static int dummy_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int dummy_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
|
||||
|
|
|
@ -1058,7 +1058,8 @@ static const struct nla_policy geneve_policy[IFLA_GENEVE_MAX + 1] = {
|
|||
[IFLA_GENEVE_UDP_ZERO_CSUM6_RX] = { .type = NLA_U8 },
|
||||
};
|
||||
|
||||
static int geneve_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int geneve_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
|
||||
|
|
|
@ -698,7 +698,8 @@ static const struct nla_policy gtp_policy[IFLA_GTP_MAX + 1] = {
|
|||
[IFLA_GTP_ROLE] = { .type = NLA_U32 },
|
||||
};
|
||||
|
||||
static int gtp_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int gtp_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (!data)
|
||||
return -EINVAL;
|
||||
|
|
|
@ -273,7 +273,8 @@ static int ifb_open(struct net_device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ifb_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int ifb_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
|
||||
|
|
|
@ -477,7 +477,8 @@ static size_t ipvlan_nl_getsize(const struct net_device *dev)
|
|||
);
|
||||
}
|
||||
|
||||
static int ipvlan_nl_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int ipvlan_nl_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (data && data[IFLA_IPVLAN_MODE]) {
|
||||
u16 mode = nla_get_u16(data[IFLA_IPVLAN_MODE]);
|
||||
|
|
|
@ -3287,7 +3287,8 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
|
|||
return err;
|
||||
}
|
||||
|
||||
static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
u64 csid = MACSEC_DEFAULT_CIPHER_ID;
|
||||
u8 icv_len = DEFAULT_ICV_LEN;
|
||||
|
|
|
@ -1162,7 +1162,8 @@ static void macvlan_port_destroy(struct net_device *dev)
|
|||
kfree(port);
|
||||
}
|
||||
|
||||
static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
|
||||
|
|
|
@ -127,7 +127,8 @@ static void nlmon_setup(struct net_device *dev)
|
|||
dev->min_mtu = sizeof(struct nlmsghdr);
|
||||
}
|
||||
|
||||
static int nlmon_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int nlmon_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS])
|
||||
return -EINVAL;
|
||||
|
|
|
@ -1061,7 +1061,8 @@ static const struct nla_policy ppp_nl_policy[IFLA_PPP_MAX + 1] = {
|
|||
[IFLA_PPP_DEV_FD] = { .type = NLA_S32 },
|
||||
};
|
||||
|
||||
static int ppp_nl_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int ppp_nl_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (!data)
|
||||
return -EINVAL;
|
||||
|
|
|
@ -2110,7 +2110,8 @@ static int team_newlink(struct net *src_net, struct net_device *dev,
|
|||
return register_netdevice(dev);
|
||||
}
|
||||
|
||||
static int team_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int team_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
|
||||
|
|
|
@ -1580,7 +1580,8 @@ static void tun_setup(struct net_device *dev)
|
|||
/* Trivial set of netlink ops to allow deleting tun or tap
|
||||
* device with netlink.
|
||||
*/
|
||||
static int tun_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int tun_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -329,7 +329,8 @@ static void veth_setup(struct net_device *dev)
|
|||
* netlink interface
|
||||
*/
|
||||
|
||||
static int veth_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int veth_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
|
||||
|
@ -374,7 +375,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
|
|||
if (err < 0)
|
||||
return err;
|
||||
|
||||
err = veth_validate(peer_tb, NULL);
|
||||
err = veth_validate(peer_tb, NULL, extack);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
|
|
|
@ -1372,7 +1372,8 @@ static void vrf_setup(struct net_device *dev)
|
|||
dev->priv_flags |= IFF_NO_QUEUE;
|
||||
}
|
||||
|
||||
static int vrf_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int vrf_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
|
||||
|
|
|
@ -2711,7 +2711,8 @@ static const struct nla_policy vxlan_policy[IFLA_VXLAN_MAX + 1] = {
|
|||
[IFLA_VXLAN_REMCSUM_NOPARTIAL] = { .type = NLA_FLAG },
|
||||
};
|
||||
|
||||
static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) {
|
||||
|
|
|
@ -63,7 +63,8 @@ struct rtnl_link_ops {
|
|||
int maxtype;
|
||||
const struct nla_policy *policy;
|
||||
int (*validate)(struct nlattr *tb[],
|
||||
struct nlattr *data[]);
|
||||
struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack);
|
||||
|
||||
int (*newlink)(struct net *src_net,
|
||||
struct net_device *dev,
|
||||
|
|
|
@ -39,7 +39,8 @@ static inline int vlan_validate_qos_map(struct nlattr *attr)
|
|||
NULL);
|
||||
}
|
||||
|
||||
static int vlan_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int vlan_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct ifla_vlan_flags *flags;
|
||||
u16 id;
|
||||
|
|
|
@ -858,7 +858,9 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
|
|||
|
||||
return err;
|
||||
}
|
||||
static int br_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
|
||||
static int br_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
|
||||
|
|
|
@ -2582,7 +2582,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||
data = attr;
|
||||
}
|
||||
if (ops->validate) {
|
||||
err = ops->validate(tb, data);
|
||||
err = ops->validate(tb, data, extack);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,8 @@ static void lowpan_setup(struct net_device *ldev)
|
|||
ldev->features |= NETIF_F_NETNS_LOCAL;
|
||||
}
|
||||
|
||||
static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != IEEE802154_ADDR_LEN)
|
||||
|
|
|
@ -779,7 +779,8 @@ static struct pernet_operations ipgre_net_ops = {
|
|||
.size = sizeof(struct ip_tunnel_net),
|
||||
};
|
||||
|
||||
static int ipgre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int ipgre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
__be16 flags;
|
||||
|
||||
|
@ -802,7 +803,8 @@ static int ipgre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ipgre_tap_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int ipgre_tap_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
__be32 daddr;
|
||||
|
||||
|
@ -823,7 +825,7 @@ static int ipgre_tap_validate(struct nlattr *tb[], struct nlattr *data[])
|
|||
}
|
||||
|
||||
out:
|
||||
return ipgre_tunnel_validate(tb, data);
|
||||
return ipgre_tunnel_validate(tb, data, extack);
|
||||
}
|
||||
|
||||
static int ipgre_netlink_parms(struct net_device *dev,
|
||||
|
|
|
@ -465,7 +465,8 @@ static struct pernet_operations vti_net_ops = {
|
|||
.size = sizeof(struct ip_tunnel_net),
|
||||
};
|
||||
|
||||
static int vti_tunnel_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int vti_tunnel_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -375,7 +375,8 @@ static int ipip_tunnel_init(struct net_device *dev)
|
|||
return ip_tunnel_init(dev);
|
||||
}
|
||||
|
||||
static int ipip_tunnel_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int ipip_tunnel_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
u8 proto;
|
||||
|
||||
|
|
|
@ -1170,7 +1170,8 @@ static struct pernet_operations ip6gre_net_ops = {
|
|||
.size = sizeof(struct ip6gre_net),
|
||||
};
|
||||
|
||||
static int ip6gre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int ip6gre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
__be16 flags;
|
||||
|
||||
|
@ -1188,7 +1189,8 @@ static int ip6gre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ip6gre_tap_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int ip6gre_tap_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct in6_addr daddr;
|
||||
|
||||
|
@ -1209,7 +1211,7 @@ static int ip6gre_tap_validate(struct nlattr *tb[], struct nlattr *data[])
|
|||
}
|
||||
|
||||
out:
|
||||
return ip6gre_tunnel_validate(tb, data);
|
||||
return ip6gre_tunnel_validate(tb, data, extack);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1885,7 +1885,8 @@ static int __net_init ip6_fb_tnl_dev_init(struct net_device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ip6_tnl_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int ip6_tnl_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
u8 proto;
|
||||
|
||||
|
|
|
@ -907,7 +907,8 @@ static int __net_init vti6_fb_tnl_dev_init(struct net_device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int vti6_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int vti6_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1406,7 +1406,8 @@ static void __net_init ipip6_fb_tunnel_init(struct net_device *dev)
|
|||
rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
|
||||
}
|
||||
|
||||
static int ipip6_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
static int ipip6_validate(struct nlattr *tb[], struct nlattr *data[],
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
u8 proto;
|
||||
|
||||
|
|
Loading…
Reference in New Issue