aboutsummaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_nat.c
diff options
context:
space:
mode:
authorDarren Reed <darrenr@FreeBSD.org>2000-10-29 07:50:11 +0000
committerDarren Reed <darrenr@FreeBSD.org>2000-10-29 07:50:11 +0000
commita49e8152f56fe7d0d36361b2e232354c94bffe5e (patch)
tree07bcd938fb5448ce3cc5144acbf4c58a58859142 /sys/netinet/ip_nat.c
parentb13a6dbb2807ebb6dd209c8fcd7935e27a2a9668 (diff)
downloadsrc-a49e8152f56fe7d0d36361b2e232354c94bffe5e.tar.gz
src-a49e8152f56fe7d0d36361b2e232354c94bffe5e.zip
Import IP filter 3.4.13
Notes
Notes: svn path=/vendor-sys/ipfilter/dist-old/; revision=67851
Diffstat (limited to 'sys/netinet/ip_nat.c')
-rw-r--r--sys/netinet/ip_nat.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/sys/netinet/ip_nat.c b/sys/netinet/ip_nat.c
index d52f48d46e05..4f6921d3f3de 100644
--- a/sys/netinet/ip_nat.c
+++ b/sys/netinet/ip_nat.c
@@ -9,7 +9,7 @@
*/
#if !defined(lint)
static const char sccsid[] = "@(#)ip_nat.c 1.11 6/5/96 (C) 1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: ip_nat.c,v 2.37.2.25 2000/10/25 10:38:47 darrenr Exp $";
+static const char rcsid[] = "@(#)$Id: ip_nat.c,v 2.37.2.26 2000/10/27 14:06:48 darrenr Exp $";
#endif
#if defined(__FreeBSD__) && defined(KERNEL) && !defined(_KERNEL)
@@ -118,7 +118,6 @@ u_int ipf_nattable_sz = NAT_TABLE_SZ;
u_int ipf_natrules_sz = NAT_SIZE;
u_int ipf_rdrrules_sz = RDR_SIZE;
u_int ipf_hostmap_sz = HOSTMAP_SIZE;
-int nat_wilds = 0;
u_32_t nat_masks = 0;
u_32_t rdr_masks = 0;
ipnat_t **nat_rules = NULL;
@@ -144,7 +143,7 @@ static void nat_delnat __P((struct ipnat *));
static int fr_natgetent __P((caddr_t));
static int fr_natgetsz __P((caddr_t));
static int fr_natputent __P((caddr_t));
-static void nat_tabmove __P((nat_t *, u_int));
+static void nat_tabmove __P((nat_t *));
static int nat_match __P((fr_info_t *, ipnat_t *, ip_t *));
static hostmap_t *nat_hostmap __P((ipnat_t *, struct in_addr,
struct in_addr));
@@ -1004,7 +1003,7 @@ struct nat *natd;
struct ipnat *ipn;
if (natd->nat_flags & FI_WILDP)
- nat_wilds--;
+ nat_stats.ns_wilds--;
if (natd->nat_hnext[0])
natd->nat_hnext[0]->nat_phnext[0] = natd->nat_phnext[0];
*natd->nat_phnext[0] = natd->nat_hnext[0];
@@ -1148,7 +1147,7 @@ int direction;
bzero((char *)nat, sizeof(*nat));
nat->nat_flags = flags;
if (flags & FI_WILDP)
- nat_wilds++;
+ nat_stats.ns_wilds++;
/*
* Search the current table for a match.
*/
@@ -1916,7 +1915,7 @@ u_32_t ports;
((nat->nat_outport == dport) || (nflags & FI_W_SPORT)))))
return nat;
}
- if (!nat_wilds || !(flags & IPN_TCPUDP))
+ if (!nat_stats.ns_wilds || !(flags & IPN_TCPUDP))
return NULL;
RWLOCK_EXIT(&ipf_nat);
hv = NAT_HASH_FN(dst, 0, ipf_nattable_sz);
@@ -1935,8 +1934,7 @@ u_32_t ports;
continue;
if (((nat->nat_oport == sport) || (nflags & FI_W_DPORT)) &&
((nat->nat_outport == dport) || (nflags & FI_W_SPORT))) {
- hv = NAT_HASH_FN(dst, dport, ipf_nattable_sz);
- nat_tabmove(nat, hv);
+ nat_tabmove(nat);
break;
}
}
@@ -1945,11 +1943,11 @@ u_32_t ports;
}
-static void nat_tabmove(nat, hv)
+static void nat_tabmove(nat)
nat_t *nat;
-u_int hv;
{
nat_t **natp;
+ u_int hv;
/*
* Remove the NAT entry from the old location
@@ -1959,9 +1957,14 @@ u_int hv;
*nat->nat_phnext[0] = nat->nat_hnext[0];
if (nat->nat_hnext[1])
- nat->nat_hnext[0]->nat_phnext[1] = nat->nat_phnext[1];
+ nat->nat_hnext[1]->nat_phnext[1] = nat->nat_phnext[1];
*nat->nat_phnext[1] = nat->nat_hnext[1];
+ /*
+ * Add into the NAT table in the new position
+ */
+ hv = NAT_HASH_FN(nat->nat_inip.s_addr, nat->nat_inport,
+ ipf_nattable_sz);
natp = &nat_table[0][hv];
if (*natp)
(*natp)->nat_phnext[0] = &nat->nat_hnext[0];
@@ -1969,9 +1972,8 @@ u_int hv;
nat->nat_hnext[0] = *natp;
*natp = nat;
- /*
- * Add into the NAT table in the new position
- */
+ hv = NAT_HASH_FN(nat->nat_outip.s_addr, nat->nat_outport,
+ ipf_nattable_sz);
natp = &nat_table[1][hv];
if (*natp)
(*natp)->nat_phnext[1] = &nat->nat_hnext[1];
@@ -2018,7 +2020,7 @@ u_32_t ports;
(nat->nat_oport == dport || nflags & FI_W_DPORT))))
return nat;
}
- if (!nat_wilds || !(flags & IPN_TCPUDP))
+ if (!nat_stats.ns_wilds || !(flags & IPN_TCPUDP))
return NULL;
RWLOCK_EXIT(&ipf_nat);
hv = NAT_HASH_FN(srcip, 0, ipf_nattable_sz);
@@ -2037,8 +2039,7 @@ u_32_t ports;
continue;
if (((nat->nat_inport == sport) || (nflags & FI_W_DPORT)) &&
((nat->nat_oport == dport) || (nflags & FI_W_SPORT))) {
- hv = NAT_HASH_FN(srcip, sport, ipf_nattable_sz);
- nat_tabmove(nat, hv);
+ nat_tabmove(nat);
break;
}
}
@@ -2179,7 +2180,7 @@ fr_info_t *fin;
nat->nat_outport = sport;
nat->nat_flags &= ~(FI_W_DPORT|FI_W_SPORT);
nflags = nat->nat_flags;
- nat_wilds--;
+ nat_stats.ns_wilds--;
}
} else {
RWLOCK_EXIT(&ipf_nat);
@@ -2392,7 +2393,7 @@ fr_info_t *fin;
nat->nat_outport = dport;
nat->nat_flags &= ~(FI_W_SPORT|FI_W_DPORT);
nflags = nat->nat_flags;
- nat_wilds--;
+ nat_stats.ns_wilds--;
}
} else {
RWLOCK_EXIT(&ipf_nat);