util: Fix reversed IPv4/IPv6 port assignment

Submitted by Radostin Stoyanov on Aug. 30, 2018, 1:13 p.m.

Details

Message ID 20180830131354.17064-1-rstoyanov1@gmail.com
State Accepted
Series "util: Fix reversed IPv4/IPv6 port assignment"
Commit 8f2752f82509c1d0b516e07ee73b6de555134475
Headers show

Commit Message

Radostin Stoyanov Aug. 30, 2018, 1:13 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

Andrey Vagin Sept. 10, 2018, 6:39 p.m.
Applied, thanks!

On Thu, Aug 30, 2018 at 02:13:54PM +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
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu