Skip to content

Commit 08a9572

Browse files
q2venPaolo Abeni
authored andcommitted
phonet: Pass ifindex to fill_addr().
We will convert addr_doit() and getaddr_dumpit() to RCU, both of which call fill_addr(). The former will call phonet_address_notify() outside of RCU due to GFP_KERNEL, so dev will not be available in fill_addr(). Let's pass ifindex directly to fill_addr(). Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 1bf70e6 commit 08a9572

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

net/phonet/pn_netlink.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/* Device address handling */
2121

22-
static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr,
22+
static int fill_addr(struct sk_buff *skb, u32 ifindex, u8 addr,
2323
u32 portid, u32 seq, int event);
2424

2525
void phonet_address_notify(int event, struct net_device *dev, u8 addr)
@@ -31,7 +31,8 @@ void phonet_address_notify(int event, struct net_device *dev, u8 addr)
3131
nla_total_size(1), GFP_KERNEL);
3232
if (skb == NULL)
3333
goto errout;
34-
err = fill_addr(skb, dev, addr, 0, 0, event);
34+
35+
err = fill_addr(skb, dev->ifindex, addr, 0, 0, event);
3536
if (err < 0) {
3637
WARN_ON(err == -EMSGSIZE);
3738
kfree_skb(skb);
@@ -92,8 +93,8 @@ static int addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
9293
return err;
9394
}
9495

95-
static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr,
96-
u32 portid, u32 seq, int event)
96+
static int fill_addr(struct sk_buff *skb, u32 ifindex, u8 addr,
97+
u32 portid, u32 seq, int event)
9798
{
9899
struct ifaddrmsg *ifm;
99100
struct nlmsghdr *nlh;
@@ -107,7 +108,7 @@ static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr,
107108
ifm->ifa_prefixlen = 0;
108109
ifm->ifa_flags = IFA_F_PERMANENT;
109110
ifm->ifa_scope = RT_SCOPE_LINK;
110-
ifm->ifa_index = dev->ifindex;
111+
ifm->ifa_index = ifindex;
111112
if (nla_put_u8(skb, IFA_LOCAL, addr))
112113
goto nla_put_failure;
113114
nlmsg_end(skb, nlh);
@@ -140,7 +141,7 @@ static int getaddr_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
140141
if (addr_idx++ < addr_start_idx)
141142
continue;
142143

143-
if (fill_addr(skb, pnd->netdev, addr << 2,
144+
if (fill_addr(skb, pnd->netdev->ifindex, addr << 2,
144145
NETLINK_CB(cb->skb).portid,
145146
cb->nlh->nlmsg_seq, RTM_NEWADDR) < 0)
146147
goto out;

0 commit comments

Comments
 (0)