net: rtnetlink: add msg kind names
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>
This commit is contained in:
committed by
David S. Miller
parent
ae10162c7e
commit
12dc5c2cb7
@@ -13,6 +13,13 @@ enum rtnl_link_flags {
|
|||||||
RTNL_FLAG_DOIT_UNLOCKED = 1,
|
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,
|
void rtnl_register(int protocol, int msgtype,
|
||||||
rtnl_doit_func, rtnl_dumpit_func, unsigned int flags);
|
rtnl_doit_func, rtnl_dumpit_func, unsigned int flags);
|
||||||
int rtnl_register_module(struct module *owner, int protocol, int msgtype,
|
int rtnl_register_module(struct module *owner, int protocol, int msgtype,
|
||||||
|
|||||||
@@ -5928,11 +5928,11 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||||||
{
|
{
|
||||||
struct net *net = sock_net(skb->sk);
|
struct net *net = sock_net(skb->sk);
|
||||||
struct rtnl_link *link;
|
struct rtnl_link *link;
|
||||||
|
enum rtnl_kinds kind;
|
||||||
struct module *owner;
|
struct module *owner;
|
||||||
int err = -EOPNOTSUPP;
|
int err = -EOPNOTSUPP;
|
||||||
rtnl_doit_func doit;
|
rtnl_doit_func doit;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
int kind;
|
|
||||||
int family;
|
int family;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
@@ -5949,11 +5949,11 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||||||
family = ((struct rtgenmsg *)nlmsg_data(nlh))->rtgen_family;
|
family = ((struct rtgenmsg *)nlmsg_data(nlh))->rtgen_family;
|
||||||
kind = type&3;
|
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;
|
return -EPERM;
|
||||||
|
|
||||||
rcu_read_lock();
|
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;
|
struct sock *rtnl;
|
||||||
rtnl_dumpit_func dumpit;
|
rtnl_dumpit_func dumpit;
|
||||||
u32 min_dump_alloc = 0;
|
u32 min_dump_alloc = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user