From: Ian Jackson Date: Sat, 25 Oct 2014 15:56:50 +0000 (+0100) Subject: udp: Insist on only one successful default socket setup X-Git-Tag: proposed.ipv6-polypath-fixes.v1~5 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=commitdiff_plain;h=b3877445fa32f46d70057212cb38347ae1bf4955;ds=sidebyside udp: Insist on only one successful default socket setup If we default the addresses to use, we only insist that at least one of them can be successfully set up. (This is particularly significant when upgrading an existing secnet installation to the new secnet, with IPv6 support, but on a host with no IPv6, and no address configured in the config file. Without this patch, secnet would fail to start up because it would try, and fail, to bind the IPv6 address.) Signed-off-by: Ian Jackson --- diff --git a/udp.c b/udp.c index c526765..dde73ef 100644 --- a/udp.c +++ b/udp.c @@ -397,8 +397,14 @@ static void udp_phase_hook(void *sst, uint32_t new_phase) struct udpsocks *socks=&st->socks; struct udpcommon *uc=&st->uc; int i; - for (i=0; in_socks; i++) - udp_make_socket(uc,&socks->socks[i],M_FATAL); + bool_t anydone=0; + + for (i=0; in_socks; i++) { + bool_t required=st->addr_configured + || (!anydone && i==socks->n_socks-1); + anydone += udp_make_socket(uc,&socks->socks[i], + required ? M_FATAL : M_WARNING); + } udp_socks_register(uc,socks, uc->use_proxy ? "proxy" : "socket");