|
|
86f512 |
From 0eda4eb08b74e5c1e3100a9369b78625b8bb79c6 Mon Sep 17 00:00:00 2001
|
|
|
86f512 |
From: Eugene Syromyatnikov <evgsyr@gmail.com>
|
|
|
86f512 |
Date: Sun, 20 Oct 2019 12:59:51 +0200
|
|
|
86f512 |
Subject: [PATCH 67/76] rtnl_route: decode struct rta_mfc_stats and struct
|
|
|
86f512 |
rtvia unconditionally
|
|
|
86f512 |
|
|
|
86f512 |
* rtnl_route.c (struct_rta_mfc_stats, struct_rtvia): New typedefs.
|
|
|
86f512 |
[HAVE_STRUCT_RTA_MFC_STATS]: Add a static_assert to check
|
|
|
86f512 |
that sizeof(struct rta_mfc_stats) has the expected value.
|
|
|
86f512 |
[HAVE_STRUCT_RTVIA]: Add a static_assert to check that sizeof(struct
|
|
|
86f512 |
rtvia) has the expected value.
|
|
|
86f512 |
(decode_rta_mfc_stats) [HAVE_STRUCT_RTA_MFC_STATS]: Remove guard.
|
|
|
86f512 |
(decode_rta_mfc_stats): Change the type of mfcs variable to
|
|
|
86f512 |
struct_rta_mfc_stats.
|
|
|
86f512 |
(decode_rtvia): Change the type of via variable to struct_rtvia.
|
|
|
86f512 |
|
|
|
86f512 |
References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
|
|
|
86f512 |
---
|
|
|
86f512 |
rtnl_route.c | 35 ++++++++++++++++++++++++-----------
|
|
|
86f512 |
1 file changed, 24 insertions(+), 11 deletions(-)
|
|
|
86f512 |
|
|
|
86f512 |
diff --git a/rtnl_route.c b/rtnl_route.c
|
|
|
86f512 |
index f1bca94..aa81e50 100644
|
|
|
86f512 |
--- a/rtnl_route.c
|
|
|
86f512 |
+++ b/rtnl_route.c
|
|
|
86f512 |
@@ -26,6 +26,27 @@
|
|
|
86f512 |
#include "xlat/rtnl_route_attrs.h"
|
|
|
86f512 |
#include "xlat/rtnl_rta_metrics_attrs.h"
|
|
|
86f512 |
|
|
|
86f512 |
+/** Added by Linux commit v3.8-rc1~139^2~90 */
|
|
|
86f512 |
+typedef struct {
|
|
|
86f512 |
+ uint64_t mfcs_packets;
|
|
|
86f512 |
+ uint64_t mfcs_bytes;
|
|
|
86f512 |
+ uint64_t mfcs_wrong_if;
|
|
|
86f512 |
+} struct_rta_mfc_stats;
|
|
|
86f512 |
+
|
|
|
86f512 |
+typedef struct {
|
|
|
86f512 |
+ uint16_t /* __kernel_sa_family_t */ rtvia_family;
|
|
|
86f512 |
+ uint8_t rtvia_addr[0];
|
|
|
86f512 |
+} struct_rtvia;
|
|
|
86f512 |
+
|
|
|
86f512 |
+#ifdef HAVE_STRUCT_RTA_MFC_STATS
|
|
|
86f512 |
+static_assert(sizeof(struct_rta_mfc_stats) == sizeof(struct rta_mfc_stats),
|
|
|
86f512 |
+ "Unexpected struct rta_mfc_stats, please update the decoder");
|
|
|
86f512 |
+#endif
|
|
|
86f512 |
+#ifdef HAVE_STRUCT_RTVIA
|
|
|
86f512 |
+static_assert(sizeof(struct_rtvia) == sizeof(struct rtvia),
|
|
|
86f512 |
+ "Unexpected struct rtvia, please update the decoder");
|
|
|
86f512 |
+#endif
|
|
|
86f512 |
+
|
|
|
86f512 |
bool
|
|
|
86f512 |
decode_nla_rt_class(struct tcb *const tcp,
|
|
|
86f512 |
const kernel_ulong_t addr,
|
|
|
86f512 |
@@ -138,8 +159,7 @@ decode_rta_mfc_stats(struct tcb *const tcp,
|
|
|
86f512 |
const unsigned int len,
|
|
|
86f512 |
const void *const opaque_data)
|
|
|
86f512 |
{
|
|
|
86f512 |
-#ifdef HAVE_STRUCT_RTA_MFC_STATS
|
|
|
86f512 |
- struct rta_mfc_stats mfcs;
|
|
|
86f512 |
+ struct_rta_mfc_stats mfcs;
|
|
|
86f512 |
|
|
|
86f512 |
if (len < sizeof(mfcs))
|
|
|
86f512 |
return false;
|
|
|
86f512 |
@@ -151,9 +171,6 @@ decode_rta_mfc_stats(struct tcb *const tcp,
|
|
|
86f512 |
}
|
|
|
86f512 |
|
|
|
86f512 |
return true;
|
|
|
86f512 |
-#else
|
|
|
86f512 |
- return false;
|
|
|
86f512 |
-#endif
|
|
|
86f512 |
}
|
|
|
86f512 |
|
|
|
86f512 |
static bool
|
|
|
86f512 |
@@ -162,15 +179,14 @@ decode_rtvia(struct tcb *const tcp,
|
|
|
86f512 |
const unsigned int len,
|
|
|
86f512 |
const void *const opaque_data)
|
|
|
86f512 |
{
|
|
|
86f512 |
-#ifdef HAVE_STRUCT_RTVIA
|
|
|
86f512 |
- struct rtvia via;
|
|
|
86f512 |
+ struct_rtvia via;
|
|
|
86f512 |
|
|
|
86f512 |
if (len < sizeof(via))
|
|
|
86f512 |
return false;
|
|
|
86f512 |
else if (!umove_or_printaddr(tcp, addr, &via)) {
|
|
|
86f512 |
PRINT_FIELD_XVAL("{", via, rtvia_family, addrfams, "AF_???");
|
|
|
86f512 |
|
|
|
86f512 |
- const unsigned int offset = offsetof(struct rtvia, rtvia_addr);
|
|
|
86f512 |
+ const unsigned int offset = offsetof(struct_rtvia, rtvia_addr);
|
|
|
86f512 |
|
|
|
86f512 |
if (len > offset) {
|
|
|
86f512 |
tprints(", ");
|
|
|
86f512 |
@@ -181,9 +197,6 @@ decode_rtvia(struct tcb *const tcp,
|
|
|
86f512 |
}
|
|
|
86f512 |
|
|
|
86f512 |
return true;
|
|
|
86f512 |
-#else
|
|
|
86f512 |
- return false;
|
|
|
86f512 |
-#endif
|
|
|
86f512 |
}
|
|
|
86f512 |
|
|
|
86f512 |
static bool
|
|
|
86f512 |
--
|
|
|
86f512 |
2.1.4
|
|
|
86f512 |
|