From 988147adb4ab8a2dc9f0bf01e8bc24e236f98417 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Thu, 8 Sep 2022 17:12:40 +0200 Subject: nft: support dissection of meta pkktype mode Makes iptables-nft-save dump 'nft meta pkttype' rules. Signed-off-by: Florian Westphal Reviewed-by: Phil Sutter --- iptables/nft-shared.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'iptables/nft-shared.c') diff --git a/iptables/nft-shared.c b/iptables/nft-shared.c index 74e19cca..79c93fe8 100644 --- a/iptables/nft-shared.c +++ b/iptables/nft-shared.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -323,6 +324,27 @@ static int parse_meta_mark(struct nft_xt_ctx *ctx, struct nftnl_expr *e) return 0; } +static int parse_meta_pkttype(struct nft_xt_ctx *ctx, struct nftnl_expr *e) +{ + struct xt_pkttype_info *pkttype; + struct xtables_match *match; + uint8_t value; + + match = nft_create_match(ctx, ctx->cs, "pkttype"); + if (!match) + return -1; + + pkttype = (void*)match->m->data; + + if (nftnl_expr_get_u32(e, NFTNL_EXPR_CMP_OP) == NFT_CMP_NEQ) + pkttype->invert = 1; + + value = nftnl_expr_get_u8(e, NFTNL_EXPR_CMP_DATA); + pkttype->pkttype = value; + + return 0; +} + int parse_meta(struct nft_xt_ctx *ctx, struct nftnl_expr *e, uint8_t key, char *iniface, unsigned char *iniface_mask, char *outiface, unsigned char *outiface_mask, uint8_t *invflags) @@ -369,6 +391,9 @@ int parse_meta(struct nft_xt_ctx *ctx, struct nftnl_expr *e, uint8_t key, case NFT_META_MARK: parse_meta_mark(ctx, e); break; + case NFT_META_PKTTYPE: + parse_meta_pkttype(ctx, e); + break; default: return -1; } -- cgit v1.2.3