summaryrefslogtreecommitdiffstats
path: root/src/expr/flow_offload.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2024-10-02 16:44:49 +0200
committerPhil Sutter <phil@nwl.cc>2025-10-18 21:11:27 +0200
commit5a54b99859fd52d8c7e866b57f6d8fac3e20a78f (patch)
tree6f4638c243b241886fdd0bb8916f074bcd0d12ad /src/expr/flow_offload.c
parent6f24a13a19b8690444564f50e1866fae5abf7687 (diff)
utils: Introduce nftnl_parse_str_attr()HEADmaster
Wrap the common parsing of string attributes in a function. Apart from slightly reducing code size, this unifies callers in conditional freeing of the field in case it was set before (missing in twelve spots) and error checking for failing strdup()-calls (missing in four spots). Signed-off-by: Phil Sutter <phil@nwl.cc> Acked-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src/expr/flow_offload.c')
-rw-r--r--src/expr/flow_offload.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/expr/flow_offload.c b/src/expr/flow_offload.c
index 5f209a6..ce22ec4 100644
--- a/src/expr/flow_offload.c
+++ b/src/expr/flow_offload.c
@@ -79,13 +79,11 @@ static int nftnl_expr_flow_parse(struct nftnl_expr *e, struct nlattr *attr)
if (mnl_attr_parse_nested(attr, nftnl_expr_flow_cb, tb) < 0)
return -1;
- if (tb[NFTA_FLOW_TABLE_NAME]) {
- flow->table_name =
- strdup(mnl_attr_get_str(tb[NFTA_FLOW_TABLE_NAME]));
- if (!flow->table_name)
- return -1;
- e->flags |= (1 << NFTNL_EXPR_FLOW_TABLE_NAME);
- }
+ if (nftnl_parse_str_attr(tb[NFTA_FLOW_TABLE_NAME],
+ NFTNL_EXPR_FLOW_TABLE_NAME,
+ (const char **)&flow->table_name,
+ &e->flags) < 0)
+ return -1;
return ret;
}