From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <shaw.leon@gmail.com>
Cc: <alex.aring@gmail.com>, <andrew+netdev@lunn.ch>,
<b.a.t.m.a.n@lists.open-mesh.org>, <bpf@vger.kernel.org>,
<bridge@lists.linux.dev>, <davem@davemloft.net>,
<donald.hunter@gmail.com>, <dsahern@kernel.org>,
<edumazet@google.com>, <herbert@gondor.apana.org.au>,
<horms@kernel.org>, <kuba@kernel.org>, <kuniyu@amazon.com>,
<linux-can@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-kselftest@vger.kernel.org>, <linux-ppp@vger.kernel.org>,
<linux-rdma@vger.kernel.org>, <linux-wireless@vger.kernel.org>,
<linux-wpan@vger.kernel.org>, <miquel.raynal@bootlin.com>,
<netdev@vger.kernel.org>, <osmocom-net-gprs@lists.osmocom.org>,
<pabeni@redhat.com>, <shuah@kernel.org>,
<stefan@datenfreihafen.org>, <steffen.klassert@secunet.com>,
<wireguard@lists.zx2c4.com>
Subject: Re: [PATCH net-next v8 06/11] net: ipv6: Use link netns in newlink() of rtnl_link_ops
Date: Tue, 14 Jan 2025 13:49:35 +0900 [thread overview]
Message-ID: <20250114044935.26418-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20250113143719.7948-3-shaw.leon@gmail.com>
From: Xiao Liang <shaw.leon@gmail.com>
Date: Mon, 13 Jan 2025 22:37:14 +0800
> diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
> index 2a6a424806aa..ac5e402c34bc 100644
> --- a/drivers/net/bonding/bond_netlink.c
> +++ b/drivers/net/bonding/bond_netlink.c
> @@ -564,10 +564,12 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],
> return 0;
> }
>
> -static int bond_newlink(struct net *src_net, struct net_device *bond_dev,
> - struct nlattr *tb[], struct nlattr *data[],
> +static int bond_newlink(struct net_device *bond_dev,
> + struct rtnl_newlink_params *params,
> struct netlink_ext_ack *extack)
> {
> + struct nlattr **data = params->data;
> + struct nlattr **tb = params->tb;
> int err;
>
> err = bond_changelink(bond_dev, tb, data, extack);
Note that IFLA_BOND_ACTIVE_SLAVE uses dev_net(dev) for
__dev_get_by_index().
[...]
> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index fed4fe2a4748..0c496aa1f706 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -1565,11 +1565,12 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
> }
> EXPORT_SYMBOL_GPL(macvlan_common_newlink);
>
> -static int macvlan_newlink(struct net *src_net, struct net_device *dev,
> - struct nlattr *tb[], struct nlattr *data[],
> +static int macvlan_newlink(struct net_device *dev,
> + struct rtnl_newlink_params *params,
> struct netlink_ext_ack *extack)
> {
> - return macvlan_common_newlink(src_net, dev, tb, data, extack);
> + return macvlan_common_newlink(params->net, dev, params->tb,
> + params->data, extack);
Pass params as is as you did for ipvlan_link_new().
Same for macvtap_newlink().
[...]
> diff --git a/drivers/net/netkit.c b/drivers/net/netkit.c
> index 1e1b00756be7..1e9eadc77da2 100644
> --- a/drivers/net/netkit.c
> +++ b/drivers/net/netkit.c
> @@ -327,10 +327,13 @@ static int netkit_validate(struct nlattr *tb[], struct nlattr *data[],
>
> static struct rtnl_link_ops netkit_link_ops;
>
> -static int netkit_new_link(struct net *peer_net, struct net_device *dev,
> - struct nlattr *tb[], struct nlattr *data[],
> +static int netkit_new_link(struct net_device *dev,
> + struct rtnl_newlink_params *params,
> struct netlink_ext_ack *extack)
> {
> + struct nlattr **data = params->data;
> + struct net *peer_net = params->net;
> + struct nlattr **tb = params->tb;
nit: please keep the reverse xmas tree order.
> struct nlattr *peer_tb[IFLA_MAX + 1], **tbp = tb, *attr;
you can define *tbp here and initialise it later.
struct nlattr *peer_tb[IFLA_MAX + 1], **tbp, *attr;
> enum netkit_action policy_prim = NETKIT_PASS;
> enum netkit_action policy_peer = NETKIT_PASS;
[...]
> @@ -1064,6 +1067,11 @@ static void wwan_create_default_link(struct wwan_device *wwandev,
> struct net_device *dev;
> struct nlmsghdr *nlh;
> struct sk_buff *msg;
> + struct rtnl_newlink_params params = {
> + .net = &init_net,
> + .tb = tb,
> + .data = data,
> + };
nit: Reverse xmas tree order
[...]
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index ec98349b9620..7ff5e96f6ba7 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -3766,6 +3766,14 @@ static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm,
> struct net_device *dev;
> char ifname[IFNAMSIZ];
> int err;
> + struct rtnl_newlink_params params = {
nit: Reverse xmas tree order
> + .net = net,
Use sock_net(skb->sk) directly here and remove net defined above,
which is no longer used in this function.
---8<---
unsigned char name_assign_type = NET_NAME_USER;
struct rtnl_newlink_params params = {
.net = sock_net(skb->sk),
.src_net = net,
.link_net = link_net,
.peer_net = peer_net,
.tb = tb,
.data = data,
};
u32 portid = NETLINK_CB(skb).portid;
---8<---
[...]
> @@ -1698,6 +1702,10 @@ struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
> LIST_HEAD(list_kill);
> struct ip_tunnel *t;
> int err;
> + struct rtnl_newlink_params params = {
> + .net = net,
> + .tb = tb,
> + };
>
> memset(&tb, 0, sizeof(tb));
nit: Reverse xmas tree
next prev parent reply other threads:[~2025-01-14 4:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 14:37 [PATCH net-next v8 00/11] net: Improve netns handling in rtnetlink Xiao Liang
2025-01-13 14:37 ` [PATCH net-next v8 01/11] rtnetlink: Lookup device in target netns when creating link Xiao Liang
2025-01-14 1:39 ` Kuniyuki Iwashima
2025-01-13 14:37 ` [PATCH net-next v8 02/11] rtnetlink: Pack newlink() params into struct Xiao Liang
2025-01-14 4:49 ` Kuniyuki Iwashima [this message]
2025-01-14 9:02 ` [PATCH net-next v8 06/11] net: ipv6: Use link netns in newlink() of rtnl_link_ops Xiao Liang
2025-01-13 14:37 ` [PATCH net-next v8 03/11] net: " Xiao Liang
2025-01-13 14:37 ` [PATCH net-next v8 04/11] ieee802154: 6lowpan: Validate " Xiao Liang
2025-01-13 14:37 ` [PATCH net-next v8 05/11] net: ip_tunnel: Use " Xiao Liang
2025-01-13 14:37 ` [PATCH net-next v8 06/11] net: ipv6: " Xiao Liang
2025-01-13 14:37 ` [PATCH net-next v8 07/11] net: xfrm: " Xiao Liang
2025-01-13 14:37 ` [PATCH net-next v8 08/11] rtnetlink: Remove "net" from newlink params Xiao Liang
2025-01-13 14:37 ` [PATCH net-next v8 09/11] rtnetlink: Create link directly in target net namespace Xiao Liang
2025-01-13 14:37 ` [PATCH net-next v8 10/11] selftests: net: Add python context manager for netns entering Xiao Liang
2025-01-13 14:37 ` [PATCH net-next v8 11/11] selftests: net: Add test cases for link and peer netns Xiao Liang
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=20250114044935.26418-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=alex.aring@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=bpf@vger.kernel.org \
--cc=bridge@lists.linux.dev \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-ppp@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=osmocom-net-gprs@lists.osmocom.org \
--cc=pabeni@redhat.com \
--cc=shaw.leon@gmail.com \
--cc=shuah@kernel.org \
--cc=stefan@datenfreihafen.org \
--cc=steffen.klassert@secunet.com \
--cc=wireguard@lists.zx2c4.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).