Skip to content

Commit 76d0016

Browse files
mkjdavem330
authored andcommitted
mctp: Don't let RTM_DELROUTE delete local routes
We need to test against the existing route type, not the rtm_type in the netlink request. Fixes: 83f0a0b ("mctp: Specify route types, require rtm_type in RTM_*ROUTE messages") Signed-off-by: Matt Johnston <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 00e158f commit 76d0016

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

net/mctp/route.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ static int mctp_route_add(struct mctp_dev *mdev, mctp_eid_t daddr_start,
952952
}
953953

954954
static int mctp_route_remove(struct mctp_dev *mdev, mctp_eid_t daddr_start,
955-
unsigned int daddr_extent)
955+
unsigned int daddr_extent, unsigned char type)
956956
{
957957
struct net *net = dev_net(mdev->dev);
958958
struct mctp_route *rt, *tmp;
@@ -969,7 +969,8 @@ static int mctp_route_remove(struct mctp_dev *mdev, mctp_eid_t daddr_start,
969969

970970
list_for_each_entry_safe(rt, tmp, &net->mctp.routes, list) {
971971
if (rt->dev == mdev &&
972-
rt->min == daddr_start && rt->max == daddr_end) {
972+
rt->min == daddr_start && rt->max == daddr_end &&
973+
rt->type == type) {
973974
list_del_rcu(&rt->list);
974975
/* TODO: immediate RTM_DELROUTE */
975976
mctp_route_release(rt);
@@ -987,7 +988,7 @@ int mctp_route_add_local(struct mctp_dev *mdev, mctp_eid_t addr)
987988

988989
int mctp_route_remove_local(struct mctp_dev *mdev, mctp_eid_t addr)
989990
{
990-
return mctp_route_remove(mdev, addr, 0);
991+
return mctp_route_remove(mdev, addr, 0, RTN_LOCAL);
991992
}
992993

993994
/* removes all entries for a given device */
@@ -1195,7 +1196,7 @@ static int mctp_delroute(struct sk_buff *skb, struct nlmsghdr *nlh,
11951196
if (rtm->rtm_type != RTN_UNICAST)
11961197
return -EINVAL;
11971198

1198-
rc = mctp_route_remove(mdev, daddr_start, rtm->rtm_dst_len);
1199+
rc = mctp_route_remove(mdev, daddr_start, rtm->rtm_dst_len, RTN_UNICAST);
11991200
return rc;
12001201
}
12011202

0 commit comments

Comments
 (0)