Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Kuniyuki Iwashima and committed by
Paolo Abeni
302fc6bb b7d2fc9a

+6 -6
+6 -6
net/phonet/pn_netlink.c
··· 170 170 171 171 /* Routes handling */ 172 172 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) 175 175 { 176 176 struct rtmsg *rtm; 177 177 struct nlmsghdr *nlh; ··· 190 190 rtm->rtm_scope = RT_SCOPE_UNIVERSE; 191 191 rtm->rtm_type = RTN_UNICAST; 192 192 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)) 195 194 goto nla_put_failure; 196 195 nlmsg_end(skb, nlh); 197 196 return 0; ··· 209 210 nla_total_size(1) + nla_total_size(4), GFP_KERNEL); 210 211 if (skb == NULL) 211 212 goto errout; 212 - err = fill_route(skb, dev, dst, 0, 0, event); 213 + 214 + err = fill_route(skb, dev->ifindex, dst, 0, 0, event); 213 215 if (err < 0) { 214 216 WARN_ON(err == -EMSGSIZE); 215 217 kfree_skb(skb); ··· 286 286 if (!dev) 287 287 continue; 288 288 289 - err = fill_route(skb, dev, addr << 2, 289 + err = fill_route(skb, READ_ONCE(dev->ifindex), addr << 2, 290 290 NETLINK_CB(cb->skb).portid, 291 291 cb->nlh->nlmsg_seq, RTM_NEWROUTE); 292 292 if (err < 0)