Commit 3993832464dd4e14a4c926583a11f0fa92c1f0f0

Authored by Patrick McHardy
1 parent 3a6c2b419b

netfilter: nfnetlink: constify message attributes and headers

Signed-off-by: Patrick McHardy <kaber@trash.net>

Showing 9 changed files with 55 additions and 35 deletions Side-by-side Diff

include/linux/netfilter/nfnetlink.h
... ... @@ -58,7 +58,8 @@
58 58 struct nfnl_callback
59 59 {
60 60 int (*call)(struct sock *nl, struct sk_buff *skb,
61   - struct nlmsghdr *nlh, struct nlattr *cda[]);
  61 + const struct nlmsghdr *nlh,
  62 + const struct nlattr * const cda[]);
62 63 const struct nla_policy *policy; /* netlink attribute policy */
63 64 const u_int16_t attr_count; /* number of nlattr's */
64 65 };
include/net/netfilter/nf_nat_core.h
... ... @@ -31,7 +31,7 @@
31 31 extern int
32 32 (*nfnetlink_parse_nat_setup_hook)(struct nf_conn *ct,
33 33 enum nf_nat_manip_type manip,
34   - struct nlattr *attr);
  34 + const struct nlattr *attr);
35 35  
36 36 #endif /* _NF_NAT_CORE_H */
net/ipv4/netfilter/nf_nat_core.c
... ... @@ -620,7 +620,7 @@
620 620 };
621 621  
622 622 static int
623   -nfnetlink_parse_nat(struct nlattr *nat,
  623 +nfnetlink_parse_nat(const struct nlattr *nat,
624 624 const struct nf_conn *ct, struct nf_nat_range *range)
625 625 {
626 626 struct nlattr *tb[CTA_NAT_MAX+1];
... ... @@ -656,7 +656,7 @@
656 656 static int
657 657 nfnetlink_parse_nat_setup(struct nf_conn *ct,
658 658 enum nf_nat_manip_type manip,
659   - struct nlattr *attr)
  659 + const struct nlattr *attr)
660 660 {
661 661 struct nf_nat_range range;
662 662  
... ... @@ -671,7 +671,7 @@
671 671 static int
672 672 nfnetlink_parse_nat_setup(struct nf_conn *ct,
673 673 enum nf_nat_manip_type manip,
674   - struct nlattr *attr)
  674 + const struct nlattr *attr)
675 675 {
676 676 return -EOPNOTSUPP;
677 677 }
net/netfilter/nf_conntrack_core.c
... ... @@ -47,7 +47,7 @@
47 47  
48 48 int (*nfnetlink_parse_nat_setup_hook)(struct nf_conn *ct,
49 49 enum nf_nat_manip_type manip,
50   - struct nlattr *attr) __read_mostly;
  50 + const struct nlattr *attr) __read_mostly;
51 51 EXPORT_SYMBOL_GPL(nfnetlink_parse_nat_setup_hook);
52 52  
53 53 DEFINE_SPINLOCK(nf_conntrack_lock);
net/netfilter/nf_conntrack_netlink.c
... ... @@ -704,7 +704,8 @@
704 704 }
705 705  
706 706 static int
707   -ctnetlink_parse_tuple(struct nlattr *cda[], struct nf_conntrack_tuple *tuple,
  707 +ctnetlink_parse_tuple(const struct nlattr * const cda[],
  708 + struct nf_conntrack_tuple *tuple,
708 709 enum ctattr_tuple type, u_int8_t l3num)
709 710 {
710 711 struct nlattr *tb[CTA_TUPLE_MAX+1];
... ... @@ -740,7 +741,7 @@
740 741 }
741 742  
742 743 static inline int
743   -ctnetlink_parse_help(struct nlattr *attr, char **helper_name)
  744 +ctnetlink_parse_help(const struct nlattr *attr, char **helper_name)
744 745 {
745 746 struct nlattr *tb[CTA_HELP_MAX+1];
746 747  
... ... @@ -764,7 +765,8 @@
764 765  
765 766 static int
766 767 ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
767   - struct nlmsghdr *nlh, struct nlattr *cda[])
  768 + const struct nlmsghdr *nlh,
  769 + const struct nlattr * const cda[])
768 770 {
769 771 struct nf_conntrack_tuple_hash *h;
770 772 struct nf_conntrack_tuple tuple;
... ... @@ -823,7 +825,8 @@
823 825  
824 826 static int
825 827 ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
826   - struct nlmsghdr *nlh, struct nlattr *cda[])
  828 + const struct nlmsghdr *nlh,
  829 + const struct nlattr * const cda[])
827 830 {
828 831 struct nf_conntrack_tuple_hash *h;
829 832 struct nf_conntrack_tuple tuple;
... ... @@ -884,7 +887,7 @@
884 887 static int
885 888 ctnetlink_parse_nat_setup(struct nf_conn *ct,
886 889 enum nf_nat_manip_type manip,
887   - struct nlattr *attr)
  890 + const struct nlattr *attr)
888 891 {
889 892 typeof(nfnetlink_parse_nat_setup_hook) parse_nat_setup;
890 893  
... ... @@ -914,7 +917,7 @@
914 917 #endif
915 918  
916 919 static int
917   -ctnetlink_change_status(struct nf_conn *ct, struct nlattr *cda[])
  920 +ctnetlink_change_status(struct nf_conn *ct, const struct nlattr * const cda[])
918 921 {
919 922 unsigned long d;
920 923 unsigned int status = ntohl(nla_get_be32(cda[CTA_STATUS]));
... ... @@ -940,7 +943,7 @@
940 943 }
941 944  
942 945 static int
943   -ctnetlink_change_nat(struct nf_conn *ct, struct nlattr *cda[])
  946 +ctnetlink_change_nat(struct nf_conn *ct, const struct nlattr * const cda[])
944 947 {
945 948 #ifdef CONFIG_NF_NAT_NEEDED
946 949 int ret;
... ... @@ -966,7 +969,7 @@
966 969 }
967 970  
968 971 static inline int
969   -ctnetlink_change_helper(struct nf_conn *ct, struct nlattr *cda[])
  972 +ctnetlink_change_helper(struct nf_conn *ct, const struct nlattr * const cda[])
970 973 {
971 974 struct nf_conntrack_helper *helper;
972 975 struct nf_conn_help *help = nfct_help(ct);
... ... @@ -1028,7 +1031,7 @@
1028 1031 }
1029 1032  
1030 1033 static inline int
1031   -ctnetlink_change_timeout(struct nf_conn *ct, struct nlattr *cda[])
  1034 +ctnetlink_change_timeout(struct nf_conn *ct, const struct nlattr * const cda[])
1032 1035 {
1033 1036 u_int32_t timeout = ntohl(nla_get_be32(cda[CTA_TIMEOUT]));
1034 1037  
1035 1038  
... ... @@ -1042,9 +1045,10 @@
1042 1045 }
1043 1046  
1044 1047 static inline int
1045   -ctnetlink_change_protoinfo(struct nf_conn *ct, struct nlattr *cda[])
  1048 +ctnetlink_change_protoinfo(struct nf_conn *ct, const struct nlattr * const cda[])
1046 1049 {
1047   - struct nlattr *tb[CTA_PROTOINFO_MAX+1], *attr = cda[CTA_PROTOINFO];
  1050 + const struct nlattr *attr = cda[CTA_PROTOINFO];
  1051 + struct nlattr *tb[CTA_PROTOINFO_MAX+1];
1048 1052 struct nf_conntrack_l4proto *l4proto;
1049 1053 int err = 0;
1050 1054  
... ... @@ -1061,7 +1065,7 @@
1061 1065  
1062 1066 #ifdef CONFIG_NF_NAT_NEEDED
1063 1067 static inline int
1064   -change_nat_seq_adj(struct nf_nat_seq *natseq, struct nlattr *attr)
  1068 +change_nat_seq_adj(struct nf_nat_seq *natseq, const struct nlattr * const attr)
1065 1069 {
1066 1070 struct nlattr *cda[CTA_NAT_SEQ_MAX+1];
1067 1071  
... ... @@ -1089,7 +1093,8 @@
1089 1093 }
1090 1094  
1091 1095 static int
1092   -ctnetlink_change_nat_seq_adj(struct nf_conn *ct, struct nlattr *cda[])
  1096 +ctnetlink_change_nat_seq_adj(struct nf_conn *ct,
  1097 + const struct nlattr * const cda[])
1093 1098 {
1094 1099 int ret = 0;
1095 1100 struct nf_conn_nat *nat = nfct_nat(ct);
... ... @@ -1120,7 +1125,8 @@
1120 1125 #endif
1121 1126  
1122 1127 static int
1123   -ctnetlink_change_conntrack(struct nf_conn *ct, struct nlattr *cda[])
  1128 +ctnetlink_change_conntrack(struct nf_conn *ct,
  1129 + const struct nlattr * const cda[])
1124 1130 {
1125 1131 int err;
1126 1132  
... ... @@ -1169,7 +1175,7 @@
1169 1175 }
1170 1176  
1171 1177 static struct nf_conn *
1172   -ctnetlink_create_conntrack(struct nlattr *cda[],
  1178 +ctnetlink_create_conntrack(const struct nlattr * const cda[],
1173 1179 struct nf_conntrack_tuple *otuple,
1174 1180 struct nf_conntrack_tuple *rtuple,
1175 1181 u8 u3)
... ... @@ -1304,7 +1310,8 @@
1304 1310  
1305 1311 static int
1306 1312 ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1307   - struct nlmsghdr *nlh, struct nlattr *cda[])
  1313 + const struct nlmsghdr *nlh,
  1314 + const struct nlattr * const cda[])
1308 1315 {
1309 1316 struct nf_conntrack_tuple otuple, rtuple;
1310 1317 struct nf_conntrack_tuple_hash *h = NULL;
... ... @@ -1629,7 +1636,8 @@
1629 1636  
1630 1637 static int
1631 1638 ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1632   - struct nlmsghdr *nlh, struct nlattr *cda[])
  1639 + const struct nlmsghdr *nlh,
  1640 + const struct nlattr * const cda[])
1633 1641 {
1634 1642 struct nf_conntrack_tuple tuple;
1635 1643 struct nf_conntrack_expect *exp;
... ... @@ -1689,7 +1697,8 @@
1689 1697  
1690 1698 static int
1691 1699 ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
1692   - struct nlmsghdr *nlh, struct nlattr *cda[])
  1700 + const struct nlmsghdr *nlh,
  1701 + const struct nlattr * const cda[])
1693 1702 {
1694 1703 struct nf_conntrack_expect *exp;
1695 1704 struct nf_conntrack_tuple tuple;
1696 1705  
... ... @@ -1767,13 +1776,15 @@
1767 1776 return 0;
1768 1777 }
1769 1778 static int
1770   -ctnetlink_change_expect(struct nf_conntrack_expect *x, struct nlattr *cda[])
  1779 +ctnetlink_change_expect(struct nf_conntrack_expect *x,
  1780 + const struct nlattr * const cda[])
1771 1781 {
1772 1782 return -EOPNOTSUPP;
1773 1783 }
1774 1784  
1775 1785 static int
1776   -ctnetlink_create_expect(struct nlattr *cda[], u_int8_t u3, u32 pid, int report)
  1786 +ctnetlink_create_expect(const struct nlattr * const cda[], u_int8_t u3,
  1787 + u32 pid, int report)
1777 1788 {
1778 1789 struct nf_conntrack_tuple tuple, mask, master_tuple;
1779 1790 struct nf_conntrack_tuple_hash *h = NULL;
... ... @@ -1831,7 +1842,8 @@
1831 1842  
1832 1843 static int
1833 1844 ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb,
1834   - struct nlmsghdr *nlh, struct nlattr *cda[])
  1845 + const struct nlmsghdr *nlh,
  1846 + const struct nlattr * const cda[])
1835 1847 {
1836 1848 struct nf_conntrack_tuple tuple;
1837 1849 struct nf_conntrack_expect *exp;
net/netfilter/nfnetlink.c
... ... @@ -170,7 +170,7 @@
170 170 if (err < 0)
171 171 return err;
172 172  
173   - err = nc->call(nfnl, skb, nlh, cda);
  173 + err = nc->call(nfnl, skb, nlh, (const struct nlattr **)cda);
174 174 if (err == -EAGAIN)
175 175 goto replay;
176 176 return err;
net/netfilter/nfnetlink_log.c
... ... @@ -694,7 +694,8 @@
694 694  
695 695 static int
696 696 nfulnl_recv_unsupp(struct sock *ctnl, struct sk_buff *skb,
697   - struct nlmsghdr *nlh, struct nlattr *nfqa[])
  697 + const struct nlmsghdr *nlh,
  698 + const struct nlattr * const nfqa[])
698 699 {
699 700 return -ENOTSUPP;
700 701 }
... ... @@ -716,7 +717,8 @@
716 717  
717 718 static int
718 719 nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
719   - struct nlmsghdr *nlh, struct nlattr *nfula[])
  720 + const struct nlmsghdr *nlh,
  721 + const struct nlattr * const nfula[])
720 722 {
721 723 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
722 724 u_int16_t group_num = ntohs(nfmsg->res_id);
net/netfilter/nfnetlink_queue.c
... ... @@ -608,7 +608,8 @@
608 608  
609 609 static int
610 610 nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
611   - struct nlmsghdr *nlh, struct nlattr *nfqa[])
  611 + const struct nlmsghdr *nlh,
  612 + const struct nlattr * const nfqa[])
612 613 {
613 614 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
614 615 u_int16_t queue_num = ntohs(nfmsg->res_id);
... ... @@ -670,7 +671,8 @@
670 671  
671 672 static int
672 673 nfqnl_recv_unsupp(struct sock *ctnl, struct sk_buff *skb,
673   - struct nlmsghdr *nlh, struct nlattr *nfqa[])
  674 + const struct nlmsghdr *nlh,
  675 + const struct nlattr * const nfqa[])
674 676 {
675 677 return -ENOTSUPP;
676 678 }
... ... @@ -687,7 +689,8 @@
687 689  
688 690 static int
689 691 nfqnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
690   - struct nlmsghdr *nlh, struct nlattr *nfqa[])
  692 + const struct nlmsghdr *nlh,
  693 + const struct nlattr * const nfqa[])
691 694 {
692 695 struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
693 696 u_int16_t queue_num = ntohs(nfmsg->res_id);
net/netfilter/xt_osf.c
... ... @@ -70,7 +70,8 @@
70 70 }
71 71  
72 72 static int xt_osf_add_callback(struct sock *ctnl, struct sk_buff *skb,
73   - struct nlmsghdr *nlh, struct nlattr *osf_attrs[])
  73 + const struct nlmsghdr *nlh,
  74 + const struct nlattr * const osf_attrs[])
74 75 {
75 76 struct xt_osf_user_finger *f;
76 77 struct xt_osf_finger *kf = NULL, *sf;
... ... @@ -112,7 +113,8 @@
112 113 }
113 114  
114 115 static int xt_osf_remove_callback(struct sock *ctnl, struct sk_buff *skb,
115   - struct nlmsghdr *nlh, struct nlattr *osf_attrs[])
  116 + const struct nlmsghdr *nlh,
  117 + const struct nlattr * const osf_attrs[])
116 118 {
117 119 struct xt_osf_user_finger *f;
118 120 struct xt_osf_finger *sf;