Commit d3bf0d70 authored by Ondřej Surý's avatar Ondřej Surý

Merge branch '2-the-compilation-is-broken-on-linux' into 'master'

Resolve "The compilation is broken on Linux"

Closes #2 and #1

See merge request !2
parents ab21dbd5 a2f6bb77
Pipeline #308 passed with stages
in 1 minute and 11 seconds
*~
*.bak
/autom4te.cache/
/configure
/Makefile.in
/Makefile
*.o
/genreport
*~
.deps/
/Makefile
/Makefile.in
/autom4te.cache/
/config.guess
/config.h
/config.h.in
/config.log
/config.status
.deps/
/config.sub
/configure
/configure
/genreport
image: "debian:sid"
variables:
DEBIAN_FRONTEND: noninteractive
LC_ALL: C.UTF-8
......@@ -5,13 +7,13 @@ variables:
stages:
- build
- test
build:debian:sid:amd64:
image: "debian:sid"
build:
stage: build
tags:
- linux
- docker
stage: build
before_script:
- apt-get update
- apt-get -y install autotools-dev build-essential autoconf automake libtool
......@@ -21,5 +23,16 @@ build:debian:sid:amd64:
- make -k all V=1
artifacts:
expire_in: '1 week'
untracked: true
when: on_failure
paths:
- config.log
- genreport
test:
stage: test
tags:
- linux
- docker
script:
- echo . f.root-servers.net | ./genreport
dependencies:
- build
......@@ -7,6 +7,55 @@ AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([Makefile])
AC_USE_SYSTEM_EXTENSIONS
AC_CANONICAL_HOST
AC_CHECK_LIB(resolv,res_init)
AC_CHECK_LIB(bind,res_init)
AC_SEARCH_LIBS([res_mkquery],[resolv bind])
AC_SEARCH_LIBS([res_9_mkquery],[resolv bind])
AC_SEARCH_LIBS([__res_mkquery],[resolv bind])
AC_CHECK_HEADERS(sys/types.h netinet/in.h arpa/nameser.h resolv.h)
AC_MSG_CHECKING(for res_getservers)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
],
[
union res_sockaddr_union servers[10];
res_getservers(&_res, &servers, sizeof(servers)/sizeof(*servers));
],
[
AC_DEFINE([HAVE_RES_GETSERVERS], [1],
[Define to 1 if you have the `res_getservers' function.])
AC_MSG_RESULT(yes)
],
[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for struct sockaddr_in.sin_len)
AC_TRY_COMPILE([
#include <sys/socket.h>
#include <netinet/in.h>
],
[
struct sockaddr_in sin;
sin.sin_len = 0;
],
[
AC_DEFINE([HAVE_SIN_LEN], [1],
[Define to 1 struct sockaddr_in has sin_len.])
AC_MSG_RESULT(yes)
],
[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for struct sockaddr_in6.sin6_len)
AC_TRY_COMPILE([
#include <sys/socket.h>
#include <netinet/in.h>
],
[
struct sockaddr_in6 sin6;
sin6.sin6_len = 0;
],
[
AC_DEFINE([HAVE_SIN6_LEN], [1],
[Define to 1 struct sockaddr_in6 has sin6_len.])
AC_MSG_RESULT(yes)
],
[AC_MSG_RESULT(no)])
AC_OUTPUT
......@@ -8,6 +8,8 @@
#define FD_SETSIZE 1600
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
......@@ -36,6 +38,10 @@
#include <resolv.h>
#include <signal.h>
#ifndef FD_COPY
#define FD_COPY(x, y) memmove(y, x, sizeof(*x))
#endif
#define ns_t_dname 39
#define ns_t_sink 40
#define ns_t_apl 42
......@@ -99,7 +105,16 @@ static int inorder = 0;
static int serial = 0;
static long long sent;
#ifdef HAVE_RES_GETSERVERS
static union res_sockaddr_union servers[10];
#else
static union {
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
} servers[10];
#endif
static int nservers = 0;
int ident = 0;
......@@ -427,7 +442,7 @@ storage_equal(struct sockaddr_storage *s1, struct sockaddr_storage *s2) {
struct sockaddr_in *sin1, *sin2;
struct sockaddr_in6 *sin61, *sin62;
if (s1->ss_len != s2->ss_len || s1->ss_family != s2->ss_family)
if (s1->ss_family != s2->ss_family)
return (0);
switch (s1->ss_family) {
......@@ -799,13 +814,16 @@ addtag(struct workitem *item, const char *tag) {
static void
resend(struct workitem *item) {
int n, fd = -1;
socklen_t ss_len;
switch (item->summary->storage.ss_family) {
case AF_INET:
fd = udp4;
ss_len = sizeof(struct sockaddr_in);
break;
case AF_INET6:
fd = udp6;
ss_len = sizeof(struct sockaddr_in6);
break;
}
......@@ -826,8 +844,7 @@ resend(struct workitem *item) {
}
n = sendto(fd, item->buf, item->buflen, 0,
(struct sockaddr *)&item->summary->storage,
item->summary->storage.ss_len);
(struct sockaddr *)&item->summary->storage, ss_len);
if (n > 0) {
if (debug)
printf("resend %s rdlen=%u udpsize=%u flags=%04x "
......@@ -863,13 +880,17 @@ dotest(struct workitem *item) {
unsigned char *cp;
unsigned int ttl;
int n, fd, id, tries = 0, opcode;
socklen_t ss_len;
switch (item->summary->storage.ss_family) {
case AF_INET:
fd = udp4;
ss_len = sizeof(struct sockaddr_in);
break;
case AF_INET6:
fd = udp6;
ss_len = sizeof(struct sockaddr_in6);
break;
}
......@@ -996,8 +1017,7 @@ dotest(struct workitem *item) {
}
n = sendto(fd, item->buf, item->buflen, 0,
(struct sockaddr *)&item->summary->storage,
item->summary->storage.ss_len);
(struct sockaddr *)&item->summary->storage, ss_len);
}
if (n > 0) {
......@@ -1039,14 +1059,18 @@ check(char *zone, char *ns, char *address, struct summary *parent) {
memset(&storage, 0, sizeof(storage));
if (inet_pton(AF_INET6, address, &addr6) == 1) {
struct sockaddr_in6 *s = (struct sockaddr_in6 *)&storage;
#ifdef HAVE_SIN6_LEN
s->sin6_len = sizeof(struct sockaddr_in6);
#endif
s->sin6_family = AF_INET6;
s->sin6_port = htons(53);
s->sin6_addr = addr6;
fd = udp6;
} else if (inet_pton(AF_INET, address, &addr) == 1) {
struct sockaddr_in *s = (struct sockaddr_in *)&storage;
#ifdef HAVE_SIN_LEN
s->sin_len = sizeof(struct sockaddr_in);
#endif
s->sin_family = AF_INET;
s->sin_port = htons(53);
s->sin_addr = addr;
......@@ -1133,6 +1157,7 @@ static void
dolookup(struct workitem *item, int type) {
char name[1024];
int n, fd = -1;
socklen_t ss_len;
item->summary->tests++;
item->summary->type = item->type = type;
......@@ -1148,9 +1173,11 @@ dolookup(struct workitem *item, int type) {
switch (item->summary->storage.ss_family) {
case AF_INET:
fd = udp4;
ss_len = sizeof(struct sockaddr_in);
break;
case AF_INET6:
fd = udp6;
ss_len = sizeof(struct sockaddr_in6);
break;
}
......@@ -1218,8 +1245,7 @@ dolookup(struct workitem *item, int type) {
}
n = sendto(fd, item->buf, item->buflen, 0,
(struct sockaddr *)&item->summary->storage,
item->summary->storage.ss_len);
(struct sockaddr *)&item->summary->storage, ss_len);
}
if (n > 0) {
if (debug)
......@@ -1946,6 +1972,7 @@ connectdone(int fd) {
static void
connecttoserver(struct workitem *item) {
int fd, n, on = 1;
socklen_t ss_len;
fd = socket(item->summary->storage.ss_family,
SOCK_STREAM, IPPROTO_TCP);
......@@ -1964,6 +1991,7 @@ connecttoserver(struct workitem *item) {
freeitem(item);
return;
}
/*
* Make the socket non blocking.
*/
......@@ -1977,6 +2005,7 @@ connecttoserver(struct workitem *item) {
return;
}
#ifdef SO_NOSIGPIPE
/*
* Don't generate a SIG_PIPE if there is a I/O error on this socket.
*/
......@@ -1989,12 +2018,21 @@ connecttoserver(struct workitem *item) {
freeitem(item);
return;
}
#endif
switch (item->summary->storage.ss_family) {
case AF_INET:
ss_len = sizeof(struct sockaddr_in);
break;
case AF_INET6:
ss_len = sizeof(struct sockaddr_in6);
break;
}
/*
* Start the actual connect.
*/
n = connect(fd, (struct sockaddr *)&item->summary->storage,
item->summary->storage.ss_len);
n = connect(fd, (struct sockaddr *)&item->summary->storage, ss_len);
if (n == -1 && errno == EINPROGRESS) {
if (!item->outstanding++)
outstanding++;
......@@ -2124,7 +2162,9 @@ icmp4read(int fd) {
id = (buf[msgdata] << 8) + buf[msgdata + 1];
memset(&storage, 0, sizeof(storage));
sin->sin_family = AF_INET;
#ifdef HAVE_SIN_LEN
sin->sin_len = sizeof(*sin);
#endif
sin->sin_addr = icmp->icmp_ip.ip_dst;
sin->sin_port = udphdr->uh_dport;
item = finditem(&storage, id);
......@@ -2138,7 +2178,9 @@ icmp4read(int fd) {
id = (buf[msgdata + 2] << 8) + buf[msgdata + 3];
memset(&storage, 0, sizeof(storage));
sin->sin_family = AF_INET;
#ifdef HAVE_SIN_LEN
sin->sin_len = sizeof(*sin);
#endif
sin->sin_addr = icmp->icmp_ip.ip_dst;
sin->sin_port = tcphdr->th_dport;
item = finditem(&storage, id);
......@@ -2207,7 +2249,9 @@ icmp4read(int fd) {
id = (buf[msgdata] << 8) + buf[msgdata + 1];
memset(&storage, 0, sizeof(storage));
sin->sin_family = AF_INET;
#ifdef HAVE_SIN_LEN
sin->sin_len = sizeof(*sin);
#endif
sin->sin_addr = icmp->icmp_ip.ip_dst;
sin->sin_port = udphdr->uh_dport;
item = finditem(&storage, id);
......@@ -2221,7 +2265,9 @@ icmp4read(int fd) {
id = (buf[msgdata + 2] << 8) + buf[msgdata + 3];
memset(&storage, 0, sizeof(storage));
sin->sin_family = AF_INET;
#ifdef HAVE_SIN_LEN
sin->sin_len = sizeof(*sin);
#endif
sin->sin_addr = icmp->icmp_ip.ip_dst;
sin->sin_port = tcphdr->th_dport;
item = finditem(&storage, id);
......@@ -2303,7 +2349,9 @@ icmp6read(int fd) {
id = (buf[msgdata] << 8) + buf[msgdata + 1];
memset(&storage, 0, sizeof(storage));
sin6->sin6_family = AF_INET6;
#ifdef HAVE_SIN6_LEN
sin6->sin6_len = sizeof(*sin6);
#endif
memcpy(&sin6->sin6_addr, &ip6->ip6_dst, 16);
sin6->sin6_port = udphdr->uh_dport;
item = finditem(&storage, id);
......@@ -2336,7 +2384,9 @@ icmp6read(int fd) {
id = (buf[msgdata] << 8) + buf[msgdata + 1];
memset(&storage, 0, sizeof(storage));
sin6->sin6_family = AF_INET6;
#ifdef HAVE_SIN6_LEN
sin6->sin6_len = sizeof(*sin6);
#endif
memcpy(&sin6->sin6_addr, &ip6->ip6_dst, 16);
sin6->sin6_port = udphdr->uh_dport;
item = finditem(&storage, id);
......@@ -2350,7 +2400,9 @@ icmp6read(int fd) {
id = (buf[msgdata + 2] << 8) + buf[msgdata + 3];
memset(&storage, 0, sizeof(storage));
sin6->sin6_family = AF_INET6;
#ifdef HAVE_SIN6_LEN
sin6->sin6_len = sizeof(*sin6);
#endif
memcpy(&sin6->sin6_addr, &ip6->ip6_dst , 16);
sin6->sin6_port = tcphdr->th_dport;
item = finditem(&storage, id);
......@@ -2397,7 +2449,9 @@ icmp6read(int fd) {
id = (buf[msgdata] << 8) + buf[msgdata + 1];
memset(&storage, 0, sizeof(storage));
sin6->sin6_family = AF_INET6;
#ifdef HAVE_SIN6_LEN
sin6->sin6_len = sizeof(*sin6);
#endif
memcpy(&sin6->sin6_addr, &ip6->ip6_dst, 16);
sin6->sin6_port = udphdr->uh_dport;
item = finditem(&storage, id);
......@@ -2411,7 +2465,9 @@ icmp6read(int fd) {
id = (buf[msgdata + 2] << 8) + buf[msgdata + 3];
memset(&storage, 0, sizeof(storage));
sin6->sin6_family = AF_INET6;
#ifdef HAVE_SIN6_LEN
sin6->sin6_len = sizeof(*sin6);
#endif
memcpy(&sin6->sin6_addr, &ip6->ip6_dst , 16);
sin6->sin6_port = tcphdr->th_dport;
item = finditem(&storage, id);
......@@ -2669,7 +2725,16 @@ main(int argc, char **argv) {
ident = getpid() & 0xFFFF;
#ifdef SIGINFO
/* Preferred signal. */
signal(SIGINFO, info);
#endif
signal(SIGUSR1, info);
#ifndef SO_NOSIGPIPE
/* Ignore SIGPIPE if we can't set SO_NOSIGPIPE. */
signal(SIGPIPE, SIG_IGN);
#endif
FD_ZERO(&rfds);
FD_ZERO(&wfds);
......@@ -2741,8 +2806,12 @@ main(int argc, char **argv) {
}
}
if (icmp4 >= 0) {
#ifdef IP_STRIPHDR
n = setsockopt(icmp4, IPPROTO_IP, IP_STRIPHDR,
(void *)&on, sizeof(on));
#else
n = -1;
#endif
if (n == -1) {
close(icmp4);
icmp4 = -1;
......@@ -2784,9 +2853,21 @@ main(int argc, char **argv) {
* If we haven't been given recursive servers to use the
* get the system's default servers.
*/
if (!nservers)
#ifdef HAVE_RES_GETSERVERS
if (!nservers) {
nservers = res_getservers(&_res, servers,
sizeof(servers)/sizeof(servers[0]));
}
#else
/*
* This does not support IPv6 nameservers.
*/
if (!nservers) {
memset(servers, 0, sizeof(servers));
for (;nservers < _res.nscount; nservers++)
servers[nservers].sin = _res.nsaddr_list[nservers];
}
#endif
gettimeofday(&start, NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment