Skip to content

Commit c21ef3e

Browse files
David Aherndavem330
authored andcommitted
net: rtnetlink: plumb extended ack to doit function
Add netlink_ext_ack arg to rtnl_doit_func. Pass extack arg to nlmsg_parse for doit functions that call it directly. This is the first step to using extended error reporting in rtnetlink. >From here individual subsystems can be updated to set netlink_ext_ack as needed. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent af3b515 commit c21ef3e

26 files changed

Lines changed: 162 additions & 99 deletions

‎drivers/net/vrf.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,11 +1282,11 @@ static int vrf_fib_rule(const struct net_device *dev, __u8 family, bool add_it)
12821282
/* fib_nl_{new,del}rule handling looks for net from skb->sk */
12831283
skb->sk = dev_net(dev)->rtnl;
12841284
if (add_it) {
1285-
err = fib_nl_newrule(skb, nlh);
1285+
err = fib_nl_newrule(skb, nlh, NULL);
12861286
if (err == -EEXIST)
12871287
err = 0;
12881288
} else {
1289-
err = fib_nl_delrule(skb, nlh);
1289+
err = fib_nl_delrule(skb, nlh, NULL);
12901290
if (err == -ENOENT)
12911291
err = 0;
12921292
}

‎include/net/fib_rules.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ int fib_default_rule_add(struct fib_rules_ops *, u32 pref, u32 table,
143143
u32 flags);
144144
bool fib_rule_matchall(const struct fib_rule *rule);
145145

146-
int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh);
147-
int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh);
146+
int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
147+
struct netlink_ext_ack *extack);
148+
int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh,
149+
struct netlink_ext_ack *extack);
148150
#endif

‎include/net/rtnetlink.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#include <linux/rtnetlink.h>
55
#include <net/netlink.h>
66

7-
typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *);
7+
typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *,
8+
struct netlink_ext_ack *);
89
typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *);
910
typedef u16 (*rtnl_calcit_func)(struct sk_buff *, struct nlmsghdr *);
1011

‎net/bridge/br_mdb.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br,
569569
return ret;
570570
}
571571

572-
static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh)
572+
static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
573+
struct netlink_ext_ack *extack)
573574
{
574575
struct net *net = sock_net(skb->sk);
575576
struct net_bridge_vlan_group *vg;
@@ -663,7 +664,8 @@ static int __br_mdb_del(struct net_bridge *br, struct br_mdb_entry *entry)
663664
return err;
664665
}
665666

666-
static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh)
667+
static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
668+
struct netlink_ext_ack *extack)
667669
{
668670
struct net *net = sock_net(skb->sk);
669671
struct net_bridge_vlan_group *vg;

‎net/can/gw.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,8 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
809809
return 0;
810810
}
811811

812-
static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh)
812+
static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh,
813+
struct netlink_ext_ack *extack)
813814
{
814815
struct rtcanmsg *r;
815816
struct cgw_job *gwj;
@@ -921,7 +922,8 @@ static void cgw_remove_all_jobs(void)
921922
}
922923
}
923924

924-
static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
925+
static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh,
926+
struct netlink_ext_ack *extack)
925927
{
926928
struct cgw_job *gwj = NULL;
927929
struct hlist_node *nx;

‎net/core/fib_rules.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ static int rule_exists(struct fib_rules_ops *ops, struct fib_rule_hdr *frh,
368368
return 0;
369369
}
370370

371-
int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh)
371+
int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
372+
struct netlink_ext_ack *extack)
372373
{
373374
struct net *net = sock_net(skb->sk);
374375
struct fib_rule_hdr *frh = nlmsg_data(nlh);
@@ -386,7 +387,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh)
386387
goto errout;
387388
}
388389

389-
err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy, NULL);
390+
err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy, extack);
390391
if (err < 0)
391392
goto errout;
392393

@@ -561,7 +562,8 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh)
561562
}
562563
EXPORT_SYMBOL_GPL(fib_nl_newrule);
563564

564-
int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh)
565+
int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh,
566+
struct netlink_ext_ack *extack)
565567
{
566568
struct net *net = sock_net(skb->sk);
567569
struct fib_rule_hdr *frh = nlmsg_data(nlh);
@@ -580,7 +582,7 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh)
580582
goto errout;
581583
}
582584

583-
err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy, NULL);
585+
err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy, extack);
584586
if (err < 0)
585587
goto errout;
586588

‎net/core/neighbour.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,8 @@ static struct neigh_table *neigh_find_table(int family)
15901590
return tbl;
15911591
}
15921592

1593-
static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh)
1593+
static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh,
1594+
struct netlink_ext_ack *extack)
15941595
{
15951596
struct net *net = sock_net(skb->sk);
15961597
struct ndmsg *ndm;
@@ -1648,7 +1649,8 @@ static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh)
16481649
return err;
16491650
}
16501651

1651-
static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh)
1652+
static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh,
1653+
struct netlink_ext_ack *extack)
16521654
{
16531655
int flags = NEIGH_UPDATE_F_ADMIN | NEIGH_UPDATE_F_OVERRIDE;
16541656
struct net *net = sock_net(skb->sk);
@@ -1661,7 +1663,7 @@ static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh)
16611663
int err;
16621664

16631665
ASSERT_RTNL();
1664-
err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL, NULL);
1666+
err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL, extack);
16651667
if (err < 0)
16661668
goto out;
16671669

@@ -1936,7 +1938,8 @@ static const struct nla_policy nl_ntbl_parm_policy[NDTPA_MAX+1] = {
19361938
[NDTPA_LOCKTIME] = { .type = NLA_U64 },
19371939
};
19381940

1939-
static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh)
1941+
static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh,
1942+
struct netlink_ext_ack *extack)
19401943
{
19411944
struct net *net = sock_net(skb->sk);
19421945
struct neigh_table *tbl;
@@ -1946,7 +1949,7 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh)
19461949
int err, tidx;
19471950

19481951
err = nlmsg_parse(nlh, sizeof(*ndtmsg), tb, NDTA_MAX,
1949-
nl_neightbl_policy, NULL);
1952+
nl_neightbl_policy, extack);
19501953
if (err < 0)
19511954
goto errout;
19521955

@@ -1984,7 +1987,7 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh)
19841987
int i, ifindex = 0;
19851988

19861989
err = nla_parse_nested(tbp, NDTPA_MAX, tb[NDTA_PARMS],
1987-
nl_ntbl_parm_policy, NULL);
1990+
nl_ntbl_parm_policy, extack);
19881991
if (err < 0)
19891992
goto errout_tbl_lock;
19901993

‎net/core/net_namespace.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,16 @@ static const struct nla_policy rtnl_net_policy[NETNSA_MAX + 1] = {
571571
[NETNSA_FD] = { .type = NLA_U32 },
572572
};
573573

574-
static int rtnl_net_newid(struct sk_buff *skb, struct nlmsghdr *nlh)
574+
static int rtnl_net_newid(struct sk_buff *skb, struct nlmsghdr *nlh,
575+
struct netlink_ext_ack *extack)
575576
{
576577
struct net *net = sock_net(skb->sk);
577578
struct nlattr *tb[NETNSA_MAX + 1];
578579
struct net *peer;
579580
int nsid, err;
580581

581582
err = nlmsg_parse(nlh, sizeof(struct rtgenmsg), tb, NETNSA_MAX,
582-
rtnl_net_policy, NULL);
583+
rtnl_net_policy, extack);
583584
if (err < 0)
584585
return err;
585586
if (!tb[NETNSA_NSID])
@@ -644,7 +645,8 @@ static int rtnl_net_fill(struct sk_buff *skb, u32 portid, u32 seq, int flags,
644645
return -EMSGSIZE;
645646
}
646647

647-
static int rtnl_net_getid(struct sk_buff *skb, struct nlmsghdr *nlh)
648+
static int rtnl_net_getid(struct sk_buff *skb, struct nlmsghdr *nlh,
649+
struct netlink_ext_ack *extack)
648650
{
649651
struct net *net = sock_net(skb->sk);
650652
struct nlattr *tb[NETNSA_MAX + 1];
@@ -653,7 +655,7 @@ static int rtnl_net_getid(struct sk_buff *skb, struct nlmsghdr *nlh)
653655
int err, id;
654656

655657
err = nlmsg_parse(nlh, sizeof(struct rtgenmsg), tb, NETNSA_MAX,
656-
rtnl_net_policy, NULL);
658+
rtnl_net_policy, extack);
657659
if (err < 0)
658660
return err;
659661
if (tb[NETNSA_PID])

‎net/core/rtnetlink.c‎

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,7 +2213,8 @@ static int do_setlink(const struct sk_buff *skb,
22132213
return err;
22142214
}
22152215

2216-
static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh)
2216+
static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
2217+
struct netlink_ext_ack *extack)
22172218
{
22182219
struct net *net = sock_net(skb->sk);
22192220
struct ifinfomsg *ifm;
@@ -2222,7 +2223,8 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh)
22222223
struct nlattr *tb[IFLA_MAX+1];
22232224
char ifname[IFNAMSIZ];
22242225

2225-
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy, NULL);
2226+
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy,
2227+
extack);
22262228
if (err < 0)
22272229
goto errout;
22282230

@@ -2306,7 +2308,8 @@ int rtnl_delete_link(struct net_device *dev)
23062308
}
23072309
EXPORT_SYMBOL_GPL(rtnl_delete_link);
23082310

2309-
static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh)
2311+
static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh,
2312+
struct netlink_ext_ack *extack)
23102313
{
23112314
struct net *net = sock_net(skb->sk);
23122315
struct net_device *dev;
@@ -2315,7 +2318,7 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh)
23152318
struct nlattr *tb[IFLA_MAX+1];
23162319
int err;
23172320

2318-
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy, NULL);
2321+
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy, extack);
23192322
if (err < 0)
23202323
return err;
23212324

@@ -2426,7 +2429,8 @@ static int rtnl_group_changelink(const struct sk_buff *skb,
24262429
return 0;
24272430
}
24282431

2429-
static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
2432+
static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
2433+
struct netlink_ext_ack *extack)
24302434
{
24312435
struct net *net = sock_net(skb->sk);
24322436
const struct rtnl_link_ops *ops;
@@ -2444,7 +2448,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
24442448
#ifdef CONFIG_MODULES
24452449
replay:
24462450
#endif
2447-
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy, NULL);
2451+
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy, extack);
24482452
if (err < 0)
24492453
return err;
24502454

@@ -2678,7 +2682,8 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
26782682
}
26792683
}
26802684

2681-
static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh)
2685+
static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr *nlh,
2686+
struct netlink_ext_ack *extack)
26822687
{
26832688
struct net *net = sock_net(skb->sk);
26842689
struct ifinfomsg *ifm;
@@ -2689,7 +2694,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh)
26892694
int err;
26902695
u32 ext_filter_mask = 0;
26912696

2692-
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy, NULL);
2697+
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy, extack);
26932698
if (err < 0)
26942699
return err;
26952700

@@ -2960,7 +2965,8 @@ static int fdb_vid_parse(struct nlattr *vlan_attr, u16 *p_vid)
29602965
return 0;
29612966
}
29622967

2963-
static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh)
2968+
static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
2969+
struct netlink_ext_ack *extack)
29642970
{
29652971
struct net *net = sock_net(skb->sk);
29662972
struct ndmsg *ndm;
@@ -2970,7 +2976,7 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh)
29702976
u16 vid;
29712977
int err;
29722978

2973-
err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL, NULL);
2979+
err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL, extack);
29742980
if (err < 0)
29752981
return err;
29762982

@@ -3060,7 +3066,8 @@ int ndo_dflt_fdb_del(struct ndmsg *ndm,
30603066
}
30613067
EXPORT_SYMBOL(ndo_dflt_fdb_del);
30623068

3063-
static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh)
3069+
static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
3070+
struct netlink_ext_ack *extack)
30643071
{
30653072
struct net *net = sock_net(skb->sk);
30663073
struct ndmsg *ndm;
@@ -3073,7 +3080,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh)
30733080
if (!netlink_capable(skb, CAP_NET_ADMIN))
30743081
return -EPERM;
30753082

3076-
err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL, NULL);
3083+
err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL, extack);
30773084
if (err < 0)
30783085
return err;
30793086

@@ -3503,7 +3510,8 @@ static int rtnl_bridge_notify(struct net_device *dev)
35033510
return err;
35043511
}
35053512

3506-
static int rtnl_bridge_setlink(struct sk_buff *skb, struct nlmsghdr *nlh)
3513+
static int rtnl_bridge_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
3514+
struct netlink_ext_ack *extack)
35073515
{
35083516
struct net *net = sock_net(skb->sk);
35093517
struct ifinfomsg *ifm;
@@ -3577,7 +3585,8 @@ static int rtnl_bridge_setlink(struct sk_buff *skb, struct nlmsghdr *nlh)
35773585
return err;
35783586
}
35793587

3580-
static int rtnl_bridge_dellink(struct sk_buff *skb, struct nlmsghdr *nlh)
3588+
static int rtnl_bridge_dellink(struct sk_buff *skb, struct nlmsghdr *nlh,
3589+
struct netlink_ext_ack *extack)
35813590
{
35823591
struct net *net = sock_net(skb->sk);
35833592
struct ifinfomsg *ifm;
@@ -3945,7 +3954,8 @@ static size_t if_nlmsg_stats_size(const struct net_device *dev,
39453954
return size;
39463955
}
39473956

3948-
static int rtnl_stats_get(struct sk_buff *skb, struct nlmsghdr *nlh)
3957+
static int rtnl_stats_get(struct sk_buff *skb, struct nlmsghdr *nlh,
3958+
struct netlink_ext_ack *extack)
39493959
{
39503960
struct net *net = sock_net(skb->sk);
39513961
struct net_device *dev = NULL;
@@ -4107,7 +4117,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
41074117
if (doit == NULL)
41084118
return -EOPNOTSUPP;
41094119

4110-
return doit(skb, nlh);
4120+
return doit(skb, nlh, extack);
41114121
}
41124122

41134123
static void rtnetlink_rcv(struct sk_buff *skb)

‎net/dcb/dcbnl.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,8 @@ static const struct reply_func reply_funcs[DCB_CMD_MAX+1] = {
16961696
[DCB_CMD_CEE_GET] = { RTM_GETDCB, dcbnl_cee_get },
16971697
};
16981698

1699-
static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
1699+
static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
1700+
struct netlink_ext_ack *extack)
17001701
{
17011702
struct net *net = sock_net(skb->sk);
17021703
struct net_device *netdev;
@@ -1712,7 +1713,7 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
17121713
return -EPERM;
17131714

17141715
ret = nlmsg_parse(nlh, sizeof(*dcb), tb, DCB_ATTR_MAX,
1715-
dcbnl_rtnl_policy, NULL);
1716+
dcbnl_rtnl_policy, extack);
17161717
if (ret < 0)
17171718
return ret;
17181719

0 commit comments

Comments
 (0)