net: add net device refcount tracker to pneigh_queue
Subsystems (2)
PATCH 1/1 net: add net device refcount tracker to pneigh_queue
From: xu xin <[email protected]>
Add a static net device refcount tracker to neighbour.c to track dev's refcnt when pneigh enqueuing and dequeuing.
--- net/core/neighbour.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/core/neighbour.c +4 -3
@@ -61,6 +61,7 @@ static int pneigh_ifdown_and_unlock(struct neigh_table *tbl,static const struct seq_operations neigh_stat_seq_ops;#endif +static netdevice_tracker pneigh_queue_dev_tracker;/* Neighbour hash table buckets are protected with rwlock tbl->lock.
@@ -364,7 +365,7 @@ static void pneigh_queue_purge(struct sk_buff_head *list, struct net *net,spin_unlock_irqrestore (&list->lock, flags);while ((skb =__skb_dequeue (&tmp))) { -dev_put (skb->dev); +netdev_put (skb->dev, &pneigh_queue_dev_tracker);kfree_skb (skb); } }
@@ -1633,7 +1634,7 @@ static void neigh_proxy_process(struct timer_list *t)kfree_skb (skb); } -dev_put (dev); +netdev_put (skb->dev, &pneigh_queue_dev_tracker); }else if (!sched_next || tdif < sched_next) sched_next = tdif; }
@@ -1673,7 +1674,7 @@ void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, sched_next = tbl->proxy_timer.expires; }skb_dst_drop (skb); -dev_hold (skb->dev); +netdev_hold (skb->dev, &pneigh_queue_dev_tracker,GFP_KERNEL );__skb_queue_tail (&tbl->proxy_queue, skb); p->qlen++;mod_timer (&tbl->proxy_timer, sched_next);
Signature · 1 line
2.15.2
Quoted 10 lines · On Fri, Aug 4, 2023 at 10:58 AM <[email protected]> wrote:
From: xu xin <[email protected]>
Add a static net device refcount tracker to
neighbour.cto track dev's refcnt when pneigh enqueuing and dequeuing.Signed-off-by xu xin <[email protected]>Reviewed-by Yang Yang <[email protected]>Cc Kuang Mingfu <[email protected]>---
Can you explain how this patch was tested ?
Thanks.
PATCH 1/1 net: add net device refcount tracker to pneigh_queue
Quoted 9 lines
Quoted 7 lines
Add a static net device refcount tracker to
neighbour.cto track dev's refcnt when pneigh enqueuing and dequeuing.Signed-off-by xu xin <[email protected]>Reviewed-by Yang Yang <[email protected]>Cc Kuang Mingfu <[email protected]>---
Quoted 3 lines
Can you explain how this patch was tested ?
Thanks.
Sorry, I misunderstand the usage of netdev_hold and its netdevice_tracker.
I thought this tracker was simple enough, so I just added an additional netdev_hold in the same postion and test if there is a warning "unregister_netdevice: waiting for ...".
But as you said, we need a separate netdevice_tracker per netdev_hold(), and specially per dev?
Actually, I'm still a little confused.
For example, here, can I move this netdevice_tracker into struct sk_buff ?
Quoted 39 lines
net/core/neighbour.c +4
-3@@ -61,6 +61,7 @@ static int pneigh_ifdown_and_unlock(struct neigh_table *tbl,static const struct seq_operations neigh_stat_seq_ops;#endif +static netdevice_tracker pneigh_queue_dev_tracker;/* Neighbour hash table buckets are protected with rwlock tbl->lock. @@ -364,7 +365,7 @@ static void pneigh_queue_purge(struct sk_buff_head *list, struct net *net,spin_unlock_irqrestore (&list->lock, flags);while ((skb =__skb_dequeue (&tmp))) { -dev_put (skb->dev); +netdev_put (skb->dev, &pneigh_queue_dev_tracker);kfree_skb (skb); } }@@ -1633,7 +1634,7 @@ static void neigh_proxy_process(struct timer_list *t)kfree_skb (skb); } -dev_put (dev); +netdev_put (skb->dev, &pneigh_queue_dev_tracker); }else if (!sched_next || tdif < sched_next) sched_next = tdif; }@@ -1673,7 +1674,7 @@ void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, sched_next = tbl->proxy_timer.expires; }skb_dst_drop (skb); -dev_hold (skb->dev); +netdev_hold (skb->dev, &pneigh_queue_dev_tracker,GFP_KERNEL );__skb_queue_tail (&tbl->proxy_queue, skb); p->qlen++;mod_timer (&tbl->proxy_timer, sched_next);