From c3372ecbecdab099840cdb2af653e60a3ab9ad56 Mon Sep 17 00:00:00 2001 From: vgross Date: Thu, 15 Oct 2015 10:27:18 +0000 Subject: [PATCH] in6_pcbconnect() returns EADDRNOTAVAIL when all the ports in the range portfirst .. portlast are in use. ok millert@, mpi@ --- sys/netinet6/in6_pcb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 67b5384780f..efca7525384 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_pcb.c,v 1.76 2015/10/09 01:10:27 deraadt Exp $ */ +/* $OpenBSD: in6_pcb.c,v 1.77 2015/10/15 10:27:18 vgross Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -450,8 +450,9 @@ in6_pcbconnect(struct inpcb *inp, struct mbuf *nam) KASSERT(IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) || inp->inp_lport); if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6)) { - if (inp->inp_lport == 0) - (void)in6_pcbbind(inp, NULL, curproc); + if (inp->inp_lport == 0 && + in6_pcbbind(inp, NULL, curproc) == EADDRNOTAVAIL) + return (EADDRNOTAVAIL); inp->inp_laddr6 = *in6a; } inp->inp_faddr6 = sin6->sin6_addr; -- 2.20.1