Skip to content

Commit d89fa27

Browse files
author
Paolo Abeni
committed
Merge branch 'rtnetlink-refactor-rtnl_-new-del-set-link-for-per-netns-rtnl'
Kuniyuki Iwashima says: ==================== rtnetlink: Refactor rtnl_{new,del,set}link() for per-netns RTNL. This is a prep for the next series where we will push RTNL down to rtnl_{new,del,set}link(). That means, for example, __rtnl_newlink() is always under RTNL, but rtnl_newlink() has a non-RTNL section. As a prerequisite for per-netns RTNL, we will move netns validation (and RTNL-independent validations if possible) to that section. rtnl_link_ops and rtnl_af_ops will be protected with SRCU not to depend on RTNL. Changes: v2: * Add Eric's Reviewed-by to patch 1-4,6,8-11, (no tag on 5,7,12-14) * Patch 7 * Handle error of init_srcu_struct(). * Call cleanup_srcu_struct() after synchronize_srcu(). * Patch 12 * Move put_net() before errorout label * Patch 13 * Newly added as prep for patch 14 * Patch 14 * Handle error of init_srcu_struct(). * Call cleanup_srcu_struct() after synchronize_srcu(). v1: https://lore.kernel.org/netdev/[email protected]/ ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 6f07cd8 + 6ab0f86 commit d89fa27

File tree

7 files changed

+351
-263
lines changed

7 files changed

+351
-263
lines changed

include/net/rtnetlink.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define __NET_RTNETLINK_H
44

55
#include <linux/rtnetlink.h>
6+
#include <linux/srcu.h>
67
#include <net/netlink.h>
78

89
typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *,
@@ -69,7 +70,8 @@ static inline int rtnl_msg_family(const struct nlmsghdr *nlh)
6970
/**
7071
* struct rtnl_link_ops - rtnetlink link operations
7172
*
72-
* @list: Used internally
73+
* @list: Used internally, protected by RTNL and SRCU
74+
* @srcu: Used internally
7375
* @kind: Identifier
7476
* @netns_refund: Physical device, move to init_net on netns exit
7577
* @maxtype: Highest device specific netlink attribute number
@@ -100,6 +102,7 @@ static inline int rtnl_msg_family(const struct nlmsghdr *nlh)
100102
*/
101103
struct rtnl_link_ops {
102104
struct list_head list;
105+
struct srcu_struct srcu;
103106

104107
const char *kind;
105108

@@ -169,7 +172,8 @@ void rtnl_link_unregister(struct rtnl_link_ops *ops);
169172
/**
170173
* struct rtnl_af_ops - rtnetlink address family operations
171174
*
172-
* @list: Used internally
175+
* @list: Used internally, protected by RTNL and SRCU
176+
* @srcu: Used internally
173177
* @family: Address family
174178
* @fill_link_af: Function to fill IFLA_AF_SPEC with address family
175179
* specific netlink attributes.
@@ -182,6 +186,8 @@ void rtnl_link_unregister(struct rtnl_link_ops *ops);
182186
*/
183187
struct rtnl_af_ops {
184188
struct list_head list;
189+
struct srcu_struct srcu;
190+
185191
int family;
186192

187193
int (*fill_link_af)(struct sk_buff *skb,
@@ -201,7 +207,7 @@ struct rtnl_af_ops {
201207
size_t (*get_stats_af_size)(const struct net_device *dev);
202208
};
203209

204-
void rtnl_af_register(struct rtnl_af_ops *ops);
210+
int rtnl_af_register(struct rtnl_af_ops *ops);
205211
void rtnl_af_unregister(struct rtnl_af_ops *ops);
206212

207213
struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]);

net/bridge/br_netlink.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,9 @@ int __init br_netlink_init(void)
19241924
if (err)
19251925
goto out;
19261926

1927-
rtnl_af_register(&br_af_ops);
1927+
err = rtnl_af_register(&br_af_ops);
1928+
if (err)
1929+
goto out_vlan;
19281930

19291931
err = rtnl_link_register(&br_link_ops);
19301932
if (err)
@@ -1934,6 +1936,8 @@ int __init br_netlink_init(void)
19341936

19351937
out_af:
19361938
rtnl_af_unregister(&br_af_ops);
1939+
out_vlan:
1940+
br_vlan_rtnl_uninit();
19371941
out:
19381942
return err;
19391943
}

0 commit comments

Comments
 (0)