net: http: Use random source port when connecting
If we re-connect to same peer server, then we should select a new source port. Noticed that if the same source port as before is used for the new connection, the peer might drop the packet. This was seen when connecting to Linux peer. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
3616ec145b
commit
c9e6ef5331
1 changed files with 11 additions and 0 deletions
|
@ -491,6 +491,17 @@ static int tcp_connect(struct http_client_ctx *ctx)
|
|||
|
||||
if (ctx->tcp.remote.family == AF_INET6) {
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
|
||||
/* If we are reconnecting, then make sure the source port
|
||||
* is re-calculated so that the peer will not get confused
|
||||
* which connection the connection is related to.
|
||||
* This was seen in Linux which dropped packets when the same
|
||||
* source port was for a new connection after the old connection
|
||||
* was terminated.
|
||||
*/
|
||||
net_sin6(&ctx->tcp.local)->sin6_port = 0;
|
||||
} else {
|
||||
net_sin(&ctx->tcp.local)->sin_port = 0;
|
||||
}
|
||||
|
||||
ret = get_local_addr(ctx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue