mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-07 13:15:12 +02:00
xt_pknock: use do_div for long division
This commit is contained in:

committed by
Jan Engelhardt

parent
5104269605
commit
3aa4ca3eaf
@@ -335,7 +335,8 @@ is_interknock_time_exceeded(const struct peer *peer, unsigned int max_time)
|
|||||||
static inline bool
|
static inline bool
|
||||||
has_logged_during_this_minute(const struct peer *peer)
|
has_logged_during_this_minute(const struct peer *peer)
|
||||||
{
|
{
|
||||||
return peer != NULL && peer->login_sec / 60 == ktime_get_seconds() / 60;
|
unsigned long x = ktime_get_seconds(), y = peer->login_sec;
|
||||||
|
return peer != NULL && do_div(y, 60) == do_div(x, 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -709,6 +710,7 @@ has_secret(const unsigned char *secret, unsigned int secret_len, uint32_t ipsrc,
|
|||||||
unsigned int hexa_size;
|
unsigned int hexa_size;
|
||||||
int ret;
|
int ret;
|
||||||
bool fret = false;
|
bool fret = false;
|
||||||
|
unsigned long x;
|
||||||
unsigned int epoch_min;
|
unsigned int epoch_min;
|
||||||
|
|
||||||
if (payload_len == 0)
|
if (payload_len == 0)
|
||||||
@@ -727,7 +729,8 @@ has_secret(const unsigned char *secret, unsigned int secret_len, uint32_t ipsrc,
|
|||||||
hexresult = kzalloc(hexa_size, GFP_ATOMIC);
|
hexresult = kzalloc(hexa_size, GFP_ATOMIC);
|
||||||
if (hexresult == NULL)
|
if (hexresult == NULL)
|
||||||
return false;
|
return false;
|
||||||
epoch_min = ktime_get_seconds() / 60;
|
x = ktime_get_seconds();
|
||||||
|
epoch_min = do_div(x, 60);
|
||||||
|
|
||||||
ret = crypto_shash_setkey(crypto.tfm, secret, secret_len);
|
ret = crypto_shash_setkey(crypto.tfm, secret, secret_len);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
Reference in New Issue
Block a user