IPV6 listener ERROR on binding: Address family not supported by protocol

@jyijyi ,

Disabling the Firewall has no impact below are the logs:
netstat


ip6tables -S

iptables -S

This time have kept the ping no to verify the data connection is on during the entire test. Attached is the wireshark log for reference.
testipv6_8.pcap (57.5 KB)

In the case if the WP76 itself is not able to listen is there any point moving forward to test with PC? Are you suspecting the cm tool not setting up the routes correctly?

Tested with the PC connected to WP and PC establishing the connection I still see the issue.

Firewall on PC Switched off both windows defender and mcaffee

Wireshark logs still show the same response on the TCP Connection using the ncat from nmap for listening.

Wireshark PC logs.pcapng (86.7 KB)

Test 1 tested NC for listener and client on the same device and it works fine so there seems to be no issue with nc listening:

nc listener:
image

nc client using localhost:
image

If pc also has problem, you need to understand why pc is not responding to incoming tcp connection first

attached is the tcpdump logs for the IPv6 listener and client running on the same WP76 module.
localhost successful connect with nc testipv6_12.pcap (1.1 KB)

@jyijyi ,

PC is showing the same problem, ideally I would have expected the module to behave correctly.

Any pointers what is happening here? The local connection seems to be working so I do not see any issue with the listener and client applications or NC.

Legato Listener application working correctly as well for localhost connection:

Logread Logs:

Application start and ncat logs:

Only when connecting from outside the device the connection does not succeed.

here is the listener function:
int start_listener(void)
{

 int listen_sock_fd = -1, client_sock_fd = -1;
struct sockaddr_in6 server_addr, client_addr;
socklen_t client_addr_len;
char str_addr[INET6_ADDRSTRLEN];
int ret, flag;
char ch;

/* Create socket for listening (client requests) */
 LE_INFO("Creating Socket for Listening\n");
listen_sock_fd = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
if(listen_sock_fd == -1) {
	perror("socket()");
	return EXIT_FAILURE;
}

/* Set socket to reuse address */
flag = 1;
ret = setsockopt(listen_sock_fd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
if(ret == -1) {
	perror("setsockopt()");
	return EXIT_FAILURE;
}

server_addr.sin6_family = AF_INET6;
server_addr.sin6_addr = in6addr_any;
server_addr.sin6_port = htons(SERVER_PORT);

/* Bind address and socket together */
 LE_INFO("Binding Socket \n");
ret = bind(listen_sock_fd, (struct sockaddr*)&server_addr, sizeof(server_addr));
if(ret == -1) {
	perror("bind()");
	close(listen_sock_fd);
	return EXIT_FAILURE;
}

/* Create listening queue (client requests) */
 LE_INFO("Listening on the Socket\n");
ret = listen(listen_sock_fd, CLIENT_QUEUE_LEN);
if (ret == -1) {
	perror("listen()");
	close(listen_sock_fd);
	return EXIT_FAILURE;
}

client_addr_len = sizeof(client_addr);

while(1) {
	/* Do TCP handshake with client */
	client_sock_fd = accept(listen_sock_fd,
			(struct sockaddr*)&client_addr,
			&client_addr_len);
	if (client_sock_fd == -1) {
		perror("accept()");
		close(listen_sock_fd);
		return EXIT_FAILURE;
	}

	inet_ntop(AF_INET6, &(client_addr.sin6_addr),
			str_addr, sizeof(str_addr));
	LE_INFO("New connection from: %s:%d ...\n",
			str_addr,
			ntohs(client_addr.sin6_port));

	/* Wait for data from client */
	ret = read(client_sock_fd, &ch, 1);
	if (ret == -1) {
		perror("read()");
		close(client_sock_fd);
		continue;
	}

	/* Do very useful thing with received data :-) */
	ch++;

	/* Send response to client */
	ret = write(client_sock_fd, &ch, 1);
	if (ret == -1) {
		perror("write()");
		close(client_sock_fd);
		continue;
	}

	/* Do TCP teardown */
	ret = close(client_sock_fd);
	if (ret == -1) {
		perror("close()");
		client_sock_fd = -1;
	}

	LE_INFO("Connection closed\n");
}
return EXIT_SUCCESS;

}

If pc has problem, that means it is not solely module problem …

Problem here now is even host pc receiving the packet, it is not responding.

If HL is working fine, you can set up data channel for your pc and compare the wireshark log to see if there is any clue

I Doubt testing on HL series will result into any conclusion. HL is plain modem working on AT Commands and the TCP Stack inside HL would be handling the incoming client connections.

In case if HL is connected to the PC ( in this case the IP stack used for handling connection is the PC ) it will have the same result as we are seeing in WP and PC.

Is there any other way to know how we can debug this further to resolve the issue?

Are you using linux host pc or windows?
Or both have problem?

I suspect the ipv6 network interface is not set to default

You can first fix the issue in pc and see if that is same solution for module

Btw, see if this helps

Hi Let me check out this suggestion. In the meantime tested a few more scenrios:

  1. Between 2 Android phone and the Android application netpal and able to connect on the listener and client on the Android phones.

Android Phone IPv6 client:

Android Phone IPv6 listener:

Able to send and receive data between the two phones:

  1. Android Phone with USB tethering to the PC as listener and the WP76 module as Client.
    2 listener were setup one in phone on port 4055 and another in PC on 4058. The WP76 IPv6
    client could connect to the listener on 4055 in the phone but not on 4058 in the PC.

It looks like some settings is missing on the PC due to which the client is not able to connect to the listener.

Thanks & Regards,

Pankaj Sant

Seems your host pc is windows, right?
Did you see problem with ubuntu pc?

yes The host PC is windows for Ubuntu PC I don’t have it now will check it in the evening.

HI I checked out this suggestion on netcat and I am using the openbsd version from the yocto meta layer.

I removed the busybox version and directly used the netcat-openbsd version giving me more option for both IPv4 and IPv6.

btw can you let me know how to set the IPv6 network interface in this rmnet_data0 as the default interface? I believed Cm tool would do it and not bother about what IP was assigned to the rmnet_data0?

Thanks & Regards,

Pankaj Sant

Hi

A few tests with Android phone Wifi Tethering and USB tethering to PC, it is found that every time the connection is refused when the listener is on the windows PC. Firewall disabled in windows.

On the phone the client connects smoothly to the listener.

Will test further with the linux PC today evening.

I am not sure if nc is doing the binding correctly, from the test till now it seems the client connection never reaches the listener port. tcpdump does produce logs for interface rmnet_data0 but not for port.

Have you tried to ping the public ipv6 address of module?

Yes Ping to the Public IPV6 address is working correctly. As seen in the above messages the connections do happen in the phones

only when setting up with nc over PC or modules directly the connection is failing. Therefore there is no doubt on the SIM card and the Public Static IPv6 Addressess.

only thing I suspect is the NC and the application code may have some issues. looking into some pointers as below:

c - Binding Sockets to IPv6 Addresses - Stack Overflow

c - IPv6 Bind failures - Stack Overflow

c - why can’t i bind ipv6 socket to a linklocal address - Stack Overflow

windows - What is sin6_scope_id for the IPv6 loopback address? - Stack Overflow

Ubuntu Manpage: netinet/in.h - Internet address family

Will directly try with a linux PC and then move onto the module.

That is why i think the ipv6 interface is not the default one

hmmm do you have any idea on how do we set it to default? Is it in the WP76 firmware or on legato application side?