tcp: Fix conceptually incorrect byte-order switch in tcp_tap_handler()
tcp_hash_lookup() expects the port numbers in host order, but the TCP header, of course, has them in network order, so we need to switch them. However we call htons() (host to network) instead of ntohs() (network to host). This works because those do the same thing in practice (they only wouldn't on very strange theoretical platforms which are neither big nor little endian). But, having this the "wrong" way around is misleading, so switch it around. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
a672705e4d
commit
89fcb563fc
1 changed files with 1 additions and 1 deletions
2
tcp.c
2
tcp.c
|
@ -2533,7 +2533,7 @@ int tcp_tap_handler(struct ctx *c, uint8_t pif, int af,
|
||||||
optlen = MIN(optlen, ((1UL << 4) /* from doff width */ - 6) * 4UL);
|
optlen = MIN(optlen, ((1UL << 4) /* from doff width */ - 6) * 4UL);
|
||||||
opts = packet_get(p, idx, sizeof(*th), optlen, NULL);
|
opts = packet_get(p, idx, sizeof(*th), optlen, NULL);
|
||||||
|
|
||||||
conn = tcp_hash_lookup(c, af, daddr, htons(th->source), htons(th->dest));
|
conn = tcp_hash_lookup(c, af, daddr, ntohs(th->source), ntohs(th->dest));
|
||||||
|
|
||||||
/* New connection from tap */
|
/* New connection from tap */
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
|
|
Loading…
Reference in a new issue