Skip to content

Commit ec1e561

Browse files
Eric Dumazetdavem330
authored andcommitted
bridge: add RCU annotations to bridge port lookup
br_port_get() renamed to br_port_get_rtnl() to make clear RTNL is held. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b5ed54e commit ec1e561

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

net/bridge/br_if.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ int br_del_if(struct net_bridge *br, struct net_device *dev)
475475
{
476476
struct net_bridge_port *p;
477477

478-
p = br_port_get(dev);
478+
p = br_port_get_rtnl(dev);
479479
if (!p || p->br != br)
480480
return -EINVAL;
481481

net/bridge/br_netlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
119119

120120
idx = 0;
121121
for_each_netdev(net, dev) {
122-
struct net_bridge_port *port = br_port_get(dev);
122+
struct net_bridge_port *port = br_port_get_rtnl(dev);
123123

124124
/* not a bridge port */
125125
if (!port || idx < cb->args[0])
@@ -171,7 +171,7 @@ static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
171171
if (!dev)
172172
return -ENODEV;
173173

174-
p = br_port_get(dev);
174+
p = br_port_get_rtnl(dev);
175175
if (!p)
176176
return -EINVAL;
177177

net/bridge/br_notify.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
3737
int err;
3838

3939
/* not a port of a bridge */
40-
if (!br_port_exists(dev))
40+
p = br_port_get_rtnl(dev);
41+
if (!p)
4142
return NOTIFY_DONE;
4243

43-
p = br_port_get(dev);
4444
br = p->br;
4545

4646
switch (event) {

net/bridge/br_private.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *d
159159
return br_port_exists(dev) ? port : NULL;
160160
}
161161

162-
static inline struct net_bridge_port *br_port_get(struct net_device *dev)
162+
static inline struct net_bridge_port *br_port_get_rtnl(struct net_device *dev)
163163
{
164-
return br_port_exists(dev) ? dev->rx_handler_data : NULL;
164+
return br_port_exists(dev) ?
165+
rtnl_dereference(dev->rx_handler_data) : NULL;
165166
}
166167

167168
struct br_cpu_netstats {

0 commit comments

Comments
 (0)