From 156ad0dbf571bd0f7593de0e9f63cc4fbd07084e Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 11 Jan 2016 10:44:29 +0800 Subject: [PATCH] udp_bind: Fix the logic to check both pcbs have REUSEADDR set The code for #if SO_REUSE case does not match the comment. By default, we don't allow to bind to a port that any other udp PCB is already bound to, unless *all* PCBs with that port have tha REUSEADDR flag set. Which means we want to omit checking for the same port if both pcbs have REUSEADDR set. Fix the logic accordingly. Fixes: d0348e0c60b3 ("task #6995: Implement SO_REUSEADDR (correctly)") Signed-off-by: Axel Lin --- src/core/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/udp.c b/src/core/udp.c index 8bae1b48..1b87b3c2 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -962,7 +962,7 @@ udp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port) PCB is already bound to, unless *all* PCBs with that port have tha REUSEADDR flag set. */ #if SO_REUSE - else if (!ip_get_option(pcb, SOF_REUSEADDR) && + else if (!ip_get_option(pcb, SOF_REUSEADDR) || !ip_get_option(ipcb, SOF_REUSEADDR)) { #else /* SO_REUSE */ /* port matches that of PCB in list and REUSEADDR not set -> reject */