Commit f2ea825f authored by Jan Engelhardt's avatar Jan Engelhardt Committed by Patrick McHardy

[NETFILTER]: nf_nat: use bool type in nf_nat_proto

Signed-off-by: default avatarJan Engelhardt <jengelh@computergmbh.de>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
parent 5f2b4c90
...@@ -15,13 +15,13 @@ struct nf_nat_protocol ...@@ -15,13 +15,13 @@ struct nf_nat_protocol
/* Translate a packet to the target according to manip type. /* Translate a packet to the target according to manip type.
Return true if succeeded. */ Return true if succeeded. */
int (*manip_pkt)(struct sk_buff *skb, bool (*manip_pkt)(struct sk_buff *skb,
unsigned int iphdroff, unsigned int iphdroff,
const struct nf_conntrack_tuple *tuple, const struct nf_conntrack_tuple *tuple,
enum nf_nat_manip_type maniptype); enum nf_nat_manip_type maniptype);
/* Is the manipable part of the tuple between min and max incl? */ /* Is the manipable part of the tuple between min and max incl? */
int (*in_range)(const struct nf_conntrack_tuple *tuple, bool (*in_range)(const struct nf_conntrack_tuple *tuple,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
const union nf_conntrack_man_proto *min, const union nf_conntrack_man_proto *min,
const union nf_conntrack_man_proto *max); const union nf_conntrack_man_proto *max);
...@@ -30,7 +30,7 @@ struct nf_nat_protocol ...@@ -30,7 +30,7 @@ struct nf_nat_protocol
maniptype), to give a unique tuple in the given range if maniptype), to give a unique tuple in the given range if
possible; return false if not. Per-protocol part of tuple possible; return false if not. Per-protocol part of tuple
is initialized to the incoming packet. */ is initialized to the incoming packet. */
int (*unique_tuple)(struct nf_conntrack_tuple *tuple, bool (*unique_tuple)(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range, const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
const struct nf_conn *ct); const struct nf_conn *ct);
...@@ -59,12 +59,12 @@ extern int init_protocols(void) __init; ...@@ -59,12 +59,12 @@ extern int init_protocols(void) __init;
extern void cleanup_protocols(void); extern void cleanup_protocols(void);
extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum); extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
extern int nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple, extern bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
const union nf_conntrack_man_proto *min, const union nf_conntrack_man_proto *min,
const union nf_conntrack_man_proto *max); const union nf_conntrack_man_proto *max);
extern int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, extern bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range, const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
const struct nf_conn *ct, const struct nf_conn *ct,
......
...@@ -349,7 +349,7 @@ nf_nat_setup_info(struct nf_conn *ct, ...@@ -349,7 +349,7 @@ nf_nat_setup_info(struct nf_conn *ct,
EXPORT_SYMBOL(nf_nat_setup_info); EXPORT_SYMBOL(nf_nat_setup_info);
/* Returns true if succeeded. */ /* Returns true if succeeded. */
static int static bool
manip_pkt(u_int16_t proto, manip_pkt(u_int16_t proto,
struct sk_buff *skb, struct sk_buff *skb,
unsigned int iphdroff, unsigned int iphdroff,
...@@ -360,7 +360,7 @@ manip_pkt(u_int16_t proto, ...@@ -360,7 +360,7 @@ manip_pkt(u_int16_t proto,
const struct nf_nat_protocol *p; const struct nf_nat_protocol *p;
if (!skb_make_writable(skb, iphdroff + sizeof(*iph))) if (!skb_make_writable(skb, iphdroff + sizeof(*iph)))
return 0; return false;
iph = (void *)skb->data + iphdroff; iph = (void *)skb->data + iphdroff;
...@@ -369,7 +369,7 @@ manip_pkt(u_int16_t proto, ...@@ -369,7 +369,7 @@ manip_pkt(u_int16_t proto,
/* rcu_read_lock()ed by nf_hook_slow */ /* rcu_read_lock()ed by nf_hook_slow */
p = __nf_nat_proto_find(proto); p = __nf_nat_proto_find(proto);
if (!p->manip_pkt(skb, iphdroff, target, maniptype)) if (!p->manip_pkt(skb, iphdroff, target, maniptype))
return 0; return false;
iph = (void *)skb->data + iphdroff; iph = (void *)skb->data + iphdroff;
...@@ -380,7 +380,7 @@ manip_pkt(u_int16_t proto, ...@@ -380,7 +380,7 @@ manip_pkt(u_int16_t proto,
csum_replace4(&iph->check, iph->daddr, target->dst.u3.ip); csum_replace4(&iph->check, iph->daddr, target->dst.u3.ip);
iph->daddr = target->dst.u3.ip; iph->daddr = target->dst.u3.ip;
} }
return 1; return true;
} }
/* Do packet manipulations according to nf_nat_setup_info. */ /* Do packet manipulations according to nf_nat_setup_info. */
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <net/netfilter/nf_nat_rule.h> #include <net/netfilter/nf_nat_rule.h>
#include <net/netfilter/nf_nat_protocol.h> #include <net/netfilter/nf_nat_protocol.h>
int nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple, bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
const union nf_conntrack_man_proto *min, const union nf_conntrack_man_proto *min,
const union nf_conntrack_man_proto *max) const union nf_conntrack_man_proto *max)
...@@ -34,7 +34,7 @@ int nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple, ...@@ -34,7 +34,7 @@ int nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple,
} }
EXPORT_SYMBOL_GPL(nf_nat_proto_in_range); EXPORT_SYMBOL_GPL(nf_nat_proto_in_range);
int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range, const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
const struct nf_conn *ct, const struct nf_conn *ct,
...@@ -53,7 +53,7 @@ int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -53,7 +53,7 @@ int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) { if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) {
/* If it's dst rewrite, can't change port */ /* If it's dst rewrite, can't change port */
if (maniptype == IP_NAT_MANIP_DST) if (maniptype == IP_NAT_MANIP_DST)
return 0; return false;
if (ntohs(*portptr) < 1024) { if (ntohs(*portptr) < 1024) {
/* Loose convention: >> 512 is credential passing */ /* Loose convention: >> 512 is credential passing */
...@@ -83,9 +83,9 @@ int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -83,9 +83,9 @@ int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
continue; continue;
if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM)) if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM))
*rover = off; *rover = off;
return 1; return true;
} }
return 0; return false;
} }
EXPORT_SYMBOL_GPL(nf_nat_proto_unique_tuple); EXPORT_SYMBOL_GPL(nf_nat_proto_unique_tuple);
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
static u_int16_t dccp_port_rover; static u_int16_t dccp_port_rover;
static int static bool
dccp_unique_tuple(struct nf_conntrack_tuple *tuple, dccp_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range, const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
...@@ -32,7 +32,7 @@ dccp_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -32,7 +32,7 @@ dccp_unique_tuple(struct nf_conntrack_tuple *tuple,
&dccp_port_rover); &dccp_port_rover);
} }
static int static bool
dccp_manip_pkt(struct sk_buff *skb, dccp_manip_pkt(struct sk_buff *skb,
unsigned int iphdroff, unsigned int iphdroff,
const struct nf_conntrack_tuple *tuple, const struct nf_conntrack_tuple *tuple,
...@@ -49,7 +49,7 @@ dccp_manip_pkt(struct sk_buff *skb, ...@@ -49,7 +49,7 @@ dccp_manip_pkt(struct sk_buff *skb,
hdrsize = sizeof(struct dccp_hdr); hdrsize = sizeof(struct dccp_hdr);
if (!skb_make_writable(skb, hdroff + hdrsize)) if (!skb_make_writable(skb, hdroff + hdrsize))
return 0; return false;
iph = (struct iphdr *)(skb->data + iphdroff); iph = (struct iphdr *)(skb->data + iphdroff);
hdr = (struct dccp_hdr *)(skb->data + hdroff); hdr = (struct dccp_hdr *)(skb->data + hdroff);
...@@ -70,12 +70,12 @@ dccp_manip_pkt(struct sk_buff *skb, ...@@ -70,12 +70,12 @@ dccp_manip_pkt(struct sk_buff *skb,
*portptr = newport; *portptr = newport;
if (hdrsize < sizeof(*hdr)) if (hdrsize < sizeof(*hdr))
return 1; return true;
inet_proto_csum_replace4(&hdr->dccph_checksum, skb, oldip, newip, 1); inet_proto_csum_replace4(&hdr->dccph_checksum, skb, oldip, newip, 1);
inet_proto_csum_replace2(&hdr->dccph_checksum, skb, oldport, newport, inet_proto_csum_replace2(&hdr->dccph_checksum, skb, oldport, newport,
0); 0);
return 1; return true;
} }
static const struct nf_nat_protocol nf_nat_protocol_dccp = { static const struct nf_nat_protocol nf_nat_protocol_dccp = {
......
...@@ -37,7 +37,7 @@ MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>"); ...@@ -37,7 +37,7 @@ MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
MODULE_DESCRIPTION("Netfilter NAT protocol helper module for GRE"); MODULE_DESCRIPTION("Netfilter NAT protocol helper module for GRE");
/* generate unique tuple ... */ /* generate unique tuple ... */
static int static bool
gre_unique_tuple(struct nf_conntrack_tuple *tuple, gre_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range, const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
...@@ -50,7 +50,7 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -50,7 +50,7 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple,
/* If there is no master conntrack we are not PPTP, /* If there is no master conntrack we are not PPTP,
do not change tuples */ do not change tuples */
if (!ct->master) if (!ct->master)
return 0; return false;
if (maniptype == IP_NAT_MANIP_SRC) if (maniptype == IP_NAT_MANIP_SRC)
keyptr = &tuple->src.u.gre.key; keyptr = &tuple->src.u.gre.key;
...@@ -71,15 +71,15 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -71,15 +71,15 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple,
for (i = 0; i < range_size; i++, key++) { for (i = 0; i < range_size; i++, key++) {
*keyptr = htons(min + key % range_size); *keyptr = htons(min + key % range_size);
if (!nf_nat_used_tuple(tuple, ct)) if (!nf_nat_used_tuple(tuple, ct))
return 1; return true;
} }
pr_debug("%p: no NAT mapping\n", ct); pr_debug("%p: no NAT mapping\n", ct);
return 0; return false;
} }
/* manipulate a GRE packet according to maniptype */ /* manipulate a GRE packet according to maniptype */
static int static bool
gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff, gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff,
const struct nf_conntrack_tuple *tuple, const struct nf_conntrack_tuple *tuple,
enum nf_nat_manip_type maniptype) enum nf_nat_manip_type maniptype)
...@@ -92,7 +92,7 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff, ...@@ -92,7 +92,7 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff,
/* pgreh includes two optional 32bit fields which are not required /* pgreh includes two optional 32bit fields which are not required
* to be there. That's where the magic '8' comes from */ * to be there. That's where the magic '8' comes from */
if (!skb_make_writable(skb, hdroff + sizeof(*pgreh) - 8)) if (!skb_make_writable(skb, hdroff + sizeof(*pgreh) - 8))
return 0; return false;
greh = (void *)skb->data + hdroff; greh = (void *)skb->data + hdroff;
pgreh = (struct gre_hdr_pptp *)greh; pgreh = (struct gre_hdr_pptp *)greh;
...@@ -100,7 +100,7 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff, ...@@ -100,7 +100,7 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff,
/* we only have destination manip of a packet, since 'source key' /* we only have destination manip of a packet, since 'source key'
* is not present in the packet itself */ * is not present in the packet itself */
if (maniptype != IP_NAT_MANIP_DST) if (maniptype != IP_NAT_MANIP_DST)
return 1; return true;
switch (greh->version) { switch (greh->version) {
case GRE_VERSION_1701: case GRE_VERSION_1701:
/* We do not currently NAT any GREv0 packets. /* We do not currently NAT any GREv0 packets.
...@@ -112,9 +112,9 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff, ...@@ -112,9 +112,9 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff,
break; break;
default: default:
pr_debug("can't nat unknown GRE version\n"); pr_debug("can't nat unknown GRE version\n");
return 0; return false;
} }
return 1; return true;
} }
static const struct nf_nat_protocol gre = { static const struct nf_nat_protocol gre = {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <net/netfilter/nf_nat_rule.h> #include <net/netfilter/nf_nat_rule.h>
#include <net/netfilter/nf_nat_protocol.h> #include <net/netfilter/nf_nat_protocol.h>
static int static bool
icmp_in_range(const struct nf_conntrack_tuple *tuple, icmp_in_range(const struct nf_conntrack_tuple *tuple,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
const union nf_conntrack_man_proto *min, const union nf_conntrack_man_proto *min,
...@@ -27,7 +27,7 @@ icmp_in_range(const struct nf_conntrack_tuple *tuple, ...@@ -27,7 +27,7 @@ icmp_in_range(const struct nf_conntrack_tuple *tuple,
ntohs(tuple->src.u.icmp.id) <= ntohs(max->icmp.id); ntohs(tuple->src.u.icmp.id) <= ntohs(max->icmp.id);
} }
static int static bool
icmp_unique_tuple(struct nf_conntrack_tuple *tuple, icmp_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range, const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
...@@ -46,12 +46,12 @@ icmp_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -46,12 +46,12 @@ icmp_unique_tuple(struct nf_conntrack_tuple *tuple,
tuple->src.u.icmp.id = htons(ntohs(range->min.icmp.id) + tuple->src.u.icmp.id = htons(ntohs(range->min.icmp.id) +
(id % range_size)); (id % range_size));
if (!nf_nat_used_tuple(tuple, ct)) if (!nf_nat_used_tuple(tuple, ct))
return 1; return true;
} }
return 0; return false;
} }
static int static bool
icmp_manip_pkt(struct sk_buff *skb, icmp_manip_pkt(struct sk_buff *skb,
unsigned int iphdroff, unsigned int iphdroff,
const struct nf_conntrack_tuple *tuple, const struct nf_conntrack_tuple *tuple,
...@@ -62,13 +62,13 @@ icmp_manip_pkt(struct sk_buff *skb, ...@@ -62,13 +62,13 @@ icmp_manip_pkt(struct sk_buff *skb,
unsigned int hdroff = iphdroff + iph->ihl*4; unsigned int hdroff = iphdroff + iph->ihl*4;
if (!skb_make_writable(skb, hdroff + sizeof(*hdr))) if (!skb_make_writable(skb, hdroff + sizeof(*hdr)))
return 0; return false;
hdr = (struct icmphdr *)(skb->data + hdroff); hdr = (struct icmphdr *)(skb->data + hdroff);
inet_proto_csum_replace2(&hdr->checksum, skb, inet_proto_csum_replace2(&hdr->checksum, skb,
hdr->un.echo.id, tuple->src.u.icmp.id, 0); hdr->un.echo.id, tuple->src.u.icmp.id, 0);
hdr->un.echo.id = tuple->src.u.icmp.id; hdr->un.echo.id = tuple->src.u.icmp.id;
return 1; return true;
} }
const struct nf_nat_protocol nf_nat_protocol_icmp = { const struct nf_nat_protocol nf_nat_protocol_icmp = {
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
static u_int16_t nf_sctp_port_rover; static u_int16_t nf_sctp_port_rover;
static int static bool
sctp_unique_tuple(struct nf_conntrack_tuple *tuple, sctp_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range, const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
...@@ -26,7 +26,7 @@ sctp_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -26,7 +26,7 @@ sctp_unique_tuple(struct nf_conntrack_tuple *tuple,
&nf_sctp_port_rover); &nf_sctp_port_rover);
} }
static int static bool
sctp_manip_pkt(struct sk_buff *skb, sctp_manip_pkt(struct sk_buff *skb,
unsigned int iphdroff, unsigned int iphdroff,
const struct nf_conntrack_tuple *tuple, const struct nf_conntrack_tuple *tuple,
...@@ -39,7 +39,7 @@ sctp_manip_pkt(struct sk_buff *skb, ...@@ -39,7 +39,7 @@ sctp_manip_pkt(struct sk_buff *skb,
u32 crc32; u32 crc32;
if (!skb_make_writable(skb, hdroff + sizeof(*hdr))) if (!skb_make_writable(skb, hdroff + sizeof(*hdr)))
return 0; return false;
iph = (struct iphdr *)(skb->data + iphdroff); iph = (struct iphdr *)(skb->data + iphdroff);
hdr = (struct sctphdr *)(skb->data + hdroff); hdr = (struct sctphdr *)(skb->data + hdroff);
...@@ -63,7 +63,7 @@ sctp_manip_pkt(struct sk_buff *skb, ...@@ -63,7 +63,7 @@ sctp_manip_pkt(struct sk_buff *skb,
crc32 = sctp_end_cksum(crc32); crc32 = sctp_end_cksum(crc32);
hdr->checksum = htonl(crc32); hdr->checksum = htonl(crc32);
return 1; return true;
} }
static const struct nf_nat_protocol nf_nat_protocol_sctp = { static const struct nf_nat_protocol nf_nat_protocol_sctp = {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
static u_int16_t tcp_port_rover; static u_int16_t tcp_port_rover;
static int static bool
tcp_unique_tuple(struct nf_conntrack_tuple *tuple, tcp_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range, const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
...@@ -30,7 +30,7 @@ tcp_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -30,7 +30,7 @@ tcp_unique_tuple(struct nf_conntrack_tuple *tuple,
&tcp_port_rover); &tcp_port_rover);
} }
static int static bool
tcp_manip_pkt(struct sk_buff *skb, tcp_manip_pkt(struct sk_buff *skb,
unsigned int iphdroff, unsigned int iphdroff,
const struct nf_conntrack_tuple *tuple, const struct nf_conntrack_tuple *tuple,
...@@ -50,7 +50,7 @@ tcp_manip_pkt(struct sk_buff *skb, ...@@ -50,7 +50,7 @@ tcp_manip_pkt(struct sk_buff *skb,
hdrsize = sizeof(struct tcphdr); hdrsize = sizeof(struct tcphdr);
if (!skb_make_writable(skb, hdroff + hdrsize)) if (!skb_make_writable(skb, hdroff + hdrsize))
return 0; return false;
iph = (struct iphdr *)(skb->data + iphdroff); iph = (struct iphdr *)(skb->data + iphdroff);
hdr = (struct tcphdr *)(skb->data + hdroff); hdr = (struct tcphdr *)(skb->data + hdroff);
...@@ -73,11 +73,11 @@ tcp_manip_pkt(struct sk_buff *skb, ...@@ -73,11 +73,11 @@ tcp_manip_pkt(struct sk_buff *skb,
*portptr = newport; *portptr = newport;
if (hdrsize < sizeof(*hdr)) if (hdrsize < sizeof(*hdr))
return 1; return true;
inet_proto_csum_replace4(&hdr->check, skb, oldip, newip, 1); inet_proto_csum_replace4(&hdr->check, skb, oldip, newip, 1);
inet_proto_csum_replace2(&hdr->check, skb, oldport, newport, 0); inet_proto_csum_replace2(&hdr->check, skb, oldport, newport, 0);
return 1; return true;
} }
const struct nf_nat_protocol nf_nat_protocol_tcp = { const struct nf_nat_protocol nf_nat_protocol_tcp = {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
static u_int16_t udp_port_rover; static u_int16_t udp_port_rover;
static int static bool
udp_unique_tuple(struct nf_conntrack_tuple *tuple, udp_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range, const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
...@@ -29,7 +29,7 @@ udp_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -29,7 +29,7 @@ udp_unique_tuple(struct nf_conntrack_tuple *tuple,
&udp_port_rover); &udp_port_rover);
} }
static int static bool
udp_manip_pkt(struct sk_buff *skb, udp_manip_pkt(struct sk_buff *skb,
unsigned int iphdroff, unsigned int iphdroff,
const struct nf_conntrack_tuple *tuple, const struct nf_conntrack_tuple *tuple,
...@@ -42,7 +42,7 @@ udp_manip_pkt(struct sk_buff *skb, ...@@ -42,7 +42,7 @@ udp_manip_pkt(struct sk_buff *skb,
__be16 *portptr, newport; __be16 *portptr, newport;
if (!skb_make_writable(skb, hdroff + sizeof(*hdr))) if (!skb_make_writable(skb, hdroff + sizeof(*hdr)))
return 0; return false;
iph = (struct iphdr *)(skb->data + iphdroff); iph = (struct iphdr *)(skb->data + iphdroff);
hdr = (struct udphdr *)(skb->data + hdroff); hdr = (struct udphdr *)(skb->data + hdroff);
...@@ -68,7 +68,7 @@ udp_manip_pkt(struct sk_buff *skb, ...@@ -68,7 +68,7 @@ udp_manip_pkt(struct sk_buff *skb,
hdr->check = CSUM_MANGLED_0; hdr->check = CSUM_MANGLED_0;
} }
*portptr = newport; *portptr = newport;
return 1; return true;
} }
const struct nf_nat_protocol nf_nat_protocol_udp = { const struct nf_nat_protocol nf_nat_protocol_udp = {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
static u_int16_t udplite_port_rover; static u_int16_t udplite_port_rover;
static int static bool
udplite_unique_tuple(struct nf_conntrack_tuple *tuple, udplite_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range, const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
...@@ -28,7 +28,7 @@ udplite_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -28,7 +28,7 @@ udplite_unique_tuple(struct nf_conntrack_tuple *tuple,
&udplite_port_rover); &udplite_port_rover);
} }
static int static bool
udplite_manip_pkt(struct sk_buff *skb, udplite_manip_pkt(struct sk_buff *skb,
unsigned int iphdroff, unsigned int iphdroff,
const struct nf_conntrack_tuple *tuple, const struct nf_conntrack_tuple *tuple,
...@@ -41,7 +41,7 @@ udplite_manip_pkt(struct sk_buff *skb, ...@@ -41,7 +41,7 @@ udplite_manip_pkt(struct sk_buff *skb,
__be16 *portptr, newport; __be16 *portptr, newport;
if (!skb_make_writable(skb, hdroff + sizeof(*hdr))) if (!skb_make_writable(skb, hdroff + sizeof(*hdr)))
return 0; return false;
iph = (struct iphdr *)(skb->data + iphdroff); iph = (struct iphdr *)(skb->data + iphdroff);
hdr = (struct udphdr *)(skb->data + hdroff); hdr = (struct udphdr *)(skb->data + hdroff);
...@@ -66,7 +66,7 @@ udplite_manip_pkt(struct sk_buff *skb, ...@@ -66,7 +66,7 @@ udplite_manip_pkt(struct sk_buff *skb,
hdr->check = CSUM_MANGLED_0; hdr->check = CSUM_MANGLED_0;
*portptr = newport; *portptr = newport;
return 1; return true;
} }
static const struct nf_nat_protocol nf_nat_protocol_udplite = { static const struct nf_nat_protocol nf_nat_protocol_udplite = {
......
...@@ -18,31 +18,31 @@ ...@@ -18,31 +18,31 @@
#include <net/netfilter/nf_nat_rule.h> #include <net/netfilter/nf_nat_rule.h>
#include <net/netfilter/nf_nat_protocol.h> #include <net/netfilter/nf_nat_protocol.h>
static int unknown_in_range(const struct nf_conntrack_tuple *tuple, static bool unknown_in_range(const struct nf_conntrack_tuple *tuple,
enum nf_nat_manip_type manip_type, enum nf_nat_manip_type manip_type,
const union nf_conntrack_man_proto *min, const union nf_conntrack_man_proto *min,
const union nf_conntrack_man_proto *max) const union nf_conntrack_man_proto *max)
{ {
return 1; return true;
} }
static int unknown_unique_tuple(struct nf_conntrack_tuple *tuple, static bool unknown_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range, const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype, enum nf_nat_manip_type maniptype,
const struct nf_conn *ct) const struct nf_conn *ct)
{ {
/* Sorry: we can't help you; if it's not unique, we can't frob /* Sorry: we can't help you; if it's not unique, we can't frob
anything. */ anything. */
return 0; return false;
} }
static int static bool
unknown_manip_pkt(struct sk_buff *skb, unknown_manip_pkt(struct sk_buff *skb,
unsigned int iphdroff, unsigned int iphdroff,
const struct nf_conntrack_tuple *tuple, const struct nf_conntrack_tuple *tuple,
enum nf_nat_manip_type maniptype) enum nf_nat_manip_type maniptype)
{ {
return 1; return true;
} }
const struct nf_nat_protocol nf_nat_unknown_protocol = { const struct nf_nat_protocol nf_nat_unknown_protocol = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment