Skip to contentSkip to conversation

datatype: time_print() ignores -T

PATCH New Pablo Neira Ayuso 1 participant 1 message Sep 3, 2021 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 datatype: time_print() ignores -T

Honor NFT_CTX_OUTPUT_NUMERIC_TIME.

 # nft list ruleset
 table ip x {
        set y {
                type ipv4_addr
                flags timeout
                elements = { 1.1.1.1 timeout 5m expires 1m49s40ms }
        }
 }
 # sudo nft -T list ruleset
 table ip x {
        set y {
                type ipv4_addr
                flags timeout
                elements = { 1.1.1.1 timeout 300s expires 108s }
        }
 }
---
 src/datatype.c | 5 +++++
 1 file changed, 5 insertions(+)
src/datatype.c +5 -0
index 7267d60895d8..b849f70833c7 100644
@@ -911,6 +911,11 @@ void time_print(uint64_t ms, struct output_ctx *octx)
 {
 	uint64_t days, hours, minutes, seconds;
 
+	if (nft_output_seconds(octx)) {
+		nft_print(octx, "%" PRIu64 "s", ms / 1000);
+		return;
+	}
+
 	days = ms / 86400000;
 	ms %= 86400000;
 
Signature · 1 line
2.20.1