]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
nat: Eliminate misuse of AF_*
authorMáté Eckl <ecklm94@gmail.com>
Wed, 6 Jun 2018 09:13:35 +0000 (11:13 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 6 Jun 2018 13:02:00 +0000 (15:02 +0200)
Although the value of AF_INET and NFPROTO_IPV4 is the same, the use of
AF_INET was misleading when checking the proto family.
Same with AF_INET6.

Signed-off-by: Máté Eckl <ecklm94@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c
src/netlink_delinearize.c

index 22b14c972d930a55c996154cd12eca5273ee1221..ff75fc451e9ab0301e9ec63b9ecea7f962e3d210 100644 (file)
@@ -2402,8 +2402,8 @@ static int stmt_evaluate_reject(struct eval_ctx *ctx, struct stmt *stmt)
 static int nat_evaluate_family(struct eval_ctx *ctx, struct stmt *stmt)
 {
        switch (ctx->pctx.family) {
-       case AF_INET:
-       case AF_INET6:
+       case NFPROTO_IPV4:
+       case NFPROTO_IPV6:
                return 0;
        default:
                return stmt_error(ctx, stmt,
@@ -2418,7 +2418,7 @@ static int evaluate_addr(struct eval_ctx *ctx, struct stmt *stmt,
        const struct datatype *dtype;
        unsigned int len;
 
-       if (pctx->family == AF_INET) {
+       if (pctx->family == NFPROTO_IPV4) {
                dtype = &ipaddr_type;
                len   = 4 * BITS_PER_BYTE;
        } else {
index 7d882ebac555a89f8b465ba6aad6580051b6fefd..2c938e520357c856456c574012f01ebe8e6ec0ba 100644 (file)
@@ -878,7 +878,7 @@ static void netlink_parse_nat(struct netlink_parse_ctx *ctx,
                        goto out_err;
                }
 
-               if (family == AF_INET)
+               if (family == NFPROTO_IPV4)
                        expr_set_type(addr, &ipaddr_type, BYTEORDER_BIG_ENDIAN);
                else
                        expr_set_type(addr, &ip6addr_type,
@@ -895,7 +895,7 @@ static void netlink_parse_nat(struct netlink_parse_ctx *ctx,
                        goto out_err;
                }
 
-               if (family == AF_INET)
+               if (family == NFPROTO_IPV4)
                        expr_set_type(addr, &ipaddr_type, BYTEORDER_BIG_ENDIAN);
                else
                        expr_set_type(addr, &ip6addr_type,