aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2005-12-14 02:15:40 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-01-03 16:10:37 -0500
commitca304b6104ffdd120bb6687a88a0625e58bc71cd (patch)
tree99bdf631af245808459a0a956350b9388eada7fc
parent8129765ac07c2455c927051e3a8b048b619b56ee (diff)
[IPV6]: Introduce inet6_rsk()
And inet6_rsk_offset in inet_request_sock, for the same reasons as inet_sock's pinfo6 member. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/ip.h4
-rw-r--r--include/linux/ipv6.h39
-rw-r--r--net/ipv4/inet_diag.c8
-rw-r--r--net/ipv6/inet6_connection_sock.c4
-rw-r--r--net/ipv6/tcp_ipv6.c19
5 files changed, 52 insertions, 22 deletions
diff --git a/include/linux/ip.h b/include/linux/ip.h
index 33e8a19a1a0f..5a560daeade5 100644
--- a/include/linux/ip.h
+++ b/include/linux/ip.h
@@ -110,6 +110,10 @@ struct ip_options {
110 110
111struct inet_request_sock { 111struct inet_request_sock {
112 struct request_sock req; 112 struct request_sock req;
113#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
114 u16 inet6_rsk_offset;
115 /* 2 bytes hole, try to pack */
116#endif
113 u32 loc_addr; 117 u32 loc_addr;
114 u32 rmt_addr; 118 u32 rmt_addr;
115 u16 rmt_port; 119 u16 rmt_port;
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index e0b922785d98..7d3e86d9576e 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -199,18 +199,17 @@ static inline int inet6_iif(const struct sk_buff *skb)
199 return IP6CB(skb)->iif; 199 return IP6CB(skb)->iif;
200} 200}
201 201
202struct tcp6_request_sock { 202struct inet6_request_sock {
203 struct tcp_request_sock req;
204 struct in6_addr loc_addr; 203 struct in6_addr loc_addr;
205 struct in6_addr rmt_addr; 204 struct in6_addr rmt_addr;
206 struct sk_buff *pktopts; 205 struct sk_buff *pktopts;
207 int iif; 206 int iif;
208}; 207};
209 208
210static inline struct tcp6_request_sock *tcp6_rsk(const struct request_sock *sk) 209struct tcp6_request_sock {
211{ 210 struct tcp_request_sock tcp6rsk_tcp;
212 return (struct tcp6_request_sock *)sk; 211 struct inet6_request_sock tcp6rsk_inet6;
213} 212};
214 213
215/** 214/**
216 * struct ipv6_pinfo - ipv6 private area 215 * struct ipv6_pinfo - ipv6 private area
@@ -304,6 +303,28 @@ static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk)
304 return inet_sk(__sk)->pinet6; 303 return inet_sk(__sk)->pinet6;
305} 304}
306 305
306static inline struct inet6_request_sock *
307 inet6_rsk(const struct request_sock *rsk)
308{
309 return (struct inet6_request_sock *)(((u8 *)rsk) +
310 inet_rsk(rsk)->inet6_rsk_offset);
311}
312
313static inline u32 inet6_rsk_offset(struct request_sock *rsk)
314{
315 return rsk->rsk_ops->obj_size - sizeof(struct inet6_request_sock);
316}
317
318static inline struct request_sock *inet6_reqsk_alloc(struct request_sock_ops *ops)
319{
320 struct request_sock *req = reqsk_alloc(ops);
321
322 if (req != NULL)
323 inet_rsk(req)->inet6_rsk_offset = inet6_rsk_offset(req);
324
325 return req;
326}
327
307static inline struct raw6_sock *raw6_sk(const struct sock *sk) 328static inline struct raw6_sock *raw6_sk(const struct sock *sk)
308{ 329{
309 return (struct raw6_sock *)sk; 330 return (struct raw6_sock *)sk;
@@ -361,6 +382,12 @@ static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk)
361 return NULL; 382 return NULL;
362} 383}
363 384
385static inline struct inet6_request_sock *
386 inet6_rsk(const struct request_sock *rsk)
387{
388 return NULL;
389}
390
364static inline struct raw6_sock *raw6_sk(const struct sock *sk) 391static inline struct raw6_sock *raw6_sk(const struct sock *sk)
365{ 392{
366 return NULL; 393 return NULL;
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 39061ed53cfd..3ce73b141d7e 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -489,9 +489,9 @@ static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk,
489#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) 489#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
490 if (r->idiag_family == AF_INET6) { 490 if (r->idiag_family == AF_INET6) {
491 ipv6_addr_copy((struct in6_addr *)r->id.idiag_src, 491 ipv6_addr_copy((struct in6_addr *)r->id.idiag_src,
492 &tcp6_rsk(req)->loc_addr); 492 &inet6_rsk(req)->loc_addr);
493 ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst, 493 ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst,
494 &tcp6_rsk(req)->rmt_addr); 494 &inet6_rsk(req)->rmt_addr);
495 } 495 }
496#endif 496#endif
497 nlh->nlmsg_len = skb->tail - b; 497 nlh->nlmsg_len = skb->tail - b;
@@ -553,13 +553,13 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
553 entry.saddr = 553 entry.saddr =
554#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) 554#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
555 (entry.family == AF_INET6) ? 555 (entry.family == AF_INET6) ?
556 tcp6_rsk(req)->loc_addr.s6_addr32 : 556 inet6_rsk(req)->loc_addr.s6_addr32 :
557#endif 557#endif
558 &ireq->loc_addr; 558 &ireq->loc_addr;
559 entry.daddr = 559 entry.daddr =
560#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) 560#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
561 (entry.family == AF_INET6) ? 561 (entry.family == AF_INET6) ?
562 tcp6_rsk(req)->rmt_addr.s6_addr32 : 562 inet6_rsk(req)->rmt_addr.s6_addr32 :
563#endif 563#endif
564 &ireq->rmt_addr; 564 &ireq->rmt_addr;
565 entry.dport = ntohs(ireq->rmt_port); 565 entry.dport = ntohs(ireq->rmt_port);
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index 04ff44344f90..fe874eeaa40c 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -61,7 +61,7 @@ struct request_sock *inet6_csk_search_req(const struct sock *sk,
61 lopt->nr_table_entries)]; 61 lopt->nr_table_entries)];
62 (req = *prev) != NULL; 62 (req = *prev) != NULL;
63 prev = &req->dl_next) { 63 prev = &req->dl_next) {
64 const struct tcp6_request_sock *treq = tcp6_rsk(req); 64 const struct inet6_request_sock *treq = inet6_rsk(req);
65 65
66 if (inet_rsk(req)->rmt_port == rport && 66 if (inet_rsk(req)->rmt_port == rport &&
67 req->rsk_ops->family == AF_INET6 && 67 req->rsk_ops->family == AF_INET6 &&
@@ -85,7 +85,7 @@ void inet6_csk_reqsk_queue_hash_add(struct sock *sk,
85{ 85{
86 struct inet_connection_sock *icsk = inet_csk(sk); 86 struct inet_connection_sock *icsk = inet_csk(sk);
87 struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt; 87 struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt;
88 const u32 h = inet6_synq_hash(&tcp6_rsk(req)->rmt_addr, 88 const u32 h = inet6_synq_hash(&inet6_rsk(req)->rmt_addr,
89 inet_rsk(req)->rmt_port, 89 inet_rsk(req)->rmt_port,
90 lopt->hash_rnd, lopt->nr_table_entries); 90 lopt->hash_rnd, lopt->nr_table_entries);
91 91
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 5a10d30cec4a..c2472d771664 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -656,7 +656,7 @@ out:
656static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req, 656static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
657 struct dst_entry *dst) 657 struct dst_entry *dst)
658{ 658{
659 struct tcp6_request_sock *treq = tcp6_rsk(req); 659 struct inet6_request_sock *treq = inet6_rsk(req);
660 struct ipv6_pinfo *np = inet6_sk(sk); 660 struct ipv6_pinfo *np = inet6_sk(sk);
661 struct sk_buff * skb; 661 struct sk_buff * skb;
662 struct ipv6_txoptions *opt = NULL; 662 struct ipv6_txoptions *opt = NULL;
@@ -722,8 +722,8 @@ done:
722 722
723static void tcp_v6_reqsk_destructor(struct request_sock *req) 723static void tcp_v6_reqsk_destructor(struct request_sock *req)
724{ 724{
725 if (tcp6_rsk(req)->pktopts) 725 if (inet6_rsk(req)->pktopts)
726 kfree_skb(tcp6_rsk(req)->pktopts); 726 kfree_skb(inet6_rsk(req)->pktopts);
727} 727}
728 728
729static struct request_sock_ops tcp6_request_sock_ops = { 729static struct request_sock_ops tcp6_request_sock_ops = {
@@ -956,7 +956,7 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
956 */ 956 */
957static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) 957static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
958{ 958{
959 struct tcp6_request_sock *treq; 959 struct inet6_request_sock *treq;
960 struct ipv6_pinfo *np = inet6_sk(sk); 960 struct ipv6_pinfo *np = inet6_sk(sk);
961 struct tcp_options_received tmp_opt; 961 struct tcp_options_received tmp_opt;
962 struct tcp_sock *tp = tcp_sk(sk); 962 struct tcp_sock *tp = tcp_sk(sk);
@@ -981,7 +981,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
981 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) 981 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
982 goto drop; 982 goto drop;
983 983
984 req = reqsk_alloc(&tcp6_request_sock_ops); 984 req = inet6_reqsk_alloc(&tcp6_request_sock_ops);
985 if (req == NULL) 985 if (req == NULL)
986 goto drop; 986 goto drop;
987 987
@@ -994,7 +994,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
994 tmp_opt.tstamp_ok = tmp_opt.saw_tstamp; 994 tmp_opt.tstamp_ok = tmp_opt.saw_tstamp;
995 tcp_openreq_init(req, &tmp_opt, skb); 995 tcp_openreq_init(req, &tmp_opt, skb);
996 996
997 treq = tcp6_rsk(req); 997 treq = inet6_rsk(req);
998 ipv6_addr_copy(&treq->rmt_addr, &skb->nh.ipv6h->saddr); 998 ipv6_addr_copy(&treq->rmt_addr, &skb->nh.ipv6h->saddr);
999 ipv6_addr_copy(&treq->loc_addr, &skb->nh.ipv6h->daddr); 999 ipv6_addr_copy(&treq->loc_addr, &skb->nh.ipv6h->daddr);
1000 TCP_ECN_create_request(req, skb->h.th); 1000 TCP_ECN_create_request(req, skb->h.th);
@@ -1035,7 +1035,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1035 struct request_sock *req, 1035 struct request_sock *req,
1036 struct dst_entry *dst) 1036 struct dst_entry *dst)
1037{ 1037{
1038 struct tcp6_request_sock *treq = tcp6_rsk(req); 1038 struct inet6_request_sock *treq = inet6_rsk(req);
1039 struct ipv6_pinfo *newnp, *np = inet6_sk(sk); 1039 struct ipv6_pinfo *newnp, *np = inet6_sk(sk);
1040 struct tcp6_sock *newtcp6sk; 1040 struct tcp6_sock *newtcp6sk;
1041 struct inet_sock *newinet; 1041 struct inet_sock *newinet;
@@ -1723,14 +1723,13 @@ static int tcp_v6_destroy_sock(struct sock *sk)
1723static void get_openreq6(struct seq_file *seq, 1723static void get_openreq6(struct seq_file *seq,
1724 struct sock *sk, struct request_sock *req, int i, int uid) 1724 struct sock *sk, struct request_sock *req, int i, int uid)
1725{ 1725{
1726 struct in6_addr *dest, *src;
1727 int ttd = req->expires - jiffies; 1726 int ttd = req->expires - jiffies;
1727 struct in6_addr *src = &inet6_rsk(req)->loc_addr;
1728 struct in6_addr *dest = &inet6_rsk(req)->rmt_addr;
1728 1729
1729 if (ttd < 0) 1730 if (ttd < 0)
1730 ttd = 0; 1731 ttd = 0;
1731 1732
1732 src = &tcp6_rsk(req)->loc_addr;
1733 dest = &tcp6_rsk(req)->rmt_addr;
1734 seq_printf(seq, 1733 seq_printf(seq,
1735 "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X " 1734 "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
1736 "%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p\n", 1735 "%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p\n",