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. Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
47f0bd5032
commit
cb196b7259
|
@ -40,11 +40,21 @@ struct mctp_hdr {
|
|||
|
||||
#define MCTP_INITIAL_DEFAULT_NET 1
|
||||
|
||||
static inline bool mctp_address_ok(mctp_eid_t eid)
|
||||
static inline bool mctp_address_unicast(mctp_eid_t eid)
|
||||
{
|
||||
return eid >= 8 && eid < 255;
|
||||
}
|
||||
|
||||
static inline bool mctp_address_broadcast(mctp_eid_t eid)
|
||||
{
|
||||
return eid == 255;
|
||||
}
|
||||
|
||||
static inline bool mctp_address_null(mctp_eid_t eid)
|
||||
{
|
||||
return eid == 0;
|
||||
}
|
||||
|
||||
static inline bool mctp_address_matches(mctp_eid_t match, mctp_eid_t eid)
|
||||
{
|
||||
return match == eid || match == MCTP_ADDR_ANY;
|
||||
|
|
|
@ -209,7 +209,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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue