Index: sys/netinet/in_pcb.c =================================================================== --- sys/netinet/in_pcb.c +++ sys/netinet/in_pcb.c @@ -2812,6 +2812,7 @@ struct socket *so; int error; char buf[1024]; + bool specific; if (req->oldptr != NULL || req->oldlen != 0) return (EINVAL); @@ -2841,7 +2842,7 @@ htons(params->sop_inc.inc6_zoneid & 0xffff); } #endif - if (params->sop_inc.inc_lport != htons(0)) { + if ((specific = (params->sop_inc.inc_lport != htons(0)))) { if (params->sop_inc.inc_fport == htons(0)) inpi.hash = INP_PCBHASH_WILD(params->sop_inc.inc_lport, pcbinfo->ipi_hashmask); @@ -2861,19 +2862,26 @@ params->sop_inc.inc_fport, pcbinfo->ipi_hashmask); } - while ((inp = inp_next(&inpi)) != NULL) - if (inp->inp_gencnt == params->sop_id) { - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { - INP_WUNLOCK(inp); - return (ECONNRESET); - } - so = inp->inp_socket; - KASSERT(so != NULL, ("inp_socket == NULL")); - soref(so); - error = (*ctloutput_set)(inp, &sopt); - sorele(so); - break; + while ((inp = inp_next(&inpi)) != NULL) { + if (specific) { + if (memcmp(&inp->inp_inc.inc_ie, + ¶ms->sop_inc.inc_ie, + sizeof(struct in_endpoints)) != 0) + continue; + } else if (inp->inp_gencnt != params->sop_id) + continue; + + if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + INP_WUNLOCK(inp); + return (ECONNRESET); } + so = inp->inp_socket; + KASSERT(so != NULL, ("inp_socket == NULL")); + soref(so); + error = (*ctloutput_set)(inp, &sopt); + sorele(so); + break; + } if (inp == NULL) error = ESRCH; return (error);