Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Setting IPV6_V6ONLY option failed" in redir_handler #11

Closed
cuihaoleo opened this issue Oct 8, 2018 · 3 comments
Closed

"Setting IPV6_V6ONLY option failed" in redir_handler #11

cuihaoleo opened this issue Oct 8, 2018 · 3 comments

Comments

@cuihaoleo
Copy link

First thanks for your team continuing the development of xinetd.

I have noticed that xinetd produce "Setting IPV6_V6ONLY option failed" errors in syslog from time to time. It is just annoying, and xinetd works well. The problem happens in Debian's xinetd (1:2.3.15-6) and FreeBSD's (2.3.15_2), and I think it has been there for a long time.

After debugging, I realized that IPv6 to IPv4 redirection caused the error message. Example config:

service test
{
	disable		= no
	port		= 8080
	redirect	= 202.38.64.1 80
	type		= UNLISTED
	protocol	= tcp
	socket_type	= stream
	user		= nobody
	wait		= no
	flags 	= IPv6
}

Whenever a client connect to :8080, xinetd generates that error:

$ ./xinetd -d -f xinetd.conf
......
18/10/8@16:05:20: DEBUG: 2621 {main_loop} select returned 1
18/10/8@16:05:20: DEBUG: 2621 {server_start} Starting service test
18/10/8@16:05:20: DEBUG: 2621 {main_loop} active_services = 1
18/10/8@16:05:20: ERROR: 22179 {redir_handler} Setting IPV6_V6ONLY option failed (Protocol not available (errno = 92))
18/10/8@16:05:20: DEBUG: 2621 {main_loop} active_services = 1
18/10/8@16:05:20: DEBUG: 2621 {main_loop} select returned 1
18/10/8@16:05:20: DEBUG: 2621 {check_pipe} Got signal 17 (Child exited)
18/10/8@16:05:20: DEBUG: 2621 {child_exit} waitpid returned = 22179
18/10/8@16:05:20: DEBUG: 2621 {server_end} test server 22179 exited
18/10/8@16:05:20: INFO: 2621 {conn_free} freeing connection
18/10/8@16:05:20: DEBUG: 2621 {child_exit} waitpid returned = -1
18/10/8@16:05:20: DEBUG: 2621 {main_loop} active_services = 1

The problematic code is in redirect.c (intruduced since 4587246):

      if( SC_IPV6( scp ) ) {
         if( SC_V6ONLY( scp ) ) {
            v6on = 1;
         } else {
            v6on = 0;
         }
#ifdef IPV6_V6ONLY
         if( setsockopt(RedirServerFd, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&v6on, sizeof(v6on)) < 0 ) { 
            msg( LOG_ERR, func, "Setting IPV6_V6ONLY option failed (%m)" );
         }
#endif
      }

When the redirect target is an IPv4 host, setting IPV6_V6ONLY fails and yields the error message.

In fact, I think this part should be removed. RedirServerFd is a client-side socket (not for listen but for connection to upstream server). AFAIK, setting IPV6_V6ONLY on a client-side socket makes no sense.

@cuihaoleo
Copy link
Author

I create a PR for this.

Other socket options should also be examined. For example, SO_KEEPALIVE is set in both service.c and redirect.c, while TCP_NODELAY is not set in redirect.c.

It is not clear whether some flags in the config affects the connection between xinetd and redir upstream.

@scarabeusiv
Copy link

Hello, the patch seems to be correct. There should be no need to set the option on the client side.

Anyhow the other flags missing in places is mostly caused by most of the code to be copy&paste but since we are only in maintenance mode I personaly don't feel like refactoring :) Yet if there are patches we shall merge them.

@scarabeusiv
Copy link

Closing as I merged the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants