Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: iptables: Devel

Purpose of /* Try to get same port: if not, try to change it. */ ip_nat_ftp.c

 

 

iptables devel RSS feed   Index | Next | Previous | View Threaded


hemantkumarjain at yahoo

Jul 30, 2001, 5:28 PM

Post #1 of 2 (439 views)
Permalink
Purpose of /* Try to get same port: if not, try to change it. */ ip_nat_ftp.c

Hi,

I am trying to understand following code segment in ftp_data_fixup in
ip_nat_ftp.c

/* Try to get same port: if not, try to change it. */
for (port = ct_ftp_info->port; port != 0; port++) {
tuple.dst.u.tcp.port = htons(port);

if (ip_conntrack_expect_related(ct, &tuple, &mask, NULL) == 0)
break;
}

How does this affect the ip_conntrack_expect_related which has already been
called in ip_conntrack_ftp.c, may be with a different (originally parsed from
the stream) port?

I tried forcibly replacing the port value and faced some problems. (as if the
port was busy)
Has this code-segment been tested?

Hemant


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/


laforge at gnumonks

Jul 30, 2001, 3:15 PM

Post #2 of 2 (399 views)
Permalink
Re: Purpose of /* Try to get same port: if not, try to change it. */ ip_nat_ftp.c [In reply to]

On Mon, Jul 30, 2001 at 05:28:13PM -0700, Hemant Jain wrote:
> Hi,
>
> I am trying to understand following code segment in ftp_data_fixup in
> ip_nat_ftp.c
>
> /* Try to get same port: if not, try to change it. */
> for (port = ct_ftp_info->port; port != 0; port++) {
> tuple.dst.u.tcp.port = htons(port);
>
> if (ip_conntrack_expect_related(ct, &tuple, &mask, NULL) == 0)
> break;
> }
>
> How does this affect the ip_conntrack_expect_related which has already been
> called in ip_conntrack_ftp.c, may be with a different (originally parsed from
> the stream) port?

It doesn't. ip_nat_ftp is about the nat mapping. We try to find a free port
on the to-be-nat'ed-to ip address.

> I tried forcibly replacing the port value and faced some problems. (as if the
> port was busy)

yes. every (port, l4prot, ip-addr) tuple can only be used once to perserve
a 1:1 mapping.


> Has this code-segment been tested?

it's running an estimated several thousend times every second one some of
the 20 million linux installations over the world.

> Hemant

--
Live long and prosper
- Harald Welte / laforge [at] gnumonks http://www.gnumonks.org
============================================================================
GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M-
V-- PS+ PE-- Y+ PGP++ t++ 5-- !X !R tv-- b+++ DI? !D G+ e* h+ r% y+(*)

iptables devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.