net: second round of netdevice refcount tracking
Subsystems (11)
cover net: second round of netdevice refcount tracking
From: Eric Dumazet <[email protected]>
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(-)
Signature · 1 line
2.34.1.400.ga245620fadb-goog
PATCH 1/13 net: eql: add net device refcount tracker
From: Eric Dumazet <[email protected]>
--- drivers/net/eql.c | 4 ++-- include/linux/if_eql.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/eql.c +2 -2
@@ -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 ;
include/linux/if_eql.h +1 -0
@@ -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;
Signature · 1 line
2.34.1.400.ga245620fadb-goog
PATCH 2/13 vlan: add net device refcount tracker
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- include/linux/if_vlan.h | 3 +++ net/8021q/vlan_dev.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
include/linux/if_vlan.h +3 -0
@@ -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;
net/8021q/vlan_dev.c +2 -2
@@ -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)
Signature · 1 line
2.34.1.400.ga245620fadb-goog
PATCH 3/13 net: bridge: add net device refcount tracker
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- net/bridge/br_if.c | 6 +++--- net/bridge/br_private.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-)
net/bridge/br_if.c +3 -3
@@ -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); }
net/bridge/br_private.h +1 -0
@@ -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;
Signature · 1 line
2.34.1.400.ga245620fadb-goog
PATCH 4/13 net: watchdog: add net device refcount tracker
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
Add a netdevice_tracker inside struct net_device, to track the self reference when a device has an active watchdog timer.
--- include/linux/netdevice.h | 2 ++ net/sched/sch_generic.c | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-)
include/linux/netdevice.h +2 -0
@@ -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)
net/sched/sch_generic.c +6 -4
@@ -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); }
Signature · 1 line
2.34.1.400.ga245620fadb-goog
PATCH 5/13 net: switchdev: add net device refcount tracker
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- net/switchdev/switchdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/switchdev/switchdev.c +3 -2
@@ -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);
Signature · 1 line
2.34.1.400.ga245620fadb-goog
PATCH 6/13 inet: add net device refcount tracker to struct fib_nh_common
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- include/net/ip_fib.h | 2 ++ net/ipv4/fib_semantics.c | 12 +++++++----- net/ipv6/route.c | 2 ++ 3 files changed, 11 insertions(+), 5 deletions(-)
include/net/ip_fib.h +2 -0
@@ -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
net/ipv4/fib_semantics.c +7 -5
@@ -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 ;
net/ipv6/route.c +2 -0
@@ -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:
Signature · 1 line
2.34.1.400.ga245620fadb-goog
PATCH 7/13 ax25: add net device refcount tracker
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- include/net/ax25.h | 3 +++ net/ax25/ax25_dev.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-)
include/net/ax25.h +3 -0
@@ -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];
net/ax25/ax25_dev.c +4 -4
@@ -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); }
Signature · 1 line
2.34.1.400.ga245620fadb-goog
PATCH 8/13 llc: add net device refcount tracker
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- include/net/llc_conn.h | 1 + net/llc/af_llc.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)
include/net/llc_conn.h +1 -0
@@ -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;
net/llc/af_llc.c +3 -2
@@ -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;
Signature · 1 line
2.34.1.400.ga245620fadb-goog
PATCH 9/13 pktgen add net device refcount tracker
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- net/core/pktgen.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/core/pktgen.c +5 -3
@@ -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_XFRMfree_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 ; }
Signature · 1 line
2.34.1.400.ga245620fadb-goog
PATCH 10/13 net/smc: add net device tracker to struct smc_pnetentry
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- net/smc/smc_pnet.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/smc/smc_pnet.c +5 -4
@@ -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);
Signature · 1 line
2.34.1.400.ga245620fadb-goog
Re: [PATCH net-next 10/13] net/smc: add net device tracker to struct smc_pnetentry
Quoted 7 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
Signed-off-by Eric Dumazet <[email protected]>--- net/smc/smc_pnet.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
PATCH 11/13 netlink: add net device refcount tracker to struct ethnl_req_info
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- net/ethtool/netlink.c | 8 +++++--- net/ethtool/netlink.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-)
net/ethtool/netlink.c +5 -3
@@ -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);
net/ethtool/netlink.h +2 -0
@@ -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; };
Signature · 1 line
2.34.1.400.ga245620fadb-goog
Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
net/ethtool/netlink.c static void ethnl_default_notify(struct net_device *dev, unsigned int cmd, · line 630
Quoted 8 lines · Eric Dumazet
net/ethtool/netlink.c +1
-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 ;
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
Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
Quoted 14 lines · Johannes Berg
net/ethtool/netlink.c static void ethnl_default_notify(struct net_device *dev, unsigned int cmd, · line 630
Quoted 8 lines · Eric Dumazet
net/ethtool/netlink.c +1
-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 ;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?
Quoted 2 lines
This
req_infois 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 <[email protected]> Date: Tue Dec 14 00:42:30 2021 -0800
ethtool: use ethnl_parse_header_dev_put()
Quoted 5 lines
At least it would seem we need to free the tracker at the end of this function, or perhaps never even create one?
johannes
Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
Hi Eric,
Quoted 14 lines
Quoted 11 lines
net/ethtool/netlink.c static void ethnl_default_notify(struct net_device *dev, unsigned int cmd, · line 630
Quoted 7 lines
net/ethtool/netlink.c +1
-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 ;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?
Quoted 2 lines
This
req_infois 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?
Quoted 8 lines
We had a fix.
commit
34ac17ecbf575eb079094d44f1bd30c66897aa21Author: Eric Dumazet <[email protected]> Date: Tue Dec 14 00:42:30 2021 -0800ethtool: 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
Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
Quoted 23 lines · Johannes Berg
Hi Eric,
Quoted 20 lines
Quoted 11 lines
Review static void ethnl_default_notify(struct net_device *dev, unsigned int cmd, · line 630
Quoted 7 lines
(quoted diff) +1
-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;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?
Quoted 2 lines
This
req_infois 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
34ac17ecbf575eb079094d44f1bd30c66897aa21Author: Eric Dumazet <[email protected]> Date: Tue Dec 14 00:42:30 2021 -0800
Quoted 5 lines
Quoted 2 lines
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.
net/ethtool/netlink.c +0 -0
@@ -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);Johannes Berg
Tested-byRe: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
Quoted 24 lines · Eric Dumazet
Quoted 23 lines · Johannes Berg
Hi Eric,
Quoted 20 lines
Quoted 11 lines
Review static void ethnl_default_notify(struct net_device *dev, unsigned int cmd, · line 630
Quoted 7 lines
(quoted diff) +1
-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;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?
Quoted 2 lines
This
req_infois 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
34ac17ecbf575eb079094d44f1bd30c66897aa21Author: Eric Dumazet <[email protected]> Date: Tue Dec 14 00:42:30 2021 -0800
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
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.
Quoted 3 lines
ethnl_parse_header_dev_get()needs to take a ref, but indeedethnl_default_notify()does its own allocation/freeing.
Right.
net/ethtool/netlink.c static void ethnl_default_notify(struct net_device · line 631
Quoted 10 lines
net/ethtool/netlink.c +0
-1@@ -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.
Just wasn't sure it was correct or I was missing something. :)
johannes
Jakub Kicinski
maintainerRe: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
Quoted 14 lines · On Tue, 04 Jan 2022 17:23:51 +0100 Johannes Berg wrote:
net/ethtool/netlink.c static void ethnl_default_notify(struct net_device · line 631
Quoted 10 lines
net/ethtool/netlink.c +0
-1@@ -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()whenreq_infois freed, both work fine.
Quoted 3 lines
Tested-by Johannes Berg <[email protected]>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.
Re: [PATCH net-next 11/13] netlink: add net device refcount tracker to struct ethnl_req_info
Quoted 16 lines · Jakub Kicinski
Quoted 14 lines · On Tue, 04 Jan 2022 17:23:51 +0100 Johannes Berg wrote:
net/ethtool/netlink.c static void ethnl_default_notify(struct net_device · line 631
Quoted 10 lines
net/ethtool/netlink.c +0
-1@@ -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()whenreq_infois freed, both work fine.
Quoted 6 lines
Quoted 3 lines
Tested-by Johannes Berg <[email protected]>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 ;)
PATCH 12/13 openvswitch: add net device refcount tracker to struct vport
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- net/openvswitch/vport-netdev.c | 8 ++++---- net/openvswitch/vport.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-)
net/openvswitch/vport-netdev.c +4 -4
@@ -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 ();
net/openvswitch/vport.h +2 -0
@@ -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;
Signature · 1 line
2.34.1.400.ga245620fadb-goog
PATCH 13/13 net: sched: act_mirred: add net device refcount tracker
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- include/net/tc_act/tc_mirred.h | 1 + net/sched/act_mirred.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-)
include/net/tc_act/tc_mirred.h +1 -0
@@ -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)
net/sched/act_mirred.c +10 -8
@@ -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. */
Signature · 1 line
2.34.1.400.ga245620fadb-goog
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 21 lines · On Mon, 6 Dec 2021 17:30:26 -0800 you wrote:
From: Eric Dumazet <[email protected]>
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 structfib_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 structsmc_pnetentry
netlink: add net device refcount tracker to structethnl_req_info
openvswitch: add net device refcount tracker to struct vport
net: sched:act_mirred: add net device refcount tracker
Quoted 1 line
[...]
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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html