Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

[NETFILTER]: nf_nat: use bool type in nf_nat_proto

parent 5f2b4c90
Loading
Loading
Loading
Loading
+21 −21
Original line number Diff line number Diff line
@@ -15,13 +15,13 @@ struct nf_nat_protocol

	/* Translate a packet to the target according to manip type.
	   Return true if succeeded. */
	int (*manip_pkt)(struct sk_buff *skb,
	bool (*manip_pkt)(struct sk_buff *skb,
			  unsigned int iphdroff,
			  const struct nf_conntrack_tuple *tuple,
			  enum nf_nat_manip_type maniptype);

	/* 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,
			 const union nf_conntrack_man_proto *min,
			 const union nf_conntrack_man_proto *max);
@@ -30,7 +30,7 @@ struct nf_nat_protocol
	   maniptype), to give a unique tuple in the given range if
	   possible; return false if not.  Per-protocol part of tuple
	   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,
			     enum nf_nat_manip_type maniptype,
			     const struct nf_conn *ct);
@@ -59,12 +59,12 @@ extern int init_protocols(void) __init;
extern void cleanup_protocols(void);
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,
				  const union nf_conntrack_man_proto *min,
				  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,
				      enum nf_nat_manip_type maniptype,
				      const struct nf_conn *ct,
+4 −4
Original line number Diff line number Diff line
@@ -349,7 +349,7 @@ nf_nat_setup_info(struct nf_conn *ct,
EXPORT_SYMBOL(nf_nat_setup_info);

/* Returns true if succeeded. */
static int
static bool
manip_pkt(u_int16_t proto,
	  struct sk_buff *skb,
	  unsigned int iphdroff,
@@ -360,7 +360,7 @@ manip_pkt(u_int16_t proto,
	const struct nf_nat_protocol *p;

	if (!skb_make_writable(skb, iphdroff + sizeof(*iph)))
		return 0;
		return false;

	iph = (void *)skb->data + iphdroff;

@@ -369,7 +369,7 @@ manip_pkt(u_int16_t proto,
	/* rcu_read_lock()ed by nf_hook_slow */
	p = __nf_nat_proto_find(proto);
	if (!p->manip_pkt(skb, iphdroff, target, maniptype))
		return 0;
		return false;

	iph = (void *)skb->data + iphdroff;

@@ -380,7 +380,7 @@ manip_pkt(u_int16_t proto,
		csum_replace4(&iph->check, 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. */
+12 −12
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
#include <net/netfilter/nf_nat_rule.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,
			   const union nf_conntrack_man_proto *min,
			   const union nf_conntrack_man_proto *max)
@@ -34,7 +34,7 @@ int nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple,
}
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,
			       enum nf_nat_manip_type maniptype,
			       const struct nf_conn *ct,
@@ -53,7 +53,7 @@ int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
	if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) {
		/* If it's dst rewrite, can't change port */
		if (maniptype == IP_NAT_MANIP_DST)
			return 0;
			return false;

		if (ntohs(*portptr) < 1024) {
			/* Loose convention: >> 512 is credential passing */
@@ -83,9 +83,9 @@ int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
			continue;
		if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM))
			*rover = off;
		return 1;
		return true;
	}
	return 0;
	return false;
}
EXPORT_SYMBOL_GPL(nf_nat_proto_unique_tuple);

+5 −5
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@

static u_int16_t dccp_port_rover;

static int
static bool
dccp_unique_tuple(struct nf_conntrack_tuple *tuple,
		  const struct nf_nat_range *range,
		  enum nf_nat_manip_type maniptype,
@@ -32,7 +32,7 @@ dccp_unique_tuple(struct nf_conntrack_tuple *tuple,
					 &dccp_port_rover);
}

static int
static bool
dccp_manip_pkt(struct sk_buff *skb,
	       unsigned int iphdroff,
	       const struct nf_conntrack_tuple *tuple,
@@ -49,7 +49,7 @@ dccp_manip_pkt(struct sk_buff *skb,
		hdrsize = sizeof(struct dccp_hdr);

	if (!skb_make_writable(skb, hdroff + hdrsize))
		return 0;
		return false;

	iph = (struct iphdr *)(skb->data + iphdroff);
	hdr = (struct dccp_hdr *)(skb->data + hdroff);
@@ -70,12 +70,12 @@ dccp_manip_pkt(struct sk_buff *skb,
	*portptr = newport;

	if (hdrsize < sizeof(*hdr))
		return 1;
		return true;

	inet_proto_csum_replace4(&hdr->dccph_checksum, skb, oldip, newip, 1);
	inet_proto_csum_replace2(&hdr->dccph_checksum, skb, oldport, newport,
				 0);
	return 1;
	return true;
}

static const struct nf_nat_protocol nf_nat_protocol_dccp = {
+9 −9
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
MODULE_DESCRIPTION("Netfilter NAT protocol helper module for GRE");

/* generate unique tuple ... */
static int
static bool
gre_unique_tuple(struct nf_conntrack_tuple *tuple,
		 const struct nf_nat_range *range,
		 enum nf_nat_manip_type maniptype,
@@ -50,7 +50,7 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple,
	/* If there is no master conntrack we are not PPTP,
	   do not change tuples */
	if (!ct->master)
		return 0;
		return false;

	if (maniptype == IP_NAT_MANIP_SRC)
		keyptr = &tuple->src.u.gre.key;
@@ -71,15 +71,15 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple,
	for (i = 0; i < range_size; i++, key++) {
		*keyptr = htons(min + key % range_size);
		if (!nf_nat_used_tuple(tuple, ct))
			return 1;
			return true;
	}

	pr_debug("%p: no NAT mapping\n", ct);
	return 0;
	return false;
}

/* manipulate a GRE packet according to maniptype */
static int
static bool
gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff,
	      const struct nf_conntrack_tuple *tuple,
	      enum nf_nat_manip_type maniptype)
@@ -92,7 +92,7 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff,
	/* pgreh includes two optional 32bit fields which are not required
	 * to be there.  That's where the magic '8' comes from */
	if (!skb_make_writable(skb, hdroff + sizeof(*pgreh) - 8))
		return 0;
		return false;

	greh = (void *)skb->data + hdroff;
	pgreh = (struct gre_hdr_pptp *)greh;
@@ -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'
	 * is not present in the packet itself */
	if (maniptype != IP_NAT_MANIP_DST)
		return 1;
		return true;
	switch (greh->version) {
	case GRE_VERSION_1701:
		/* We do not currently NAT any GREv0 packets.
@@ -112,9 +112,9 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff,
		break;
	default:
		pr_debug("can't nat unknown GRE version\n");
		return 0;
		return false;
	}
	return 1;
	return true;
}

static const struct nf_nat_protocol gre = {
Loading