All of lore.kernel.org
 help / color / mirror / Atom feed
* [iptables PATCH] libxtables: Unexport init_extensions*() declarations
@ 2022-06-02 18:24 Phil Sutter
  2022-06-03  5:08 ` Nick
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Sutter @ 2022-06-02 18:24 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Nick, Jan Engelhardt, Pablo Neira Ayuso

The functions are used for static builds to initialize extensions after
libxtables init. Regular library users should not need them, but the
empty declarations introduced in #else case (and therefore present in
user's env) may clash with existing symbol names.

Avoid problems and guard the whole block declaring the function
prototypes and mangling extensions' _init functions by XTABLES_INTERNAL.

Reported-by: Nick <vincent@systemli.org>
Fixes: 6c689b639cf8e ("Simplify static build extension loading")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 include/xtables.h | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/include/xtables.h b/include/xtables.h
index c2694b7b28886..f1937f3ea0530 100644
--- a/include/xtables.h
+++ b/include/xtables.h
@@ -585,27 +585,6 @@ static inline void xtables_print_mark_mask(unsigned int mark,
 	xtables_print_val_mask(mark, mask, NULL);
 }
 
-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
-#	ifdef _INIT
-#		undef _init
-#		define _init _INIT
-#	endif
-	extern void init_extensions(void);
-	extern void init_extensions4(void);
-	extern void init_extensions6(void);
-	extern void init_extensionsa(void);
-	extern void init_extensionsb(void);
-#else
-#	define _init __attribute__((constructor)) _INIT
-#	define EMPTY_FUNC_DEF(x) static inline void x(void) {}
-	EMPTY_FUNC_DEF(init_extensions)
-	EMPTY_FUNC_DEF(init_extensions4)
-	EMPTY_FUNC_DEF(init_extensions6)
-	EMPTY_FUNC_DEF(init_extensionsa)
-	EMPTY_FUNC_DEF(init_extensionsb)
-#	undef EMPTY_FUNC_DEF
-#endif
-
 extern const struct xtables_pprot xtables_chain_protos[];
 extern uint16_t xtables_parse_protocol(const char *s);
 
@@ -663,9 +642,30 @@ void xtables_announce_chain(const char *name);
 #		define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
 #	endif
 
+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
+#	ifdef _INIT
+#		undef _init
+#		define _init _INIT
+#	endif
+	extern void init_extensions(void);
+	extern void init_extensions4(void);
+	extern void init_extensions6(void);
+	extern void init_extensionsa(void);
+	extern void init_extensionsb(void);
+#else
+#	define _init __attribute__((constructor)) _INIT
+#	define EMPTY_FUNC_DEF(x) static inline void x(void) {}
+	EMPTY_FUNC_DEF(init_extensions)
+	EMPTY_FUNC_DEF(init_extensions4)
+	EMPTY_FUNC_DEF(init_extensions6)
+	EMPTY_FUNC_DEF(init_extensionsa)
+	EMPTY_FUNC_DEF(init_extensionsb)
+#	undef EMPTY_FUNC_DEF
+#endif
+
 extern void _init(void);
 
-#endif
+#endif /* XTABLES_INTERNAL */
 
 #ifdef __cplusplus
 } /* extern "C" */
-- 
2.34.1


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

* Re: [iptables PATCH] libxtables: Unexport init_extensions*() declarations
  2022-06-02 18:24 [iptables PATCH] libxtables: Unexport init_extensions*() declarations Phil Sutter
@ 2022-06-03  5:08 ` Nick
  2022-06-03 13:10   ` Nick
  0 siblings, 1 reply; 3+ messages in thread
From: Nick @ 2022-06-03  5:08 UTC (permalink / raw)
  To: Phil Sutter, netfilter-devel; +Cc: Jan Engelhardt, Pablo Neira Ayuso

Thanks. You can also put my whole Name: Nick Hainke <vincent@systemli.org>.
I will test it again. :) I had a longer discussion with another OpenWrt 
member, why everything is done in OpenWrt as it is. Not sure what will 
happen in future with firewall3.

Bests
Nick

On 6/2/22 20:24, Phil Sutter wrote:
> The functions are used for static builds to initialize extensions after
> libxtables init. Regular library users should not need them, but the
> empty declarations introduced in #else case (and therefore present in
> user's env) may clash with existing symbol names.
>
> Avoid problems and guard the whole block declaring the function
> prototypes and mangling extensions' _init functions by XTABLES_INTERNAL.
>
> Reported-by: Nick <vincent@systemli.org>
> Fixes: 6c689b639cf8e ("Simplify static build extension loading")
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
>   include/xtables.h | 44 ++++++++++++++++++++++----------------------
>   1 file changed, 22 insertions(+), 22 deletions(-)
>
> diff --git a/include/xtables.h b/include/xtables.h
> index c2694b7b28886..f1937f3ea0530 100644
> --- a/include/xtables.h
> +++ b/include/xtables.h
> @@ -585,27 +585,6 @@ static inline void xtables_print_mark_mask(unsigned int mark,
>   	xtables_print_val_mask(mark, mask, NULL);
>   }
>   
> -#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
> -#	ifdef _INIT
> -#		undef _init
> -#		define _init _INIT
> -#	endif
> -	extern void init_extensions(void);
> -	extern void init_extensions4(void);
> -	extern void init_extensions6(void);
> -	extern void init_extensionsa(void);
> -	extern void init_extensionsb(void);
> -#else
> -#	define _init __attribute__((constructor)) _INIT
> -#	define EMPTY_FUNC_DEF(x) static inline void x(void) {}
> -	EMPTY_FUNC_DEF(init_extensions)
> -	EMPTY_FUNC_DEF(init_extensions4)
> -	EMPTY_FUNC_DEF(init_extensions6)
> -	EMPTY_FUNC_DEF(init_extensionsa)
> -	EMPTY_FUNC_DEF(init_extensionsb)
> -#	undef EMPTY_FUNC_DEF
> -#endif
> -
>   extern const struct xtables_pprot xtables_chain_protos[];
>   extern uint16_t xtables_parse_protocol(const char *s);
>   
> @@ -663,9 +642,30 @@ void xtables_announce_chain(const char *name);
>   #		define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
>   #	endif
>   
> +#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
> +#	ifdef _INIT
> +#		undef _init
> +#		define _init _INIT
> +#	endif
> +	extern void init_extensions(void);
> +	extern void init_extensions4(void);
> +	extern void init_extensions6(void);
> +	extern void init_extensionsa(void);
> +	extern void init_extensionsb(void);
> +#else
> +#	define _init __attribute__((constructor)) _INIT
> +#	define EMPTY_FUNC_DEF(x) static inline void x(void) {}
> +	EMPTY_FUNC_DEF(init_extensions)
> +	EMPTY_FUNC_DEF(init_extensions4)
> +	EMPTY_FUNC_DEF(init_extensions6)
> +	EMPTY_FUNC_DEF(init_extensionsa)
> +	EMPTY_FUNC_DEF(init_extensionsb)
> +#	undef EMPTY_FUNC_DEF
> +#endif
> +
>   extern void _init(void);
>   
> -#endif
> +#endif /* XTABLES_INTERNAL */
>   
>   #ifdef __cplusplus
>   } /* extern "C" */

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

* Re: [iptables PATCH] libxtables: Unexport init_extensions*() declarations
  2022-06-03  5:08 ` Nick
@ 2022-06-03 13:10   ` Nick
  0 siblings, 0 replies; 3+ messages in thread
From: Nick @ 2022-06-03 13:10 UTC (permalink / raw)
  To: Phil Sutter, netfilter-devel; +Cc: Jan Engelhardt, Pablo Neira Ayuso

The patch works for me. Thanks.

Bests
Nick

On 6/3/22 07:08, Nick wrote:
> Thanks. You can also put my whole Name: Nick Hainke 
> <vincent@systemli.org>.
> I will test it again. :) I had a longer discussion with another 
> OpenWrt member, why everything is done in OpenWrt as it is. Not sure 
> what will happen in future with firewall3.
>
> Bests
> Nick
>
> On 6/2/22 20:24, Phil Sutter wrote:
>> The functions are used for static builds to initialize extensions after
>> libxtables init. Regular library users should not need them, but the
>> empty declarations introduced in #else case (and therefore present in
>> user's env) may clash with existing symbol names.
>>
>> Avoid problems and guard the whole block declaring the function
>> prototypes and mangling extensions' _init functions by XTABLES_INTERNAL.
>>
>> Reported-by: Nick <vincent@systemli.org>
>> Fixes: 6c689b639cf8e ("Simplify static build extension loading")
>> Signed-off-by: Phil Sutter <phil@nwl.cc>
>> ---
>>   include/xtables.h | 44 ++++++++++++++++++++++----------------------
>>   1 file changed, 22 insertions(+), 22 deletions(-)
>>
>> diff --git a/include/xtables.h b/include/xtables.h
>> index c2694b7b28886..f1937f3ea0530 100644
>> --- a/include/xtables.h
>> +++ b/include/xtables.h
>> @@ -585,27 +585,6 @@ static inline void 
>> xtables_print_mark_mask(unsigned int mark,
>>       xtables_print_val_mask(mark, mask, NULL);
>>   }
>>   -#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
>> -#    ifdef _INIT
>> -#        undef _init
>> -#        define _init _INIT
>> -#    endif
>> -    extern void init_extensions(void);
>> -    extern void init_extensions4(void);
>> -    extern void init_extensions6(void);
>> -    extern void init_extensionsa(void);
>> -    extern void init_extensionsb(void);
>> -#else
>> -#    define _init __attribute__((constructor)) _INIT
>> -#    define EMPTY_FUNC_DEF(x) static inline void x(void) {}
>> -    EMPTY_FUNC_DEF(init_extensions)
>> -    EMPTY_FUNC_DEF(init_extensions4)
>> -    EMPTY_FUNC_DEF(init_extensions6)
>> -    EMPTY_FUNC_DEF(init_extensionsa)
>> -    EMPTY_FUNC_DEF(init_extensionsb)
>> -#    undef EMPTY_FUNC_DEF
>> -#endif
>> -
>>   extern const struct xtables_pprot xtables_chain_protos[];
>>   extern uint16_t xtables_parse_protocol(const char *s);
>>   @@ -663,9 +642,30 @@ void xtables_announce_chain(const char *name);
>>   #        define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
>>   #    endif
>>   +#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
>> +#    ifdef _INIT
>> +#        undef _init
>> +#        define _init _INIT
>> +#    endif
>> +    extern void init_extensions(void);
>> +    extern void init_extensions4(void);
>> +    extern void init_extensions6(void);
>> +    extern void init_extensionsa(void);
>> +    extern void init_extensionsb(void);
>> +#else
>> +#    define _init __attribute__((constructor)) _INIT
>> +#    define EMPTY_FUNC_DEF(x) static inline void x(void) {}
>> +    EMPTY_FUNC_DEF(init_extensions)
>> +    EMPTY_FUNC_DEF(init_extensions4)
>> +    EMPTY_FUNC_DEF(init_extensions6)
>> +    EMPTY_FUNC_DEF(init_extensionsa)
>> +    EMPTY_FUNC_DEF(init_extensionsb)
>> +#    undef EMPTY_FUNC_DEF
>> +#endif
>> +
>>   extern void _init(void);
>>   -#endif
>> +#endif /* XTABLES_INTERNAL */
>>     #ifdef __cplusplus
>>   } /* extern "C" */

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

end of thread, other threads:[~2022-06-03 13:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02 18:24 [iptables PATCH] libxtables: Unexport init_extensions*() declarations Phil Sutter
2022-06-03  5:08 ` Nick
2022-06-03 13:10   ` Nick

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.