All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xtables-addons 3.15 doesn't compile on 32-bit x86
@ 2021-02-21 14:50 andy
  2021-02-24  0:19 ` Jan Engelhardt
  0 siblings, 1 reply; 4+ messages in thread
From: andy @ 2021-02-21 14:50 UTC (permalink / raw)
  To: netfilter-devel

Xtables-addons 3.15 doesn't compile with 32-bit x86 kernel:

ERROR: "__divdi3"
[/mnt/sdb1/lamp32-11/build/xtables-addons-3.15/extensions/pknock/xt_pknock.ko]
undefined!
 
Replace long integer division with do_div().

This patch fixes it:

--- extensions/pknock/xt_pknock.c-orig                                  
                                                 
+++ extensions/pknock/xt_pknock.c                                       
                                                 
@@ -335,7 +335,9 @@                                                     
                                                 
 static inline bool                                                     
                                                 
 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();                          
                                                 
+       unsigned long y = peer->login_sec;                              
                                                 
+       return peer != NULL && do_div(y, 60) == do_div(x, 60);          
                                                 
 }                                                                      
                                                 
                                                                        
                                                 
 /**                                                                    
                                                 
@@ -709,6 +711,7 @@                                                     
                                                 
        unsigned int hexa_size;                                         
                                                 
        int ret;                                                        
                                                 
        bool fret = false;                                              
                                                 
+       unsigned long x = ktime_get_seconds();                          
                                                 
        unsigned int epoch_min;                                         
                                                 
                                                                        
                                                 
        if (payload_len == 0)                                           
                                                 
@@ -727,7 +730,8 @@                                                     
                                                 
        hexresult = kzalloc(hexa_size, GFP_ATOMIC);                     
                                                 
        if (hexresult == NULL)                                          
                                                 
                return false;                                           
                                                 
-       epoch_min = ktime_get_seconds() / 60;                           
                                                 
+                                                                       
                                                 
+       epoch_min = do_div(x, 60);                                      
                                                 
                                                                        
                                                 
        ret = crypto_shash_setkey(crypto.tfm, secret, secret_len);      
                                                 
        if (ret != 0) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xtables-addons 3.15 doesn't compile on 32-bit x86
  2021-02-21 14:50 [PATCH] xtables-addons 3.15 doesn't compile on 32-bit x86 andy
@ 2021-02-24  0:19 ` Jan Engelhardt
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2021-02-24  0:19 UTC (permalink / raw)
  To: andy; +Cc: netfilter-devel


On Sunday 2021-02-21 15:50, andy@asjohnson.com wrote:

>Xtables-addons 3.15 doesn't compile with 32-bit x86 kernel:
>
>ERROR: "__divdi3"
>[/mnt/sdb1/lamp32-11/build/xtables-addons-3.15/extensions/pknock/xt_pknock.ko]
>undefined!
> 
>Replace long integer division with do_div().
>
>This patch fixes it:

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] xtables-addons 3.15 doesn't compile on 32-bit x86
  2021-02-28 14:54 andy
@ 2021-02-28 16:57 ` Jan Engelhardt
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2021-02-28 16:57 UTC (permalink / raw)
  To: andy; +Cc: netfilter-devel

On Sunday 2021-02-28 15:54, andy@asjohnson.com wrote:

>The original patch for long division on x86 didn't take into account
>the use of short circuit logic for checking if peer is NULL before
>testing it. Here is a revised patch to v3.16:
>
>--- xtables-addons-3.16-orig/extensions/pknock/xt_pknock.c
>+++ xtables-addons-3.16-patched/extensions/pknock/xt_pknock.c
>@@ -311,9 +311,13 @@
> static inline bool
> autoclose_time_passed(const struct peer *peer, unsigned int
>autoclose_time)
> {

Applied.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] xtables-addons 3.15 doesn't compile on 32-bit x86
@ 2021-02-28 14:54 andy
  2021-02-28 16:57 ` Jan Engelhardt
  0 siblings, 1 reply; 4+ messages in thread
From: andy @ 2021-02-28 14:54 UTC (permalink / raw)
  To: netfilter-devel

The original patch for long division on x86 didn't take into account
the use of short circuit logic for checking if peer is NULL before
testing it. Here is a revised patch to v3.16:

--- xtables-addons-3.16-orig/extensions/pknock/xt_pknock.c
+++ xtables-addons-3.16-patched/extensions/pknock/xt_pknock.c
@@ -311,9 +311,13 @@
 static inline bool
 autoclose_time_passed(const struct peer *peer, unsigned int
autoclose_time)
 {
-	unsigned long x = ktime_get_seconds();
-	unsigned long y = peer->login_sec + autoclose_time * 60;
-	return peer != NULL && autoclose_time != 0 && time_after(x, y);
+	if (peer != NULL) {
+		unsigned long x = ktime_get_seconds();
+		unsigned long y = peer->login_sec + autoclose_time * 60;
+		return autoclose_time != 0 && time_after(x, y);
+	} else {
+		return 0;
+	}
 }
 
 /**
@@ -335,8 +339,12 @@
 static inline bool
 has_logged_during_this_minute(const struct peer *peer)
 {
-	unsigned long x = ktime_get_seconds(), y = peer->login_sec;
-	return peer != NULL && do_div(y, 60) == do_div(x, 60);
+	if (peer != NULL) {
+		unsigned long x = ktime_get_seconds(), y = peer->login_sec;
+		return do_div(y, 60) == do_div(x, 60);
+	} else {
+		return 0;
+	}
 }
 
 /**


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-28 16:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-21 14:50 [PATCH] xtables-addons 3.15 doesn't compile on 32-bit x86 andy
2021-02-24  0:19 ` Jan Engelhardt
2021-02-28 14:54 andy
2021-02-28 16:57 ` Jan Engelhardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.