diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2021-10-04 22:54:10 +0200 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2021-10-18 23:01:19 +0200 |
commit | 48d6d038bb9f8ea09cf4e9cbfd00a9a3baeaa5e5 (patch) | |
tree | 08ebbd7562391010eec016a49cab2f4b4e625e0f | |
parent | 8268fc02d1b98ca9f260787313d13dfcf907a314 (diff) | |
download | backports-48d6d038bb9f8ea09cf4e9cbfd00a9a3baeaa5e5.tar.gz |
backports: Add dev_get_tstats64() and bp_dev_get_tstats64()
dev_get_tstats64() was added as a generic function for .ndo_get_stats64.
The signature of this callback function changed with kernel 4.11, add
the bp_dev_get_tstats64() function on such older kernel version.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r-- | backport/backport-include/linux/netdevice.h | 10 | ||||
-rw-r--r-- | backport/compat/Makefile | 2 | ||||
-rw-r--r-- | backport/compat/backport-4.11.c | 12 | ||||
-rw-r--r-- | backport/compat/backport-5.11.c | 19 |
4 files changed, 43 insertions, 0 deletions
diff --git a/backport/backport-include/linux/netdevice.h b/backport/backport-include/linux/netdevice.h index e9c07a91..d854faef 100644 --- a/backport/backport-include/linux/netdevice.h +++ b/backport/backport-include/linux/netdevice.h @@ -113,4 +113,14 @@ void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s, int netif_rx_any_context(struct sk_buff *skb); #endif /* < 5.10 */ +#if LINUX_VERSION_IS_LESS(5,11,0) +#define dev_get_tstats64 LINUX_BACKPORT(dev_get_tstats64) +void dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s); +#endif /* < 5.11 */ + +#if LINUX_VERSION_IS_LESS(4,11,0) +struct rtnl_link_stats64 * +bp_dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s); +#endif /* < 4.11 */ + #endif /* __BACKPORT_NETDEVICE_H */ diff --git a/backport/compat/Makefile b/backport/compat/Makefile index bbedd49c..e927a0c8 100644 --- a/backport/compat/Makefile +++ b/backport/compat/Makefile @@ -12,11 +12,13 @@ compat-$(CPTCFG_KERNEL_4_6) += backport-4.6.o compat-$(CPTCFG_KERNEL_4_7) += backport-4.7.o compat-$(CPTCFG_KERNEL_4_8) += backport-4.8.o compat-$(CPTCFG_KERNEL_4_10) += backport-4.10.o +compat-$(CPTCFG_KERNEL_4_11) += backport-4.11.o compat-$(CPTCFG_KERNEL_4_18) += backport-4.18.o compat-$(CPTCFG_KERNEL_5_2) += backport-5.2.o backport-genetlink.o compat-$(CPTCFG_KERNEL_5_3) += backport-5.3.o compat-$(CPTCFG_KERNEL_5_5) += backport-5.5.o compat-$(CPTCFG_KERNEL_5_10) += backport-5.10.o +compat-$(CPTCFG_KERNEL_5_11) += backport-5.11.o compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/verify.o compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/pkcs7.asn1.o diff --git a/backport/compat/backport-4.11.c b/backport/compat/backport-4.11.c new file mode 100644 index 00000000..83445856 --- /dev/null +++ b/backport/compat/backport-4.11.c @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/export.h> +#include <linux/netdevice.h> + +struct rtnl_link_stats64 * +bp_dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s) +{ + dev_get_tstats64(dev, s); + return s; +} +EXPORT_SYMBOL_GPL(bp_dev_get_tstats64); diff --git a/backport/compat/backport-5.11.c b/backport/compat/backport-5.11.c new file mode 100644 index 00000000..e60f35cf --- /dev/null +++ b/backport/compat/backport-5.11.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/export.h> +#include <linux/netdevice.h> + +/** + * dev_get_tstats64 - ndo_get_stats64 implementation + * @dev: device to get statistics from + * @s: place to store stats + * + * Populate @s from dev->stats and dev->tstats. Can be used as + * ndo_get_stats64() callback. + */ +void dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s) +{ + netdev_stats_to_stats64(s, &dev->stats); + dev_fetch_sw_netstats(s, dev->tstats); +} +EXPORT_SYMBOL_GPL(dev_get_tstats64); |