diff options
author | Eric Dumazet <edumazet@google.com> | 2015-03-18 17:05:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-18 22:00:34 -0400 |
commit | d1e559d0b1b0d02f76a6bd5b768a99dc834ae926 (patch) | |
tree | 283048c1921aeec1c2dfb25e72e6e67cddffcb23 /net/dccp | |
parent | 5b441f76f1b83591e8cd9d60ba1df3a2aacde27f (diff) |
inet: add IPv6 support to sk_ehashfn()
Intent is to converge IPv4 & IPv6 inet_hash functions to
factorize code.
IPv4 sockets initialize sk_rcv_saddr and sk_v6_daddr
in this patch, thanks to new sk_daddr_set() and sk_rcv_saddr_set()
helpers.
__inet6_hash can now use sk_ehashfn() instead of a private
inet6_sk_ehashfn() and will simply use __inet_hash() in a
following patch.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp')
-rw-r--r-- | net/dccp/ipv4.c | 9 | ||||
-rw-r--r-- | net/dccp/ipv6.c | 10 |
2 files changed, 6 insertions, 13 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index bf897829f4f0..f3f8906f482e 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -89,10 +89,9 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
89 | 89 | ||
90 | if (inet->inet_saddr == 0) | 90 | if (inet->inet_saddr == 0) |
91 | inet->inet_saddr = fl4->saddr; | 91 | inet->inet_saddr = fl4->saddr; |
92 | inet->inet_rcv_saddr = inet->inet_saddr; | 92 | sk_rcv_saddr_set(sk, inet->inet_saddr); |
93 | |||
94 | inet->inet_dport = usin->sin_port; | 93 | inet->inet_dport = usin->sin_port; |
95 | inet->inet_daddr = daddr; | 94 | sk_daddr_set(sk, daddr); |
96 | 95 | ||
97 | inet_csk(sk)->icsk_ext_hdr_len = 0; | 96 | inet_csk(sk)->icsk_ext_hdr_len = 0; |
98 | if (inet_opt) | 97 | if (inet_opt) |
@@ -408,8 +407,8 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
408 | 407 | ||
409 | newinet = inet_sk(newsk); | 408 | newinet = inet_sk(newsk); |
410 | ireq = inet_rsk(req); | 409 | ireq = inet_rsk(req); |
411 | newinet->inet_daddr = ireq->ir_rmt_addr; | 410 | sk_daddr_set(newsk, ireq->ir_rmt_addr); |
412 | newinet->inet_rcv_saddr = ireq->ir_loc_addr; | 411 | sk_rcv_saddr_set(newsk, ireq->ir_loc_addr); |
413 | newinet->inet_saddr = ireq->ir_loc_addr; | 412 | newinet->inet_saddr = ireq->ir_loc_addr; |
414 | newinet->inet_opt = ireq->opt; | 413 | newinet->inet_opt = ireq->opt; |
415 | ireq->opt = NULL; | 414 | ireq->opt = NULL; |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index d7e7c7b0a3f1..9216d173dd5f 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -470,11 +470,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
470 | 470 | ||
471 | memcpy(newnp, np, sizeof(struct ipv6_pinfo)); | 471 | memcpy(newnp, np, sizeof(struct ipv6_pinfo)); |
472 | 472 | ||
473 | ipv6_addr_set_v4mapped(newinet->inet_daddr, &newsk->sk_v6_daddr); | 473 | newnp->saddr = newsk->sk_v6_rcv_saddr; |
474 | |||
475 | ipv6_addr_set_v4mapped(newinet->inet_saddr, &newnp->saddr); | ||
476 | |||
477 | newsk->sk_v6_rcv_saddr = newnp->saddr; | ||
478 | 474 | ||
479 | inet_csk(newsk)->icsk_af_ops = &dccp_ipv6_mapped; | 475 | inet_csk(newsk)->icsk_af_ops = &dccp_ipv6_mapped; |
480 | newsk->sk_backlog_rcv = dccp_v4_do_rcv; | 476 | newsk->sk_backlog_rcv = dccp_v4_do_rcv; |
@@ -917,9 +913,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
917 | sk->sk_backlog_rcv = dccp_v6_do_rcv; | 913 | sk->sk_backlog_rcv = dccp_v6_do_rcv; |
918 | goto failure; | 914 | goto failure; |
919 | } | 915 | } |
920 | ipv6_addr_set_v4mapped(inet->inet_saddr, &np->saddr); | 916 | np->saddr = sk->sk_v6_rcv_saddr; |
921 | ipv6_addr_set_v4mapped(inet->inet_rcv_saddr, &sk->sk_v6_rcv_saddr); | ||
922 | |||
923 | return err; | 917 | return err; |
924 | } | 918 | } |
925 | 919 | ||