Skip to contentSkip to conversation

SYN,URG combination considered INVALID by tcp conntrack

DISCUSSION Martijn Posthuma 2 participants 2 messages Sep 5, 2006 – Feb 13, 2007 netfilter

lore
Share & tools
lore
#0 lore raw

We have been experiencing problems with tcp connection establishment when (for some reason) the URG flag and pointer were set in the SYN segment. The problem did not affect all machines that were contacted but a subset. All affected machines were using netfilter-conntrack and firewalling. Inspection of the conntrack code (on a 2.6 linux kernel source) reveiled that the above mentioned combination of flags is not considered valid. The code I am referring to is in nf_conntrack_proto_tcp.c version 2.2, lines 768 to 795:

#define TH_FIN  0x01
#define TH_SYN  0x02
#define TH_RST  0x04
#define TH_PUSH 0x08
#define TH_ACK  0x10
#define TH_URG  0x20
#define TH_ECE  0x40
#define TH_CWR  0x80

/* table of valid flag combinations - ECE and CWR are always valid */ static u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG) + 1] =

{
    [TH_SYN]            = 1,
    [TH_SYN|TH_ACK]         = 1,
    [TH_SYN|TH_PUSH]        = 1,
    [TH_SYN|TH_ACK|TH_PUSH]     = 1,
    [TH_RST]            = 1,
    [TH_RST|TH_ACK]         = 1,
    [TH_RST|TH_ACK|TH_PUSH]     = 1,
    [TH_FIN|TH_ACK]         = 1,
    [TH_ACK]            = 1,
    [TH_ACK|TH_PUSH]        = 1,
    [TH_ACK|TH_URG]         = 1,
    [TH_ACK|TH_URG|TH_PUSH]     = 1,
    [TH_FIN|TH_ACK|TH_PUSH]     = 1,
    [TH_FIN|TH_ACK|TH_URG]      = 1,
    [TH_FIN|TH_ACK|TH_URG|TH_PUSH]  = 1,
};

As you can see the SYN,URG combination is not considered valid. I can not find any justification for this in RFC793. I do realize that it is a rare combination of flags, but legal none the less. (In the RFC there is even a explicit mention of the fact that a SYN segment can contain data, so a URG flag is perfectly feasible in that case).

Does someone know of a good reason that this flag combination is excluded?

Signature · 2 lines
Martijn Posthuma - software engineer Sangine
www.sangine.com t:+32 (0)14 472 576 f:+32 (0)14 472 582
#1 lore raw
Quoted 8 lines · Martijn Posthuma

We have been experiencing problems with tcp connection establishment when (for some reason) the URG flag and pointer were set in the SYN segment. The problem did not affect all machines that were contacted but a subset. All affected machines were using netfilter-conntrack and firewalling. Inspection of the conntrack code (on a 2.6 linux kernel source) reveiled that the above mentioned combination of flags is not considered valid. The code I am referring to is in nf_conntrack_proto_tcp.c version 2.2, lines 768 to 795:

[..]

As you can see the SYN,URG combination is not considered valid. I can not find any justification for this in RFC793. I do realize that it is a rare combination of flags, but legal none the less. (In the RFC there is even a explicit mention of the fact that a SYN segment can contain data, so a URG flag is perfectly feasible in that case).

Does someone know of a good reason that this flag combination is excluded?

No reason, I've added SYN|URG and SYN|PUSH|URG to the valid flag combinations, thanks.