should ip_natout return -1 when it run out of port to create nat

This is a discussion on should ip_natout return -1 when it run out of port to create nat within the IPFilter forums, part of the System Security and Security Related category; Hi, On FreeBSD 4.7 and 4.9, ip_natout function return 0 when it can't allocate a TCP/UDP ...


Go Back   Usenet Forums > System Security and Security Related > IPFilter

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-19-2004
Ming Fu
 
Posts: n/a
Default should ip_natout return -1 when it run out of port to create nat

Hi,

On FreeBSD 4.7 and 4.9, ip_natout function return 0 when it can't
allocate a TCP/UDP port for an outbound map.
This make it confusing as ip_natout return 0 also means there is no
ipnat rule to match. This cause internal IP to leak on the external side
when port runs out.

For example:

map xl0 from 10.10.0.0/16 to 172.31.2.144 port = 23 -> 172.31.2.148/32
portmap tcp 30000:30010
pass in log quick on tl0 proto tcp from 10.10.0.0/16 to 172.31.2.144
port = 23 flags S keep state

There only 10 ports availabe for map, intentionally to illustrate the
problem. when 11 telnet session passes through the ipfilter, the 11th
session goes out with un-mapped source IP.

I suggest the follow modification to ip_natout.c


void *sifp;
u_32_t iph;
nat_t *nat;
+ int cant_nat = 0;
+

if (nat_list == NULL || (fr_nat_lock))
return 0;
***************
*** 2431,2436 ****
--- 2439,2448 ----
np->in_hits++;
break;
}
+ /* if can't nat, set a flag to dump the packet
+ did the fil.c listen? */
+ else
+ cant_nat = 1;
}
if ((np == NULL) && (i > 0)) {
do {
***************
*** 2552,2557 ****
--- 2564,2574 ----
}
RWLOCK_EXIT(&ipf_nat); /* READ/WRITE */
fin->fin_ifp = sifp;
+ /* return -1 if a nat rule was matched, but no resource
+ to create nat state */
+ if (cant_nat)
+ return -1;
+ else
return 0;
}


Anyone know if the behavior has changed in 4.x release?

Regards
Ming




Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:49 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0