Skip to content

Commit 8679c31

Browse files
Rocco Yuedavem330
authored andcommitted
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: Rocco Yue <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 314001f commit 8679c31

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

include/net/rtnetlink.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ struct rtnl_af_ops {
153153
u32 ext_filter_mask);
154154

155155
int (*validate_link_af)(const struct net_device *dev,
156-
const struct nlattr *attr);
156+
const struct nlattr *attr,
157+
struct netlink_ext_ack *extack);
157158
int (*set_link_af)(struct net_device *dev,
158159
const struct nlattr *attr,
159160
struct netlink_ext_ack *extack);

net/core/rtnetlink.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,8 @@ static int rtnl_ensure_unique_netns(struct nlattr *tb[],
22572257
return -EINVAL;
22582258
}
22592259

2260-
static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[])
2260+
static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[],
2261+
struct netlink_ext_ack *extack)
22612262
{
22622263
if (dev) {
22632264
if (tb[IFLA_ADDRESS] &&
@@ -2284,7 +2285,7 @@ static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[])
22842285
return -EOPNOTSUPP;
22852286

22862287
if (af_ops->validate_link_af) {
2287-
err = af_ops->validate_link_af(dev, af);
2288+
err = af_ops->validate_link_af(dev, af, extack);
22882289
if (err < 0)
22892290
return err;
22902291
}
@@ -2592,7 +2593,7 @@ static int do_setlink(const struct sk_buff *skb,
25922593
const struct net_device_ops *ops = dev->netdev_ops;
25932594
int err;
25942595

2595-
err = validate_linkmsg(dev, tb);
2596+
err = validate_linkmsg(dev, tb, extack);
25962597
if (err < 0)
25972598
return err;
25982599

@@ -3290,7 +3291,7 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
32903291
m_ops = master_dev->rtnl_link_ops;
32913292
}
32923293

3293-
err = validate_linkmsg(dev, tb);
3294+
err = validate_linkmsg(dev, tb, extack);
32943295
if (err < 0)
32953296
return err;
32963297

net/ipv4/devinet.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,8 @@ static const struct nla_policy inet_af_policy[IFLA_INET_MAX+1] = {
19501950
};
19511951

19521952
static int inet_validate_link_af(const struct net_device *dev,
1953-
const struct nlattr *nla)
1953+
const struct nlattr *nla,
1954+
struct netlink_ext_ack *extack)
19541955
{
19551956
struct nlattr *a, *tb[IFLA_INET_MAX+1];
19561957
int err, rem;
@@ -1959,7 +1960,7 @@ static int inet_validate_link_af(const struct net_device *dev,
19591960
return -EAFNOSUPPORT;
19601961

19611962
err = nla_parse_nested_deprecated(tb, IFLA_INET_MAX, nla,
1962-
inet_af_policy, NULL);
1963+
inet_af_policy, extack);
19631964
if (err < 0)
19641965
return err;
19651966

net/ipv6/addrconf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5792,7 +5792,8 @@ static int check_stable_privacy(struct inet6_dev *idev, struct net *net,
57925792
}
57935793

57945794
static int inet6_validate_link_af(const struct net_device *dev,
5795-
const struct nlattr *nla)
5795+
const struct nlattr *nla,
5796+
struct netlink_ext_ack *extack)
57965797
{
57975798
struct nlattr *tb[IFLA_INET6_MAX + 1];
57985799
struct inet6_dev *idev = NULL;
@@ -5805,7 +5806,7 @@ static int inet6_validate_link_af(const struct net_device *dev,
58055806
}
58065807

58075808
err = nla_parse_nested_deprecated(tb, IFLA_INET6_MAX, nla,
5808-
inet6_af_policy, NULL);
5809+
inet6_af_policy, extack);
58095810
if (err)
58105811
return err;
58115812

0 commit comments

Comments
 (0)