History

netfilter: xtables: change matches to return error code

The following semantic patch does part of the transformation: // <smpl> @ rule1 @ struct xt_match ops; identifier check; @@ ops.checkentry = check; @@ identifier rule1.check; @@ check(...) { <... -return true; +return 0; ...> } @@ identifier rule1.check; @@ check(...) { <... -return false; +return -EINVAL; ...> } // </smpl>

Jan Engelhardt committed 16 years ago

Commit bd414ee1 parent 135367b44 files · +162 −156Browse files

Unified · Split

44 files
  1. net/bridge/netfilter/ebt_802_3.c +2 −2
  2. net/bridge/netfilter/ebt_among.c +4 −4
  3. net/bridge/netfilter/ebt_arp.c +3 −3
  4. net/bridge/netfilter/ebt_ip.c +7 −7
  5. net/bridge/netfilter/ebt_ip6.c +7 −7
  6. net/bridge/netfilter/ebt_limit.c +2 −2
  7. net/bridge/netfilter/ebt_mark_m.c +4 −4
  8. net/bridge/netfilter/ebt_pkttype.c +2 −2
  9. net/bridge/netfilter/ebt_stp.c +3 −3
  10. net/bridge/netfilter/ebt_vlan.c +7 −7
  11. net/ipv4/netfilter/ip_tables.c +1 −1
  12. net/ipv4/netfilter/ipt_addrtype.c +4 −4
  13. net/ipv4/netfilter/ipt_ah.c +2 −2
  14. net/ipv4/netfilter/ipt_ecn.c +4 −4
  15. net/ipv6/netfilter/ip6_tables.c +1 −1
  16. net/ipv6/netfilter/ip6t_ah.c +2 −2
  17. net/ipv6/netfilter/ip6t_frag.c +2 −2
  18. net/ipv6/netfilter/ip6t_hbh.c +3 −3
  19. net/ipv6/netfilter/ip6t_ipv6header.c +2 −2
  20. net/ipv6/netfilter/ip6t_mh.c +1 −1
  21. net/ipv6/netfilter/ip6t_rt.c +3 −3
  22. net/netfilter/x_tables.c +10 −2
  23. net/netfilter/xt_cluster.c +3 −3
  24. net/netfilter/xt_connbytes.c +4 −4
  25. net/netfilter/xt_connlimit.c +3 −3
  26. net/netfilter/xt_connmark.c +4 −4
  27. net/netfilter/xt_conntrack.c +2 −2
  28. net/netfilter/xt_dccp.c +4 −4
  29. net/netfilter/xt_dscp.c +2 −2
  30. net/netfilter/xt_esp.c +2 −2
  31. net/netfilter/xt_hashlimit.c +14 −15
  32. net/netfilter/xt_helper.c +2 −2
  33. net/netfilter/xt_limit.c +3 −3
  34. net/netfilter/xt_physdev.c +3 −3
  35. net/netfilter/xt_policy.c +5 −5
  36. net/netfilter/xt_quota.c +3 −3
  37. net/netfilter/xt_rateest.c +2 −2
  38. net/netfilter/xt_recent.c +9 −9
  39. net/netfilter/xt_sctp.c +6 −6
  40. net/netfilter/xt_state.c +2 −2
  41. net/netfilter/xt_statistic.c +3 −3
  42. net/netfilter/xt_string.c +6 −7
  43. net/netfilter/xt_tcpudp.c +2 −2
  44. net/netfilter/xt_time.c +2 −2
net/bridge/netfilter/ebt_802_3.c+2−2
@@ -41,9 +41,9 @@ static int ebt_802_3_mt_check(const struct xt_mtchk_param *par) · 40 unmodified lines
4141 const struct ebt_802_3_info *info = par->matchinfo;
4242
4343 if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK)
44− return false;
44+ return -EINVAL;
4545
46− return true;
46+ return 0;
4747 }
4848
4949 static struct xt_match ebt_802_3_mt_reg __read_mostly = {
net/bridge/netfilter/ebt_among.c+4−4
@@ -190,17 +190,17 @@ static int ebt_among_mt_check(const struct xt_mtchk_param *par) · 189 unmodified lines
190190 pr_info("wrong size: %d against expected %d, rounded to %Zd\n",
191191 em->match_size, expected_length,
192192 EBT_ALIGN(expected_length));
193− return false;
193+ return -EINVAL;
194194 }
195195 if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) {
196196 pr_info("dst integrity fail: %x\n", -err);
197− return false;
197+ return -EINVAL;
198198 }
199199 if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) {
200200 pr_info("src integrity fail: %x\n", -err);
201− return false;
201+ return -EINVAL;
202202 }
203− return true;
203+ return 0;
204204 }
205205
206206 static struct xt_match ebt_among_mt_reg __read_mostly = {
net/bridge/netfilter/ebt_arp.c+3−3
@@ -108,10 +108,10 @@ static int ebt_arp_mt_check(const struct xt_mtchk_param *par) · 107 unmodified lines
108108 if ((e->ethproto != htons(ETH_P_ARP) &&
109109 e->ethproto != htons(ETH_P_RARP)) ||
110110 e->invflags & EBT_IPROTO)
111− return false;
111+ return -EINVAL;
112112 if (info->bitmask & ~EBT_ARP_MASK || info->invflags & ~EBT_ARP_MASK)
113− return false;
114− return true;
113+ return -EINVAL;
114+ return 0;
115115 }
116116
117117 static struct xt_match ebt_arp_mt_reg __read_mostly = {
net/bridge/netfilter/ebt_ip.c+7−7
@@ -84,24 +84,24 @@ static int ebt_ip_mt_check(const struct xt_mtchk_param *par) · 83 unmodified lines
8484
8585 if (e->ethproto != htons(ETH_P_IP) ||
8686 e->invflags & EBT_IPROTO)
87− return false;
87+ return -EINVAL;
8888 if (info->bitmask & ~EBT_IP_MASK || info->invflags & ~EBT_IP_MASK)
89− return false;
89+ return -EINVAL;
9090 if (info->bitmask & (EBT_IP_DPORT | EBT_IP_SPORT)) {
9191 if (info->invflags & EBT_IP_PROTO)
92− return false;
92+ return -EINVAL;
9393 if (info->protocol != IPPROTO_TCP &&
9494 info->protocol != IPPROTO_UDP &&
9595 info->protocol != IPPROTO_UDPLITE &&
9696 info->protocol != IPPROTO_SCTP &&
9797 info->protocol != IPPROTO_DCCP)
98− return false;
98+ return -EINVAL;
9999 }
100100 if (info->bitmask & EBT_IP_DPORT && info->dport[0] > info->dport[1])
101− return false;
101+ return -EINVAL;
102102 if (info->bitmask & EBT_IP_SPORT && info->sport[0] > info->sport[1])
103− return false;
104− return true;
103+ return -EINVAL;
104+ return 0;
105105 }
106106
107107 static struct xt_match ebt_ip_mt_reg __read_mostly = {
net/bridge/netfilter/ebt_ip6.c+7−7
@@ -86,24 +86,24 @@ static int ebt_ip6_mt_check(const struct xt_mtchk_param *par) · 85 unmodified lines
8686 struct ebt_ip6_info *info = par->matchinfo;
8787
8888 if (e->ethproto != htons(ETH_P_IPV6) || e->invflags & EBT_IPROTO)
89− return false;
89+ return -EINVAL;
9090 if (info->bitmask & ~EBT_IP6_MASK || info->invflags & ~EBT_IP6_MASK)
91− return false;
91+ return -EINVAL;
9292 if (info->bitmask & (EBT_IP6_DPORT | EBT_IP6_SPORT)) {
9393 if (info->invflags & EBT_IP6_PROTO)
94− return false;
94+ return -EINVAL;
9595 if (info->protocol != IPPROTO_TCP &&
9696 info->protocol != IPPROTO_UDP &&
9797 info->protocol != IPPROTO_UDPLITE &&
9898 info->protocol != IPPROTO_SCTP &&
9999 info->protocol != IPPROTO_DCCP)
100− return false;
100+ return -EINVAL;
101101 }
102102 if (info->bitmask & EBT_IP6_DPORT && info->dport[0] > info->dport[1])
103− return false;
103+ return -EINVAL;
104104 if (info->bitmask & EBT_IP6_SPORT && info->sport[0] > info->sport[1])
105− return false;
106− return true;
105+ return -EINVAL;
106+ return 0;
107107 }
108108
109109 static struct xt_match ebt_ip6_mt_reg __read_mostly = {
net/bridge/netfilter/ebt_limit.c+2−2
@@ -74,7 +74,7 @@ static int ebt_limit_mt_check(const struct xt_mtchk_param *par) · 73 unmodified lines
7474 user2credits(info->avg * info->burst) < user2credits(info->avg)) {
7575 pr_info("overflow, try lower: %u/%u\n",
7676 info->avg, info->burst);
77− return false;
77+ return -EINVAL;
7878 }
7979
8080 /* User avg in seconds * EBT_LIMIT_SCALE: convert to jiffies * 128. */
@@ -82,7 +82,7 @@ static int ebt_limit_mt_check(const struct xt_mtchk_param *par) · 1 unmodified line
8282 info->credit = user2credits(info->avg * info->burst);
8383 info->credit_cap = user2credits(info->avg * info->burst);
8484 info->cost = user2credits(info->avg);
85− return true;
85+ return 0;
8686 }
8787
8888
net/bridge/netfilter/ebt_mark_m.c+4−4
@@ -27,12 +27,12 @@ static int ebt_mark_mt_check(const struct xt_mtchk_param *par) · 26 unmodified lines
2727 const struct ebt_mark_m_info *info = par->matchinfo;
2828
2929 if (info->bitmask & ~EBT_MARK_MASK)
30− return false;
30+ return -EINVAL;
3131 if ((info->bitmask & EBT_MARK_OR) && (info->bitmask & EBT_MARK_AND))
32− return false;
32+ return -EINVAL;
3333 if (!info->bitmask)
34− return false;
35− return true;
34+ return -EINVAL;
35+ return 0;
3636 }
3737
3838
net/bridge/netfilter/ebt_pkttype.c+2−2
@@ -25,9 +25,9 @@ static int ebt_pkttype_mt_check(const struct xt_mtchk_param *par) · 24 unmodified lines
2525 const struct ebt_pkttype_info *info = par->matchinfo;
2626
2727 if (info->invert != 0 && info->invert != 1)
28− return false;
28+ return -EINVAL;
2929 /* Allow any pkt_type value */
30− return true;
30+ return 0;
3131 }
3232
3333 static struct xt_match ebt_pkttype_mt_reg __read_mostly = {
net/bridge/netfilter/ebt_stp.c+3−3
@@ -162,13 +162,13 @@ static int ebt_stp_mt_check(const struct xt_mtchk_param *par) · 161 unmodified lines
162162
163163 if (info->bitmask & ~EBT_STP_MASK || info->invflags & ~EBT_STP_MASK ||
164164 !(info->bitmask & EBT_STP_MASK))
165− return false;
165+ return -EINVAL;
166166 /* Make sure the match only receives stp frames */
167167 if (compare_ether_addr(e->destmac, bridge_ula) ||
168168 compare_ether_addr(e->destmsk, msk) || !(e->bitmask & EBT_DESTMAC))
169− return false;
169+ return -EINVAL;
170170
171− return true;
171+ return 0;
172172 }
173173
174174 static struct xt_match ebt_stp_mt_reg __read_mostly = {
net/bridge/netfilter/ebt_vlan.c+7−7
@@ -88,7 +88,7 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par) · 87 unmodified lines
8888 if (e->ethproto != htons(ETH_P_8021Q)) {
8989 pr_debug("passed entry proto %2.4X is not 802.1Q (8100)\n",
9090 ntohs(e->ethproto));
91− return false;
91+ return -EINVAL;
9292 }
9393
9494 /* Check for bitmask range
@@ -96,14 +96,14 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par) · 1 unmodified line
9696 if (info->bitmask & ~EBT_VLAN_MASK) {
9797 pr_debug("bitmask %2X is out of mask (%2X)\n",
9898 info->bitmask, EBT_VLAN_MASK);
99− return false;
99+ return -EINVAL;
100100 }
101101
102102 /* Check for inversion flags range */
103103 if (info->invflags & ~EBT_VLAN_MASK) {
104104 pr_debug("inversion flags %2X is out of mask (%2X)\n",
105105 info->invflags, EBT_VLAN_MASK);
106− return false;
106+ return -EINVAL;
107107 }
108108
109109 /* Reserved VLAN ID (VID) values
@@ -117,7 +117,7 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par) · 7 unmodified lines
117117 if (info->id > VLAN_GROUP_ARRAY_LEN) {
118118 pr_debug("id %d is out of range (1-4096)\n",
119119 info->id);
120− return false;
120+ return -EINVAL;
121121 }
122122 /* Note: This is valid VLAN-tagged frame point.
123123 * Any value of user_priority are acceptable,
@@ -132,7 +132,7 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par) · 8 unmodified lines
132132 if ((unsigned char) info->prio > 7) {
133133 pr_debug("prio %d is out of range (0-7)\n",
134134 info->prio);
135− return false;
135+ return -EINVAL;
136136 }
137137 }
138138 /* Check for encapsulated proto range - it is possible to be
@@ -142,11 +142,11 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par) · 3 unmodified lines
142142 if ((unsigned short) ntohs(info->encap) < ETH_ZLEN) {
143143 pr_debug("encap frame length %d is less than "
144144 "minimal\n", ntohs(info->encap));
145− return false;
145+ return -EINVAL;
146146 }
147147 }
148148
149− return true;
149+ return 0;
150150 }
151151
152152 static struct xt_match ebt_vlan_mt_reg __read_mostly = {
net/ipv4/netfilter/ip_tables.c+1−1
@@ -2181,7 +2181,7 @@ static int icmp_checkentry(const struct xt_mtchk_param *par) · 2180 unmodified lines
21812181 const struct ipt_icmp *icmpinfo = par->matchinfo;
21822182
21832183 /* Must specify no unknown invflags */
2184− return !(icmpinfo->invflags & ~IPT_ICMP_INV);
2184+ return (icmpinfo->invflags & ~IPT_ICMP_INV) ? -EINVAL : 0;
21852185 }
21862186
21872187 /* The built-in targets: standard (NULL) and error. */
net/ipv4/netfilter/ipt_addrtype.c+4−4
@@ -78,7 +78,7 @@ static int addrtype_mt_checkentry_v1(const struct xt_mtchk_param *par) · 77 unmodified lines
7878 info->flags & IPT_ADDRTYPE_LIMIT_IFACE_OUT) {
7979 pr_info("both incoming and outgoing "
8080 "interface limitation cannot be selected\n");
81− return false;
81+ return -EINVAL;
8282 }
8383
8484 if (par->hook_mask & ((1 << NF_INET_PRE_ROUTING) |
@@ -86,7 +86,7 @@ static int addrtype_mt_checkentry_v1(const struct xt_mtchk_param *par) · 1 unmodified line
8686 info->flags & IPT_ADDRTYPE_LIMIT_IFACE_OUT) {
8787 pr_info("output interface limitation "
8888 "not valid in PREROUTING and INPUT\n");
89− return false;
89+ return -EINVAL;
9090 }
9191
9292 if (par->hook_mask & ((1 << NF_INET_POST_ROUTING) |
@@ -94,10 +94,10 @@ static int addrtype_mt_checkentry_v1(const struct xt_mtchk_param *par) · 1 unmodified line
9494 info->flags & IPT_ADDRTYPE_LIMIT_IFACE_IN) {
9595 pr_info("input interface limitation "
9696 "not valid in POSTROUTING and OUTPUT\n");
97− return false;
97+ return -EINVAL;
9898 }
9999
100− return true;
100+ return 0;
101101 }
102102
103103 static struct xt_match addrtype_mt_reg[] __read_mostly = {
net/ipv4/netfilter/ipt_ah.c+2−2
@@ -62,9 +62,9 @@ static int ah_mt_check(const struct xt_mtchk_param *par) · 61 unmodified lines
6262 /* Must specify no unknown invflags */
6363 if (ahinfo->invflags & ~IPT_AH_INV_MASK) {
6464 pr_debug("unknown flags %X\n", ahinfo->invflags);
65− return false;
65+ return -EINVAL;
6666 }
67− return true;
67+ return 0;
6868 }
6969
7070 static struct xt_match ah_mt_reg __read_mostly = {
net/ipv4/netfilter/ipt_ecn.c+4−4
@@ -91,18 +91,18 @@ static int ecn_mt_check(const struct xt_mtchk_param *par) · 90 unmodified lines
9191 const struct ipt_ip *ip = par->entryinfo;
9292
9393 if (info->operation & IPT_ECN_OP_MATCH_MASK)
94− return false;
94+ return -EINVAL;
9595
9696 if (info->invert & IPT_ECN_OP_MATCH_MASK)
97− return false;
97+ return -EINVAL;
9898
9999 if (info->operation & (IPT_ECN_OP_MATCH_ECE|IPT_ECN_OP_MATCH_CWR) &&
100100 ip->proto != IPPROTO_TCP) {
101101 pr_info("cannot match TCP bits in rule for non-tcp packets\n");
102− return false;
102+ return -EINVAL;
103103 }
104104
105− return true;
105+ return 0;
106106 }
107107
108108 static struct xt_match ecn_mt_reg __read_mostly = {
net/ipv6/netfilter/ip6_tables.c+1−1
@@ -2214,7 +2214,7 @@ static int icmp6_checkentry(const struct xt_mtchk_param *par) · 2213 unmodified lines
22142214 const struct ip6t_icmp *icmpinfo = par->matchinfo;
22152215
22162216 /* Must specify no unknown invflags */
2217− return !(icmpinfo->invflags & ~IP6T_ICMP_INV);
2217+ return (icmpinfo->invflags & ~IP6T_ICMP_INV) ? -EINVAL : 0;
22182218 }
22192219
22202220 /* The built-in targets: standard (NULL) and error. */
net/ipv6/netfilter/ip6t_ah.c+2−2
@@ -93,9 +93,9 @@ static int ah_mt6_check(const struct xt_mtchk_param *par) · 92 unmodified lines
9393
9494 if (ahinfo->invflags & ~IP6T_AH_INV_MASK) {
9595 pr_debug("unknown flags %X\n", ahinfo->invflags);
96− return false;
96+ return -EINVAL;
9797 }
98− return true;
98+ return 0;
9999 }
100100
101101 static struct xt_match ah_mt6_reg __read_mostly = {
net/ipv6/netfilter/ip6t_frag.c+2−2
@@ -108,9 +108,9 @@ static int frag_mt6_check(const struct xt_mtchk_param *par) · 107 unmodified lines
108108
109109 if (fraginfo->invflags & ~IP6T_FRAG_INV_MASK) {
110110 pr_debug("unknown flags %X\n", fraginfo->invflags);
111− return false;
111+ return -EINVAL;
112112 }
113− return true;
113+ return 0;
114114 }
115115
116116 static struct xt_match frag_mt6_reg __read_mostly = {
net/ipv6/netfilter/ip6t_hbh.c+3−3
@@ -170,15 +170,15 @@ static int hbh_mt6_check(const struct xt_mtchk_param *par) · 169 unmodified lines
170170
171171 if (optsinfo->invflags & ~IP6T_OPTS_INV_MASK) {
172172 pr_debug("unknown flags %X\n", optsinfo->invflags);
173− return false;
173+ return -EINVAL;
174174 }
175175
176176 if (optsinfo->flags & IP6T_OPTS_NSTRICT) {
177177 pr_debug("Not strict - not implemented");
178− return false;
178+ return -EINVAL;
179179 }
180180
181− return true;
181+ return 0;
182182 }
183183
184184 static struct xt_match hbh_mt6_reg[] __read_mostly = {
net/ipv6/netfilter/ip6t_ipv6header.c+2−2
@@ -125,9 +125,9 @@ static int ipv6header_mt6_check(const struct xt_mtchk_param *par) · 124 unmodified lines
125125 /* invflags is 0 or 0xff in hard mode */
126126 if ((!info->modeflag) && info->invflags != 0x00 &&
127127 info->invflags != 0xFF)
128− return false;
128+ return -EINVAL;
129129
130− return true;
130+ return 0;
131131 }
132132
133133 static struct xt_match ipv6header_mt6_reg __read_mostly = {
net/ipv6/netfilter/ip6t_mh.c+1−1
@@ -67,7 +67,7 @@ static int mh_mt6_check(const struct xt_mtchk_param *par) · 66 unmodified lines
6767 const struct ip6t_mh *mhinfo = par->matchinfo;
6868
6969 /* Must specify no unknown invflags */
70− return !(mhinfo->invflags & ~IP6T_MH_INV_MASK);
70+ return (mhinfo->invflags & ~IP6T_MH_INV_MASK) ? -EINVAL : 0;
7171 }
7272
7373 static struct xt_match mh_mt6_reg __read_mostly = {
net/ipv6/netfilter/ip6t_rt.c+3−3
@@ -189,17 +189,17 @@ static int rt_mt6_check(const struct xt_mtchk_param *par) · 188 unmodified lines
189189
190190 if (rtinfo->invflags & ~IP6T_RT_INV_MASK) {
191191 pr_debug("unknown flags %X\n", rtinfo->invflags);
192− return false;
192+ return -EINVAL;
193193 }
194194 if ((rtinfo->flags & (IP6T_RT_RES | IP6T_RT_FST_MASK)) &&
195195 (!(rtinfo->flags & IP6T_RT_TYP) ||
196196 (rtinfo->rt_type != 0) ||
197197 (rtinfo->invflags & IP6T_RT_INV_TYP))) {
198198 pr_debug("`--rt-type 0' required before `--rt-0-*'");
199− return false;
199+ return -EINVAL;
200200 }
201201
202− return true;
202+ return 0;
203203 }
204204
205205 static struct xt_match rt_mt6_reg __read_mostly = {
net/netfilter/x_tables.c+10−2
@@ -363,6 +363,8 @@ static char *textify_hooks(char *buf, size_t size, unsigned int mask) · 362 unmodified lines
363363 int xt_check_match(struct xt_mtchk_param *par,
364364 unsigned int size, u_int8_t proto, bool inv_proto)
365365 {
366+ int ret;
367+
366368 if (XT_ALIGN(par->match->matchsize) != size &&
367369 par->match->matchsize != -1) {
368370 /*
@@ -399,8 +401,14 @@ int xt_check_match(struct xt_mtchk_param *par, · 30 unmodified lines
399401 par->match->proto);
400402 return -EINVAL;
401403 }
402− if (par->match->checkentry != NULL && !par->match->checkentry(par))
403− return -EINVAL;
404+ if (par->match->checkentry != NULL) {
405+ ret = par->match->checkentry(par);
406+ if (ret < 0)
407+ return ret;
408+ else if (ret > 0)
409+ /* Flag up potential errors. */
410+ return -EIO;
411+ }
404412 return 0;
405413 }
406414 EXPORT_SYMBOL_GPL(xt_check_match);
net/netfilter/xt_cluster.c+3−3
@@ -140,14 +140,14 @@ static int xt_cluster_mt_checkentry(const struct xt_mtchk_param *par) · 139 unmodified lines
140140 pr_info("you have exceeded the maximum "
141141 "number of cluster nodes (%u > %u)\n",
142142 info->total_nodes, XT_CLUSTER_NODES_MAX);
143− return false;
143+ return -EINVAL;
144144 }
145145 if (info->node_mask >= (1ULL << info->total_nodes)) {
146146 pr_info("this node mask cannot be "
147147 "higher than the total number of nodes\n");
148− return false;
148+ return -EINVAL;
149149 }
150− return true;
150+ return 0;
151151 }
152152
153153 static struct xt_match xt_cluster_match __read_mostly = {
net/netfilter/xt_connbytes.c+4−4
@@ -100,20 +100,20 @@ static int connbytes_mt_check(const struct xt_mtchk_param *par) · 99 unmodified lines
100100 if (sinfo->what != XT_CONNBYTES_PKTS &&
101101 sinfo->what != XT_CONNBYTES_BYTES &&
102102 sinfo->what != XT_CONNBYTES_AVGPKT)
103− return false;
103+ return -EINVAL;
104104
105105 if (sinfo->direction != XT_CONNBYTES_DIR_ORIGINAL &&
106106 sinfo->direction != XT_CONNBYTES_DIR_REPLY &&
107107 sinfo->direction != XT_CONNBYTES_DIR_BOTH)
108− return false;
108+ return -EINVAL;
109109
110110 if (nf_ct_l3proto_try_module_get(par->family) < 0) {
111111 pr_info("cannot load conntrack support for proto=%u\n",
112112 par->family);
113− return false;
113+ return -EINVAL;
114114 }
115115
116− return true;
116+ return 0;
117117 }
118118
119119 static void connbytes_mt_destroy(const struct xt_mtdtor_param *par)
net/netfilter/xt_connlimit.c+3−3
@@ -228,21 +228,21 @@ static int connlimit_mt_check(const struct xt_mtchk_param *par) · 227 unmodified lines
228228 if (nf_ct_l3proto_try_module_get(par->family) < 0) {
229229 pr_info("cannot load conntrack support for "
230230 "address family %u\n", par->family);
231− return false;
231+ return -EINVAL;
232232 }
233233
234234 /* init private data */
235235 info->data = kmalloc(sizeof(struct xt_connlimit_data), GFP_KERNEL);
236236 if (info->data == NULL) {
237237 nf_ct_l3proto_module_put(par->family);
238− return false;
238+ return -EINVAL;
239239 }
240240
241241 spin_lock_init(&info->data->lock);
242242 for (i = 0; i < ARRAY_SIZE(info->data->iphash); ++i)
243243 INIT_LIST_HEAD(&info->data->iphash[i]);
244244
245− return true;
245+ return 0;
246246 }
247247
248248 static void connlimit_mt_destroy(const struct xt_mtdtor_param *par)
net/netfilter/xt_connmark.c+4−4
@@ -79,9 +79,9 @@ static int connmark_tg_check(const struct xt_tgchk_param *par) · 78 unmodified lines
7979 if (nf_ct_l3proto_try_module_get(par->family) < 0) {
8080 pr_info("cannot load conntrack support for proto=%u\n",
8181 par->family);
82− return false;
82+ return -EINVAL;
8383 }
84− return true;
84+ return 0;
8585 }
8686
8787 static void connmark_tg_destroy(const struct xt_tgdtor_param *par)
@@ -108,9 +108,9 @@ static int connmark_mt_check(const struct xt_mtchk_param *par) · 20 unmodified lines
108108 if (nf_ct_l3proto_try_module_get(par->family) < 0) {
109109 pr_info("cannot load conntrack support for proto=%u\n",
110110 par->family);
111− return false;
111+ return -EINVAL;
112112 }
113− return true;
113+ return 0;
114114 }
115115
116116 static void connmark_mt_destroy(const struct xt_mtdtor_param *par)
net/netfilter/xt_conntrack.c+2−2
@@ -211,9 +211,9 @@ static int conntrack_mt_check(const struct xt_mtchk_param *par) · 210 unmodified lines
211211 if (nf_ct_l3proto_try_module_get(par->family) < 0) {
212212 pr_info("cannot load conntrack support for proto=%u\n",
213213 par->family);
214− return false;
214+ return -EINVAL;
215215 }
216− return true;
216+ return 0;
217217 }
218218
219219 static void conntrack_mt_destroy(const struct xt_mtdtor_param *par)
net/netfilter/xt_dccp.c+4−4
@@ -128,12 +128,12 @@ static int dccp_mt_check(const struct xt_mtchk_param *par) · 127 unmodified lines
128128 const struct xt_dccp_info *info = par->matchinfo;
129129
130130 if (info->flags & ~XT_DCCP_VALID_FLAGS)
131− return false;
131+ return -EINVAL;
132132 if (info->invflags & ~XT_DCCP_VALID_FLAGS)
133− return false;
133+ return -EINVAL;
134134 if (info->invflags & ~info->flags)
135− return false;
136− return true;
135+ return -EINVAL;
136+ return 0;
137137 }
138138
139139 static struct xt_match dccp_mt_reg[] __read_mostly = {
net/netfilter/xt_dscp.c+2−2
@@ -48,10 +48,10 @@ static int dscp_mt_check(const struct xt_mtchk_param *par) · 47 unmodified lines
4848
4949 if (info->dscp > XT_DSCP_MAX) {
5050 pr_info("dscp %x out of range\n", info->dscp);
51− return false;
51+ return -EINVAL;
5252 }
5353
54− return true;
54+ return 0;
5555 }
5656
5757 static bool tos_mt(const struct sk_buff *skb, const struct xt_match_param *par)
net/netfilter/xt_esp.c+2−2
@@ -66,10 +66,10 @@ static int esp_mt_check(const struct xt_mtchk_param *par) · 65 unmodified lines
6666
6767 if (espinfo->invflags & ~XT_ESP_INV_MASK) {
6868 pr_debug("unknown flags %X\n", espinfo->invflags);
69− return false;
69+ return -EINVAL;
7070 }
7171
72− return true;
72+ return 0;
7373 }
7474
7575 static struct xt_match esp_mt_reg[] __read_mostly = {
net/netfilter/xt_hashlimit.c+14−15
@@ -681,30 +681,29 @@ static int hashlimit_mt_check_v0(const struct xt_mtchk_param *par) · 680 unmodified lines
681681 user2credits(r->cfg.avg * r->cfg.burst) < user2credits(r->cfg.avg)) {
682682 pr_info("overflow, try lower: %u/%u\n",
683683 r->cfg.avg, r->cfg.burst);
684− return false;
684+ return -EINVAL;
685685 }
686686 if (r->cfg.mode == 0 ||
687687 r->cfg.mode > (XT_HASHLIMIT_HASH_DPT |
688688 XT_HASHLIMIT_HASH_DIP |
689689 XT_HASHLIMIT_HASH_SIP |
690690 XT_HASHLIMIT_HASH_SPT))
691− return false;
691+ return -EINVAL;
692692 if (!r->cfg.gc_interval)
693− return false;
693+ return -EINVAL;
694694 if (!r->cfg.expire)
695− return false;
695+ return -EINVAL;
696696 if (r->name[sizeof(r->name) - 1] != '\0')
697− return false;
697+ return -EINVAL;
698698
699699 mutex_lock(&hashlimit_mutex);
700700 r->hinfo = htable_find_get(net, r->name, par->family);
701701 if (!r->hinfo && htable_create_v0(net, r, par->family) != 0) {
702702 mutex_unlock(&hashlimit_mutex);
703− return false;
703+ return -EINVAL;
704704 }
705705 mutex_unlock(&hashlimit_mutex);
706−
707− return true;
706+ return 0;
708707 }
709708
710709 static int hashlimit_mt_check(const struct xt_mtchk_param *par)
@@ -718,28 +717,28 @@ static int hashlimit_mt_check(const struct xt_mtchk_param *par) · 7 unmodified lines
718717 user2credits(info->cfg.avg)) {
719718 pr_info("overflow, try lower: %u/%u\n",
720719 info->cfg.avg, info->cfg.burst);
721− return false;
720+ return -EINVAL;
722721 }
723722 if (info->cfg.gc_interval == 0 || info->cfg.expire == 0)
724− return false;
723+ return -EINVAL;
725724 if (info->name[sizeof(info->name)-1] != '\0')
726− return false;
725+ return -EINVAL;
727726 if (par->family == NFPROTO_IPV4) {
728727 if (info->cfg.srcmask > 32 || info->cfg.dstmask > 32)
729− return false;
728+ return -EINVAL;
730729 } else {
731730 if (info->cfg.srcmask > 128 || info->cfg.dstmask > 128)
732− return false;
731+ return -EINVAL;
733732 }
734733
735734 mutex_lock(&hashlimit_mutex);
736735 info->hinfo = htable_find_get(net, info->name, par->family);
737736 if (!info->hinfo && htable_create(net, info, par->family) != 0) {
738737 mutex_unlock(&hashlimit_mutex);
739− return false;
738+ return -EINVAL;
740739 }
741740 mutex_unlock(&hashlimit_mutex);
742− return true;
741+ return 0;
743742 }
744743
745744 static void
net/netfilter/xt_helper.c+2−2
@@ -61,10 +61,10 @@ static int helper_mt_check(const struct xt_mtchk_param *par) · 60 unmodified lines
6161 if (nf_ct_l3proto_try_module_get(par->family) < 0) {
6262 pr_info("cannot load conntrack support for proto=%u\n",
6363 par->family);
64− return false;
64+ return -EINVAL;
6565 }
6666 info->name[29] = '\0';
67− return true;
67+ return 0;
6868 }
6969
7070 static void helper_mt_destroy(const struct xt_mtdtor_param *par)
net/netfilter/xt_limit.c+3−3
@@ -107,12 +107,12 @@ static int limit_mt_check(const struct xt_mtchk_param *par) · 106 unmodified lines
107107 || user2credits(r->avg * r->burst) < user2credits(r->avg)) {
108108 pr_info("Overflow, try lower: %u/%u\n",
109109 r->avg, r->burst);
110− return false;
110+ return -EINVAL;
111111 }
112112
113113 priv = kmalloc(sizeof(*priv), GFP_KERNEL);
114114 if (priv == NULL)
115− return false;
115+ return -EINVAL;
116116
117117 /* For SMP, we only want to use one set of state. */
118118 r->master = priv;
@@ -124,7 +124,7 @@ static int limit_mt_check(const struct xt_mtchk_param *par) · 5 unmodified lines
124124 r->credit_cap = user2credits(r->avg * r->burst); /* Credits full. */
125125 r->cost = user2credits(r->avg);
126126 }
127− return true;
127+ return 0;
128128 }
129129
130130 static void limit_mt_destroy(const struct xt_mtdtor_param *par)
net/netfilter/xt_physdev.c+3−3
@@ -89,7 +89,7 @@ static int physdev_mt_check(const struct xt_mtchk_param *par) · 88 unmodified lines
8989
9090 if (!(info->bitmask & XT_PHYSDEV_OP_MASK) ||
9191 info->bitmask & ~XT_PHYSDEV_OP_MASK)
92− return false;
92+ return -EINVAL;
9393 if (info->bitmask & XT_PHYSDEV_OP_OUT &&
9494 (!(info->bitmask & XT_PHYSDEV_OP_BRIDGED) ||
9595 info->invert & XT_PHYSDEV_OP_BRIDGED) &&
@@ -99,9 +99,9 @@ static int physdev_mt_check(const struct xt_mtchk_param *par) · 3 unmodified lines
9999 "POSTROUTING chains for non-bridged traffic is not "
100100 "supported anymore.\n");
101101 if (par->hook_mask & (1 << NF_INET_LOCAL_OUT))
102− return false;
102+ return -EINVAL;
103103 }
104− return true;
104+ return 0;
105105 }
106106
107107 static struct xt_match physdev_mt_reg __read_mostly = {
net/netfilter/xt_policy.c+5−5
@@ -134,23 +134,23 @@ static int policy_mt_check(const struct xt_mtchk_param *par) · 133 unmodified lines
134134
135135 if (!(info->flags & (XT_POLICY_MATCH_IN|XT_POLICY_MATCH_OUT))) {
136136 pr_info("neither incoming nor outgoing policy selected\n");
137− return false;
137+ return -EINVAL;
138138 }
139139 if (par->hook_mask & ((1 << NF_INET_PRE_ROUTING) |
140140 (1 << NF_INET_LOCAL_IN)) && info->flags & XT_POLICY_MATCH_OUT) {
141141 pr_info("output policy not valid in PREROUTING and INPUT\n");
142− return false;
142+ return -EINVAL;
143143 }
144144 if (par->hook_mask & ((1 << NF_INET_POST_ROUTING) |
145145 (1 << NF_INET_LOCAL_OUT)) && info->flags & XT_POLICY_MATCH_IN) {
146146 pr_info("input policy not valid in POSTROUTING and OUTPUT\n");
147− return false;
147+ return -EINVAL;
148148 }
149149 if (info->len > XT_POLICY_MAX_ELEM) {
150150 pr_info("too many policy elements\n");
151− return false;
151+ return -EINVAL;
152152 }
153− return true;
153+ return 0;
154154 }
155155
156156 static struct xt_match policy_mt_reg[] __read_mostly = {
net/netfilter/xt_quota.c+3−3
@@ -48,14 +48,14 @@ static int quota_mt_check(const struct xt_mtchk_param *par) · 47 unmodified lines
4848 struct xt_quota_info *q = par->matchinfo;
4949
5050 if (q->flags & ~XT_QUOTA_MASK)
51− return false;
51+ return -EINVAL;
5252
5353 q->master = kmalloc(sizeof(*q->master), GFP_KERNEL);
5454 if (q->master == NULL)
55− return false;
55+ return -EINVAL;
5656
5757 q->master->quota = q->quota;
58− return true;
58+ return 0;
5959 }
6060
6161 static void quota_mt_destroy(const struct xt_mtdtor_param *par)
net/netfilter/xt_rateest.c+2−2
@@ -109,12 +109,12 @@ static int xt_rateest_mt_checkentry(const struct xt_mtchk_param *par) · 108 unmodified lines
109109
110110 info->est1 = est1;
111111 info->est2 = est2;
112− return true;
112+ return 0;
113113
114114 err2:
115115 xt_rateest_put(est1);
116116 err1:
117− return false;
117+ return -EINVAL;
118118 }
119119
120120 static void xt_rateest_mt_destroy(const struct xt_mtdtor_param *par)
net/netfilter/xt_recent.c+9−9
@@ -314,7 +314,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par) · 313 unmodified lines
314314 struct proc_dir_entry *pde;
315315 #endif
316316 unsigned i;
317− bool ret = false;
317+ int ret = -EINVAL;
318318
319319 if (unlikely(!hash_rnd_inited)) {
320320 get_random_bytes(&hash_rnd, sizeof(hash_rnd));
@@ -323,33 +323,33 @@ static int recent_mt_check(const struct xt_mtchk_param *par) · 2 unmodified lines
323323 if (info->check_set & ~XT_RECENT_VALID_FLAGS) {
324324 pr_info("Unsupported user space flags (%08x)\n",
325325 info->check_set);
326− return false;
326+ return -EINVAL;
327327 }
328328 if (hweight8(info->check_set &
329329 (XT_RECENT_SET | XT_RECENT_REMOVE |
330330 XT_RECENT_CHECK | XT_RECENT_UPDATE)) != 1)
331− return false;
331+ return -EINVAL;
332332 if ((info->check_set & (XT_RECENT_SET | XT_RECENT_REMOVE)) &&
333333 (info->seconds || info->hit_count ||
334334 (info->check_set & XT_RECENT_MODIFIERS)))
335− return false;
335+ return -EINVAL;
336336 if ((info->check_set & XT_RECENT_REAP) && !info->seconds)
337− return false;
337+ return -EINVAL;
338338 if (info->hit_count > ip_pkt_list_tot) {
339339 pr_info("hitcount (%u) is larger than "
340340 "packets to be remembered (%u)\n",
341341 info->hit_count, ip_pkt_list_tot);
342− return false;
342+ return -EINVAL;
343343 }
344344 if (info->name[0] == '\0' ||
345345 strnlen(info->name, XT_RECENT_NAME_LEN) == XT_RECENT_NAME_LEN)
346− return false;
346+ return -EINVAL;
347347
348348 mutex_lock(&recent_mutex);
349349 t = recent_table_lookup(recent_net, info->name);
350350 if (t != NULL) {
351351 t->refcnt++;
352− ret = true;
352+ ret = 0;
353353 goto out;
354354 }
355355
@@ -375,7 +375,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par) · 19 unmodified lines
375375 spin_lock_bh(&recent_lock);
376376 list_add_tail(&t->list, &recent_net->tables);
377377 spin_unlock_bh(&recent_lock);
378− ret = true;
378+ ret = 0;
379379 out:
380380 mutex_unlock(&recent_mutex);
381381 return ret;
net/netfilter/xt_sctp.c+6−6
@@ -149,17 +149,17 @@ static int sctp_mt_check(const struct xt_mtchk_param *par) · 148 unmodified lines
149149 const struct xt_sctp_info *info = par->matchinfo;
150150
151151 if (info->flags & ~XT_SCTP_VALID_FLAGS)
152− return false;
152+ return -EINVAL;
153153 if (info->invflags & ~XT_SCTP_VALID_FLAGS)
154− return false;
154+ return -EINVAL;
155155 if (info->invflags & ~info->flags)
156− return false;
156+ return -EINVAL;
157157 if (!(info->flags & XT_SCTP_CHUNK_TYPES))
158− return true;
158+ return 0;
159159 if (info->chunk_match_type & (SCTP_CHUNK_MATCH_ALL |
160160 SCTP_CHUNK_MATCH_ANY | SCTP_CHUNK_MATCH_ONLY))
161− return true;
162− return false;
161+ return 0;
162+ return -EINVAL;
163163 }
164164
165165 static struct xt_match sctp_mt_reg[] __read_mostly = {
net/netfilter/xt_state.c+2−2
@@ -42,9 +42,9 @@ static int state_mt_check(const struct xt_mtchk_param *par) · 41 unmodified lines
4242 if (nf_ct_l3proto_try_module_get(par->family) < 0) {
4343 pr_info("cannot load conntrack support for proto=%u\n",
4444 par->family);
45− return false;
45+ return -EINVAL;
4646 }
47− return true;
47+ return 0;
4848 }
4949
5050 static void state_mt_destroy(const struct xt_mtdtor_param *par)
net/netfilter/xt_statistic.c+3−3
@@ -58,14 +58,14 @@ static int statistic_mt_check(const struct xt_mtchk_param *par) · 57 unmodified lines
5858
5959 if (info->mode > XT_STATISTIC_MODE_MAX ||
6060 info->flags & ~XT_STATISTIC_MASK)
61− return false;
61+ return -EINVAL;
6262
6363 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
6464 if (info->master == NULL)
65− return false;
65+ return -EINVAL;
6666 info->master->count = info->u.nth.count;
6767
68− return true;
68+ return 0;
6969 }
7070
7171 static void statistic_mt_destroy(const struct xt_mtdtor_param *par)
net/netfilter/xt_string.c+6−7
@@ -48,26 +48,25 @@ static int string_mt_check(const struct xt_mtchk_param *par) · 47 unmodified lines
4848
4949 /* Damn, can't handle this case properly with iptables... */
5050 if (conf->from_offset > conf->to_offset)
51− return false;
51+ return -EINVAL;
5252 if (conf->algo[XT_STRING_MAX_ALGO_NAME_SIZE - 1] != '\0')
53− return false;
53+ return -EINVAL;
5454 if (conf->patlen > XT_STRING_MAX_PATTERN_SIZE)
55− return false;
55+ return -EINVAL;
5656 if (par->match->revision == 1) {
5757 if (conf->u.v1.flags &
5858 ~(XT_STRING_FLAG_IGNORECASE | XT_STRING_FLAG_INVERT))
59− return false;
59+ return -EINVAL;
6060 if (conf->u.v1.flags & XT_STRING_FLAG_IGNORECASE)
6161 flags |= TS_IGNORECASE;
6262 }
6363 ts_conf = textsearch_prepare(conf->algo, conf->pattern, conf->patlen,
6464 GFP_KERNEL, flags);
6565 if (IS_ERR(ts_conf))
66− return false;
66+ return -EINVAL;
6767
6868 conf->config = ts_conf;
69−
70− return true;
69+ return 0;
7170 }
7271
7372 static void string_mt_destroy(const struct xt_mtdtor_param *par)
net/netfilter/xt_tcpudp.c+2−2
@@ -125,7 +125,7 @@ static int tcp_mt_check(const struct xt_mtchk_param *par) · 124 unmodified lines
125125 const struct xt_tcp *tcpinfo = par->matchinfo;
126126
127127 /* Must specify no unknown invflags */
128− return !(tcpinfo->invflags & ~XT_TCP_INV_MASK);
128+ return (tcpinfo->invflags & ~XT_TCP_INV_MASK) ? -EINVAL : 0;
129129 }
130130
131131 static bool udp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
@@ -160,7 +160,7 @@ static int udp_mt_check(const struct xt_mtchk_param *par) · 28 unmodified lines
160160 const struct xt_udp *udpinfo = par->matchinfo;
161161
162162 /* Must specify no unknown invflags */
163− return !(udpinfo->invflags & ~XT_UDP_INV_MASK);
163+ return (udpinfo->invflags & ~XT_UDP_INV_MASK) ? -EINVAL : 0;
164164 }
165165
166166 static struct xt_match tcpudp_mt_reg[] __read_mostly = {
net/netfilter/xt_time.c+2−2
@@ -225,10 +225,10 @@ static int time_mt_check(const struct xt_mtchk_param *par) · 224 unmodified lines
225225 info->daytime_stop > XT_TIME_MAX_DAYTIME) {
226226 pr_info("invalid argument - start or "
227227 "stop time greater than 23:59:59\n");
228− return false;
228+ return -EINVAL;
229229 }
230230
231− return true;
231+ return 0;
232232 }
233233
234234 static struct xt_match xt_time_mt_reg __read_mostly = {

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