tcp: Restore source address to network endianness before using it for hash table
This was actually fine "on the wire", but it's inconsistent with the way we hash other addresses/protocols and also ends up with a wrong endianness in captures in case we replace the address with our default gateway. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
000ae818d4
commit
a2b86c5f90
1 changed files with 3 additions and 2 deletions
5
tcp.c
5
tcp.c
|
@ -2970,9 +2970,10 @@ static void tcp_conn_from_sock(struct ctx *c, union epoll_ref ref,
|
||||||
memset(&conn->a.a4.one, 0xff, sizeof(conn->a.a4.one));
|
memset(&conn->a.a4.one, 0xff, sizeof(conn->a.a4.one));
|
||||||
|
|
||||||
if (s_addr >> IN_CLASSA_NSHIFT == IN_LOOPBACKNET ||
|
if (s_addr >> IN_CLASSA_NSHIFT == IN_LOOPBACKNET ||
|
||||||
s_addr == INADDR_ANY || s_addr == htonl(c->addr4_seen))
|
s_addr == INADDR_ANY || htonl(s_addr) == c->addr4_seen)
|
||||||
sa4.sin_addr.s_addr = c->gw4;
|
s_addr = ntohl(c->gw4);
|
||||||
|
|
||||||
|
s_addr = htonl(s_addr);
|
||||||
memcpy(&conn->a.a4.a, &s_addr, sizeof(conn->a.a4.a));
|
memcpy(&conn->a.a4.a, &s_addr, sizeof(conn->a.a4.a));
|
||||||
|
|
||||||
conn->sock_port = ntohs(sa4.sin_port);
|
conn->sock_port = ntohs(sa4.sin_port);
|
||||||
|
|
Loading…
Reference in a new issue