From f30eae26d813e54897caa1def6501d662dd79228 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 1 Oct 2024 12:59:29 +0200 Subject: utils: Add helpers for interface name wildcards Support simple (suffix) wildcards in NFTNL_{CHAIN,FLOWTABLE}_DEVICES identified by NFTA_DEVICE_PREFIX attribute. Add helpers converting to and from the human-readable asterisk-suffix notation. Signed-off-by: Phil Sutter --- include/linux/netfilter/nf_tables.h | 2 ++ include/utils.h | 5 +++++ 2 files changed, 7 insertions(+) (limited to 'include') diff --git a/include/linux/netfilter/nf_tables.h b/include/linux/netfilter/nf_tables.h index 2beb30b..8e0eb83 100644 --- a/include/linux/netfilter/nf_tables.h +++ b/include/linux/netfilter/nf_tables.h @@ -1784,10 +1784,12 @@ enum nft_synproxy_attributes { * enum nft_device_attributes - nf_tables device netlink attributes * * @NFTA_DEVICE_NAME: name of this device (NLA_STRING) + * @NFTA_DEVICE_PREFIX: device name prefix, a simple wildcard (NLA_STRING) */ enum nft_devices_attributes { NFTA_DEVICE_UNSPEC, NFTA_DEVICE_NAME, + NFTA_DEVICE_PREFIX, __NFTA_DEVICE_MAX }; #define NFTA_DEVICE_MAX (__NFTA_DEVICE_MAX - 1) diff --git a/include/utils.h b/include/utils.h index 247d99d..5a3379f 100644 --- a/include/utils.h +++ b/include/utils.h @@ -83,4 +83,9 @@ int nftnl_fprintf(FILE *fpconst, const void *obj, uint32_t cmd, uint32_t type, int nftnl_set_str_attr(const char **dptr, uint32_t *flags, uint16_t attr, const void *data, uint32_t data_len); +struct nlattr; + +void nftnl_attr_put_ifname(struct nlmsghdr *nlh, const char *ifname); +char *nftnl_attr_get_ifname(const struct nlattr *attr); + #endif -- cgit v1.2.3