Skip to content

Commit

Permalink
tcp: fix ipv4 mapped request socks
Browse files Browse the repository at this point in the history
ss should display ipv4 mapped request sockets like this :

tcp    SYN-RECV   0      0  ::ffff:192.168.0.1:8080   ::ffff:192.0.2.1:35261

and not like this :

tcp    SYN-RECV   0      0  192.168.0.1:8080   192.0.2.1:35261

We should init ireq->ireq_family based on listener sk_family,
not the actual protocol carried by SYN packet.

This means we can set ireq_family in inet_reqsk_alloc()

Fixes: 3f66b08 ("inet: introduce ireq_family")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Mar 25, 2015
1 parent d631b94 commit 0144a81
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 5 deletions.
1 change: 0 additions & 1 deletion net/ipv4/syncookies.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
treq->snt_synack = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsecr : 0;
treq->tfo_listener = false;
ireq->ireq_family = AF_INET;

ireq->ir_iif = sk->sk_bound_dev_if;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/tcp_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -5980,7 +5980,7 @@ struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops,
atomic64_set(&ireq->ir_cookie, 0);
ireq->ireq_state = TCP_NEW_SYN_RECV;
write_pnet(&ireq->ireq_net, sock_net(sk_listener));

ireq->ireq_family = sk_listener->sk_family;
}

return req;
Expand Down
1 change: 0 additions & 1 deletion net/ipv4/tcp_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,6 @@ static void tcp_v4_init_req(struct request_sock *req, struct sock *sk_listener,
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;
}

static struct dst_entry *tcp_v4_route_req(struct sock *sk, struct flowi *fl,
Expand Down
1 change: 0 additions & 1 deletion net/ipv6/syncookies.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
ireq = inet_rsk(req);
treq = tcp_rsk(req);
treq->tfo_listener = false;
ireq->ireq_family = AF_INET6;

if (security_inet_conn_request(sk, skb, req))
goto out_free;
Expand Down
1 change: 0 additions & 1 deletion net/ipv6/tcp_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,6 @@ static void tcp_v6_init_req(struct request_sock *req, struct sock *sk,
atomic_inc(&skb->users);
ireq->pktopts = skb;
}
ireq->ireq_family = AF_INET6;
}

static struct dst_entry *tcp_v6_route_req(struct sock *sk, struct flowi *fl,
Expand Down

0 comments on commit 0144a81

Please sign in to comment.