Skip to content

Commit

Permalink
MT#57371 split up rtpe_target function
Browse files Browse the repository at this point in the history
... so that the core functionality can be re-used

Change-Id: Ie567110dc3c407ee38dcf6710d090828206db619
  • Loading branch information
rfuchs committed Oct 19, 2023
1 parent b263aba commit e39f2ee
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions daemon/nftables.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,8 @@ static const char *input_immediate(struct nftnl_rule *r, int family, struct add_
}


static const char *rtpe_target(struct nftnl_rule *r, int family, struct add_rule_callbacks *callbacks) {
nftnl_rule_set_str(r, NFTNL_RULE_CHAIN, callbacks->chain);

AUTO_CLEANUP(struct nftnl_expr *e, expr_free) = nftnl_expr_alloc("target");
static const char *rtpe_target_base(struct nftnl_rule *r, struct add_rule_callbacks *callbacks) {
struct nftnl_expr *e = nftnl_expr_alloc("target");
if (!e)
return "failed to allocate target expr for RTPENGINE";

Expand All @@ -417,13 +415,22 @@ static const char *rtpe_target(struct nftnl_rule *r, int family, struct add_rule
nftnl_expr_set(e, NFTNL_EXPR_TG_INFO, &callbacks->rtpe_target_info, sizeof(callbacks->rtpe_target_info));

nftnl_rule_add_expr(r, e);
e = NULL;

e = nftnl_expr_alloc("counter");
return NULL;
}


static const char *rtpe_target(struct nftnl_rule *r, int family, struct add_rule_callbacks *callbacks) {
nftnl_rule_set_str(r, NFTNL_RULE_CHAIN, callbacks->chain);

const char *err = rtpe_target_base(r, callbacks);
if (err)
return err;

struct nftnl_expr *e = nftnl_expr_alloc("counter");
if (!e)
return "failed to allocate counter expr for RTPENGINE";
nftnl_rule_add_expr(r, e);
e = NULL;

return NULL;
}
Expand Down

0 comments on commit e39f2ee

Please sign in to comment.