Skip to contentSkip to conversation

Stange ip_conntrack (newnat) behaviour.

DISCUSSION A. van Schie 2 participants 4 messages Jun 2, 2002 – Jun 4, 2002 netfilter

lore
Share & tools
lore
#0 lore raw

Hi,

I have switched almost a month ago to kernel-2.4.18 (from 2.4.8) with netfilters (cvs update around 2002/04/31) 'newnat'.

Quoted 1 line

From that moment on I got dropped packets on excisting tcp connectings.

After I added logging of NEW tcp connections,
I saw something strange that I think comes from ip_conntrack.

I'm using conntrack-state to filter my packets.
A simple version of my rules look like this:
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A OUTPUT -m state --state NEW -p tcp --destination-port 110 -j log+accept
...
iptables -A OUTPUT -j log+drop

  iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  iptables -A INPUT -j log+drop

What I see with ULOG is the following:

+------+------------+------+------+-----------------+--------+-------+--------+-------+---------+-------+------------+------------+------------+---------+---------+
| id   | prefix     | in   | out  | time            | saddr  | sport | daddr  | dport | ip_csum | ip_id | ip_fragoff | tcp_seq    | tcp_ackseq | tcp_ack | tcp_syn |
+------+------------+------+------+-----------------+--------+-------+--------+-------+---------+-------+------------+------------+------------+---------+---------+
| 8603 | ACCEPT-NEW |      | eth1 | 18:38:10.389606 | client | 38136 | server |   110 |       0 |     0 |          0 | 4080432246 |          0 |    NULL |       1 |
| 8604 | ACCEPT-NEW |      | eth1 | 18:38:10.389606 | client | 38136 | server |   110 |   21509 | 13068 |          0 | 4080432246 |          0 |    NULL |       1 |
| 8605 | DROPPED    | eth1 |      | 18:38:10.397096 | server |   110 | client | 38136 |   62367 | 56184 |      16384 | 3577899487 | 4080432247 |       1 |    NULL |
| 8606 | ACCEPT-NEW |      | eth1 | 18:38:16.389606 | client | 38136 | server |   110 |   21508 | 13069 |          0 | 4080432246 |          0 |    NULL |       1 |
| 8607 | DROPPED    | eth1 |      | 18:38:16.403816 | server |   110 | client | 38136 |   62365 | 56186 |      16384 | 3577899487 | 4080432247 |       1 |    NULL |
| 8608 | ACCEPT-NEW |      | eth1 | 18:39:55.286423 | client | 38137 | server |   110 |    1024 |     0 |          0 | 4184019953 |          0 |    NULL |       1 |
+------+------------+------+------+-----------------+--------+-------+--------+-------+---------+-------+------------+------------+------------+---------+---------+

All other fields are equal.

What I find strange is that it starts with 2 almost the same packets (except for ip_id), and that they both get the conntrack state NEW!
And that the first response (I think) does not get the conntrack state ESTABLISHED because it's dropped! And a few seconds later it happens again (normally it not happens agian on the same connecting).

I see no syslog-messages at that time.

I think there is a problem in conntrack,
maybe the newnat patch or the "double packet" is introduced in the kernel.

Can someone tell me what is going wrong, and/or how to solve it.

Signature · 2 lines
Andries van Schie
Let's make the linux-world a safer place to live in ;-)
#1 lore raw

Hi,

Quoted 23 lines · A. van Schie

I saw something strange that I think comes from ip_conntrack.

I'm using conntrack-state to filter my packets.
A simple version of my rules look like this:
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A OUTPUT -m state --state NEW -p tcp --destination-port 110 -j log+accept
...
iptables -A OUTPUT -j log+drop

  iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  iptables -A INPUT -j log+drop

What I see with ULOG is the following:

+------+------------+------+------+-----------------+--------+-------+--------+-------+---------+-------+------------+------------+------------+---------+---------+
| id   | prefix     | in   | out  | time            | saddr  | sport | daddr  | dport | ip_csum | ip_id | ip_fragoff | tcp_seq    | tcp_ackseq | tcp_ack | tcp_syn |
+------+------------+------+------+-----------------+--------+-------+--------+-------+---------+-------+------------+------------+------------+---------+---------+
| 8603 | ACCEPT-NEW |      | eth1 | 18:38:10.389606 | client | 38136 | server |   110 |       0 |     0 |          0 | 4080432246 |          0 |    NULL |       1 |
| 8604 | ACCEPT-NEW |      | eth1 | 18:38:10.389606 | client | 38136 | server |   110 |   21509 | 13068 |          0 | 4080432246 |          0 |    NULL |       1 |
| 8605 | DROPPED    | eth1 |      | 18:38:10.397096 | server |   110 | client | 38136 |   62367 | 56184 |      16384 | 3577899487 | 4080432247 |       1 |    NULL |
| 8606 | ACCEPT-NEW |      | eth1 | 18:38:16.389606 | client | 38136 | server |   110 |   21508 | 13069 |          0 | 4080432246 |          0 |    NULL |       1 |
| 8607 | DROPPED    | eth1 |      | 18:38:16.403816 | server |   110 | client | 38136 |   62365 | 56186 |      16384 | 3577899487 | 4080432247 |       1 |    NULL |
| 8608 | ACCEPT-NEW |      | eth1 | 18:39:55.286423 | client | 38137 | server |   110 |    1024 |     0 |          0 | 4184019953 |          0 |    NULL |       1 |
+------+------------+------+------+-----------------+--------+-------+--------+-------+---------+-------+------------+------------+------------+---------+---------+
Quoted 4 lines

All other fields are equal.

What I find strange is that it starts with 2 almost the same packets (except for ip_id), and that they both get the conntrack state NEW!

What else state should they got? But those first two packets looks strange, that's true.

Quoted 2 lines

I think there is a problem in conntrack,
maybe the newnat patch or the "double packet" is introduced in the kernel.

If you suspect something like that, then start tcpdumping both involved interfaces and look at the generated logs.

Did you applied other patches from p-o-m?

Regards,
Jozsef
-
E-mail : [email protected], [email protected]
WWW-Home: http://www.kfki.hu/~kadlec
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#2 lore raw
Quoted 47 lines · Jozsef Kadlecsik

Hi,

Quoted 44 lines · A. van Schie

I saw something strange that I think comes from ip_conntrack.

I'm using conntrack-state to filter my packets.
A simple version of my rules look like this:
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A OUTPUT -m state --state NEW -p tcp --destination-port 110
-j log+accept ...
iptables -A OUTPUT -j log+drop

  iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  iptables -A INPUT -j log+drop

What I see with ULOG is the following:
+------+------------+------+------+-----------------+--------+-------+---
-----+-------+---------+-------+------------+------------+------------+---
------+---------+

| id   | prefix     | in   | out  | time            | saddr  | sport |
| daddr  | dport | ip_csum | ip_id | ip_fragoff | tcp_seq    | tcp_ackseq
| | tcp_ack | tcp_syn |

+------+------------+------+------+-----------------+--------+-------+---
-----+-------+---------+-------+------------+------------+------------+---
------+---------+

| 8603 | ACCEPT-NEW |      | eth1 | 18:38:10.389606 | client | 38136 |
| server |   110 |       0 |     0 |          0 | 4080432246 |          0
| |    NULL |       1 | 8604 | ACCEPT-NEW |      | eth1 | 18:38:10.389606
| | client | 38136 | server |   110 |   21509 | 13068 |          0 |
| 4080432246 |          0 |    NULL |       1 | 8605 | DROPPED    | eth1
| |      | 18:38:10.397096 | server |   110 | client | 38136 |   62367 |
| 56184 |      16384 | 3577899487 | 4080432247 |       1 |    NULL | 8606
| | ACCEPT-NEW |      | eth1 | 18:38:16.389606 | client | 38136 | server
| |   110 |   21508 | 13069 |          0 | 4080432246 |          0 |   
| NULL |       1 | 8607 | DROPPED    | eth1 |      | 18:38:16.403816 |
| server |   110 | client | 38136 |   62365 | 56186 |      16384 |
| 3577899487 | 4080432247 |       1 |    NULL | 8608 | ACCEPT-NEW |     
| | eth1 | 18:39:55.286423 | client | 38137 | server |   110 |    1024 | 
|    0 |          0 | 4184019953 |          0 |    NULL |       1 |

+------+------------+------+------+-----------------+--------+-------+---
-----+-------+---------+-------+------------+------------+------------+---
------+---------+ All other fields are equal.

Quoted 5 lines
Quoted 2 lines

What I find strange is that it starts with 2 almost the same packets (except for ip_id), and that they both get the conntrack state NEW!

What else state should they got? But those first two packets looks strange, that's true.

I expected that conntrack gives the second packet the state ESTABLISHED, because all fields that conntrack checks are equal, or is there some other special tcp connection tracking code that I missed.

And I didn't expected the third "response" packet to be DROPPED.

Is it possible that 2 or more packets are handled in parallel on a Single CPU machine? What still not explains that third DROPPED packet, the syn must be send before any response is expected.

Quoted 6 lines
Quoted 3 lines

I think there is a problem in conntrack,
maybe the newnat patch or the "double packet" is introduced in the kernel.

If you suspect something like that, then start tcpdumping both involved interfaces and look at the generated logs.

I'm not to handy with that tool, I hope that the current netfilter logging is enough to see what has happend.

Quoted 1 line

Did you applied other patches from p-o-m?

Yes: here is the list:
Already applied: submitted/2.4.14

                 submitted/2.4.18
                 submitted/2.4.4
                 submitted/REJECT-dont_fragment
                 submitted/TOS-oops-fix
                 submitted/ah-esp
                 submitted/conntrack+nat-helper-unregister
                 submitted/ip6t_mac-fix-ipv6
                 submitted/ip6tables-export-symbols
                 submitted/ip_nat_irc-srcaddr-fix
                 submitted/ipqueue-ipv6
                 submitted/ipt_MIRROR-ttl
                 submitted/ipt_REJECT-checkentry
                 submitted/ipt_mac-fix
                 submitted/ipt_unclean-ecn
                 submitted/irc-dcc-mask
                 submitted/local-nat
                 submitted/macro-trailing-semicolon-fix
                 submitted/mangle5hooks
                 submitted/module-license
                 submitted/nat-export_symbols
                 submitted/netfilter-arp
                 submitted/skb_clone_copy
                 submitted/tcp-MSS
                 submitted/ulog
                 pending/0-newnat13
                 pending/DSCP
                 pending/conntrack
                 pending/ipv6-agr-ipv6
                 pending/length-ipv6
                 pending/ownercmd
                 pending/pkttype
                 base/IPV4OPTSSTRIP
                 base/REJECT-ipv6
                 base/TTL
                 base/ahesp6-ipv6
                 base/ipv4options
                 base/mport
                 base/psd
                 base/quota
                 base/time
                 extra/h323-conntrack-nat
                 extra/helper
                 extra/recent
                 extra/record-rpc
                 extra/tcp-window-tracking
Quoted 7 lines

Regards,
Jozsef
-
E-mail : [email protected], [email protected]
WWW-Home: http://www.kfki.hu/~kadlec
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
Signature · 2 lines
Andries van Schie
Let's make the linux-world a safer place to live in ;-)
#3 lore raw
Quoted 11 lines · A. van Schie
Quoted 5 lines
Quoted 2 lines

What I find strange is that it starts with 2 almost the same packets (except for ip_id), and that they both get the conntrack state NEW!

What else state should they got? But those first two packets looks strange, that's true.

I expected that conntrack gives the second packet the state ESTABLISHED, because all fields that conntrack checks are equal, or is there some other special tcp connection tracking code that I missed.

From conntrack point of view all parameters of the first two packets are

identical, so the second one is a resent packet. There was no response yet from the destination, therefore the state remains the same: NEW.

Quoted 1 line

And I didn't expected the third "response" packet to be DROPPED.

This is the first response. :-). But it should not be dropped. :-(

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

I think there is a problem in conntrack,
maybe the newnat patch or the "double packet" is introduced in the kernel.

If you suspect something like that, then start tcpdumping both involved interfaces and look at the generated logs.

I'm not to handy with that tool, I hope that the current netfilter logging is enough to see what has happend.

If you suspect that the kernel generates packets just out of the blue, then the netfilter logging alone won't help. One has to compare what one can catch on the interface itself (by tcpdump) and compare the result with the netfilter logging.

Quoted 1 line
Quoted 1 line

Did you applied other patches from p-o-m?

[..]

Quoted 1 line

extra/tcp-window-tracking

Don't you see any logs about out of window packets?

If yes, I'd suggest to use the new version of the tcp-window-tracking patch. There were problems with window scaling support in the older versions of the patch, which could break connections.

Regards,
Jozsef
-
E-mail : [email protected], [email protected]
WWW-Home: http://www.kfki.hu/~kadlec
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary