Commit 7c8d4cb4 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[NETFILTER]: nfnetlink: make subsystem and callbacks const

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 169e3674
...@@ -118,9 +118,9 @@ struct nfnl_callback ...@@ -118,9 +118,9 @@ struct nfnl_callback
struct nfnetlink_subsystem struct nfnetlink_subsystem
{ {
const char *name; const char *name;
__u8 subsys_id; /* nfnetlink subsystem ID */ __u8 subsys_id; /* nfnetlink subsystem ID */
__u8 cb_count; /* number of callbacks */ __u8 cb_count; /* number of callbacks */
struct nfnl_callback *cb; /* callback for individual types */ const struct nfnl_callback *cb; /* callback for individual types */
}; };
extern void __nfa_fill(struct sk_buff *skb, int attrtype, extern void __nfa_fill(struct sk_buff *skb, int attrtype,
...@@ -129,8 +129,8 @@ extern void __nfa_fill(struct sk_buff *skb, int attrtype, ...@@ -129,8 +129,8 @@ extern void __nfa_fill(struct sk_buff *skb, int attrtype,
({ if (skb_tailroom(skb) < (int)NFA_SPACE(attrlen)) goto nfattr_failure; \ ({ if (skb_tailroom(skb) < (int)NFA_SPACE(attrlen)) goto nfattr_failure; \
__nfa_fill(skb, attrtype, attrlen, data); }) __nfa_fill(skb, attrtype, attrlen, data); })
extern int nfnetlink_subsys_register(struct nfnetlink_subsystem *n); extern int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n);
extern int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n); extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n);
extern void nfattr_parse(struct nfattr *tb[], int maxattr, extern void nfattr_parse(struct nfattr *tb[], int maxattr,
struct nfattr *nfa, int len); struct nfattr *nfa, int len);
......
...@@ -1548,7 +1548,7 @@ static struct notifier_block ctnl_notifier_exp = { ...@@ -1548,7 +1548,7 @@ static struct notifier_block ctnl_notifier_exp = {
}; };
#endif #endif
static struct nfnl_callback ctnl_cb[IPCTNL_MSG_MAX] = { static const struct nfnl_callback ctnl_cb[IPCTNL_MSG_MAX] = {
[IPCTNL_MSG_CT_NEW] = { .call = ctnetlink_new_conntrack, [IPCTNL_MSG_CT_NEW] = { .call = ctnetlink_new_conntrack,
.attr_count = CTA_MAX, }, .attr_count = CTA_MAX, },
[IPCTNL_MSG_CT_GET] = { .call = ctnetlink_get_conntrack, [IPCTNL_MSG_CT_GET] = { .call = ctnetlink_get_conntrack,
...@@ -1559,7 +1559,7 @@ static struct nfnl_callback ctnl_cb[IPCTNL_MSG_MAX] = { ...@@ -1559,7 +1559,7 @@ static struct nfnl_callback ctnl_cb[IPCTNL_MSG_MAX] = {
.attr_count = CTA_MAX, }, .attr_count = CTA_MAX, },
}; };
static struct nfnl_callback ctnl_exp_cb[IPCTNL_MSG_EXP_MAX] = { static const struct nfnl_callback ctnl_exp_cb[IPCTNL_MSG_EXP_MAX] = {
[IPCTNL_MSG_EXP_GET] = { .call = ctnetlink_get_expect, [IPCTNL_MSG_EXP_GET] = { .call = ctnetlink_get_expect,
.attr_count = CTA_EXPECT_MAX, }, .attr_count = CTA_EXPECT_MAX, },
[IPCTNL_MSG_EXP_NEW] = { .call = ctnetlink_new_expect, [IPCTNL_MSG_EXP_NEW] = { .call = ctnetlink_new_expect,
...@@ -1568,14 +1568,14 @@ static struct nfnl_callback ctnl_exp_cb[IPCTNL_MSG_EXP_MAX] = { ...@@ -1568,14 +1568,14 @@ static struct nfnl_callback ctnl_exp_cb[IPCTNL_MSG_EXP_MAX] = {
.attr_count = CTA_EXPECT_MAX, }, .attr_count = CTA_EXPECT_MAX, },
}; };
static struct nfnetlink_subsystem ctnl_subsys = { static const struct nfnetlink_subsystem ctnl_subsys = {
.name = "conntrack", .name = "conntrack",
.subsys_id = NFNL_SUBSYS_CTNETLINK, .subsys_id = NFNL_SUBSYS_CTNETLINK,
.cb_count = IPCTNL_MSG_MAX, .cb_count = IPCTNL_MSG_MAX,
.cb = ctnl_cb, .cb = ctnl_cb,
}; };
static struct nfnetlink_subsystem ctnl_exp_subsys = { static const struct nfnetlink_subsystem ctnl_exp_subsys = {
.name = "conntrack_expect", .name = "conntrack_expect",
.subsys_id = NFNL_SUBSYS_CTNETLINK_EXP, .subsys_id = NFNL_SUBSYS_CTNETLINK_EXP,
.cb_count = IPCTNL_MSG_EXP_MAX, .cb_count = IPCTNL_MSG_EXP_MAX,
......
...@@ -41,7 +41,7 @@ MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_NETFILTER); ...@@ -41,7 +41,7 @@ MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_NETFILTER);
static char __initdata nfversion[] = "0.30"; static char __initdata nfversion[] = "0.30";
static struct sock *nfnl = NULL; static struct sock *nfnl = NULL;
static struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT]; static const struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT];
static DEFINE_MUTEX(nfnl_mutex); static DEFINE_MUTEX(nfnl_mutex);
static void nfnl_lock(void) static void nfnl_lock(void)
...@@ -66,7 +66,7 @@ static void nfnl_unlock(void) ...@@ -66,7 +66,7 @@ static void nfnl_unlock(void)
nfnl->sk_data_ready(nfnl, 0); nfnl->sk_data_ready(nfnl, 0);
} }
int nfnetlink_subsys_register(struct nfnetlink_subsystem *n) int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n)
{ {
nfnl_lock(); nfnl_lock();
if (subsys_table[n->subsys_id]) { if (subsys_table[n->subsys_id]) {
...@@ -80,7 +80,7 @@ int nfnetlink_subsys_register(struct nfnetlink_subsystem *n) ...@@ -80,7 +80,7 @@ int nfnetlink_subsys_register(struct nfnetlink_subsystem *n)
} }
EXPORT_SYMBOL_GPL(nfnetlink_subsys_register); EXPORT_SYMBOL_GPL(nfnetlink_subsys_register);
int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n) int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n)
{ {
nfnl_lock(); nfnl_lock();
subsys_table[n->subsys_id] = NULL; subsys_table[n->subsys_id] = NULL;
...@@ -90,7 +90,7 @@ int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n) ...@@ -90,7 +90,7 @@ int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n)
} }
EXPORT_SYMBOL_GPL(nfnetlink_subsys_unregister); EXPORT_SYMBOL_GPL(nfnetlink_subsys_unregister);
static inline struct nfnetlink_subsystem *nfnetlink_get_subsys(u_int16_t type) static inline const struct nfnetlink_subsystem *nfnetlink_get_subsys(u_int16_t type)
{ {
u_int8_t subsys_id = NFNL_SUBSYS_ID(type); u_int8_t subsys_id = NFNL_SUBSYS_ID(type);
...@@ -100,8 +100,8 @@ static inline struct nfnetlink_subsystem *nfnetlink_get_subsys(u_int16_t type) ...@@ -100,8 +100,8 @@ static inline struct nfnetlink_subsystem *nfnetlink_get_subsys(u_int16_t type)
return subsys_table[subsys_id]; return subsys_table[subsys_id];
} }
static inline struct nfnl_callback * static inline const struct nfnl_callback *
nfnetlink_find_client(u_int16_t type, struct nfnetlink_subsystem *ss) nfnetlink_find_client(u_int16_t type, const struct nfnetlink_subsystem *ss)
{ {
u_int8_t cb_id = NFNL_MSG_TYPE(type); u_int8_t cb_id = NFNL_MSG_TYPE(type);
...@@ -147,7 +147,7 @@ EXPORT_SYMBOL_GPL(nfattr_parse); ...@@ -147,7 +147,7 @@ EXPORT_SYMBOL_GPL(nfattr_parse);
* *
*/ */
static int static int
nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys, nfnetlink_check_attributes(const struct nfnetlink_subsystem *subsys,
struct nlmsghdr *nlh, struct nfattr *cda[]) struct nlmsghdr *nlh, struct nfattr *cda[])
{ {
int min_len = NLMSG_SPACE(sizeof(struct nfgenmsg)); int min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));
...@@ -197,8 +197,8 @@ EXPORT_SYMBOL_GPL(nfnetlink_unicast); ...@@ -197,8 +197,8 @@ EXPORT_SYMBOL_GPL(nfnetlink_unicast);
/* Process one complete nfnetlink message. */ /* Process one complete nfnetlink message. */
static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
{ {
struct nfnl_callback *nc; const struct nfnl_callback *nc;
struct nfnetlink_subsystem *ss; const struct nfnetlink_subsystem *ss;
int type, err; int type, err;
if (security_netlink_recv(skb, CAP_NET_ADMIN)) if (security_netlink_recv(skb, CAP_NET_ADMIN))
......
...@@ -883,14 +883,14 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb, ...@@ -883,14 +883,14 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
return ret; return ret;
} }
static struct nfnl_callback nfulnl_cb[NFULNL_MSG_MAX] = { static const struct nfnl_callback nfulnl_cb[NFULNL_MSG_MAX] = {
[NFULNL_MSG_PACKET] = { .call = nfulnl_recv_unsupp, [NFULNL_MSG_PACKET] = { .call = nfulnl_recv_unsupp,
.attr_count = NFULA_MAX, }, .attr_count = NFULA_MAX, },
[NFULNL_MSG_CONFIG] = { .call = nfulnl_recv_config, [NFULNL_MSG_CONFIG] = { .call = nfulnl_recv_config,
.attr_count = NFULA_CFG_MAX, }, .attr_count = NFULA_CFG_MAX, },
}; };
static struct nfnetlink_subsystem nfulnl_subsys = { static const struct nfnetlink_subsystem nfulnl_subsys = {
.name = "log", .name = "log",
.subsys_id = NFNL_SUBSYS_ULOG, .subsys_id = NFNL_SUBSYS_ULOG,
.cb_count = NFULNL_MSG_MAX, .cb_count = NFULNL_MSG_MAX,
......
...@@ -961,7 +961,7 @@ nfqnl_recv_config(struct sock *ctnl, struct sk_buff *skb, ...@@ -961,7 +961,7 @@ nfqnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
return ret; return ret;
} }
static struct nfnl_callback nfqnl_cb[NFQNL_MSG_MAX] = { static const struct nfnl_callback nfqnl_cb[NFQNL_MSG_MAX] = {
[NFQNL_MSG_PACKET] = { .call = nfqnl_recv_unsupp, [NFQNL_MSG_PACKET] = { .call = nfqnl_recv_unsupp,
.attr_count = NFQA_MAX, }, .attr_count = NFQA_MAX, },
[NFQNL_MSG_VERDICT] = { .call = nfqnl_recv_verdict, [NFQNL_MSG_VERDICT] = { .call = nfqnl_recv_verdict,
...@@ -970,7 +970,7 @@ static struct nfnl_callback nfqnl_cb[NFQNL_MSG_MAX] = { ...@@ -970,7 +970,7 @@ static struct nfnl_callback nfqnl_cb[NFQNL_MSG_MAX] = {
.attr_count = NFQA_CFG_MAX, }, .attr_count = NFQA_CFG_MAX, },
}; };
static struct nfnetlink_subsystem nfqnl_subsys = { static const struct nfnetlink_subsystem nfqnl_subsys = {
.name = "nf_queue", .name = "nf_queue",
.subsys_id = NFNL_SUBSYS_QUEUE, .subsys_id = NFNL_SUBSYS_QUEUE,
.cb_count = NFQNL_MSG_MAX, .cb_count = NFQNL_MSG_MAX,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment