History

netfilter: make function op structures const

No functional changes, these structures should be const.

Florian Westphal committed 4 years ago

Commit 285c8a71 parent 3fce1646 files · +18 −18Browse files

Unified · Split

6 files
  1. include/linux/netfilter.h +4 −4
  2. net/netfilter/core.c +5 −5
  3. net/netfilter/nf_conntrack_core.c +2 −2
  4. net/netfilter/nf_conntrack_netlink.c +2 −2
  5. net/netfilter/nf_nat_core.c +1 −1
  6. net/netfilter/nfnetlink_queue.c +4 −4
include/linux/netfilter.h+4−4
@@ -381,13 +381,13 @@ struct nf_nat_hook { · 380 unmodified lines
381 enum ip_conntrack_dir dir);381 enum ip_conntrack_dir dir);
382};382};
383 383
384extern struct nf_nat_hook __rcu *nf_nat_hook;384extern const struct nf_nat_hook __rcu *nf_nat_hook;
385 385
386static inline void386static inline void
387nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)387nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
388{388{
389#if IS_ENABLED(CONFIG_NF_NAT)389#if IS_ENABLED(CONFIG_NF_NAT)
390 struct nf_nat_hook *nat_hook;390 const struct nf_nat_hook *nat_hook;
391 391
392 rcu_read_lock();392 rcu_read_lock();
393 nat_hook = rcu_dereference(nf_nat_hook);393 nat_hook = rcu_dereference(nf_nat_hook);
@@ -464,7 +464,7 @@ struct nf_ct_hook { · 70 unmodified lines
464 const struct sk_buff *);464 const struct sk_buff *);
465 void (*attach)(struct sk_buff *nskb, const struct sk_buff *skb);465 void (*attach)(struct sk_buff *nskb, const struct sk_buff *skb);
466};466};
467extern struct nf_ct_hook __rcu *nf_ct_hook;467extern const struct nf_ct_hook __rcu *nf_ct_hook;
468 468
469struct nlattr;469struct nlattr;
470 470
@@ -479,7 +479,7 @@ struct nfnl_ct_hook { · 8 unmodified lines
479 void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct,479 void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct,
480 enum ip_conntrack_info ctinfo, s32 off);480 enum ip_conntrack_info ctinfo, s32 off);
481};481};
482extern struct nfnl_ct_hook __rcu *nfnl_ct_hook;482extern const struct nfnl_ct_hook __rcu *nfnl_ct_hook;
483 483
484/**484/**
485 * nf_skb_duplicated - TEE target has sent a packet485 * nf_skb_duplicated - TEE target has sent a packet
net/netfilter/core.c+5−5
@@ -666,14 +666,14 @@ EXPORT_SYMBOL(nf_hook_slow_list); · 665 unmodified lines
666/* This needs to be compiled in any case to avoid dependencies between the666/* This needs to be compiled in any case to avoid dependencies between the
667 * nfnetlink_queue code and nf_conntrack.667 * nfnetlink_queue code and nf_conntrack.
668 */668 */
669struct nfnl_ct_hook __rcu *nfnl_ct_hook __read_mostly;669const struct nfnl_ct_hook __rcu *nfnl_ct_hook __read_mostly;
670EXPORT_SYMBOL_GPL(nfnl_ct_hook);670EXPORT_SYMBOL_GPL(nfnl_ct_hook);
671 671
672struct nf_ct_hook __rcu *nf_ct_hook __read_mostly;672const struct nf_ct_hook __rcu *nf_ct_hook __read_mostly;
673EXPORT_SYMBOL_GPL(nf_ct_hook);673EXPORT_SYMBOL_GPL(nf_ct_hook);
674 674
675#if IS_ENABLED(CONFIG_NF_CONNTRACK)675#if IS_ENABLED(CONFIG_NF_CONNTRACK)
676struct nf_nat_hook __rcu *nf_nat_hook __read_mostly;676const struct nf_nat_hook __rcu *nf_nat_hook __read_mostly;
677EXPORT_SYMBOL_GPL(nf_nat_hook);677EXPORT_SYMBOL_GPL(nf_nat_hook);
678 678
679/* This does not belong here, but locally generated errors need it if connection679/* This does not belong here, but locally generated errors need it if connection
@@ -696,7 +696,7 @@ EXPORT_SYMBOL(nf_ct_attach); · 16 unmodified lines
696 696
697void nf_conntrack_destroy(struct nf_conntrack *nfct)697void nf_conntrack_destroy(struct nf_conntrack *nfct)
698{698{
699 struct nf_ct_hook *ct_hook;699 const struct nf_ct_hook *ct_hook;
700 700
701 rcu_read_lock();701 rcu_read_lock();
702 ct_hook = rcu_dereference(nf_ct_hook);702 ct_hook = rcu_dereference(nf_ct_hook);
@@ -709,7 +709,7 @@ EXPORT_SYMBOL(nf_conntrack_destroy); · 6 unmodified lines
709bool nf_ct_get_tuple_skb(struct nf_conntrack_tuple *dst_tuple,709bool nf_ct_get_tuple_skb(struct nf_conntrack_tuple *dst_tuple,
710 const struct sk_buff *skb)710 const struct sk_buff *skb)
711{711{
712 struct nf_ct_hook *ct_hook;712 const struct nf_ct_hook *ct_hook;
713 bool ret = false;713 bool ret = false;
714 714
715 rcu_read_lock();715 rcu_read_lock();
net/netfilter/nf_conntrack_core.c+2−2
@@ -2085,9 +2085,9 @@ static int __nf_conntrack_update(struct net *net, struct sk_buff *skb, · 2084 unmodified lines
2085 struct nf_conn *ct,2085 struct nf_conn *ct,
2086 enum ip_conntrack_info ctinfo)2086 enum ip_conntrack_info ctinfo)
2087{2087{
2088 const struct nf_nat_hook *nat_hook;
2088 struct nf_conntrack_tuple_hash *h;2089 struct nf_conntrack_tuple_hash *h;
2089 struct nf_conntrack_tuple tuple;2090 struct nf_conntrack_tuple tuple;
2090 struct nf_nat_hook *nat_hook;
2091 unsigned int status;2091 unsigned int status;
2092 int dataoff;2092 int dataoff;
2093 u16 l3num;2093 u16 l3num;
@@ -2769,7 +2769,7 @@ err_cachep: · 675 unmodified lines
2769 return ret;2769 return ret;
2770}2770}
2771 2771
2772static struct nf_ct_hook nf_conntrack_hook = {2772static const struct nf_ct_hook nf_conntrack_hook = {
2773 .update = nf_conntrack_update,2773 .update = nf_conntrack_update,
2774 .destroy = destroy_conntrack,2774 .destroy = destroy_conntrack,
2775 .get_tuple_skb = nf_conntrack_get_tuple_skb,2775 .get_tuple_skb = nf_conntrack_get_tuple_skb,
net/netfilter/nf_conntrack_netlink.c+2−2
@@ -1819,7 +1819,7 @@ ctnetlink_parse_nat_setup(struct nf_conn *ct, · 1818 unmodified lines
1819 const struct nlattr *attr)1819 const struct nlattr *attr)
1820 __must_hold(RCU)1820 __must_hold(RCU)
1821{1821{
1822 struct nf_nat_hook *nat_hook;1822 const struct nf_nat_hook *nat_hook;
1823 int err;1823 int err;
1824 1824
1825 nat_hook = rcu_dereference(nf_nat_hook);1825 nat_hook = rcu_dereference(nf_nat_hook);
@@ -2921,7 +2921,7 @@ static void ctnetlink_glue_seqadj(struct sk_buff *skb, struct nf_conn *ct, · 1095 unmodified lines
2921 nf_ct_tcp_seqadj_set(skb, ct, ctinfo, diff);2921 nf_ct_tcp_seqadj_set(skb, ct, ctinfo, diff);
2922}2922}
2923 2923
2924static struct nfnl_ct_hook ctnetlink_glue_hook = {2924static const struct nfnl_ct_hook ctnetlink_glue_hook = {
2925 .build_size = ctnetlink_glue_build_size,2925 .build_size = ctnetlink_glue_build_size,
2926 .build = ctnetlink_glue_build,2926 .build = ctnetlink_glue_build,
2927 .parse = ctnetlink_glue_parse,2927 .parse = ctnetlink_glue_parse,
net/netfilter/nf_nat_core.c+1−1
@@ -1167,7 +1167,7 @@ static struct pernet_operations nat_net_ops = { · 1166 unmodified lines
1167 .size = sizeof(struct nat_net),1167 .size = sizeof(struct nat_net),
1168};1168};
1169 1169
1170static struct nf_nat_hook nat_hook = {1170static const struct nf_nat_hook nat_hook = {
1171 .parse_nat_setup = nfnetlink_parse_nat_setup,1171 .parse_nat_setup = nfnetlink_parse_nat_setup,
1172#ifdef CONFIG_XFRM1172#ifdef CONFIG_XFRM
1173 .decode_session = __nf_nat_decode_session,1173 .decode_session = __nf_nat_decode_session,
net/netfilter/nfnetlink_queue.c+4−4
@@ -225,7 +225,7 @@ find_dequeue_entry(struct nfqnl_instance *queue, unsigned int id) · 224 unmodified lines
225 225
226static void nfqnl_reinject(struct nf_queue_entry *entry, unsigned int verdict)226static void nfqnl_reinject(struct nf_queue_entry *entry, unsigned int verdict)
227{227{
228 struct nf_ct_hook *ct_hook;228 const struct nf_ct_hook *ct_hook;
229 int err;229 int err;
230 230
231 if (verdict == NF_ACCEPT ||231 if (verdict == NF_ACCEPT ||
@@ -388,7 +388,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, · 156 unmodified lines
388 struct net_device *outdev;388 struct net_device *outdev;
389 struct nf_conn *ct = NULL;389 struct nf_conn *ct = NULL;
390 enum ip_conntrack_info ctinfo = 0;390 enum ip_conntrack_info ctinfo = 0;
391 struct nfnl_ct_hook *nfnl_ct;391 const struct nfnl_ct_hook *nfnl_ct;
392 bool csum_verify;392 bool csum_verify;
393 char *secdata = NULL;393 char *secdata = NULL;
394 u32 seclen = 0;394 u32 seclen = 0;
@@ -1103,7 +1103,7 @@ static int nfqnl_recv_verdict_batch(struct sk_buff *skb, · 708 unmodified lines
1103 return 0;1103 return 0;
1104}1104}
1105 1105
1106static struct nf_conn *nfqnl_ct_parse(struct nfnl_ct_hook *nfnl_ct,1106static struct nf_conn *nfqnl_ct_parse(const struct nfnl_ct_hook *nfnl_ct,
1107 const struct nlmsghdr *nlh,1107 const struct nlmsghdr *nlh,
1108 const struct nlattr * const nfqa[],1108 const struct nlattr * const nfqa[],
1109 struct nf_queue_entry *entry,1109 struct nf_queue_entry *entry,
@@ -1170,11 +1170,11 @@ static int nfqnl_recv_verdict(struct sk_buff *skb, const struct nfnl_info *info, · 60 unmodified lines
1170{1170{
1171 struct nfnl_queue_net *q = nfnl_queue_pernet(info->net);1171 struct nfnl_queue_net *q = nfnl_queue_pernet(info->net);
1172 u_int16_t queue_num = ntohs(info->nfmsg->res_id);1172 u_int16_t queue_num = ntohs(info->nfmsg->res_id);
1173 const struct nfnl_ct_hook *nfnl_ct;
1173 struct nfqnl_msg_verdict_hdr *vhdr;1174 struct nfqnl_msg_verdict_hdr *vhdr;
1174 enum ip_conntrack_info ctinfo;1175 enum ip_conntrack_info ctinfo;
1175 struct nfqnl_instance *queue;1176 struct nfqnl_instance *queue;
1176 struct nf_queue_entry *entry;1177 struct nf_queue_entry *entry;
1177 struct nfnl_ct_hook *nfnl_ct;
1178 struct nf_conn *ct = NULL;1178 struct nf_conn *ct = NULL;
1179 unsigned int verdict;1179 unsigned int verdict;
1180 int err;1180 int err;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t