summaryrefslogtreecommitdiffstats
path: root/src/str_array.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2024-10-01 12:59:29 +0200
committerPhil Sutter <phil@nwl.cc>2025-09-30 23:02:32 +0200
commitf30eae26d813e54897caa1def6501d662dd79228 (patch)
tree4623427758b9224d3ecbc6cd0f65d141d5f017b3 /src/str_array.c
parenteb8fb569c501dc088dc950061369102687f8d2a5 (diff)
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 <phil@nwl.cc>
Diffstat (limited to 'src/str_array.c')
-rw-r--r--src/str_array.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/str_array.c b/src/str_array.c
index 5669c61..4292c98 100644
--- a/src/str_array.c
+++ b/src/str_array.c
@@ -45,9 +45,13 @@ int nftnl_parse_devs(struct nftnl_str_array *sa, const struct nlattr *nest)
int len = 0;
mnl_attr_for_each_nested(attr, nest) {
- if (mnl_attr_get_type(attr) != NFTA_DEVICE_NAME)
+ switch(mnl_attr_get_type(attr)) {
+ default:
return -1;
- len++;
+ case NFTA_DEVICE_NAME:
+ case NFTA_DEVICE_PREFIX:
+ len++;
+ }
}
nftnl_str_array_clear(sa);
@@ -56,7 +60,7 @@ int nftnl_parse_devs(struct nftnl_str_array *sa, const struct nlattr *nest)
return -1;
mnl_attr_for_each_nested(attr, nest) {
- sa->array[sa->len] = strdup(mnl_attr_get_str(attr));
+ sa->array[sa->len] = nftnl_attr_get_ifname(attr);
if (!sa->array[sa->len]) {
nftnl_str_array_clear(sa);
return -1;