Skip to content

Commit

Permalink
Store in TCP conns the real ephemeral port and not the listening port
Browse files Browse the repository at this point in the history
Related to #1692

(cherry picked from commit 929c854)
  • Loading branch information
bogdan-iancu committed Jun 11, 2019
1 parent 06178ac commit 1bdf0b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/net_tcp.c
Expand Up @@ -834,6 +834,8 @@ static struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su,
struct socket_info* si, int state, int flags)
{
struct tcp_connection *c;
union sockaddr_union local_su;
unsigned int su_size;

c=(struct tcp_connection*)shm_malloc(sizeof(struct tcp_connection));
if (c==0){
Expand All @@ -855,7 +857,9 @@ static struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su,
c->rcv.src_port=su_getport(su);
c->rcv.bind_address = si;
c->rcv.dst_ip = si->address;
c->rcv.dst_port = si->port_no;
su_size = sockaddru_len(local_su);
getsockname(sock, (struct sockaddr *)&local_su, &su_size);
c->rcv.dst_port = su_getport(&local_su);
print_ip("tcpconn_new: new tcp connection to: ", &c->rcv.src_ip, "\n");
LM_DBG("on port %d, proto %d\n", c->rcv.src_port, si->proto);
c->id=(*connection_id)++;
Expand Down

0 comments on commit 1bdf0b9

Please sign in to comment.