merge sctp_opt with sctp_sock
Subsystems (3)
PATCH 1/1 merge sctp_opt with sctp_sock
Hi David, Sridhar,
Please take a look and if its acceptable pull from:
bk://kernel.bkbits.net/acme/connection_sock-2.6
The tricky bit here is that SCTP, to keep the existing logic,
needs a way to copy only its private area from one sock to another, so I introduced a generic inet_sk_copy_descendant, that knows about the inet (v4/v6) layout (wrt inet_sock and inet6_pinfo), using this and sk->sk_prot->slab_obj_size we can copy the inet_sock descendant private area generically.
Best Regards,
- Arnaldo
===================================================================
[email protected], 2005-01-15 02:32:54-02:00, [email protected]
[SCTP] merge sctp_sock with sctp_opt
No need for two structs, follow the new inet_sock layout style.
Also introduce inet_sk_copy_descendant, to copy just the inet_sock descendant specific area from one sock to another.
include/linux/ip.h | 14 +++++++++ include/linux/ipv6.h | 11 +++++++ include/net/sctp/sctp.h | 19 ------------- include/net/sctp/structs.h | 44 +++++++++++++++++++++--------- net/sctp/associola.c | 8 ++--- net/sctp/bind_addr.c | 4 +- net/sctp/chunk.c | 2 - net/sctp/endpointola.c | 2 - net/sctp/ipv6.c | 20 +++++++------- net/sctp/output.c | 4 +- net/sctp/protocol.c | 16 +++++------ net/sctp/sm_make_chunk.c | 2 - net/sctp/socket.c | 64 ++++++++++++++++++++++----------------------- net/sctp/transport.c | 2 - net/sctp/ulpqueue.c | 3 -- 15 files changed, 120 insertions(+), 95 deletions(-)
include/linux/ip.h +14 -0
@@ -158,6 +158,20 @@return (struct inet_sock *)sk; } +static inline void __inet_sk_copy_descendant (struct sock *sk_to, +const struct sock *sk_from, +const int ancestor_size) +{ +memcpy (inet_sk (sk_to) +1 ,inet_sk (sk_from) +1 , + sk_from->sk_prot->slab_obj_size - ancestor_size); +} +#if !(defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE )) +static inline void inet_sk_copy_descendant (struct sock *sk_to, +const struct sock *sk_from) +{ +__inet_sk_copy_descendant (sk_to, sk_from,sizeof (struct inet_sock )); +} +#endif #endif struct iphdr {
include/linux/ipv6.h +11 -0
@@ -282,6 +282,17 @@ return &((struct raw6_sock *)__sk)->raw6; } +static inline void inet_sk_copy_descendant (struct sock *sk_to, +const struct sock *sk_from) +{ +int ancestor_size =sizeof (struct inet_sock ); + +if (sk_from->sk_family ==PF_INET6 ) + ancestor_size +=sizeof (struct ipv6_pinfo ); + +__inet_sk_copy_descendant (sk_to, sk_from, ancestor_size); +} +#define __ipv6_only_sock (sk) (inet6_sk(sk)->ipv6only)#define ipv6_only_sock (sk) ((sk)->sk_family == PF_INET6 && __ipv6_only_sock(sk))#else
include/net/sctp/sctp.h +1 -18
@@ -423,7 +423,7 @@ }/* Break down data chunks at this point. */ -static inline int sctp_frag_point (const struct sctp_opt *sp,int pmtu) +static inline int sctp_frag_point (const struct sctp_sock *sp,int pmtu) {int frag = pmtu;
@@ -575,23 +575,6 @@ h ^= vtag;return (h & (sctp_assoc_hashsize-1 )); } - -/* WARNING: Do not change the layout of the members in sctp_sock! */ -struct sctp_sock { -struct inet_sock inet; -struct sctp_opt sctp; -}; - -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) -struct sctp6_sock { -struct inet_sock inet; -struct sctp_opt sctp; -struct ipv6_pinfo inet6; -}; -#endif /* CONFIG_IPV6 */ - -#define sctp_sk (__sk) (&((struct sctp_sock *)__sk)->sctp) -#define sctp_opt2sk (__sp) &container_of(__sp, struct sctp_sock, sctp)->inet.sk/* Is a socket of this style? */ #define sctp_style (sk, style) __sctp_style((sk), (SCTP_SOCKET_##style))
include/net/sctp/structs.h +31 -13
103 lines not on this page · raw message
net/sctp/associola.c +4 -4
@@ -73,7 +73,7 @@ sctp_scope_t scope, int gfp) { -struct sctp_opt *sp; +struct sctp_sock *sp;int i;/* Retrieve the SCTP per socket area. */
@@ -434,7 +434,7 @@ int gfp) {struct sctp_transport *peer; -struct sctp_opt *sp; +struct sctp_sock *sp;unsigned short port; sp =sctp_sk (asoc->base.sk);
@@ -886,7 +886,7 @@/* This routine moves an association from its old sk to a new sk. */ void sctp_assoc_migrate (struct sctp_association *assoc,struct sock *newsk) { -struct sctp_opt *newsp =sctp_sk (newsk); +struct sctp_sock *newsp =sctp_sk (newsk);struct sock *oldsk = assoc->base.sk;/* Delete the association from the old endpoint's list of
@@ -1059,7 +1059,7 @@ }if (pmtu) { -struct sctp_opt *sp =sctp_sk (asoc->base.sk); +struct sctp_sock *sp =sctp_sk (asoc->base.sk); asoc->pmtu = pmtu; asoc->frag_point =sctp_frag_point (sp, pmtu); }
net/sctp/bind_addr.c +2 -2
@@ -293,7 +293,7 @@/* Does this contain a specified address? Allow wildcarding. */ int sctp_bind_addr_match (struct sctp_bind_addr *bp,const union sctp_addr *addr, -struct sctp_opt *opt) +struct sctp_sock *opt) {struct sctp_sockaddr_entry *laddr;struct list_head *pos;
@@ -313,7 +313,7 @@union sctp_addr *sctp_find_unmatch_addr (struct sctp_bind_addr *bp,const union sctp_addr *addrs,int addrcnt, -struct sctp_opt *opt) +struct sctp_sock *opt) {struct sctp_sockaddr_entry *laddr;union sctp_addr *addr;
net/sctp/chunk.c +1 -1
@@ -77,7 +77,7 @@ {struct list_head *pos, *temp;struct sctp_chunk *chunk; -struct sctp_opt *sp; +struct sctp_sock *sp;struct sctp_ulpevent *ev;struct sctp_association *asoc =NULL ;int error =0 , notify;
net/sctp/endpointola.c +1 -1
@@ -69,7 +69,7 @@static struct sctp_endpoint *sctp_endpoint_init (struct sctp_endpoint *ep,struct sock *sk,int gfp) { -struct sctp_opt *sp =sctp_sk (sk); +struct sctp_sock *sp =sctp_sk (sk);memset (ep,0 ,sizeof (struct sctp_endpoint ));/* Initialize the base structure. */
net/sctp/ipv6.c +10 -10
@@ -502,7 +502,7 @@ }/* Should this be available for binding? */ -static int sctp_v6_available (union sctp_addr *addr,struct sctp_opt *sp) +static int sctp_v6_available (union sctp_addr *addr,struct sctp_sock *sp) {int type;struct in6_addr *in6 = (struct in6_addr *)&addr->v6.sin6_addr;
@@ -531,14 +531,14 @@* Return 0 - If the address is a non-unicast or an illegal address. * Return 1 - If the address is a unicast. */ -static int sctp_v6_addr_valid (union sctp_addr *addr,struct sctp_opt *sp) +static int sctp_v6_addr_valid (union sctp_addr *addr,struct sctp_sock *sp) {int ret =ipv6_addr_type (&addr->v6.sin6_addr);/* Support v4-mapped-v6 address. */ if (ret ==IPV6_ADDR_MAPPED ) {/* Note: This routine is used in input, so v4-mapped-v6 -* are disallowed here when there is no sctp_opt. +* are disallowed here when there is no sctp_sock. */ if (!sp || !sp->v4mapped)return 0 ;
@@ -616,7 +616,7 @@ newsk->sk_shutdown = sk->sk_shutdown; newsctp6sk = (struct sctp6_sock *)newsk; - newsctp6sk->inet.pinet6 = &newsctp6sk->inet6; +inet_sk (newsk)->pinet6 = &newsctp6sk->inet6; newinet =inet_sk (newsk); newnp =inet6_sk (newsk);
@@ -661,7 +661,7 @@ }/* Map v4 address to mapped v6 address */ -static void sctp_v6_addr_v4map (struct sctp_opt *sp,union sctp_addr *addr) +static void sctp_v6_addr_v4map (struct sctp_sock *sp,union sctp_addr *addr) {if (sp->v4mapped &&AF_INET == addr->sa.sa_family)sctp_v4_map_v6 (addr);
@@ -766,7 +766,7 @@ }/* Do we support this AF? */ -static int sctp_inet6_af_supported (sa_family_t family,struct sctp_opt *sp) +static int sctp_inet6_af_supported (sa_family_t family,struct sctp_sock *sp) {switch (family) {case AF_INET6 :
@@ -786,7 +786,7 @@*/ static int sctp_inet6_cmp_addr (const union sctp_addr *addr1,const union sctp_addr *addr2, -struct sctp_opt *opt) +struct sctp_sock *opt) {struct sctp_af *af1, *af2;
@@ -808,7 +808,7 @@/* Verify that the provided sockaddr looks bindable. Common verification, * has already been taken care of. */ -static int sctp_inet6_bind_verify (struct sctp_opt *opt,union sctp_addr *addr) +static int sctp_inet6_bind_verify (struct sctp_sock *opt,union sctp_addr *addr) {struct sctp_af *af;
@@ -838,7 +838,7 @@/* Verify that the provided sockaddr looks bindable. Common verification, * has already been taken care of. */ -static int sctp_inet6_send_verify (struct sctp_opt *opt,union sctp_addr *addr) +static int sctp_inet6_send_verify (struct sctp_sock *opt,union sctp_addr *addr) {struct sctp_af *af =NULL ;
@@ -872,7 +872,7 @@* addresses. * Returns number of addresses supported. */ -static int sctp_inet6_supported_addrs (const struct sctp_opt *opt, +static int sctp_inet6_supported_addrs (const struct sctp_sock *opt,__u16 *types) { types[0 ] =SCTP_PARAM_IPV4_ADDRESS ;
net/sctp/output.c +2 -2
@@ -110,7 +110,7 @@ packet->destination_port = dport;skb_queue_head_init (&packet->chunks);if (asoc) { -struct sctp_opt *sp =sctp_sk (asoc->base.sk); +struct sctp_sock *sp =sctp_sk (asoc->base.sk); overhead = sp->pf->af->net_header_len; }else { overhead =sizeof (struct ipv6hdr );
@@ -534,7 +534,7 @@struct sctp_transport *transport = packet->transport;__u32 max_burst_bytes;struct sctp_association *asoc = transport->asoc; -struct sctp_opt *sp =sctp_sk (asoc->base.sk); +struct sctp_sock *sp =sctp_sk (asoc->base.sk);struct sctp_outq *q = &asoc->outqueue;/* RFC 2960 6.1 Transmission of DATA Chunks
net/sctp/protocol.c +8 -8
@@ -364,7 +364,7 @@* Return 0 - If the address is a non-unicast or an illegal address. * Return 1 - If the address is a unicast. */ -static int sctp_v4_addr_valid (union sctp_addr *addr,struct sctp_opt *sp) +static int sctp_v4_addr_valid (union sctp_addr *addr,struct sctp_sock *sp) {/* Is this a non-unicast address or a unusable SCTP address? */ if (IS_IPV4_UNUSABLE_ADDRESS (&addr->v4.sin_addr.s_addr))
@@ -374,7 +374,7 @@ }/* Should this be available for binding? */ -static int sctp_v4_available (union sctp_addr *addr,struct sctp_opt *sp) +static int sctp_v4_available (union sctp_addr *addr,struct sctp_sock *sp) {int ret =inet_addr_type (addr->v4.sin_addr.s_addr);
@@ -608,7 +608,7 @@ }/* Map address, empty for v4 family */ -static void sctp_v4_addr_v4map (struct sctp_opt *sp,union sctp_addr *addr) +static void sctp_v4_addr_v4map (struct sctp_sock *sp,union sctp_addr *addr) {/* Empty */ }
@@ -745,7 +745,7 @@ }/* Do we support this AF? */ -static int sctp_inet_af_supported (sa_family_t family,struct sctp_opt *sp) +static int sctp_inet_af_supported (sa_family_t family,struct sctp_sock *sp) {/* PF_INET only supports AF_INET addresses. */ return (AF_INET == family);
@@ -754,7 +754,7 @@/* Address matching with wildcards allowed. */ static int sctp_inet_cmp_addr (const union sctp_addr *addr1,const union sctp_addr *addr2, -struct sctp_opt *opt) +struct sctp_sock *opt) {/* PF_INET only supports AF_INET addresses. */ if (addr1->sa.sa_family != addr2->sa.sa_family)
@@ -771,7 +771,7 @@/* Verify that provided sockaddr looks bindable. Common verification has * already been taken care of. */ -static int sctp_inet_bind_verify (struct sctp_opt *opt,union sctp_addr *addr) +static int sctp_inet_bind_verify (struct sctp_sock *opt,union sctp_addr *addr) {return sctp_v4_available (addr, opt); }
@@ -779,7 +779,7 @@/* Verify that sockaddr looks sendable. Common verification has already * been taken care of. */ -static int sctp_inet_send_verify (struct sctp_opt *opt,union sctp_addr *addr) +static int sctp_inet_send_verify (struct sctp_sock *opt,union sctp_addr *addr) {return 1 ; }
@@ -787,7 +787,7 @@/* Fill in Supported Address Type information for INIT and INIT-ACK * chunks. Returns number of addresses supported. */ -static int sctp_inet_supported_addrs (const struct sctp_opt *opt, +static int sctp_inet_supported_addrs (const struct sctp_sock *opt,__u16 *types) { types[0 ] =SCTP_PARAM_IPV4_ADDRESS ;
net/sctp/sm_make_chunk.c +1 -1
@@ -181,7 +181,7 @@size_t chunksize;struct sctp_chunk *retval =NULL ;int num_types, addrs_len =0 ; -struct sctp_opt *sp; +struct sctp_sock *sp;sctp_supported_addrs_param_t sat;__u16 types[2 ];sctp_adaption_ind_param_t aiparam;
net/sctp/socket.c +32 -32
250 lines not on this page · raw message
net/sctp/transport.c +1 -1
@@ -237,7 +237,7 @@* address. */ void sctp_transport_route (struct sctp_transport *transport, -union sctp_addr *saddr,struct sctp_opt *opt) +union sctp_addr *saddr,struct sctp_sock *opt) {struct sctp_association *asoc = transport->asoc;struct sctp_af *af = transport->af_specific;
net/sctp/ulpqueue.c +1 -2
@@ -138,8 +138,7 @@*/ int sctp_clear_pd (struct sock *sk) { -struct sctp_opt *sp; - sp =sctp_sk (sk); +struct sctp_sock *sp =sctp_sk (sk); sp->pd_mode =0 ;if (!skb_queue_empty (&sp->pd_lobby)) {
David S. Miller
maintainerQuoted 10 lines · On Sat, 15 Jan 2005 02:52:13 -0200 Arnaldo Carvalho de Melo…
Please take a look and if its acceptable pull from:
bk://kernel.bkbits.net/acme/connection_sock-2.6
The tricky bit here is that SCTP, to keep the existing logic,
needs a way to copy only its private area from one sock to another, so I introduced a genericinet_sk_copy_descendant, that knows about the inet (v4/v6) layout (wrtinet_sockandinet6_pinfo), using this andsk->sk_prot->slab_obj_sizewe can copy theinet_sockdescendant private area generically.
This looks fine, although I wish the descendant copying thing could be done more cleanly somehow.
Pulled.
David S. Miller escreveu:
Quoted 16 lines
Quoted 10 lines · On Sat, 15 Jan 2005 02:52:13 -0200 Arnaldo Carvalho de Melo…
Please take a look and if its acceptable pull from:
bk://kernel.bkbits.net/acme/connection_sock-2.6
The tricky bit here is that SCTP, to keep the existing logic,
needs a way to copy only its private area from one sock to another, so I introduced a genericinet_sk_copy_descendant, that knows about the inet (v4/v6) layout (wrtinet_sockandinet6_pinfo), using this andsk->sk_prot->slab_obj_sizewe can copy theinet_sockdescendant private area generically.
Quoted 2 lines
This looks fine, although I wish the descendant copying thing could be done more cleanly somehow.
/me too, but this is the best scheme I've found for now, perhaps in the future, after some more refactoring work is done/merged we can find some better way of doing this (tcp_create_openreq_child also does something like this, but does it in all the sock, perhaps SCTP can do something similar).
In fact my ambition is after mucho refactoring have some common infrastructure even for child creation.
OK, back to chainsawing net/{ax25,netrom,rose} into a state where we can actually use a slab cache for each of them, which is needed to get the connection_sock abstraction into place, most of the work is done, now I'm reading some HAM radio howtos and preparing a testbed using bpqether, etc. Oh, there is another legacy family to send to you first: IPv6 ;)
Quoted 1 line
Pulled.
Thanks.
- Arnaldo
Quoted 17 lines · Arnaldo Carvalho de Melo
David S. Miller escreveu:
Quoted 16 lines
Quoted 10 lines · On Sat, 15 Jan 2005 02:52:13 -0200 Arnaldo Carvalho de Melo…
Please take a look and if its acceptable pull from:
bk://kernel.bkbits.net/acme/connection_sock-2.6
The tricky bit here is that SCTP, to keep the existing logic,
needs a way to copy only its private area from one sock to another, so I introduced a genericinet_sk_copy_descendant, that knows about the inet (v4/v6) layout (wrtinet_sockandinet6_pinfo), using this andsk->sk_prot->slab_obj_sizewe can copy theinet_sockdescendant private area generically.
Quoted 8 lines
Quoted 2 lines
This looks fine, although I wish the descendant copying thing could be done more cleanly somehow.
/me too, but this is the best scheme I've found for now, perhaps in the future, after some more refactoring work is done/merged we can find some better way of doing this (
tcp_create_openreq_childalso does something like this, but does it in all the sock, perhaps SCTP can do something similar).
I thought you introduced this generic function so that other protocols also may use it. If you & Dave feel that this is not clean and is going to be needed only by SCTP, SCTP also could do a memcpy of the entire sock instead of only sctp private area before calling sctp_sock_migrate although it is not very straightforward. Let me know if i should work on a patch to do that.
Thanks
Sridhar
Sridhar Samudrala escreveu:
Quoted 32 lines · Arnaldo Carvalho de Melo
Quoted 21 lines
David S. Miller escreveu:
Quoted 17 lines
Quoted 10 lines · On Sat, 15 Jan 2005 02:52:13 -0200 Arnaldo Carvalho de Melo…
Please take a look and if its acceptable pull from:
bk://kernel.bkbits.net/acme/connection_sock-2.6
The tricky bit here is that SCTP, to keep the existing logic,
needs a way to copy only its private area from one sock to another, so I introduced a genericinet_sk_copy_descendant, that knows about the inet (v4/v6) layout (wrtinet_sockandinet6_pinfo), using this andsk->sk_prot->slab_obj_sizewe can copy theinet_sockdescendant private area generically.Quoted 8 lines
Quoted 2 lines
This looks fine, although I wish the descendant copying thing could be done more cleanly somehow.
/me too, but this is the best scheme I've found for now, perhaps in the future, after some more refactoring work is done/merged we can find some better way of doing this (
tcp_create_openreq_childalso does something like this, but does it in all the sock, perhaps SCTP can do something similar).
Quoted 5 lines
I thought you introduced this generic function so that other protocols also may use it. If you & Dave feel that this is not clean and is going to be needed only by SCTP, SCTP also could do a memcpy of the entire sock instead of only sctp private area before calling
sctp_sock_migratealthough it is not very straightforward. Let me know if i should work on a patch to do that.
Sridhar, please leave it as is for now, perhaps some other protocol will need it, I still have decnet, econet, x.25, wanrouter, etc to go, and this is not something we should spend too much time for now, I think, I'm more than happy if you just tell me that this is equivalent to what we had before, i.e. that I didn't introduced any bugs 8)
- Arnaldo
Quoted 39 lines · Arnaldo Carvalho de Melo
Sridhar Samudrala escreveu:
Quoted 32 lines · Arnaldo Carvalho de Melo
Quoted 21 lines
David S. Miller escreveu:
Quoted 17 lines
Quoted 10 lines · On Sat, 15 Jan 2005 02:52:13 -0200 Arnaldo Carvalho de Melo…
Please take a look and if its acceptable pull from:
bk://kernel.bkbits.net/acme/connection_sock-2.6
The tricky bit here is that SCTP, to keep the existing logic,
needs a way to copy only its private area from one sock to another, so I introduced a genericinet_sk_copy_descendant, that knows about the inet (v4/v6) layout (wrtinet_sockandinet6_pinfo), using this andsk->sk_prot->slab_obj_sizewe can copy theinet_sockdescendant private area generically.Quoted 8 lines
Quoted 2 lines
This looks fine, although I wish the descendant copying thing could be done more cleanly somehow.
/me too, but this is the best scheme I've found for now, perhaps in the future, after some more refactoring work is done/merged we can find some better way of doing this (
tcp_create_openreq_childalso does something like this, but does it in all the sock, perhaps SCTP can do something similar).Quoted 5 lines
I thought you introduced this generic function so that other protocols also may use it. If you & Dave feel that this is not clean and is going to be needed only by SCTP, SCTP also could do a memcpy of the entire sock instead of only sctp private area before calling
sctp_sock_migratealthough it is not very straightforward. Let me know if i should work on a patch to do that.
Quoted 5 lines
Sridhar, please leave it as is for now, perhaps some other protocol will need it, I still have decnet, econet, x.25, wanrouter, etc to go, and this is not something we should spend too much time for now, I think, I'm more than happy if you just tell me that this is equivalent to what we had before, i.e. that I didn't introduced any bugs 8)
It looks fine and i don't see any issues. will try to pull from davem's tree and test to see that it doesn't break any SCTP regression tests.
-Sridhar