nf_conntrack resync with 2.6.11-rc4
Subsystems (2)
Hi Yasuyuki!
Since lots of changes went into ip_conntrack over the last months, I went through the pain of re-synchronizing nf_conntrack with ip_conntrack, hopefully this was the last time.
The code that is now in svn (Version 3689) compiles fine with a 2.6.11-rc4 kernel here. I didn't yet do runtime testing. Yasuyuki, could you please look into that?
I will really oppose any fundamental changes to ip_conntrack at this point, unless the respectiva author submits patches for both ip_conntrack and nf_conntrack.
It's still my position that we should merge it upstream ASAP (2.6.12), even though some minor isues (like ct_extend vs. features) have not yet been sorted out completely. We don't have an experimental kernel series, so we have to put it as EXPERIMENTAL into current 2.6.x. This gives us more exposure, and will make syncing with ip_conntrack changes a more obvious duty :)
To give it even more testing, I'm now starting the work on implementing IPv4 NAT on top of it - lots of users (including me) won't be able to run it on their production routers without that feature :(
Cheers,
Harald
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
Hi, Harald,
Last week, I reviewed the recent changes to ip_conntrack. OK, then I'll re-sync nf_conntrack with it ASAP.
Regards,
-----------------------------------------------------------------
Yasuyuki KOZAKAI @ USAGI Project <[email protected]>
From: Harald Welte <[email protected]>
Date: Tue, 15 Feb 2005 13:47:51 +0100
Quoted 33 lines
Hi Yasuyuki!
Since lots of changes went into
ip_conntrackover the last months, I went through the pain of re-synchronizingnf_conntrackwithip_conntrack, hopefully this was the last time.The code that is now in svn (Version 3689) compiles fine with a 2.6.11-rc4 kernel here. I didn't yet do runtime testing. Yasuyuki, could you please look into that?
I will really oppose any fundamental changes to
ip_conntrackat this point, unless the respectiva author submits patches for bothip_conntrackandnf_conntrack.It's still my position that we should merge it upstream ASAP (2.6.12), even though some minor isues (like
ct_extendvs. features) have not yet been sorted out completely. We don't have an experimental kernel series, so we have to put it as EXPERIMENTAL into current 2.6.x. This gives us more exposure, and will make syncing withip_conntrackchanges a more obvious duty :)To give it even more testing, I'm now starting the work on implementing IPv4 NAT on top of it - lots of users (including me) won't be able to run it on their production routers without that feature :(
Cheers,
HaraldSignature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
Quoted 5 lines · Yasuyuki KOZAKAI
Hi, Harald,
Last week, I reviewed the recent changes to
ip_conntrack. OK, then I'll re-syncnf_conntrackwith it ASAP.
Yasuyuki, I was telling you that I already did all the work ;) I was just asking you to test it ;)
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
Oh, sorry for mis-reading.
OK, I'll check it.
From: Harald Welte <[email protected]>
Date: Tue, 15 Feb 2005 15:04:02 +0100
Quoted 16 lines · Yasuyuki KOZAKAI
Quoted 5 lines
Hi, Harald,
Last week, I reviewed the recent changes to
ip_conntrack. OK, then I'll re-syncnf_conntrackwith it ASAP.Yasuyuki, I was telling you that I already did all the work ;) I was just asking you to test it ;)
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
Hello Harald,
Quoted 3 lines · Harald Welte
Since lots of changes went into
ip_conntrackover the last months, I went through the pain of re-synchronizingnf_conntrackwithip_conntrack, hopefully this was the last time.
isn't this one missing?
Michal
Signature · 5 lines
Michal Rokos email: <michal AT rokos DOT info> jabber: <majkl AT jabber DOT cz> icq: 36118339
include/linux/netfilter/nf_conntrack_tcp.h renamed from svn/nf_conntrack/linux-2.6/include/linux/netfilter/nf_conntrack_tcp.h +1 -1
@@ -23,7 +23,7 @@ };/* Window scaling is advertised by the sender */ -#define NF_CT_TCP_STATE_FLAG_WINDOW_SCALE 0x01 +#define NF_CT_TCP_FLAG_WINDOW_SCALE 0x01/* SACK is permitted by the sender */ #define NF_CT_TCP_FLAG_SACK_PERM 0x02
net/netfilter/nf_conntrack_proto_tcp.c renamed from svn/nf_conntrack/linux-2.6/net/netfilter/nf_conntrack_proto_tcp.c +18 -13
@@ -280,9 +280,9 @@* sCL -> sCL */ /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ -/*ack*/ { sIV, sIV, sIV, sES, sCW, sCW, sTW, sTW, sCL, sIV }, +/*ack*/ { sIV, sIG, sIV, sES, sCW, sCW, sTW, sTW, sCL, sIV },/* -* sSS -> sIV ACK is invalid: we haven't seen a SYN/ACK yet. +* sSS -> sIG Might be a half-open connection. * sSR -> sIV Simultaneous open. * sES -> sES :-) * sFW -> sCW Normal close request answered by ACK.
@@ -444,7 +444,7 @@ state->td_scale =14 ; } state->flags |= -NF_CT_TCP_STATE_FLAG_WINDOW_SCALE ; +NF_CT_TCP_FLAG_WINDOW_SCALE ; } ptr += opsize -2 ; length -= opsize;
@@ -566,8 +566,8 @@* Both sides must send the Window Scale option * to enable window scaling in either direction. */ -if (!(sender->flags &NF_CT_TCP_STATE_FLAG_WINDOW_SCALE - && receiver->flags &NF_CT_TCP_STATE_FLAG_WINDOW_SCALE )) +if (!(sender->flags &NF_CT_TCP_FLAG_WINDOW_SCALE + && receiver->flags &NF_CT_TCP_FLAG_WINDOW_SCALE )) sender->td_scale = receiver->td_scale =0 ; }else {
@@ -580,8 +580,10 @@ sender->td_maxwin = (win ==0 ?1 : win); sender->td_maxend = end + sender->td_maxwin; } - }else if (state->state ==TCP_CONNTRACK_SYN_SENT - && dir ==NF_CT_DIR_ORIGINAL + }else if (((state->state ==TCP_CONNTRACK_SYN_SENT + && dir ==NF_CT_DIR_ORIGINAL ) + || (state->state ==TCP_CONNTRACK_SYN_RECV + && dir ==NF_CT_DIR_REPLY )) &&after (end, sender->td_end)) {/* * RFC 793: "if a TCP is reinitialized ... then it need
@@ -699,7 +701,7 @@"nf_ct_tcp: %s " , before(end, sender->td_maxend + 1) ? after(seq, sender->td_end - receiver->td_maxwin - 1) ? - before(ack, receiver->td_end + 1) ? + before(sack, receiver->td_end + 1) ? after(ack, receiver->td_end - MAXACKWINDOW(sender)) ? "BUG" : "ACK is under the lower bound (possibly overly delayed ACK)" : "ACK is over the upper bound (ACKed data has never seen yet)"
@@ -896,7 +898,9 @@switch (new_state) {case TCP_CONNTRACK_IGNORE : -/* Either SYN in ORIGINAL, or SYN/ACK in REPLY direction. */ +/* Either SYN in ORIGINAL +* or SYN/ACK in REPLY +* or ACK in REPLY direction (half-open connection). */ if (index ==TCP_SYNACK_SET && conntrack->proto.tcp.last_index ==TCP_SYN_SET && conntrack->proto.tcp.last_dir != dir
@@ -925,7 +929,7 @@WRITE_UNLOCK (&tcp_lock);if (LOG_INVALID (IPPROTO_TCP ))nf_log_packet (pf,0 , skb,NULL ,NULL , -"nf_ct_tcp: invalid SYN (ignored) " ); +"nf_ct_tcp: invalid packed ignored " );return NF_ACCEPT ;case TCP_CONNTRACK_MAX :/* Invalid packet */
@@ -950,11 +954,12 @@break ;case TCP_CONNTRACK_CLOSE :if (index ==TCP_RST_SET - &&test_bit (NF_S_SEEN_REPLY_BIT , &conntrack->status) - && conntrack->proto.tcp.last_index <=TCP_SYNACK_SET + && ((test_bit (NF_S_SEEN_REPLY_BIT , &conntrack->status) + && conntrack->proto.tcp.last_index <=TCP_SYNACK_SET ) + || conntrack->proto.tcp.last_index ==TCP_ACK_SET ) &&after (ntohl (th->ack_seq), conntrack->proto.tcp.last_seq)) { -/* Ignore RST closing down invalid SYN +/* Ignore RST closing down invalid SYN or ACK we had let trough. */ WRITE_UNLOCK (&tcp_lock);if (LOG_INVALID (IPPROTO_TCP ))
Hello again,
Quoted 6 lines · Michal Rokos
Quoted 3 lines · Harald Welte
Since lots of changes went into
ip_conntrackover the last months, I went through the pain of re-synchronizingnf_conntrackwithip_conntrack, hopefully this was the last time.isn't this one missing?
And more....
in net/netfilter/nf_conntrack_ftp.c there's helper like static int help(struct sk_buff **pskb,
unsigned int protoff,
struct nf_conn *ct,
enum nf_conntrack_info ctinfo) {}
but prototype defined in include/linux/netfilter/nf_conntrack_helper.h is as int (*help)(struct sk_buff **pskb,
struct nf_conn *ct,
enum nf_conntrack_info conntrackinfo);
I'm sorry that patch isn't included...
Michal
Hello,
Quoted 6 lines · Michal Rokos
in
net/netfilter/nf_conntrack_ftp.cthere's helper like static int help(structsk_buff**pskb,
unsigned int protoff,
structnf_conn*ct,
enumnf_conntrack_infoctinfo) {}
Quoted 6 lines
but prototype defined in
include/linux/netfilter/nf_conntrack_helper.his as int (*help)(structsk_buff**pskb,
structnf_conn*ct,
enumnf_conntrack_infoconntrackinfo);I'm sorry that patch isn't included...
Well I tried to hack it.... Is something like this OK?
I believe that passing protoff to helpers is good thing and could be handy to know... Most of them are using dataoff, but that's just simple protoff+sizeof(XXX).
Michal
# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2005/02/16 11:22:16+01:00 [email protected]
# [nf_conntrack] Propagate protoff to helpers.
#
# net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c # 2005/02/16 11:22:02+01:00 [email protected] +23 -4 # Pass protoff to helper. # Code is actually stolen from usagi tree. # # net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c # 2005/02/16 11:22:02+01:00 [email protected] +2 -1 # Pass protoff to helper. # # include/linux/netfilter/nf_conntrack_helper.h # 2005/02/16 11:22:02+01:00 [email protected] +1 -0 # Helpers can use protoff now. # diff -Nru a/include/linux/netfilter/nf_conntrack_helper.h b/include/linux/netfilter/nf_conntrack_helper.h --- a/include/linux/netfilter/nf_conntrack_helper.h 2005-02-16 11:25:35 +01:00 +++ b/include/linux/netfilter/nf_conntrack_helper.h 2005-02-16 11:25:35 +01:00 @@ -30,6 +30,7 @@ /* Function to call when data passes; return verdict, or -1 to invalidate. */ int (*help)(struct sk_buff **pskb, + unsigned int protoff, struct nf_conn *ct, enum nf_conntrack_info conntrackinfo); }; diff -Nru a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c 2005-02-16 11:25:35 +01:00 +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c 2005-02-16 11:25:35 +01:00 @@ -170,7 +170,8 @@ ct = nf_ct_get(*pskb, &ctinfo); if (ct && ct->helper) { unsigned int ret; - ret = ct->helper->help(pskb, ct, ctinfo); + ret = ct->helper->help(pskb, (*pskb)->nh.iph->ihl*4, + ct, ctinfo); if (ret != NF_ACCEPT) return ret; } diff -Nru a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c --- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c 2005-02-16 11:25:35 +01:00 +++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c 2005-02-16 11:25:35 +01:00 @@ -188,14 +188,33 @@ /* This is where we call the helper: as the packet goes out. */ ct = nf_ct_get(*pskb, &ctinfo); if (ct && ct->helper) { + unsigned int extoff, len, protoff; + u_int8_t protonum; unsigned int ret; - ret = ct->helper->help(pskb, ct, ctinfo); - if (ret != NF_ACCEPT) - return ret; + + extoff = (u8*)((*pskb)->nh.ipv6h+1) - (*pskb)->data; + len = (*pskb)->len - extoff; + + /* Verify that a protocol is present and get the protocol handler + we need */ + protonum = (*pskb)->nh.ipv6h->nexthdr; + protoff = ipv6_skip_exthdr(*pskb, extoff, &protonum, len); + + /* + * Notice! (protoff == (*pskb)->len) mean that this packet doesn't + * have no data except of IPv6 & ext headers. but tracked anyway. + * - kozakai + */ + if (!(protoff < 0 || protoff > (*pskb)->len + || protonum == NEXTHDR_FRAGMENT)) { + + ret = ct->helper->help(pskb, protoff, ct, ctinfo); + if (ret != NF_ACCEPT) + return ret; + } }
/* We've seen it coming out the other side: confirm it */
-
return nf_conntrack_confirm(pskb);
}
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: helper and handling IPv6 fragments [was Re: nf_conntrack resync with 2.6.11-rc4]
Quoted 1 line · Yasuyuki KOZAKAI
Well, There seems to be some issues in IPv6 module by resent changes.
ACK.
Quoted 2 lines
In the result, all fragments reach
ipv6_confirm(). helper should not track all of them, and track reassembled skb JUST ONCE.
Agreed.
Quoted 7 lines
But how
ipv6_confirm()can figure out whether helper has already tracked the reassembled skb or not ?I think nfcache flag may help. If helper return
NF_ACCEPT,ipv6_confirm()setNFC_ALTERDto nfcache of it. And when other fragments reachipv6_confirm(), it can return without call helper. Of cause, we need to define the other flags for STOLEN/REPEAT...
I'm not sure if I understand this proposal correctly. Do you suggest to set the nfcache bit of the reassembled clone as soon as the first fragment has passed the helper (and returned NF_ACCEPT) ?
Signature · 5 lines
- Harald Welte <[email protected]> http://netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
Re: helper and handling IPv6 fragments
Hi, Harald,
From: Harald Welte <[email protected]>
Date: Sat, 19 Feb 2005 19:50:28 +0100
Quoted 11 lines
Quoted 7 lines
But how
ipv6_confirm()can figure out whether helper has already tracked the reassembled skb or not ?I think nfcache flag may help. If helper return
NF_ACCEPT,ipv6_confirm()setNFC_ALTERDto nfcache of it. And when other fragments reachipv6_confirm(), it can return without call helper. Of cause, we need to define the other flags for STOLEN/REPEAT...I'm not sure if I understand this proposal correctly. Do you suggest to set the nfcache bit of the reassembled clone as soon as the first fragment has passed the helper (and returned
NF_ACCEPT) ?
Yes, that's right. In the current code, no one touches the nfcache bit of reassembled clone. So we can utilize it for nf_conntrack.
Regards,
-----------------------------------------------------------------
Yasuyuki KOZAKAI @ USAGI Project <[email protected]>
Re: helper and handling IPv6 fragments
Quoted 6 lines · Yasuyuki KOZAKAI
Quoted 3 lines
I'm not sure if I understand this proposal correctly. Do you suggest to set the nfcache bit of the reassembled clone as soon as the first fragment has passed the helper (and returned
NF_ACCEPT) ?Yes, that's right. In the current code, no one touches the nfcache bit of reassembled clone. So we can utilize it for
nf_conntrack.
Ok, I agree we should solve it this way. Thanks for your clarification.
Signature · 5 lines
- Harald Welte <[email protected]> http://netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
Yasuyuki KOZAKAI
AppliedHi, Michal,
I applied your patch. Thanks a lot.
And I found other missing changes by using sed & diff technology ;) I'll commit them latter.
Regards,
From: Michal Rokos <[email protected]>
Date: Tue, 15 Feb 2005 16:15:23 +0100
Quoted 17 lines
Hello Harald,
Quoted 3 lines · Harald Welte
Since lots of changes went into
ip_conntrackover the last months, I went through the pain of re-synchronizingnf_conntrackwithip_conntrack, hopefully this was the last time.isn't this one missing?
Michal
Signature · 5 lines
Michal Rokos email: <michal AT rokos DOT info> jabber: <majkl AT jabber DOT cz> icq: 36118339