summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolay Aleksandrov <razor@blackwall.org>2022-04-13 13:51:51 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-10-17 16:11:57 +0300
commit21d30b12695a8bc1a600b47d3792378f402dc453 (patch)
tree23724f48b62580c499c5d2475a91948612ff3a69
parent95ad7ee0faee2b76cb58876f71b8f9dc2bb104ba (diff)
downloadlinux-21d30b12695a8bc1a600b47d3792378f402dc453.tar.xz
net: rtnetlink: add msg kind names
[ Upstream commit 12dc5c2cb7b269c5a1c6d02844f40bfce942a7a6 ] Add rtnl kind names instead of using raw values. We'll need to check for DEL kind later to validate bulk flag support. Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org> Signed-off-by: David S. Miller <davem@davemloft.net> Stable-dep-of: d51705614f66 ("mctp: Handle error of rtnl_register_module().") Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--include/net/rtnetlink.h7
-rw-r--r--net/core/rtnetlink.c6
2 files changed, 10 insertions, 3 deletions
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index a2a74e0e5c49..c9d3ae92c932 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -13,6 +13,13 @@ enum rtnl_link_flags {
RTNL_FLAG_DOIT_UNLOCKED = 1,
};
+enum rtnl_kinds {
+ RTNL_KIND_NEW,
+ RTNL_KIND_DEL,
+ RTNL_KIND_GET,
+ RTNL_KIND_SET
+};
+
void rtnl_register(int protocol, int msgtype,
rtnl_doit_func, rtnl_dumpit_func, unsigned int flags);
int rtnl_register_module(struct module *owner, int protocol, int msgtype,
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index eca7f6f4a52f..8fc86d1edf56 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -5521,11 +5521,11 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
{
struct net *net = sock_net(skb->sk);
struct rtnl_link *link;
+ enum rtnl_kinds kind;
struct module *owner;
int err = -EOPNOTSUPP;
rtnl_doit_func doit;
unsigned int flags;
- int kind;
int family;
int type;
@@ -5542,11 +5542,11 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
family = ((struct rtgenmsg *)nlmsg_data(nlh))->rtgen_family;
kind = type&3;
- if (kind != 2 && !netlink_net_capable(skb, CAP_NET_ADMIN))
+ if (kind != RTNL_KIND_GET && !netlink_net_capable(skb, CAP_NET_ADMIN))
return -EPERM;
rcu_read_lock();
- if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
+ if (kind == RTNL_KIND_GET && (nlh->nlmsg_flags & NLM_F_DUMP)) {
struct sock *rtnl;
rtnl_dumpit_func dumpit;
u32 min_dump_alloc = 0;