summaryrefslogtreecommitdiff
path: root/bundled
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2018-08-19 13:34:41 +0200
committerDmitry V. Levin <ldv@strace.io>2021-11-07 08:00:00 +0000
commita1813471957f97e85df7098453598c57aa0bfda5 (patch)
tree2a280b596b41e881700e00a66c0658d853b53a61 /bundled
parente8fb4de6d960c7a6374dbb59f20fbd3689e88df5 (diff)
downloadstrace-a1813471957f97e85df7098453598c57aa0bfda5.tar.gz
netlink_route: implement RTM_NEWSTATS and RTM_GETSTATS message decoding
* src/xlat/ifstats_af_spec_mpls_attrs.in: New file. * src/xlat/ifstats_attr_flags.in: Likewise. * src/xlat/ifstats_attrs.in: Likewise. * src/xlat/ifstats_offload_attrs.in: Likewise. * src/xlat/ifstats_xstats_bond_3ad_attrs.in: Likewise. * src/xlat/ifstats_xstats_bond_attrs.in: Likewise. * src/xlat/ifstats_xstats_bridge_attrs.in: Likewise. * src/xlat/ifstats_xstats_bridge_mcast_indices.in: Likewise. * src/xlat/ifstats_xstats_type_attrs.in: Likewise. * src/xlat/nl_bridge_vlan_flags.in: Likewise. * bundled/linux/include/uapi/linux/if_bonding.h: New file, copied from headers_install'ed Linux kernel v5.15. * bundled/linux/include/uapi/linux/mpls.h: Likewise. * bundled/Makefile.am (EXTRA_DIST): Add them. * src/rtnl_stats.c: New file. * src/Makefile.am (strace_SOURCES): Add it. * src/netlink_route.c (route_decoders) <[RTM_NEWSTATS - RTM_BASE], [RTM_GETSTATS - RTM_BASE]>: New decoder, call decode_ifstatsmsg. * src/netlink_route.h (decode_ifstatsmsg): New declaration. * src/nlattr.h (DECL_NLA(rtnl_link_stats64)): Likewise. * src/rtnl_link.c (decode_nla_rtnl_link_stats64): Rename from decode_rtnl_link_stats64. (ifinfomsg_nla_decoders) <[IFLA_STATS64]>: Use decode_nla_rtnl_link_stats64. * src/print_fields.h (PRINT_FIELD_ARRAY_INDEXED): New macro. * tests/nlattr_ifstats.c: New file. * tests/nlattr_ifstats-Xabbrev.c: Likewise. * tests/nlattr_ifstats-Xraw.c: Likewise. * tests/nlattr_ifstats-Xverbose.c: Likewise. * tests/.gitignore: Add nlattr_ifstats, nlattr_ifstats-Xabbrev, nlattr_ifstats-Xraw, and nlattr_ifstats-Xverbose. * tests/pure_executables.list: Likewise. * tests/gen_tests.in (nlattr_ifstats, nlattr_ifstats-Xabbrev, nlattr_ifstats-Xraw, nlattr_ifstats-Xverbose): New tests. * tests/netlink_route.c: Update/add checks for the RTM_*STATS message types. * NEWS: Mention it.
Diffstat (limited to 'bundled')
-rw-r--r--bundled/Makefile.am2
-rw-r--r--bundled/linux/include/uapi/linux/if_bonding.h155
-rw-r--r--bundled/linux/include/uapi/linux/mpls.h77
3 files changed, 234 insertions, 0 deletions
diff --git a/bundled/Makefile.am b/bundled/Makefile.am
index b3da1b23a..388e05dc5 100644
--- a/bundled/Makefile.am
+++ b/bundled/Makefile.am
@@ -43,6 +43,7 @@ EXTRA_DIST = \
linux/include/uapi/linux/hiddev.h \
linux/include/uapi/linux/if_addr.h \
linux/include/uapi/linux/if_addrlabel.h \
+ linux/include/uapi/linux/if_bonding.h \
linux/include/uapi/linux/if_bridge.h \
linux/include/uapi/linux/if_link.h \
linux/include/uapi/linux/in6.h \
@@ -60,6 +61,7 @@ EXTRA_DIST = \
linux/include/uapi/linux/memfd.h \
linux/include/uapi/linux/mmtimer.h \
linux/include/uapi/linux/mount.h \
+ linux/include/uapi/linux/mpls.h \
linux/include/uapi/linux/mqueue.h \
linux/include/uapi/linux/neighbour.h \
linux/include/uapi/linux/netconf.h \
diff --git a/bundled/linux/include/uapi/linux/if_bonding.h b/bundled/linux/include/uapi/linux/if_bonding.h
new file mode 100644
index 000000000..d174914a8
--- /dev/null
+++ b/bundled/linux/include/uapi/linux/if_bonding.h
@@ -0,0 +1,155 @@
+/* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
+/*
+ * Bond several ethernet interfaces into a Cisco, running 'Etherchannel'.
+ *
+ *
+ * Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
+ * NCM: Network and Communications Management, Inc.
+ *
+ * BUT, I'm the one who modified it for ethernet, so:
+ * (c) Copyright 1999, Thomas Davis, tadavis@lbl.gov
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU Public License, incorporated herein by reference.
+ *
+ * 2003/03/18 - Amir Noam <amir.noam at intel dot com>
+ * - Added support for getting slave's speed and duplex via ethtool.
+ * Needed for 802.3ad and other future modes.
+ *
+ * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ * Shmulik Hen <shmulik.hen at intel dot com>
+ * - Enable support of modes that need to use the unique mac address of
+ * each slave.
+ *
+ * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ * Amir Noam <amir.noam at intel dot com>
+ * - Moved driver's private data types to bonding.h
+ *
+ * 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
+ * Tsippy Mendelson <tsippy.mendelson at intel dot com> and
+ * Shmulik Hen <shmulik.hen at intel dot com>
+ * - Added support for IEEE 802.3ad Dynamic link aggregation mode.
+ *
+ * 2003/05/01 - Amir Noam <amir.noam at intel dot com>
+ * - Added ABI version control to restore compatibility between
+ * new/old ifenslave and new/old bonding.
+ *
+ * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
+ * - Code cleanup and style changes
+ *
+ * 2005/05/05 - Jason Gabler <jygabler at lbl dot gov>
+ * - added definitions for various XOR hashing policies
+ */
+
+#ifndef _LINUX_IF_BONDING_H
+#define _LINUX_IF_BONDING_H
+
+#include <linux/if.h>
+#include <linux/types.h>
+#include <linux/if_ether.h>
+
+/* userland - kernel ABI version (2003/05/08) */
+#define BOND_ABI_VERSION 2
+
+/*
+ * We can remove these ioctl definitions in 2.5. People should use the
+ * SIOC*** versions of them instead
+ */
+#define BOND_ENSLAVE_OLD (SIOCDEVPRIVATE)
+#define BOND_RELEASE_OLD (SIOCDEVPRIVATE + 1)
+#define BOND_SETHWADDR_OLD (SIOCDEVPRIVATE + 2)
+#define BOND_SLAVE_INFO_QUERY_OLD (SIOCDEVPRIVATE + 11)
+#define BOND_INFO_QUERY_OLD (SIOCDEVPRIVATE + 12)
+#define BOND_CHANGE_ACTIVE_OLD (SIOCDEVPRIVATE + 13)
+
+#define BOND_CHECK_MII_STATUS (SIOCGMIIPHY)
+
+#define BOND_MODE_ROUNDROBIN 0
+#define BOND_MODE_ACTIVEBACKUP 1
+#define BOND_MODE_XOR 2
+#define BOND_MODE_BROADCAST 3
+#define BOND_MODE_8023AD 4
+#define BOND_MODE_TLB 5
+#define BOND_MODE_ALB 6 /* TLB + RLB (receive load balancing) */
+
+/* each slave's link has 4 states */
+#define BOND_LINK_UP 0 /* link is up and running */
+#define BOND_LINK_FAIL 1 /* link has just gone down */
+#define BOND_LINK_DOWN 2 /* link has been down for too long time */
+#define BOND_LINK_BACK 3 /* link is going back */
+
+/* each slave has several states */
+#define BOND_STATE_ACTIVE 0 /* link is active */
+#define BOND_STATE_BACKUP 1 /* link is backup */
+
+#define BOND_DEFAULT_MAX_BONDS 1 /* Default maximum number of devices to support */
+
+#define BOND_DEFAULT_TX_QUEUES 16 /* Default number of tx queues per device */
+
+#define BOND_DEFAULT_RESEND_IGMP 1 /* Default number of IGMP membership reports */
+
+/* hashing types */
+#define BOND_XMIT_POLICY_LAYER2 0 /* layer 2 (MAC only), default */
+#define BOND_XMIT_POLICY_LAYER34 1 /* layer 3+4 (IP ^ (TCP || UDP)) */
+#define BOND_XMIT_POLICY_LAYER23 2 /* layer 2+3 (IP ^ MAC) */
+#define BOND_XMIT_POLICY_ENCAP23 3 /* encapsulated layer 2+3 */
+#define BOND_XMIT_POLICY_ENCAP34 4 /* encapsulated layer 3+4 */
+#define BOND_XMIT_POLICY_VLAN_SRCMAC 5 /* vlan + source MAC */
+
+/* 802.3ad port state definitions (43.4.2.2 in the 802.3ad standard) */
+#define LACP_STATE_LACP_ACTIVITY 0x1
+#define LACP_STATE_LACP_TIMEOUT 0x2
+#define LACP_STATE_AGGREGATION 0x4
+#define LACP_STATE_SYNCHRONIZATION 0x8
+#define LACP_STATE_COLLECTING 0x10
+#define LACP_STATE_DISTRIBUTING 0x20
+#define LACP_STATE_DEFAULTED 0x40
+#define LACP_STATE_EXPIRED 0x80
+
+typedef struct ifbond {
+ __s32 bond_mode;
+ __s32 num_slaves;
+ __s32 miimon;
+} ifbond;
+
+typedef struct ifslave {
+ __s32 slave_id; /* Used as an IN param to the BOND_SLAVE_INFO_QUERY ioctl */
+ char slave_name[IFNAMSIZ];
+ __s8 link;
+ __s8 state;
+ __u32 link_failure_count;
+} ifslave;
+
+struct ad_info {
+ __u16 aggregator_id;
+ __u16 ports;
+ __u16 actor_key;
+ __u16 partner_key;
+ __u8 partner_system[ETH_ALEN];
+};
+
+/* Embedded inside LINK_XSTATS_TYPE_BOND */
+enum {
+ BOND_XSTATS_UNSPEC,
+ BOND_XSTATS_3AD,
+ __BOND_XSTATS_MAX
+};
+#define BOND_XSTATS_MAX (__BOND_XSTATS_MAX - 1)
+
+/* Embedded inside BOND_XSTATS_3AD */
+enum {
+ BOND_3AD_STAT_LACPDU_RX,
+ BOND_3AD_STAT_LACPDU_TX,
+ BOND_3AD_STAT_LACPDU_UNKNOWN_RX,
+ BOND_3AD_STAT_LACPDU_ILLEGAL_RX,
+ BOND_3AD_STAT_MARKER_RX,
+ BOND_3AD_STAT_MARKER_TX,
+ BOND_3AD_STAT_MARKER_RESP_RX,
+ BOND_3AD_STAT_MARKER_RESP_TX,
+ BOND_3AD_STAT_MARKER_UNKNOWN_RX,
+ BOND_3AD_STAT_PAD,
+ __BOND_3AD_STAT_MAX
+};
+#define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1)
+
+#endif /* _LINUX_IF_BONDING_H */
diff --git a/bundled/linux/include/uapi/linux/mpls.h b/bundled/linux/include/uapi/linux/mpls.h
new file mode 100644
index 000000000..9effbf99d
--- /dev/null
+++ b/bundled/linux/include/uapi/linux/mpls.h
@@ -0,0 +1,77 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _MPLS_H
+#define _MPLS_H
+
+#include <linux/types.h>
+#include <asm/byteorder.h>
+
+/* Reference: RFC 5462, RFC 3032
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Label | TC |S| TTL |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * Label: Label Value, 20 bits
+ * TC: Traffic Class field, 3 bits
+ * S: Bottom of Stack, 1 bit
+ * TTL: Time to Live, 8 bits
+ */
+
+struct mpls_label {
+ __be32 entry;
+};
+
+#define MPLS_LS_LABEL_MASK 0xFFFFF000
+#define MPLS_LS_LABEL_SHIFT 12
+#define MPLS_LS_TC_MASK 0x00000E00
+#define MPLS_LS_TC_SHIFT 9
+#define MPLS_LS_S_MASK 0x00000100
+#define MPLS_LS_S_SHIFT 8
+#define MPLS_LS_TTL_MASK 0x000000FF
+#define MPLS_LS_TTL_SHIFT 0
+
+/* Reserved labels */
+#define MPLS_LABEL_IPV4NULL 0 /* RFC3032 */
+#define MPLS_LABEL_RTALERT 1 /* RFC3032 */
+#define MPLS_LABEL_IPV6NULL 2 /* RFC3032 */
+#define MPLS_LABEL_IMPLNULL 3 /* RFC3032 */
+#define MPLS_LABEL_ENTROPY 7 /* RFC6790 */
+#define MPLS_LABEL_GAL 13 /* RFC5586 */
+#define MPLS_LABEL_OAMALERT 14 /* RFC3429 */
+#define MPLS_LABEL_EXTENSION 15 /* RFC7274 */
+
+#define MPLS_LABEL_FIRST_UNRESERVED 16 /* RFC3032 */
+
+/* These are embedded into IFLA_STATS_AF_SPEC:
+ * [IFLA_STATS_AF_SPEC]
+ * -> [AF_MPLS]
+ * -> [MPLS_STATS_xxx]
+ *
+ * Attributes:
+ * [MPLS_STATS_LINK] = {
+ * struct mpls_link_stats
+ * }
+ */
+enum {
+ MPLS_STATS_UNSPEC, /* also used as 64bit pad attribute */
+ MPLS_STATS_LINK,
+ __MPLS_STATS_MAX,
+};
+
+#define MPLS_STATS_MAX (__MPLS_STATS_MAX - 1)
+
+struct mpls_link_stats {
+ __u64 rx_packets; /* total packets received */
+ __u64 tx_packets; /* total packets transmitted */
+ __u64 rx_bytes; /* total bytes received */
+ __u64 tx_bytes; /* total bytes transmitted */
+ __u64 rx_errors; /* bad packets received */
+ __u64 tx_errors; /* packet transmit problems */
+ __u64 rx_dropped; /* packet dropped on receive */
+ __u64 tx_dropped; /* packet dropped on transmit */
+ __u64 rx_noroute; /* no route for packet dest */
+};
+
+#endif /* _MPLS_H */