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: d0348e0c60 ("task #6995: Implement SO_REUSEADDR (correctly)")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
This commit is contained in:
Axel Lin 2016-01-11 10:44:29 +08:00 committed by Dirk Ziegelmeier
parent 5056d375f2
commit 156ad0dbf5

View File

@ -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 */