* [PATCH] netfilter: xt_time: use is_leap_year() helper
@ 2026-01-23 8:10 Jinjie Ruan
2026-01-26 13:56 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Jinjie Ruan @ 2026-01-23 8:10 UTC (permalink / raw)
To: pablo, fw, phil, davem, edumazet, kuba, pabeni, horms,
netfilter-devel, coreteam, netdev, linux-kernel
Cc: ruanjinjie
Use the is_leap_year() helper from rtc.h instead of
writing it by hand
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
net/netfilter/xt_time.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/net/netfilter/xt_time.c b/net/netfilter/xt_time.c
index 6aa12d0f54e2..00319d2a54da 100644
--- a/net/netfilter/xt_time.c
+++ b/net/netfilter/xt_time.c
@@ -14,6 +14,7 @@
#include <linux/ktime.h>
#include <linux/module.h>
+#include <linux/rtc.h>
#include <linux/skbuff.h>
#include <linux/types.h>
#include <linux/netfilter/x_tables.h>
@@ -64,11 +65,6 @@ static const u_int16_t days_since_epoch[] = {
3287, 2922, 2557, 2191, 1826, 1461, 1096, 730, 365, 0,
};
-static inline bool is_leap(unsigned int y)
-{
- return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
-}
-
/*
* Each network packet has a (nano)seconds-since-the-epoch (SSTE) timestamp.
* Since we match against days and daytime, the SSTE value needs to be
@@ -138,7 +134,7 @@ static void localtime_3(struct xtm *r, time64_t time)
* (A different approach to use would be to subtract a monthlength
* from w repeatedly while counting.)
*/
- if (is_leap(year)) {
+ if (is_leap_year(year)) {
/* use days_since_leapyear[] in a leap year */
for (i = ARRAY_SIZE(days_since_leapyear) - 1;
i > 0 && days_since_leapyear[i] > w; --i)
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] netfilter: xt_time: use is_leap_year() helper
2026-01-23 8:10 [PATCH] netfilter: xt_time: use is_leap_year() helper Jinjie Ruan
@ 2026-01-26 13:56 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2026-01-26 13:56 UTC (permalink / raw)
To: Jinjie Ruan
Cc: pablo, fw, phil, davem, edumazet, kuba, pabeni, netfilter-devel,
coreteam, netdev, linux-kernel
On Fri, Jan 23, 2026 at 04:10:51PM +0800, Jinjie Ruan wrote:
> Use the is_leap_year() helper from rtc.h instead of
> writing it by hand
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-26 13:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23 8:10 [PATCH] netfilter: xt_time: use is_leap_year() helper Jinjie Ruan
2026-01-26 13:56 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox