@@ -99,10 +99,10 @@ static int ipoib_changelink(struct net_device *dev, struct nlattr *tb[],
static int ipoib_new_child_link(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
- struct net *src_net = params->net;
struct nlattr **tb = params->tb;
struct net_device *pdev;
struct ipoib_dev_priv *ppriv;
@@ -112,7 +112,7 @@ static int ipoib_new_child_link(struct rtnl_newlink_params *params)
if (!tb[IFLA_LINK])
return -EINVAL;
- pdev = __dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
+ pdev = __dev_get_by_index(link_net, nla_get_u32(tb[IFLA_LINK]));
if (!pdev || pdev->type != ARPHRD_INFINIBAND)
return -ENODEV;
@@ -3163,16 +3163,16 @@ static int amt_validate(struct nlattr *tb[], struct nlattr *data[],
static int amt_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
struct nlattr **tb = params->tb;
- struct net *net = params->net;
struct amt_dev *amt;
int err = -EINVAL;
amt = netdev_priv(dev);
- amt->net = net;
+ amt->net = link_net;
amt->mode = nla_get_u32(data[IFLA_AMT_MODE]);
if (data[IFLA_AMT_MAX_TUNNELS] &&
@@ -3187,7 +3187,7 @@ static int amt_newlink(struct rtnl_newlink_params *params)
amt->hash_buckets = AMT_HSIZE;
amt->nr_tunnels = 0;
get_random_bytes(&amt->hash_seed, sizeof(amt->hash_seed));
- amt->stream_dev = dev_get_by_index(net,
+ amt->stream_dev = dev_get_by_index(link_net,
nla_get_u32(data[IFLA_AMT_LINK]));
if (!amt->stream_dev) {
NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_AMT_LINK],
@@ -700,11 +700,11 @@ static void bareudp_dellink(struct net_device *dev, struct list_head *head)
static int bareudp_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
struct nlattr **tb = params->tb;
- struct net *net = params->net;
struct bareudp_conf conf;
int err;
@@ -712,7 +712,7 @@ static int bareudp_newlink(struct rtnl_newlink_params *params)
if (err)
return err;
- err = bareudp_configure(net, dev, &conf, extack);
+ err = bareudp_configure(link_net, dev, &conf, extack);
if (err)
return err;
@@ -174,10 +174,10 @@ static struct rtnl_link_ops vxcan_link_ops;
static int vxcan_newlink(struct rtnl_newlink_params *params)
{
+ struct net *peer_net = rtnl_newlink_peer_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
- struct net *peer_net = params->net;
struct nlattr **tb = params->tb;
struct vxcan_priv *priv;
struct net_device *peer;
@@ -120,10 +120,10 @@ static void rmnet_unregister_bridge(struct rmnet_port *port)
static int rmnet_newlink(struct rtnl_newlink_params *params)
{
u32 data_format = RMNET_FLAGS_INGRESS_DEAGGREGATION;
+ struct net *link_net = rtnl_newlink_link_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
- struct net *src_net = params->net;
struct nlattr **tb = params->tb;
struct net_device *real_dev;
int mode = RMNET_EPMODE_VND;
@@ -137,7 +137,7 @@ static int rmnet_newlink(struct rtnl_newlink_params *params)
return -EINVAL;
}
- real_dev = __dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
+ real_dev = __dev_get_by_index(link_net, nla_get_u32(tb[IFLA_LINK]));
if (!real_dev) {
NL_SET_ERR_MSG_MOD(extack, "link does not exist");
return -ENODEV;
@@ -1616,11 +1616,11 @@ static void geneve_link_config(struct net_device *dev,
static int geneve_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
struct nlattr **tb = params->tb;
- struct net *net = params->net;
struct geneve_config cfg = {
.df = GENEVE_DF_UNSET,
.use_udp6_rx_checksums = false,
@@ -1634,7 +1634,7 @@ static int geneve_newlink(struct rtnl_newlink_params *params)
if (err)
return err;
- err = geneve_configure(net, dev, extack, &cfg);
+ err = geneve_configure(link_net, dev, extack, &cfg);
if (err)
return err;
@@ -1462,9 +1462,9 @@ static int gtp_create_sockets(struct gtp_dev *gtp, const struct nlattr *nla,
static int gtp_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
- struct net *src_net = params->net;
unsigned int role = GTP_ROLE_GGSN;
struct gtp_dev *gtp;
struct gtp_net *gn;
@@ -1495,7 +1495,7 @@ static int gtp_newlink(struct rtnl_newlink_params *params)
gtp->restart_count = nla_get_u8_default(data[IFLA_GTP_RESTART_COUNT],
0);
- gtp->net = src_net;
+ gtp->net = link_net;
err = gtp_hashtable_new(gtp, hashsize);
if (err < 0)
@@ -534,10 +534,10 @@ static int ipvlan_nl_fillinfo(struct sk_buff *skb,
int ipvlan_link_new(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
- struct net *src_net = params->net;
struct nlattr **tb = params->tb;
struct ipvl_dev *ipvlan;
struct ipvl_port *port;
@@ -550,7 +550,7 @@ int ipvlan_link_new(struct rtnl_newlink_params *params)
if (!tb[IFLA_LINK])
return -EINVAL;
- phy_dev = __dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
+ phy_dev = __dev_get_by_index(link_net, nla_get_u32(tb[IFLA_LINK]));
if (!phy_dev)
return -ENODEV;
@@ -4143,11 +4143,11 @@ static struct lock_class_key macsec_netdev_addr_lock_key;
static int macsec_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
struct nlattr **tb = params->tb;
- struct net *net = params->net;
rx_handler_func_t *rx_handler;
u8 icv_len = MACSEC_DEFAULT_ICV_LEN;
struct net_device *real_dev;
@@ -4159,7 +4159,7 @@ static int macsec_newlink(struct rtnl_newlink_params *params)
if (!tb[IFLA_LINK])
return -EINVAL;
- real_dev = __dev_get_by_index(net, nla_get_u32(tb[IFLA_LINK]));
+ real_dev = __dev_get_by_index(link_net, nla_get_u32(tb[IFLA_LINK]));
if (!real_dev)
return -ENODEV;
if (real_dev->type != ARPHRD_ETHER)
@@ -1567,8 +1567,9 @@ EXPORT_SYMBOL_GPL(macvlan_common_newlink);
static int macvlan_newlink(struct rtnl_newlink_params *params)
{
- return macvlan_common_newlink(params->net, params->dev, params->tb,
- params->data, params->extack);
+ return macvlan_common_newlink(rtnl_newlink_link_net(params),
+ params->dev, params->tb, params->data,
+ params->extack);
}
void macvlan_dellink(struct net_device *dev, struct list_head *head)
@@ -105,8 +105,8 @@ static int macvtap_newlink(struct rtnl_newlink_params *params)
/* Don't put anything that may fail after macvlan_common_newlink
* because we can't undo what it does.
*/
- err = macvlan_common_newlink(params->net, dev, params->tb, params->data,
- params->extack);
+ err = macvlan_common_newlink(rtnl_newlink_link_net(params), dev,
+ params->tb, params->data, params->extack);
if (err) {
netdev_rx_handler_unregister(dev);
return err;
@@ -329,10 +329,10 @@ static struct rtnl_link_ops netkit_link_ops;
static int netkit_new_link(struct rtnl_newlink_params *params)
{
+ struct net *peer_net = rtnl_newlink_peer_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
- struct net *peer_net = params->net;
struct nlattr **tb = params->tb;
struct nlattr *peer_tb[IFLA_MAX + 1], **tbp = tb, *attr;
enum netkit_action policy_prim = NETKIT_PASS;
@@ -186,14 +186,14 @@ static int pfcp_add_sock(struct pfcp_dev *pfcp)
static int pfcp_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct net_device *dev = params->dev;
- struct net *net = params->net;
struct pfcp_dev *pfcp;
struct pfcp_net *pn;
int err;
pfcp = netdev_priv(dev);
- pfcp->net = net;
+ pfcp->net = link_net;
err = pfcp_add_sock(pfcp);
if (err) {
@@ -1305,9 +1305,9 @@ static int ppp_nl_validate(struct nlattr *tb[], struct nlattr *data[],
static int ppp_nl_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
- struct net *src_net = params->net;
struct nlattr **tb = params->tb;
struct ppp_config conf = {
.unit = -1,
@@ -1345,7 +1345,7 @@ static int ppp_nl_newlink(struct rtnl_newlink_params *params)
if (!tb[IFLA_IFNAME] || !nla_len(tb[IFLA_IFNAME]) || !*(char *)nla_data(tb[IFLA_IFNAME]))
conf.ifname_is_set = false;
- err = ppp_dev_configure(src_net, dev, &conf);
+ err = ppp_dev_configure(link_net, dev, &conf);
out_unlock:
mutex_unlock(&ppp_mutex);
@@ -1767,10 +1767,10 @@ static int veth_init_queues(struct net_device *dev, struct nlattr *tb[])
static int veth_newlink(struct rtnl_newlink_params *params)
{
+ struct net *peer_net = rtnl_newlink_peer_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
- struct net *peer_net = params->net;
struct nlattr **tb = params->tb;
int err;
struct net_device *peer;
@@ -4395,10 +4395,10 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[],
static int vxlan_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
- struct net *src_net = params->net;
struct nlattr **tb = params->tb;
struct vxlan_config conf;
int err;
@@ -4407,7 +4407,7 @@ static int vxlan_newlink(struct rtnl_newlink_params *params)
if (err)
return err;
- return __vxlan_dev_create(src_net, dev, &conf, extack);
+ return __vxlan_dev_create(link_net, dev, &conf, extack);
}
static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
@@ -309,13 +309,13 @@ static void wg_setup(struct net_device *dev)
static int wg_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct net_device *dev = params->dev;
- struct net *src_net = params->net;
struct wg_device *wg;
int ret = -ENOMEM;
wg = netdev_priv(dev);
- rcu_assign_pointer(wg->creating_net, src_net);
+ rcu_assign_pointer(wg->creating_net, link_net);
init_rwsem(&wg->static_identity.lock);
mutex_init(&wg->socket_update_lock);
mutex_init(&wg->device_update_lock);
@@ -521,10 +521,10 @@ static rx_handler_result_t virt_wifi_rx_handler(struct sk_buff **pskb)
/* Called with rtnl lock held. */
static int virt_wifi_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct virt_wifi_netdev_priv *priv;
- struct net *src_net = params->net;
struct nlattr **tb = params->tb;
int err;
@@ -536,7 +536,7 @@ static int virt_wifi_newlink(struct rtnl_newlink_params *params)
netif_carrier_off(dev);
priv->upperdev = dev;
- priv->lowerdev = __dev_get_by_index(src_net,
+ priv->lowerdev = __dev_get_by_index(link_net,
nla_get_u32(tb[IFLA_LINK]));
if (!priv->lowerdev)
@@ -1070,7 +1070,7 @@ static void wwan_create_default_link(struct wwan_device *wwandev,
struct nlmsghdr *nlh;
struct sk_buff *msg;
struct rtnl_newlink_params params = {
- .net = &init_net,
+ .src_net = &init_net,
.tb = tb,
.data = data,
};
@@ -137,10 +137,10 @@ static int vlan_changelink(struct net_device *dev, struct nlattr *tb[],
static int vlan_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
- struct net *src_net = params->net;
struct nlattr **tb = params->tb;
struct net_device *real_dev;
struct vlan_dev_priv *vlan;
@@ -160,7 +160,7 @@ static int vlan_newlink(struct rtnl_newlink_params *params)
return -EINVAL;
}
- real_dev = __dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
+ real_dev = __dev_get_by_index(link_net, nla_get_u32(tb[IFLA_LINK]));
if (!real_dev) {
NL_SET_ERR_MSG_MOD(extack, "link does not exist");
return -ENODEV;
@@ -31,10 +31,10 @@ static const struct nla_policy hsr_policy[IFLA_HSR_MAX + 1] = {
*/
static int hsr_newlink(struct rtnl_newlink_params *params)
{
+ struct net *link_net = rtnl_newlink_link_net(params);
struct netlink_ext_ack *extack = params->extack;
struct net_device *dev = params->dev;
struct nlattr **data = params->data;
- struct net *src_net = params->net;
enum hsr_version proto_version;
unsigned char multicast_spec;
u8 proto = HSR_PROTOCOL_HSR;
@@ -48,7 +48,7 @@ static int hsr_newlink(struct rtnl_newlink_params *params)
NL_SET_ERR_MSG_MOD(extack, "Slave1 device not specified");
return -EINVAL;
}
- link[0] = __dev_get_by_index(src_net,
+ link[0] = __dev_get_by_index(link_net,
nla_get_u32(data[IFLA_HSR_SLAVE1]));
if (!link[0]) {
NL_SET_ERR_MSG_MOD(extack, "Slave1 does not exist");
@@ -58,7 +58,7 @@ static int hsr_newlink(struct rtnl_newlink_params *params)
NL_SET_ERR_MSG_MOD(extack, "Slave2 device not specified");
return -EINVAL;
}
- link[1] = __dev_get_by_index(src_net,
+ link[1] = __dev_get_by_index(link_net,
nla_get_u32(data[IFLA_HSR_SLAVE2]));
if (!link[1]) {
NL_SET_ERR_MSG_MOD(extack, "Slave2 does not exist");
@@ -71,7 +71,7 @@ static int hsr_newlink(struct rtnl_newlink_params *params)
}
if (data[IFLA_HSR_INTERLINK])
- interlink = __dev_get_by_index(src_net,
+ interlink = __dev_get_by_index(link_net,
nla_get_u32(data[IFLA_HSR_INTERLINK]));
if (interlink && interlink == link[0]) {
These netdevice drivers already uses netns parameter in newlink() callback. Convert them to use rtnl_newlink_link_net() or rtnl_newlink_peer_net() for clarity and deprecate params->net. Signed-off-by: Xiao Liang <shaw.leon@gmail.com> --- drivers/infiniband/ulp/ipoib/ipoib_netlink.c | 4 ++-- drivers/net/amt.c | 6 +++--- drivers/net/bareudp.c | 4 ++-- drivers/net/can/vxcan.c | 2 +- drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c | 4 ++-- drivers/net/geneve.c | 4 ++-- drivers/net/gtp.c | 4 ++-- drivers/net/ipvlan/ipvlan_main.c | 4 ++-- drivers/net/macsec.c | 4 ++-- drivers/net/macvlan.c | 5 +++-- drivers/net/macvtap.c | 4 ++-- drivers/net/netkit.c | 2 +- drivers/net/pfcp.c | 4 ++-- drivers/net/ppp/ppp_generic.c | 4 ++-- drivers/net/veth.c | 2 +- drivers/net/vxlan/vxlan_core.c | 4 ++-- drivers/net/wireguard/device.c | 4 ++-- drivers/net/wireless/virtual/virt_wifi.c | 4 ++-- drivers/net/wwan/wwan_core.c | 2 +- net/8021q/vlan_netlink.c | 4 ++-- net/hsr/hsr_netlink.c | 8 ++++---- 21 files changed, 42 insertions(+), 41 deletions(-)