diff options
author | Charles Longeau <github@chl.be> | 2013-03-30 13:57:38 +0100 |
---|---|---|
committer | Charles Longeau <github@chl.be> | 2013-03-30 13:57:38 +0100 |
commit | d7550405ee29427638f3367e4d14761c1add1626 (patch) | |
tree | e5e910b7b861fcacccfd92c22a95c41067aa3ce2 /contrib | |
parent | fix merge master conflicts (diff) | |
download | OpenSMTPD-d7550405ee29427638f3367e4d14761c1add1626.tar.xz OpenSMTPD-d7550405ee29427638f3367e4d14761c1add1626.zip |
sync with latest asr changes
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/lib/libc/asr/CVS/Entries | 34 | ||||
-rw-r--r-- | contrib/lib/libc/asr/asr.c | 4 | ||||
-rw-r--r-- | contrib/lib/libc/asr/asr_utils.c | 34 | ||||
-rw-r--r-- | contrib/lib/libc/asr/getaddrinfo_async.c | 26 | ||||
-rw-r--r-- | contrib/lib/libc/asr/gethostnamadr_async.c | 6 | ||||
-rw-r--r-- | contrib/lib/libc/asr/getnameinfo_async.c | 31 | ||||
-rw-r--r-- | contrib/lib/libc/asr/res_mkquery.c | 4 |
7 files changed, 93 insertions, 46 deletions
diff --git a/contrib/lib/libc/asr/CVS/Entries b/contrib/lib/libc/asr/CVS/Entries index 1fb3276a..bd795451 100644 --- a/contrib/lib/libc/asr/CVS/Entries +++ b/contrib/lib/libc/asr/CVS/Entries @@ -1,26 +1,26 @@ /Makefile.inc/1.5/Sat Nov 24 17:15:45 2012// /asr.h/1.4/Result of merge// /asr_debug.c/1.10/Result of merge+Sat Nov 24 17:15:46 2012// -/asr_utils.c/1.3/Result of merge// -/getnameinfo_async.c/1.5/Result of merge+Sat Nov 24 17:15:46 2012// /getrrsetbyname_async.c/1.3/Result of merge+Sat Nov 24 17:15:50 2012// /getnetnamadr_async.c/1.7/Result of merge// -/asr.c/1.15/Result of merge// /asr_private.h/1.11/Wed Mar 27 22:31:23 2013// -/async_resolver.3/1.8/Wed Mar 27 22:31:23 2013// -/getaddrinfo.c/1.1/Sat Mar 23 20:37:21 2013// -/getaddrinfo_async.c/1.11/Result of merge// -/gethostnamadr.c/1.2/Sat Mar 23 20:37:21 2013// -/gethostnamadr_async.c/1.13/Result of merge// -/getnameinfo.c/1.1/Sat Mar 23 20:37:21 2013// -/getnetnamadr.c/1.2/Sat Mar 23 20:37:21 2013// -/getrrsetbyname.c/1.1/Sat Mar 23 20:37:21 2013// -/res_debug.c/1.1/Sat Mar 23 20:37:21 2013// -/res_init.c/1.1/Sat Mar 23 20:37:21 2013// -/res_mkquery.c/1.3/Sat Mar 23 20:37:21 2013// -/res_query.c/1.1/Sat Mar 23 20:37:21 2013// /res_search_async.c/1.4/Result of merge// -/res_send.c/1.1/Sat Mar 23 20:37:21 2013// /res_send_async.c/1.7/Result of merge// -/sethostent.c/1.1/Sat Mar 23 20:37:21 2013// +/asr_utils.c/1.4/Result of merge// +/async_resolver.3/1.8/Sat Mar 30 02:18:10 2013// +/getaddrinfo.c/1.1/Sat Mar 30 02:18:10 2013// +/getaddrinfo_async.c/1.12/Result of merge+Sat Mar 30 02:24:26 2013// +/gethostnamadr.c/1.2/Sat Mar 30 02:18:10 2013// +/gethostnamadr_async.c/1.14/Result of merge// +/getnameinfo.c/1.1/Sat Mar 30 02:18:10 2013// +/getnameinfo_async.c/1.6/Result of merge// +/getnetnamadr.c/1.2/Sat Mar 30 02:18:10 2013// +/getrrsetbyname.c/1.1/Sat Mar 30 02:18:10 2013// +/res_debug.c/1.1/Sat Mar 30 02:18:10 2013// +/res_init.c/1.1/Sat Mar 30 02:18:10 2013// +/res_mkquery.c/1.4/Sat Mar 30 02:24:27 2013// +/res_query.c/1.1/Sat Mar 30 02:18:10 2013// +/res_send.c/1.1/Sat Mar 30 02:18:10 2013// +/sethostent.c/1.1/Sat Mar 30 02:18:10 2013// +/asr.c/1.16/Result of merge// D diff --git a/contrib/lib/libc/asr/asr.c b/contrib/lib/libc/asr/asr.c index 96d50e73..97099bb6 100644 --- a/contrib/lib/libc/asr/asr.c +++ b/contrib/lib/libc/asr/asr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asr.c,v 1.15 2013/03/27 07:40:41 eric Exp $ */ +/* $OpenBSD: asr.c,v 1.16 2013/03/30 08:06:42 otto Exp $ */ /* * Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org> * @@ -420,7 +420,7 @@ asr_check_reload(struct asr *asr) if (clock_gettime(CLOCK_MONOTONIC, &tp) == -1) return; - if ((tp.tv_sec - asr->a_rtime) < RELOAD_DELAY) + if ((tp.tv_sec - asr->a_rtime) < RELOAD_DELAY && asr->a_rtime != 0) return; asr->a_rtime = tp.tv_sec; diff --git a/contrib/lib/libc/asr/asr_utils.c b/contrib/lib/libc/asr/asr_utils.c index 1b418605..6f708fd8 100644 --- a/contrib/lib/libc/asr/asr_utils.c +++ b/contrib/lib/libc/asr/asr_utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asr_utils.c,v 1.3 2012/11/24 15:12:48 eric Exp $ */ +/* $OpenBSD: asr_utils.c,v 1.4 2013/03/29 23:01:24 eric Exp $ */ /* * Copyright (c) 2009-2012 Eric Faurot <eric@faurot.net> * @@ -19,13 +19,16 @@ #include <sys/types.h> #include <sys/socket.h> +#include <net/if.h> #include <netinet/in.h> #include <arpa/inet.h> #include <arpa/nameser.h> #include <ctype.h> #include <errno.h> +#include <stdint.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -423,6 +426,8 @@ sockaddr_from_str(struct sockaddr *sa, int family, const char *str) struct in6_addr in6a; struct sockaddr_in *sin; struct sockaddr_in6 *sin6; + char *cp, *str2; + const char *errstr; switch (family) { case PF_UNSPEC: @@ -444,7 +449,19 @@ sockaddr_from_str(struct sockaddr *sa, int family, const char *str) return (0); case PF_INET6: - if (inet_pton(PF_INET6, str, &in6a) != 1) + cp = strchr(str, SCOPE_DELIMITER); + if (cp) { + str2 = strdup(str); + if (str2 == NULL) + return (-1); + str2[cp - str] = '\0'; + if (inet_pton(PF_INET6, str2, &in6a) != 1) { + free(str2); + return (-1); + } + cp++; + free(str2); + } else if (inet_pton(PF_INET6, str, &in6a) != 1) return (-1); sin6 = (struct sockaddr_in6 *)sa; @@ -454,6 +471,19 @@ sockaddr_from_str(struct sockaddr *sa, int family, const char *str) #endif sin6->sin6_family = PF_INET6; sin6->sin6_addr = in6a; + + if (cp == NULL) + return (0); + + if (IN6_IS_ADDR_LINKLOCAL(&in6a) || + IN6_IS_ADDR_MC_LINKLOCAL(&in6a) || + IN6_IS_ADDR_MC_NODELOCAL(&in6a)) + if ((sin6->sin6_scope_id = if_nametoindex(cp))) + return (0); + + sin6->sin6_scope_id = strtonum(cp, 0, UINT32_MAX, &errstr); + if (errstr) + return (-1); return (0); default: diff --git a/contrib/lib/libc/asr/getaddrinfo_async.c b/contrib/lib/libc/asr/getaddrinfo_async.c index 9f381c28..42d7e150 100644 --- a/contrib/lib/libc/asr/getaddrinfo_async.c +++ b/contrib/lib/libc/asr/getaddrinfo_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getaddrinfo_async.c,v 1.11 2013/03/27 07:40:41 eric Exp $ */ +/* $OpenBSD: getaddrinfo_async.c,v 1.12 2013/03/28 11:47:23 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -63,7 +63,7 @@ static const struct match matches[] = { }; #define MATCH_FAMILY(a, b) ((a) == matches[(b)].family || (a) == PF_UNSPEC) -#define MATCH_PROTO(a, b) ((a) == matches[(b)].protocol || (a) == 0) +#define MATCH_PROTO(a, b) ((a) == matches[(b)].protocol || (a) == 0 || matches[(b)].protocol == 0) /* Do not match SOCK_RAW unless explicitely specified */ #define MATCH_SOCKTYPE(a, b) ((a) == matches[(b)].socktype || ((a) == 0 && \ matches[(b)].socktype != SOCK_RAW)) @@ -173,16 +173,6 @@ getaddrinfo_async_run(struct async *as, struct async_res *ar) break; } -#ifdef EAI_PROTOCOL - if (ai->ai_protocol && - ai->ai_protocol != IPPROTO_UDP && - ai->ai_protocol != IPPROTO_TCP) { - ar->ar_gai_errno = EAI_PROTOCOL; - async_set_state(as, ASR_STATE_HALT); - break; - } -#endif - if (ai->ai_socktype == SOCK_RAW && as->as.ai.servname != NULL) { ar->ar_gai_errno = EAI_SERVICE; @@ -517,7 +507,7 @@ static int addrinfo_add(struct async *as, const struct sockaddr *sa, const char *cname) { struct addrinfo *ai; - int i, port; + int i, port, proto; for (i = 0; matches[i].family != -1; i++) { if (matches[i].family != sa->sa_family || @@ -525,9 +515,13 @@ addrinfo_add(struct async *as, const struct sockaddr *sa, const char *cname) !MATCH_PROTO(as->as.ai.hints.ai_protocol, i)) continue; - if (matches[i].protocol == IPPROTO_TCP) + proto = as->as.ai.hints.ai_protocol; + if (!proto) + proto = matches[i].protocol; + + if (proto == IPPROTO_TCP) port = as->as.ai.port_tcp; - else if (matches[i].protocol == IPPROTO_UDP) + else if (proto == IPPROTO_UDP) port = as->as.ai.port_udp; else port = 0; @@ -541,7 +535,7 @@ addrinfo_add(struct async *as, const struct sockaddr *sa, const char *cname) return (EAI_MEMORY); ai->ai_family = sa->sa_family; ai->ai_socktype = matches[i].socktype; - ai->ai_protocol = matches[i].protocol; + ai->ai_protocol = proto; ai->ai_addrlen = SA_LEN(sa); ai->ai_addr = (void*)(ai + 1); if (cname && diff --git a/contrib/lib/libc/asr/gethostnamadr_async.c b/contrib/lib/libc/asr/gethostnamadr_async.c index fa073b09..57e61f90 100644 --- a/contrib/lib/libc/asr/gethostnamadr_async.c +++ b/contrib/lib/libc/asr/gethostnamadr_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gethostnamadr_async.c,v 1.13 2013/03/27 07:40:41 eric Exp $ */ +/* $OpenBSD: gethostnamadr_async.c,v 1.14 2013/03/29 20:04:17 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -502,7 +502,7 @@ hostent_from_packet(int reqtype, int family, char *pkt, size_t pktlen) if (family != AF_INET) break; if (hostent_set_cname(h, rr.rr_dname, 1) == -1) - goto fail; + ; if (hostent_add_addr(h, &rr.rr.in_a.addr, 4) == -1) goto fail; break; @@ -513,7 +513,7 @@ hostent_from_packet(int reqtype, int family, char *pkt, size_t pktlen) if (family != AF_INET6) break; if (hostent_set_cname(h, rr.rr_dname, 1) == -1) - goto fail; + ; if (hostent_add_addr(h, &rr.rr.in_aaaa.addr6, 16) == -1) goto fail; break; diff --git a/contrib/lib/libc/asr/getnameinfo_async.c b/contrib/lib/libc/asr/getnameinfo_async.c index 4ca9c4a9..57ea3234 100644 --- a/contrib/lib/libc/asr/getnameinfo_async.c +++ b/contrib/lib/libc/asr/getnameinfo_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getnameinfo_async.c,v 1.5 2012/11/24 15:12:48 eric Exp $ */ +/* $OpenBSD: getnameinfo_async.c,v 1.6 2013/03/29 21:20:50 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -19,6 +19,7 @@ #include <sys/types.h> #include <sys/socket.h> +#include <net/if.h> #include <netinet/in.h> #include <arpa/inet.h> #include <arpa/nameser.h> @@ -260,9 +261,11 @@ _servname(struct async *as) static int _numerichost(struct async *as) { - void *addr; - char *buf = as->as.ni.hostname; - size_t buflen = as->as.ni.hostnamelen; + unsigned int ifidx; + char scope[IF_NAMESIZE + 1], *ifname; + void *addr; + char *buf = as->as.ni.hostname; + size_t buflen = as->as.ni.hostnamelen; if (as->as.ni.sa.sa.sa_family == AF_INET) addr = &as->as.ni.sa.sain.sin_addr; @@ -272,5 +275,25 @@ _numerichost(struct async *as) if (inet_ntop(as->as.ni.sa.sa.sa_family, addr, buf, buflen) == NULL) return (-1); /* errno set */ + if (as->as.ni.sa.sa.sa_family == AF_INET6 && + as->as.ni.sa.sain6.sin6_scope_id) { + + scope[0] = SCOPE_DELIMITER; + scope[1] = '\0'; + + ifidx = as->as.ni.sa.sain6.sin6_scope_id; + ifname = NULL; + + if (IN6_IS_ADDR_LINKLOCAL(&as->as.ni.sa.sain6.sin6_addr) || + IN6_IS_ADDR_MC_LINKLOCAL(&as->as.ni.sa.sain6.sin6_addr) || + IN6_IS_ADDR_MC_NODELOCAL(&as->as.ni.sa.sain6.sin6_addr)) + ifname = if_indextoname(ifidx, scope + 1); + + if (ifname == NULL) + snprintf(scope + 1, sizeof(scope) - 1, "%u", ifidx); + + strlcat(buf, scope, buflen); + } + return (0); } diff --git a/contrib/lib/libc/asr/res_mkquery.c b/contrib/lib/libc/asr/res_mkquery.c index 21ac2b85..f5479d5c 100644 --- a/contrib/lib/libc/asr/res_mkquery.c +++ b/contrib/lib/libc/asr/res_mkquery.c @@ -1,4 +1,4 @@ -/* $OpenBSD: res_mkquery.c,v 1.3 2012/11/24 15:12:48 eric Exp $ */ +/* $OpenBSD: res_mkquery.c,v 1.4 2013/03/29 22:51:35 guenther Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -89,9 +89,9 @@ res_querydomain(const char *name, /* we really want domain to end with a dot for now */ if (domain && ((n = strlen(domain)) == 0 || domain[n - 1 ] != '.')) { - domain = ndom; strlcpy(ndom, domain, sizeof ndom); strlcat(ndom, ".", sizeof ndom); + domain = ndom; } if (asr_make_fqdn(name, domain, fqdn, sizeof fqdn) == 0) { |