]> granicus.if.org Git - strace/commitdiff
rtnl_link: print pad field in the struct ifla_port_vsi decoder
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sat, 19 Oct 2019 08:44:36 +0000 (10:44 +0200)
committerEugene Syromyatnikov <evgsyr@gmail.com>
Sat, 19 Oct 2019 16:01:47 +0000 (18:01 +0200)
And steamline the flow a bit.

* rtnl_link.c (decode_ifla_port_vsi): Factor the printing code out of
the conditional statement, add pad field printing.
* tests/nlattr_ifla_port.c: Add check for the pad field printing.

rtnl_link.c
tests/nlattr_ifla_port.c

index e1f2caacbadfb5041632a034ca4e88350fae5bc2..f668cd664add9e913816bceaf84380fd78274109 100644 (file)
@@ -558,13 +558,18 @@ decode_ifla_port_vsi(struct tcb *const tcp,
 
        if (len < sizeof(vsi))
                return false;
-       else if (!umove_or_printaddr(tcp, addr, &vsi)) {
-               PRINT_FIELD_U("{", vsi, vsi_mgr_id);
-               PRINT_FIELD_STRING(", ", vsi, vsi_type_id,
-                                  sizeof(vsi.vsi_type_id), QUOTE_FORCE_HEX);
-               PRINT_FIELD_U(", ", vsi, vsi_type_version);
-               tprints("}");
-       }
+       if (umove_or_printaddr(tcp, addr, &vsi))
+               return true;
+
+       PRINT_FIELD_U("{", vsi, vsi_mgr_id);
+       PRINT_FIELD_STRING(", ", vsi, vsi_type_id,
+                          sizeof(vsi.vsi_type_id), QUOTE_FORCE_HEX);
+       PRINT_FIELD_U(", ", vsi, vsi_type_version);
+
+       if (!IS_ARRAY_ZERO(vsi.pad))
+               PRINT_FIELD_HEX_ARRAY(", ", vsi, pad);
+
+       tprints("}");
 
        return true;
 }
index df2a2ef6e67c5d4818297a815edef1f0c629526d..1a7f7deb6b49817f1488ef74947b9e29202ea6c2 100644 (file)
@@ -57,6 +57,21 @@ main(void)
                                  printf(", vsi_type_id=\"\\x61\\x62\\x63\"");
                                  PRINT_FIELD_U(", ", vsi, vsi_type_version);
                                  printf("}"));
+
+       static const struct ifla_port_vsi vsi2 = {
+               .vsi_mgr_id = 0xab,
+               .vsi_type_id = { 10, 0, 255 },
+               .vsi_type_version = 0xef,
+               .pad = { 0, 1, 2 },
+       };
+       TEST_NESTED_NLATTR_OBJECT(fd, nlh0, hdrlen,
+                                 init_ifinfomsg, print_ifinfomsg,
+                                 IFLA_PORT_VSI_TYPE, pattern, vsi2,
+                                 PRINT_FIELD_U("{", vsi2, vsi_mgr_id);
+                                 printf(", vsi_type_id=\"\\x0a\\x00\\xff\"");
+                                 PRINT_FIELD_U(", ", vsi2, vsi_type_version);
+                                 printf(", pad=\"\\x00\\x01\\x02\"");
+                                 printf("}"));
 #endif
 
        puts("+++ exited with 0 +++");