Blame SOURCES/0077-nft-shared-Introduce-__get_cmp_data.patch

646579
From c76e3088d700ce416a2ff109168ce124ec1cebf7 Mon Sep 17 00:00:00 2001
c89b2a
From: Phil Sutter <phil@nwl.cc>
c89b2a
Date: Tue, 27 Sep 2022 23:15:37 +0200
c89b2a
Subject: [PATCH] nft-shared: Introduce __get_cmp_data()
c89b2a
c89b2a
This is an inner function to get_cmp_data() returning the op value as-is
c89b2a
for caller examination.
c89b2a
c89b2a
Signed-off-by: Phil Sutter <phil@nwl.cc>
c89b2a
(cherry picked from commit 8dc22798bf813ce92aaac58a6fe8749fe3fc18dc)
c89b2a
c89b2a
Conflicts:
c89b2a
	iptables/nft-shared.c
c89b2a
	iptables/nft-shared.h
c89b2a
- Context changes due to missing commits
c89b2a
  cf14b92bc1a3f ("nft-shared: Drop unused function print_proto()") and
c89b2a
  aa92ec96078d0 ("nft: pass struct nft_xt_ctx to parse_meta()")
c89b2a
---
c89b2a
 iptables/nft-shared.c | 17 ++++++++++-------
c89b2a
 iptables/nft-shared.h |  1 +
c89b2a
 2 files changed, 11 insertions(+), 7 deletions(-)
c89b2a
c89b2a
diff --git a/iptables/nft-shared.c b/iptables/nft-shared.c
c89b2a
index e3ba4ac34146f..af6d33ce6120b 100644
c89b2a
--- a/iptables/nft-shared.c
c89b2a
+++ b/iptables/nft-shared.c
c89b2a
@@ -388,17 +388,20 @@ void print_proto(uint16_t proto, int invert)
c89b2a
 	printf("-p %u ", proto);
c89b2a
 }
c89b2a
 
c89b2a
-void get_cmp_data(struct nftnl_expr *e, void *data, size_t dlen, bool *inv)
c89b2a
+void __get_cmp_data(struct nftnl_expr *e, void *data, size_t dlen, uint8_t *op)
c89b2a
 {
c89b2a
 	uint32_t len;
c89b2a
-	uint8_t op;
c89b2a
 
c89b2a
 	memcpy(data, nftnl_expr_get(e, NFTNL_EXPR_CMP_DATA, &len), dlen);
c89b2a
-	op = nftnl_expr_get_u32(e, NFTNL_EXPR_CMP_OP);
c89b2a
-	if (op == NFT_CMP_NEQ)
c89b2a
-		*inv = true;
c89b2a
-	else
c89b2a
-		*inv = false;
c89b2a
+	*op = nftnl_expr_get_u32(e, NFTNL_EXPR_CMP_OP);
c89b2a
+}
c89b2a
+
c89b2a
+void get_cmp_data(struct nftnl_expr *e, void *data, size_t dlen, bool *inv)
c89b2a
+{
c89b2a
+	uint8_t op;
c89b2a
+
c89b2a
+	__get_cmp_data(e, data, dlen, &op);
c89b2a
+	*inv = (op == NFT_CMP_NEQ);
c89b2a
 }
c89b2a
 
c89b2a
 static void nft_meta_set_to_target(struct nft_xt_ctx *ctx)
c89b2a
diff --git a/iptables/nft-shared.h b/iptables/nft-shared.h
c89b2a
index 29f7056714235..e01381b83c47a 100644
c89b2a
--- a/iptables/nft-shared.h
c89b2a
+++ b/iptables/nft-shared.h
c89b2a
@@ -143,6 +143,7 @@ int parse_meta(struct nftnl_expr *e, uint8_t key, char *iniface,
c89b2a
 		unsigned char *iniface_mask, char *outiface,
c89b2a
 		unsigned char *outiface_mask, uint8_t *invflags);
c89b2a
 void print_proto(uint16_t proto, int invert);
c89b2a
+void __get_cmp_data(struct nftnl_expr *e, void *data, size_t dlen, uint8_t *op);
c89b2a
 void get_cmp_data(struct nftnl_expr *e, void *data, size_t dlen, bool *inv);
c89b2a
 void nft_rule_to_iptables_command_state(struct nft_handle *h,
c89b2a
 					const struct nftnl_rule *r,
c89b2a
-- 
c89b2a
2.38.0
c89b2a