[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #55604] UDP can bind to same port when use IPv4 ANY an
From: |
vinu |
Subject: |
[lwip-devel] [bug #55604] UDP can bind to same port when use IPv4 ANY and IPv6 ANY , SO_REUSEADDR is disable and IPV6_V6ONLY is disable |
Date: |
Tue, 29 Jan 2019 11:24:16 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 |
URL:
<https://savannah.nongnu.org/bugs/?55604>
Summary: UDP can bind to same port when use IPv4 ANY and IPv6
ANY ,SO_REUSEADDR is disable and IPV6_V6ONLY is disable
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: vineeshvinu
Submitted on: Tue 29 Jan 2019 04:24:14 PM UTC
Category: UDP
Severity: 3 - Normal
Item Group: Faulty Behaviour
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
lwIP version: 2.1.1
_______________________________________________________
Details:
Below bind will be success since the check inside udp_bind will not match IPv4
any and IPv6 Any type, please check once
IP_GET_TYPE(&ipcb->local_ip) will be 0 and IP_GET_TYPE(ipaddr) is 46
if ((ipcb->local_port == port) &&
(IP_GET_TYPE(&ipcb->local_ip) == IP_GET_TYPE(ipaddr)) &&
/* IP address matches or any IP used? */
(ip_addr_cmp(&ipcb->local_ip, ipaddr) ||
ip_addr_isany(ipaddr) ||
ip_addr_isany(&ipcb->local_ip))) {
/* other PCB already binds to this local IP and port */
LWIP_DEBUGF(UDP_DEBUG,
("udp_bind: local port %"U16_F" already bound by
another pcb\n", port));
return ERR_USE;
}
SO_REUSEADDR = disable
IPV6_V6ONLY = disable
void test2_cmd(unsigned int p0, unsigned int p1, unsigned int p2, unsigned int
p3)
{
int sock4, sock6;
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
int ret;
sock4 = socket(AF_INET, SOCK_DGRAM, 0);
sock6 = socket(AF_INET6, SOCK_DGRAM, 0);
sin.sin_family = AF_INET;
sin.sin_port = htons(4444);
inet_pton(AF_INET, "0.0.0.0", &sin.sin_addr);
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons(4444);
sin6.sin6_flowinfo = 0;
inet_pton(AF_INET6, "::", &sin6.sin6_addr);
int reuse = 0;
ret = setsockopt(sock4, SOL_SOCKET, SO_REUSEADDR, &reuse,
sizeof(reuse));
if (ret < 0) {
perror("reuse4");
}
ret = setsockopt(sock6, SOL_SOCKET, SO_REUSEADDR, &reuse,
sizeof(reuse));
if (ret < 0) {
perror("reuse6");
}
int v6only = 0;
ret = setsockopt(sock6, IPPROTO_IPV6, IPV6_V6ONLY, &v6only,
sizeof(v6only));
if (ret < 0) {
perror("setsockopt");
}
ret = bind(sock4, (struct sockaddr*)&sin, sizeof(sin));
if (ret < 0) {
perror("bind4");
}
ret = bind(sock6, (struct sockaddr*)&sin6, sizeof(sin6));
if (ret < 0) {
perror("bind6");
}
_______________________________________________________
Reply to this item at:
<https://savannah.nongnu.org/bugs/?55604>
_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-devel] [bug #55604] UDP can bind to same port when use IPv4 ANY and IPv6 ANY , SO_REUSEADDR is disable and IPV6_V6ONLY is disable,
vinu <=