Commit 19eda879a136889110c692dec4c2ab59e0e43cef
Committed by
Patrick McHardy
1 parent
18219d3f7d
Exists in
master
and in
7 other branches
netfilter: change return types of check functions for Ebtables extensions
Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: Patrick McHardy <kaber@trash.net>
Showing 20 changed files with 109 additions and 108 deletions Side-by-side Diff
- include/linux/netfilter_bridge/ebtables.h
- net/bridge/netfilter/ebt_802_3.c
- net/bridge/netfilter/ebt_among.c
- net/bridge/netfilter/ebt_arp.c
- net/bridge/netfilter/ebt_arpreply.c
- net/bridge/netfilter/ebt_dnat.c
- net/bridge/netfilter/ebt_ip.c
- net/bridge/netfilter/ebt_ip6.c
- net/bridge/netfilter/ebt_limit.c
- net/bridge/netfilter/ebt_log.c
- net/bridge/netfilter/ebt_mark.c
- net/bridge/netfilter/ebt_mark_m.c
- net/bridge/netfilter/ebt_nflog.c
- net/bridge/netfilter/ebt_pkttype.c
- net/bridge/netfilter/ebt_redirect.c
- net/bridge/netfilter/ebt_snat.c
- net/bridge/netfilter/ebt_stp.c
- net/bridge/netfilter/ebt_ulog.c
- net/bridge/netfilter/ebt_vlan.c
- net/bridge/netfilter/ebtables.c
include/linux/netfilter_bridge/ebtables.h
... | ... | @@ -211,8 +211,7 @@ |
211 | 211 | int (*match)(const struct sk_buff *skb, const struct net_device *in, |
212 | 212 | const struct net_device *out, const void *matchdata, |
213 | 213 | unsigned int datalen); |
214 | - /* 0 == let it in */ | |
215 | - int (*check)(const char *tablename, unsigned int hookmask, | |
214 | + bool (*check)(const char *tablename, unsigned int hookmask, | |
216 | 215 | const struct ebt_entry *e, void *matchdata, unsigned int datalen); |
217 | 216 | void (*destroy)(void *matchdata, unsigned int datalen); |
218 | 217 | unsigned int matchsize; |
... | ... | @@ -226,8 +225,7 @@ |
226 | 225 | void (*watcher)(const struct sk_buff *skb, unsigned int hooknr, |
227 | 226 | const struct net_device *in, const struct net_device *out, |
228 | 227 | const void *watcherdata, unsigned int datalen); |
229 | - /* 0 == let it in */ | |
230 | - int (*check)(const char *tablename, unsigned int hookmask, | |
228 | + bool (*check)(const char *tablename, unsigned int hookmask, | |
231 | 229 | const struct ebt_entry *e, void *watcherdata, unsigned int datalen); |
232 | 230 | void (*destroy)(void *watcherdata, unsigned int datalen); |
233 | 231 | unsigned int targetsize; |
... | ... | @@ -242,8 +240,7 @@ |
242 | 240 | int (*target)(struct sk_buff *skb, unsigned int hooknr, |
243 | 241 | const struct net_device *in, const struct net_device *out, |
244 | 242 | const void *targetdata, unsigned int datalen); |
245 | - /* 0 == let it in */ | |
246 | - int (*check)(const char *tablename, unsigned int hookmask, | |
243 | + bool (*check)(const char *tablename, unsigned int hookmask, | |
247 | 244 | const struct ebt_entry *e, void *targetdata, unsigned int datalen); |
248 | 245 | void (*destroy)(void *targetdata, unsigned int datalen); |
249 | 246 | unsigned int targetsize; |
net/bridge/netfilter/ebt_802_3.c
... | ... | @@ -37,15 +37,15 @@ |
37 | 37 | } |
38 | 38 | |
39 | 39 | static struct ebt_match filter_802_3; |
40 | -static int ebt_802_3_check(const char *tablename, unsigned int hookmask, | |
40 | +static bool ebt_802_3_check(const char *tablename, unsigned int hookmask, | |
41 | 41 | const struct ebt_entry *e, void *data, unsigned int datalen) |
42 | 42 | { |
43 | 43 | const struct ebt_802_3_info *info = data; |
44 | 44 | |
45 | 45 | if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK) |
46 | - return -EINVAL; | |
46 | + return false; | |
47 | 47 | |
48 | - return 0; | |
48 | + return true; | |
49 | 49 | } |
50 | 50 | |
51 | 51 | static struct ebt_match filter_802_3 __read_mostly = { |
net/bridge/netfilter/ebt_among.c
... | ... | @@ -177,9 +177,10 @@ |
177 | 177 | return EBT_MATCH; |
178 | 178 | } |
179 | 179 | |
180 | -static int ebt_among_check(const char *tablename, unsigned int hookmask, | |
181 | - const struct ebt_entry *e, void *data, | |
182 | - unsigned int datalen) | |
180 | +static bool | |
181 | +ebt_among_check(const char *tablename, unsigned int hookmask, | |
182 | + const struct ebt_entry *e, void *data, | |
183 | + unsigned int datalen) | |
183 | 184 | { |
184 | 185 | const struct ebt_among_info *info = data; |
185 | 186 | int expected_length = sizeof(struct ebt_among_info); |
186 | 187 | |
187 | 188 | |
188 | 189 | |
... | ... | @@ -197,19 +198,19 @@ |
197 | 198 | "against expected %d, rounded to %Zd\n", |
198 | 199 | datalen, expected_length, |
199 | 200 | EBT_ALIGN(expected_length)); |
200 | - return -EINVAL; | |
201 | + return false; | |
201 | 202 | } |
202 | 203 | if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) { |
203 | 204 | printk(KERN_WARNING |
204 | 205 | "ebtables: among: dst integrity fail: %x\n", -err); |
205 | - return -EINVAL; | |
206 | + return false; | |
206 | 207 | } |
207 | 208 | if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) { |
208 | 209 | printk(KERN_WARNING |
209 | 210 | "ebtables: among: src integrity fail: %x\n", -err); |
210 | - return -EINVAL; | |
211 | + return false; | |
211 | 212 | } |
212 | - return 0; | |
213 | + return true; | |
213 | 214 | } |
214 | 215 | |
215 | 216 | static struct ebt_match filter_among __read_mostly = { |
net/bridge/netfilter/ebt_arp.c
... | ... | @@ -100,7 +100,7 @@ |
100 | 100 | return EBT_MATCH; |
101 | 101 | } |
102 | 102 | |
103 | -static int ebt_arp_check(const char *tablename, unsigned int hookmask, | |
103 | +static bool ebt_arp_check(const char *tablename, unsigned int hookmask, | |
104 | 104 | const struct ebt_entry *e, void *data, unsigned int datalen) |
105 | 105 | { |
106 | 106 | const struct ebt_arp_info *info = data; |
107 | 107 | |
... | ... | @@ -108,10 +108,10 @@ |
108 | 108 | if ((e->ethproto != htons(ETH_P_ARP) && |
109 | 109 | e->ethproto != htons(ETH_P_RARP)) || |
110 | 110 | e->invflags & EBT_IPROTO) |
111 | - return -EINVAL; | |
111 | + return false; | |
112 | 112 | if (info->bitmask & ~EBT_ARP_MASK || info->invflags & ~EBT_ARP_MASK) |
113 | - return -EINVAL; | |
114 | - return 0; | |
113 | + return false; | |
114 | + return true; | |
115 | 115 | } |
116 | 116 | |
117 | 117 | static struct ebt_match filter_arp __read_mostly = { |
net/bridge/netfilter/ebt_arpreply.c
... | ... | @@ -58,20 +58,20 @@ |
58 | 58 | return info->target; |
59 | 59 | } |
60 | 60 | |
61 | -static int ebt_target_reply_check(const char *tablename, unsigned int hookmask, | |
61 | +static bool ebt_target_reply_check(const char *tablename, unsigned int hookmask, | |
62 | 62 | const struct ebt_entry *e, void *data, unsigned int datalen) |
63 | 63 | { |
64 | 64 | const struct ebt_arpreply_info *info = data; |
65 | 65 | |
66 | 66 | if (BASE_CHAIN && info->target == EBT_RETURN) |
67 | - return -EINVAL; | |
67 | + return false; | |
68 | 68 | if (e->ethproto != htons(ETH_P_ARP) || |
69 | 69 | e->invflags & EBT_IPROTO) |
70 | - return -EINVAL; | |
70 | + return false; | |
71 | 71 | CLEAR_BASE_CHAIN_BIT; |
72 | 72 | if (strcmp(tablename, "nat") || hookmask & ~(1 << NF_BR_PRE_ROUTING)) |
73 | - return -EINVAL; | |
74 | - return 0; | |
73 | + return false; | |
74 | + return true; | |
75 | 75 | } |
76 | 76 | |
77 | 77 | static struct ebt_target reply_target __read_mostly = { |
net/bridge/netfilter/ebt_dnat.c
... | ... | @@ -27,21 +27,21 @@ |
27 | 27 | return info->target; |
28 | 28 | } |
29 | 29 | |
30 | -static int ebt_target_dnat_check(const char *tablename, unsigned int hookmask, | |
30 | +static bool ebt_target_dnat_check(const char *tablename, unsigned int hookmask, | |
31 | 31 | const struct ebt_entry *e, void *data, unsigned int datalen) |
32 | 32 | { |
33 | 33 | const struct ebt_nat_info *info = data; |
34 | 34 | |
35 | 35 | if (BASE_CHAIN && info->target == EBT_RETURN) |
36 | - return -EINVAL; | |
36 | + return false; | |
37 | 37 | CLEAR_BASE_CHAIN_BIT; |
38 | 38 | if ( (strcmp(tablename, "nat") || |
39 | 39 | (hookmask & ~((1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_LOCAL_OUT)))) && |
40 | 40 | (strcmp(tablename, "broute") || hookmask & ~(1 << NF_BR_BROUTING)) ) |
41 | - return -EINVAL; | |
41 | + return false; | |
42 | 42 | if (INVALID_TARGET) |
43 | - return -EINVAL; | |
44 | - return 0; | |
43 | + return false; | |
44 | + return true; | |
45 | 45 | } |
46 | 46 | |
47 | 47 | static struct ebt_target dnat __read_mostly = { |
net/bridge/netfilter/ebt_ip.c
... | ... | @@ -78,31 +78,31 @@ |
78 | 78 | return EBT_MATCH; |
79 | 79 | } |
80 | 80 | |
81 | -static int ebt_ip_check(const char *tablename, unsigned int hookmask, | |
81 | +static bool ebt_ip_check(const char *tablename, unsigned int hookmask, | |
82 | 82 | const struct ebt_entry *e, void *data, unsigned int datalen) |
83 | 83 | { |
84 | 84 | const struct ebt_ip_info *info = data; |
85 | 85 | |
86 | 86 | if (e->ethproto != htons(ETH_P_IP) || |
87 | 87 | e->invflags & EBT_IPROTO) |
88 | - return -EINVAL; | |
88 | + return false; | |
89 | 89 | if (info->bitmask & ~EBT_IP_MASK || info->invflags & ~EBT_IP_MASK) |
90 | - return -EINVAL; | |
90 | + return false; | |
91 | 91 | if (info->bitmask & (EBT_IP_DPORT | EBT_IP_SPORT)) { |
92 | 92 | if (info->invflags & EBT_IP_PROTO) |
93 | - return -EINVAL; | |
93 | + return false; | |
94 | 94 | if (info->protocol != IPPROTO_TCP && |
95 | 95 | info->protocol != IPPROTO_UDP && |
96 | 96 | info->protocol != IPPROTO_UDPLITE && |
97 | 97 | info->protocol != IPPROTO_SCTP && |
98 | 98 | info->protocol != IPPROTO_DCCP) |
99 | - return -EINVAL; | |
99 | + return false; | |
100 | 100 | } |
101 | 101 | if (info->bitmask & EBT_IP_DPORT && info->dport[0] > info->dport[1]) |
102 | - return -EINVAL; | |
102 | + return false; | |
103 | 103 | if (info->bitmask & EBT_IP_SPORT && info->sport[0] > info->sport[1]) |
104 | - return -EINVAL; | |
105 | - return 0; | |
104 | + return false; | |
105 | + return true; | |
106 | 106 | } |
107 | 107 | |
108 | 108 | static struct ebt_match filter_ip __read_mostly = { |
net/bridge/netfilter/ebt_ip6.c
... | ... | @@ -92,30 +92,30 @@ |
92 | 92 | return EBT_MATCH; |
93 | 93 | } |
94 | 94 | |
95 | -static int ebt_ip6_check(const char *tablename, unsigned int hookmask, | |
95 | +static bool ebt_ip6_check(const char *tablename, unsigned int hookmask, | |
96 | 96 | const struct ebt_entry *e, void *data, unsigned int datalen) |
97 | 97 | { |
98 | 98 | struct ebt_ip6_info *info = (struct ebt_ip6_info *)data; |
99 | 99 | |
100 | 100 | if (e->ethproto != htons(ETH_P_IPV6) || e->invflags & EBT_IPROTO) |
101 | - return -EINVAL; | |
101 | + return false; | |
102 | 102 | if (info->bitmask & ~EBT_IP6_MASK || info->invflags & ~EBT_IP6_MASK) |
103 | - return -EINVAL; | |
103 | + return false; | |
104 | 104 | if (info->bitmask & (EBT_IP6_DPORT | EBT_IP6_SPORT)) { |
105 | 105 | if (info->invflags & EBT_IP6_PROTO) |
106 | - return -EINVAL; | |
106 | + return false; | |
107 | 107 | if (info->protocol != IPPROTO_TCP && |
108 | 108 | info->protocol != IPPROTO_UDP && |
109 | 109 | info->protocol != IPPROTO_UDPLITE && |
110 | 110 | info->protocol != IPPROTO_SCTP && |
111 | 111 | info->protocol != IPPROTO_DCCP) |
112 | - return -EINVAL; | |
112 | + return false; | |
113 | 113 | } |
114 | 114 | if (info->bitmask & EBT_IP6_DPORT && info->dport[0] > info->dport[1]) |
115 | - return -EINVAL; | |
115 | + return false; | |
116 | 116 | if (info->bitmask & EBT_IP6_SPORT && info->sport[0] > info->sport[1]) |
117 | - return -EINVAL; | |
118 | - return 0; | |
117 | + return false; | |
118 | + return true; | |
119 | 119 | } |
120 | 120 | |
121 | 121 | static struct ebt_match filter_ip6 = |
net/bridge/netfilter/ebt_limit.c
... | ... | @@ -65,7 +65,7 @@ |
65 | 65 | return (user * HZ * CREDITS_PER_JIFFY) / EBT_LIMIT_SCALE; |
66 | 66 | } |
67 | 67 | |
68 | -static int ebt_limit_check(const char *tablename, unsigned int hookmask, | |
68 | +static bool ebt_limit_check(const char *tablename, unsigned int hookmask, | |
69 | 69 | const struct ebt_entry *e, void *data, unsigned int datalen) |
70 | 70 | { |
71 | 71 | struct ebt_limit_info *info = data; |
... | ... | @@ -75,7 +75,7 @@ |
75 | 75 | user2credits(info->avg * info->burst) < user2credits(info->avg)) { |
76 | 76 | printk("Overflow in ebt_limit, try lower: %u/%u\n", |
77 | 77 | info->avg, info->burst); |
78 | - return -EINVAL; | |
78 | + return false; | |
79 | 79 | } |
80 | 80 | |
81 | 81 | /* User avg in seconds * EBT_LIMIT_SCALE: convert to jiffies * 128. */ |
... | ... | @@ -83,7 +83,7 @@ |
83 | 83 | info->credit = user2credits(info->avg * info->burst); |
84 | 84 | info->credit_cap = user2credits(info->avg * info->burst); |
85 | 85 | info->cost = user2credits(info->avg); |
86 | - return 0; | |
86 | + return true; | |
87 | 87 | } |
88 | 88 | |
89 | 89 | static struct ebt_match ebt_limit_reg __read_mostly = { |
net/bridge/netfilter/ebt_log.c
... | ... | @@ -24,17 +24,17 @@ |
24 | 24 | |
25 | 25 | static DEFINE_SPINLOCK(ebt_log_lock); |
26 | 26 | |
27 | -static int ebt_log_check(const char *tablename, unsigned int hookmask, | |
27 | +static bool ebt_log_check(const char *tablename, unsigned int hookmask, | |
28 | 28 | const struct ebt_entry *e, void *data, unsigned int datalen) |
29 | 29 | { |
30 | 30 | struct ebt_log_info *info = data; |
31 | 31 | |
32 | 32 | if (info->bitmask & ~EBT_LOG_MASK) |
33 | - return -EINVAL; | |
33 | + return false; | |
34 | 34 | if (info->loglevel >= 8) |
35 | - return -EINVAL; | |
35 | + return false; | |
36 | 36 | info->prefix[EBT_LOG_PREFIX_SIZE - 1] = '\0'; |
37 | - return 0; | |
37 | + return true; | |
38 | 38 | } |
39 | 39 | |
40 | 40 | struct tcpudphdr |
net/bridge/netfilter/ebt_mark.c
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | return info->target | ~EBT_VERDICT_BITS; |
38 | 38 | } |
39 | 39 | |
40 | -static int ebt_target_mark_check(const char *tablename, unsigned int hookmask, | |
40 | +static bool ebt_target_mark_check(const char *tablename, unsigned int hookmask, | |
41 | 41 | const struct ebt_entry *e, void *data, unsigned int datalen) |
42 | 42 | { |
43 | 43 | const struct ebt_mark_t_info *info = data; |
44 | 44 | |
45 | 45 | |
... | ... | @@ -45,15 +45,15 @@ |
45 | 45 | |
46 | 46 | tmp = info->target | ~EBT_VERDICT_BITS; |
47 | 47 | if (BASE_CHAIN && tmp == EBT_RETURN) |
48 | - return -EINVAL; | |
48 | + return false; | |
49 | 49 | CLEAR_BASE_CHAIN_BIT; |
50 | 50 | if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0) |
51 | - return -EINVAL; | |
51 | + return false; | |
52 | 52 | tmp = info->target & ~EBT_VERDICT_BITS; |
53 | 53 | if (tmp != MARK_SET_VALUE && tmp != MARK_OR_VALUE && |
54 | 54 | tmp != MARK_AND_VALUE && tmp != MARK_XOR_VALUE) |
55 | - return -EINVAL; | |
56 | - return 0; | |
55 | + return false; | |
56 | + return true; | |
57 | 57 | } |
58 | 58 | |
59 | 59 | static struct ebt_target mark_target __read_mostly = { |
net/bridge/netfilter/ebt_mark_m.c
... | ... | @@ -23,18 +23,18 @@ |
23 | 23 | return !(((skb->mark & info->mask) == info->mark) ^ info->invert); |
24 | 24 | } |
25 | 25 | |
26 | -static int ebt_mark_check(const char *tablename, unsigned int hookmask, | |
26 | +static bool ebt_mark_check(const char *tablename, unsigned int hookmask, | |
27 | 27 | const struct ebt_entry *e, void *data, unsigned int datalen) |
28 | 28 | { |
29 | 29 | const struct ebt_mark_m_info *info = data; |
30 | 30 | |
31 | 31 | if (info->bitmask & ~EBT_MARK_MASK) |
32 | - return -EINVAL; | |
32 | + return false; | |
33 | 33 | if ((info->bitmask & EBT_MARK_OR) && (info->bitmask & EBT_MARK_AND)) |
34 | - return -EINVAL; | |
34 | + return false; | |
35 | 35 | if (!info->bitmask) |
36 | - return -EINVAL; | |
37 | - return 0; | |
36 | + return false; | |
37 | + return true; | |
38 | 38 | } |
39 | 39 | |
40 | 40 | static struct ebt_match filter_mark __read_mostly = { |
net/bridge/netfilter/ebt_nflog.c
... | ... | @@ -36,17 +36,17 @@ |
36 | 36 | nf_log_packet(PF_BRIDGE, hooknr, skb, in, out, &li, "%s", info->prefix); |
37 | 37 | } |
38 | 38 | |
39 | -static int ebt_nflog_check(const char *tablename, | |
40 | - unsigned int hookmask, | |
41 | - const struct ebt_entry *e, | |
42 | - void *data, unsigned int datalen) | |
39 | +static bool ebt_nflog_check(const char *tablename, | |
40 | + unsigned int hookmask, | |
41 | + const struct ebt_entry *e, | |
42 | + void *data, unsigned int datalen) | |
43 | 43 | { |
44 | 44 | struct ebt_nflog_info *info = (struct ebt_nflog_info *)data; |
45 | 45 | |
46 | 46 | if (info->flags & ~EBT_NFLOG_MASK) |
47 | - return -EINVAL; | |
47 | + return false; | |
48 | 48 | info->prefix[EBT_NFLOG_PREFIX_SIZE - 1] = '\0'; |
49 | - return 0; | |
49 | + return true; | |
50 | 50 | } |
51 | 51 | |
52 | 52 | static struct ebt_watcher nflog __read_mostly = { |
net/bridge/netfilter/ebt_pkttype.c
... | ... | @@ -23,15 +23,15 @@ |
23 | 23 | return (skb->pkt_type != info->pkt_type) ^ info->invert; |
24 | 24 | } |
25 | 25 | |
26 | -static int ebt_pkttype_check(const char *tablename, unsigned int hookmask, | |
26 | +static bool ebt_pkttype_check(const char *tablename, unsigned int hookmask, | |
27 | 27 | const struct ebt_entry *e, void *data, unsigned int datalen) |
28 | 28 | { |
29 | 29 | const struct ebt_pkttype_info *info = data; |
30 | 30 | |
31 | 31 | if (info->invert != 0 && info->invert != 1) |
32 | - return -EINVAL; | |
32 | + return false; | |
33 | 33 | /* Allow any pkt_type value */ |
34 | - return 0; | |
34 | + return true; | |
35 | 35 | } |
36 | 36 | |
37 | 37 | static struct ebt_match filter_pkttype __read_mostly = { |
net/bridge/netfilter/ebt_redirect.c
... | ... | @@ -33,20 +33,20 @@ |
33 | 33 | return info->target; |
34 | 34 | } |
35 | 35 | |
36 | -static int ebt_target_redirect_check(const char *tablename, unsigned int hookmask, | |
36 | +static bool ebt_target_redirect_check(const char *tablename, unsigned int hookmask, | |
37 | 37 | const struct ebt_entry *e, void *data, unsigned int datalen) |
38 | 38 | { |
39 | 39 | const struct ebt_redirect_info *info = data; |
40 | 40 | |
41 | 41 | if (BASE_CHAIN && info->target == EBT_RETURN) |
42 | - return -EINVAL; | |
42 | + return false; | |
43 | 43 | CLEAR_BASE_CHAIN_BIT; |
44 | 44 | if ( (strcmp(tablename, "nat") || hookmask & ~(1 << NF_BR_PRE_ROUTING)) && |
45 | 45 | (strcmp(tablename, "broute") || hookmask & ~(1 << NF_BR_BROUTING)) ) |
46 | - return -EINVAL; | |
46 | + return false; | |
47 | 47 | if (INVALID_TARGET) |
48 | - return -EINVAL; | |
49 | - return 0; | |
48 | + return false; | |
49 | + return true; | |
50 | 50 | } |
51 | 51 | |
52 | 52 | static struct ebt_target redirect_target __read_mostly = { |
net/bridge/netfilter/ebt_snat.c
... | ... | @@ -43,7 +43,7 @@ |
43 | 43 | return info->target | ~EBT_VERDICT_BITS; |
44 | 44 | } |
45 | 45 | |
46 | -static int ebt_target_snat_check(const char *tablename, unsigned int hookmask, | |
46 | +static bool ebt_target_snat_check(const char *tablename, unsigned int hookmask, | |
47 | 47 | const struct ebt_entry *e, void *data, unsigned int datalen) |
48 | 48 | { |
49 | 49 | const struct ebt_nat_info *info = data; |
50 | 50 | |
51 | 51 | |
52 | 52 | |
53 | 53 | |
... | ... | @@ -51,19 +51,19 @@ |
51 | 51 | |
52 | 52 | tmp = info->target | ~EBT_VERDICT_BITS; |
53 | 53 | if (BASE_CHAIN && tmp == EBT_RETURN) |
54 | - return -EINVAL; | |
54 | + return false; | |
55 | 55 | CLEAR_BASE_CHAIN_BIT; |
56 | 56 | if (strcmp(tablename, "nat")) |
57 | - return -EINVAL; | |
57 | + return false; | |
58 | 58 | if (hookmask & ~(1 << NF_BR_POST_ROUTING)) |
59 | - return -EINVAL; | |
59 | + return false; | |
60 | 60 | |
61 | 61 | if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0) |
62 | - return -EINVAL; | |
62 | + return false; | |
63 | 63 | tmp = info->target | EBT_VERDICT_BITS; |
64 | 64 | if ((tmp & ~NAT_ARP_BIT) != ~NAT_ARP_BIT) |
65 | - return -EINVAL; | |
66 | - return 0; | |
65 | + return false; | |
66 | + return true; | |
67 | 67 | } |
68 | 68 | |
69 | 69 | static struct ebt_target snat __read_mostly = { |
net/bridge/netfilter/ebt_stp.c
... | ... | @@ -153,7 +153,7 @@ |
153 | 153 | return EBT_MATCH; |
154 | 154 | } |
155 | 155 | |
156 | -static int ebt_stp_check(const char *tablename, unsigned int hookmask, | |
156 | +static bool ebt_stp_check(const char *tablename, unsigned int hookmask, | |
157 | 157 | const struct ebt_entry *e, void *data, unsigned int datalen) |
158 | 158 | { |
159 | 159 | const struct ebt_stp_info *info = data; |
160 | 160 | |
161 | 161 | |
... | ... | @@ -162,13 +162,13 @@ |
162 | 162 | |
163 | 163 | if (info->bitmask & ~EBT_STP_MASK || info->invflags & ~EBT_STP_MASK || |
164 | 164 | !(info->bitmask & EBT_STP_MASK)) |
165 | - return -EINVAL; | |
165 | + return false; | |
166 | 166 | /* Make sure the match only receives stp frames */ |
167 | 167 | if (compare_ether_addr(e->destmac, bridge_ula) || |
168 | 168 | compare_ether_addr(e->destmsk, msk) || !(e->bitmask & EBT_DESTMAC)) |
169 | - return -EINVAL; | |
169 | + return false; | |
170 | 170 | |
171 | - return 0; | |
171 | + return true; | |
172 | 172 | } |
173 | 173 | |
174 | 174 | static struct ebt_match filter_stp __read_mostly = { |
net/bridge/netfilter/ebt_ulog.c
... | ... | @@ -255,14 +255,13 @@ |
255 | 255 | ebt_ulog_packet(hooknr, skb, in, out, uloginfo, NULL); |
256 | 256 | } |
257 | 257 | |
258 | - | |
259 | -static int ebt_ulog_check(const char *tablename, unsigned int hookmask, | |
258 | +static bool ebt_ulog_check(const char *tablename, unsigned int hookmask, | |
260 | 259 | const struct ebt_entry *e, void *data, unsigned int datalen) |
261 | 260 | { |
262 | 261 | struct ebt_ulog_info *uloginfo = data; |
263 | 262 | |
264 | 263 | if (uloginfo->nlgroup > 31) |
265 | - return -EINVAL; | |
264 | + return false; | |
266 | 265 | |
267 | 266 | uloginfo->prefix[EBT_ULOG_PREFIX_LEN - 1] = '\0'; |
268 | 267 | |
269 | 268 | |
... | ... | @@ -288,12 +287,13 @@ |
288 | 287 | |
289 | 288 | static int __init ebt_ulog_init(void) |
290 | 289 | { |
291 | - int i, ret = 0; | |
290 | + bool ret = true; | |
291 | + int i; | |
292 | 292 | |
293 | 293 | if (nlbufsiz >= 128*1024) { |
294 | 294 | printk(KERN_NOTICE "ebt_ulog: Netlink buffer has to be <= 128kB," |
295 | 295 | " please try a smaller nlbufsiz parameter.\n"); |
296 | - return -EINVAL; | |
296 | + return false; | |
297 | 297 | } |
298 | 298 | |
299 | 299 | /* initialize ulog_buffers */ |
300 | 300 | |
301 | 301 | |
... | ... | @@ -305,12 +305,15 @@ |
305 | 305 | ebtulognl = netlink_kernel_create(&init_net, NETLINK_NFLOG, |
306 | 306 | EBT_ULOG_MAXNLGROUPS, NULL, NULL, |
307 | 307 | THIS_MODULE); |
308 | - if (!ebtulognl) | |
309 | - ret = -ENOMEM; | |
310 | - else if ((ret = ebt_register_watcher(&ulog))) | |
308 | + if (!ebtulognl) { | |
309 | + printk(KERN_WARNING KBUILD_MODNAME ": out of memory trying to " | |
310 | + "call netlink_kernel_create\n"); | |
311 | + ret = false; | |
312 | + } else if (ebt_register_watcher(&ulog) != 0) { | |
311 | 313 | netlink_kernel_release(ebtulognl); |
314 | + } | |
312 | 315 | |
313 | - if (ret == 0) | |
316 | + if (ret) | |
314 | 317 | nf_log_register(NFPROTO_BRIDGE, &ebt_ulog_logger); |
315 | 318 | |
316 | 319 | return ret; |
net/bridge/netfilter/ebt_vlan.c
... | ... | @@ -87,7 +87,7 @@ |
87 | 87 | return EBT_MATCH; |
88 | 88 | } |
89 | 89 | |
90 | -static int | |
90 | +static bool | |
91 | 91 | ebt_check_vlan(const char *tablename, |
92 | 92 | unsigned int hooknr, |
93 | 93 | const struct ebt_entry *e, void *data, unsigned int datalen) |
... | ... | @@ -99,7 +99,7 @@ |
99 | 99 | DEBUG_MSG |
100 | 100 | ("passed entry proto %2.4X is not 802.1Q (8100)\n", |
101 | 101 | (unsigned short) ntohs(e->ethproto)); |
102 | - return -EINVAL; | |
102 | + return false; | |
103 | 103 | } |
104 | 104 | |
105 | 105 | /* Check for bitmask range |
106 | 106 | |
... | ... | @@ -107,14 +107,14 @@ |
107 | 107 | if (info->bitmask & ~EBT_VLAN_MASK) { |
108 | 108 | DEBUG_MSG("bitmask %2X is out of mask (%2X)\n", |
109 | 109 | info->bitmask, EBT_VLAN_MASK); |
110 | - return -EINVAL; | |
110 | + return false; | |
111 | 111 | } |
112 | 112 | |
113 | 113 | /* Check for inversion flags range */ |
114 | 114 | if (info->invflags & ~EBT_VLAN_MASK) { |
115 | 115 | DEBUG_MSG("inversion flags %2X is out of mask (%2X)\n", |
116 | 116 | info->invflags, EBT_VLAN_MASK); |
117 | - return -EINVAL; | |
117 | + return false; | |
118 | 118 | } |
119 | 119 | |
120 | 120 | /* Reserved VLAN ID (VID) values |
... | ... | @@ -129,7 +129,7 @@ |
129 | 129 | DEBUG_MSG |
130 | 130 | ("id %d is out of range (1-4096)\n", |
131 | 131 | info->id); |
132 | - return -EINVAL; | |
132 | + return false; | |
133 | 133 | } |
134 | 134 | /* Note: This is valid VLAN-tagged frame point. |
135 | 135 | * Any value of user_priority are acceptable, |
... | ... | @@ -144,7 +144,7 @@ |
144 | 144 | if ((unsigned char) info->prio > 7) { |
145 | 145 | DEBUG_MSG("prio %d is out of range (0-7)\n", |
146 | 146 | info->prio); |
147 | - return -EINVAL; | |
147 | + return false; | |
148 | 148 | } |
149 | 149 | } |
150 | 150 | /* Check for encapsulated proto range - it is possible to be |
151 | 151 | |
... | ... | @@ -155,11 +155,11 @@ |
155 | 155 | DEBUG_MSG |
156 | 156 | ("encap frame length %d is less than minimal\n", |
157 | 157 | ntohs(info->encap)); |
158 | - return -EINVAL; | |
158 | + return false; | |
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - return 0; | |
162 | + return true; | |
163 | 163 | } |
164 | 164 | |
165 | 165 | static struct ebt_match filter_vlan __read_mostly = { |
net/bridge/netfilter/ebtables.c
... | ... | @@ -365,7 +365,7 @@ |
365 | 365 | return -EINVAL; |
366 | 366 | } |
367 | 367 | if (match->check && |
368 | - match->check(name, hookmask, e, m->data, m->match_size) != 0) { | |
368 | + !match->check(name, hookmask, e, m->data, m->match_size)) { | |
369 | 369 | BUGPRINT("match->check failed\n"); |
370 | 370 | module_put(match->me); |
371 | 371 | return -EINVAL; |
... | ... | @@ -403,7 +403,7 @@ |
403 | 403 | return -EINVAL; |
404 | 404 | } |
405 | 405 | if (watcher->check && |
406 | - watcher->check(name, hookmask, e, w->data, w->watcher_size) != 0) { | |
406 | + !watcher->check(name, hookmask, e, w->data, w->watcher_size)) { | |
407 | 407 | BUGPRINT("watcher->check failed\n"); |
408 | 408 | module_put(watcher->me); |
409 | 409 | return -EINVAL; |
... | ... | @@ -716,7 +716,7 @@ |
716 | 716 | ret = -EINVAL; |
717 | 717 | goto cleanup_watchers; |
718 | 718 | } else if (t->u.target->check && |
719 | - t->u.target->check(name, hookmask, e, t->data, t->target_size) != 0) { | |
719 | + !t->u.target->check(name, hookmask, e, t->data, t->target_size)) { | |
720 | 720 | module_put(t->u.target->me); |
721 | 721 | ret = -EFAULT; |
722 | 722 | goto cleanup_watchers; |