diff options
| author | Xiao Liang <[email protected]> | 2025-02-19 12:50:35 +0000 |
|---|---|---|
| committer | Jakub Kicinski <[email protected]> | 2025-02-21 23:28:03 +0000 |
| commit | 5314e3d68455c56161c02133e08a44c3a9e8cf4a (patch) | |
| tree | ba3e2191d9747c420cc1991258ff2d7d3dd75ad1 /net/xfrm/xfrm_interface_core.c | |
| parent | net: ipv6: Use link netns in newlink() of rtnl_link_ops (diff) | |
| download | kernel-5314e3d68455c56161c02133e08a44c3a9e8cf4a.tar.gz kernel-5314e3d68455c56161c02133e08a44c3a9e8cf4a.zip | |
net: xfrm: Use link netns in newlink() of rtnl_link_ops
When link_net is set, use it as link netns instead of dev_net(). This
prepares for rtnetlink core to create device in target netns directly,
in which case the two namespaces may be different.
Signed-off-by: Xiao Liang <[email protected]>
Reviewed-by: Kuniyuki Iwashima <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Diffstat (limited to 'net/xfrm/xfrm_interface_core.c')
| -rw-r--r-- | net/xfrm/xfrm_interface_core.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/net/xfrm/xfrm_interface_core.c b/net/xfrm/xfrm_interface_core.c index 5659a6cadd51..622445f041d3 100644 --- a/net/xfrm/xfrm_interface_core.c +++ b/net/xfrm/xfrm_interface_core.c @@ -242,10 +242,9 @@ static void xfrmi_dev_free(struct net_device *dev) gro_cells_destroy(&xi->gro_cells); } -static int xfrmi_create(struct net_device *dev) +static int xfrmi_create(struct net *net, struct net_device *dev) { struct xfrm_if *xi = netdev_priv(dev); - struct net *net = dev_net(dev); struct xfrmi_net *xfrmn = net_generic(net, xfrmi_net_id); int err; @@ -819,11 +818,12 @@ static int xfrmi_newlink(struct net_device *dev, struct netlink_ext_ack *extack) { struct nlattr **data = params->data; - struct net *net = dev_net(dev); struct xfrm_if_parms p = {}; struct xfrm_if *xi; + struct net *net; int err; + net = params->link_net ? : dev_net(dev); xfrmi_netlink_parms(data, &p); if (p.collect_md) { struct xfrmi_net *xfrmn = net_generic(net, xfrmi_net_id); @@ -852,7 +852,7 @@ static int xfrmi_newlink(struct net_device *dev, xi->net = net; xi->dev = dev; - err = xfrmi_create(dev); + err = xfrmi_create(net, dev); return err; } |
