Skip to contentSkip to conversation

How to create a "persistent" expectation with newnat?

DISCUSSION Ian Latter 2 participants 2 messages Feb 26, 2003 netfilter

lore
Share & tools
lore

Ian Latter

author
#0 lore raw
Quoted 1 line

Howdy pardner. :-)

ahhh .. Brian ;-) Didn't see your sig b4 ...

Quoted 10 lines
Quoted 2 lines

Wouldn't most of your problems go away if you set the expectation
on the outbound connection?

I do that. And it works while there are outbound connections. But as I described in my last message, there might be some time (quite a bit of time in fact) between outgoing connections. Indeed, once you have been on the network long enough and your address gets known to enough other peers on the network, you will start to see enough incoming connections that you no longer make outgoing connections to keep the "minimum connections" count up.

Instead of relying on outgoing connections to maintain the live session, leave that out for the time being, and set up an untimed inbound expectation.

Quoted 3 lines

Since there potentially can be no outgoing connections after the first few, it is these incoming connections that need to keep the "flywheel" (of inbound expectations) going.

s'cool ... let one out set it off ... and the ins can look after themselves ...

Quoted 7 lines
Quoted 6 lines

Ie. If I was to alter my rsh module to
do gnutella, on what you've said below, I would look for the one outbound connection (client to server --- or client to universe in p2p), setup an expectation on the inbound connections (universe to client) for either an unlimited or numbered count of each type, then handle these connections.

Quoted 5 lines

But the expectation will go away when either of a) it times out, or b) the master connection goes away. It is for both of these reasons that the expectation needs to continually be renewed (even when your only connections are inbound). It needs to be attached to an ESTABLISHED connection and not be timed out.

Whenever your "end condition" occurs for the client ... then unload all
of the open expectations .... so ... a or b rings true, then trash the open
expects ..

Quoted 5 lines
Quoted 1 line

In this way you will also avoid hassles later with NAT ....

For inbound connections, I don't know that there are NAT issues yet. I don't think anything in the payload needs to be altered. I have not looked that deeply yet.

Even if there's nothing in the payload ... if the NAT has been a masq or some other non ip-to-ip mapping, then the helper will need to rewrite the ip headers ... this had to be done in rsh .. which works like ftp ... one out with a port in the proto for where a new one should come back .. this then hits the firewall (tables) as a local port, which then needs to be re-written. Not that my rsh nat code ever got published ... I've been meaning to ask Harald about that actually ...

Quoted 5 lines
Quoted 2 lines

So, generally, my feeling from netfilter is that you track the outbound and expect the inbound ...

Generally, I agree with you -- for protocols where this is in fact the case.

I don't see your proto as being tremendously different from ftp ... 'cept that the data sessions can be many+ and they can come from
the universe and not the master destination ... should be pretty straight forward ...

Quoted 5 lines

b.

Signature · 1 line
Brian J. Murrell

--
Ian Latter
Internet and Networking Security Officer
Macquarie University

#1 lore raw
Quoted 2 lines · Ian Latter

ahhh .. Brian ;-) Didn't see your sig b4 ...

S'ok. It was funny.

Quoted 2 lines

Instead of relying on outgoing connections to maintain the live session, leave that out for the time being, and set up an untimed inbound expectation.

But unless I am mistaken, inbound expectations have to be related to an ESTABLISHED connection. That is fine, except as soon as the ESTABLISHED connection goes away so does it's expectation(s). With the nature of P2P like Gnutella, connections come and go like the wind.

That is why the expectation (which is the same for every outgoing and incoming connection) needs to be refreshed with new master connections.

Quoted 1 line

s'cool ... let one out set it off ... and the ins can look after themselves ...

Right. I do refresh the expecation for every outbound connection, but need to refresh on inbound connections as well as outbound connections can be few and far between once the client has made it's presence known.

Quoted 2 lines

Whenever your "end condition" occurs for the client ... then unload all of the open expectations ....

Well, the expectation (there is only one, it's the same expectation for all masters everybody:allports->client:localport) goes away when it times out or the master connection goes away. That is clean enough for me.

Quoted 2 lines

so ... a or b rings true, then trash the open
expects ..

It's just cleaner to let the framework do that for me.

Quoted 3 lines

Even if there's nothing in the payload ... if the NAT has been a masq or some other non ip-to-ip mapping, then the helper will need to rewrite the ip headers ...

Right. I am already doing that. I do alter the payload in the outgoing connection if needed -- although with gtk-gnutella, it somehow determines the outside address of the iptables box so technically it's not needed.

Quoted 4 lines

this had to be done in rsh .. which works like ftp ... one out with a port in the proto for where a new one should come back .. this then hits the firewall (tables) as a local port, which then needs to be re-written.

Right. That I am doing already as well. I have successfully run two different clients behind my modules and they both work (while both are using the same local port), so I must be doing something right. :-)

Quoted 4 lines

I don't see your proto as being tremendously different from ftp ... 'cept that the data sessions can be many+ and they can come from
the universe and not the master destination ... should be pretty straight forward ...

'Tis really. In my original message, I think I said it was 99% working and thought I had to use a hack to get it to work when indeed my hack was (close to) the right solution. I based heavily on the ftp and/or irc modules.

b.

Signature · 1 line
Brian J. Murrell