Re: [PATCH] reorganize include/linux/dccp.h
On 8/7/05, Arnaldo Carvalho de Melo <[EMAIL PROTECTED]> wrote: > Em Sun, Aug 07, 2005 at 04:59:27PM +0200, Harald Welte escreveu: > > On Sun, Aug 07, 2005 at 04:13:16AM -0300, Arnaldo Carvalho de Melo wrote: > > > > you cannot include linux/in.h from the top of the file, I think I tried > > > > that and ran into problems (the definitions collide with glibc > > > > definitions e.g. of sockaddr_in, etc.) > > > > > > > > So if possible, move that include down to the __KERNEL__ section. At > > > > least this way iptables libipt_dccp.c compiles. > > > > > > Oh my, OK, I should be more careful about making sure kernel headers are > > > usable by userland programs ;-\ Nah, I'll fix that properly by just not > > > including linux/in.h at all and fixing sockaddr_dccp, take a look: > > > > ok, seems fine with me. > > > > Will you have some time to test the iptables dccp match? If not, do you I will, but not right now, I just finished generalising the TCP timewait engine, now implementing struct dccp_timewait_sock and gluing it to the "new" inet_timewait_death_row infrastructure. > > have any DCCP test programs (just establishing a session, ..)? This > > would help me with testing... > > http://oops.merseine.nu:81/dccp/ttcp.dccp.patch > http://oops.merseine.nu:81/dccp/libdnet-20050421.tar.bz2 > http://oops.merseine.nu:81/dccp/libdnet-20050421.dccp.patch > > - Arnaldo > - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] reorganize include/linux/dccp.h
Em Sun, Aug 07, 2005 at 04:59:27PM +0200, Harald Welte escreveu: > On Sun, Aug 07, 2005 at 04:13:16AM -0300, Arnaldo Carvalho de Melo wrote: > > > you cannot include linux/in.h from the top of the file, I think I tried > > > that and ran into problems (the definitions collide with glibc > > > definitions e.g. of sockaddr_in, etc.) > > > > > > So if possible, move that include down to the __KERNEL__ section. At > > > least this way iptables libipt_dccp.c compiles. > > > > Oh my, OK, I should be more careful about making sure kernel headers are > > usable by userland programs ;-\ Nah, I'll fix that properly by just not > > including linux/in.h at all and fixing sockaddr_dccp, take a look: > > ok, seems fine with me. > > Will you have some time to test the iptables dccp match? If not, do you > have any DCCP test programs (just establishing a session, ..)? This > would help me with testing... http://oops.merseine.nu:81/dccp/ttcp.dccp.patch http://oops.merseine.nu:81/dccp/libdnet-20050421.tar.bz2 http://oops.merseine.nu:81/dccp/libdnet-20050421.dccp.patch - Arnaldo - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] reorganize include/linux/dccp.h
On Sun, Aug 07, 2005 at 04:13:16AM -0300, Arnaldo Carvalho de Melo wrote: > > you cannot include linux/in.h from the top of the file, I think I tried > > that and ran into problems (the definitions collide with glibc > > definitions e.g. of sockaddr_in, etc.) > > > > So if possible, move that include down to the __KERNEL__ section. At > > least this way iptables libipt_dccp.c compiles. > > Oh my, OK, I should be more careful about making sure kernel headers are > usable by userland programs ;-\ Nah, I'll fix that properly by just not > including linux/in.h at all and fixing sockaddr_dccp, take a look: ok, seems fine with me. Will you have some time to test the iptables dccp match? If not, do you have any DCCP test programs (just establishing a session, ..)? This would help me with testing... Cheers, Harald -- - Harald Welte <[EMAIL PROTECTED]> http://gnumonks.org/ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) pgpRfJA50ihL7.pgp Description: PGP signature
Re: [PATCH] reorganize include/linux/dccp.h
Em Sun, Aug 07, 2005 at 08:58:34AM +0200, Harald Welte escreveu: > On Sat, Aug 06, 2005 at 06:34:40PM -0300, Arnaldo Carvalho de Melo wrote: > > On 8/6/05, Harald Welte <[EMAIL PROTECTED]> wrote: > > > Hi Arnaldo! > > > > > > The protocol header files in are usually structured in a > > > way to be included by userspace code. The top section consists of > > > general protocol structure definitions, typedefs, enums - followed by an > > > #ifdef __KERNEL__ section. > > > > > > Currently doesn't follow that convention and can > > > therefore not be used from userspace. However, e.g. iptables' > > > libipt_dccp.c actually needs various definitions. > > > > > > Below is a proposed patch to clean up dccp.h. Please review and > > > consider applying it. Thanks! > > > > > > [the iptables ipt_dccp patch applies cleanly on top of this - but not > > > the other way around] > > > > OK, I'm applying both patches, just had to add an include for linux/in.h > > that > > was missing, thanks! > > you cannot include linux/in.h from the top of the file, I think I tried > that and ran into problems (the definitions collide with glibc > definitions e.g. of sockaddr_in, etc.) > > So if possible, move that include down to the __KERNEL__ section. At > least this way iptables libipt_dccp.c compiles. Oh my, OK, I should be more careful about making sure kernel headers are usable by userland programs ;-\ Nah, I'll fix that properly by just not including linux/in.h at all and fixing sockaddr_dccp, take a look: diff --git a/include/linux/dccp.h b/include/linux/dccp.h --- a/include/linux/dccp.h +++ b/include/linux/dccp.h @@ -1,14 +1,17 @@ #ifndef _LINUX_DCCP_H #define _LINUX_DCCP_H -#include #include #include -/* FIXME: this is utterly wrong */ +/* Structure describing an Internet (DCCP) socket address. */ struct sockaddr_dccp { - struct sockaddr_in in; - unsigned intservice; + sa_family_t sdccp_family; /* Address family */ + unsigned short int sdccp_port; /* Port number */ + struct in_addr sdccp_addr; /* Internet address */ + unsigned intsdccp_service; /* Service */ + /* Pad to size of `struct sockaddr': 16 bytes . */ + unsignd int sdccp_pad; }; /** Better? :-) - Arnaldo - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] reorganize include/linux/dccp.h
On Sat, Aug 06, 2005 at 06:34:40PM -0300, Arnaldo Carvalho de Melo wrote: > On 8/6/05, Harald Welte <[EMAIL PROTECTED]> wrote: > > Hi Arnaldo! > > > > The protocol header files in are usually structured in a > > way to be included by userspace code. The top section consists of > > general protocol structure definitions, typedefs, enums - followed by an > > #ifdef __KERNEL__ section. > > > > Currently doesn't follow that convention and can > > therefore not be used from userspace. However, e.g. iptables' > > libipt_dccp.c actually needs various definitions. > > > > Below is a proposed patch to clean up dccp.h. Please review and > > consider applying it. Thanks! > > > > [the iptables ipt_dccp patch applies cleanly on top of this - but not > > the other way around] > > OK, I'm applying both patches, just had to add an include for linux/in.h that > was missing, thanks! you cannot include linux/in.h from the top of the file, I think I tried that and ran into problems (the definitions collide with glibc definitions e.g. of sockaddr_in, etc.) So if possible, move that include down to the __KERNEL__ section. At least this way iptables libipt_dccp.c compiles. > - Arnaldo -- - Harald Welte <[EMAIL PROTECTED]> http://gnumonks.org/ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) pgpFp6ckZeHAf.pgp Description: PGP signature
Re: [PATCH] reorganize include/linux/dccp.h
On 8/6/05, Harald Welte <[EMAIL PROTECTED]> wrote: > Hi Arnaldo! > > The protocol header files in are usually structured in a > way to be included by userspace code. The top section consists of > general protocol structure definitions, typedefs, enums - followed by an > #ifdef __KERNEL__ section. > > Currently doesn't follow that convention and can > therefore not be used from userspace. However, e.g. iptables' > libipt_dccp.c actually needs various definitions. > > Below is a proposed patch to clean up dccp.h. Please review and > consider applying it. Thanks! > > [the iptables ipt_dccp patch applies cleanly on top of this - but not > the other way around] OK, I'm applying both patches, just had to add an include for linux/in.h that was missing, thanks! - Arnaldo - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] reorganize include/linux/dccp.h
Hi Arnaldo! The protocol header files in are usually structured in a way to be included by userspace code. The top section consists of general protocol structure definitions, typedefs, enums - followed by an #ifdef __KERNEL__ section. Currently doesn't follow that convention and can therefore not be used from userspace. However, e.g. iptables' libipt_dccp.c actually needs various definitions. Below is a proposed patch to clean up dccp.h. Please review and consider applying it. Thanks! [the iptables ipt_dccp patch applies cleanly on top of this - but not the other way around] Cheers, Harald -- - Harald Welte <[EMAIL PROTECTED]> http://gnumonks.org/ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) [DCCP] make include-able from userspace The protocol header files in are usually structured in a way to be included by userspace code. The top section consists of general protocol structure definitions, typedefs, enums - followed by an #ifdef __KERNEL__ section. Currently doesn't follow that convention and can therefore not be used from userspace. However, for example iptables' libipt_dccp.c actually needs various definitions from there. Signed-off-by: Harald Welte <[EMAIL PROTECTED]> --- commit 328f1df306bf5ae317d399d15146daae7bbd8477 tree 2d5da11ab69a35124755f95ef8f6a61ff492b935 parent 627c49af0423f8f48a2f467c8b69f746ef1891bc author Harald Welte <[EMAIL PROTECTED]> Sa, 06 Aug 2005 23:17:00 +0200 committer Harald Welte <[EMAIL PROTECTED]> Sa, 06 Aug 2005 23:17:00 +0200 include/linux/dccp.h | 238 +- 1 files changed, 121 insertions(+), 117 deletions(-) diff --git a/include/linux/dccp.h b/include/linux/dccp.h --- a/include/linux/dccp.h +++ b/include/linux/dccp.h @@ -1,16 +1,8 @@ #ifndef _LINUX_DCCP_H #define _LINUX_DCCP_H -#include -#include #include -#include -#include - -#include -#include -#include -#include +#include /* FIXME: this is utterly wrong */ struct sockaddr_dccp { @@ -18,40 +10,6 @@ struct sockaddr_dccp { unsigned intservice; }; -enum dccp_state { - DCCP_OPEN = TCP_ESTABLISHED, - DCCP_REQUESTING = TCP_SYN_SENT, - DCCP_PARTOPEN = TCP_FIN_WAIT1, /* FIXME: - This mapping is horrible, but TCP has - no matching state for DCCP_PARTOPEN, - as TCP_SYN_RECV is already used by - DCCP_RESPOND, why don't stop using TCP - mapping of states? OK, now we don't use - sk_stream_sendmsg anymore, so doesn't - seem to exist any reason for us to - do the TCP mapping here */ - DCCP_LISTEN = TCP_LISTEN, - DCCP_RESPOND= TCP_SYN_RECV, - DCCP_CLOSING= TCP_CLOSING, - DCCP_TIME_WAIT = TCP_TIME_WAIT, - DCCP_CLOSED = TCP_CLOSE, - DCCP_MAX_STATES = TCP_MAX_STATES, -}; - -#define DCCP_STATE_MASK 0xf -#define DCCP_ACTION_FIN (1<<7) - -enum { - DCCPF_OPEN = TCPF_ESTABLISHED, - DCCPF_REQUESTING = TCPF_SYN_SENT, - DCCPF_PARTOPEN = TCPF_FIN_WAIT1, - DCCPF_LISTEN = TCPF_LISTEN, - DCCPF_RESPOND= TCPF_SYN_RECV, - DCCPF_CLOSING= TCPF_CLOSING, - DCCPF_TIME_WAIT = TCPF_TIME_WAIT, - DCCPF_CLOSED = TCPF_CLOSE, -}; - /** * struct dccp_hdr - generic part of DCCP packet header * @@ -94,11 +52,6 @@ struct dccp_hdr { #endif }; -static inline struct dccp_hdr *dccp_hdr(const struct sk_buff *skb) -{ - return (struct dccp_hdr *)skb->h.raw; -} - /** * struct dccp_hdr_ext - the low bits of a 48 bit seq packet * @@ -108,34 +61,6 @@ struct dccp_hdr_ext { __u32 dccph_seq_low; }; -static inline struct dccp_hdr_ext *dccp_hdrx(const struct sk_buff *skb) -{ - return (struct dccp_hdr_ext *)(skb->h.raw + sizeof(struct dccp_hdr)); -} - -static inline unsigned int dccp_basic_hdr_len(const struct sk_buff *skb) -{ - const struct dccp_hdr *dh = dccp_hdr(skb); - return sizeof(*dh) + (dh->dccph_x ? sizeof(struct dccp_hdr_ext) : 0); -} - -static inline __u64 dccp_hdr_seq(const struct sk_buff *skb) -{ - const struct dccp_hdr *dh = dccp_hdr(skb); -#if defined(__LITTLE_ENDIAN_BITFIELD) - __u64 seq_nr = ntohl(dh->dccph_seq << 8); -#elif defined(__BIG_ENDIAN_BITFIELD) - __u64 seq_nr = ntohl(dh->dccph_seq); -#else -#error "Adjust your defines" -#endif - - if (dh->dccph_x != 0) - seq_nr = (seq_nr << 32) + ntohl(dccp_hdrx(skb)->dccph_seq_low); - - return seq_nr; -} - /** * struct dccp_h