summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@toy.ghostprotocols.net>2005-01-14 22:32:54 -0200
committerDavid S. Miller <davem@nuts.davemloft.net>2005-01-14 22:32:54 -0200
commitdbf390aca67ee01d93cb438a6e4f28897efcfcee (patch)
tree1d5029bf07a808e81aa15f2e6aae515ee50cd124 /include
parent62343f7629a612d82f0314777b17dff7807976dc (diff)
[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. Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/ip.h14
-rw-r--r--include/linux/ipv6.h11
-rw-r--r--include/net/sctp/sctp.h19
-rw-r--r--include/net/sctp/structs.h44
4 files changed, 57 insertions, 31 deletions
diff --git a/include/linux/ip.h b/include/linux/ip.h
index 3fe93474047d..487152a404f8 100644
--- a/include/linux/ip.h
+++ b/include/linux/ip.h
@@ -158,6 +158,20 @@ static inline struct inet_sock *inet_sk(const struct sock *sk)
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 {
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index f80c4b3f84a3..0dec5d2ff0c2 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -282,6 +282,17 @@ static inline struct raw6_opt * raw6_sk(const struct sock *__sk)
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
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index cca17d427c9d..960abfa48d68 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -423,7 +423,7 @@ static inline __s32 sctp_jitter(__u32 rto)
}
/* 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;
@@ -576,23 +576,6 @@ static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 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))
static inline int __sctp_style(const struct sock *sk, sctp_socket_type_t style)
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index dfa0dc43fb17..7e64cf6bda1e 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -58,6 +58,7 @@
#include <linux/socket.h> /* linux/in.h needs this!! */
#include <linux/in.h> /* We get struct sockaddr_in. */
#include <linux/in6.h> /* We get struct in6_addr */
+#include <linux/ipv6.h>
#include <asm/param.h> /* We get MAXHOSTNAMELEN. */
#include <asm/atomic.h> /* This gets us atomic counters. */
#include <linux/skbuff.h> /* We need sk_buff_head. */
@@ -84,7 +85,6 @@ struct sctp_inq;
struct sctp_outq;
struct sctp_bind_addr;
struct sctp_ulpq;
-struct sctp_opt;
struct sctp_ep_common;
struct sctp_ssnmap;
@@ -234,7 +234,9 @@ typedef enum {
} sctp_socket_type_t;
/* Per socket SCTP information. */
-struct sctp_opt {
+struct sctp_sock {
+ /* inet_sock has to be the first member of sctp_sock */
+ struct inet_sock inet;
/* What kind of a socket is this? */
sctp_socket_type_t type;
@@ -272,6 +274,22 @@ struct sctp_opt {
struct sk_buff_head pd_lobby;
};
+static inline struct sctp_sock *sctp_sk(const struct sock *sk)
+{
+ return (struct sctp_sock *)sk;
+}
+
+static inline struct sock *sctp_opt2sk(const struct sctp_sock *sp)
+{
+ return (struct sock *)sp;
+}
+
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+struct sctp6_sock {
+ struct sctp_sock sctp;
+ struct ipv6_pinfo inet6;
+};
+#endif /* CONFIG_IPV6 */
/* This is our APPLICATION-SPECIFIC state cookie.
@@ -487,12 +505,12 @@ struct sctp_af {
int (*to_addr_param) (const union sctp_addr *,
union sctp_addr_param *);
int (*addr_valid) (union sctp_addr *,
- struct sctp_opt *);
+ struct sctp_sock *);
sctp_scope_t (*scope) (union sctp_addr *);
void (*inaddr_any) (union sctp_addr *, unsigned short);
int (*is_any) (const union sctp_addr *);
int (*available) (union sctp_addr *,
- struct sctp_opt *);
+ struct sctp_sock *);
int (*skb_iif) (const struct sk_buff *sk);
int (*is_ce) (const struct sk_buff *sk);
void (*seq_dump_addr)(struct seq_file *seq,
@@ -510,16 +528,16 @@ int sctp_register_af(struct sctp_af *);
struct sctp_pf {
void (*event_msgname)(struct sctp_ulpevent *, char *, int *);
void (*skb_msgname) (struct sk_buff *, char *, int *);
- int (*af_supported) (sa_family_t, struct sctp_opt *);
+ int (*af_supported) (sa_family_t, struct sctp_sock *);
int (*cmp_addr) (const union sctp_addr *,
const union sctp_addr *,
- struct sctp_opt *);
- int (*bind_verify) (struct sctp_opt *, union sctp_addr *);
- int (*send_verify) (struct sctp_opt *, union sctp_addr *);
- int (*supported_addrs)(const struct sctp_opt *, __u16 *);
+ struct sctp_sock *);
+ int (*bind_verify) (struct sctp_sock *, union sctp_addr *);
+ int (*send_verify) (struct sctp_sock *, union sctp_addr *);
+ int (*supported_addrs)(const struct sctp_sock *, __u16 *);
struct sock *(*create_accept_sk) (struct sock *sk,
struct sctp_association *asoc);
- void (*addr_v4map) (struct sctp_opt *, union sctp_addr *);
+ void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
struct sctp_af *af;
};
@@ -922,7 +940,7 @@ struct sctp_transport *sctp_transport_new(const union sctp_addr *, int);
void sctp_transport_set_owner(struct sctp_transport *,
struct sctp_association *);
void sctp_transport_route(struct sctp_transport *, union sctp_addr *,
- struct sctp_opt *);
+ struct sctp_sock *);
void sctp_transport_pmtu(struct sctp_transport *);
void sctp_transport_free(struct sctp_transport *);
void sctp_transport_reset_timers(struct sctp_transport *);
@@ -1071,11 +1089,11 @@ int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *,
int gfp);
int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *);
int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *,
- struct sctp_opt *);
+ struct sctp_sock *);
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);
union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,
int *addrs_len, int gfp);
int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len,