]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: rtnetlink: add helper to extract msg type's kind
authorNikolay Aleksandrov <razor@blackwall.org>
Wed, 13 Apr 2022 10:51:52 +0000 (13:51 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Oct 2025 13:03:10 +0000 (14:03 +0100)
[ Upstream commit 2e9ea3e30f696fd438319c07836422bb0bbb4608 ]

Add a helper which extracts the msg type's kind using the kind mask (0x3).

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: bf29555f5bdc ("rtnetlink: Allow deleting FDB entries in user namespace")
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/net/rtnetlink.h
net/core/rtnetlink.c

index dcb1c92e69879e1e586155f8af709febf3fb1b33..d2961e2ed30bdeaf0c48231128e38acb6a863c32 100644 (file)
@@ -19,6 +19,12 @@ enum rtnl_kinds {
        RTNL_KIND_GET,
        RTNL_KIND_SET
 };
+#define RTNL_KIND_MASK 0x3
+
+static inline enum rtnl_kinds rtnl_msgtype_kind(int msgtype)
+{
+       return msgtype & RTNL_KIND_MASK;
+}
 
 struct rtnl_msg_handler {
        struct module *owner;
index e8e67429e437f06585005f432f6320b7399a4f36..79fb6d74e6dab83964244223f9ad38341e51ca45 100644 (file)
@@ -5572,7 +5572,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
                return 0;
 
        family = ((struct rtgenmsg *)nlmsg_data(nlh))->rtgen_family;
-       kind = type&3;
+       kind = rtnl_msgtype_kind(type);
 
        if (kind != RTNL_KIND_GET && !netlink_net_capable(skb, CAP_NET_ADMIN))
                return -EPERM;