public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: <yang.yang29@zte.com.cn>
To: <davem@davemloft.net>
Cc: <dsahern@kernel.org>, <edumazet@google.com>, <kuba@kernel.org>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] net: add net device refcount tracker to pneigh_queue
Date: Fri, 4 Aug 2023 16:57:46 +0800 (CST)	[thread overview]
Message-ID: <202308041657467504029@zte.com.cn> (raw)

From: xu xin <xu.xin16@zte.com.cn>

Add a static net device refcount tracker to neighbour.c to track
dev's refcnt when pneigh enqueuing and dequeuing.

Signed-off-by: xu xin <xu.xin16@zte.com.cn>
Reviewed-by: Yang Yang <yang.yang.29@zte.com.cn>
Cc: Kuang Mingfu <kuang.mingfu@zte.com.cn>
---
 net/core/neighbour.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index ddd0f32de20e..56e87130fa95 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -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);
-- 
2.15.2

             reply	other threads:[~2023-08-04  9:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04  8:57 yang.yang29 [this message]
2023-08-04 12:01 ` [PATCH] net: add net device refcount tracker to pneigh_queue Eric Dumazet
2023-08-05  6:46   ` xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202308041657467504029@zte.com.cn \
    --to=yang.yang29@zte.com.cn \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox