inet: request sock should init IPv6/IPv4 addresses
authorEric Dumazet <edumazet@google.com>
Wed, 18 Mar 2015 21:05:38 +0000 (14:05 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 Mar 2015 02:00:35 +0000 (22:00 -0400)
In order to be able to use sk_ehashfn() for request socks,
we need to initialize their IPv6/IPv4 addresses.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/request_sock.h
net/dccp/ipv4.c
net/ipv4/inet_diag.c
net/ipv4/syncookies.c
net/ipv4/tcp_ipv4.c

index 3fa4f824900a78b9c1d75a94e87c6fd89056ec07..e7ef86340514423fc3089a944027498dda9cee9f 100644 (file)
@@ -91,6 +91,11 @@ static inline struct request_sock *inet_reqsk(struct sock *sk)
        return (struct request_sock *)sk;
 }
 
+static inline struct sock *req_to_sk(struct request_sock *req)
+{
+       return (struct sock *)req;
+}
+
 static inline void reqsk_free(struct request_sock *req)
 {
        /* temporary debugging */
index f3f8906f482e69fd77f855a75a970472ee9da7ad..e7ad291cd96b73fd733425bb46816a8c14cfe274 100644 (file)
@@ -638,8 +638,8 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
                goto drop_and_free;
 
        ireq = inet_rsk(req);
-       ireq->ir_loc_addr = ip_hdr(skb)->daddr;
-       ireq->ir_rmt_addr = ip_hdr(skb)->saddr;
+       sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
+       sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
        ireq->ireq_family = AF_INET;
        ireq->ir_iif = sk->sk_bound_dev_if;
 
index e7ba59038c8ded98ae560b0e35d01c9eca6ff832..74c39c9f3e11deb443102c7a571b1d4bc9f540b1 100644 (file)
@@ -742,14 +742,14 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
 
                        if (bc) {
                                /* Note: entry.sport and entry.userlocks are already set */
-                               entry_fill_addrs(&entry, (struct sock *)req);
+                               entry_fill_addrs(&entry, req_to_sk(req));
                                entry.dport = ntohs(ireq->ir_rmt_port);
 
                                if (!inet_diag_bc_run(bc, &entry))
                                        continue;
                        }
 
-                       err = inet_req_diag_fill((struct sock *)req, skb,
+                       err = inet_req_diag_fill(req_to_sk(req), skb,
                                                 NETLINK_CB(cb->skb).portid,
                                                 cb->nlh->nlmsg_seq,
                                                 NLM_F_MULTI, cb->nlh);
index 34e755403715812fbc125f1fa6d97964875ac7c0..ef01d8570358bf52a82eaaa408d8ba79af3c46f8 100644 (file)
@@ -337,8 +337,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
        req->mss                = mss;
        ireq->ir_num            = ntohs(th->dest);
        ireq->ir_rmt_port       = th->source;
-       ireq->ir_loc_addr       = ip_hdr(skb)->daddr;
-       ireq->ir_rmt_addr       = ip_hdr(skb)->saddr;
+       sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
+       sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
        ireq->ir_mark           = inet_request_mark(sk, skb);
        ireq->snd_wscale        = tcp_opt.snd_wscale;
        ireq->sack_ok           = tcp_opt.sack_ok;
index ca207df4af1c40d54234328d8253cf08c315c4f0..ddd0b1f25b9666b1b49f95973c8859f57263ef3e 100644 (file)
@@ -1219,14 +1219,14 @@ static bool tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
 
 #endif
 
-static void tcp_v4_init_req(struct request_sock *req, struct sock *sk,
+static void tcp_v4_init_req(struct request_sock *req, struct sock *sk_listener,
                            struct sk_buff *skb)
 {
        struct inet_request_sock *ireq = inet_rsk(req);
 
-       ireq->ir_loc_addr = ip_hdr(skb)->daddr;
-       ireq->ir_rmt_addr = ip_hdr(skb)->saddr;
-       ireq->no_srccheck = inet_sk(sk)->transparent;
+       sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
+       sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
+       ireq->no_srccheck = inet_sk(sk_listener)->transparent;
        ireq->opt = tcp_v4_save_options(skb);
        ireq->ireq_family = AF_INET;
 }