* [PATCH net-next 00/13] net: second round of netdevice refcount tracking
@ 2021-12-07 1:30 Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 01/13] net: eql: add net device refcount tracker Eric Dumazet
` (13 more replies)
0 siblings, 14 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
The most interesting part of this series is probably
("inet: add net device refcount tracker to struct fib_nh_common")
but only future reports will confirm this guess.
Eric Dumazet (13):
net: eql: add net device refcount tracker
vlan: add net device refcount tracker
net: bridge: add net device refcount tracker
net: watchdog: add net device refcount tracker
net: switchdev: add net device refcount tracker
inet: add net device refcount tracker to struct fib_nh_common
ax25: add net device refcount tracker
llc: add net device refcount tracker
pktgen add net device refcount tracker
net/smc: add net device tracker to struct smc_pnetentry
netlink: add net device refcount tracker to struct ethnl_req_info
openvswitch: add net device refcount tracker to struct vport
net: sched: act_mirred: add net device refcount tracker
drivers/net/eql.c | 4 ++--
include/linux/if_eql.h | 1 +
include/linux/if_vlan.h | 3 +++
include/linux/netdevice.h | 2 ++
include/net/ax25.h | 3 +++
include/net/ip_fib.h | 2 ++
include/net/llc_conn.h | 1 +
include/net/tc_act/tc_mirred.h | 1 +
net/8021q/vlan_dev.c | 4 ++--
net/ax25/ax25_dev.c | 8 ++++----
net/bridge/br_if.c | 6 +++---
net/bridge/br_private.h | 1 +
net/core/pktgen.c | 8 +++++---
net/ethtool/netlink.c | 8 +++++---
net/ethtool/netlink.h | 2 ++
net/ipv4/fib_semantics.c | 12 +++++++-----
net/ipv6/route.c | 2 ++
net/llc/af_llc.c | 5 +++--
net/openvswitch/vport-netdev.c | 8 ++++----
net/openvswitch/vport.h | 2 ++
net/sched/act_mirred.c | 18 ++++++++++--------
net/sched/sch_generic.c | 10 ++++++----
net/smc/smc_pnet.c | 9 +++++----
net/switchdev/switchdev.c | 5 +++--
24 files changed, 79 insertions(+), 46 deletions(-)
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH net-next 01/13] net: eql: add net device refcount tracker
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 02/13] vlan: " Eric Dumazet
` (12 subsequent siblings)
13 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
drivers/net/eql.c | 4 ++--
include/linux/if_eql.h | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/eql.c b/drivers/net/eql.c
index 8ef34901c2d8eef46ade52600c31359042463297..1111d1f33865edc7f98e7057118c9e4b8c8d327b 100644
--- a/drivers/net/eql.c
+++ b/drivers/net/eql.c
@@ -225,7 +225,7 @@ static void eql_kill_one_slave(slave_queue_t *queue, slave_t *slave)
list_del(&slave->list);
queue->num_slaves--;
slave->dev->flags &= ~IFF_SLAVE;
- dev_put(slave->dev);
+ dev_put_track(slave->dev, &slave->dev_tracker);
kfree(slave);
}
@@ -399,7 +399,7 @@ static int __eql_insert_slave(slave_queue_t *queue, slave_t *slave)
if (duplicate_slave)
eql_kill_one_slave(queue, duplicate_slave);
- dev_hold(slave->dev);
+ dev_hold_track(slave->dev, &slave->dev_tracker, GFP_ATOMIC);
list_add(&slave->list, &queue->all_slaves);
queue->num_slaves++;
slave->dev->flags |= IFF_SLAVE;
diff --git a/include/linux/if_eql.h b/include/linux/if_eql.h
index d984694c384d7dde37b7b1f9ac0a90e6ef7bb87f..d75601d613cc6859b692ab3a41b55893e5921dd9 100644
--- a/include/linux/if_eql.h
+++ b/include/linux/if_eql.h
@@ -26,6 +26,7 @@
typedef struct slave {
struct list_head list;
struct net_device *dev;
+ netdevice_tracker dev_tracker;
long priority;
long priority_bps;
long priority_Bps;
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 02/13] vlan: add net device refcount tracker
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 01/13] net: eql: add net device refcount tracker Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 03/13] net: bridge: " Eric Dumazet
` (11 subsequent siblings)
13 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/linux/if_vlan.h | 3 +++
net/8021q/vlan_dev.c | 4 ++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 41a518336673b496faf7ce0ea2a65068fe6814f2..8420fe5049272bbfa108df794bb351f7d87f7a5c 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -162,6 +162,7 @@ struct netpoll;
* @vlan_id: VLAN identifier
* @flags: device flags
* @real_dev: underlying netdevice
+ * @dev_tracker: refcount tracker for @real_dev reference
* @real_dev_addr: address of underlying netdevice
* @dent: proc dir entry
* @vlan_pcpu_stats: ptr to percpu rx stats
@@ -177,6 +178,8 @@ struct vlan_dev_priv {
u16 flags;
struct net_device *real_dev;
+ netdevice_tracker dev_tracker;
+
unsigned char real_dev_addr[ETH_ALEN];
struct proc_dir_entry *dent;
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 866556e041b729af5ebd5184fa3a90374fc3c244..26d031a43cc1a70aa94a5f3efe895efacb612cad 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -616,7 +616,7 @@ static int vlan_dev_init(struct net_device *dev)
return -ENOMEM;
/* Get vlan's reference to real_dev */
- dev_hold(real_dev);
+ dev_hold_track(real_dev, &vlan->dev_tracker, GFP_KERNEL);
return 0;
}
@@ -848,7 +848,7 @@ static void vlan_dev_free(struct net_device *dev)
vlan->vlan_pcpu_stats = NULL;
/* Get rid of the vlan's reference to real_dev */
- dev_put(vlan->real_dev);
+ dev_put_track(vlan->real_dev, &vlan->dev_tracker);
}
void vlan_setup(struct net_device *dev)
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 03/13] net: bridge: add net device refcount tracker
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 01/13] net: eql: add net device refcount tracker Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 02/13] vlan: " Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 04/13] net: watchdog: " Eric Dumazet
` (10 subsequent siblings)
13 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/bridge/br_if.c | 6 +++---
net/bridge/br_private.h | 1 +
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 3915832a03c25e22ae2215ee93dceb0f8e5b5cc4..a52ad81596b72dde8e9a0affccd38c91ab59315d 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -274,7 +274,7 @@ static void destroy_nbp(struct net_bridge_port *p)
p->br = NULL;
p->dev = NULL;
- dev_put(dev);
+ dev_put_track(dev, &p->dev_tracker);
kobject_put(&p->kobj);
}
@@ -423,7 +423,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
return ERR_PTR(-ENOMEM);
p->br = br;
- dev_hold(dev);
+ dev_hold_track(dev, &p->dev_tracker, GFP_KERNEL);
p->dev = dev;
p->path_cost = port_cost(dev);
p->priority = 0x8000 >> BR_PORT_BITS;
@@ -434,7 +434,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
br_stp_port_timer_init(p);
err = br_multicast_add_port(p);
if (err) {
- dev_put(dev);
+ dev_put_track(dev, &p->dev_tracker);
kfree(p);
p = ERR_PTR(err);
}
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index c0efd697865abea651263fc5258715e50c151726..af2b3512d86c8bc0fe799d9d698fa9b6bf3cb94b 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -344,6 +344,7 @@ struct net_bridge_mdb_entry {
struct net_bridge_port {
struct net_bridge *br;
struct net_device *dev;
+ netdevice_tracker dev_tracker;
struct list_head list;
unsigned long flags;
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 04/13] net: watchdog: add net device refcount tracker
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
` (2 preceding siblings ...)
2021-12-07 1:30 ` [PATCH net-next 03/13] net: bridge: " Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 05/13] net: switchdev: " Eric Dumazet
` (9 subsequent siblings)
13 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Add a netdevice_tracker inside struct net_device, to track
the self reference when a device has an active watchdog timer.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/linux/netdevice.h | 2 ++
net/sched/sch_generic.c | 10 ++++++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 201d8c5be80685f89d7fdba4b61f83194beb9b13..235d5d082f1a446c8d898ffcc5b1983df7c04f35 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1944,6 +1944,7 @@ enum netdev_ml_priv_type {
*
* @dev_addr_shadow: Copy of @dev_addr to catch direct writes.
* @linkwatch_dev_tracker: refcount tracker used by linkwatch.
+ * @watchdog_dev_tracker: refcount tracker used by watchdog.
*
* FIXME: cleanup struct net_device such that network protocol info
* moves out.
@@ -2275,6 +2276,7 @@ struct net_device {
u8 dev_addr_shadow[MAX_ADDR_LEN];
netdevice_tracker linkwatch_dev_tracker;
+ netdevice_tracker watchdog_dev_tracker;
};
#define to_net_dev(d) container_of(d, struct net_device, dev)
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 8c8fbf2e385679e46a1b7af47eeac059fb8468cc..b07bd1c7330f54a00c44ecd2e354af76f62b64e8 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -499,6 +499,7 @@ EXPORT_SYMBOL(netif_tx_unlock);
static void dev_watchdog(struct timer_list *t)
{
struct net_device *dev = from_timer(dev, t, watchdog_timer);
+ bool release = true;
spin_lock(&dev->tx_global_lock);
if (!qdisc_tx_is_noop(dev)) {
@@ -534,12 +535,13 @@ static void dev_watchdog(struct timer_list *t)
if (!mod_timer(&dev->watchdog_timer,
round_jiffies(jiffies +
dev->watchdog_timeo)))
- dev_hold(dev);
+ release = false;
}
}
spin_unlock(&dev->tx_global_lock);
- dev_put(dev);
+ if (release)
+ dev_put_track(dev, &dev->watchdog_dev_tracker);
}
void __netdev_watchdog_up(struct net_device *dev)
@@ -549,7 +551,7 @@ void __netdev_watchdog_up(struct net_device *dev)
dev->watchdog_timeo = 5*HZ;
if (!mod_timer(&dev->watchdog_timer,
round_jiffies(jiffies + dev->watchdog_timeo)))
- dev_hold(dev);
+ dev_hold_track(dev, &dev->watchdog_dev_tracker, GFP_ATOMIC);
}
}
EXPORT_SYMBOL_GPL(__netdev_watchdog_up);
@@ -563,7 +565,7 @@ static void dev_watchdog_down(struct net_device *dev)
{
netif_tx_lock_bh(dev);
if (del_timer(&dev->watchdog_timer))
- dev_put(dev);
+ dev_put_track(dev, &dev->watchdog_dev_tracker);
netif_tx_unlock_bh(dev);
}
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 05/13] net: switchdev: add net device refcount tracker
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
` (3 preceding siblings ...)
2021-12-07 1:30 ` [PATCH net-next 04/13] net: watchdog: " Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 06/13] inet: add net device refcount tracker to struct fib_nh_common Eric Dumazet
` (8 subsequent siblings)
13 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/switchdev/switchdev.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 83460470e88315f9bee59271b6955294d0b6f42a..b62565278faccfb7f96228a19304a9ec6c161655 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -28,6 +28,7 @@ typedef void switchdev_deferred_func_t(struct net_device *dev,
struct switchdev_deferred_item {
struct list_head list;
struct net_device *dev;
+ netdevice_tracker dev_tracker;
switchdev_deferred_func_t *func;
unsigned long data[];
};
@@ -63,7 +64,7 @@ void switchdev_deferred_process(void)
while ((dfitem = switchdev_deferred_dequeue())) {
dfitem->func(dfitem->dev, dfitem->data);
- dev_put(dfitem->dev);
+ dev_put_track(dfitem->dev, &dfitem->dev_tracker);
kfree(dfitem);
}
}
@@ -90,7 +91,7 @@ static int switchdev_deferred_enqueue(struct net_device *dev,
dfitem->dev = dev;
dfitem->func = func;
memcpy(dfitem->data, data, data_len);
- dev_hold(dev);
+ dev_hold_track(dev, &dfitem->dev_tracker, GFP_ATOMIC);
spin_lock_bh(&deferred_lock);
list_add_tail(&dfitem->list, &deferred);
spin_unlock_bh(&deferred_lock);
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 06/13] inet: add net device refcount tracker to struct fib_nh_common
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
` (4 preceding siblings ...)
2021-12-07 1:30 ` [PATCH net-next 05/13] net: switchdev: " Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 07/13] ax25: add net device refcount tracker Eric Dumazet
` (7 subsequent siblings)
13 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/ip_fib.h | 2 ++
net/ipv4/fib_semantics.c | 12 +++++++-----
net/ipv6/route.c | 2 ++
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 3417ba2d27ad6a1b5612a8855d2788f10d9fdf25..c4297704bbcbaac0ad5da1675ae47dee1e133df4 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -79,6 +79,7 @@ struct fnhe_hash_bucket {
struct fib_nh_common {
struct net_device *nhc_dev;
+ netdevice_tracker nhc_dev_tracker;
int nhc_oif;
unsigned char nhc_scope;
u8 nhc_family;
@@ -111,6 +112,7 @@ struct fib_nh {
int nh_saddr_genid;
#define fib_nh_family nh_common.nhc_family
#define fib_nh_dev nh_common.nhc_dev
+#define fib_nh_dev_tracker nh_common.nhc_dev_tracker
#define fib_nh_oif nh_common.nhc_oif
#define fib_nh_flags nh_common.nhc_flags
#define fib_nh_lws nh_common.nhc_lwtstate
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index fde7797b580694bb3924c5c6e9560cf04fd67387..3cad543dc7477aa94140d240ecd2014093befddd 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -208,7 +208,7 @@ static void rt_fibinfo_free_cpus(struct rtable __rcu * __percpu *rtp)
void fib_nh_common_release(struct fib_nh_common *nhc)
{
- dev_put(nhc->nhc_dev);
+ dev_put_track(nhc->nhc_dev, &nhc->nhc_dev_tracker);
lwtstate_put(nhc->nhc_lwtstate);
rt_fibinfo_free_cpus(nhc->nhc_pcpu_rth_output);
rt_fibinfo_free(&nhc->nhc_rth_input);
@@ -1006,7 +1006,7 @@ static int fib_check_nh_v6_gw(struct net *net, struct fib_nh *nh,
err = ipv6_stub->fib6_nh_init(net, &fib6_nh, &cfg, GFP_KERNEL, extack);
if (!err) {
nh->fib_nh_dev = fib6_nh.fib_nh_dev;
- dev_hold(nh->fib_nh_dev);
+ dev_hold_track(nh->fib_nh_dev, &nh->fib_nh_dev_tracker, GFP_KERNEL);
nh->fib_nh_oif = nh->fib_nh_dev->ifindex;
nh->fib_nh_scope = RT_SCOPE_LINK;
@@ -1090,7 +1090,7 @@ static int fib_check_nh_v4_gw(struct net *net, struct fib_nh *nh, u32 table,
if (!netif_carrier_ok(dev))
nh->fib_nh_flags |= RTNH_F_LINKDOWN;
nh->fib_nh_dev = dev;
- dev_hold(dev);
+ dev_hold_track(dev, &nh->fib_nh_dev_tracker, GFP_ATOMIC);
nh->fib_nh_scope = RT_SCOPE_LINK;
return 0;
}
@@ -1144,7 +1144,7 @@ static int fib_check_nh_v4_gw(struct net *net, struct fib_nh *nh, u32 table,
"No egress device for nexthop gateway");
goto out;
}
- dev_hold(dev);
+ dev_hold_track(dev, &nh->fib_nh_dev_tracker, GFP_ATOMIC);
if (!netif_carrier_ok(dev))
nh->fib_nh_flags |= RTNH_F_LINKDOWN;
err = (dev->flags & IFF_UP) ? 0 : -ENETDOWN;
@@ -1178,7 +1178,7 @@ static int fib_check_nh_nongw(struct net *net, struct fib_nh *nh,
}
nh->fib_nh_dev = in_dev->dev;
- dev_hold(nh->fib_nh_dev);
+ dev_hold_track(nh->fib_nh_dev, &nh->fib_nh_dev_tracker, GFP_ATOMIC);
nh->fib_nh_scope = RT_SCOPE_HOST;
if (!netif_carrier_ok(nh->fib_nh_dev))
nh->fib_nh_flags |= RTNH_F_LINKDOWN;
@@ -1508,6 +1508,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
err = -ENODEV;
if (!nh->fib_nh_dev)
goto failure;
+ netdev_tracker_alloc(nh->fib_nh_dev, &nh->fib_nh_dev_tracker,
+ GFP_KERNEL);
} else {
int linkdown = 0;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 8d834f901b483edf75c493620d38f979a4bcbf69..4d02a329ab6004169ebd31c5474ce8be5553d569 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3628,6 +3628,8 @@ int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh,
}
fib6_nh->fib_nh_dev = dev;
+ netdev_tracker_alloc(dev, &fib6_nh->fib_nh_dev_tracker, gfp_flags);
+
fib6_nh->fib_nh_oif = dev->ifindex;
err = 0;
out:
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 07/13] ax25: add net device refcount tracker
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
` (5 preceding siblings ...)
2021-12-07 1:30 ` [PATCH net-next 06/13] inet: add net device refcount tracker to struct fib_nh_common Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 08/13] llc: " Eric Dumazet
` (6 subsequent siblings)
13 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/ax25.h | 3 +++
net/ax25/ax25_dev.c | 8 ++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/include/net/ax25.h b/include/net/ax25.h
index 03d409de61ad0e7d37ba0e805a07475e40bab478..526e49589197909b459de068222c4a9cf76050ba 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -229,7 +229,10 @@ struct ctl_table;
typedef struct ax25_dev {
struct ax25_dev *next;
+
struct net_device *dev;
+ netdevice_tracker dev_tracker;
+
struct net_device *forward;
struct ctl_table_header *sysheader;
int values[AX25_MAX_VALUES];
diff --git a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c
index d0a043a51848b3141a6e1f2a7b1ed53a51931ae3..256fadb94df3125ddc2f5ed5f8b1c91d6e243546 100644
--- a/net/ax25/ax25_dev.c
+++ b/net/ax25/ax25_dev.c
@@ -58,7 +58,7 @@ void ax25_dev_device_up(struct net_device *dev)
dev->ax25_ptr = ax25_dev;
ax25_dev->dev = dev;
- dev_hold(dev);
+ dev_hold_track(dev, &ax25_dev->dev_tracker, GFP_ATOMIC);
ax25_dev->forward = NULL;
ax25_dev->values[AX25_VALUES_IPDEFMODE] = AX25_DEF_IPDEFMODE;
@@ -114,7 +114,7 @@ void ax25_dev_device_down(struct net_device *dev)
ax25_dev_list = s->next;
spin_unlock_bh(&ax25_dev_lock);
dev->ax25_ptr = NULL;
- dev_put(dev);
+ dev_put_track(dev, &ax25_dev->dev_tracker);
kfree(ax25_dev);
return;
}
@@ -124,7 +124,7 @@ void ax25_dev_device_down(struct net_device *dev)
s->next = ax25_dev->next;
spin_unlock_bh(&ax25_dev_lock);
dev->ax25_ptr = NULL;
- dev_put(dev);
+ dev_put_track(dev, &ax25_dev->dev_tracker);
kfree(ax25_dev);
return;
}
@@ -188,7 +188,7 @@ void __exit ax25_dev_free(void)
ax25_dev = ax25_dev_list;
while (ax25_dev != NULL) {
s = ax25_dev;
- dev_put(ax25_dev->dev);
+ dev_put_track(ax25_dev->dev, &ax25_dev->dev_tracker);
ax25_dev = ax25_dev->next;
kfree(s);
}
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 08/13] llc: add net device refcount tracker
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
` (6 preceding siblings ...)
2021-12-07 1:30 ` [PATCH net-next 07/13] ax25: add net device refcount tracker Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 09/13] pktgen " Eric Dumazet
` (5 subsequent siblings)
13 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/llc_conn.h | 1 +
net/llc/af_llc.c | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/net/llc_conn.h b/include/net/llc_conn.h
index ea985aa7a6c5e64b6802c2399ad47db23fdbd9bf..2c1ea3414640523a3efc20ad626ae9896a418d1b 100644
--- a/include/net/llc_conn.h
+++ b/include/net/llc_conn.h
@@ -38,6 +38,7 @@ struct llc_sock {
struct llc_addr laddr; /* lsap/mac pair */
struct llc_addr daddr; /* dsap/mac pair */
struct net_device *dev; /* device to send to remote */
+ netdevice_tracker dev_tracker;
u32 copied_seq; /* head of yet unread data */
u8 retry_count; /* number of retries */
u8 ack_must_be_send;
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 3086f4a6ae683f1119d4813648bf9fd9ba215436..26c00ebf4fbae4d7dc1c27d180385470fa252be0 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -224,7 +224,7 @@ static int llc_ui_release(struct socket *sock)
} else {
release_sock(sk);
}
- dev_put(llc->dev);
+ dev_put_track(llc->dev, &llc->dev_tracker);
sock_put(sk);
llc_sk_free(sk);
out:
@@ -295,6 +295,7 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
llc->dev = dev_getfirstbyhwtype(&init_net, addr->sllc_arphrd);
if (!llc->dev)
goto out;
+ netdev_tracker_alloc(llc->dev, &llc->dev_tracker, GFP_KERNEL);
rc = -EUSERS;
llc->laddr.lsap = llc_ui_autoport();
if (!llc->laddr.lsap)
@@ -362,7 +363,7 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
} else
llc->dev = dev_getbyhwaddr_rcu(&init_net, addr->sllc_arphrd,
addr->sllc_mac);
- dev_hold(llc->dev);
+ dev_hold_track(llc->dev, &llc->dev_tracker, GFP_ATOMIC);
rcu_read_unlock();
if (!llc->dev)
goto out;
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 09/13] pktgen add net device refcount tracker
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
` (7 preceding siblings ...)
2021-12-07 1:30 ` [PATCH net-next 08/13] llc: " Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 10/13] net/smc: add net device tracker to struct smc_pnetentry Eric Dumazet
` (4 subsequent siblings)
13 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/core/pktgen.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index a3d74e2704c42e3bec1aa502b911c1b952a56cf1..560a5e712dc32fe4aa2cfaa751c3fe1e462c614f 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -410,6 +410,7 @@ struct pktgen_dev {
* device name (not when the inject is
* started as it used to do.)
*/
+ netdevice_tracker dev_tracker;
char odevname[32];
struct flow_state *flows;
unsigned int cflows; /* Concurrent flows (config) */
@@ -2099,7 +2100,7 @@ static int pktgen_setup_dev(const struct pktgen_net *pn,
/* Clean old setups */
if (pkt_dev->odev) {
- dev_put(pkt_dev->odev);
+ dev_put_track(pkt_dev->odev, &pkt_dev->dev_tracker);
pkt_dev->odev = NULL;
}
@@ -2117,6 +2118,7 @@ static int pktgen_setup_dev(const struct pktgen_net *pn,
err = -ENETDOWN;
} else {
pkt_dev->odev = odev;
+ netdev_tracker_alloc(odev, &pkt_dev->dev_tracker, GFP_KERNEL);
return 0;
}
@@ -3805,7 +3807,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
return add_dev_to_thread(t, pkt_dev);
out2:
- dev_put(pkt_dev->odev);
+ dev_put_track(pkt_dev->odev, &pkt_dev->dev_tracker);
out1:
#ifdef CONFIG_XFRM
free_SAs(pkt_dev);
@@ -3899,7 +3901,7 @@ static int pktgen_remove_device(struct pktgen_thread *t,
/* Dis-associate from the interface */
if (pkt_dev->odev) {
- dev_put(pkt_dev->odev);
+ dev_put_track(pkt_dev->odev, &pkt_dev->dev_tracker);
pkt_dev->odev = NULL;
}
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 10/13] net/smc: add net device tracker to struct smc_pnetentry
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
` (8 preceding siblings ...)
2021-12-07 1:30 ` [PATCH net-next 09/13] pktgen " Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-09 8:05 ` Karsten Graul
2021-12-07 1:30 ` [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info Eric Dumazet
` (3 subsequent siblings)
13 siblings, 1 reply; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/smc/smc_pnet.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c
index 67e9d9fde08540fe1e152b85c450a0165eb37747..e171cc6483f84aac0e3cf496079a7ca57807b991 100644
--- a/net/smc/smc_pnet.c
+++ b/net/smc/smc_pnet.c
@@ -64,6 +64,7 @@ struct smc_pnetentry {
struct {
char eth_name[IFNAMSIZ + 1];
struct net_device *ndev;
+ netdevice_tracker dev_tracker;
};
struct {
char ib_name[IB_DEVICE_NAME_MAX + 1];
@@ -119,7 +120,7 @@ static int smc_pnet_remove_by_pnetid(struct net *net, char *pnet_name)
smc_pnet_match(pnetelem->pnet_name, pnet_name)) {
list_del(&pnetelem->list);
if (pnetelem->type == SMC_PNET_ETH && pnetelem->ndev) {
- dev_put(pnetelem->ndev);
+ dev_put_track(pnetelem->ndev, &pnetelem->dev_tracker);
pr_warn_ratelimited("smc: net device %s "
"erased user defined "
"pnetid %.16s\n",
@@ -195,7 +196,7 @@ static int smc_pnet_add_by_ndev(struct net_device *ndev)
list_for_each_entry_safe(pnetelem, tmp_pe, &pnettable->pnetlist, list) {
if (pnetelem->type == SMC_PNET_ETH && !pnetelem->ndev &&
!strncmp(pnetelem->eth_name, ndev->name, IFNAMSIZ)) {
- dev_hold(ndev);
+ dev_hold_track(ndev, &pnetelem->dev_tracker, GFP_ATOMIC);
pnetelem->ndev = ndev;
rc = 0;
pr_warn_ratelimited("smc: adding net device %s with "
@@ -226,7 +227,7 @@ static int smc_pnet_remove_by_ndev(struct net_device *ndev)
write_lock(&pnettable->lock);
list_for_each_entry_safe(pnetelem, tmp_pe, &pnettable->pnetlist, list) {
if (pnetelem->type == SMC_PNET_ETH && pnetelem->ndev == ndev) {
- dev_put(pnetelem->ndev);
+ dev_put_track(pnetelem->ndev, &pnetelem->dev_tracker);
pnetelem->ndev = NULL;
rc = 0;
pr_warn_ratelimited("smc: removing net device %s with "
@@ -368,7 +369,7 @@ static int smc_pnet_add_eth(struct smc_pnettable *pnettable, struct net *net,
memcpy(new_pe->pnet_name, pnet_name, SMC_MAX_PNETID_LEN);
strncpy(new_pe->eth_name, eth_name, IFNAMSIZ);
new_pe->ndev = ndev;
-
+ netdev_tracker_alloc(ndev, &new_pe->dev_tracker, GFP_KERNEL);
rc = -EEXIST;
new_netdev = true;
write_lock(&pnettable->lock);
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
` (9 preceding siblings ...)
2021-12-07 1:30 ` [PATCH net-next 10/13] net/smc: add net device tracker to struct smc_pnetentry Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2022-01-04 15:29 ` Johannes Berg
2021-12-07 1:30 ` [PATCH net-next 12/13] openvswitch: add net device refcount tracker to struct vport Eric Dumazet
` (2 subsequent siblings)
13 siblings, 1 reply; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ethtool/netlink.c | 8 +++++---
net/ethtool/netlink.h | 2 ++
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 38b44c0291b11af2c6d59c532c0c4ad4bba2ce27..eaa50af074be563cdac9d700cdb0f9d32a54252c 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -141,6 +141,7 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info,
}
req_info->dev = dev;
+ netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
req_info->flags = flags;
return 0;
}
@@ -399,7 +400,7 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)
ops->cleanup_data(reply_data);
genlmsg_end(rskb, reply_payload);
- dev_put(req_info->dev);
+ dev_put_track(req_info->dev, &req_info->dev_tracker);
kfree(reply_data);
kfree(req_info);
return genlmsg_reply(rskb, info);
@@ -411,7 +412,7 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)
if (ops->cleanup_data)
ops->cleanup_data(reply_data);
err_dev:
- dev_put(req_info->dev);
+ dev_put_track(req_info->dev, &req_info->dev_tracker);
kfree(reply_data);
kfree(req_info);
return ret;
@@ -547,7 +548,7 @@ static int ethnl_default_start(struct netlink_callback *cb)
* same parser as for non-dump (doit) requests is used, it
* would take reference to the device if it finds one
*/
- dev_put(req_info->dev);
+ dev_put_track(req_info->dev, &req_info->dev_tracker);
req_info->dev = NULL;
}
if (ret < 0)
@@ -624,6 +625,7 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
}
req_info->dev = dev;
+ netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
req_info->flags |= ETHTOOL_FLAG_COMPACT_BITSETS;
ethnl_init_reply_data(reply_data, ops, dev);
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 490598e5eedd9a614bf64ced6be482523cad12cf..a779bbb0c524f00e7a798bc8448bebbd43b65488 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -222,6 +222,7 @@ static inline unsigned int ethnl_reply_header_size(void)
/**
* struct ethnl_req_info - base type of request information for GET requests
* @dev: network device the request is for (may be null)
+ * @dev_tracker: refcount tracker for @dev reference
* @flags: request flags common for all request types
*
* This is a common base for request specific structures holding data from
@@ -230,6 +231,7 @@ static inline unsigned int ethnl_reply_header_size(void)
*/
struct ethnl_req_info {
struct net_device *dev;
+ netdevice_tracker dev_tracker;
u32 flags;
};
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 12/13] openvswitch: add net device refcount tracker to struct vport
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
` (10 preceding siblings ...)
2021-12-07 1:30 ` [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 13/13] net: sched: act_mirred: add net device refcount tracker Eric Dumazet
2021-12-08 5:20 ` [PATCH net-next 00/13] net: second round of netdevice refcount tracking patchwork-bot+netdevbpf
13 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/openvswitch/vport-netdev.c | 8 ++++----
net/openvswitch/vport.h | 2 ++
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c
index c1ad6699b1f89d9f00ba85a9f23c89b1661ec812..b498dac4e1e0046f6a325a1cdf0afa38c95ef722 100644
--- a/net/openvswitch/vport-netdev.c
+++ b/net/openvswitch/vport-netdev.c
@@ -82,7 +82,7 @@ struct vport *ovs_netdev_link(struct vport *vport, const char *name)
err = -ENODEV;
goto error_free_vport;
}
-
+ netdev_tracker_alloc(vport->dev, &vport->dev_tracker, GFP_KERNEL);
if (vport->dev->flags & IFF_LOOPBACK ||
(vport->dev->type != ARPHRD_ETHER &&
vport->dev->type != ARPHRD_NONE) ||
@@ -115,7 +115,7 @@ struct vport *ovs_netdev_link(struct vport *vport, const char *name)
error_unlock:
rtnl_unlock();
error_put:
- dev_put(vport->dev);
+ dev_put_track(vport->dev, &vport->dev_tracker);
error_free_vport:
ovs_vport_free(vport);
return ERR_PTR(err);
@@ -137,7 +137,7 @@ static void vport_netdev_free(struct rcu_head *rcu)
{
struct vport *vport = container_of(rcu, struct vport, rcu);
- dev_put(vport->dev);
+ dev_put_track(vport->dev, &vport->dev_tracker);
ovs_vport_free(vport);
}
@@ -173,7 +173,7 @@ void ovs_netdev_tunnel_destroy(struct vport *vport)
*/
if (vport->dev->reg_state == NETREG_REGISTERED)
rtnl_delete_link(vport->dev);
- dev_put(vport->dev);
+ dev_put_track(vport->dev, &vport->dev_tracker);
vport->dev = NULL;
rtnl_unlock();
diff --git a/net/openvswitch/vport.h b/net/openvswitch/vport.h
index 8a930ca6d6b17d88c08536083c0d888cce3e99c2..9de5030d9801c7065a4cf5478cfc3778891a6535 100644
--- a/net/openvswitch/vport.h
+++ b/net/openvswitch/vport.h
@@ -58,6 +58,7 @@ struct vport_portids {
/**
* struct vport - one port within a datapath
* @dev: Pointer to net_device.
+ * @dev_tracker: refcount tracker for @dev reference
* @dp: Datapath to which this port belongs.
* @upcall_portids: RCU protected 'struct vport_portids'.
* @port_no: Index into @dp's @ports array.
@@ -69,6 +70,7 @@ struct vport_portids {
*/
struct vport {
struct net_device *dev;
+ netdevice_tracker dev_tracker;
struct datapath *dp;
struct vport_portids __rcu *upcall_portids;
u16 port_no;
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH net-next 13/13] net: sched: act_mirred: add net device refcount tracker
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
` (11 preceding siblings ...)
2021-12-07 1:30 ` [PATCH net-next 12/13] openvswitch: add net device refcount tracker to struct vport Eric Dumazet
@ 2021-12-07 1:30 ` Eric Dumazet
2021-12-08 5:20 ` [PATCH net-next 00/13] net: second round of netdevice refcount tracking patchwork-bot+netdevbpf
13 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2021-12-07 1:30 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/tc_act/tc_mirred.h | 1 +
net/sched/act_mirred.c | 18 ++++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/include/net/tc_act/tc_mirred.h b/include/net/tc_act/tc_mirred.h
index 1cace4c69e4450963e5392a555d7b3fd9f10456d..32ce8ea36950e86745cc1d31f49e69962ff2c6ee 100644
--- a/include/net/tc_act/tc_mirred.h
+++ b/include/net/tc_act/tc_mirred.h
@@ -10,6 +10,7 @@ struct tcf_mirred {
int tcfm_eaction;
bool tcfm_mac_header_xmit;
struct net_device __rcu *tcfm_dev;
+ netdevice_tracker tcfm_dev_tracker;
struct list_head tcfm_list;
};
#define to_mirred(a) ((struct tcf_mirred *)a)
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index efc963ab995a333ab21ec3d00884097c6a10a2b4..952416bd65e6ae00fe048a32b37252d1ed13ef0a 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -79,7 +79,7 @@ static void tcf_mirred_release(struct tc_action *a)
/* last reference to action, no need to lock */
dev = rcu_dereference_protected(m->tcfm_dev, 1);
- dev_put(dev);
+ dev_put_track(dev, &m->tcfm_dev_tracker);
}
static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = {
@@ -101,7 +101,6 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
bool mac_header_xmit = false;
struct tc_mirred *parm;
struct tcf_mirred *m;
- struct net_device *dev;
bool exists = false;
int ret, err;
u32 index;
@@ -171,16 +170,19 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
spin_lock_bh(&m->tcf_lock);
if (parm->ifindex) {
- dev = dev_get_by_index(net, parm->ifindex);
- if (!dev) {
+ struct net_device *odev, *ndev;
+
+ ndev = dev_get_by_index(net, parm->ifindex);
+ if (!ndev) {
spin_unlock_bh(&m->tcf_lock);
err = -ENODEV;
goto put_chain;
}
- mac_header_xmit = dev_is_mac_header_xmit(dev);
- dev = rcu_replace_pointer(m->tcfm_dev, dev,
+ mac_header_xmit = dev_is_mac_header_xmit(ndev);
+ odev = rcu_replace_pointer(m->tcfm_dev, ndev,
lockdep_is_held(&m->tcf_lock));
- dev_put(dev);
+ dev_put_track(odev, &m->tcfm_dev_tracker);
+ netdev_tracker_alloc(ndev, &m->tcfm_dev_tracker, GFP_ATOMIC);
m->tcfm_mac_header_xmit = mac_header_xmit;
}
goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
@@ -400,7 +402,7 @@ static int mirred_device_event(struct notifier_block *unused,
list_for_each_entry(m, &mirred_list, tcfm_list) {
spin_lock_bh(&m->tcf_lock);
if (tcf_mirred_dev_dereference(m) == dev) {
- dev_put(dev);
+ dev_put_track(dev, &m->tcfm_dev_tracker);
/* Note : no rcu grace period necessary, as
* net_device are already rcu protected.
*/
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH net-next 00/13] net: second round of netdevice refcount tracking
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
` (12 preceding siblings ...)
2021-12-07 1:30 ` [PATCH net-next 13/13] net: sched: act_mirred: add net device refcount tracker Eric Dumazet
@ 2021-12-08 5:20 ` patchwork-bot+netdevbpf
13 siblings, 0 replies; 23+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-08 5:20 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, netdev, edumazet
Hello:
This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 6 Dec 2021 17:30:26 -0800 you wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> The most interesting part of this series is probably
> ("inet: add net device refcount tracker to struct fib_nh_common")
> but only future reports will confirm this guess.
>
> Eric Dumazet (13):
> net: eql: add net device refcount tracker
> vlan: add net device refcount tracker
> net: bridge: add net device refcount tracker
> net: watchdog: add net device refcount tracker
> net: switchdev: add net device refcount tracker
> inet: add net device refcount tracker to struct fib_nh_common
> ax25: add net device refcount tracker
> llc: add net device refcount tracker
> pktgen add net device refcount tracker
> net/smc: add net device tracker to struct smc_pnetentry
> netlink: add net device refcount tracker to struct ethnl_req_info
> openvswitch: add net device refcount tracker to struct vport
> net: sched: act_mirred: add net device refcount tracker
>
> [...]
Here is the summary with links:
- [net-next,01/13] net: eql: add net device refcount tracker
https://git.kernel.org/netdev/net-next/c/08f0b22d731f
- [net-next,02/13] vlan: add net device refcount tracker
https://git.kernel.org/netdev/net-next/c/19c9ebf6ed70
- [net-next,03/13] net: bridge: add net device refcount tracker
https://git.kernel.org/netdev/net-next/c/b2dcdc7f731d
- [net-next,04/13] net: watchdog: add net device refcount tracker
https://git.kernel.org/netdev/net-next/c/f12bf6f3f942
- [net-next,05/13] net: switchdev: add net device refcount tracker
https://git.kernel.org/netdev/net-next/c/4fc003fe0313
- [net-next,06/13] inet: add net device refcount tracker to struct fib_nh_common
https://git.kernel.org/netdev/net-next/c/e44b14ebae10
- [net-next,07/13] ax25: add net device refcount tracker
https://git.kernel.org/netdev/net-next/c/66ce07f7802b
- [net-next,08/13] llc: add net device refcount tracker
https://git.kernel.org/netdev/net-next/c/615d069dcf12
- [net-next,09/13] pktgen add net device refcount tracker
https://git.kernel.org/netdev/net-next/c/035f1f2b96ae
- [net-next,10/13] net/smc: add net device tracker to struct smc_pnetentry
https://git.kernel.org/netdev/net-next/c/b60645248af3
- [net-next,11/13] netlink: add net device refcount tracker to struct ethnl_req_info
https://git.kernel.org/netdev/net-next/c/e4b8954074f6
- [net-next,12/13] openvswitch: add net device refcount tracker to struct vport
https://git.kernel.org/netdev/net-next/c/e7c8ab8419d7
- [net-next,13/13] net: sched: act_mirred: add net device refcount tracker
https://git.kernel.org/netdev/net-next/c/ada066b2e02c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH net-next 10/13] net/smc: add net device tracker to struct smc_pnetentry
2021-12-07 1:30 ` [PATCH net-next 10/13] net/smc: add net device tracker to struct smc_pnetentry Eric Dumazet
@ 2021-12-09 8:05 ` Karsten Graul
0 siblings, 0 replies; 23+ messages in thread
From: Karsten Graul @ 2021-12-09 8:05 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski
Cc: netdev, Eric Dumazet, linux-s390
On 07/12/2021 02:30, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> net/smc/smc_pnet.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
Acked-by: Karsten Graul <kgraul@linux.ibm.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
2021-12-07 1:30 ` [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info Eric Dumazet
@ 2022-01-04 15:29 ` Johannes Berg
2022-01-04 15:44 ` Eric Dumazet
0 siblings, 1 reply; 23+ messages in thread
From: Johannes Berg @ 2022-01-04 15:29 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet
On Mon, 2021-12-06 at 17:30 -0800, Eric Dumazet wrote:
>
> @@ -624,6 +625,7 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
> }
>
> req_info->dev = dev;
> + netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
> req_info->flags |= ETHTOOL_FLAG_COMPACT_BITSETS;
>
I may have missed a follow-up patch (did a search on netdev now, but
...), but I'm hitting warnings from this and I'm not sure it's right?
This req_info is just allocated briefly and freed again, and I'm not
even sure there's a dev_get/dev_put involved here, I didn't see any?
At least it would seem we need to free the tracker at the end of this
function, or perhaps never even create one?
johannes
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
2022-01-04 15:29 ` Johannes Berg
@ 2022-01-04 15:44 ` Eric Dumazet
2022-01-04 16:07 ` Johannes Berg
0 siblings, 1 reply; 23+ messages in thread
From: Eric Dumazet @ 2022-01-04 15:44 UTC (permalink / raw)
To: Johannes Berg; +Cc: Eric Dumazet, David S . Miller, Jakub Kicinski, netdev
On Tue, Jan 4, 2022 at 7:29 AM Johannes Berg <johannes@sipsolutions.net> wrote:
>
> On Mon, 2021-12-06 at 17:30 -0800, Eric Dumazet wrote:
> >
> > @@ -624,6 +625,7 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
> > }
> >
> > req_info->dev = dev;
> > + netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
> > req_info->flags |= ETHTOOL_FLAG_COMPACT_BITSETS;
> >
>
> I may have missed a follow-up patch (did a search on netdev now, but
> ...), but I'm hitting warnings from this and I'm not sure it's right?
>
> This req_info is just allocated briefly and freed again, and I'm not
> even sure there's a dev_get/dev_put involved here, I didn't see any?
We had a fix.
commit 34ac17ecbf575eb079094d44f1bd30c66897aa21
Author: Eric Dumazet <edumazet@google.com>
Date: Tue Dec 14 00:42:30 2021 -0800
ethtool: use ethnl_parse_header_dev_put()
>
> At least it would seem we need to free the tracker at the end of this
> function, or perhaps never even create one?
>
> johannes
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
2022-01-04 15:44 ` Eric Dumazet
@ 2022-01-04 16:07 ` Johannes Berg
2022-01-04 16:22 ` Eric Dumazet
0 siblings, 1 reply; 23+ messages in thread
From: Johannes Berg @ 2022-01-04 16:07 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Eric Dumazet, David S . Miller, Jakub Kicinski, netdev
Hi Eric,
> > > @@ -624,6 +625,7 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
> > > }
> > >
> > > req_info->dev = dev;
> > > + netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
> > > req_info->flags |= ETHTOOL_FLAG_COMPACT_BITSETS;
> > >
> >
> > I may have missed a follow-up patch (did a search on netdev now, but
> > ...), but I'm hitting warnings from this and I'm not sure it's right?
> >
> > This req_info is just allocated briefly and freed again, and I'm not
> > even sure there's a dev_get/dev_put involved here, I didn't see any?
>
> We had a fix.
>
> commit 34ac17ecbf575eb079094d44f1bd30c66897aa21
> Author: Eric Dumazet <edumazet@google.com>
> Date: Tue Dec 14 00:42:30 2021 -0800
>
> ethtool: use ethnl_parse_header_dev_put()
>
Hmm. I have this in my tree, and I don't think it affected
ethnl_default_notify() anyway?
johannes
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
2022-01-04 16:07 ` Johannes Berg
@ 2022-01-04 16:22 ` Eric Dumazet
2022-01-04 16:23 ` Johannes Berg
0 siblings, 1 reply; 23+ messages in thread
From: Eric Dumazet @ 2022-01-04 16:22 UTC (permalink / raw)
To: Johannes Berg; +Cc: Eric Dumazet, David S . Miller, Jakub Kicinski, netdev
On Tue, Jan 4, 2022 at 8:07 AM Johannes Berg <johannes@sipsolutions.net> wrote:
>
> Hi Eric,
>
> > > > @@ -624,6 +625,7 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
> > > > }
> > > >
> > > > req_info->dev = dev;
> > > > + netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
> > > > req_info->flags |= ETHTOOL_FLAG_COMPACT_BITSETS;
> > > >
> > >
> > > I may have missed a follow-up patch (did a search on netdev now, but
> > > ...), but I'm hitting warnings from this and I'm not sure it's right?
> > >
> > > This req_info is just allocated briefly and freed again, and I'm not
> > > even sure there's a dev_get/dev_put involved here, I didn't see any?
> >
> > We had a fix.
> >
> > commit 34ac17ecbf575eb079094d44f1bd30c66897aa21
> > Author: Eric Dumazet <edumazet@google.com>
> > Date: Tue Dec 14 00:42:30 2021 -0800
> >
> > ethtool: use ethnl_parse_header_dev_put()
> >
>
> Hmm. I have this in my tree, and I don't think it affected
> ethnl_default_notify() anyway?
Strange, syzbot have not reported anything there.
ethnl_parse_header_dev_get() needs to take a ref, but
indeed ethnl_default_notify() does its own allocation/freeing.
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index ea23659fab28..5fe8f4ae2ceb 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -627,7 +627,6 @@ static void ethnl_default_notify(struct net_device
*dev, unsigned int cmd,
}
req_info->dev = dev;
- netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
req_info->flags |= ETHTOOL_FLAG_COMPACT_BITSETS;
ethnl_init_reply_data(reply_data, ops, dev);
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
2022-01-04 16:22 ` Eric Dumazet
@ 2022-01-04 16:23 ` Johannes Berg
2022-01-05 16:57 ` Jakub Kicinski
0 siblings, 1 reply; 23+ messages in thread
From: Johannes Berg @ 2022-01-04 16:23 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Eric Dumazet, David S . Miller, Jakub Kicinski, netdev
On Tue, 2022-01-04 at 08:22 -0800, Eric Dumazet wrote:
> On Tue, Jan 4, 2022 at 8:07 AM Johannes Berg <johannes@sipsolutions.net> wrote:
> >
> > Hi Eric,
> >
> > > > > @@ -624,6 +625,7 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
> > > > > }
> > > > >
> > > > > req_info->dev = dev;
> > > > > + netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
> > > > > req_info->flags |= ETHTOOL_FLAG_COMPACT_BITSETS;
> > > > >
> > > >
> > > > I may have missed a follow-up patch (did a search on netdev now, but
> > > > ...), but I'm hitting warnings from this and I'm not sure it's right?
> > > >
> > > > This req_info is just allocated briefly and freed again, and I'm not
> > > > even sure there's a dev_get/dev_put involved here, I didn't see any?
> > >
> > > We had a fix.
> > >
> > > commit 34ac17ecbf575eb079094d44f1bd30c66897aa21
> > > Author: Eric Dumazet <edumazet@google.com>
> > > Date: Tue Dec 14 00:42:30 2021 -0800
> > >
> > > ethtool: use ethnl_parse_header_dev_put()
> > >
> >
> > Hmm. I have this in my tree, and I don't think it affected
> > ethnl_default_notify() anyway?
>
> Strange, syzbot have not reported anything there.
:)
Not sure - I'm hitting it in one of the wireless bridging tests.
>
> ethnl_parse_header_dev_get() needs to take a ref, but
> indeed ethnl_default_notify() does its own allocation/freeing.
Right.
> diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
> index ea23659fab28..5fe8f4ae2ceb 100644
> --- a/net/ethtool/netlink.c
> +++ b/net/ethtool/netlink.c
> @@ -627,7 +627,6 @@ static void ethnl_default_notify(struct net_device
> *dev, unsigned int cmd,
> }
>
> req_info->dev = dev;
> - netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
So I had already tested both this and explicitly doing
netdev_tracker_free() when req_info is freed, both work fine.
Tested-by: Johannes Berg <johannes@sipsolutions.net>
Just wasn't sure it was correct or I was missing something. :)
johannes
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
2022-01-04 16:23 ` Johannes Berg
@ 2022-01-05 16:57 ` Jakub Kicinski
2022-01-05 16:58 ` Eric Dumazet
0 siblings, 1 reply; 23+ messages in thread
From: Jakub Kicinski @ 2022-01-05 16:57 UTC (permalink / raw)
To: Eric Dumazet, Eric Dumazet; +Cc: Johannes Berg, David S . Miller, netdev
On Tue, 04 Jan 2022 17:23:51 +0100 Johannes Berg wrote:
> > diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
> > index ea23659fab28..5fe8f4ae2ceb 100644
> > --- a/net/ethtool/netlink.c
> > +++ b/net/ethtool/netlink.c
> > @@ -627,7 +627,6 @@ static void ethnl_default_notify(struct net_device
> > *dev, unsigned int cmd,
> > }
> >
> > req_info->dev = dev;
> > - netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
>
> So I had already tested both this and explicitly doing
> netdev_tracker_free() when req_info is freed, both work fine.
>
> Tested-by: Johannes Berg <johannes@sipsolutions.net>
>
> Just wasn't sure it was correct or I was missing something. :)
Hi Eric, I didn't see this one submitted, is it coming?
No rush, just checking if it fell thru the cracks.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
2022-01-05 16:57 ` Jakub Kicinski
@ 2022-01-05 16:58 ` Eric Dumazet
0 siblings, 0 replies; 23+ messages in thread
From: Eric Dumazet @ 2022-01-05 16:58 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: Eric Dumazet, Johannes Berg, David S . Miller, netdev
[-- Attachment #1: Type: text/plain, Size: 949 bytes --]
On Wed, Jan 5, 2022 at 8:57 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Tue, 04 Jan 2022 17:23:51 +0100 Johannes Berg wrote:
> > > diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
> > > index ea23659fab28..5fe8f4ae2ceb 100644
> > > --- a/net/ethtool/netlink.c
> > > +++ b/net/ethtool/netlink.c
> > > @@ -627,7 +627,6 @@ static void ethnl_default_notify(struct net_device
> > > *dev, unsigned int cmd,
> > > }
> > >
> > > req_info->dev = dev;
> > > - netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
> >
> > So I had already tested both this and explicitly doing
> > netdev_tracker_free() when req_info is freed, both work fine.
> >
> > Tested-by: Johannes Berg <johannes@sipsolutions.net>
> >
> > Just wasn't sure it was correct or I was missing something. :)
>
> Hi Eric, I didn't see this one submitted, is it coming?
> No rush, just checking if it fell thru the cracks.
Yes, this is coming ;)
[-- Attachment #2: cleardot.gif --]
[-- Type: image/gif, Size: 43 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2022-01-05 16:59 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 1:30 [PATCH net-next 00/13] net: second round of netdevice refcount tracking Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 01/13] net: eql: add net device refcount tracker Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 02/13] vlan: " Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 03/13] net: bridge: " Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 04/13] net: watchdog: " Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 05/13] net: switchdev: " Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 06/13] inet: add net device refcount tracker to struct fib_nh_common Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 07/13] ax25: add net device refcount tracker Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 08/13] llc: " Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 09/13] pktgen " Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 10/13] net/smc: add net device tracker to struct smc_pnetentry Eric Dumazet
2021-12-09 8:05 ` Karsten Graul
2021-12-07 1:30 ` [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info Eric Dumazet
2022-01-04 15:29 ` Johannes Berg
2022-01-04 15:44 ` Eric Dumazet
2022-01-04 16:07 ` Johannes Berg
2022-01-04 16:22 ` Eric Dumazet
2022-01-04 16:23 ` Johannes Berg
2022-01-05 16:57 ` Jakub Kicinski
2022-01-05 16:58 ` Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 12/13] openvswitch: add net device refcount tracker to struct vport Eric Dumazet
2021-12-07 1:30 ` [PATCH net-next 13/13] net: sched: act_mirred: add net device refcount tracker Eric Dumazet
2021-12-08 5:20 ` [PATCH net-next 00/13] net: second round of netdevice refcount tracking patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.