[PATCHv2,1/6] util: Fix reversed IPv4/IPv6 port assignment

Submitted by Radostin Stoyanov on Sept. 3, 2018, 8:35 p.m.

Details

Message ID 20180903203514.32423-2-rstoyanov1@gmail.com
State New
Series "remote: Refactor TCP client/server setup"
Headers show

Commit Message

Radostin Stoyanov Sept. 3, 2018, 8:35 p.m.
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
---
 criu/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/util.c b/criu/util.c
index ab4d89aa..22d0be42 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -1322,9 +1322,9 @@  int setup_tcp_server(char *type)
 		}
 
 		if (saddr.ss_family == AF_INET6) {
-			opts.port = ntohs(((struct sockaddr_in *)&saddr)->sin_port);
-		} else if (saddr.ss_family == AF_INET) {
 			opts.port = ntohs(((struct sockaddr_in6 *)&saddr)->sin6_port);
+		} else if (saddr.ss_family == AF_INET) {
+			opts.port = ntohs(((struct sockaddr_in *)&saddr)->sin_port);
 		}
 
 		pr_info("Using %u port\n", opts.port);

Comments

Adrian Reber Sept. 4, 2018, 8:13 a.m.
Fix of an obvious error:

Acked-by: Adrian Reber <areber@redhat.com>

On Mon, Sep 03, 2018 at 09:35:09PM +0100, Radostin Stoyanov wrote:
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
> ---
>  criu/util.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/criu/util.c b/criu/util.c
> index ab4d89aa..22d0be42 100644
> --- a/criu/util.c
> +++ b/criu/util.c
> @@ -1322,9 +1322,9 @@ int setup_tcp_server(char *type)
>  		}
>  
>  		if (saddr.ss_family == AF_INET6) {
> -			opts.port = ntohs(((struct sockaddr_in *)&saddr)->sin_port);
> -		} else if (saddr.ss_family == AF_INET) {
>  			opts.port = ntohs(((struct sockaddr_in6 *)&saddr)->sin6_port);
> +		} else if (saddr.ss_family == AF_INET) {
> +			opts.port = ntohs(((struct sockaddr_in *)&saddr)->sin_port);
>  		}
>  
>  		pr_info("Using %u port\n", opts.port);
> -- 
> 2.17.1