|
|
86f512 |
From be67f0080a317a7089cde75a6011ac5bb78aae5b Mon Sep 17 00:00:00 2001
|
|
|
86f512 |
From: Eugene Syromyatnikov <evgsyr@gmail.com>
|
|
|
86f512 |
Date: Thu, 10 Oct 2019 11:08:51 +0200
|
|
|
86f512 |
Subject: [PATCH 63/76] rtnl_link: use internal rtnl_link_stats* and
|
|
|
86f512 |
ifla_port_vsi definitions
|
|
|
86f512 |
|
|
|
86f512 |
Define substitutes for struct rtnl_link_stats, struct
|
|
|
86f512 |
rtnl_link_stats64, and struct ifla_port_vsi internally.
|
|
|
86f512 |
Add a static_assert that informs about future growth of the structures
|
|
|
86f512 |
provided by the kernel headers.
|
|
|
86f512 |
|
|
|
86f512 |
* rtnl_link.c (struct_rtnl_link_stats, struct_rtnl_link_stats64,
|
|
|
86f512 |
struct_ifla_port_vsi): New typedefs.
|
|
|
86f512 |
[HAVE_STRUCT_RTNL_LINK_STATS_RX_NOHANDLER]: Add a static_assert to check
|
|
|
86f512 |
that sizeof(struct rtnl_link_stats) has the expected value.
|
|
|
86f512 |
[HAVE_STRUCT_RTNL_LINK_STATS64_RX_NOHANDLER]: Add a static_assert
|
|
|
86f512 |
to check that sizeof(struct rtnl_link_stats) has the expected value.
|
|
|
86f512 |
[HAVE_STRUCT_IFLA_PORT_VSI]: Add a static_assert to check
|
|
|
86f512 |
that sizeof(struct ifla_port_vsi) has the expected value.
|
|
|
86f512 |
(decode_rtnl_link_stats) [HAVE_STRUCT_RTNL_LINK_STATS_RX_NOHANDLER]:
|
|
|
86f512 |
Remove guard.
|
|
|
86f512 |
(decode_rtnl_link_stats): Change the type of st variable to
|
|
|
86f512 |
struct_rtnl_link_stats; use struct_rtnl_link_stats in offsetofend
|
|
|
86f512 |
statement for min_size definition.
|
|
|
86f512 |
(decode_rtnl_link_stats64) [HAVE_STRUCT_RTNL_LINK_STATS64,
|
|
|
86f512 |
HAVE_STRUCT_RTNL_LINK_STATS64_RX_NOHANDLER]: Remove guards.
|
|
|
86f512 |
(decode_rtnl_link_stats64): Change the type of st variable
|
|
|
86f512 |
to struct_rtnl_link_stats64.
|
|
|
86f512 |
(decode_ifla_port_vsi) [HAVE_STRUCT_IFLA_PORT_VSI]: Remove guard.
|
|
|
86f512 |
(decode_ifla_port_vsi): Change the type of vsi variable
|
|
|
86f512 |
to struct_ifla_port_vsi.
|
|
|
86f512 |
|
|
|
86f512 |
References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
|
|
|
86f512 |
---
|
|
|
86f512 |
rtnl_link.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++----------
|
|
|
86f512 |
1 file changed, 87 insertions(+), 17 deletions(-)
|
|
|
86f512 |
|
|
|
86f512 |
diff --git a/rtnl_link.c b/rtnl_link.c
|
|
|
86f512 |
index 92bc1e0..5ab3d03 100644
|
|
|
86f512 |
--- a/rtnl_link.c
|
|
|
86f512 |
+++ b/rtnl_link.c
|
|
|
86f512 |
@@ -42,15 +42,95 @@
|
|
|
86f512 |
#include "xlat/tun_device_types.h"
|
|
|
86f512 |
#include "xlat/xdp_flags.h"
|
|
|
86f512 |
|
|
|
86f512 |
+typedef struct {
|
|
|
86f512 |
+ uint32_t rx_packets;
|
|
|
86f512 |
+ uint32_t tx_packets;
|
|
|
86f512 |
+ uint32_t rx_bytes;
|
|
|
86f512 |
+ uint32_t tx_bytes;
|
|
|
86f512 |
+ uint32_t rx_errors;
|
|
|
86f512 |
+ uint32_t tx_errors;
|
|
|
86f512 |
+ uint32_t rx_dropped;
|
|
|
86f512 |
+ uint32_t tx_dropped;
|
|
|
86f512 |
+ uint32_t multicast;
|
|
|
86f512 |
+ uint32_t collisions;
|
|
|
86f512 |
+ uint32_t rx_length_errors;
|
|
|
86f512 |
+ uint32_t rx_over_errors;
|
|
|
86f512 |
+ uint32_t rx_crc_errors;
|
|
|
86f512 |
+ uint32_t rx_frame_errors;
|
|
|
86f512 |
+ uint32_t rx_fifo_errors;
|
|
|
86f512 |
+ uint32_t rx_missed_errors;
|
|
|
86f512 |
+ uint32_t tx_aborted_errors;
|
|
|
86f512 |
+ uint32_t tx_carrier_errors;
|
|
|
86f512 |
+ uint32_t tx_fifo_errors;
|
|
|
86f512 |
+ uint32_t tx_heartbeat_errors;
|
|
|
86f512 |
+ uint32_t tx_window_errors;
|
|
|
86f512 |
+ uint32_t rx_compressed;
|
|
|
86f512 |
+ uint32_t tx_compressed;
|
|
|
86f512 |
+ uint32_t rx_nohandler; /**< Added by v4.6-rc1~91^2~329^2~2 */
|
|
|
86f512 |
+} struct_rtnl_link_stats;
|
|
|
86f512 |
+
|
|
|
86f512 |
+/** Added by Linux commit v2.6.35-rc1~473^2~759 */
|
|
|
86f512 |
+typedef struct {
|
|
|
86f512 |
+ uint64_t rx_packets;
|
|
|
86f512 |
+ uint64_t tx_packets;
|
|
|
86f512 |
+ uint64_t rx_bytes;
|
|
|
86f512 |
+ uint64_t tx_bytes;
|
|
|
86f512 |
+ uint64_t rx_errors;
|
|
|
86f512 |
+ uint64_t tx_errors;
|
|
|
86f512 |
+ uint64_t rx_dropped;
|
|
|
86f512 |
+ uint64_t tx_dropped;
|
|
|
86f512 |
+ uint64_t multicast;
|
|
|
86f512 |
+ uint64_t collisions;
|
|
|
86f512 |
+ uint64_t rx_length_errors;
|
|
|
86f512 |
+ uint64_t rx_over_errors;
|
|
|
86f512 |
+ uint64_t rx_crc_errors;
|
|
|
86f512 |
+ uint64_t rx_frame_errors;
|
|
|
86f512 |
+ uint64_t rx_fifo_errors;
|
|
|
86f512 |
+ uint64_t rx_missed_errors;
|
|
|
86f512 |
+ uint64_t tx_aborted_errors;
|
|
|
86f512 |
+ uint64_t tx_carrier_errors;
|
|
|
86f512 |
+ uint64_t tx_fifo_errors;
|
|
|
86f512 |
+ uint64_t tx_heartbeat_errors;
|
|
|
86f512 |
+ uint64_t tx_window_errors;
|
|
|
86f512 |
+ uint64_t rx_compressed;
|
|
|
86f512 |
+ uint64_t tx_compressed;
|
|
|
86f512 |
+ uint64_t rx_nohandler; /**< Added by v4.6-rc1~91^2~329^2~2 */
|
|
|
86f512 |
+} struct_rtnl_link_stats64;
|
|
|
86f512 |
+
|
|
|
86f512 |
+/** Added by Linux commit v2.6.35-rc1~473^2~33 */
|
|
|
86f512 |
+typedef struct {
|
|
|
86f512 |
+ uint8_t vsi_mgr_id;
|
|
|
86f512 |
+ uint8_t vsi_type_id[3];
|
|
|
86f512 |
+ uint8_t vsi_type_version;
|
|
|
86f512 |
+ uint8_t pad[3];
|
|
|
86f512 |
+} struct_ifla_port_vsi;
|
|
|
86f512 |
+
|
|
|
86f512 |
+#ifdef HAVE_STRUCT_RTNL_LINK_STATS_RX_NOHANDLER
|
|
|
86f512 |
+static_assert(sizeof(struct_rtnl_link_stats)
|
|
|
86f512 |
+ == sizeof(struct rtnl_link_stats),
|
|
|
86f512 |
+ "struct rtnl_link_stats size mismatch"
|
|
|
86f512 |
+ ", please update the decoder");
|
|
|
86f512 |
+#endif
|
|
|
86f512 |
+#ifdef HAVE_STRUCT_RTNL_LINK_STATS64_RX_NOHANDLER
|
|
|
86f512 |
+static_assert(sizeof(struct_rtnl_link_stats64)
|
|
|
86f512 |
+ == sizeof(struct rtnl_link_stats64),
|
|
|
86f512 |
+ "struct rtnl_link_stats64 size mismatch"
|
|
|
86f512 |
+ ", please update the decoder");
|
|
|
86f512 |
+#endif
|
|
|
86f512 |
+#ifdef HAVE_STRUCT_IFLA_PORT_VSI
|
|
|
86f512 |
+static_assert(sizeof(struct_ifla_port_vsi) == sizeof(struct ifla_port_vsi),
|
|
|
86f512 |
+ "struct ifla_port_vsi size mismatch, please update the decoder");
|
|
|
86f512 |
+#endif
|
|
|
86f512 |
+
|
|
|
86f512 |
static bool
|
|
|
86f512 |
decode_rtnl_link_stats(struct tcb *const tcp,
|
|
|
86f512 |
const kernel_ulong_t addr,
|
|
|
86f512 |
const unsigned int len,
|
|
|
86f512 |
const void *const opaque_data)
|
|
|
86f512 |
{
|
|
|
86f512 |
- struct rtnl_link_stats st;
|
|
|
86f512 |
+ struct_rtnl_link_stats st;
|
|
|
86f512 |
const unsigned int min_size =
|
|
|
86f512 |
- offsetofend(struct rtnl_link_stats, tx_compressed);
|
|
|
86f512 |
+ offsetofend(struct_rtnl_link_stats, tx_compressed);
|
|
|
86f512 |
const unsigned int def_size = sizeof(st);
|
|
|
86f512 |
const unsigned int size =
|
|
|
86f512 |
(len >= def_size) ? def_size :
|
|
|
86f512 |
@@ -86,10 +166,9 @@ decode_rtnl_link_stats(struct tcb *const tcp,
|
|
|
86f512 |
|
|
|
86f512 |
PRINT_FIELD_U(", ", st, rx_compressed);
|
|
|
86f512 |
PRINT_FIELD_U(", ", st, tx_compressed);
|
|
|
86f512 |
-#ifdef HAVE_STRUCT_RTNL_LINK_STATS_RX_NOHANDLER
|
|
|
86f512 |
+
|
|
|
86f512 |
if (len >= def_size)
|
|
|
86f512 |
PRINT_FIELD_U(", ", st, rx_nohandler);
|
|
|
86f512 |
-#endif
|
|
|
86f512 |
tprints("}");
|
|
|
86f512 |
}
|
|
|
86f512 |
|
|
|
86f512 |
@@ -424,10 +503,9 @@ decode_rtnl_link_stats64(struct tcb *const tcp,
|
|
|
86f512 |
const unsigned int len,
|
|
|
86f512 |
const void *const opaque_data)
|
|
|
86f512 |
{
|
|
|
86f512 |
-#ifdef HAVE_STRUCT_RTNL_LINK_STATS64
|
|
|
86f512 |
- struct rtnl_link_stats64 st;
|
|
|
86f512 |
+ struct_rtnl_link_stats64 st;
|
|
|
86f512 |
const unsigned int min_size =
|
|
|
86f512 |
- offsetofend(struct rtnl_link_stats64, tx_compressed);
|
|
|
86f512 |
+ offsetofend(struct_rtnl_link_stats64, tx_compressed);
|
|
|
86f512 |
const unsigned int def_size = sizeof(st);
|
|
|
86f512 |
const unsigned int size =
|
|
|
86f512 |
(len >= def_size) ? def_size :
|
|
|
86f512 |
@@ -463,17 +541,13 @@ decode_rtnl_link_stats64(struct tcb *const tcp,
|
|
|
86f512 |
|
|
|
86f512 |
PRINT_FIELD_U(", ", st, rx_compressed);
|
|
|
86f512 |
PRINT_FIELD_U(", ", st, tx_compressed);
|
|
|
86f512 |
-# ifdef HAVE_STRUCT_RTNL_LINK_STATS64_RX_NOHANDLER
|
|
|
86f512 |
+
|
|
|
86f512 |
if (len >= def_size)
|
|
|
86f512 |
PRINT_FIELD_U(", ", st, rx_nohandler);
|
|
|
86f512 |
-# endif
|
|
|
86f512 |
tprints("}");
|
|
|
86f512 |
}
|
|
|
86f512 |
|
|
|
86f512 |
return true;
|
|
|
86f512 |
-#else
|
|
|
86f512 |
- return false;
|
|
|
86f512 |
-#endif
|
|
|
86f512 |
}
|
|
|
86f512 |
|
|
|
86f512 |
static bool
|
|
|
86f512 |
@@ -482,8 +556,7 @@ decode_ifla_port_vsi(struct tcb *const tcp,
|
|
|
86f512 |
const unsigned int len,
|
|
|
86f512 |
const void *const opaque_data)
|
|
|
86f512 |
{
|
|
|
86f512 |
-#ifdef HAVE_STRUCT_IFLA_PORT_VSI
|
|
|
86f512 |
- struct ifla_port_vsi vsi;
|
|
|
86f512 |
+ struct_ifla_port_vsi vsi;
|
|
|
86f512 |
|
|
|
86f512 |
if (len < sizeof(vsi))
|
|
|
86f512 |
return false;
|
|
|
86f512 |
@@ -496,9 +569,6 @@ decode_ifla_port_vsi(struct tcb *const tcp,
|
|
|
86f512 |
}
|
|
|
86f512 |
|
|
|
86f512 |
return true;
|
|
|
86f512 |
-#else
|
|
|
86f512 |
- return false;
|
|
|
86f512 |
-#endif
|
|
|
86f512 |
}
|
|
|
86f512 |
|
|
|
86f512 |
static const nla_decoder_t ifla_port_nla_decoders[] = {
|
|
|
86f512 |
--
|
|
|
86f512 |
2.1.4
|
|
|
86f512 |
|