]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables: simplify struct nft_xt_ctx
authorPhil Sutter <phil@nwl.cc>
Thu, 19 Jul 2018 16:31:56 +0000 (18:31 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 19 Jul 2018 20:18:06 +0000 (22:18 +0200)
Replace union 'state' by its sole member.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
iptables/nft-arp.c
iptables/nft-shared.c
iptables/nft-shared.h

index 7b70ef22db8ae69df597b66f909d4507e1bf9fac..06d8664790f4ea6fa408fb6336b6d368d85c3e7f 100644 (file)
@@ -372,7 +372,7 @@ void nft_rule_to_arptables_command_state(const struct nftnl_rule *r,
        struct nftnl_expr *expr;
        int family = nftnl_rule_get_u32(r, NFTNL_RULE_FAMILY);
        struct nft_xt_ctx ctx = {
-               .state.cs = cs,
+               .cs = cs,
                .family = family,
        };
 
@@ -387,7 +387,7 @@ void nft_rule_to_arptables_command_state(const struct nftnl_rule *r,
                        nftnl_expr_get_str(expr, NFTNL_EXPR_NAME);
 
                if (strcmp(name, "counter") == 0)
-                       nft_parse_counter(expr, &ctx.state.cs->arp.counters);
+                       nft_parse_counter(expr, &ctx.cs->arp.counters);
                else if (strcmp(name, "payload") == 0)
                        nft_parse_payload(&ctx, expr);
                else if (strcmp(name, "meta") == 0)
index 0ff07bf3ef1e6f8277e49bbd81b6a06b38ddd220..12c22a40806013fa18d97666bdd2fa843f1da8a4 100644 (file)
@@ -303,7 +303,7 @@ void nft_parse_target(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
        struct xt_entry_target *t;
        size_t size;
        struct nft_family_ops *ops;
-       void *data = ctx->state.cs;
+       void *data = ctx->cs;
 
        target = xtables_find_target(targname, XTF_TRY_LOAD);
        if (target == NULL)
@@ -341,7 +341,7 @@ void nft_parse_match(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
        case NFPROTO_IPV4:
        case NFPROTO_IPV6:
        case NFPROTO_BRIDGE:
-               matches = &ctx->state.cs->matches;
+               matches = &ctx->cs->matches;
                break;
        default:
                fprintf(stderr, "BUG: nft_parse_match() unknown family %d\n",
@@ -368,7 +368,7 @@ void nft_parse_match(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
 
        ops = nft_family_ops_lookup(ctx->family);
        if (ops->parse_match != NULL)
-               ops->parse_match(match, ctx->state.cs);
+               ops->parse_match(match, ctx->cs);
 }
 
 void print_proto(uint16_t proto, int invert)
@@ -431,7 +431,7 @@ static void nft_meta_set_to_target(struct nft_xt_ctx *ctx)
        target->t = t;
 
        ops = nft_family_ops_lookup(ctx->family);
-       ops->parse_target(target, ctx->state.cs);
+       ops->parse_target(target, ctx->cs);
 }
 
 void nft_parse_meta(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
@@ -476,7 +476,7 @@ void nft_parse_bitwise(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
 void nft_parse_cmp(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
 {
        struct nft_family_ops *ops = nft_family_ops_lookup(ctx->family);
-       void *data = ctx->state.cs;
+       void *data = ctx->cs;
        uint32_t reg;
 
        reg = nftnl_expr_get_u32(e, NFTNL_EXPR_CMP_SREG);
@@ -506,7 +506,7 @@ void nft_parse_immediate(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
        struct nft_family_ops *ops;
        const char *jumpto = NULL;
        bool nft_goto = false;
-       void *data = ctx->state.cs;
+       void *data = ctx->cs;
        int verdict;
 
        if (nftnl_expr_is_set(e, NFTNL_EXPR_IMM_DATA)) {
@@ -555,7 +555,7 @@ void nft_rule_to_iptables_command_state(const struct nftnl_rule *r,
        struct nftnl_expr *expr;
        int family = nftnl_rule_get_u32(r, NFTNL_RULE_FAMILY);
        struct nft_xt_ctx ctx = {
-               .state.cs = cs,
+               .cs = cs,
                .family = family,
        };
 
@@ -570,7 +570,7 @@ void nft_rule_to_iptables_command_state(const struct nftnl_rule *r,
                        nftnl_expr_get_str(expr, NFTNL_EXPR_NAME);
 
                if (strcmp(name, "counter") == 0)
-                       nft_parse_counter(expr, &ctx.state.cs->counters);
+                       nft_parse_counter(expr, &ctx.cs->counters);
                else if (strcmp(name, "payload") == 0)
                        nft_parse_payload(&ctx, expr);
                else if (strcmp(name, "meta") == 0)
index 18927a2981977ed959eb404b53fba7c794927892..2ad1ae6bd16517c3104941817d2962695d82e5b6 100644 (file)
@@ -47,9 +47,7 @@ enum {
 };
 
 struct nft_xt_ctx {
-       union {
-               struct iptables_command_state *cs;
-       } state;
+       struct iptables_command_state *cs;
        struct nftnl_expr_iter *iter;
        int family;
        uint32_t flags;