connlimit error?
In connlimit module for 2.6.11 in line 74 is:
[..]
[74] found != NULL && ct = tuplehash_to_ctrack(found)
&&
[..]
in my kernel 2.6.11.6 with some patches it can't compile return error:
router:~/rpm/BUILD/linux-2.6.11.6%make SUBDIRS=net/ipv4/netfilter
CC [M] net/ipv4/netfilter/ipt_connlimit.onet/ipv4/netfilter/ipt_connlimit.c: In function `count_them':net/ipv4/netfilter/ipt_connlimit.c:75: error: invalid lvalue in assignment
make[1]: *** [net/ipv4/netfilter/ipt_connlimit.o] Error 1
make: *** [_module_net/ipv4/netfilter] Error 2
when I removed "ct = tuplehash_to_ctrack(found)"
like in linux-2.6 module all looks OK.
Can anyone looking on this ?
Thanx.
Sas.
Signature · 2 lines
{Wojciech 'Sas' Cieciwa - Member of PLD Team }
{e-mail: [email protected], http://www.republika.pl/cieciwa }Quoted 4 lines · On Tue, 5 Apr 2005, Wojciech 'Sas' [iso-8859-2] Ci�ciwa wrote:
In connlimit module for 2.6.11 in line 74 is:
[..]
[74] found != NULL && ct =tuplehash_to_ctrack(found)
&&
If I am not mistaken that = should be a ==
Regards
Henrik
Quoted 8 lines · Henrik Nordstrom
Quoted 4 lines · On Tue, 5 Apr 2005, Wojciech 'Sas' [iso-8859-2] Ciêciwa wrote:
In connlimit module for 2.6.11 in line 74 is:
[..]
[74] found != NULL && ct =tuplehash_to_ctrack(found)
&&If I am not mistaken that = should be a ==
No, actually not. two lines above "struct ip_conntrack *ct = NULL".
The whole purpose of this segment is to check for 'found' and if there is one, resolve 'ct' based on found and do some further checks. I've added the missing parenthesis in svn now.
[yes, bad programming style, but I didn't want to change more than absolutely required between 2.6.10 and 2.6.11 versions]
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
Quoted 10 lines · Harald Welte
Quoted 1 line
If I am not mistaken that = should be a ==
No, actually not. two lines above "struct
ip_conntrack*ct = NULL".The whole purpose of this segment is to check for 'found' and if there is one, resolve 'ct' based on found and do some further checks. I've added the missing parenthesis in svn now.
[yes, bad programming style, but I didn't want to change more than absolutely required between 2.6.10 and 2.6.11 versions]
Indeed bad style, not even counting the missing parantesis:
The variable ct is overloaded both as a block local and a function
argument. This is what fooled me into thinking the intention was to compare with the ct given as argument..
In addition the block level ct is declared mid-block (not at the
beginning of a block) which will cause compile errors with GCC 2.95.X and RedHat GCC 2.96-xxx and makes it even harder to see that it is overloaded when eyeballing the code.
Regards
Henrik
patch to address my concerns below.
Quoted 15 lines · Henrik Nordstrom
Quoted 10 lines · Harald Welte
Quoted 1 line
If I am not mistaken that = should be a ==
No, actually not. two lines above "struct
ip_conntrack*ct = NULL".The whole purpose of this segment is to check for 'found' and if there is one, resolve 'ct' based on found and do some further checks. I've added the missing parenthesis in svn now.
[yes, bad programming style, but I didn't want to change more than absolutely required between 2.6.10 and 2.6.11 versions]
Indeed bad style, not even counting the missing parantesis:
Quoted 9 lines
The variable ct is overloaded both as a block local and a function
argument. This is what fooled me into thinking the intention was to compare with the ct given as argument..In addition the block level ct is declared mid-block (not at the beginning
of a block) which will cause compile errors with GCC 2.95.X and RedHat GCC 2.96-xxx and makes it even harder to see that it is overloaded when eyeballing the code.Regards
Henrik
linux-2.6.11/net/ipv4/netfilter/ipt_connlimit.c +9 -9
@@ -67,12 +67,12 @@/* check the saved connections */ for (lh = hash->next; lh != hash; lh = lh->next) { - conn = list_entry(lh,struct ipt_connlimit_conn,list); - found =ip_conntrack_find_get (&conn->tuple,ct); -struct ip_conntrack *ct =NULL ; +struct ip_conntrack *found_ct =NULL ; + conn = list_entry(lh,struct ipt_connlimit_conn,list); + found =ip_conntrack_find_get (&conn->tuple,ct);if (0 ==memcmp (&conn->tuple,&tuple,sizeof (tuple)) && - found !=NULL && (ct =tuplehash_to_ctrack (found)) && - ct->proto.tcp.state !=TCP_CONNTRACK_TIME_WAIT ) { + found !=NULL && (found_ct =tuplehash_to_ctrack (found)) !=NULL && + found_ct->proto.tcp.state !=TCP_CONNTRACK_TIME_WAIT ) {/* Just to be sure we have it only once in the list. We should'nt see tuples twice unless someone hooks this into a table without "-p tcp --syn" */
@@ -83,7 +83,7 @@ipt_iphash (addr & mask),NIPQUAD (conn->tuple.src.ip),ntohs (conn->tuple.src.u.tcp.port),NIPQUAD (conn->tuple.dst.ip),ntohs (conn->tuple.dst.u.tcp.port), - (NULL != found) ? tcp[ct->proto.tcp.state] : "gone"); + (NULL != found) ? tcp[found_ct->proto.tcp.state] : "gone");#endif if (NULL == found) {/* this one is gone */
@@ -92,20 +92,20 @@kfree (conn);continue ; } -if (ct->proto.tcp.state ==TCP_CONNTRACK_TIME_WAIT ) { +if (found_ct->proto.tcp.state ==TCP_CONNTRACK_TIME_WAIT ) {/* we don't care about connections which are closed already -> ditch it */ lh = lh->prev;list_del (lh->next);kfree (conn); -nf_conntrack_put (&ct->ct_general); +nf_conntrack_put (&found_ct->ct_general);continue ; }if ((addr & mask) == (conn->tuple.src.ip & mask)) {/* same source IP address -> be counted! */ matches++; } -nf_conntrack_put (&ct->ct_general); +nf_conntrack_put (&found_ct->ct_general); }if (addit) {/* save the new connection in our list */
Quoted 1 line · Henrik Nordstrom
patch to address my concerns below.
thanks, Committed revision 3857.
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
Quoted 15 lines · Wojciech 'Sas' Ci?ciwa
In connlimit module for 2.6.11 in line 74 is:
[..]
[74] found != NULL && ct =tuplehash_to_ctrack(found)
&&
[..]
in my kernel 2.6.11.6 with some patches it can't compile return error:
router:~/rpm/BUILD/linux-2.6.11.6%make SUBDIRS=net/ipv4/netfilter
CC [M]net/ipv4/netfilter/ipt_connlimit.onet/ipv4/netfilter/ipt_connlimit.c: In function `count_them':net/ipv4/netfilter/ipt_connlimit.c:75: error: invalid lvalue in assignment
make[1]: *** [net/ipv4/netfilter/ipt_connlimit.o] Error 1
make: *** [_module_net/ipv4/netfilter] Error 2
Quoted 4 lines
when I removed "ct =
tuplehash_to_ctrack(found)"
like in linux-2.6 module all looks OK.Can anyone looking on this ?
should be fixed now.
btw: preferred way for a bug report is via https://bugzilla.netfilter.org
Quoted 2 lines
Thanx.
Sas.
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