Skip to content

Commit

Permalink
mctp: Remove only static neighbour on RTM_DELNEIGH
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
scopeInfinity authored and davem330 committed Jan 2, 2022
1 parent d6d8683 commit ae81de7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions net/mctp/neigh.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,17 @@ 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;
bool dropped = false;

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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ae81de7

Please sign in to comment.