diff options
36 files changed, 1105 insertions, 507 deletions
diff --git a/net/relayd/Makefile b/net/relayd/Makefile index 46032fdc179a..10e1086af3f0 100644 --- a/net/relayd/Makefile +++ b/net/relayd/Makefile @@ -5,54 +5,62 @@ # $FreeBSD$ PORTNAME= relayd -PORTVERSION= 4.2.20071221 -PORTREVISION= 1 +PORTVERSION= 4.6.20090813 CATEGORIES= net MASTER_SITES= ${MASTER_SITE_LOCAL} -MASTER_SITE_SUBDIR= kuriyama +MASTER_SITE_SUBDIR= mm -MAINTAINER= kuriyama@FreeBSD.org -COMMENT= OpenBSD Relay Daemon +MAINTAINER= mm@FreeBSD.org +COMMENT= OpenBSD relay daemon -LIB_DEPENDS= event-1.4:${PORTSDIR}/devel/libevent +USE_BZIP2= yes +MANCOMPRESSED= yes -WRKSRC= ${WRKDIR}/tmp +WRKSRC= ${WRKDIR}/usr.sbin MAN5= relayd.conf.5 MAN8= relayctl.8 relayd.8 USE_RC_SUBR= relayd CFLAGS+= -I${PREFIX}/include -WRKSRCC= ${WRKDIR}/tmp/relayctl -WRKSRCD= ${WRKDIR}/tmp/relayd -_MAKE= ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_ARGS} +MAKE_ARGS+= BINDIR=${PREFIX}/sbin MANDIR=${PREFIX}/man/man + RUSER= _relayd RGROUP= _relayd +PKGINSTALL= ${WRKDIR}/pkginstall +SUB_FILES+= pkg-install + +SUB_LIST+= RUSER=${RUSER} \ + RGROUP=${RGROUP} post-extract: - ${MKDIR} ${WRKSRC} - ${MV} ${WRKDIR}/relayctl ${WRKSRC}/ - ${MV} ${WRKDIR}/relayd ${WRKSRC}/ + @${CP} ${FILESDIR}/Makefile.all ${WRKSRC}/Makefile + @${CP} ${FILESDIR}/Makefile.relayctl ${WRKSRC}/relayctl/Makefile + @${CP} ${FILESDIR}/Makefile.relayd ${WRKSRC}/relayd/Makefile + @${CP} ${FILESDIR}/arc4random.c ${WRKSRC}/relayd pre-build: ${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' \ - ${WRKSRCD}/relayd.h \ - ${WRKSRCD}/relayd.conf.5 ${WRKSRCD}/relayd.8 - -do-build: - (cd ${WRKSRCC}; ${_MAKE} ${ALL_TARGET}) - (cd ${WRKSRCD}; ${_MAKE} ${ALL_TARGET}) + ${WRKSRC}/relayd/relayd.h \ + ${WRKSRC}/relayd/relayd.conf.5 \ + ${WRKSRC}/relayd/relayd.8 pre-su-install: - @${SETENV} PKG_PREFIX=${PREFIX} RUSER=${RUSER} RGROUP=${RGROUP} \ + @${SETENV} PKG_PREFIX=${PREFIX} \ ${SH} ${PKGINSTALL} ${PORTNAME} PRE-INSTALL -do-install: - (cd ${WRKSRCC}; ${_MAKE} ${INSTALL_TARGET} install-man) - (cd ${WRKSRCD}; ${_MAKE} ${INSTALL_TARGET} install-man) +OPTIONS= LIBEVENT_STATIC "Build with static libevent" Off .include <bsd.port.pre.mk> +.if defined(WITH_LIBEVENT_STATIC) +BUILD_DEPENDS= ${LOCALBASE}/lib/libevent.a:${PORTSDIR}/devel/libevent +MAKE_ARGS+= LIBEVENT=${LOCALBASE}/lib/libevent.a +.else +LIB_DEPENDS= event-1.4:${PORTSDIR}/devel/libevent +MAKE_ARGS+= LIBEVENT=-levent +.endif + .if (${OSVERSION} < 700049) && !defined(I_KNOW_WHAT_I_AM_DOING) IGNORE= needs a patched kernel to work correctly (http://www.openbsd.org/cgi-bin/cvsweb/src/sys/net/pf_table.c.diff?r1=1.67&r2=1.68) .endif diff --git a/net/relayd/distinfo b/net/relayd/distinfo index 714b2da38216..ac2665dd1206 100644 --- a/net/relayd/distinfo +++ b/net/relayd/distinfo @@ -1,3 +1,3 @@ -MD5 (relayd-4.2.20071221.tar.gz) = 3e6060c3228f2427d4dc3f3740cd4b15 -SHA256 (relayd-4.2.20071221.tar.gz) = e92d777408e87e9c60d5a439affddc6c2ea005fcb116ced937f3ce977e9b3d0d -SIZE (relayd-4.2.20071221.tar.gz) = 84150 +MD5 (relayd-4.6.20090813.tar.bz2) = 957b3388e49829049cda31a6e00694fd +SHA256 (relayd-4.6.20090813.tar.bz2) = 44cebacc23d9372fbf9f81cfa6088b5b5450cc7f65104b6b33181b23a4fdefd9 +SIZE (relayd-4.6.20090813.tar.bz2) = 75568 diff --git a/net/relayd/files/Makefile.all b/net/relayd/files/Makefile.all new file mode 100644 index 000000000000..3458f8dc487f --- /dev/null +++ b/net/relayd/files/Makefile.all @@ -0,0 +1,5 @@ +# $FreeBSD$ + +SUBDIR= relayd relayctl + +.include <bsd.subdir.mk> diff --git a/net/relayd/files/Makefile.relayctl b/net/relayd/files/Makefile.relayctl new file mode 100644 index 000000000000..24b5ab4d3018 --- /dev/null +++ b/net/relayd/files/Makefile.relayctl @@ -0,0 +1,21 @@ +# $FreeBSD$ + +PROG= relayctl + +.PATH: ${.CURDIR}/../relayd +SRCS= buffer.c \ + imsg.c \ + log.c + +.PATH: ${.CURDIR} +SRCS+= relayctl.c \ + parser.c + +MAN= relayctl.8 + +CFLAGS+= -D__dead='' +CFLAGS+= -I${.CURDIR} \ + -I${.CURDIR}/../relayd \ + -I${PREFIX}/include + +.include <bsd.prog.mk> diff --git a/net/relayd/files/Makefile.relayd b/net/relayd/files/Makefile.relayd new file mode 100644 index 000000000000..f6aa3cf648a6 --- /dev/null +++ b/net/relayd/files/Makefile.relayd @@ -0,0 +1,38 @@ +# $FreeBSD$ + +PROG= relayd + +MAN= relayd.8 \ + relayd.conf.5 + +SRCS= parse.y \ + log.c \ + control.c \ + buffer.c \ + imsg.c \ + ssl.c \ + ssl_privsep.c \ + relayd.c \ + pfe.c \ + pfe_filter.c \ + hce.c \ + relay.c \ + relay_udp.c \ + check_icmp.c \ + check_tcp.c \ + check_script.c \ + name2id.c \ + arc4random.c \ + shuffle.c + +CFLAGS+= -DSHA1_DIGEST_LENGTH=SHA_DIGEST_LENGTH \ + -DSHA1_DIGEST_STRING_LENGTH=SHA_DIGEST_LENGTH \ + -DOPENSSL_NO_SHA -DOPENSSL_NO_MD5 \ + -D__dead='' +CFLAGS+= -I${.CURDIR} -I${PREFIX}/include +CLEANFILES+= y.tab.h + +LDADD= -lmd -L${PREFIX}/lib ${LIBEVENT} -lssl -lcrypto +DPADD= ${LIBEVENT} ${LIBSSL} ${LIBCRYPTO} + +.include <bsd.prog.mk> diff --git a/net/relayd/files/arc4random.c b/net/relayd/files/arc4random.c new file mode 100644 index 000000000000..08017bc22e73 --- /dev/null +++ b/net/relayd/files/arc4random.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1999,2000,2004 Damien Miller <djm@mindrot.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $FreeBSD: /tmp/pcvs/ports/net/relayd/files/Attic/arc4random.c,v 1.1 2010-05-28 11:59:49 mm Exp $ + */ + +#include <sys/param.h> + +#if __FreeBSD_version < 800041 + +#include <sys/types.h> +#include <limits.h> +#include <stdlib.h> + +/* + * Calculate a uniformly distributed random number less than upper_bound + * avoiding "modulo bias". + * + * Uniformity is achieved by generating new random numbers until the one + * returned is outside the range [0, 2**32 % upper_bound). This + * guarantees the selected random number will be inside + * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound) + * after reduction modulo upper_bound. + */ +u_int32_t +arc4random_uniform(u_int32_t upper_bound) +{ + u_int32_t r, min; + + if (upper_bound < 2) + return 0; + +#if (ULONG_MAX > 0xffffffffUL) + min = 0x100000000UL % upper_bound; +#else + /* Calculate (2**32 % upper_bound) avoiding 64-bit math */ + if (upper_bound > 0x80000000) + min = 1 + ~upper_bound; /* 2**32 - upper_bound */ + else { + /* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */ + min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound; + } +#endif + + /* + * This could theoretically loop forever but each retry has + * p > 0.5 (worst case, usually far better) of selecting a + * number inside the range we need, so it should rarely need + * to re-roll. + */ + for (;;) { + r = arc4random(); + if (r >= min) + break; + } + + return r % upper_bound; +} + +#endif /* __FreeBSD_version */ diff --git a/net/relayd/files/patch-ctl-Makefile b/net/relayd/files/patch-ctl-Makefile deleted file mode 100644 index 686d1a5c1906..000000000000 --- a/net/relayd/files/patch-ctl-Makefile +++ /dev/null @@ -1,20 +0,0 @@ ---- relayctl/Makefile.orig Tue Jan 9 09:45:32 2007 -+++ relayctl/Makefile Wed Jun 6 18:58:57 2007 -@@ -8,9 +8,16 @@ - MAN= relayctl.8 - - CFLAGS+= -Wall -Werror -I${.CURDIR} -I${.CURDIR}/../relayd -+CFLAGS+= -I${PREFIX}/include -D__dead='' - CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes - CFLAGS+= -Wmissing-declarations - CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual --CFLAGS+= -Wsign-compare -Wbounded -+CFLAGS+= -Wsign-compare -+ -+install: -+ $(INSTALL) -m 555 -g wheel -o root relayctl $(PREFIX)/sbin -+ -+install-man: -+ $(INSTALL) -o root -g wheel -m 444 relayctl.8 $(PREFIX)/man/man8 - - .include <bsd.prog.mk> diff --git a/net/relayd/files/patch-ctl-parser.c b/net/relayd/files/patch-ctl-parser.c deleted file mode 100644 index f2162c9e9f05..000000000000 --- a/net/relayd/files/patch-ctl-parser.c +++ /dev/null @@ -1,21 +0,0 @@ ---- relayctl/parser.c.orig Wed May 30 07:41:48 2007 -+++ relayctl/parser.c Mon Jan 7 21:32:16 2008 -@@ -18,7 +18,7 @@ - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include <sys/types.h> -+#include <sys/param.h> - #include <sys/socket.h> - #include <sys/queue.h> - #include <netinet/in.h> -@@ -118,6 +118,9 @@ - }; - - static struct parse_result res; -+ -+const struct token *match_token(const char *, const struct token []); -+void show_valid_args(const struct token []); - - struct parse_result * - parse(int argc, char *argv[]) diff --git a/net/relayd/files/patch-ctl-parser.h b/net/relayd/files/patch-ctl-parser.h deleted file mode 100644 index 329b6c03dce5..000000000000 --- a/net/relayd/files/patch-ctl-parser.h +++ /dev/null @@ -1,8 +0,0 @@ ---- relayctl/parser.h.orig Wed Jun 6 18:25:59 2007 -+++ relayctl/parser.h Wed Jun 6 18:27:58 2007 -@@ -38,5 +38,3 @@ - }; - - struct parse_result *parse(int, char *[]); --const struct token *match_token(const char *, const struct token []); --void show_valid_args(const struct token []); diff --git a/net/relayd/files/patch-ctl-relayctl.c b/net/relayd/files/patch-ctl-relayctl.c deleted file mode 100644 index 478e4a7d68cc..000000000000 --- a/net/relayd/files/patch-ctl-relayctl.c +++ /dev/null @@ -1,28 +0,0 @@ ---- relayctl/relayctl.c.orig 2007-12-20 21:15:43.000000000 +0100 -+++ relayctl/relayctl.c 2008-03-20 17:15:14.000000000 +0100 -@@ -20,6 +20,7 @@ - */ - - #include <sys/types.h> -+#include <sys/param.h> - #include <sys/socket.h> - #include <sys/queue.h> - #include <sys/un.h> -@@ -297,7 +298,7 @@ - imn = monitor_lookup(imsg->hdr.type); - printf("%s: imsg type %u len %u peerid %u pid %d\n", imn->name, - imsg->hdr.type, imsg->hdr.len, imsg->hdr.peerid, imsg->hdr.pid); -- printf("\ttimestamp: %u, %s", now, ctime(&now)); -+ printf("\ttimestamp: %lu, %s", (unsigned long)now, ctime(&now)); - if (imn->type == -1) - done = 1; - if (imn->func != NULL) -@@ -508,7 +509,7 @@ - printf("\t%8s\ttotal: %llu sessions\n" - "\t%8s\tlast: %u/%us %u/h %u/d sessions\n" - "\t%8s\taverage: %u/%us %u/h %u/d sessions\n", -- "", crs.cnt, -+ "", (long long unsigned)crs.cnt, - "", crs.last, crs.interval, - crs.last_hour, crs.last_day, - "", crs.avg, crs.interval, diff --git a/net/relayd/files/patch-d-Makefile b/net/relayd/files/patch-d-Makefile deleted file mode 100644 index a983bfebf003..000000000000 --- a/net/relayd/files/patch-d-Makefile +++ /dev/null @@ -1,26 +0,0 @@ ---- relayd/Makefile.orig Tue Feb 27 04:35:43 2007 -+++ relayd/Makefile Tue Jun 5 20:57:45 2007 -@@ -6,13 +6,20 @@ - check_icmp.c check_tcp.c relay.c carp.c - MAN= relayd.8 relayd.conf.5 - --LDADD= -levent -lssl -lcrypto -+LDADD= -lmd -L${PREFIX}/lib -levent -lssl -lcrypto - DPADD= ${LIBEVENT} ${LIBSSL} ${LIBCRYPTO} --CFLAGS+= -Wall -I${.CURDIR} -+CFLAGS+= -Wall -I${.CURDIR} -I${PREFIX}/include -D__dead='' -DSHA1_DIGEST_LENGTH=SHA_DIGEST_LENGTH -DSHA1_DIGEST_STRING_LENGTH=SHA_DIGEST_LENGTH -DOPENSSL_NO_SHA -DOPENSSL_NO_MD5 - CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes - CFLAGS+= -Wmissing-declarations - CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual --CFLAGS+= -Wsign-compare -Wbounded -+CFLAGS+= -Wsign-compare - CLEANFILES+= y.tab.h -+ -+install: -+ $(INSTALL) -m 555 -g wheel -o root relayd $(PREFIX)/sbin -+ -+install-man: -+ $(INSTALL) -m 444 -g wheel -o root relayd.conf.5 $(PREFIX)/man/man5 -+ $(INSTALL) -m 444 -g wheel -o root relayd.8 $(PREFIX)/man/man8 - - .include <bsd.prog.mk> diff --git a/net/relayd/files/patch-d-carp.c b/net/relayd/files/patch-d-carp.c deleted file mode 100644 index 57cafacf3229..000000000000 --- a/net/relayd/files/patch-d-carp.c +++ /dev/null @@ -1,44 +0,0 @@ ---- relayd/carp.c.orig 2007-12-08 02:17:00.000000000 +0900 -+++ relayd/carp.c 2008-01-14 08:43:07.745281030 +0900 -@@ -19,6 +19,7 @@ - #include <sys/param.h> - #include <sys/socket.h> - #include <sys/ioctl.h> -+#include <sys/queue.h> - - #include <net/if.h> - -@@ -105,6 +106,7 @@ - int - carp_demote_get(char *group) - { -+#if 0 - int s; - struct ifgroupreq ifgr; - -@@ -131,6 +133,9 @@ - - close(s); - return ((int)ifgr.ifgr_attrib.ifg_carp_demoted); -+#else -+ return (-1); -+#endif - } - - int -@@ -188,6 +193,7 @@ - int - carp_demote_ioctl(char *group, int demote) - { -+#if 0 - int s, res; - struct ifgroupreq ifgr; - -@@ -214,4 +220,7 @@ - - close(s); - return (res); -+#else -+ return (-1); -+#endif - } diff --git a/net/relayd/files/patch-d-check_icmp.c b/net/relayd/files/patch-d-check_icmp.c deleted file mode 100644 index 5fa746a3f234..000000000000 --- a/net/relayd/files/patch-d-check_icmp.c +++ /dev/null @@ -1,11 +0,0 @@ ---- relayd/check_icmp.c.orig 2008-01-14 10:10:32.881133017 +0900 -+++ relayd/check_icmp.c 2008-01-14 10:10:45.169385174 +0900 -@@ -16,7 +16,7 @@ - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include <sys/types.h> -+#include <sys/param.h> - #include <sys/queue.h> - #include <sys/socket.h> - diff --git a/net/relayd/files/patch-d-check_tcp.c b/net/relayd/files/patch-d-check_tcp.c deleted file mode 100644 index 44db31fc5190..000000000000 --- a/net/relayd/files/patch-d-check_tcp.c +++ /dev/null @@ -1,47 +0,0 @@ ---- relayd/check_tcp.c.orig 2007-12-08 02:17:00.000000000 +0900 -+++ relayd/check_tcp.c 2008-01-14 16:47:41.131892553 +0900 -@@ -31,7 +31,7 @@ - #include <stdlib.h> - #include <errno.h> - #include <fnmatch.h> --#include <sha1.h> -+#include <sha.h> - - #include <openssl/ssl.h> - -@@ -285,7 +285,7 @@ - if (b == NULL) - fatal("out of memory"); - *b = '\0'; -- if (fnmatch(cte->table->conf.exbuf, cte->buf->buf, 0) == 0) { -+ if (fnmatch(cte->table->conf.exbuf, (char *)cte->buf->buf, 0) == 0) { - cte->host->up = HOST_UP; - return (0); - } -@@ -316,7 +316,7 @@ - fatal("out of memory"); - *b = '\0'; - -- head = cte->buf->buf; -+ head = (char *)cte->buf->buf; - host = cte->host; - if (strncmp(head, "HTTP/1.1 ", strlen("HTTP/1.1 ")) && - strncmp(head, "HTTP/1.0 ", strlen("HTTP/1.0 "))) { -@@ -363,7 +363,7 @@ - fatal("out of memory"); - *b = '\0'; - -- head = cte->buf->buf; -+ head = (char *)cte->buf->buf; - host = cte->host; - if ((head = strstr(head, "\r\n\r\n")) == NULL) { - log_debug("check_http_digest: %s failed " -@@ -373,7 +373,7 @@ - } - head += strlen("\r\n\r\n"); - -- digeststr(cte->table->conf.digest_type, head, strlen(head), digest); -+ digeststr(cte->table->conf.digest_type, (u_int8_t*)head, strlen(head), digest); - - if (strcmp(cte->table->conf.digest, digest)) { - log_warnx("check_http_digest: %s failed " diff --git a/net/relayd/files/patch-d-log.c b/net/relayd/files/patch-d-log.c deleted file mode 100644 index 0811fecce71d..000000000000 --- a/net/relayd/files/patch-d-log.c +++ /dev/null @@ -1,11 +0,0 @@ ---- relayd/log.c.orig 2008-01-14 09:59:27.825621568 +0900 -+++ relayd/log.c 2008-01-14 09:59:36.888069516 +0900 -@@ -16,7 +16,7 @@ - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include <sys/types.h> -+#include <sys/param.h> - #include <sys/queue.h> - #include <sys/socket.h> - #include <sys/tree.h> diff --git a/net/relayd/files/patch-d-parse.y b/net/relayd/files/patch-d-parse.y deleted file mode 100644 index 7bf00396a128..000000000000 --- a/net/relayd/files/patch-d-parse.y +++ /dev/null @@ -1,11 +0,0 @@ ---- relayd/parse.y.orig Tue Jun 5 20:12:20 2007 -+++ relayd/parse.y Tue Jun 5 20:12:51 2007 -@@ -1561,7 +1561,7 @@ - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; /* DUMMY */ - error = getaddrinfo(s, NULL, &hints, &res0); -- if (error == EAI_AGAIN || error == EAI_NODATA || error == EAI_NONAME) -+ if (error == EAI_AGAIN || error == EAI_NONAME) - return (0); - if (error) { - log_warnx("host_dns: could not parse \"%s\": %s", s, diff --git a/net/relayd/files/patch-d-pfe.c b/net/relayd/files/patch-d-pfe.c deleted file mode 100644 index 196f13933648..000000000000 --- a/net/relayd/files/patch-d-pfe.c +++ /dev/null @@ -1,10 +0,0 @@ ---- relayd/pfe.c.orig 2008-01-14 10:06:37.013495830 +0900 -+++ relayd/pfe.c 2008-01-14 10:06:47.508856711 +0900 -@@ -17,6 +17,7 @@ - */ - - #include <sys/param.h> -+#include <sys/queue.h> - #include <sys/stat.h> - #include <sys/socket.h> - #include <sys/un.h> diff --git a/net/relayd/files/patch-d-pfe_filter.c b/net/relayd/files/patch-d-pfe_filter.c deleted file mode 100644 index fb2747b28b0e..000000000000 --- a/net/relayd/files/patch-d-pfe_filter.c +++ /dev/null @@ -1,45 +0,0 @@ ---- relayd/pfe_filter.c.orig 2007-12-21 05:15:43.000000000 +0900 -+++ relayd/pfe_filter.c 2008-01-20 15:31:28.856798863 +0900 -@@ -89,6 +89,7 @@ - sizeof(tables[i].pfrt_name)) - goto toolong; - tables[i].pfrt_flags |= PFR_TFLAG_PERSIST; -+ log_debug("init_tables: prepare anchor \"%s\" and table \"%s\"", tables[i].pfrt_anchor, tables[i].pfrt_name); - i++; - } - if (i != env->rdrcount) -@@ -239,10 +240,15 @@ - sizeof(io.pfrio_table.pfrt_name)) >= - sizeof(io.pfrio_table.pfrt_name)) - goto toolong; -+ /* pfctl -Tflush */ - if (ioctl(env->pf->dev, DIOCRCLRADDRS, &io) == -1) - fatal("flush_table: cannot flush table addresses"); -+ /* pfctl -Tzero */ -+#if 0 -+ /* XXX: ioctl(DIOCRCLRTSTATS) requires io.pfrio_esize to be set as sizeof(struct pfr_table), but here doesn't set it. */ - if (ioctl(env->pf->dev, DIOCRCLRTSTATS, &io) == -1) - fatal("flush_table: cannot flush table stats"); -+#endif - log_debug("flush_table: flushed table %s", rdr->conf.name); - return; - -@@ -321,7 +327,9 @@ - rio.rule.dst.addr.type = PF_ADDR_ADDRMASK; - rio.rule.dst.port_op = PF_OP_EQ; - rio.rule.dst.port[0] = address->port; -+#if 0 - rio.rule.rtableid = -1; /* stay in the main routing table */ -+#endif - rio.rule.action = PF_RDR; - if (strlen(rdr->conf.tag)) - (void)strlcpy(rio.rule.tagname, rdr->conf.tag, -@@ -362,7 +370,7 @@ - - if (ioctl(env->pf->dev, DIOCADDRULE, &rio) == -1) - fatal("cannot add rule"); -- log_debug("sync_ruleset: rule added"); -+ log_debug("sync_ruleset: rule added into anchor \"%s\", table \"%s\"", rio.anchor, pio.addr.addr.v.tblname); - } - if (transaction_commit(env) == -1) - log_warn("sync_ruleset: add rules transaction failed"); diff --git a/net/relayd/files/patch-d-relay.c b/net/relayd/files/patch-d-relay.c deleted file mode 100644 index c170b2736a3a..000000000000 --- a/net/relayd/files/patch-d-relay.c +++ /dev/null @@ -1,72 +0,0 @@ ---- relayd/relay.c.orig 2007-12-09 05:36:36.000000000 +0900 -+++ relayd/relay.c 2008-01-14 10:26:05.345356528 +0900 -@@ -16,7 +16,7 @@ - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include <sys/types.h> -+#include <sys/param.h> - #include <sys/queue.h> - #include <sys/time.h> - #include <sys/stat.h> -@@ -675,6 +675,7 @@ - &val, sizeof(val)) == -1) - goto bad; - } -+#if 0 - if (proto->tcpflags & (TCPFLAG_SACK|TCPFLAG_NSACK)) { - if (proto->tcpflags & TCPFLAG_NSACK) - val = 0; -@@ -684,6 +685,7 @@ - &val, sizeof(val)) == -1) - goto bad; - } -+#endif - - return (s); - -@@ -1000,7 +1002,7 @@ - } - } - if (strstr(val, "$TIMEOUT") != NULL) { -- snprintf(ibuf, sizeof(ibuf), "%lu", rlay->conf.timeout.tv_sec); -+ snprintf(ibuf, sizeof(ibuf), "%lu", (unsigned long)rlay->conf.timeout.tv_sec); - if (expand_string(buf, len, "$TIMEOUT", ibuf) != 0) - return (NULL); - } -@@ -1565,7 +1567,7 @@ - switch (type) { - case DIGEST_SHA1: - case DIGEST_MD5: -- if ((md = digeststr(type, val, strlen(val), NULL)) == NULL) { -+ if ((md = digeststr(type, (u_int8_t*)val, strlen(val), NULL)) == NULL) { - relay_close_http(con, 500, - "failed to allocate digest", 0); - goto fail; -@@ -2469,7 +2471,7 @@ - goto err; - - /* Set session context to the local relay name */ -- if (!SSL_CTX_set_session_id_context(ctx, rlay->conf.name, -+ if (!SSL_CTX_set_session_id_context(ctx, (unsigned char*)rlay->conf.name, - strlen(rlay->conf.name))) - goto err; - -@@ -2849,7 +2851,7 @@ - if (fstat(fd, &st) != 0) - goto fail; - size = st.st_size; -- if ((buf = (char *)calloc(1, size + 1)) == NULL) -+ if ((buf = (u_int8_t *)calloc(1, size + 1)) == NULL) - goto fail; - if (read(fd, buf, size) != size) - goto fail; -@@ -2857,7 +2859,7 @@ - close(fd); - - *len = size + 1; -- return (buf); -+ return (char *)(buf); - - fail: - if (buf != NULL) diff --git a/net/relayd/files/patch-d-relay_udp.c b/net/relayd/files/patch-d-relay_udp.c deleted file mode 100644 index 9b233242a145..000000000000 --- a/net/relayd/files/patch-d-relay_udp.c +++ /dev/null @@ -1,11 +0,0 @@ ---- relayd/relay_udp.c.orig 2008-01-14 10:09:08.345280942 +0900 -+++ relayd/relay_udp.c 2008-01-14 10:09:21.665469901 +0900 -@@ -16,7 +16,7 @@ - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include <sys/types.h> -+#include <sys/param.h> - #include <sys/queue.h> - #include <sys/time.h> - #include <sys/stat.h> diff --git a/net/relayd/files/patch-d-relayd.8 b/net/relayd/files/patch-d-relayd.8 deleted file mode 100644 index c58d299a6c3a..000000000000 --- a/net/relayd/files/patch-d-relayd.8 +++ /dev/null @@ -1,20 +0,0 @@ ---- relayd/relayd.8.orig 2007-12-12 23:55:12.000000000 +0900 -+++ relayd/relayd.8 2008-01-14 08:47:34.673073391 +0900 -@@ -116,7 +116,7 @@ - .It Fl f Ar file - Specify an alternative configuration file. - The default is --.Pa /etc/relayd.conf . -+.Pa %%PREFIX%%/etc/relayd.conf . - .It Fl n - Configtest mode. - Only check the configuration file for validity. -@@ -125,7 +125,7 @@ - .El - .Sh FILES - .Bl -tag -width "/var/run/relayd.sockXX" -compact --.It /etc/relayd.conf -+.It %%PREFIX%%/etc/relayd.conf - Default configuration file. - .It /var/run/relayd.sock - Unix-domain socket used for communication with diff --git a/net/relayd/files/patch-d-relayd.c b/net/relayd/files/patch-d-relayd.c deleted file mode 100644 index 19be09b14b3c..000000000000 --- a/net/relayd/files/patch-d-relayd.c +++ /dev/null @@ -1,29 +0,0 @@ ---- relayd/relayd.c.orig 2008-01-14 10:00:21.487354557 +0900 -+++ relayd/relayd.c 2008-01-14 16:44:45.705572691 +0900 -@@ -16,7 +16,7 @@ - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include <sys/types.h> -+#include <sys/param.h> - #include <sys/queue.h> - #include <sys/socket.h> - #include <sys/wait.h> -@@ -36,7 +36,7 @@ - #include <unistd.h> - #include <ctype.h> - #include <pwd.h> --#include <sha1.h> -+#include <sha.h> - #include <md5.h> - - #include <openssl/ssl.h> -@@ -943,7 +943,7 @@ - { - switch (type) { - case DIGEST_SHA1: -- return (SHA1Data(data, len, buf)); -+ return (SHA1_Data(data, len, buf)); - break; - case DIGEST_MD5: - return (MD5Data(data, len, buf)); diff --git a/net/relayd/files/patch-d-relayd.conf.5 b/net/relayd/files/patch-d-relayd.conf.5 deleted file mode 100644 index f1afc511f8d5..000000000000 --- a/net/relayd/files/patch-d-relayd.conf.5 +++ /dev/null @@ -1,33 +0,0 @@ ---- relayd/relayd.conf.5.orig 2007-12-12 23:55:12.000000000 +0900 -+++ relayd/relayd.conf.5 2008-01-14 08:49:46.404074048 +0900 -@@ -101,20 +101,7 @@ - Here are the settings that can be set globally: - .Pp - .Bl -tag -width Ds -compact --.It Ic demote Ar group --Enable the global --.Xr carp 4 --demotion option, resetting the carp demotion counter for the --specified interface group to zero on startup and to 128 on shutdown of --the daemon. --For more information on interface groups, --see the --.Ic group --keyword in --.Xr ifconfig 8 . --.Pp --.It Xo --.Ic interval Ar number -+.It Ic interval Ar number - .Xc - Set the interval in seconds at which the hosts will be checked. - The default interval is 10 seconds. -@@ -894,7 +881,7 @@ - .El - .Sh FILES - .Bl -tag -width "/etc/ssl/private/address.keyXX" -compact --.It Pa /etc/relayd.conf -+.It Pa %%PREFIX%%/etc/relayd.conf - .Xr relayd 8 - configuration file. - .Pp diff --git a/net/relayd/files/patch-d-relayd.h b/net/relayd/files/patch-d-relayd.h deleted file mode 100644 index ed7863fe17c1..000000000000 --- a/net/relayd/files/patch-d-relayd.h +++ /dev/null @@ -1,27 +0,0 @@ ---- relayd/relayd.h.orig 2007-12-21 05:15:43.000000000 +0900 -+++ relayd/relayd.h 2008-01-14 10:02:42.803752108 +0900 -@@ -20,7 +20,7 @@ - - #include <sys/tree.h> - --#define CONF_FILE "/etc/relayd.conf" -+#define CONF_FILE "%%PREFIX%%/etc/relayd.conf" - #define RELAYD_SOCKET "/var/run/relayd.sock" - #define PF_SOCKET "/dev/pf" - #define RELAYD_USER "_relayd" -@@ -56,6 +56,15 @@ - #define PURGE_PROTOS 0x08 - #define PURGE_EVERYTHING 0xff - -+#define SIMPLEQ_HEAD STAILQ_HEAD -+#define SIMPLEQ_FIRST STAILQ_FIRST -+#define SIMPLEQ_REMOVE_HEAD STAILQ_REMOVE_HEAD -+#define SIMPLEQ_ENTRY STAILQ_ENTRY -+#define SIMPLEQ_INIT STAILQ_INIT -+#define SIMPLEQ_EMPTY STAILQ_EMPTY -+#define SIMPLEQ_NEXT STAILQ_NEXT -+#define SIMPLEQ_INSERT_TAIL STAILQ_INSERT_TAIL -+ - /* buffer */ - struct buf { - TAILQ_ENTRY(buf) entry; diff --git a/net/relayd/files/patch-freebsd-relayctl b/net/relayd/files/patch-freebsd-relayctl new file mode 100644 index 000000000000..774bf777a4a0 --- /dev/null +++ b/net/relayd/files/patch-freebsd-relayctl @@ -0,0 +1,75 @@ +diff -Naur relayctl.orig/parser.c relayctl/parser.c +--- relayctl.orig/parser.c 2007-12-20 21:15:43.000000000 +0100 ++++ relayctl/parser.c 2010-05-27 10:12:35.000000000 +0200 +@@ -18,7 +18,11 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef __FreeBSD__ ++#include <sys/param.h> ++#else + #include <sys/types.h> ++#endif + #include <sys/socket.h> + #include <sys/queue.h> + +@@ -124,6 +128,11 @@ + + static struct parse_result res; + ++#ifdef __FreeBSD__ ++const struct token *match_token(const char *, const struct token []); ++void show_valid_args(const struct token []); ++#endif ++ + struct parse_result * + parse(int argc, char *argv[]) + { +diff -Naur relayctl.orig/parser.h relayctl/parser.h +--- relayctl.orig/parser.h 2007-12-20 21:15:43.000000000 +0100 ++++ relayctl/parser.h 2010-05-27 10:12:03.000000000 +0200 +@@ -41,5 +41,7 @@ + }; + + struct parse_result *parse(int, char *[]); ++#ifndef __FreeBSD__ + const struct token *match_token(const char *, const struct token []); + void show_valid_args(const struct token []); ++#endif +diff -Naur relayctl.orig/relayctl.c relayctl/relayctl.c +--- relayctl.orig/relayctl.c 2009-06-06 01:39:51.000000000 +0200 ++++ relayctl/relayctl.c 2010-05-27 10:11:39.000000000 +0200 +@@ -20,6 +20,9 @@ + */ + + #include <sys/types.h> ++#ifdef __FreeBSD__ ++#include <sys/param.h> ++#endif + #include <sys/socket.h> + #include <sys/queue.h> + #include <sys/un.h> +@@ -290,7 +293,11 @@ + imn = monitor_lookup(imsg->hdr.type); + printf("%s: imsg type %u len %u peerid %u pid %d\n", imn->name, + imsg->hdr.type, imsg->hdr.len, imsg->hdr.peerid, imsg->hdr.pid); ++#ifdef __FreeBSD__ ++ printf("\ttimestamp: %lu, %s", (unsigned long)now, ctime(&now)); ++#else + printf("\ttimestamp: %u, %s", now, ctime(&now)); ++#endif + if (imn->type == -1) + done = 1; + if (imn->func != NULL) +@@ -509,7 +516,11 @@ + printf("\t%8s\ttotal: %llu sessions\n" + "\t%8s\tlast: %u/%us %u/h %u/d sessions\n" + "\t%8s\taverage: %u/%us %u/h %u/d sessions\n", ++#ifdef __FreeBSD__ ++ "", (long long unsigned)crs.cnt, ++#else + "", crs.cnt, ++#endif + "", crs.last, crs.interval, + crs.last_hour, crs.last_day, + "", crs.avg, crs.interval, diff --git a/net/relayd/files/patch-freebsd-relayd b/net/relayd/files/patch-freebsd-relayd new file mode 100644 index 000000000000..50e2a8202189 --- /dev/null +++ b/net/relayd/files/patch-freebsd-relayd @@ -0,0 +1,684 @@ +diff -Naur relayd.orig/carp.c relayd/carp.c +--- relayd.orig/carp.c 2010-05-27 11:05:52.871795234 +0200 ++++ relayd/carp.c 2010-05-27 11:05:58.266605620 +0200 +@@ -19,6 +19,7 @@ + #include <sys/param.h> + #include <sys/socket.h> + #include <sys/ioctl.h> ++#include <sys/queue.h> + + #include <net/if.h> + +diff -Naur relayd.orig/check_tcp.c relayd/check_tcp.c +--- relayd.orig/check_tcp.c 2010-05-27 11:05:52.872794016 +0200 ++++ relayd/check_tcp.c 2010-05-27 11:05:58.269605038 +0200 +@@ -31,7 +31,7 @@ + #include <stdlib.h> + #include <errno.h> + #include <fnmatch.h> +-#include <sha1.h> ++#include <sha.h> + + #include <openssl/ssl.h> + +@@ -285,7 +285,11 @@ + if (b == NULL) + fatal("out of memory"); + *b = '\0'; ++#ifndef __FreeBSD__ + if (fnmatch(cte->table->conf.exbuf, cte->buf->buf, 0) == 0) { ++#else ++ if (fnmatch(cte->table->conf.exbuf, (char *)cte->buf->buf, 0) == 0) { ++#endif + cte->host->he = HCE_SEND_EXPECT_OK; + cte->host->up = HOST_UP; + return (0); +@@ -318,7 +322,11 @@ + fatal("out of memory"); + *b = '\0'; + ++#ifndef __FreeBSD__ + head = cte->buf->buf; ++#else ++ head = (char *)cte->buf->buf; ++#endif + host = cte->host; + host->he = HCE_HTTP_CODE_ERROR; + +@@ -370,7 +378,11 @@ + fatal("out of memory"); + *b = '\0'; + ++#ifndef __FreeBSD__ + head = cte->buf->buf; ++#else ++ head = (char *)cte->buf->buf; ++#endif + host = cte->host; + host->he = HCE_HTTP_DIGEST_ERROR; + +@@ -382,7 +394,11 @@ + } + head += strlen("\r\n\r\n"); + ++#ifndef __FreeBSD__ + digeststr(cte->table->conf.digest_type, head, strlen(head), digest); ++#else ++ digeststr(cte->table->conf.digest_type, (u_int8_t*)head, strlen(head), digest); ++#endif + + if (strcmp(cte->table->conf.digest, digest)) { + log_warnx("check_http_digest: %s failed " +diff -Naur relayd.orig/hce.c relayd/hce.c +--- relayd.orig/hce.c 2010-05-27 11:05:52.872794016 +0200 ++++ relayd/hce.c 2010-05-27 11:05:58.270605497 +0200 +@@ -167,7 +167,7 @@ + struct timeval tv; + struct table *table; + +- snmp_init(env, iev_main); ++// snmp_init(env, iev_main); + + if (!TAILQ_EMPTY(env->sc_tables)) { + evtimer_set(&env->sc_ev, hce_launch_checks, env); +@@ -336,8 +336,10 @@ + print_availability(host->check_cnt, host->up_cnt)); + } + ++/* + if (host->last_up != host->up) + snmp_hosttrap(table, host); ++*/ + + host->last_up = host->up; + +diff -Naur relayd.orig/log.c relayd/log.c +--- relayd.orig/log.c 2010-05-27 11:05:52.872794016 +0200 ++++ relayd/log.c 2010-05-27 11:05:58.271605396 +0200 +@@ -16,7 +16,11 @@ + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef __FreeBSD__ ++#include <sys/param.h> ++#else + #include <sys/types.h> ++#endif + #include <sys/queue.h> + #include <sys/socket.h> + #include <sys/tree.h> +diff -Naur relayd.orig/parse.y relayd/parse.y +--- relayd.orig/parse.y 2010-05-27 11:05:52.874794374 +0200 ++++ relayd/parse.y 2010-05-27 11:07:06.666448151 +0200 +@@ -343,6 +343,7 @@ + } + conf->sc_prefork_relay = $2; + } ++/* FreeBSD exclude + | DEMOTE STRING { + conf->sc_flags |= F_DEMOTE; + if (strlcpy(conf->sc_demote_group, $2, +@@ -360,6 +361,7 @@ + } + } + | SEND TRAP { conf->sc_flags |= F_TRAP; } ++*/ + ; + + loglevel : UPDATES { $$ = RELAYD_OPT_LOGUPDATE; } +@@ -615,6 +617,7 @@ + bcopy(&$2, &table->conf.timeout, + sizeof(struct timeval)); + } ++/* FreeBSD exclude + | DEMOTE STRING { + table->conf.flags |= F_DEMOTE; + if (strlcpy(table->conf.demote_group, $2, +@@ -632,6 +635,7 @@ + YYERROR; + } + } ++*/ + | INTERVAL NUMBER { + if ($2 < conf->sc_interval.tv_sec || + $2 % conf->sc_interval.tv_sec) { +@@ -1562,7 +1566,7 @@ + { "ciphers", CIPHERS }, + { "code", CODE }, + { "cookie", COOKIE }, +- { "demote", DEMOTE }, ++// FreeBSD { "demote", DEMOTE }, + { "digest", DIGEST }, + { "disable", DISABLE }, + { "error", ERROR }, +@@ -1625,7 +1629,7 @@ + { "timeout", TIMEOUT }, + { "to", TO }, + { "transparent", TRANSPARENT }, +- { "trap", TRAP }, ++// FreeBSD { "trap", TRAP }, + { "ttl", TTL }, + { "updates", UPDATES }, + { "url", URL }, +@@ -2260,7 +2264,8 @@ + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_DGRAM; /* DUMMY */ + error = getaddrinfo(s, NULL, &hints, &res0); +- if (error == EAI_AGAIN || error == EAI_NODATA || error == EAI_NONAME) ++// if (error == EAI_AGAIN || error == EAI_NODATA || error == EAI_NONAME) ++ if (error == EAI_AGAIN || error == EAI_NONAME) + return (0); + if (error) { + log_warnx("host_dns: could not parse \"%s\": %s", s, +diff -Naur relayd.orig/pfe.c relayd/pfe.c +--- relayd.orig/pfe.c 2010-05-27 11:05:52.874794374 +0200 ++++ relayd/pfe.c 2010-05-27 11:05:58.276615510 +0200 +@@ -17,6 +17,9 @@ + */ + + #include <sys/param.h> ++#ifdef __FreeBSD__ ++#include <sys/queue.h> ++#endif + #include <sys/stat.h> + #include <sys/socket.h> + #include <sys/un.h> +@@ -859,7 +862,9 @@ + struct table *table; + struct ctl_id id; + struct imsg imsg; ++#ifndef __FreeBSD__ + struct ctl_demote demote; ++#endif + + bzero(&id, sizeof(id)); + bzero(&imsg, sizeof(imsg)); +@@ -920,6 +925,7 @@ + */ + table->conf.flags &= ~(F_CHANGED); + ++#ifndef __FreeBSD__ + /* + * handle demotion. + */ +@@ -942,6 +948,7 @@ + sizeof(demote.group)); + imsg_compose_event(iev_main, IMSG_DEMOTE, 0, 0, -1, + &demote, sizeof(demote)); ++#endif + } + } + +diff -Naur relayd.orig/pfe_filter.c relayd/pfe_filter.c +--- relayd.orig/pfe_filter.c 2010-05-27 11:05:52.873793915 +0200 ++++ relayd/pfe_filter.c 2010-05-27 11:05:58.277615689 +0200 +@@ -97,6 +97,10 @@ + sizeof(tables[i].pfrt_name)) + goto toolong; + tables[i].pfrt_flags |= PFR_TFLAG_PERSIST; ++#ifdef __FreeBSD__ ++ log_debug("init_tables: prepare anchor \"%s\" and table \"%s\"", ++#endif ++ tables[i].pfrt_anchor, tables[i].pfrt_name); + i++; + } + if (i != env->sc_rdrcount) +@@ -280,12 +284,11 @@ + } + + psnk.psnk_af = host->conf.ss.ss_family; +- psnk.psnk_killed = 0; + + if (ioctl(env->sc_pf->dev, + DIOCKILLSRCNODES, &psnk) == -1) + fatal("kill_srcnodes: cannot kill src nodes"); +- cnt += psnk.psnk_killed; ++ cnt += psnk.psnk_af; + } + + return (cnt); +@@ -370,7 +373,11 @@ + struct sockaddr_in6 *sain6; + struct address *address; + char anchor[PF_ANCHOR_NAME_SIZE]; ++#ifndef __FreeBSD__ + int rs; ++#else ++ int rs = 0; ++#endif + struct table *t = rdr->table; + + if (!(env->sc_flags & F_NEEDPF)) +@@ -418,7 +425,9 @@ + + /* Use sloppy state handling for half connections */ + rio.rule.keep_state = PF_STATE_NORMAL; ++#if 0 + rio.rule.rule_flag = PFRULE_STATESLOPPY; ++#endif + break; + default: + fatalx("sync_ruleset: invalid forward mode"); +@@ -437,7 +446,9 @@ + rio.rule.dst.port_op = address->port.op; + rio.rule.dst.port[0] = address->port.val[0]; + rio.rule.dst.port[1] = address->port.val[1]; ++#if 0 + rio.rule.rtableid = -1; /* stay in the main routing table */ ++#endif + + if (rio.rule.proto == IPPROTO_TCP) + rio.rule.timeout[PFTM_TCP_ESTABLISHED] = +diff -Naur relayd.orig/relay.c relayd/relay.c +--- relayd.orig/relay.c 2010-05-27 11:05:52.872794016 +0200 ++++ relayd/relay.c 2010-05-27 11:05:58.280728536 +0200 +@@ -16,7 +16,11 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef __FreeBSD__ ++#include <sys/param.h> ++#else + #include <sys/types.h> ++#endif + #include <sys/queue.h> + #include <sys/time.h> + #include <sys/stat.h> +@@ -683,6 +687,7 @@ + &val, sizeof(val)) == -1) + goto bad; + } ++#ifndef __FreeBSD__ + if (proto->tcpflags & (TCPFLAG_SACK|TCPFLAG_NSACK)) { + if (proto->tcpflags & TCPFLAG_NSACK) + val = 0; +@@ -692,6 +697,7 @@ + &val, sizeof(val)) == -1) + goto bad; + } ++#endif + + return (s); + +@@ -1027,7 +1033,11 @@ + } + if (strstr(val, "$TIMEOUT") != NULL) { + snprintf(ibuf, sizeof(ibuf), "%lu", ++#ifdef __FreeBSD__ ++ (unsigned long)rlay->rl_conf.timeout.tv_sec); ++#else + rlay->rl_conf.timeout.tv_sec); ++#endif + if (expand_string(buf, len, "$TIMEOUT", ibuf) != 0) + return (NULL); + } +@@ -1624,7 +1634,11 @@ + switch (type) { + case DIGEST_SHA1: + case DIGEST_MD5: ++#ifdef __FreeBSD__ ++ if ((md = digeststr(type, (u_int8_t*)val, strlen(val), NULL)) == NULL) { ++#else + if ((md = digeststr(type, val, strlen(val), NULL)) == NULL) { ++#endif + relay_close_http(con, 500, + "failed to allocate digest", 0); + goto fail; +@@ -2642,8 +2656,12 @@ + goto err; + + /* Set session context to the local relay name */ +- if (!SSL_CTX_set_session_id_context(ctx, rlay->rl_conf.name, +- strlen(rlay->rl_conf.name))) ++ if (!SSL_CTX_set_session_id_context(ctx, ++#ifdef __FreeBSD__ ++ (unsigned char*)rlay->rl_conf.name, strlen(rlay->rl_conf.name))) ++#else ++ rlay->rl_conf.name, strlen(rlay->rl_conf.name))) ++#endif + goto err; + + return (ctx); +@@ -3104,7 +3122,11 @@ + if (fstat(fd, &st) != 0) + goto fail; + size = st.st_size; ++#ifndef __FreeBSD__ + if ((buf = (char *)calloc(1, size + 1)) == NULL) ++#else ++ if ((buf = (u_int8_t *)calloc(1, size + 1)) == NULL) ++#endif + goto fail; + if (read(fd, buf, size) != size) + goto fail; +@@ -3112,7 +3134,11 @@ + close(fd); + + *len = size + 1; ++#ifndef __FreeBSD__ + return (buf); ++#else ++ return (char *)(buf); ++#endif + + fail: + if (buf != NULL) +diff -Naur relayd.orig/relay_udp.c relayd/relay_udp.c +--- relayd.orig/relay_udp.c 2010-05-27 11:05:52.873793915 +0200 ++++ relayd/relay_udp.c 2010-05-27 11:05:58.281790178 +0200 +@@ -16,7 +16,11 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef __FreeBSD__ ++#include <sys/param.h> ++#else + #include <sys/types.h> ++#endif + #include <sys/queue.h> + #include <sys/time.h> + #include <sys/stat.h> +diff -Naur relayd.orig/relayd.8 relayd/relayd.8 +--- relayd.orig/relayd.8 2010-05-27 11:05:52.871795234 +0200 ++++ relayd/relayd.8 2010-05-27 11:05:58.282841763 +0200 +@@ -117,7 +117,7 @@ + .It Fl f Ar file + Specify an alternative configuration file. + The default is +-.Pa /etc/relayd.conf . ++.Pa %%PREFIX%%/etc/relayd.conf . + .It Fl n + Configtest mode. + Only check the configuration file for validity. +@@ -126,7 +126,7 @@ + .El + .Sh FILES + .Bl -tag -width "/var/run/relayd.sockXX" -compact +-.It /etc/relayd.conf ++.It %%PREFIX%%/etc/relayd.conf + Default configuration file. + .It /var/run/relayd.sock + Unix-domain socket used for communication with +diff -Naur relayd.orig/relayd.c relayd/relayd.c +--- relayd.orig/relayd.c 2010-05-27 11:05:52.873793915 +0200 ++++ relayd/relayd.c 2010-05-27 11:05:58.284862515 +0200 +@@ -17,7 +17,11 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef __FreeBSD__ ++#include <sys/param.h> ++#else + #include <sys/types.h> ++#endif + #include <sys/queue.h> + #include <sys/socket.h> + #include <sys/wait.h> +@@ -37,7 +41,11 @@ + #include <unistd.h> + #include <ctype.h> + #include <pwd.h> ++#ifdef __FreeBSD__ ++#include <sha.h> ++#else + #include <sha1.h> ++#endif + #include <md5.h> + + #include <openssl/ssl.h> +@@ -292,9 +300,10 @@ + iev_hce->handler, iev_hce); + event_add(&iev_hce->ev, NULL); + ++#ifndef __FreeBSD__ + if (env->sc_flags & F_DEMOTE) + carp_demote_reset(env->sc_demote_group, 0); +- ++#endif + event_dispatch(); + + return (0); +@@ -319,9 +328,11 @@ + } while (pid != -1 || (pid == -1 && errno == EINTR)); + + control_cleanup(); ++#ifndef __FreeBSD__ + carp_demote_shutdown(); + if (env->sc_flags & F_DEMOTE) + carp_demote_reset(env->sc_demote_group, 128); ++#endif + log_info("terminating"); + exit(0); + } +@@ -383,8 +394,10 @@ + memcpy(&env->sc_proto_default, &new_env->sc_proto_default, + sizeof(env->sc_proto_default)); + env->sc_prefork_relay = new_env->sc_prefork_relay; ++#ifndef __FreeBSD__ + (void)strlcpy(env->sc_demote_group, new_env->sc_demote_group, + sizeof(env->sc_demote_group)); ++#endif + + env->sc_tables = new_env->sc_tables; + env->sc_rdrs = new_env->sc_rdrs; +@@ -610,7 +623,9 @@ + struct imsgbuf *ibuf; + struct imsg imsg; + ssize_t n; ++#ifndef __FreeBSD__ + struct ctl_demote demote; ++#endif + + iev = ptr; + ibuf = &iev->ibuf; +@@ -638,6 +653,7 @@ + break; + + switch (imsg.hdr.type) { ++#ifndef __FreeBSD__ + case IMSG_DEMOTE: + if (imsg.hdr.len - IMSG_HEADER_SIZE != + sizeof(demote)) +@@ -646,6 +662,7 @@ + memcpy(&demote, imsg.data, sizeof(demote)); + carp_demote_set(demote.group, demote.level); + break; ++#endif + case IMSG_CTL_RELOAD: + /* + * so far we only get here if no L7 (relay) is done. +@@ -709,9 +726,11 @@ + imsg_compose_event(iev_hce, IMSG_SCRIPT, + 0, 0, -1, &scr, sizeof(scr)); + break; ++/* + case IMSG_SNMPSOCK: + (void)snmp_sendsock(iev); + break; ++*/ + default: + log_debug("main_dispatch_hce: unexpected imsg %d", + imsg.hdr.type); +@@ -1021,7 +1040,11 @@ + { + switch (type) { + case DIGEST_SHA1: ++#ifdef __FreeBSD__ ++ return (SHA1_Data(data, len, buf)); ++#else + return (SHA1Data(data, len, buf)); ++#endif + break; + case DIGEST_MD5: + return (MD5Data(data, len, buf)); +@@ -1258,9 +1281,11 @@ + bnd->bnd_proto == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM, + bnd->bnd_proto)) == -1) + goto fail; ++#ifndef __FreeBSD__ + if (setsockopt(s, SOL_SOCKET, SO_BINDANY, + &v, sizeof(v)) == -1) + goto fail; ++#endif + if (bind(s, (struct sockaddr *)&bnd->bnd_ss, + bnd->bnd_ss.ss_len) == -1) + goto fail; +diff -Naur relayd.orig/relayd.conf.5 relayd/relayd.conf.5 +--- relayd.orig/relayd.conf.5 2010-05-27 11:05:52.873793915 +0200 ++++ relayd/relayd.conf.5 2010-05-27 11:05:58.285863811 +0200 +@@ -103,17 +103,6 @@ + .Sh GLOBAL CONFIGURATION + Here are the settings that can be set globally: + .Bl -tag -width Ds +-.It Ic demote Ar group +-Enable the global +-.Xr carp 4 +-demotion option, resetting the carp demotion counter for the +-specified interface group to zero on startup and to 128 on shutdown of +-the daemon. +-For more information on interface groups, +-see the +-.Ic group +-keyword in +-.Xr ifconfig 8 . + .It Ic interval Ar number + Set the interval in seconds at which the hosts will be checked. + The default interval is 10 seconds. +@@ -143,15 +132,6 @@ + .Xr relayd 8 + runs 5 relay processes by default and every process will handle + all configured relays. +-.It Ic send trap +-Send an SNMP trap when the state of a host changes. +-.Xr relayd 8 +-will try to connect to +-.Xr snmpd 8 +-and request it send a trap to the registered trap receivers; +-see +-.Xr snmpd.conf 5 +-for more information about the configuration. + .It Ic timeout Ar number + Set the global timeout in milliseconds for checks. + This can be overridden by the timeout value in the table definitions. +@@ -349,17 +329,6 @@ + .Pp + The following general table options are available: + .Bl -tag -width Ds +-.It Ic demote Ar group +-Enable the per-table +-.Xr carp 4 +-demotion option. +-This will increment the carp demotion counter for the +-specified interface group if all hosts in the table are down. +-For more information on interface groups, +-see the +-.Ic group +-keyword in +-.Xr ifconfig 8 . + .It Ic interval Ar number + Override the global interval and specify one for this table. + It must be a multiple of the global interval. +@@ -1037,7 +1006,7 @@ + .El + .Sh FILES + .Bl -tag -width "/etc/ssl/private/address.keyXX" -compact +-.It Pa /etc/relayd.conf ++.It Pa %%PREFIX%%/etc/relayd.conf + .Xr relayd 8 + configuration file. + .Pp +@@ -1146,7 +1115,6 @@ + .Sh SEE ALSO + .Xr relayctl 8 , + .Xr relayd 8 , +-.Xr snmpd 8 , + .Xr ssl 8 + .Sh HISTORY + The +diff -Naur relayd.orig/relayd.h relayd/relayd.h +--- relayd.orig/relayd.h 2010-05-27 11:05:52.871795234 +0200 ++++ relayd/relayd.h 2010-05-27 11:05:58.286913720 +0200 +@@ -19,10 +19,18 @@ + */ + + #include <sys/tree.h> ++#ifdef __FreeBSD__ ++#include <sys/param.h> ++#include <sys/queue.h> ++#endif + + #include <imsg.h> + ++#ifdef __FreeBSD__ ++#define CONF_FILE "%%PREFIX%%/etc/relayd.conf" ++#else + #define CONF_FILE "/etc/relayd.conf" ++#endif + #define RELAYD_SOCKET "/var/run/relayd.sock" + #define PF_SOCKET "/dev/pf" + #define RELAYD_USER "_relayd" +@@ -57,7 +65,18 @@ + #define PURGE_PROTOS 0x08 + #define PURGE_EVERYTHING 0xff + ++#ifndef __FreeBSD__ + #define SNMP_RECONNECT_TIMEOUT { 3, 0 } /* sec, usec */ ++#else ++#define SIMPLEQ_HEAD STAILQ_HEAD ++#define SIMPLEQ_FIRST STAILQ_FIRST ++#define SIMPLEQ_REMOVE_HEAD STAILQ_REMOVE_HEAD ++#define SIMPLEQ_ENTRY STAILQ_ENTRY ++#define SIMPLEQ_INIT STAILQ_INIT ++#define SIMPLEQ_EMPTY STAILQ_EMPTY ++#define SIMPLEQ_NEXT STAILQ_NEXT ++#define SIMPLEQ_INSERT_TAIL STAILQ_INSERT_TAIL ++#endif + + #if DEBUG > 1 + #define DPRINTF log_debug +@@ -607,10 +626,11 @@ + struct event sc_statev; + struct timeval sc_statinterval; + ++#ifndef __FreeBSD__ + int sc_snmp; + struct event sc_snmpto; + struct event sc_snmpev; +- ++#endif + int sc_has_icmp; + int sc_has_icmp6; + struct ctl_icmp_event sc_icmp_send; +@@ -688,7 +708,9 @@ + IMSG_HOST_STATUS, /* notifies from hce to pfe */ + IMSG_SYNC, + IMSG_NATLOOK, ++#ifndef __FreeBSD__ + IMSG_DEMOTE, ++#endif + IMSG_STATISTICS, + IMSG_RECONF, /* reconfiguration notifies */ + IMSG_RECONF_TABLE, +@@ -704,7 +726,9 @@ + IMSG_RECONF_RELAY, + IMSG_RECONF_END, + IMSG_SCRIPT, ++#ifndef __FreeBSD__ + IMSG_SNMPSOCK, ++#endif + IMSG_BINDANY + }; + +@@ -857,10 +881,12 @@ + void pn_unref(u_int16_t); + void pn_ref(u_int16_t); + ++#ifndef __FreeBSD__ + /* snmp.c */ + void snmp_init(struct relayd *, struct imsgev *); + int snmp_sendsock(struct imsgev *); + void snmp_hosttrap(struct table *, struct host *); ++#endif + + /* shuffle.c */ + void shuffle_init(struct shuffle *); diff --git a/net/relayd/files/patch-relayctl-parser.c b/net/relayd/files/patch-relayctl-parser.c new file mode 100644 index 000000000000..74bb85c2b23d --- /dev/null +++ b/net/relayd/files/patch-relayctl-parser.c @@ -0,0 +1,20 @@ +--- relayctl/parser.c.orig 2010-05-27 11:10:01.109068426 +0200 ++++ relayctl/parser.c 2010-05-27 11:11:24.194566616 +0200 +@@ -166,7 +166,7 @@ + } + + const struct token * +-match_token(const char *word, const struct token table[]) ++match_token(const char *word, const struct token *table) + { + u_int i, match; + const struct token *t = NULL; +@@ -243,7 +243,7 @@ + } + + void +-show_valid_args(const struct token table[]) ++show_valid_args(const struct token *table) + { + int i; + diff --git a/net/relayd/files/patch-relayctl-relayctl.c b/net/relayd/files/patch-relayctl-relayctl.c new file mode 100644 index 000000000000..2bf3dc129869 --- /dev/null +++ b/net/relayd/files/patch-relayctl-relayctl.c @@ -0,0 +1,27 @@ +--- relayctl/relayctl.c.orig 2010-05-27 11:10:01.111140304 +0200 ++++ relayctl/relayctl.c 2010-05-27 11:10:16.855173170 +0200 +@@ -86,6 +86,7 @@ + }; + + struct imsgbuf *ibuf; ++int error = 0; + + __dead void + usage(void) +@@ -235,7 +236,7 @@ + close(ctl_sock); + free(ibuf); + +- return (0); ++ return (error ? 1 : 0); + } + + struct imsgname * +@@ -431,6 +432,7 @@ + break; + case IMSG_CTL_FAIL: + printf("command failed\n"); ++ error++; + break; + default: + errx(1, "wrong message in summary: %u", imsg->hdr.type); diff --git a/net/relayd/files/patch-relayd-check_icmp.c b/net/relayd/files/patch-relayd-check_icmp.c new file mode 100644 index 000000000000..84013c12c89f --- /dev/null +++ b/net/relayd/files/patch-relayd-check_icmp.c @@ -0,0 +1,11 @@ +--- relayd/check_icmp.c.orig 2009-08-07 13:32:54.000000000 +0200 ++++ relayd/check_icmp.c 2010-05-27 11:22:12.631744485 +0200 +@@ -150,7 +150,7 @@ + if (((struct sockaddr *)&host->conf.ss)->sa_family != + cie->af) + continue; +- if (!(host->flags & F_CHECK_DONE)) { ++ if (!(host->flags & (F_CHECK_DONE|F_DISABLE))) { + host->up = HOST_DOWN; + hce_notify_done(host, he); + } diff --git a/net/relayd/files/patch-relayd-check_tcp.c b/net/relayd/files/patch-relayd-check_tcp.c new file mode 100644 index 000000000000..eb4e13728c75 --- /dev/null +++ b/net/relayd/files/patch-relayd-check_tcp.c @@ -0,0 +1,10 @@ +--- relayd/check_tcp.c.orig 2010-05-27 11:10:01.114202025 +0200 ++++ relayd/check_tcp.c 2010-05-27 11:22:55.453595437 +0200 +@@ -99,6 +99,7 @@ + + cte->buf = NULL; + cte->host->up = HOST_UP; ++ event_del(&cte->ev); + event_set(&cte->ev, s, EV_TIMEOUT|EV_WRITE, tcp_write, cte); + event_add(&cte->ev, &tv); + return; diff --git a/net/relayd/files/patch-relayd-control.c b/net/relayd/files/patch-relayd-control.c new file mode 100644 index 000000000000..334ecc36412c --- /dev/null +++ b/net/relayd/files/patch-relayd-control.c @@ -0,0 +1,11 @@ +--- relayd/control.c.orig 2009-06-06 01:39:51.000000000 +0200 ++++ relayd/control.c 2010-05-27 10:41:16.689809156 +0200 +@@ -142,7 +142,7 @@ + + session_socket_blockmode(connfd, BM_NONBLOCK); + +- if ((c = malloc(sizeof(struct ctl_conn))) == NULL) { ++ if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) { + close(connfd); + log_warn("control_accept"); + return; diff --git a/net/relayd/files/patch-relayd-relay.c b/net/relayd/files/patch-relayd-relay.c new file mode 100644 index 000000000000..b48e6ddb59ff --- /dev/null +++ b/net/relayd/files/patch-relayd-relay.c @@ -0,0 +1,52 @@ +--- relayd/relay.c.orig 2010-05-27 11:10:01.121571779 +0200 ++++ relayd/relay.c 2010-05-27 11:21:34.847047990 +0200 +@@ -105,6 +105,7 @@ + char *, size_t); + void relay_close_http(struct rsession *, u_int, const char *, + u_int16_t); ++void relay_http_request_close(struct ctl_relay_event *); + + SSL_CTX *relay_ssl_ctx_create(struct relay *); + void relay_ssl_transaction(struct rsession *, +@@ -1312,6 +1313,29 @@ + } + + void ++relay_http_request_close(struct ctl_relay_event *cre) ++{ ++ if (cre->path != NULL) { ++ free(cre->path); ++ cre->path = NULL; ++ } ++ ++ cre->args = NULL; ++ cre->version = NULL; ++ ++ if (cre->buf != NULL) { ++ free(cre->buf); ++ cre->buf = NULL; ++ cre->buflen = 0; ++ } ++ ++ cre->line = 0; ++ cre->method = 0; ++ cre->done = 0; ++ cre->chunked = 0; ++} ++ ++void + relay_read_http(struct bufferevent *bev, void *arg) + { + struct ctl_relay_event *cre = (struct ctl_relay_event *)arg; +@@ -1580,10 +1604,7 @@ + if (relay_bufferevent_print(cre->dst, "\r\n") == -1) + goto fail; + +- cre->line = 0; +- cre->method = 0; +- cre->done = 0; +- cre->chunked = 0; ++ relay_http_request_close(cre); + + done: + if (cre->dir == RELAY_DIR_REQUEST && !cre->toread && diff --git a/net/relayd/files/patch-relayd-relayd.c b/net/relayd/files/patch-relayd-relayd.c new file mode 100644 index 000000000000..3b21fdc39509 --- /dev/null +++ b/net/relayd/files/patch-relayd-relayd.c @@ -0,0 +1,27 @@ +--- relayd/relayd.c.orig 2010-05-27 11:19:46.619119949 +0200 ++++ relayd/relayd.c 2010-05-27 11:20:21.164983766 +0200 +@@ -306,6 +306,8 @@ + #endif + event_dispatch(); + ++ main_shutdown(env); ++ /* NOTREACHED */ + return (0); + } + +@@ -972,6 +974,7 @@ + if (timercmp(&tv_next, &tv, >)) + bcopy(&tv_next, &tv, sizeof(tv)); + ++ event_del(ev); + event_set(ev, fd, event, fn, arg); + event_add(ev, &tv); + } +@@ -1129,6 +1132,7 @@ + } + pn->key = strdup(pk->key); + if (pn->key == NULL) { ++ free(pn); + log_warn("out of memory"); + return (NULL); + } diff --git a/net/relayd/pkg-install b/net/relayd/files/pkg-install.in index 51d59c7df480..f5ee2a7be0ca 100644 --- a/net/relayd/pkg-install +++ b/net/relayd/files/pkg-install.in @@ -4,8 +4,8 @@ case $2 in PRE-INSTALL) - USER=${RUSER} - GROUP=${RGROUP} + USER=%%RUSER%% + GROUP=%%RGROUP%% UID=913 GID=913 diff --git a/net/relayd/files/relayd.in b/net/relayd/files/relayd.in index 243037bb327e..6b853c3788a6 100644 --- a/net/relayd/files/relayd.in +++ b/net/relayd/files/relayd.in @@ -20,5 +20,12 @@ load_rc_config $name : ${relayd_enable="NO"} command="%%PREFIX%%/sbin/relayd" +relayctl="%%PREFIX%%/sbin/relayctl" +reload_cmd="relayd_reload_cmd" +extra_commands="reload" + +relayd_reload_cmd () { + ${relayctl} reload +} run_rc_command "$1" diff --git a/net/relayd/pkg-descr b/net/relayd/pkg-descr index 83a1435a3713..734b53435103 100644 --- a/net/relayd/pkg-descr +++ b/net/relayd/pkg-descr @@ -1,7 +1,11 @@ -relayd is a daemon to relay and dynamically redirect incoming -connections to a target host. Its main purposes are to run as a -load-balancer, application layer gateway, or transparent proxy. The -daemon is able to monitor groups of hosts for availability, which is -determined by checking for a specific service common to a host group. +relayd is a daemon to relay and dynamically redirect incoming connections +to a target host. Its main purposes are to run as a load-balancer, +application layer gateway, or transparent proxy. The daemon is able to +monitor groups of hosts for availability, which is determined by checking +for a specific service common to a host group. When availability is con- +firmed, Layer 3 and/or layer 7 forwarding services are set up by relayd. + +Layer 3 redirection happens at the packet level; to configure it, relayd +communicates with pf(4). WWW: http://spootnik.org/relayd/ |