提交 f43dc98b 编写于 作者: C Changli Gao 提交者: Patrick McHardy

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: NChangli Gao <xiaosuo@gmail.com>
Signed-off-by: NPatrick McHardy <kaber@trash.net>
上级 794dbc1d
...@@ -27,9 +27,9 @@ struct nf_nat_protocol { ...@@ -27,9 +27,9 @@ struct nf_nat_protocol {
/* Alter the per-proto part of the tuple (depending on /* Alter the per-proto part of the tuple (depending on
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. Per-protocol part of tuple is initialized to the
is initialized to the incoming packet. */ incoming packet. */
bool (*unique_tuple)(struct nf_conntrack_tuple *tuple, void (*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);
...@@ -63,7 +63,7 @@ extern bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple, ...@@ -63,7 +63,7 @@ extern bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple,
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 bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, extern void 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,
......
...@@ -34,7 +34,7 @@ bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple, ...@@ -34,7 +34,7 @@ bool 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);
bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, void 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 @@ bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -53,7 +53,7 @@ bool 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 false; return;
if (ntohs(*portptr) < 1024) { if (ntohs(*portptr) < 1024) {
/* Loose convention: >> 512 is credential passing */ /* Loose convention: >> 512 is credential passing */
...@@ -87,9 +87,9 @@ bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -87,9 +87,9 @@ bool 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 true; return;
} }
return false; return;
} }
EXPORT_SYMBOL_GPL(nf_nat_proto_unique_tuple); EXPORT_SYMBOL_GPL(nf_nat_proto_unique_tuple);
......
...@@ -22,14 +22,14 @@ ...@@ -22,14 +22,14 @@
static u_int16_t dccp_port_rover; static u_int16_t dccp_port_rover;
static bool static void
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,
const struct nf_conn *ct) const struct nf_conn *ct)
{ {
return nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, nf_nat_proto_unique_tuple(tuple, range, maniptype, ct,
&dccp_port_rover); &dccp_port_rover);
} }
static bool static bool
......
...@@ -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 bool static void
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 false; return;
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,11 +71,11 @@ gre_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -71,11 +71,11 @@ 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 true; return;
} }
pr_debug("%p: no NAT mapping\n", ct); pr_debug("%p: no NAT mapping\n", ct);
return false; return;
} }
/* manipulate a GRE packet according to maniptype */ /* manipulate a GRE packet according to maniptype */
......
...@@ -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 bool static void
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,9 +46,9 @@ icmp_unique_tuple(struct nf_conntrack_tuple *tuple, ...@@ -46,9 +46,9 @@ 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 true; return;
} }
return false; return;
} }
static bool static bool
......
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
static u_int16_t nf_sctp_port_rover; static u_int16_t nf_sctp_port_rover;
static bool static void
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,
const struct nf_conn *ct) const struct nf_conn *ct)
{ {
return nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, nf_nat_proto_unique_tuple(tuple, range, maniptype, ct,
&nf_sctp_port_rover); &nf_sctp_port_rover);
} }
static bool static bool
......
...@@ -20,14 +20,13 @@ ...@@ -20,14 +20,13 @@
static u_int16_t tcp_port_rover; static u_int16_t tcp_port_rover;
static bool static void
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,
const struct nf_conn *ct) const struct nf_conn *ct)
{ {
return nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, &tcp_port_rover);
&tcp_port_rover);
} }
static bool static bool
......
...@@ -19,14 +19,13 @@ ...@@ -19,14 +19,13 @@
static u_int16_t udp_port_rover; static u_int16_t udp_port_rover;
static bool static void
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,
const struct nf_conn *ct) const struct nf_conn *ct)
{ {
return nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, &udp_port_rover);
&udp_port_rover);
} }
static bool static bool
......
...@@ -18,14 +18,14 @@ ...@@ -18,14 +18,14 @@
static u_int16_t udplite_port_rover; static u_int16_t udplite_port_rover;
static bool static void
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,
const struct nf_conn *ct) const struct nf_conn *ct)
{ {
return nf_nat_proto_unique_tuple(tuple, range, maniptype, ct, nf_nat_proto_unique_tuple(tuple, range, maniptype, ct,
&udplite_port_rover); &udplite_port_rover);
} }
static bool static bool
......
...@@ -26,14 +26,14 @@ static bool unknown_in_range(const struct nf_conntrack_tuple *tuple, ...@@ -26,14 +26,14 @@ static bool unknown_in_range(const struct nf_conntrack_tuple *tuple,
return true; return true;
} }
static bool unknown_unique_tuple(struct nf_conntrack_tuple *tuple, static void 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 false; return;
} }
static bool static bool
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册