lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] Single TCP socket to handle IPv4 and IPv6 traffic


From: Rahul Gundecha
Subject: [lwip-devel] Single TCP socket to handle IPv4 and IPv6 traffic
Date: Thu, 26 Mar 2015 15:36:48 +0530

Hi all,

I need to support IPv6 connections with an existing IPv4 socket based HTTP server. There are two possibilities to accomplish this:
1) Have 2 sockets, one for IPv4, other for IPv6.
2) Have single socket handling both IPv4 and IPv6. Such support do not seem to be present in lwip at this moment.

However I observed that the existing socket which is configured for IPv4 is also able to accept and process IPv6 traffic, without any extra configuration. Hence HTTP server is able to process both IPv4 and IPv6 traffic seamlessly. Is this the recommended way?
If this is approach is right then, one issue is observed. SYN flood from IPv6 hosts results in TCP backlog queue getting full, which results further TCP connections getting rejected forever. Reasoning behind this is as follows: while purging TCP pcbs it is verified that the value of isipv6 member is same for pcb to be purged and the listening pcb (for which the accepts_pending count to be decremented. Since we created the listening socket with IPv4 options, isipv6 value of listening pcb is 'false'
On the other hand, isipv6 value of pcb created for incoming IPv6 based SYN is 'true' Hence accepts_pending count for listening pcb is not decremented.
Following is the patch which kind of fixes the issue. My question is whether the following patch is the right approach, or whether the IPv6 traffic for a specific port should not be redirected to a IPv4 socket with matching port?

diff --git a/src/core/tcp.c b/src/core/tcp.c

index cdd08ae..1a87085 100644

--- a/src/core/tcp.c

+++ b/src/core/tcp.c

@@ -1575,7 +1575,6 @@ tcp_pcb_purge(struct tcp_pcb *pcb)

         tcp_listen_pcbs.listen_pcbs != NULL);

       for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {

         if ((lpcb->local_port == pcb->local_port) &&

-            IP_PCB_IPVER_EQ(pcb, lpcb) &&

             (ipX_addr_isany(PCB_ISIPV6(lpcb), &lpcb->local_ip) ||

              ipX_addr_cmp(PCB_ISIPV6(lpcb), &pcb->local_ip, &lpcb->local_ip))) {

             /* port and address of the listen pcb match the timed-out pcb */


Thanks,
Rahul


reply via email to

[Prev in Thread] Current Thread [Next in Thread]