Commit d9c7f710 authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] Remove NAT to multiple ranges

The NAT code has the concept of multiple ranges: you can say "map this
connection onto IP 192.168.1.2 - 192.168.1.4, 192.168.1.7 ports
1024-65535, and 192.168.1.10".  I implemented this because we could.

But it's not actually *used* by many (any?) people, and you can
approximate this by a random match (from patch-o-matic) if you really
want to.  It adds complexity to the code.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a18d7224
...@@ -41,10 +41,10 @@ struct ip_nat_range ...@@ -41,10 +41,10 @@ struct ip_nat_range
union ip_conntrack_manip_proto min, max; union ip_conntrack_manip_proto min, max;
}; };
/* A range consists of an array of 1 or more ip_nat_range */ /* For backwards compat: don't use in modern code. */
struct ip_nat_multi_range struct ip_nat_multi_range_compat
{ {
unsigned int rangesize; unsigned int rangesize; /* Must be 1. */
/* hangs off end. */ /* hangs off end. */
struct ip_nat_range range[1]; struct ip_nat_range range[1];
...@@ -96,7 +96,7 @@ struct ip_nat_info ...@@ -96,7 +96,7 @@ struct ip_nat_info
/* Set up the info structure to map into this range. */ /* Set up the info structure to map into this range. */
extern unsigned int ip_nat_setup_info(struct ip_conntrack *conntrack, extern unsigned int ip_nat_setup_info(struct ip_conntrack *conntrack,
const struct ip_nat_multi_range *mr, const struct ip_nat_range *range,
unsigned int hooknum); unsigned int hooknum);
/* Is this tuple already taken? (not by us)*/ /* Is this tuple already taken? (not by us)*/
...@@ -107,5 +107,7 @@ extern int ip_nat_used_tuple(const struct ip_conntrack_tuple *tuple, ...@@ -107,5 +107,7 @@ extern int ip_nat_used_tuple(const struct ip_conntrack_tuple *tuple,
extern u_int16_t ip_nat_cheat_check(u_int32_t oldvalinv, extern u_int16_t ip_nat_cheat_check(u_int32_t oldvalinv,
u_int32_t newval, u_int32_t newval,
u_int16_t oldcheck); u_int16_t oldcheck);
#else /* !__KERNEL__: iptables wants this to compile. */
#define ip_nat_multi_range ip_nat_multi_range_compat
#endif /*__KERNEL__*/ #endif /*__KERNEL__*/
#endif #endif
...@@ -39,7 +39,7 @@ amanda_nat_expected(struct sk_buff **pskb, ...@@ -39,7 +39,7 @@ amanda_nat_expected(struct sk_buff **pskb,
{ {
struct ip_conntrack *master = master_ct(ct); struct ip_conntrack *master = master_ct(ct);
struct ip_ct_amanda_expect *exp_amanda_info; struct ip_ct_amanda_expect *exp_amanda_info;
struct ip_nat_multi_range mr; struct ip_nat_range range;
u_int32_t newip; u_int32_t newip;
IP_NF_ASSERT(info); IP_NF_ASSERT(info);
...@@ -51,20 +51,19 @@ amanda_nat_expected(struct sk_buff **pskb, ...@@ -51,20 +51,19 @@ amanda_nat_expected(struct sk_buff **pskb,
else else
newip = master->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip; newip = master->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip;
mr.rangesize = 1;
/* We don't want to manip the per-protocol, just the IPs. */ /* We don't want to manip the per-protocol, just the IPs. */
mr.range[0].flags = IP_NAT_RANGE_MAP_IPS; range.flags = IP_NAT_RANGE_MAP_IPS;
mr.range[0].min_ip = mr.range[0].max_ip = newip; range.min_ip = range.max_ip = newip;
if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_DST) { if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_DST) {
exp_amanda_info = &ct->master->help.exp_amanda_info; exp_amanda_info = &ct->master->help.exp_amanda_info;
mr.range[0].flags |= IP_NAT_RANGE_PROTO_SPECIFIED; range.flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
mr.range[0].min = mr.range[0].max range.min = range.max
= ((union ip_conntrack_manip_proto) = ((union ip_conntrack_manip_proto)
{ .udp = { htons(exp_amanda_info->port) } }); { .udp = { htons(exp_amanda_info->port) } });
} }
return ip_nat_setup_info(ct, &mr, hooknum); return ip_nat_setup_info(ct, &range, hooknum);
} }
static int amanda_data_fixup(struct ip_conntrack *ct, static int amanda_data_fixup(struct ip_conntrack *ct,
......
This diff is collapsed.
...@@ -44,7 +44,7 @@ ftp_nat_expected(struct sk_buff **pskb, ...@@ -44,7 +44,7 @@ ftp_nat_expected(struct sk_buff **pskb,
struct ip_conntrack *ct, struct ip_conntrack *ct,
struct ip_nat_info *info) struct ip_nat_info *info)
{ {
struct ip_nat_multi_range mr; struct ip_nat_range range;
u_int32_t newdstip, newsrcip, newip; u_int32_t newdstip, newsrcip, newip;
struct ip_ct_ftp_expect *exp_ftp_info; struct ip_ct_ftp_expect *exp_ftp_info;
...@@ -80,20 +80,19 @@ ftp_nat_expected(struct sk_buff **pskb, ...@@ -80,20 +80,19 @@ ftp_nat_expected(struct sk_buff **pskb,
DEBUGP("nat_expected: IP to %u.%u.%u.%u\n", NIPQUAD(newip)); DEBUGP("nat_expected: IP to %u.%u.%u.%u\n", NIPQUAD(newip));
mr.rangesize = 1;
/* We don't want to manip the per-protocol, just the IPs... */ /* We don't want to manip the per-protocol, just the IPs... */
mr.range[0].flags = IP_NAT_RANGE_MAP_IPS; range.flags = IP_NAT_RANGE_MAP_IPS;
mr.range[0].min_ip = mr.range[0].max_ip = newip; range.min_ip = range.max_ip = newip;
/* ... unless we're doing a MANIP_DST, in which case, make /* ... unless we're doing a MANIP_DST, in which case, make
sure we map to the correct port */ sure we map to the correct port */
if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_DST) { if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_DST) {
mr.range[0].flags |= IP_NAT_RANGE_PROTO_SPECIFIED; range.flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
mr.range[0].min = mr.range[0].max range.min = range.max
= ((union ip_conntrack_manip_proto) = ((union ip_conntrack_manip_proto)
{ .tcp = { htons(exp_ftp_info->port) } }); { .tcp = { htons(exp_ftp_info->port) } });
} }
return ip_nat_setup_info(ct, &mr, hooknum); return ip_nat_setup_info(ct, &range, hooknum);
} }
static int static int
......
...@@ -53,7 +53,7 @@ irc_nat_expected(struct sk_buff **pskb, ...@@ -53,7 +53,7 @@ irc_nat_expected(struct sk_buff **pskb,
struct ip_conntrack *ct, struct ip_conntrack *ct,
struct ip_nat_info *info) struct ip_nat_info *info)
{ {
struct ip_nat_multi_range mr; struct ip_nat_range range;
u_int32_t newdstip, newsrcip, newip; u_int32_t newdstip, newsrcip, newip;
struct ip_conntrack *master = master_ct(ct); struct ip_conntrack *master = master_ct(ct);
...@@ -77,12 +77,11 @@ irc_nat_expected(struct sk_buff **pskb, ...@@ -77,12 +77,11 @@ irc_nat_expected(struct sk_buff **pskb,
DEBUGP("nat_expected: IP to %u.%u.%u.%u\n", NIPQUAD(newip)); DEBUGP("nat_expected: IP to %u.%u.%u.%u\n", NIPQUAD(newip));
mr.rangesize = 1;
/* We don't want to manip the per-protocol, just the IPs. */ /* We don't want to manip the per-protocol, just the IPs. */
mr.range[0].flags = IP_NAT_RANGE_MAP_IPS; range.flags = IP_NAT_RANGE_MAP_IPS;
mr.range[0].min_ip = mr.range[0].max_ip = newip; range.min_ip = range.max_ip = newip;
return ip_nat_setup_info(ct, &mr, hooknum); return ip_nat_setup_info(ct, &range, hooknum);
} }
static int irc_data_fixup(const struct ip_ct_irc_expect *exp_irc_info, static int irc_data_fixup(const struct ip_ct_irc_expect *exp_irc_info,
......
...@@ -126,6 +126,7 @@ static unsigned int ipt_snat_target(struct sk_buff **pskb, ...@@ -126,6 +126,7 @@ static unsigned int ipt_snat_target(struct sk_buff **pskb,
{ {
struct ip_conntrack *ct; struct ip_conntrack *ct;
enum ip_conntrack_info ctinfo; enum ip_conntrack_info ctinfo;
const struct ip_nat_multi_range_compat *mr = targinfo;
IP_NF_ASSERT(hooknum == NF_IP_POST_ROUTING); IP_NF_ASSERT(hooknum == NF_IP_POST_ROUTING);
...@@ -136,7 +137,7 @@ static unsigned int ipt_snat_target(struct sk_buff **pskb, ...@@ -136,7 +137,7 @@ static unsigned int ipt_snat_target(struct sk_buff **pskb,
|| ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY)); || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY));
IP_NF_ASSERT(out); IP_NF_ASSERT(out);
return ip_nat_setup_info(ct, targinfo, hooknum); return ip_nat_setup_info(ct, &mr->range[0], hooknum);
} }
static unsigned int ipt_dnat_target(struct sk_buff **pskb, static unsigned int ipt_dnat_target(struct sk_buff **pskb,
...@@ -148,6 +149,7 @@ static unsigned int ipt_dnat_target(struct sk_buff **pskb, ...@@ -148,6 +149,7 @@ static unsigned int ipt_dnat_target(struct sk_buff **pskb,
{ {
struct ip_conntrack *ct; struct ip_conntrack *ct;
enum ip_conntrack_info ctinfo; enum ip_conntrack_info ctinfo;
const struct ip_nat_multi_range_compat *mr = targinfo;
IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING
|| hooknum == NF_IP_LOCAL_OUT); || hooknum == NF_IP_LOCAL_OUT);
...@@ -157,7 +159,7 @@ static unsigned int ipt_dnat_target(struct sk_buff **pskb, ...@@ -157,7 +159,7 @@ static unsigned int ipt_dnat_target(struct sk_buff **pskb,
/* Connection must be valid and new. */ /* Connection must be valid and new. */
IP_NF_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED)); IP_NF_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED));
return ip_nat_setup_info(ct, targinfo, hooknum); return ip_nat_setup_info(ct, &mr->range[0], hooknum);
} }
static int ipt_snat_checkentry(const char *tablename, static int ipt_snat_checkentry(const char *tablename,
...@@ -166,17 +168,15 @@ static int ipt_snat_checkentry(const char *tablename, ...@@ -166,17 +168,15 @@ static int ipt_snat_checkentry(const char *tablename,
unsigned int targinfosize, unsigned int targinfosize,
unsigned int hook_mask) unsigned int hook_mask)
{ {
struct ip_nat_multi_range *mr = targinfo; struct ip_nat_multi_range_compat *mr = targinfo;
/* Must be a valid range */ /* Must be a valid range */
if (targinfosize < sizeof(struct ip_nat_multi_range)) { if (mr->rangesize != 1) {
DEBUGP("SNAT: Target size %u too small\n", targinfosize); printk("SNAT: multiple ranges no longer supported\n");
return 0; return 0;
} }
if (targinfosize != IPT_ALIGN((sizeof(struct ip_nat_multi_range) if (targinfosize != sizeof(struct ip_nat_multi_range_compat)) {
+ (sizeof(struct ip_nat_range)
* (mr->rangesize - 1))))) {
DEBUGP("SNAT: Target size %u wrong for %u ranges\n", DEBUGP("SNAT: Target size %u wrong for %u ranges\n",
targinfosize, mr->rangesize); targinfosize, mr->rangesize);
return 0; return 0;
...@@ -201,17 +201,15 @@ static int ipt_dnat_checkentry(const char *tablename, ...@@ -201,17 +201,15 @@ static int ipt_dnat_checkentry(const char *tablename,
unsigned int targinfosize, unsigned int targinfosize,
unsigned int hook_mask) unsigned int hook_mask)
{ {
struct ip_nat_multi_range *mr = targinfo; struct ip_nat_multi_range_compat *mr = targinfo;
/* Must be a valid range */ /* Must be a valid range */
if (targinfosize < sizeof(struct ip_nat_multi_range)) { if (mr->rangesize != 1) {
DEBUGP("DNAT: Target size %u too small\n", targinfosize); printk("DNAT: multiple ranges no longer supported\n");
return 0; return 0;
} }
if (targinfosize != IPT_ALIGN((sizeof(struct ip_nat_multi_range) if (targinfosize != sizeof(struct ip_nat_multi_range_compat)) {
+ (sizeof(struct ip_nat_range)
* (mr->rangesize - 1))))) {
DEBUGP("DNAT: Target size %u wrong for %u ranges\n", DEBUGP("DNAT: Target size %u wrong for %u ranges\n",
targinfosize, mr->rangesize); targinfosize, mr->rangesize);
return 0; return 0;
...@@ -244,12 +242,12 @@ alloc_null_binding(struct ip_conntrack *conntrack, ...@@ -244,12 +242,12 @@ alloc_null_binding(struct ip_conntrack *conntrack,
= (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
? conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip ? conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip
: conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip); : conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip);
struct ip_nat_multi_range mr struct ip_nat_range range
= { 1, { { IP_NAT_RANGE_MAP_IPS, ip, ip, { 0 }, { 0 } } } }; = { IP_NAT_RANGE_MAP_IPS, ip, ip, { 0 }, { 0 } };
DEBUGP("Allocating NULL binding for %p (%u.%u.%u.%u)\n", conntrack, DEBUGP("Allocating NULL binding for %p (%u.%u.%u.%u)\n", conntrack,
NIPQUAD(ip)); NIPQUAD(ip));
return ip_nat_setup_info(conntrack, &mr, hooknum); return ip_nat_setup_info(conntrack, &range, hooknum);
} }
int ip_nat_rule_find(struct sk_buff **pskb, int ip_nat_rule_find(struct sk_buff **pskb,
......
...@@ -107,7 +107,7 @@ tftp_nat_expected(struct sk_buff **pskb, ...@@ -107,7 +107,7 @@ tftp_nat_expected(struct sk_buff **pskb,
const struct ip_conntrack *master = ct->master->expectant; const struct ip_conntrack *master = ct->master->expectant;
const struct ip_conntrack_tuple *orig = const struct ip_conntrack_tuple *orig =
&master->tuplehash[IP_CT_DIR_ORIGINAL].tuple; &master->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
struct ip_nat_multi_range mr; struct ip_nat_range range;
#if 0 #if 0
const struct ip_conntrack_tuple *repl = const struct ip_conntrack_tuple *repl =
&master->tuplehash[IP_CT_DIR_REPLY].tuple; &master->tuplehash[IP_CT_DIR_REPLY].tuple;
...@@ -124,21 +124,19 @@ tftp_nat_expected(struct sk_buff **pskb, ...@@ -124,21 +124,19 @@ tftp_nat_expected(struct sk_buff **pskb,
IP_NF_ASSERT(master); IP_NF_ASSERT(master);
IP_NF_ASSERT(!(info->initialized & (1 << HOOK2MANIP(hooknum)))); IP_NF_ASSERT(!(info->initialized & (1 << HOOK2MANIP(hooknum))));
mr.rangesize = 1; range.flags = IP_NAT_RANGE_MAP_IPS;
mr.range[0].flags = IP_NAT_RANGE_MAP_IPS;
if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC) { if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC) {
mr.range[0].min_ip = mr.range[0].max_ip = orig->dst.ip; range.min_ip = range.max_ip = orig->dst.ip;
DEBUGP("orig: %u.%u.%u.%u:%u <-> %u.%u.%u.%u:%u " DEBUGP("orig: %u.%u.%u.%u:%u <-> %u.%u.%u.%u:%u "
"newsrc: %u.%u.%u.%u\n", "newsrc: %u.%u.%u.%u\n",
NIPQUAD((*pskb)->nh.iph->saddr), ntohs(uh->source), NIPQUAD((*pskb)->nh.iph->saddr), ntohs(uh->source),
NIPQUAD((*pskb)->nh.iph->daddr), ntohs(uh->dest), NIPQUAD((*pskb)->nh.iph->daddr), ntohs(uh->dest),
NIPQUAD(orig->dst.ip)); NIPQUAD(orig->dst.ip));
} else { } else {
mr.range[0].min_ip = mr.range[0].max_ip = orig->src.ip; range.min_ip = range.max_ip = orig->src.ip;
mr.range[0].min.udp.port = mr.range[0].max.udp.port = range.min.udp.port = range.max.udp.port = orig->src.u.udp.port;
orig->src.u.udp.port; range.flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
mr.range[0].flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
DEBUGP("orig: %u.%u.%u.%u:%u <-> %u.%u.%u.%u:%u " DEBUGP("orig: %u.%u.%u.%u:%u <-> %u.%u.%u.%u:%u "
"newdst: %u.%u.%u.%u:%u\n", "newdst: %u.%u.%u.%u:%u\n",
...@@ -147,7 +145,7 @@ tftp_nat_expected(struct sk_buff **pskb, ...@@ -147,7 +145,7 @@ tftp_nat_expected(struct sk_buff **pskb,
NIPQUAD(orig->src.ip), ntohs(orig->src.u.udp.port)); NIPQUAD(orig->src.ip), ntohs(orig->src.u.udp.port));
} }
return ip_nat_setup_info(ct,&mr,hooknum); return ip_nat_setup_info(ct, &range, hooknum);
} }
static struct ip_nat_helper tftp[MAX_PORTS]; static struct ip_nat_helper tftp[MAX_PORTS];
......
...@@ -43,7 +43,7 @@ masquerade_check(const char *tablename, ...@@ -43,7 +43,7 @@ masquerade_check(const char *tablename,
unsigned int targinfosize, unsigned int targinfosize,
unsigned int hook_mask) unsigned int hook_mask)
{ {
const struct ip_nat_multi_range *mr = targinfo; const struct ip_nat_multi_range_compat *mr = targinfo;
if (strcmp(tablename, "nat") != 0) { if (strcmp(tablename, "nat") != 0) {
DEBUGP("masquerade_check: bad table `%s'.\n", tablename); DEBUGP("masquerade_check: bad table `%s'.\n", tablename);
...@@ -79,8 +79,8 @@ masquerade_target(struct sk_buff **pskb, ...@@ -79,8 +79,8 @@ masquerade_target(struct sk_buff **pskb,
{ {
struct ip_conntrack *ct; struct ip_conntrack *ct;
enum ip_conntrack_info ctinfo; enum ip_conntrack_info ctinfo;
const struct ip_nat_multi_range *mr; const struct ip_nat_multi_range_compat *mr;
struct ip_nat_multi_range newrange; struct ip_nat_range newrange;
struct rtable *rt; struct rtable *rt;
u_int32_t newsrc; u_int32_t newsrc;
...@@ -108,10 +108,10 @@ masquerade_target(struct sk_buff **pskb, ...@@ -108,10 +108,10 @@ masquerade_target(struct sk_buff **pskb,
WRITE_UNLOCK(&masq_lock); WRITE_UNLOCK(&masq_lock);
/* Transfer from original range. */ /* Transfer from original range. */
newrange = ((struct ip_nat_multi_range) newrange = ((struct ip_nat_range)
{ 1, { { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS, { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS,
newsrc, newsrc, newsrc, newsrc,
mr->range[0].min, mr->range[0].max } } }); mr->range[0].min, mr->range[0].max });
/* Hand modified range to generic setup. */ /* Hand modified range to generic setup. */
return ip_nat_setup_info(ct, &newrange, hooknum); return ip_nat_setup_info(ct, &newrange, hooknum);
......
...@@ -36,7 +36,7 @@ check(const char *tablename, ...@@ -36,7 +36,7 @@ check(const char *tablename,
unsigned int targinfosize, unsigned int targinfosize,
unsigned int hook_mask) unsigned int hook_mask)
{ {
const struct ip_nat_multi_range *mr = targinfo; const struct ip_nat_multi_range_compat *mr = targinfo;
if (strcmp(tablename, "nat") != 0) { if (strcmp(tablename, "nat") != 0) {
DEBUGP(MODULENAME":check: bad table `%s'.\n", tablename); DEBUGP(MODULENAME":check: bad table `%s'.\n", tablename);
...@@ -72,8 +72,8 @@ target(struct sk_buff **pskb, ...@@ -72,8 +72,8 @@ target(struct sk_buff **pskb,
struct ip_conntrack *ct; struct ip_conntrack *ct;
enum ip_conntrack_info ctinfo; enum ip_conntrack_info ctinfo;
u_int32_t new_ip, netmask; u_int32_t new_ip, netmask;
const struct ip_nat_multi_range *mr = targinfo; const struct ip_nat_multi_range_compat *mr = targinfo;
struct ip_nat_multi_range newrange; struct ip_nat_range newrange;
IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING
|| hooknum == NF_IP_POST_ROUTING); || hooknum == NF_IP_POST_ROUTING);
...@@ -87,10 +87,10 @@ target(struct sk_buff **pskb, ...@@ -87,10 +87,10 @@ target(struct sk_buff **pskb,
new_ip = (*pskb)->nh.iph->saddr & ~netmask; new_ip = (*pskb)->nh.iph->saddr & ~netmask;
new_ip |= mr->range[0].min_ip & netmask; new_ip |= mr->range[0].min_ip & netmask;
newrange = ((struct ip_nat_multi_range) newrange = ((struct ip_nat_range)
{ 1, { { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS, { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS,
new_ip, new_ip, new_ip, new_ip,
mr->range[0].min, mr->range[0].max } } }); mr->range[0].min, mr->range[0].max });
/* Hand modified range to generic setup. */ /* Hand modified range to generic setup. */
return ip_nat_setup_info(ct, &newrange, hooknum); return ip_nat_setup_info(ct, &newrange, hooknum);
......
...@@ -38,7 +38,7 @@ redirect_check(const char *tablename, ...@@ -38,7 +38,7 @@ redirect_check(const char *tablename,
unsigned int targinfosize, unsigned int targinfosize,
unsigned int hook_mask) unsigned int hook_mask)
{ {
const struct ip_nat_multi_range *mr = targinfo; const struct ip_nat_multi_range_compat *mr = targinfo;
if (strcmp(tablename, "nat") != 0) { if (strcmp(tablename, "nat") != 0) {
DEBUGP("redirect_check: bad table `%s'.\n", table); DEBUGP("redirect_check: bad table `%s'.\n", table);
...@@ -74,8 +74,8 @@ redirect_target(struct sk_buff **pskb, ...@@ -74,8 +74,8 @@ redirect_target(struct sk_buff **pskb,
struct ip_conntrack *ct; struct ip_conntrack *ct;
enum ip_conntrack_info ctinfo; enum ip_conntrack_info ctinfo;
u_int32_t newdst; u_int32_t newdst;
const struct ip_nat_multi_range *mr = targinfo; const struct ip_nat_multi_range_compat *mr = targinfo;
struct ip_nat_multi_range newrange; struct ip_nat_range newrange;
IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING
|| hooknum == NF_IP_LOCAL_OUT); || hooknum == NF_IP_LOCAL_OUT);
...@@ -99,10 +99,10 @@ redirect_target(struct sk_buff **pskb, ...@@ -99,10 +99,10 @@ redirect_target(struct sk_buff **pskb,
} }
/* Transfer from original range. */ /* Transfer from original range. */
newrange = ((struct ip_nat_multi_range) newrange = ((struct ip_nat_range)
{ 1, { { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS, { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS,
newdst, newdst, newdst, newdst,
mr->range[0].min, mr->range[0].max } } }); mr->range[0].min, mr->range[0].max });
/* Hand modified range to generic setup. */ /* Hand modified range to generic setup. */
return ip_nat_setup_info(ct, &newrange, hooknum); return ip_nat_setup_info(ct, &newrange, hooknum);
......
...@@ -149,8 +149,8 @@ same_target(struct sk_buff **pskb, ...@@ -149,8 +149,8 @@ same_target(struct sk_buff **pskb,
struct ip_conntrack *ct; struct ip_conntrack *ct;
enum ip_conntrack_info ctinfo; enum ip_conntrack_info ctinfo;
u_int32_t tmpip, aindex, new_ip; u_int32_t tmpip, aindex, new_ip;
const struct ipt_same_info *mr = targinfo; const struct ipt_same_info *same = targinfo;
struct ip_nat_multi_range newrange; struct ip_nat_range newrange;
const struct ip_conntrack_tuple *t; const struct ip_conntrack_tuple *t;
IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING || IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING ||
...@@ -161,17 +161,17 @@ same_target(struct sk_buff **pskb, ...@@ -161,17 +161,17 @@ same_target(struct sk_buff **pskb,
/* Base new source on real src ip and optionally dst ip, /* Base new source on real src ip and optionally dst ip,
giving some hope for consistency across reboots. giving some hope for consistency across reboots.
Here we calculate the index in mr->iparray which Here we calculate the index in same->iparray which
holds the ipaddress we should use */ holds the ipaddress we should use */
tmpip = ntohl(t->src.ip); tmpip = ntohl(t->src.ip);
if (!(mr->info & IPT_SAME_NODST)) if (!(same->info & IPT_SAME_NODST))
tmpip += ntohl(t->dst.ip); tmpip += ntohl(t->dst.ip);
aindex = tmpip % mr->ipnum; aindex = tmpip % same->ipnum;
new_ip = htonl(mr->iparray[aindex]); new_ip = htonl(same->iparray[aindex]);
DEBUGP("ipt_SAME: src=%u.%u.%u.%u dst=%u.%u.%u.%u, " DEBUGP("ipt_SAME: src=%u.%u.%u.%u dst=%u.%u.%u.%u, "
"new src=%u.%u.%u.%u\n", "new src=%u.%u.%u.%u\n",
...@@ -179,10 +179,10 @@ same_target(struct sk_buff **pskb, ...@@ -179,10 +179,10 @@ same_target(struct sk_buff **pskb,
NIPQUAD(new_ip)); NIPQUAD(new_ip));
/* Transfer from original range. */ /* Transfer from original range. */
newrange = ((struct ip_nat_multi_range) newrange = ((struct ip_nat_range)
{ 1, { { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS, { same->range[0].flags, new_ip, new_ip,
new_ip, new_ip, /* FIXME: Use ports from correct range! */
mr->range[0].min, mr->range[0].max } } }); same->range[0].min, same->range[0].max });
/* Hand modified range to generic setup. */ /* Hand modified range to generic setup. */
return ip_nat_setup_info(ct, &newrange, hooknum); return ip_nat_setup_info(ct, &newrange, hooknum);
......
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