1 From 610d015143e88629eab07067a4ae0c1d7548cfaf Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Thu, 2 Jun 2016 23:03:27 -0300
4 Subject: [PATCH] Rename xfree() to libnftnl_xfree() to avoid symbol naming
7 When ELF binaries and shared libraries are used, the internal
8 functions of libnftnl such as xfree() are not visible to the outside
9 world (their visibility is 'hidden'). Therefore, the fact that other
10 programs (especially nftables) may have symbols with the same name
11 does not cause any problem.
13 However, when doing static linking on a non-ELF platform (such as
14 Blackfin, which uses the FLAT binary format), there is no way of
15 encoding this visibility. Therefore, the xfree() symbols of libnftnl
16 becomes visible to the outside world, causing a conflict with the
17 xfree() symbol defined by nftables.
19 To solve this, this patch renames the libnftnl xfree() function to
22 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
23 [Gustavo: update for version 1.0.7]
24 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
26 include/utils.h | 2 +-
27 src/chain.c | 36 ++++++++++++++++++------------------
30 src/expr/data_reg.c | 2 +-
31 src/expr/dynset.c | 2 +-
32 src/expr/immediate.c | 2 +-
33 src/expr/log.c | 6 +++---
34 src/expr/lookup.c | 2 +-
35 src/expr/match.c | 6 +++---
36 src/expr/target.c | 6 +++---
38 src/object.c | 14 +++++++-------
39 src/rule.c | 32 ++++++++++++++++----------------
41 src/set.c | 26 +++++++++++++-------------
42 src/set_elem.c | 28 ++++++++++++++--------------
43 src/table.c | 14 +++++++-------
44 src/trace.c | 14 +++++++-------
47 21 files changed, 103 insertions(+), 103 deletions(-)
49 diff --git a/include/utils.h b/include/utils.h
50 index 924df32..f02fce7 100644
55 #define __noreturn __attribute__((__noreturn__))
57 -#define xfree(ptr) free((void *)ptr);
58 +#define nftnl_xfree(ptr) free((void *)ptr);
60 #define div_round_up(n, d) (((n) + (d) - 1) / (d))
62 diff --git a/src/chain.c b/src/chain.c
63 index 49cd094..444cb79 100644
66 @@ -96,14 +96,14 @@ EXPORT_SYMBOL_ALIAS(nftnl_chain_alloc, nft_chain_alloc);
67 void nftnl_chain_free(const struct nftnl_chain *c)
69 if (c->flags & (1 << NFTNL_CHAIN_NAME))
71 + nftnl_xfree(c->name);
72 if (c->flags & (1 << NFTNL_CHAIN_TABLE))
74 + nftnl_xfree(c->table);
75 if (c->flags & (1 << NFTNL_CHAIN_TYPE))
77 + nftnl_xfree(c->type);
78 if (c->flags & (1 << NFTNL_CHAIN_DEV))
81 + nftnl_xfree(c->dev);
84 EXPORT_SYMBOL_ALIAS(nftnl_chain_free, nft_chain_free);
86 @@ -120,15 +120,15 @@ void nftnl_chain_unset(struct nftnl_chain *c, uint16_t attr)
89 case NFTNL_CHAIN_NAME:
91 + nftnl_xfree(c->name);
93 case NFTNL_CHAIN_TABLE:
95 + nftnl_xfree(c->table);
99 case NFTNL_CHAIN_TYPE:
101 + nftnl_xfree(c->type);
103 case NFTNL_CHAIN_HOOKNUM:
104 case NFTNL_CHAIN_PRIO:
105 @@ -139,7 +139,7 @@ void nftnl_chain_unset(struct nftnl_chain *c, uint16_t attr)
106 case NFTNL_CHAIN_FAMILY:
108 case NFTNL_CHAIN_DEV:
110 + nftnl_xfree(c->dev);
114 @@ -168,7 +168,7 @@ int nftnl_chain_set_data(struct nftnl_chain *c, uint16_t attr,
116 case NFTNL_CHAIN_NAME:
117 if (c->flags & (1 << NFTNL_CHAIN_NAME))
119 + nftnl_xfree(c->name);
121 c->name = strdup(data);
123 @@ -176,7 +176,7 @@ int nftnl_chain_set_data(struct nftnl_chain *c, uint16_t attr,
125 case NFTNL_CHAIN_TABLE:
126 if (c->flags & (1 << NFTNL_CHAIN_TABLE))
128 + nftnl_xfree(c->table);
130 c->table = strdup(data);
132 @@ -208,7 +208,7 @@ int nftnl_chain_set_data(struct nftnl_chain *c, uint16_t attr,
134 case NFTNL_CHAIN_TYPE:
135 if (c->flags & (1 << NFTNL_CHAIN_TYPE))
137 + nftnl_xfree(c->type);
139 c->type = strdup(data);
141 @@ -216,7 +216,7 @@ int nftnl_chain_set_data(struct nftnl_chain *c, uint16_t attr,
143 case NFTNL_CHAIN_DEV:
144 if (c->flags & (1 << NFTNL_CHAIN_DEV))
146 + nftnl_xfree(c->dev);
148 c->dev = strdup(data);
150 @@ -540,7 +540,7 @@ int nftnl_chain_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_chain *c)
152 if (tb[NFTA_CHAIN_NAME]) {
153 if (c->flags & (1 << NFTNL_CHAIN_NAME))
155 + nftnl_xfree(c->name);
156 c->name = strdup(mnl_attr_get_str(tb[NFTA_CHAIN_NAME]));
159 @@ -548,7 +548,7 @@ int nftnl_chain_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_chain *c)
161 if (tb[NFTA_CHAIN_TABLE]) {
162 if (c->flags & (1 << NFTNL_CHAIN_TABLE))
164 + nftnl_xfree(c->table);
165 c->table = strdup(mnl_attr_get_str(tb[NFTA_CHAIN_TABLE]));
168 @@ -578,7 +578,7 @@ int nftnl_chain_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_chain *c)
170 if (tb[NFTA_CHAIN_TYPE]) {
171 if (c->flags & (1 << NFTNL_CHAIN_TYPE))
173 + nftnl_xfree(c->type);
174 c->type = strdup(mnl_attr_get_str(tb[NFTA_CHAIN_TYPE]));
177 @@ -889,7 +889,7 @@ void nftnl_chain_list_free(struct nftnl_chain_list *list)
184 EXPORT_SYMBOL_ALIAS(nftnl_chain_list_free, nft_chain_list_free);
186 @@ -975,6 +975,6 @@ EXPORT_SYMBOL_ALIAS(nftnl_chain_list_iter_next, nft_chain_list_iter_next);
188 void nftnl_chain_list_iter_destroy(struct nftnl_chain_list_iter *iter)
193 EXPORT_SYMBOL_ALIAS(nftnl_chain_list_iter_destroy, nft_chain_list_iter_destroy);
194 diff --git a/src/common.c b/src/common.c
195 index bf4176c..98f8012 100644
198 @@ -58,7 +58,7 @@ EXPORT_SYMBOL_ALIAS(nftnl_parse_err_alloc, nft_parse_err_alloc);
200 void nftnl_parse_err_free(struct nftnl_parse_err *err)
205 EXPORT_SYMBOL_ALIAS(nftnl_parse_err_free, nft_parse_err_free);
207 diff --git a/src/expr.c b/src/expr.c
208 index 8d5c562..47ecd3d 100644
211 @@ -50,7 +50,7 @@ void nftnl_expr_free(const struct nftnl_expr *expr)
213 expr->ops->free(expr);
218 EXPORT_SYMBOL_ALIAS(nftnl_expr_free, nft_rule_expr_free);
220 @@ -270,7 +270,7 @@ struct nftnl_expr *nftnl_expr_parse(struct nlattr *attr)
229 diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c
230 index 0249258..994b388 100644
231 --- a/src/expr/data_reg.c
232 +++ b/src/expr/data_reg.c
233 @@ -376,7 +376,7 @@ void nftnl_free_verdict(const union nftnl_data_reg *data)
234 switch(data->verdict) {
237 - xfree(data->chain);
238 + nftnl_xfree(data->chain);
242 diff --git a/src/expr/dynset.c b/src/expr/dynset.c
243 index 20a5004..f3d46a7 100644
244 --- a/src/expr/dynset.c
245 +++ b/src/expr/dynset.c
246 @@ -330,7 +330,7 @@ static void nftnl_expr_dynset_free(const struct nftnl_expr *e)
248 struct nftnl_expr_dynset *dynset = nftnl_expr_data(e);
250 - xfree(dynset->set_name);
251 + nftnl_xfree(dynset->set_name);
254 static bool nftnl_expr_dynset_cmp(const struct nftnl_expr *e1,
255 diff --git a/src/expr/immediate.c b/src/expr/immediate.c
256 index 0b188cc..6c17f68 100644
257 --- a/src/expr/immediate.c
258 +++ b/src/expr/immediate.c
259 @@ -44,7 +44,7 @@ nftnl_expr_immediate_set(struct nftnl_expr *e, uint16_t type,
261 case NFTNL_EXPR_IMM_CHAIN:
262 if (e->flags & (1 << NFTNL_EXPR_IMM_CHAIN))
263 - xfree(imm->data.chain);
264 + nftnl_xfree(imm->data.chain);
266 imm->data.chain = strdup(data);
267 if (!imm->data.chain)
268 diff --git a/src/expr/log.c b/src/expr/log.c
269 index b642255..2b24b6d 100644
272 @@ -39,7 +39,7 @@ static int nftnl_expr_log_set(struct nftnl_expr *e, uint16_t type,
274 case NFTNL_EXPR_LOG_PREFIX:
275 if (log->flags & (1 << NFTNL_EXPR_LOG_PREFIX))
276 - xfree(log->prefix);
277 + nftnl_xfree(log->prefix);
279 log->prefix = strdup(data);
281 @@ -155,7 +155,7 @@ nftnl_expr_log_parse(struct nftnl_expr *e, struct nlattr *attr)
283 if (tb[NFTA_LOG_PREFIX]) {
285 - xfree(log->prefix);
286 + nftnl_xfree(log->prefix);
288 log->prefix = strdup(mnl_attr_get_str(tb[NFTA_LOG_PREFIX]));
290 @@ -316,7 +316,7 @@ static void nftnl_expr_log_free(const struct nftnl_expr *e)
292 struct nftnl_expr_log *log = nftnl_expr_data(e);
294 - xfree(log->prefix);
295 + nftnl_xfree(log->prefix);
298 static bool nftnl_expr_log_cmp(const struct nftnl_expr *e1,
299 diff --git a/src/expr/lookup.c b/src/expr/lookup.c
300 index 861815f..1955ed3 100644
301 --- a/src/expr/lookup.c
302 +++ b/src/expr/lookup.c
303 @@ -259,7 +259,7 @@ static void nftnl_expr_lookup_free(const struct nftnl_expr *e)
305 struct nftnl_expr_lookup *lookup = nftnl_expr_data(e);
307 - xfree(lookup->set_name);
308 + nftnl_xfree(lookup->set_name);
311 static bool nftnl_expr_lookup_cmp(const struct nftnl_expr *e1,
312 diff --git a/src/expr/match.c b/src/expr/match.c
313 index dd09e1e..09e35c5 100644
314 --- a/src/expr/match.c
315 +++ b/src/expr/match.c
316 @@ -50,7 +50,7 @@ nftnl_expr_match_set(struct nftnl_expr *e, uint16_t type,
318 case NFTNL_EXPR_MT_INFO:
319 if (e->flags & (1 << NFTNL_EXPR_MT_INFO))
321 + nftnl_xfree(mt->data);
324 mt->data_len = data_len;
325 @@ -147,7 +147,7 @@ static int nftnl_expr_match_parse(struct nftnl_expr *e, struct nlattr *attr)
328 if (e->flags & (1 << NFTNL_EXPR_MT_INFO))
329 - xfree(match->data);
330 + nftnl_xfree(match->data);
332 match_data = calloc(1, len);
333 if (match_data == NULL)
334 @@ -217,7 +217,7 @@ static void nftnl_expr_match_free(const struct nftnl_expr *e)
336 struct nftnl_expr_match *match = nftnl_expr_data(e);
338 - xfree(match->data);
339 + nftnl_xfree(match->data);
342 static bool nftnl_expr_match_cmp(const struct nftnl_expr *e1,
343 diff --git a/src/expr/target.c b/src/expr/target.c
344 index ed4bf7d..5e28925 100644
345 --- a/src/expr/target.c
346 +++ b/src/expr/target.c
347 @@ -50,7 +50,7 @@ nftnl_expr_target_set(struct nftnl_expr *e, uint16_t type,
349 case NFTNL_EXPR_TG_INFO:
350 if (e->flags & (1 << NFTNL_EXPR_TG_INFO))
352 + nftnl_xfree(tg->data);
355 tg->data_len = data_len;
356 @@ -147,7 +147,7 @@ static int nftnl_expr_target_parse(struct nftnl_expr *e, struct nlattr *attr)
360 - xfree(target->data);
361 + nftnl_xfree(target->data);
363 target_data = calloc(1, len);
364 if (target_data == NULL)
365 @@ -217,7 +217,7 @@ static void nftnl_expr_target_free(const struct nftnl_expr *e)
367 struct nftnl_expr_target *target = nftnl_expr_data(e);
369 - xfree(target->data);
370 + nftnl_xfree(target->data);
373 static bool nftnl_expr_target_cmp(const struct nftnl_expr *e1,
374 diff --git a/src/gen.c b/src/gen.c
375 index c69d2f8..0143ea0 100644
378 @@ -37,7 +37,7 @@ EXPORT_SYMBOL_ALIAS(nftnl_gen_alloc, nft_gen_alloc);
380 void nftnl_gen_free(const struct nftnl_gen *gen)
385 EXPORT_SYMBOL_ALIAS(nftnl_gen_free, nft_gen_free);
387 diff --git a/src/object.c b/src/object.c
388 index 0d3dc2b..542211c 100644
391 @@ -47,11 +47,11 @@ EXPORT_SYMBOL(nftnl_obj_alloc);
392 void nftnl_obj_free(const struct nftnl_obj *obj)
394 if (obj->flags & (1 << NFTNL_OBJ_TABLE))
396 + nftnl_xfree(obj->table);
397 if (obj->flags & (1 << NFTNL_OBJ_NAME))
399 + nftnl_xfree(obj->name);
404 EXPORT_SYMBOL(nftnl_obj_free);
406 @@ -74,11 +74,11 @@ void nftnl_obj_set_data(struct nftnl_obj *obj, uint16_t attr,
409 case NFTNL_OBJ_TABLE:
411 + nftnl_xfree(obj->table);
412 obj->table = strdup(data);
416 + nftnl_xfree(obj->name);
417 obj->name = strdup(data);
420 @@ -486,7 +486,7 @@ void nftnl_obj_list_free(struct nftnl_obj_list *list)
427 EXPORT_SYMBOL(nftnl_obj_list_free);
429 @@ -573,6 +573,6 @@ EXPORT_SYMBOL(nftnl_obj_list_iter_next);
431 void nftnl_obj_list_iter_destroy(struct nftnl_obj_list_iter *iter)
436 EXPORT_SYMBOL(nftnl_obj_list_iter_destroy);
437 diff --git a/src/rule.c b/src/rule.c
438 index 22026a4..256b699 100644
441 @@ -72,13 +72,13 @@ void nftnl_rule_free(const struct nftnl_rule *r)
444 if (r->flags & (1 << (NFTNL_RULE_TABLE)))
446 + nftnl_xfree(r->table);
447 if (r->flags & (1 << (NFTNL_RULE_CHAIN)))
449 + nftnl_xfree(r->chain);
450 if (r->flags & (1 << (NFTNL_RULE_USERDATA)))
451 - xfree(r->user.data);
452 + nftnl_xfree(r->user.data);
457 EXPORT_SYMBOL_ALIAS(nftnl_rule_free, nft_rule_free);
459 @@ -95,10 +95,10 @@ void nftnl_rule_unset(struct nftnl_rule *r, uint16_t attr)
462 case NFTNL_RULE_TABLE:
464 + nftnl_xfree(r->table);
466 case NFTNL_RULE_CHAIN:
468 + nftnl_xfree(r->chain);
470 case NFTNL_RULE_HANDLE:
471 case NFTNL_RULE_COMPAT_PROTO:
472 @@ -107,7 +107,7 @@ void nftnl_rule_unset(struct nftnl_rule *r, uint16_t attr)
473 case NFTNL_RULE_FAMILY:
475 case NFTNL_RULE_USERDATA:
476 - xfree(r->user.data);
477 + nftnl_xfree(r->user.data);
481 @@ -132,7 +132,7 @@ int nftnl_rule_set_data(struct nftnl_rule *r, uint16_t attr,
483 case NFTNL_RULE_TABLE:
484 if (r->flags & (1 << NFTNL_RULE_TABLE))
486 + nftnl_xfree(r->table);
488 r->table = strdup(data);
490 @@ -140,7 +140,7 @@ int nftnl_rule_set_data(struct nftnl_rule *r, uint16_t attr,
492 case NFTNL_RULE_CHAIN:
493 if (r->flags & (1 << NFTNL_RULE_CHAIN))
495 + nftnl_xfree(r->chain);
497 r->chain = strdup(data);
499 @@ -163,7 +163,7 @@ int nftnl_rule_set_data(struct nftnl_rule *r, uint16_t attr,
501 case NFTNL_RULE_USERDATA:
502 if (r->flags & (1 << NFTNL_RULE_USERDATA))
503 - xfree(r->user.data);
504 + nftnl_xfree(r->user.data);
506 r->user.data = malloc(data_len);
508 @@ -436,7 +436,7 @@ int nftnl_rule_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_rule *r)
510 if (tb[NFTA_RULE_TABLE]) {
511 if (r->flags & (1 << NFTNL_RULE_TABLE))
513 + nftnl_xfree(r->table);
514 r->table = strdup(mnl_attr_get_str(tb[NFTA_RULE_TABLE]));
517 @@ -444,7 +444,7 @@ int nftnl_rule_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_rule *r)
519 if (tb[NFTA_RULE_CHAIN]) {
520 if (r->flags & (1 << NFTNL_RULE_CHAIN))
522 + nftnl_xfree(r->chain);
523 r->chain = strdup(mnl_attr_get_str(tb[NFTA_RULE_CHAIN]));
526 @@ -473,7 +473,7 @@ int nftnl_rule_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_rule *r)
527 mnl_attr_get_payload(tb[NFTA_RULE_USERDATA]);
529 if (r->flags & (1 << NFTNL_RULE_USERDATA))
530 - xfree(r->user.data);
531 + nftnl_xfree(r->user.data);
533 r->user.len = mnl_attr_get_payload_len(tb[NFTA_RULE_USERDATA]);
535 @@ -915,7 +915,7 @@ EXPORT_SYMBOL_ALIAS(nftnl_expr_iter_next, nft_rule_expr_iter_next);
537 void nftnl_expr_iter_destroy(struct nftnl_expr_iter *iter)
542 EXPORT_SYMBOL_ALIAS(nftnl_expr_iter_destroy, nft_rule_expr_iter_destroy);
544 @@ -976,7 +976,7 @@ void nftnl_rule_list_free(struct nftnl_rule_list *list)
551 EXPORT_SYMBOL_ALIAS(nftnl_rule_list_free, nft_rule_list_free);
553 @@ -1068,6 +1068,6 @@ EXPORT_SYMBOL_ALIAS(nftnl_rule_list_iter_next, nft_rule_list_iter_next);
555 void nftnl_rule_list_iter_destroy(const struct nftnl_rule_list_iter *iter)
560 EXPORT_SYMBOL_ALIAS(nftnl_rule_list_iter_destroy, nft_rule_list_iter_destroy);
561 diff --git a/src/ruleset.c b/src/ruleset.c
562 index b6ca565..0867e2a 100644
565 @@ -71,7 +71,7 @@ void nftnl_ruleset_free(const struct nftnl_ruleset *r)
566 nftnl_set_list_free(r->set_list);
567 if (r->flags & (1 << NFTNL_RULESET_RULELIST))
568 nftnl_rule_list_free(r->rule_list);
572 EXPORT_SYMBOL_ALIAS(nftnl_ruleset_free, nft_ruleset_free);
574 diff --git a/src/set.c b/src/set.c
575 index 14d28b5..0e93503 100644
578 @@ -45,15 +45,15 @@ void nftnl_set_free(const struct nftnl_set *s)
579 struct nftnl_set_elem *elem, *tmp;
581 if (s->flags & (1 << NFTNL_SET_TABLE))
583 + nftnl_xfree(s->table);
584 if (s->flags & (1 << NFTNL_SET_NAME))
586 + nftnl_xfree(s->name);
588 list_for_each_entry_safe(elem, tmp, &s->element_list, head) {
589 list_del(&elem->head);
590 nftnl_set_elem_free(elem);
595 EXPORT_SYMBOL_ALIAS(nftnl_set_free, nft_set_free);
597 @@ -70,10 +70,10 @@ void nftnl_set_unset(struct nftnl_set *s, uint16_t attr)
600 case NFTNL_SET_TABLE:
602 + nftnl_xfree(s->table);
606 + nftnl_xfree(s->name);
608 case NFTNL_SET_FLAGS:
609 case NFTNL_SET_KEY_TYPE:
610 @@ -89,7 +89,7 @@ void nftnl_set_unset(struct nftnl_set *s, uint16_t attr)
611 case NFTNL_SET_GC_INTERVAL:
613 case NFTNL_SET_USERDATA:
614 - xfree(s->user.data);
615 + nftnl_xfree(s->user.data);
619 @@ -122,7 +122,7 @@ int nftnl_set_set_data(struct nftnl_set *s, uint16_t attr, const void *data,
621 case NFTNL_SET_TABLE:
622 if (s->flags & (1 << NFTNL_SET_TABLE))
624 + nftnl_xfree(s->table);
626 s->table = strdup(data);
628 @@ -130,7 +130,7 @@ int nftnl_set_set_data(struct nftnl_set *s, uint16_t attr, const void *data,
631 if (s->flags & (1 << NFTNL_SET_NAME))
633 + nftnl_xfree(s->name);
635 s->name = strdup(data);
637 @@ -174,7 +174,7 @@ int nftnl_set_set_data(struct nftnl_set *s, uint16_t attr, const void *data,
639 case NFTNL_SET_USERDATA:
640 if (s->flags & (1 << NFTNL_SET_USERDATA))
641 - xfree(s->user.data);
642 + nftnl_xfree(s->user.data);
644 s->user.data = malloc(data_len);
646 @@ -474,7 +474,7 @@ int nftnl_set_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_set *s)
648 if (tb[NFTA_SET_TABLE]) {
649 if (s->flags & (1 << NFTNL_SET_TABLE))
651 + nftnl_xfree(s->table);
652 s->table = strdup(mnl_attr_get_str(tb[NFTA_SET_TABLE]));
655 @@ -482,7 +482,7 @@ int nftnl_set_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_set *s)
657 if (tb[NFTA_SET_NAME]) {
658 if (s->flags & (1 << NFTNL_SET_NAME))
660 + nftnl_xfree(s->name);
661 s->name = strdup(mnl_attr_get_str(tb[NFTA_SET_NAME]));
664 @@ -972,7 +972,7 @@ void nftnl_set_list_free(struct nftnl_set_list *list)
671 EXPORT_SYMBOL_ALIAS(nftnl_set_list_free, nft_set_list_free);
673 @@ -1064,7 +1064,7 @@ EXPORT_SYMBOL_ALIAS(nftnl_set_list_iter_next, nft_set_list_iter_next);
675 void nftnl_set_list_iter_destroy(const struct nftnl_set_list_iter *iter)
680 EXPORT_SYMBOL_ALIAS(nftnl_set_list_iter_destroy, nft_set_list_iter_destroy);
682 diff --git a/src/set_elem.c b/src/set_elem.c
683 index fa87476..6d404bd 100644
686 @@ -42,18 +42,18 @@ EXPORT_SYMBOL_ALIAS(nftnl_set_elem_alloc, nft_set_elem_alloc);
687 void nftnl_set_elem_free(struct nftnl_set_elem *s)
689 if (s->flags & (1 << NFTNL_SET_ELEM_CHAIN))
690 - xfree(s->data.chain);
691 + nftnl_xfree(s->data.chain);
693 if (s->flags & (1 << NFTNL_SET_ELEM_EXPR))
694 nftnl_expr_free(s->expr);
696 if (s->flags & (1 << NFTNL_SET_ELEM_USERDATA))
697 - xfree(s->user.data);
698 + nftnl_xfree(s->user.data);
700 if (s->flags & (1 << NFTNL_SET_ELEM_OBJREF))
702 + nftnl_xfree(s->objref);
707 EXPORT_SYMBOL_ALIAS(nftnl_set_elem_free, nft_set_elem_free);
709 @@ -70,7 +70,7 @@ void nftnl_set_elem_unset(struct nftnl_set_elem *s, uint16_t attr)
712 case NFTNL_SET_ELEM_CHAIN:
713 - xfree(s->data.chain);
714 + nftnl_xfree(s->data.chain);
716 case NFTNL_SET_ELEM_FLAGS:
717 case NFTNL_SET_ELEM_KEY: /* NFTA_SET_ELEM_KEY */
718 @@ -80,13 +80,13 @@ void nftnl_set_elem_unset(struct nftnl_set_elem *s, uint16_t attr)
719 case NFTNL_SET_ELEM_EXPIRATION: /* NFTA_SET_ELEM_EXPIRATION */
721 case NFTNL_SET_ELEM_USERDATA: /* NFTA_SET_ELEM_USERDATA */
722 - xfree(s->user.data);
723 + nftnl_xfree(s->user.data);
725 case NFTNL_SET_ELEM_EXPR:
726 nftnl_expr_free(s->expr);
728 case NFTNL_SET_ELEM_OBJREF:
730 + nftnl_xfree(s->objref);
734 @@ -112,7 +112,7 @@ int nftnl_set_elem_set(struct nftnl_set_elem *s, uint16_t attr,
736 case NFTNL_SET_ELEM_CHAIN: /* NFTA_SET_ELEM_DATA */
737 if (s->flags & (1 << NFTNL_SET_ELEM_CHAIN))
738 - xfree(s->data.chain);
739 + nftnl_xfree(s->data.chain);
741 s->data.chain = strdup(data);
743 @@ -127,7 +127,7 @@ int nftnl_set_elem_set(struct nftnl_set_elem *s, uint16_t attr,
745 case NFTNL_SET_ELEM_USERDATA: /* NFTA_SET_ELEM_USERDATA */
746 if (s->flags & (1 << NFTNL_SET_ELEM_USERDATA))
747 - xfree(s->user.data);
748 + nftnl_xfree(s->user.data);
750 s->user.data = malloc(data_len);
752 @@ -137,7 +137,7 @@ int nftnl_set_elem_set(struct nftnl_set_elem *s, uint16_t attr,
754 case NFTNL_SET_ELEM_OBJREF:
755 if (s->flags & (1 << NFTNL_SET_ELEM_OBJREF))
757 + nftnl_xfree(s->objref);
759 s->objref = strdup(data);
761 @@ -431,7 +431,7 @@ static int nftnl_set_elems_parse2(struct nftnl_set *s, const struct nlattr *nest
762 mnl_attr_get_payload(tb[NFTA_SET_ELEM_USERDATA]);
764 if (e->flags & (1 << NFTNL_RULE_USERDATA))
765 - xfree(e->user.data);
766 + nftnl_xfree(e->user.data);
768 e->user.len = mnl_attr_get_payload_len(tb[NFTA_SET_ELEM_USERDATA]);
769 e->user.data = malloc(e->user.len);
770 @@ -515,7 +515,7 @@ int nftnl_set_elems_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_set *s)
772 if (tb[NFTA_SET_ELEM_LIST_TABLE]) {
773 if (s->flags & (1 << NFTNL_SET_TABLE))
775 + nftnl_xfree(s->table);
777 strdup(mnl_attr_get_str(tb[NFTA_SET_ELEM_LIST_TABLE]));
779 @@ -524,7 +524,7 @@ int nftnl_set_elems_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_set *s)
781 if (tb[NFTA_SET_ELEM_LIST_SET]) {
782 if (s->flags & (1 << NFTNL_SET_NAME))
784 + nftnl_xfree(s->name);
786 strdup(mnl_attr_get_str(tb[NFTA_SET_ELEM_LIST_SET]));
788 @@ -810,7 +810,7 @@ EXPORT_SYMBOL_ALIAS(nftnl_set_elems_iter_next, nft_set_elems_iter_next);
790 void nftnl_set_elems_iter_destroy(struct nftnl_set_elems_iter *iter)
795 EXPORT_SYMBOL_ALIAS(nftnl_set_elems_iter_destroy, nft_set_elems_iter_destroy);
797 diff --git a/src/table.c b/src/table.c
798 index 4286d51..1e15ea7 100644
801 @@ -45,9 +45,9 @@ EXPORT_SYMBOL_ALIAS(nftnl_table_alloc, nft_table_alloc);
802 void nftnl_table_free(const struct nftnl_table *t)
804 if (t->flags & (1 << NFTNL_TABLE_NAME))
806 + nftnl_xfree(t->name);
811 EXPORT_SYMBOL_ALIAS(nftnl_table_free, nft_table_free);
813 @@ -64,7 +64,7 @@ void nftnl_table_unset(struct nftnl_table *t, uint16_t attr)
816 case NFTNL_TABLE_NAME:
818 + nftnl_xfree(t->name);
820 case NFTNL_TABLE_FLAGS:
821 case NFTNL_TABLE_FAMILY:
822 @@ -90,7 +90,7 @@ int nftnl_table_set_data(struct nftnl_table *t, uint16_t attr,
824 case NFTNL_TABLE_NAME:
825 if (t->flags & (1 << NFTNL_TABLE_NAME))
827 + nftnl_xfree(t->name);
829 t->name = strdup(data);
831 @@ -229,7 +229,7 @@ int nftnl_table_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_table *t)
833 if (tb[NFTA_TABLE_NAME]) {
834 if (t->flags & (1 << NFTNL_TABLE_NAME))
836 + nftnl_xfree(t->name);
837 t->name = strdup(mnl_attr_get_str(tb[NFTA_TABLE_NAME]));
840 @@ -448,7 +448,7 @@ void nftnl_table_list_free(struct nftnl_table_list *list)
847 EXPORT_SYMBOL_ALIAS(nftnl_table_list_free, nft_table_list_free);
849 @@ -534,6 +534,6 @@ EXPORT_SYMBOL_ALIAS(nftnl_table_list_iter_next, nft_table_list_iter_next);
851 void nftnl_table_list_iter_destroy(const struct nftnl_table_list_iter *iter)
856 EXPORT_SYMBOL_ALIAS(nftnl_table_list_iter_destroy, nft_table_list_iter_destroy);
857 diff --git a/src/trace.c b/src/trace.c
858 index bd05d3c..abfc533 100644
861 @@ -61,13 +61,13 @@ struct nftnl_trace *nftnl_trace_alloc(void)
862 EXPORT_SYMBOL(nftnl_trace_free);
863 void nftnl_trace_free(const struct nftnl_trace *t)
867 - xfree(t->jump_target);
872 + nftnl_xfree(t->chain);
873 + nftnl_xfree(t->table);
874 + nftnl_xfree(t->jump_target);
875 + nftnl_xfree(t->ll.data);
876 + nftnl_xfree(t->nh.data);
877 + nftnl_xfree(t->th.data);
881 EXPORT_SYMBOL(nftnl_trace_is_set);
882 diff --git a/src/udata.c b/src/udata.c
883 index 60c2f34..ec1f7dc 100644
886 @@ -32,7 +32,7 @@ EXPORT_SYMBOL(nftnl_udata_buf_alloc);
888 void nftnl_udata_buf_free(const struct nftnl_udata_buf *buf)
893 EXPORT_SYMBOL(nftnl_udata_buf_free);
895 diff --git a/src/utils.c b/src/utils.c
896 index 3e44960..08f668f 100644
899 @@ -264,7 +264,7 @@ int nftnl_fprintf(FILE *fp, const void *obj, uint32_t cmd, uint32_t type,