Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nf_nat: make unique_tuple return void

The only user of unique_tuple() get_unique_tuple() doesn't care about the
return value of unique_tuple(), so make unique_tuple() return void (nothing).

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>

authored by

Changli Gao and committed by
Patrick McHardy
f43dc98b 794dbc1d

+30 -32
+4 -4
include/net/netfilter/nf_nat_protocol.h
··· 27 27 28 28 /* Alter the per-proto part of the tuple (depending on 29 29 maniptype), to give a unique tuple in the given range if 30 - possible; return false if not. Per-protocol part of tuple 31 - is initialized to the incoming packet. */ 32 - bool (*unique_tuple)(struct nf_conntrack_tuple *tuple, 30 + possible. Per-protocol part of tuple is initialized to the 31 + incoming packet. */ 32 + void (*unique_tuple)(struct nf_conntrack_tuple *tuple, 33 33 const struct nf_nat_range *range, 34 34 enum nf_nat_manip_type maniptype, 35 35 const struct nf_conn *ct); ··· 63 63 const union nf_conntrack_man_proto *min, 64 64 const union nf_conntrack_man_proto *max); 65 65 66 - extern bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, 66 + extern void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, 67 67 const struct nf_nat_range *range, 68 68 enum nf_nat_manip_type maniptype, 69 69 const struct nf_conn *ct,
+4 -4
net/ipv4/netfilter/nf_nat_proto_common.c
··· 34 34 } 35 35 EXPORT_SYMBOL_GPL(nf_nat_proto_in_range); 36 36 37 - bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, 37 + void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, 38 38 const struct nf_nat_range *range, 39 39 enum nf_nat_manip_type maniptype, 40 40 const struct nf_conn *ct, ··· 53 53 if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) { 54 54 /* If it's dst rewrite, can't change port */ 55 55 if (maniptype == IP_NAT_MANIP_DST) 56 - return false; 56 + return; 57 57 58 58 if (ntohs(*portptr) < 1024) { 59 59 /* Loose convention: >> 512 is credential passing */ ··· 87 87 continue; 88 88 if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM)) 89 89 *rover = off; 90 - return true; 90 + return; 91 91 } 92 - return false; 92 + return; 93 93 } 94 94 EXPORT_SYMBOL_GPL(nf_nat_proto_unique_tuple); 95 95
+3 -3
net/ipv4/netfilter/nf_nat_proto_dccp.c
··· 22 22 23 23 static u_int16_t dccp_port_rover; 24 24 25 - static bool 25 + static void 26 26 dccp_unique_tuple(struct nf_conntrack_tuple *tuple, 27 27 const struct nf_nat_range *range, 28 28 enum nf_nat_manip_type maniptype, 29 29 const struct nf_conn *ct) 30 30 { 31 - return nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, 32 - &dccp_port_rover); 31 + nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, 32 + &dccp_port_rover); 33 33 } 34 34 35 35 static bool
+4 -4
net/ipv4/netfilter/nf_nat_proto_gre.c
··· 37 37 MODULE_DESCRIPTION("Netfilter NAT protocol helper module for GRE"); 38 38 39 39 /* generate unique tuple ... */ 40 - static bool 40 + static void 41 41 gre_unique_tuple(struct nf_conntrack_tuple *tuple, 42 42 const struct nf_nat_range *range, 43 43 enum nf_nat_manip_type maniptype, ··· 50 50 /* If there is no master conntrack we are not PPTP, 51 51 do not change tuples */ 52 52 if (!ct->master) 53 - return false; 53 + return; 54 54 55 55 if (maniptype == IP_NAT_MANIP_SRC) 56 56 keyptr = &tuple->src.u.gre.key; ··· 71 71 for (i = 0; i < range_size; i++, key++) { 72 72 *keyptr = htons(min + key % range_size); 73 73 if (!nf_nat_used_tuple(tuple, ct)) 74 - return true; 74 + return; 75 75 } 76 76 77 77 pr_debug("%p: no NAT mapping\n", ct); 78 - return false; 78 + return; 79 79 } 80 80 81 81 /* manipulate a GRE packet according to maniptype */
+3 -3
net/ipv4/netfilter/nf_nat_proto_icmp.c
··· 27 27 ntohs(tuple->src.u.icmp.id) <= ntohs(max->icmp.id); 28 28 } 29 29 30 - static bool 30 + static void 31 31 icmp_unique_tuple(struct nf_conntrack_tuple *tuple, 32 32 const struct nf_nat_range *range, 33 33 enum nf_nat_manip_type maniptype, ··· 46 46 tuple->src.u.icmp.id = htons(ntohs(range->min.icmp.id) + 47 47 (id % range_size)); 48 48 if (!nf_nat_used_tuple(tuple, ct)) 49 - return true; 49 + return; 50 50 } 51 - return false; 51 + return; 52 52 } 53 53 54 54 static bool
+3 -3
net/ipv4/netfilter/nf_nat_proto_sctp.c
··· 16 16 17 17 static u_int16_t nf_sctp_port_rover; 18 18 19 - static bool 19 + static void 20 20 sctp_unique_tuple(struct nf_conntrack_tuple *tuple, 21 21 const struct nf_nat_range *range, 22 22 enum nf_nat_manip_type maniptype, 23 23 const struct nf_conn *ct) 24 24 { 25 - return nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, 26 - &nf_sctp_port_rover); 25 + nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, 26 + &nf_sctp_port_rover); 27 27 } 28 28 29 29 static bool
+2 -3
net/ipv4/netfilter/nf_nat_proto_tcp.c
··· 20 20 21 21 static u_int16_t tcp_port_rover; 22 22 23 - static bool 23 + static void 24 24 tcp_unique_tuple(struct nf_conntrack_tuple *tuple, 25 25 const struct nf_nat_range *range, 26 26 enum nf_nat_manip_type maniptype, 27 27 const struct nf_conn *ct) 28 28 { 29 - return nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, 30 - &tcp_port_rover); 29 + nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, &tcp_port_rover); 31 30 } 32 31 33 32 static bool
+2 -3
net/ipv4/netfilter/nf_nat_proto_udp.c
··· 19 19 20 20 static u_int16_t udp_port_rover; 21 21 22 - static bool 22 + static void 23 23 udp_unique_tuple(struct nf_conntrack_tuple *tuple, 24 24 const struct nf_nat_range *range, 25 25 enum nf_nat_manip_type maniptype, 26 26 const struct nf_conn *ct) 27 27 { 28 - return nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, 29 - &udp_port_rover); 28 + nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, &udp_port_rover); 30 29 } 31 30 32 31 static bool
+3 -3
net/ipv4/netfilter/nf_nat_proto_udplite.c
··· 18 18 19 19 static u_int16_t udplite_port_rover; 20 20 21 - static bool 21 + static void 22 22 udplite_unique_tuple(struct nf_conntrack_tuple *tuple, 23 23 const struct nf_nat_range *range, 24 24 enum nf_nat_manip_type maniptype, 25 25 const struct nf_conn *ct) 26 26 { 27 - return nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, 28 - &udplite_port_rover); 27 + nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, 28 + &udplite_port_rover); 29 29 } 30 30 31 31 static bool
+2 -2
net/ipv4/netfilter/nf_nat_proto_unknown.c
··· 26 26 return true; 27 27 } 28 28 29 - static bool unknown_unique_tuple(struct nf_conntrack_tuple *tuple, 29 + static void unknown_unique_tuple(struct nf_conntrack_tuple *tuple, 30 30 const struct nf_nat_range *range, 31 31 enum nf_nat_manip_type maniptype, 32 32 const struct nf_conn *ct) 33 33 { 34 34 /* Sorry: we can't help you; if it's not unique, we can't frob 35 35 anything. */ 36 - return false; 36 + return; 37 37 } 38 38 39 39 static bool