From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Remi Denis-Courmont <courmisch@gmail.com>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>
Subject: [PATCH v1 net-next 6/9] phonet: Pass ifindex to fill_route().
Date: Thu, 17 Oct 2024 11:31:37 -0700 [thread overview]
Message-ID: <20241017183140.43028-7-kuniyu@amazon.com> (raw)
In-Reply-To: <20241017183140.43028-1-kuniyu@amazon.com>
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>
---
net/phonet/pn_netlink.c | 12 ++++++------
1 file 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 @@ static int getaddr_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
/* 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)
--
2.39.5 (Apple Git-154)
next prev parent reply other threads:[~2024-10-17 18:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 18:31 [PATCH v1 net-next 0/9] phonet: Convert all doit() and dumpit() to RCU Kuniyuki Iwashima
2024-10-17 18:31 ` [PATCH v1 net-next 1/9] phonet: Pass ifindex to fill_addr() Kuniyuki Iwashima
2024-10-23 15:24 ` Eric Dumazet
2024-10-17 18:31 ` [PATCH v1 net-next 2/9] phonet: Pass net and ifindex to phonet_address_notify() Kuniyuki Iwashima
2024-10-23 15:25 ` Eric Dumazet
2024-10-17 18:31 ` [PATCH v1 net-next 3/9] phonet: Convert phonet_device_list.lock to spinlock_t Kuniyuki Iwashima
2024-10-23 15:26 ` Eric Dumazet
2024-10-17 18:31 ` [PATCH v1 net-next 4/9] phonet: Don't hold RTNL for addr_doit() Kuniyuki Iwashima
2024-10-23 15:27 ` Eric Dumazet
2024-10-17 18:31 ` [PATCH v1 net-next 5/9] phonet: Don't hold RTNL for getaddr_dumpit() Kuniyuki Iwashima
2024-10-17 18:49 ` Rémi Denis-Courmont
2024-10-18 17:16 ` Kuniyuki Iwashima
2024-10-19 7:48 ` Rémi Denis-Courmont
2024-10-20 1:30 ` Kuniyuki Iwashima
2024-10-23 11:04 ` Paolo Abeni
2024-10-23 11:16 ` Paolo Abeni
2024-10-23 15:30 ` Eric Dumazet
2024-10-17 18:31 ` Kuniyuki Iwashima [this message]
2024-10-23 15:30 ` [PATCH v1 net-next 6/9] phonet: Pass ifindex to fill_route() Eric Dumazet
2024-10-17 18:31 ` [PATCH v1 net-next 7/9] phonet: Pass net and ifindex to rtm_phonet_notify() Kuniyuki Iwashima
2024-10-23 15:32 ` Eric Dumazet
2024-10-17 18:31 ` [PATCH v1 net-next 8/9] phonet: Convert phonet_routes.lock to spinlock_t Kuniyuki Iwashima
2024-10-23 15:33 ` Eric Dumazet
2024-10-17 18:31 ` [PATCH v1 net-next 9/9] phonet: Don't hold RTNL for route_doit() Kuniyuki Iwashima
2024-10-23 15:34 ` Eric Dumazet
2024-10-24 14:10 ` [PATCH v1 net-next 0/9] phonet: Convert all doit() and dumpit() to RCU patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241017183140.43028-7-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=courmisch@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).