From: Gagan Kumar <gagan1kumar.cs@gmail.com>
To: kuba@kernel.org, jk@codeconstruct.com.au
Cc: matt@codeconstruct.com.au, davem@davemloft.net,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Gagan Kumar <gagan1kumar.cs@gmail.com>
Subject: [PATCH v2] mctp: Remove only static neighbour on RTM_DELNEIGH
Date: Sat, 1 Jan 2022 11:11:25 +0530 [thread overview]
Message-ID: <20220101054125.9104-1-gagan1kumar.cs@gmail.com> (raw)
In-Reply-To: <20211231181709.7f46dbfc@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>
Add neighbour source flag in mctp_neigh_remove(...) to allow removal of
only static neighbours.
This should be a no-op change and might be useful later when mctp can
have MCTP_NEIGH_DISCOVER neighbours.
Signed-off-by: Gagan Kumar <gagan1kumar.cs@gmail.com>
---
Changes in v2:
- Add motivation and impact in the commit message.
- Split long line > 80 chars into two.
net/mctp/neigh.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/mctp/neigh.c b/net/mctp/neigh.c
index 5cc042121493..6ad3e33bd4d4 100644
--- a/net/mctp/neigh.c
+++ b/net/mctp/neigh.c
@@ -85,8 +85,8 @@ void mctp_neigh_remove_dev(struct mctp_dev *mdev)
mutex_unlock(&net->mctp.neigh_lock);
}
-// TODO: add a "source" flag so netlink can only delete static neighbours?
-static int mctp_neigh_remove(struct mctp_dev *mdev, mctp_eid_t eid)
+static int mctp_neigh_remove(struct mctp_dev *mdev, mctp_eid_t eid,
+ enum mctp_neigh_source source)
{
struct net *net = dev_net(mdev->dev);
struct mctp_neigh *neigh, *tmp;
@@ -94,7 +94,8 @@ static int mctp_neigh_remove(struct mctp_dev *mdev, mctp_eid_t eid)
mutex_lock(&net->mctp.neigh_lock);
list_for_each_entry_safe(neigh, tmp, &net->mctp.neighbours, list) {
- if (neigh->dev == mdev && neigh->eid == eid) {
+ if (neigh->dev == mdev && neigh->eid == eid &&
+ neigh->source == source) {
list_del_rcu(&neigh->list);
/* TODO: immediate RTM_DELNEIGH */
call_rcu(&neigh->rcu, __mctp_neigh_free);
@@ -202,7 +203,7 @@ static int mctp_rtm_delneigh(struct sk_buff *skb, struct nlmsghdr *nlh,
if (!mdev)
return -ENODEV;
- return mctp_neigh_remove(mdev, eid);
+ return mctp_neigh_remove(mdev, eid, MCTP_NEIGH_STATIC);
}
static int mctp_fill_neigh(struct sk_buff *skb, u32 portid, u32 seq, int event,
--
2.32.0
next prev parent reply other threads:[~2022-01-01 5:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-28 13:09 [PATCH] mctp: Remove only static neighbour on RTM_DELNEIGH Gagan Kumar
2021-12-31 1:51 ` Jakub Kicinski
2021-12-31 3:33 ` Jeremy Kerr
2021-12-31 12:14 ` Gagan Kumar
2022-01-01 2:17 ` Jakub Kicinski
2022-01-01 5:41 ` Gagan Kumar [this message]
2022-01-02 12:20 ` [PATCH v2] " patchwork-bot+netdevbpf
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=20220101054125.9104-1-gagan1kumar.cs@gmail.com \
--to=gagan1kumar.cs@gmail.com \
--cc=davem@davemloft.net \
--cc=jk@codeconstruct.com.au \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@codeconstruct.com.au \
--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;
as well as URLs for NNTP newsgroup(s).