Skip to content

Commit 302fc6b

Browse files
q2venPaolo Abeni
authored andcommitted
phonet: Pass ifindex to fill_route().
We will convert route_doit() to RCU. route_doit() will call rtm_phonet_notify() outside of RCU due to GFP_KERNEL, so dev will not be available in fill_route(). Let's pass ifindex directly to fill_route(). Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent b7d2fc9 commit 302fc6b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

net/phonet/pn_netlink.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ static int getaddr_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
170170

171171
/* Routes handling */
172172

173-
static int fill_route(struct sk_buff *skb, struct net_device *dev, u8 dst,
174-
u32 portid, u32 seq, int event)
173+
static int fill_route(struct sk_buff *skb, u32 ifindex, u8 dst,
174+
u32 portid, u32 seq, int event)
175175
{
176176
struct rtmsg *rtm;
177177
struct nlmsghdr *nlh;
@@ -190,8 +190,7 @@ static int fill_route(struct sk_buff *skb, struct net_device *dev, u8 dst,
190190
rtm->rtm_scope = RT_SCOPE_UNIVERSE;
191191
rtm->rtm_type = RTN_UNICAST;
192192
rtm->rtm_flags = 0;
193-
if (nla_put_u8(skb, RTA_DST, dst) ||
194-
nla_put_u32(skb, RTA_OIF, READ_ONCE(dev->ifindex)))
193+
if (nla_put_u8(skb, RTA_DST, dst) || nla_put_u32(skb, RTA_OIF, ifindex))
195194
goto nla_put_failure;
196195
nlmsg_end(skb, nlh);
197196
return 0;
@@ -210,7 +209,8 @@ void rtm_phonet_notify(int event, struct net_device *dev, u8 dst)
210209
nla_total_size(1) + nla_total_size(4), GFP_KERNEL);
211210
if (skb == NULL)
212211
goto errout;
213-
err = fill_route(skb, dev, dst, 0, 0, event);
212+
213+
err = fill_route(skb, dev->ifindex, dst, 0, 0, event);
214214
if (err < 0) {
215215
WARN_ON(err == -EMSGSIZE);
216216
kfree_skb(skb);
@@ -286,7 +286,7 @@ static int route_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
286286
if (!dev)
287287
continue;
288288

289-
err = fill_route(skb, dev, addr << 2,
289+
err = fill_route(skb, READ_ONCE(dev->ifindex), addr << 2,
290290
NETLINK_CB(cb->skb).portid,
291291
cb->nlh->nlmsg_seq, RTM_NEWROUTE);
292292
if (err < 0)

0 commit comments

Comments
 (0)