Re: Patch to add netfilter mark support

2010-09-14 Thread Andrew Beverley
On Wed, 2010-09-15 at 02:06 +, Amos Jeffries wrote:
> On Tue, 14 Sep 2010 23:55:20 +0100, Andrew Beverley 
> wrote:
> >>  * Config.accessList.outgoingTos, Config.accessList.clientsideTos,
> >> Config.accessList.outgoingNfmark, Config.accessList.clientsideNfmark
> can
> >> become members of the Qos scope Config object. All the parsing /free
> >> stuff
> >> can be moved there too with some #define parse_...() etc for the legacy
> >> parser.
> >> 
> > 
> > I've moved all the configuration variables and functions to the Qos
> > scope. I have renamed parse_acl_tos(acl_tos ** head) as
> > Ip::Qos::Config::parseConfigAclTos(acl_tos ** head).
> > 
> > However, I'm unable to compile because of the following error:
> > 
> > Qos.cc: In member function ‘void
> > Ip::Qos::Config::parseConfigAclTos(acl_tos**)’:
> > Qos.cc:377: error: argument of type ‘void (Ip::Qos::Config::)(void*)’
> does
> > not match ‘void (*)(void*)’
> > 
> > The code at line 377 is:
> > 
> > CBDATA_INIT_TYPE_FREECB(acl_tos, freedConfigAclTos);
> > 
> > I have
> > 
> > CBDATA_TYPE(acl_tos);
> > 
> > specified before the parseConfigAclTos function.
> > 
> > Could you give me any ideas as to what I am doing wrong here? If you
> > need me to send through any more of the code then please let me know.
> 
> Do you have this with a cast?
>  #define parse_acl_tos(X) Ip::Qos::Config::parseConfigAclTos((acl_tos
> **)X)
> 
> with the cf.data.pre "TYPE: acl_tos" unchanged.

No, I had changed it. However, I have now changed it back to the above,
but still get the same error. Any other ideas?

Qos.cc: In member function ‘void Ip::Qos::Config::parseConfigAclTos(acl_tos**)’:
Qos.cc:377: error: argument of type ‘void (Ip::Qos::Config::)(void*)’ does not 
match ‘void (*)(void*)’

I have attached my current Qos.cc and Qos.h

Thanks,

Andy

#include "acl/Gadgets.h"
#include "ConfigParser.h"
#include "fde.h"
#include "HierarchyLogEntry.h"
#include "ip/tools.h"
#include "Qos.h"
#include "Parsing.h"
#include "squid.h"
#include "Store.h"

extern void dump_acl_list(StoreEntry * entry, ACLList * head);

/* Qos namespace */

void
Ip::Qos::getTosFromServer(const int server_fd, fde *clientFde)
{
#if USE_QOS_TOS 
tos_t tos = 1;
int tos_len = sizeof(tos); 
clientFde->tosFromServer = 0;
if (setsockopt(server_fd,SOL_IP,IP_RECVTOS,&tos,tos_len)==0) {
unsigned char buf[512];
int len = 512;
if (getsockopt(server_fd,SOL_IP,IP_PKTOPTIONS,buf,(socklen_t*)&len) == 0) {
/* Parse the PKTOPTIONS structure to locate the TOS data message
 * prepared in the kernel by the ZPH incoming TCP TOS preserving
 * patch.
 */
unsigned char * pbuf = buf;
while (pbuf-buf < len) {
struct cmsghdr *o = (struct cmsghdr*)pbuf;
if (o->cmsg_len<=0)
break;

if (o->cmsg_level == SOL_IP && o->cmsg_type == IP_TOS) {
int *tmp = (int*)CMSG_DATA(o);
clientFde->tosFromServer = (tos_t)*tmp;
break;
}
pbuf += CMSG_LEN(o->cmsg_len);
}
} else {
debugs(33, 1, "QOS: error in getsockopt(IP_PKTOPTIONS) on FD " << server_fd << " " << xstrerror());
}
} else {
debugs(33, 1, "QOS: error in setsockopt(IP_RECVTOS) on FD " << server_fd << " " << xstrerror());
}
#endif
}

void Ip::Qos::getNfmarkFromServer(const int server_fd, const fde *servFde, const fde *clientFde)
{
#if USE_QOS_NFMARK
/* Allocate a new conntrack */
if (struct nf_conntrack *ct = nfct_new()) {

/* Prepare data needed to find the connection in the conntrack table.
 * We need the local and remote IP address, and the local and remote
 * port numbers.
 */

Ip::Address serv_fde_local_conn;
struct addrinfo *addr = NULL;
serv_fde_local_conn.InitAddrInfo(addr);
getsockname(server_fd, addr->ai_addr, &(addr->ai_addrlen));
serv_fde_local_conn = *addr;
serv_fde_local_conn.GetAddrInfo(addr);

unsigned short serv_fde_local_port = ((struct sockaddr_in*)addr->ai_addr)->sin_port;
struct in6_addr serv_fde_local_ip6;
struct in_addr serv_fde_local_ip;

if (Ip::EnableIpv6 && serv_fde_local_conn.IsIPv6()) {
serv_fde_local_ip6 = ((struct sockaddr_in6*)addr->ai_addr)->sin6_addr;
nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET6);
struct in6_addr serv_fde_remote_ip6;
inet_pton(AF_INET6,servFde->ipaddr,(struct in6_addr*)&serv_fde_remote_ip6);
nfct_set_attr(ct, ATTR_IPV6_DST, serv_fde_remote_ip6.s6_addr);
nfct_set_attr(ct, ATTR_IPV6_SRC, serv_fde_local_ip6.s6_addr); 
} else {
serv_fde_local_ip = ((struct sockaddr_in*)addr->ai_addr)->sin_addr;
nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET);
nfct_set_attr_u32(ct, ATTR_IPV4_DST, inet_addr(servFde->ip

Re: Patch to add netfilter mark support

2010-09-14 Thread Amos Jeffries
On Tue, 14 Sep 2010 23:55:20 +0100, Andrew Beverley 
wrote:
>>  * Config.accessList.outgoingTos, Config.accessList.clientsideTos,
>> Config.accessList.outgoingNfmark, Config.accessList.clientsideNfmark
can
>> become members of the Qos scope Config object. All the parsing /free
>> stuff
>> can be moved there too with some #define parse_...() etc for the legacy
>> parser.
>> 
> 
> I've moved all the configuration variables and functions to the Qos
> scope. I have renamed parse_acl_tos(acl_tos ** head) as
> Ip::Qos::Config::parseConfigAclTos(acl_tos ** head).
> 
> However, I'm unable to compile because of the following error:
> 
> Qos.cc: In member function ‘void
> Ip::Qos::Config::parseConfigAclTos(acl_tos**)’:
> Qos.cc:377: error: argument of type ‘void (Ip::Qos::Config::)(void*)’
does
> not match ‘void (*)(void*)’
> 
> The code at line 377 is:
> 
> CBDATA_INIT_TYPE_FREECB(acl_tos, freedConfigAclTos);
> 
> I have
> 
> CBDATA_TYPE(acl_tos);
> 
> specified before the parseConfigAclTos function.
> 
> Could you give me any ideas as to what I am doing wrong here? If you
> need me to send through any more of the code then please let me know.

Do you have this with a cast?
 #define parse_acl_tos(X) Ip::Qos::Config::parseConfigAclTos((acl_tos
**)X)

with the cf.data.pre "TYPE: acl_tos" unchanged.

Amos


Re: Patch to add netfilter mark support

2010-09-14 Thread Andrew Beverley

>  * Config.accessList.outgoingTos, Config.accessList.clientsideTos,
> Config.accessList.outgoingNfmark, Config.accessList.clientsideNfmark can
> become members of the Qos scope Config object. All the parsing /free stuff
> can be moved there too with some #define parse_...() etc for the legacy
> parser.
> 

I've moved all the configuration variables and functions to the Qos
scope. I have renamed parse_acl_tos(acl_tos ** head) as
Ip::Qos::Config::parseConfigAclTos(acl_tos ** head).

However, I'm unable to compile because of the following error:

Qos.cc: In member function ‘void Ip::Qos::Config::parseConfigAclTos(acl_tos**)’:
Qos.cc:377: error: argument of type ‘void (Ip::Qos::Config::)(void*)’ does not 
match ‘void (*)(void*)’

The code at line 377 is:

CBDATA_INIT_TYPE_FREECB(acl_tos, freedConfigAclTos);

I have

CBDATA_TYPE(acl_tos);

specified before the parseConfigAclTos function.

Could you give me any ideas as to what I am doing wrong here? If you
need me to send through any more of the code then please let me know.

Thanks,

Andy




Hudson build is back to normal : 3.HEAD-i386-Debian-sid #403

2010-09-14 Thread noc
See 




Build failed in Hudson: 3.HEAD-i386-OpenBSD #565

2010-09-14 Thread noc
See 

Changes:

[Alex Rousskov ] Do not send chunked requests 
without a "Transfer-Encoding: chunked" header
or with a "Content-Length: 0" header.

Whether we are sending a chunked request depends not just on whether the
received request was chunked (condition A) but also on whether we still do not
know the request body size (condition B). The old code added the
"Transfer-Encoding: chunked" header if (A && B) but chunked the request body
if (A). This resulted in malformed requests with chunked request bodies but
without the "Transfer-Encoding: chunked" header.

When adding the Transfer-Encoding field, the old code also considered zero
Content-Length as "unknown", which was, apparently wrong. This resulted in the
"Content-Length: 0" header sent with a chunked encoded [empty] body, violating
HTTP rules. I am not 100% sure we never use zero request->content_length value
to mark "unknown" length though, so this may need more work.

based on lp 3p2-plus branch, r10827.

[Alex Rousskov ] Prohibit fruitless 
modification of httpBuildRequestHeader flags parameter.

HttpStateData::httpBuildRequestHeader is a static method, but it has a
parameter called flags, just like HttpStateData objects have a data member
called flags. Modifying that parameter "worked" but had no effect on the
caller's flags. Wasted a few good hours.

The parameter is "const" now, to prevent fruitless modification.

Also removed http_state_flags parameter from HttpStateData::buildRequestPrefix
which is not a static method and has access to the "real" flags member.

No runtime effect expected.

TODO: Rename HttpStateData::httpBuildRequestHeader to mark its static nature.
Does it belong to HttpStateData at all?

--
[...truncated 3097 lines...]
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: strcat() is almost always misused, please use strlcat()
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: sprintf() is often misused, please use snprintf()
Making all in POP3
sed -e 's,[...@]perl[@],/usr/bin/perl,g' 
<../../../../helpers/basic_auth/POP3/basic_pop3_auth.pl.in >basic_pop3_auth || 
(/bin/rm -f -f basic_pop3_auth ; exit 1)
Making all in RADIUS
if ccache g++ -DHAVE_CONFIG_H  -I../../../.. -I../../../../include 
-I../../../../src  -I../../../include -I/usr/local/include
-I../../../../helpers/basic_auth/RADIUS-Wall -Wpointer-arith 
-Wwrite-strings -Wcomments -Werror -pipe -D_REENTRANT -g -O2 -MT 
basic_radius_auth.o -MD -MP -MF ".deps/basic_radius_auth.Tpo" -c -o 
basic_radius_auth.o ../../../../helpers/basic_auth/RADIUS/basic_radius_auth.cc; 
 then mv -f ".deps/basic_radius_auth.Tpo" ".deps/basic_radius_auth.Po"; else rm 
-f ".deps/basic_radius_auth.Tpo"; exit 1; fi
if ccache g++ -DHAVE_CONFIG_H  -I../../../.. -I../../../../include 
-I../../../../src  -I../../../include -I/usr/local/include
-I../../../../helpers/basic_auth/RADIUS-Wall -Wpointer-arith 
-Wwrite-strings -Wcomments -Werror -pipe -D_REENTRANT -g -O2 -MT radius-util.o 
-MD -MP -MF ".deps/radius-util.Tpo" -c -o radius-util.o 
../../../../helpers/basic_auth/RADIUS/radius-util.cc;  then mv -f 
".deps/radius-util.Tpo" ".deps/radius-util.Po"; else rm -f 
".deps/radius-util.Tpo"; exit 1; fi
/bin/sh ../../../libtool --tag=CXX --mode=link ccache g++ -Wall -Wpointer-arith 
-Wwrite-strings -Wcomments -Werror -pipe -D_REENTRANT  -g -O2  -g -o 
basic_radius_auth  basic_radius_auth.o  radius-util.o -L../../../lib -lmiscutil 
 ../../../compat/libcompat.la-lm 
libtool: link: ccache g++ -Wall -Wpointer-arith -Wwrite-strings -Wcomments 
-Werror -pipe -D_REENTRANT -g -O2 -g -o basic_radius_auth basic_radius_auth.o 
radius-util.o  
-L
 -lmiscutil ../../../compat/.libs/libcompat.a -lm
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: vsprintf() is often misused, please use vsnprintf()
basic_radius_auth.o(.text+0x128): In function `main':
../../../../helpers/basic_auth/RADIUS/basic_radius_auth.cc:471: warning: 
strcpy() is almost always misused, please use strlcpy()
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: strcat() is almost always misused, please use strlcat()
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: sprintf() is often misused, please use snprintf()
Making all in fake
if ccache g++ -DHAVE_CONFIG_H  -I../../../.. -I../../../../include 
-I../../../../src  -I../../../include -I/usr/local/include   -Wall 
-Wpointer-arith -Wwrite-strings -Wcomments -Werror -pipe -D_REENTRANT -g -O2 
-MT fake.o -MD -MP -MF ".deps/fake.Tpo" -c -o fake.o 
../../../../helpers/basic_auth/fake/fake.cc;  then mv -f ".deps/fake.Tpo" 
".deps/fake.Po"; else rm -f ".deps/fake.Tpo"; exit 1; fi
/bin/sh ../.

Build failed in Hudson: 3.HEAD-i386-OpenBSD #564

2010-09-14 Thread noc
See 

Changes:

[Alex Rousskov ] Prohibit fruitless 
modification of httpBuildRequestHeader flags parameter.

HttpStateData::httpBuildRequestHeader is a static method, but it has a
parameter called flags, just like HttpStateData objects have a data member
called flags. Modifying that parameter "worked" but had no effect on the
caller's flags. Wasted a few good hours.

The parameter is "const" now, to prevent fruitless modification.

Also removed http_state_flags parameter from HttpStateData::buildRequestPrefix
which is not a static method and has access to the "real" flags member.

No runtime effect expected.

TODO: Rename HttpStateData::httpBuildRequestHeader to mark its static nature.
Does it belong to HttpStateData at all?

[Amos Jeffries ] Additional tools may use 
malloc/calloc/free

--
[...truncated 3097 lines...]
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: strcat() is almost always misused, please use strlcat()
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: sprintf() is often misused, please use snprintf()
Making all in POP3
sed -e 's,[...@]perl[@],/usr/bin/perl,g' 
<../../../../helpers/basic_auth/POP3/basic_pop3_auth.pl.in >basic_pop3_auth || 
(/bin/rm -f -f basic_pop3_auth ; exit 1)
Making all in RADIUS
if ccache g++ -DHAVE_CONFIG_H  -I../../../.. -I../../../../include 
-I../../../../src  -I../../../include -I/usr/local/include
-I../../../../helpers/basic_auth/RADIUS-Wall -Wpointer-arith 
-Wwrite-strings -Wcomments -Werror -pipe -D_REENTRANT -g -O2 -MT 
basic_radius_auth.o -MD -MP -MF ".deps/basic_radius_auth.Tpo" -c -o 
basic_radius_auth.o ../../../../helpers/basic_auth/RADIUS/basic_radius_auth.cc; 
 then mv -f ".deps/basic_radius_auth.Tpo" ".deps/basic_radius_auth.Po"; else rm 
-f ".deps/basic_radius_auth.Tpo"; exit 1; fi
if ccache g++ -DHAVE_CONFIG_H  -I../../../.. -I../../../../include 
-I../../../../src  -I../../../include -I/usr/local/include
-I../../../../helpers/basic_auth/RADIUS-Wall -Wpointer-arith 
-Wwrite-strings -Wcomments -Werror -pipe -D_REENTRANT -g -O2 -MT radius-util.o 
-MD -MP -MF ".deps/radius-util.Tpo" -c -o radius-util.o 
../../../../helpers/basic_auth/RADIUS/radius-util.cc;  then mv -f 
".deps/radius-util.Tpo" ".deps/radius-util.Po"; else rm -f 
".deps/radius-util.Tpo"; exit 1; fi
/bin/sh ../../../libtool --tag=CXX --mode=link ccache g++ -Wall -Wpointer-arith 
-Wwrite-strings -Wcomments -Werror -pipe -D_REENTRANT  -g -O2  -g -o 
basic_radius_auth  basic_radius_auth.o  radius-util.o -L../../../lib -lmiscutil 
 ../../../compat/libcompat.la-lm 
libtool: link: ccache g++ -Wall -Wpointer-arith -Wwrite-strings -Wcomments 
-Werror -pipe -D_REENTRANT -g -O2 -g -o basic_radius_auth basic_radius_auth.o 
radius-util.o  
-L
 -lmiscutil ../../../compat/.libs/libcompat.a -lm
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: vsprintf() is often misused, please use vsnprintf()
basic_radius_auth.o(.text+0x128): In function `main':
../../../../helpers/basic_auth/RADIUS/basic_radius_auth.cc:471: warning: 
strcpy() is almost always misused, please use strlcpy()
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: strcat() is almost always misused, please use strlcat()
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: sprintf() is often misused, please use snprintf()
Making all in fake
if ccache g++ -DHAVE_CONFIG_H  -I../../../.. -I../../../../include 
-I../../../../src  -I../../../include -I/usr/local/include   -Wall 
-Wpointer-arith -Wwrite-strings -Wcomments -Werror -pipe -D_REENTRANT -g -O2 
-MT fake.o -MD -MP -MF ".deps/fake.Tpo" -c -o fake.o 
../../../../helpers/basic_auth/fake/fake.cc;  then mv -f ".deps/fake.Tpo" 
".deps/fake.Po"; else rm -f ".deps/fake.Tpo"; exit 1; fi
/bin/sh ../../../libtool --tag=CXX --mode=link ccache g++ -Wall -Wpointer-arith 
-Wwrite-strings -Wcomments -Werror -pipe -D_REENTRANT  -g -O2  -g -o 
basic_fake_auth  fake.o -L../../../lib -lmiscutil  ../../../compat/libcompat.la 
libtool: link: ccache g++ -Wall -Wpointer-arith -Wwrite-strings -Wcomments 
-Werror -pipe -D_REENTRANT -g -O2 -g -o basic_fake_auth fake.o  
-L
 -lmiscutil ../../../compat/.libs/libcompat.a
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: vsprintf() is often misused, please use vsnprintf()
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: strcpy() is almost always misused, please use strlcpy()
/usr/local/lib/gcc/i386-unknown-openbsd4.7/4.2.4/../../../libestdc++.so.11.0: 
warning: strcat() is alm