[PATCH libnftnl 2/2] set: use NFTNL_SET_ELEM_VERDICT to print verdict

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch reworks 228e8b174627 ("set_elem: Fix printing of verdict map
elements"), check if NFTNL_SET_ELEM_VERDICT is set then print the set
element verdict.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 include/set_elem.h |  3 +--
 src/set.c          |  2 +-
 src/set_elem.c     | 13 +++++++------
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/set_elem.h b/include/set_elem.h
index 503dcede2c0d..76280051bb80 100644
--- a/include/set_elem.h
+++ b/include/set_elem.h
@@ -21,7 +21,6 @@ struct nftnl_set_elem {
 };
 
 int nftnl_set_elem_snprintf_default(char *buf, size_t size,
-				    const struct nftnl_set_elem *e,
-				    enum nft_data_types dtype);
+				    const struct nftnl_set_elem *e);
 
 #endif
diff --git a/src/set.c b/src/set.c
index 1c29dd26e88d..c46f8277ff68 100644
--- a/src/set.c
+++ b/src/set.c
@@ -829,7 +829,7 @@ static int nftnl_set_snprintf_default(char *buf, size_t remain,
 		SNPRINTF_BUFFER_SIZE(ret, remain, offset);
 
 		ret = nftnl_set_elem_snprintf_default(buf + offset, remain,
-						      elem, s->data_type);
+						      elem);
 		SNPRINTF_BUFFER_SIZE(ret, remain, offset);
 	}
 
diff --git a/src/set_elem.c b/src/set_elem.c
index edcc4a271b24..12eadce1f8e0 100644
--- a/src/set_elem.c
+++ b/src/set_elem.c
@@ -700,11 +700,9 @@ int nftnl_set_elem_parse_file(struct nftnl_set_elem *e, enum nftnl_parse_type ty
 }
 
 int nftnl_set_elem_snprintf_default(char *buf, size_t remain,
-				    const struct nftnl_set_elem *e,
-				    enum nft_data_types dtype)
+				    const struct nftnl_set_elem *e)
 {
-	int dregtype = (dtype == NFT_DATA_VERDICT) ? DATA_VERDICT : DATA_VALUE;
-	int ret, offset = 0, i;
+	int ret, dregtype = DATA_VALUE, offset = 0, i;
 
 	ret = snprintf(buf, remain, "element ");
 	SNPRINTF_BUFFER_SIZE(ret, remain, offset);
@@ -725,6 +723,9 @@ int nftnl_set_elem_snprintf_default(char *buf, size_t remain,
 	ret = snprintf(buf + offset, remain, " : ");
 	SNPRINTF_BUFFER_SIZE(ret, remain, offset);
 
+	if (e->flags & (1 << NFTNL_SET_ELEM_VERDICT))
+		dregtype = DATA_VERDICT;
+
 	ret = nftnl_data_reg_snprintf(buf + offset, remain, &e->data,
 				      DATA_F_NOPFX, dregtype);
 	SNPRINTF_BUFFER_SIZE(ret, remain, offset);
@@ -761,9 +762,9 @@ static int nftnl_set_elem_cmd_snprintf(char *buf, size_t remain,
 	if (type != NFTNL_OUTPUT_DEFAULT)
 		return -1;
 
-	ret = nftnl_set_elem_snprintf_default(buf + offset, remain, e,
-					      NFT_DATA_VALUE);
+	ret = nftnl_set_elem_snprintf_default(buf + offset, remain, e);
 	SNPRINTF_BUFFER_SIZE(ret, remain, offset);
+
 	return offset;
 }
 
-- 
2.30.2




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux