diff options
author | Kuniyuki Iwashima <kuniyu@amazon.com> | 2024-10-17 20:31:37 +0200 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2024-10-24 16:03:40 +0200 |
commit | 302fc6bbcba4beee6ff5e73c2fcc257e62667d4d (patch) | |
tree | c802d0fdb43f3e5bbd96538052d7fa0f027b9d7f /net/phonet | |
parent | phonet: Don't hold RTNL for getaddr_dumpit(). (diff) | |
download | linux-302fc6bbcba4beee6ff5e73c2fcc257e62667d4d.tar.xz linux-302fc6bbcba4beee6ff5e73c2fcc257e62667d4d.zip |
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 <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/phonet')
-rw-r--r-- | net/phonet/pn_netlink.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/net/phonet/pn_netlink.c b/net/phonet/pn_netlink.c index 14928fa04675..c9a4215ec560 100644 --- a/net/phonet/pn_netlink.c +++ b/net/phonet/pn_netlink.c @@ -170,8 +170,8 @@ out: /* Routes handling */ -static int fill_route(struct sk_buff *skb, struct net_device *dev, u8 dst, - u32 portid, u32 seq, int event) +static int fill_route(struct sk_buff *skb, u32 ifindex, u8 dst, + u32 portid, u32 seq, int event) { struct rtmsg *rtm; struct nlmsghdr *nlh; @@ -190,8 +190,7 @@ static int fill_route(struct sk_buff *skb, struct net_device *dev, u8 dst, rtm->rtm_scope = RT_SCOPE_UNIVERSE; rtm->rtm_type = RTN_UNICAST; rtm->rtm_flags = 0; - if (nla_put_u8(skb, RTA_DST, dst) || - nla_put_u32(skb, RTA_OIF, READ_ONCE(dev->ifindex))) + if (nla_put_u8(skb, RTA_DST, dst) || nla_put_u32(skb, RTA_OIF, ifindex)) goto nla_put_failure; nlmsg_end(skb, nlh); return 0; @@ -210,7 +209,8 @@ void rtm_phonet_notify(int event, struct net_device *dev, u8 dst) nla_total_size(1) + nla_total_size(4), GFP_KERNEL); if (skb == NULL) goto errout; - err = fill_route(skb, dev, dst, 0, 0, event); + + err = fill_route(skb, dev->ifindex, dst, 0, 0, event); if (err < 0) { WARN_ON(err == -EMSGSIZE); kfree_skb(skb); @@ -286,7 +286,7 @@ static int route_dumpit(struct sk_buff *skb, struct netlink_callback *cb) if (!dev) continue; - err = fill_route(skb, dev, addr << 2, + err = fill_route(skb, READ_ONCE(dev->ifindex), addr << 2, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, RTM_NEWROUTE); if (err < 0) |