Commit 8679c31e authored by Rocco Yue's avatar Rocco Yue Committed by David S. Miller

net: add extack arg for link ops

Pass extack arg to validate_linkmsg and validate_link_af callbacks.
If a netlink attribute has a reject_message, use the extended ack
mechanism to carry the message back to user space.
Signed-off-by: default avatarRocco Yue <rocco.yue@mediatek.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 314001f0
...@@ -153,7 +153,8 @@ struct rtnl_af_ops { ...@@ -153,7 +153,8 @@ struct rtnl_af_ops {
u32 ext_filter_mask); u32 ext_filter_mask);
int (*validate_link_af)(const struct net_device *dev, int (*validate_link_af)(const struct net_device *dev,
const struct nlattr *attr); const struct nlattr *attr,
struct netlink_ext_ack *extack);
int (*set_link_af)(struct net_device *dev, int (*set_link_af)(struct net_device *dev,
const struct nlattr *attr, const struct nlattr *attr,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
......
...@@ -2257,7 +2257,8 @@ static int rtnl_ensure_unique_netns(struct nlattr *tb[], ...@@ -2257,7 +2257,8 @@ static int rtnl_ensure_unique_netns(struct nlattr *tb[],
return -EINVAL; return -EINVAL;
} }
static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[]) static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[],
struct netlink_ext_ack *extack)
{ {
if (dev) { if (dev) {
if (tb[IFLA_ADDRESS] && if (tb[IFLA_ADDRESS] &&
...@@ -2284,7 +2285,7 @@ static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[]) ...@@ -2284,7 +2285,7 @@ static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[])
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (af_ops->validate_link_af) { if (af_ops->validate_link_af) {
err = af_ops->validate_link_af(dev, af); err = af_ops->validate_link_af(dev, af, extack);
if (err < 0) if (err < 0)
return err; return err;
} }
...@@ -2592,7 +2593,7 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -2592,7 +2593,7 @@ static int do_setlink(const struct sk_buff *skb,
const struct net_device_ops *ops = dev->netdev_ops; const struct net_device_ops *ops = dev->netdev_ops;
int err; int err;
err = validate_linkmsg(dev, tb); err = validate_linkmsg(dev, tb, extack);
if (err < 0) if (err < 0)
return err; return err;
...@@ -3290,7 +3291,7 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -3290,7 +3291,7 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
m_ops = master_dev->rtnl_link_ops; m_ops = master_dev->rtnl_link_ops;
} }
err = validate_linkmsg(dev, tb); err = validate_linkmsg(dev, tb, extack);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -1950,7 +1950,8 @@ static const struct nla_policy inet_af_policy[IFLA_INET_MAX+1] = { ...@@ -1950,7 +1950,8 @@ static const struct nla_policy inet_af_policy[IFLA_INET_MAX+1] = {
}; };
static int inet_validate_link_af(const struct net_device *dev, static int inet_validate_link_af(const struct net_device *dev,
const struct nlattr *nla) const struct nlattr *nla,
struct netlink_ext_ack *extack)
{ {
struct nlattr *a, *tb[IFLA_INET_MAX+1]; struct nlattr *a, *tb[IFLA_INET_MAX+1];
int err, rem; int err, rem;
...@@ -1959,7 +1960,7 @@ static int inet_validate_link_af(const struct net_device *dev, ...@@ -1959,7 +1960,7 @@ static int inet_validate_link_af(const struct net_device *dev,
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
err = nla_parse_nested_deprecated(tb, IFLA_INET_MAX, nla, err = nla_parse_nested_deprecated(tb, IFLA_INET_MAX, nla,
inet_af_policy, NULL); inet_af_policy, extack);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -5792,7 +5792,8 @@ static int check_stable_privacy(struct inet6_dev *idev, struct net *net, ...@@ -5792,7 +5792,8 @@ static int check_stable_privacy(struct inet6_dev *idev, struct net *net,
} }
static int inet6_validate_link_af(const struct net_device *dev, static int inet6_validate_link_af(const struct net_device *dev,
const struct nlattr *nla) const struct nlattr *nla,
struct netlink_ext_ack *extack)
{ {
struct nlattr *tb[IFLA_INET6_MAX + 1]; struct nlattr *tb[IFLA_INET6_MAX + 1];
struct inet6_dev *idev = NULL; struct inet6_dev *idev = NULL;
...@@ -5805,7 +5806,7 @@ static int inet6_validate_link_af(const struct net_device *dev, ...@@ -5805,7 +5806,7 @@ static int inet6_validate_link_af(const struct net_device *dev,
} }
err = nla_parse_nested_deprecated(tb, IFLA_INET6_MAX, nla, err = nla_parse_nested_deprecated(tb, IFLA_INET6_MAX, nla,
inet6_af_policy, NULL); inet6_af_policy, extack);
if (err) if (err)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment