summaryrefslogtreecommitdiff
path: root/net/mctp
diff options
context:
space:
mode:
authorJeremy Kerr <jk@codeconstruct.com.au>2022-02-18 07:25:53 +0300
committerJoel Stanley <joel@jms.id.au>2022-03-18 03:38:45 +0300
commit50126574fd6ab6dcaad87b2c0d0c32d74a4e3db2 (patch)
tree57a483f44f5beac21f8d0f36c1c4c7f532fbba29 /net/mctp
parentde095564ecb4b484458a67dc2756fb1e5ffd6e77 (diff)
downloadlinux-50126574fd6ab6dcaad87b2c0d0c32d74a4e3db2.tar.xz
mctp: replace mctp_address_ok with more fine-grained helpers
Currently, we have mctp_address_ok(), which checks if an EID is in the "valid" range of 8-254 inclusive. However, 0 and 255 may also be valid addresses, depending on context. 0 is the NULL EID, which may be set when physical addressing is used. 255 is valid as a destination address for broadcasts. This change renames mctp_address_ok to mctp_address_unicast, and adds similar helpers for broadcast and null EIDs, which will be used in an upcoming commit. OpenBMC-Staging-Count: 1 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit cb196b725936f6b776ad1d073f66fbe92aa798fa) Signed-off-by: Joel Stanley <joel@jms.id.au>
Diffstat (limited to 'net/mctp')
-rw-r--r--net/mctp/device.c2
-rw-r--r--net/mctp/neigh.c2
-rw-r--r--net/mctp/route.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/net/mctp/device.c b/net/mctp/device.c
index ef2755f82f87..380ef4cf8948 100644
--- a/net/mctp/device.c
+++ b/net/mctp/device.c
@@ -208,7 +208,7 @@ static int mctp_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh,
if (!mdev)
return -ENODEV;
- if (!mctp_address_ok(addr->s_addr))
+ if (!mctp_address_unicast(addr->s_addr))
return -EINVAL;
/* Prevent duplicates. Under RTNL so don't need to lock for reading */
diff --git a/net/mctp/neigh.c b/net/mctp/neigh.c
index 6ad3e33bd4d4..ffa0f9e0983f 100644
--- a/net/mctp/neigh.c
+++ b/net/mctp/neigh.c
@@ -143,7 +143,7 @@ static int mctp_rtm_newneigh(struct sk_buff *skb, struct nlmsghdr *nlh,
}
eid = nla_get_u8(tb[NDA_DST]);
- if (!mctp_address_ok(eid)) {
+ if (!mctp_address_unicast(eid)) {
NL_SET_ERR_MSG(extack, "Invalid neighbour EID");
return -EINVAL;
}
diff --git a/net/mctp/route.c b/net/mctp/route.c
index 0c4c56e1bd6e..6a11d78cfbab 100644
--- a/net/mctp/route.c
+++ b/net/mctp/route.c
@@ -962,7 +962,7 @@ static int mctp_route_add(struct mctp_dev *mdev, mctp_eid_t daddr_start,
struct net *net = dev_net(mdev->dev);
struct mctp_route *rt, *ert;
- if (!mctp_address_ok(daddr_start))
+ if (!mctp_address_unicast(daddr_start))
return -EINVAL;
if (daddr_extent > 0xff || daddr_start + daddr_extent >= 255)