Re: [PATCH conntrack-tools] ipv6: remove use of HAVE_INET_PTON_IPV6

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 29, 2017 at 05:44:15PM +0200, Nicolas Dichtel wrote:
> The goal of this patch is to fix the ipv6 support when conntrackd is
> cross-compiled. The AC_RUN_IFELSE macro must be avoided as much as possible.
> See section 6.6 of the gnu autoconf:
> "If you really need to test for a runtime behavior while configuring, you can
>  write a test program to determine the result, and compile and run it using
>  AC_RUN_IFELSE. Avoid running test programs if possible, because this prevents
>  people from configuring your package for cross-compiling."
> 
> Let's remove this check and test the returned error to handle the case where
> ipv6 is not supported (inet_pton() returns -1 when the family is not supported).

Much less ifdef pollution, much better indeed.

One comment below:

> diff --git a/src/read_config_yy.y b/src/read_config_yy.y
> index 3bb7c5f90017..e4fd277a47ea 100644
> --- a/src/read_config_yy.y
> +++ b/src/read_config_yy.y
> @@ -240,17 +240,17 @@ multicast_option : T_IPV4_ADDR T_IP
>  multicast_option : T_IPV6_ADDR T_IP
>  {
>  	__max_dedicated_links_reached();
> +	int err;
>  
> -#ifdef HAVE_INET_PTON_IPV6
> -	if (inet_pton(AF_INET6, $2,
> -		      &conf.channel[conf.channel_num].u.mcast.in) <= 0) {
> +	err = inet_pton(AF_INET6, $2,
> +			&conf.channel[conf.channel_num].u.mcast.in);
> +	if (err == 0) {
>  		dlog(LOG_WARNING, "%s is not a valid IPv6 address", $2);
>  		break;
> +	} else if (err < 0) {
> +		dlog(LOG_WARNING, "inet_pton(): IPv6 unsupported!");
> +		break;

Probably better to exit() here and to use LOG_ERR instead?

If we cannot interpret this IPv6 address, we shouldn't go much
further.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux