Skip to content

Commit 19eda87

Browse files
Jan Engelhardtkaber
authored andcommitted
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>
1 parent 18219d3 commit 19eda87

20 files changed

Lines changed: 109 additions & 108 deletions

‎include/linux/netfilter_bridge/ebtables.h‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ struct ebt_match
211211
int (*match)(const struct sk_buff *skb, const struct net_device *in,
212212
const struct net_device *out, const void *matchdata,
213213
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,
216215
const struct ebt_entry *e, void *matchdata, unsigned int datalen);
217216
void (*destroy)(void *matchdata, unsigned int datalen);
218217
unsigned int matchsize;
@@ -226,8 +225,7 @@ struct ebt_watcher
226225
void (*watcher)(const struct sk_buff *skb, unsigned int hooknr,
227226
const struct net_device *in, const struct net_device *out,
228227
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,
231229
const struct ebt_entry *e, void *watcherdata, unsigned int datalen);
232230
void (*destroy)(void *watcherdata, unsigned int datalen);
233231
unsigned int targetsize;
@@ -242,8 +240,7 @@ struct ebt_target
242240
int (*target)(struct sk_buff *skb, unsigned int hooknr,
243241
const struct net_device *in, const struct net_device *out,
244242
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,
247244
const struct ebt_entry *e, void *targetdata, unsigned int datalen);
248245
void (*destroy)(void *targetdata, unsigned int datalen);
249246
unsigned int targetsize;

‎net/bridge/netfilter/ebt_802_3.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ static int ebt_filter_802_3(const struct sk_buff *skb, const struct net_device *
3737
}
3838

3939
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,
4141
const struct ebt_entry *e, void *data, unsigned int datalen)
4242
{
4343
const struct ebt_802_3_info *info = data;
4444

4545
if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK)
46-
return -EINVAL;
46+
return false;
4747

48-
return 0;
48+
return true;
4949
}
5050

5151
static struct ebt_match filter_802_3 __read_mostly = {

‎net/bridge/netfilter/ebt_among.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ static int ebt_filter_among(const struct sk_buff *skb,
177177
return EBT_MATCH;
178178
}
179179

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)
183184
{
184185
const struct ebt_among_info *info = data;
185186
int expected_length = sizeof(struct ebt_among_info);
@@ -197,19 +198,19 @@ static int ebt_among_check(const char *tablename, unsigned int hookmask,
197198
"against expected %d, rounded to %Zd\n",
198199
datalen, expected_length,
199200
EBT_ALIGN(expected_length));
200-
return -EINVAL;
201+
return false;
201202
}
202203
if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) {
203204
printk(KERN_WARNING
204205
"ebtables: among: dst integrity fail: %x\n", -err);
205-
return -EINVAL;
206+
return false;
206207
}
207208
if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) {
208209
printk(KERN_WARNING
209210
"ebtables: among: src integrity fail: %x\n", -err);
210-
return -EINVAL;
211+
return false;
211212
}
212-
return 0;
213+
return true;
213214
}
214215

215216
static struct ebt_match filter_among __read_mostly = {

‎net/bridge/netfilter/ebt_arp.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,18 @@ static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *in
100100
return EBT_MATCH;
101101
}
102102

103-
static int ebt_arp_check(const char *tablename, unsigned int hookmask,
103+
static bool ebt_arp_check(const char *tablename, unsigned int hookmask,
104104
const struct ebt_entry *e, void *data, unsigned int datalen)
105105
{
106106
const struct ebt_arp_info *info = data;
107107

108108
if ((e->ethproto != htons(ETH_P_ARP) &&
109109
e->ethproto != htons(ETH_P_RARP)) ||
110110
e->invflags & EBT_IPROTO)
111-
return -EINVAL;
111+
return false;
112112
if (info->bitmask & ~EBT_ARP_MASK || info->invflags & ~EBT_ARP_MASK)
113-
return -EINVAL;
114-
return 0;
113+
return false;
114+
return true;
115115
}
116116

117117
static struct ebt_match filter_arp __read_mostly = {

‎net/bridge/netfilter/ebt_arpreply.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,20 @@ static int ebt_target_reply(struct sk_buff *skb, unsigned int hooknr,
5858
return info->target;
5959
}
6060

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,
6262
const struct ebt_entry *e, void *data, unsigned int datalen)
6363
{
6464
const struct ebt_arpreply_info *info = data;
6565

6666
if (BASE_CHAIN && info->target == EBT_RETURN)
67-
return -EINVAL;
67+
return false;
6868
if (e->ethproto != htons(ETH_P_ARP) ||
6969
e->invflags & EBT_IPROTO)
70-
return -EINVAL;
70+
return false;
7171
CLEAR_BASE_CHAIN_BIT;
7272
if (strcmp(tablename, "nat") || hookmask & ~(1 << NF_BR_PRE_ROUTING))
73-
return -EINVAL;
74-
return 0;
73+
return false;
74+
return true;
7575
}
7676

7777
static struct ebt_target reply_target __read_mostly = {

‎net/bridge/netfilter/ebt_dnat.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ static int ebt_target_dnat(struct sk_buff *skb, unsigned int hooknr,
2727
return info->target;
2828
}
2929

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,
3131
const struct ebt_entry *e, void *data, unsigned int datalen)
3232
{
3333
const struct ebt_nat_info *info = data;
3434

3535
if (BASE_CHAIN && info->target == EBT_RETURN)
36-
return -EINVAL;
36+
return false;
3737
CLEAR_BASE_CHAIN_BIT;
3838
if ( (strcmp(tablename, "nat") ||
3939
(hookmask & ~((1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_LOCAL_OUT)))) &&
4040
(strcmp(tablename, "broute") || hookmask & ~(1 << NF_BR_BROUTING)) )
41-
return -EINVAL;
41+
return false;
4242
if (INVALID_TARGET)
43-
return -EINVAL;
44-
return 0;
43+
return false;
44+
return true;
4545
}
4646

4747
static struct ebt_target dnat __read_mostly = {

‎net/bridge/netfilter/ebt_ip.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,31 @@ static int ebt_filter_ip(const struct sk_buff *skb, const struct net_device *in,
7878
return EBT_MATCH;
7979
}
8080

81-
static int ebt_ip_check(const char *tablename, unsigned int hookmask,
81+
static bool ebt_ip_check(const char *tablename, unsigned int hookmask,
8282
const struct ebt_entry *e, void *data, unsigned int datalen)
8383
{
8484
const struct ebt_ip_info *info = data;
8585

8686
if (e->ethproto != htons(ETH_P_IP) ||
8787
e->invflags & EBT_IPROTO)
88-
return -EINVAL;
88+
return false;
8989
if (info->bitmask & ~EBT_IP_MASK || info->invflags & ~EBT_IP_MASK)
90-
return -EINVAL;
90+
return false;
9191
if (info->bitmask & (EBT_IP_DPORT | EBT_IP_SPORT)) {
9292
if (info->invflags & EBT_IP_PROTO)
93-
return -EINVAL;
93+
return false;
9494
if (info->protocol != IPPROTO_TCP &&
9595
info->protocol != IPPROTO_UDP &&
9696
info->protocol != IPPROTO_UDPLITE &&
9797
info->protocol != IPPROTO_SCTP &&
9898
info->protocol != IPPROTO_DCCP)
99-
return -EINVAL;
99+
return false;
100100
}
101101
if (info->bitmask & EBT_IP_DPORT && info->dport[0] > info->dport[1])
102-
return -EINVAL;
102+
return false;
103103
if (info->bitmask & EBT_IP_SPORT && info->sport[0] > info->sport[1])
104-
return -EINVAL;
105-
return 0;
104+
return false;
105+
return true;
106106
}
107107

108108
static struct ebt_match filter_ip __read_mostly = {

‎net/bridge/netfilter/ebt_ip6.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,30 @@ static int ebt_filter_ip6(const struct sk_buff *skb,
9292
return EBT_MATCH;
9393
}
9494

95-
static int ebt_ip6_check(const char *tablename, unsigned int hookmask,
95+
static bool ebt_ip6_check(const char *tablename, unsigned int hookmask,
9696
const struct ebt_entry *e, void *data, unsigned int datalen)
9797
{
9898
struct ebt_ip6_info *info = (struct ebt_ip6_info *)data;
9999

100100
if (e->ethproto != htons(ETH_P_IPV6) || e->invflags & EBT_IPROTO)
101-
return -EINVAL;
101+
return false;
102102
if (info->bitmask & ~EBT_IP6_MASK || info->invflags & ~EBT_IP6_MASK)
103-
return -EINVAL;
103+
return false;
104104
if (info->bitmask & (EBT_IP6_DPORT | EBT_IP6_SPORT)) {
105105
if (info->invflags & EBT_IP6_PROTO)
106-
return -EINVAL;
106+
return false;
107107
if (info->protocol != IPPROTO_TCP &&
108108
info->protocol != IPPROTO_UDP &&
109109
info->protocol != IPPROTO_UDPLITE &&
110110
info->protocol != IPPROTO_SCTP &&
111111
info->protocol != IPPROTO_DCCP)
112-
return -EINVAL;
112+
return false;
113113
}
114114
if (info->bitmask & EBT_IP6_DPORT && info->dport[0] > info->dport[1])
115-
return -EINVAL;
115+
return false;
116116
if (info->bitmask & EBT_IP6_SPORT && info->sport[0] > info->sport[1])
117-
return -EINVAL;
118-
return 0;
117+
return false;
118+
return true;
119119
}
120120

121121
static struct ebt_match filter_ip6 =

‎net/bridge/netfilter/ebt_limit.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ user2credits(u_int32_t user)
6565
return (user * HZ * CREDITS_PER_JIFFY) / EBT_LIMIT_SCALE;
6666
}
6767

68-
static int ebt_limit_check(const char *tablename, unsigned int hookmask,
68+
static bool ebt_limit_check(const char *tablename, unsigned int hookmask,
6969
const struct ebt_entry *e, void *data, unsigned int datalen)
7070
{
7171
struct ebt_limit_info *info = data;
@@ -75,15 +75,15 @@ static int ebt_limit_check(const char *tablename, unsigned int hookmask,
7575
user2credits(info->avg * info->burst) < user2credits(info->avg)) {
7676
printk("Overflow in ebt_limit, try lower: %u/%u\n",
7777
info->avg, info->burst);
78-
return -EINVAL;
78+
return false;
7979
}
8080

8181
/* User avg in seconds * EBT_LIMIT_SCALE: convert to jiffies * 128. */
8282
info->prev = jiffies;
8383
info->credit = user2credits(info->avg * info->burst);
8484
info->credit_cap = user2credits(info->avg * info->burst);
8585
info->cost = user2credits(info->avg);
86-
return 0;
86+
return true;
8787
}
8888

8989
static struct ebt_match ebt_limit_reg __read_mostly = {

‎net/bridge/netfilter/ebt_log.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424

2525
static DEFINE_SPINLOCK(ebt_log_lock);
2626

27-
static int ebt_log_check(const char *tablename, unsigned int hookmask,
27+
static bool ebt_log_check(const char *tablename, unsigned int hookmask,
2828
const struct ebt_entry *e, void *data, unsigned int datalen)
2929
{
3030
struct ebt_log_info *info = data;
3131

3232
if (info->bitmask & ~EBT_LOG_MASK)
33-
return -EINVAL;
33+
return false;
3434
if (info->loglevel >= 8)
35-
return -EINVAL;
35+
return false;
3636
info->prefix[EBT_LOG_PREFIX_SIZE - 1] = '\0';
37-
return 0;
37+
return true;
3838
}
3939

4040
struct tcpudphdr

0 commit comments

Comments
 (0)