]> granicus.if.org Git - strace/commitdiff
sockaddr: print sin6_flowinfo field before sin6_addr
authorShankara Pailoor <shankarapailoor@gmail.com>
Wed, 9 Jan 2019 17:09:04 +0000 (09:09 -0800)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 9 Jan 2019 02:48:13 +0000 (02:48 +0000)
The sin6_flowinfo field comes before sin6_addr in the sockaddr_in6
defintion, but for some reason we switch the order when decoding.
This patch fixes the order of decoding.

* sockaddr.c (print_sockaddr_data_in6): Print sin6_flowinfo field
before sin6_addr.
* NEWS: Mention this fix.
* tests/group_req.c (main): Update expected output.
* tests/net-sockaddr.c (check_in6_linklocal, check_in6): Likewise.
* tests/net-yy-inet6.c (INADDR_STR, SA_FIELDS): Likewise.
* tests/sockaddr_xlat.c (validate_in6): Likewise.

NEWS
sockaddr.c
tests/group_req.c
tests/net-sockaddr.c
tests/net-yy-inet6.c
tests/sockaddr_xlat.c

diff --git a/NEWS b/NEWS
index 2e813840c659f8af0914e87308d57417c3c7e3fb..4d7d5696545e7d388d2fbe5c2eba47d5a16641dd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Noteworthy changes in release ?.?? (????-??-??)
     constants.
 
 * Bug fixes
+  * Fixed ordering of sockaddr_in6 fields.
   * Fixed strace-k test on alpha.
   * Fixed build on mips o32.
   * Fixed build on NOMMU architectures.
index b5abb5b773140d547f65815d7eb24b66a91f2d85..4c306c1aad7ca77ca9093382e1b8067dc41c611f 100644 (file)
@@ -188,7 +188,6 @@ print_sockaddr_data_in6(const void *const buf, const int addrlen)
        const struct sockaddr_in6 *const sa_in6 = buf;
 
        PRINT_FIELD_NET_PORT("", *sa_in6, sin6_port);
-       PRINT_FIELD_INET_ADDR(", ", *sa_in6, sin6_addr, AF_INET6);
        tprints(", sin6_flowinfo=");
        if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
                print_quoted_string((const char*) &sa_in6->sin6_flowinfo,
@@ -201,6 +200,7 @@ print_sockaddr_data_in6(const void *const buf, const int addrlen)
        if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_ABBREV)
                tprintf("htonl(%u)", ntohl(sa_in6->sin6_flowinfo));
 
+       PRINT_FIELD_INET_ADDR(", ", *sa_in6, sin6_addr, AF_INET6);
        if (addrlen <= (int) SIN6_MIN_LEN)
                return;
 
index 575e15697d0bcc293ade5e3d45f6558a73bbc579..1a29d1a5b7c6daa28deff7f9a1260b5d635295c6 100644 (file)
@@ -76,15 +76,15 @@ main(void)
                {
                        ARG_STR(SOL_IPV6), ARG_STR(MCAST_JOIN_GROUP), greq6,
                        "gr_group={sa_family=AF_INET6, sin6_port=htons(65535)"
-                       ", inet_pton(AF_INET6, \"" multi6addr "\", &sin6_addr)"
                        ", sin6_flowinfo=htonl(4294967295)"
+                       ", inet_pton(AF_INET6, \"" multi6addr "\", &sin6_addr)"
                        ", sin6_scope_id=4294967295}"
                },
                {
                        ARG_STR(SOL_IPV6), ARG_STR(MCAST_LEAVE_GROUP), greq6,
                        "gr_group={sa_family=AF_INET6, sin6_port=htons(65535)"
-                       ", inet_pton(AF_INET6, \"" multi6addr "\", &sin6_addr)"
                        ", sin6_flowinfo=htonl(4294967295)"
+                       ", inet_pton(AF_INET6, \"" multi6addr "\", &sin6_addr)"
                        ", sin6_scope_id=4294967295}"
                }
        };
index 95c10f1447e143cf8d7aa0404f534a78baa8d4b7..dec1d87556d99afd45b3f52da885014d1913db7b 100644 (file)
@@ -156,22 +156,22 @@ check_in6_linklocal(struct sockaddr_in6 *const in6, const char *const h_addr)
        unsigned int len = sizeof(*in6);
        int ret = connect(-1, (void *) in6, len);
        printf("connect(-1, {sa_family=AF_INET6, sin6_port=htons(%hu)"
-              ", inet_pton(AF_INET6, \"%s\", &sin6_addr)"
               ", sin6_flowinfo=htonl(%u)"
+              ", inet_pton(AF_INET6, \"%s\", &sin6_addr)"
               ", sin6_scope_id=%u}, %u)"
               " = %d EBADF (%m)\n",
-              ntohs(in6->sin6_port), h_addr,
-              ntohl(in6->sin6_flowinfo), in6->sin6_scope_id, len, ret);
+              ntohs(in6->sin6_port), ntohl(in6->sin6_flowinfo),
+              h_addr, in6->sin6_scope_id, len, ret);
 
        in6->sin6_scope_id = ifindex_lo();
        if (in6->sin6_scope_id) {
                ret = connect(-1, (void *) in6, len);
                printf("connect(-1, {sa_family=AF_INET6, sin6_port=htons(%hu)"
-                      ", inet_pton(AF_INET6, \"%s\", &sin6_addr)"
                       ", sin6_flowinfo=htonl(%u)"
+                      ", inet_pton(AF_INET6, \"%s\", &sin6_addr)"
                       ", sin6_scope_id=%s}, %u)"
                       " = %d EBADF (%m)\n",
-                      ntohs(in6->sin6_port), h_addr, ntohl(in6->sin6_flowinfo),
+                      ntohs(in6->sin6_port), ntohl(in6->sin6_flowinfo), h_addr,
                       IFINDEX_LO_STR, len, ret);
        }
 }
@@ -192,10 +192,11 @@ check_in6(void)
        unsigned int len = sizeof(*in6);
        int ret = connect(-1, (void *) in6, len);
        printf("connect(-1, {sa_family=AF_INET6, sin6_port=htons(%hu)"
+              ", sin6_flowinfo=htonl(%u)"
               ", inet_pton(AF_INET6, \"%s\", &sin6_addr)"
-              ", sin6_flowinfo=htonl(%u), sin6_scope_id=%u}, %u)"
+              ", sin6_scope_id=%u}, %u)"
               " = %d EBADF (%m)\n",
-              h_port, h_addr, h_flowinfo, in6->sin6_scope_id, len, ret);
+              h_port, h_flowinfo, h_addr, in6->sin6_scope_id, len, ret);
 
        check_in6_linklocal(in6, "fe80::");
        check_in6_linklocal(in6, "ff42::");
@@ -209,10 +210,11 @@ check_in6(void)
        len = sizeof(*in6) + 4;
        ret = connect(-1, (void *) in6, len);
        printf("connect(-1, {sa_family=AF_INET6, sin6_port=htons(%hu)"
+              ", sin6_flowinfo=htonl(%u)"
               ", inet_pton(AF_INET6, \"%s\", &sin6_addr)"
-              ", sin6_flowinfo=htonl(%u), sin6_scope_id=%u}, %u)"
+              ", sin6_scope_id=%u}, %u)"
               " = %d EBADF (%m)\n",
-              h_port, h_addr, h_flowinfo, in6->sin6_scope_id, len, ret);
+              h_port, h_flowinfo, h_addr, in6->sin6_scope_id, len, ret);
 
        in6 = ((void *) in6) + 4 + sizeof(in6->sin6_scope_id);
        in6->sin6_family = AF_INET6;
@@ -222,10 +224,10 @@ check_in6(void)
        len = sizeof(*in6) - sizeof(in6->sin6_scope_id);
        ret = connect(-1, (void *) in6, len);
        printf("connect(-1, {sa_family=AF_INET6, sin6_port=htons(%hu)"
-              ", inet_pton(AF_INET6, \"%s\", &sin6_addr)"
-              ", sin6_flowinfo=htonl(%u)}, %u)"
+              ", sin6_flowinfo=htonl(%u)"
+              ", inet_pton(AF_INET6, \"%s\", &sin6_addr)}, %u)"
               " = %d EBADF (%m)\n",
-              h_port, h_addr, h_flowinfo, len, ret);
+              h_port, h_flowinfo, h_addr, len, ret);
 
        in6 = ((void *) in6) + 4;
        in6->sin6_family = AF_INET6;
index a993c660ee572402f5a87496b71eee3f15e2f72e..7040c12e69c37d5cbc6b8fd65db8c42d06f07d17 100644 (file)
@@ -14,7 +14,8 @@
 #define TCP_STR "TCPv6"
 #define INPORT sin6_port
 #define INPORT_STR "sin6_port"
-#define INADDR_STR "inet_pton(AF_INET6, \"::1\", &sin6_addr)"
-#define SA_FIELDS ", sin6_flowinfo=htonl(0), sin6_scope_id=0"
+#define INADDR_STR "sin6_flowinfo=htonl(0)" \
+       ", inet_pton(AF_INET6, \"::1\", &sin6_addr)"
+#define SA_FIELDS ", sin6_scope_id=0"
 
 #include "net-yy-inet.c"
index a4cb109cadd8348b75397a848708e3e53822b5f5..420dcfef53d947a77ca32989e3d5b99c14f96e98 100644 (file)
@@ -125,36 +125,33 @@ validate_in6(struct sockaddr_in6 *const in6, const char *const h_addr)
 #if XLAT_RAW
        printf("connect(-1, {sa_family=%#x, sin6_port=", AF_INET6);
        print_quoted_hex(&in6->sin6_port, sizeof(in6->sin6_port));
-       printf(", sin6_addr=");
-       print_quoted_hex(&in6->sin6_addr, sizeof(struct in6_addr));
        printf(", sin6_flowinfo=");
        print_quoted_hex(&in6->sin6_flowinfo, sizeof(in6->sin6_flowinfo));
-       printf(", sin6_scope_id=%u}, %u)"
-              " = %s\n", in6->sin6_scope_id, len, errstr);
+       printf(", sin6_addr=");
+       print_quoted_hex(&in6->sin6_addr, sizeof(struct in6_addr));
+       printf(", sin6_scope_id=%u}, %u) = %s\n",
+              in6->sin6_scope_id, len, errstr);
 #elif XLAT_VERBOSE
        printf("connect(-1, {sa_family=%#x /* AF_INET6 */", AF_INET6);
        printf(", sin6_port=");
        print_quoted_hex(&in6->sin6_port, sizeof(in6->sin6_port));
        printf(" /* htons(%hu) */", ntohs(in6->sin6_port));
+       printf(", sin6_flowinfo=");
+       print_quoted_hex(&in6->sin6_flowinfo, sizeof(in6->sin6_flowinfo));
+       printf(" /* htonl(%u) */", ntohl(in6->sin6_flowinfo));
        printf(", sin6_addr=");
        print_quoted_hex(&in6->sin6_addr, sizeof(struct in6_addr));
        printf(" /* inet_pton(AF_INET6, \"%s\") */", h_addr);
-       printf(", sin6_flowinfo=");
-       print_quoted_hex(&in6->sin6_flowinfo, sizeof(in6->sin6_flowinfo));
-       printf(" /* htonl(%u) */"
-              ", sin6_scope_id=%u}, %u)"
-              " = %s\n",
-              ntohl(in6->sin6_flowinfo), in6->sin6_scope_id,
-                    len, errstr);
+       printf(", sin6_scope_id=%u}, %u) = %s\n",
+              in6->sin6_scope_id, len, errstr);
 #else
        printf("connect(-1, {sa_family=AF_INET6, sin6_port=htons(%hu)"
-              ", inet_pton(AF_INET6, \"%s\", &sin6_addr)"
               ", sin6_flowinfo=htonl(%u)"
+              ", inet_pton(AF_INET6, \"%s\", &sin6_addr)"
               ", sin6_scope_id=%u}, %u)"
               " = %s\n",
-              ntohs(in6->sin6_port), h_addr,
-              ntohl(in6->sin6_flowinfo), in6->sin6_scope_id,
-                    len, errstr);
+              ntohs(in6->sin6_port), ntohl(in6->sin6_flowinfo),
+              h_addr, in6->sin6_scope_id, len, errstr);
 #endif
 }