]> granicus.if.org Git - strace/commitdiff
rtnl_route: decode struct rta_mfc_stats and struct rtvia unconditionally
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 20 Oct 2019 10:59:51 +0000 (12:59 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 20 Oct 2019 17:06:49 +0000 (17:06 +0000)
* rtnl_route.c (struct_rta_mfc_stats, struct_rtvia): New typedefs.
[HAVE_STRUCT_RTA_MFC_STATS]: Add a static_assert to check
that sizeof(struct rta_mfc_stats) has the expected value.
[HAVE_STRUCT_RTVIA]: Add a static_assert to check that sizeof(struct
rtvia) has the expected value.
(decode_rta_mfc_stats) [HAVE_STRUCT_RTA_MFC_STATS]: Remove guard.
(decode_rta_mfc_stats): Change the type of mfcs variable to
struct_rta_mfc_stats.
(decode_rtvia): Change the type of via variable to struct_rtvia.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201

rtnl_route.c

index 8e6337b713e2db9ff7c549a44fa38bbe288a13a4..a7d59ecc05e8c1a8dcd5fcc0bbd55760c64ef202 100644 (file)
 #include "xlat/rtnl_route_attrs.h"
 #include "xlat/rtnl_rta_metrics_attrs.h"
 
+/** Added by Linux commit v3.8-rc1~139^2~90 */
+typedef struct {
+       uint64_t mfcs_packets;
+       uint64_t mfcs_bytes;
+       uint64_t mfcs_wrong_if;
+} struct_rta_mfc_stats;
+
+typedef struct {
+       uint16_t /* __kernel_sa_family_t */ rtvia_family;
+       uint8_t rtvia_addr[0];
+} struct_rtvia;
+
+#ifdef HAVE_STRUCT_RTA_MFC_STATS
+static_assert(sizeof(struct_rta_mfc_stats) == sizeof(struct rta_mfc_stats),
+             "Unexpected struct rta_mfc_stats, please update the decoder");
+#endif
+#ifdef HAVE_STRUCT_RTVIA
+static_assert(sizeof(struct_rtvia) == sizeof(struct rtvia),
+             "Unexpected struct rtvia, please update the decoder");
+#endif
+
 bool
 decode_nla_rt_class(struct tcb *const tcp,
                    const kernel_ulong_t addr,
@@ -138,8 +159,7 @@ decode_rta_mfc_stats(struct tcb *const tcp,
                     const unsigned int len,
                     const void *const opaque_data)
 {
-#ifdef HAVE_STRUCT_RTA_MFC_STATS
-       struct rta_mfc_stats mfcs;
+       struct_rta_mfc_stats mfcs;
 
        if (len < sizeof(mfcs))
                return false;
@@ -151,9 +171,6 @@ decode_rta_mfc_stats(struct tcb *const tcp,
        }
 
        return true;
-#else
-       return false;
-#endif
 }
 
 static bool
@@ -162,15 +179,14 @@ decode_rtvia(struct tcb *const tcp,
             const unsigned int len,
             const void *const opaque_data)
 {
-#ifdef HAVE_STRUCT_RTVIA
-       struct rtvia via;
+       struct_rtvia via;
 
        if (len < sizeof(via))
                return false;
        else if (!umove_or_printaddr(tcp, addr, &via)) {
                PRINT_FIELD_XVAL("{", via, rtvia_family, addrfams, "AF_???");
 
-               const unsigned int offset = offsetof(struct rtvia, rtvia_addr);
+               const unsigned int offset = offsetof(struct_rtvia, rtvia_addr);
 
                if (len > offset) {
                        tprints(", ");
@@ -181,9 +197,6 @@ decode_rtvia(struct tcb *const tcp,
        }
 
        return true;
-#else
-       return false;
-#endif
 }
 
 static bool