1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-21 04:06:46 +00:00

- Import relayctl runtime log verbosity setting from OpenBSD

- Import event handling change from OpenBSD
- Bump PORTREVISION
This commit is contained in:
Martin Matuska 2010-05-31 09:45:41 +00:00
parent 38da6424b5
commit ec3e38569c
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=255382
12 changed files with 492 additions and 21 deletions

View File

@ -6,7 +6,7 @@
PORTNAME= relayd
PORTVERSION= 4.6.20090813
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_LOCAL}
MASTER_SITE_SUBDIR= mm

View File

@ -1,6 +1,42 @@
--- 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 @@
--- relayctl/parser.c.orig 2010-05-31 07:38:49.928320202 +0000
+++ relayctl/parser.c 2010-05-31 07:41:05.348576930 +0000
@@ -68,6 +68,7 @@
static const struct token t_rdr_id[];
static const struct token t_table_id[];
static const struct token t_host_id[];
+static const struct token t_log[];
static const struct token t_main[] = {
{KEYWORD, "monitor", MONITOR, NULL},
@@ -78,6 +79,7 @@
{KEYWORD, "redirect", NONE, t_rdr},
{KEYWORD, "table", NONE, t_table},
{KEYWORD, "host", NONE, t_host},
+ {KEYWORD, "log", NONE, t_log},
{ENDTOKEN, "", NONE, NULL}
};
@@ -126,11 +128,17 @@
{ENDTOKEN, "", NONE, NULL}
};
+static const struct token t_log[] = {
+ {KEYWORD, "verbose", LOG_VERBOSE, NULL},
+ {KEYWORD, "brief", LOG_BRIEF, NULL},
+ {ENDTOKEN, "", NONE, NULL}
+};
+
static struct parse_result res;
#ifdef __FreeBSD__
-const struct token *match_token(const char *, const struct token []);
-void show_valid_args(const struct token []);
+const struct token *match_token(const char *, const struct token *);
+void show_valid_args(const struct token *);
#endif
struct parse_result *
@@ -166,7 +174,7 @@
}
const struct token *
@ -9,7 +45,7 @@
{
u_int i, match;
const struct token *t = NULL;
@@ -243,7 +243,7 @@
@@ -243,7 +251,7 @@
}
void

View File

@ -0,0 +1,22 @@
--- relayctl/parser.h.orig 2010-05-31 07:38:49.934576348 +0000
+++ relayctl/parser.h 2010-05-31 07:40:47.494152077 +0000
@@ -32,7 +32,9 @@
SHUTDOWN,
POLL,
RELOAD,
- MONITOR
+ MONITOR,
+ LOG_VERBOSE,
+ LOG_BRIEF
};
struct parse_result {
@@ -42,6 +44,6 @@
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 []);
+const struct token *match_token(const char *, const struct token *);
+void show_valid_args(const struct token *);
#endif

View File

@ -1,5 +1,5 @@
--- relayctl/relayctl.c.orig 2010-05-27 11:10:01.111140304 +0200
+++ relayctl/relayctl.c 2010-05-27 11:10:16.855173170 +0200
--- relayctl/relayctl.c.orig 2010-05-31 09:31:42.351734730 +0200
+++ relayctl/relayctl.c 2010-05-31 09:31:34.629284461 +0200
@@ -86,6 +86,7 @@
};
@ -8,7 +8,41 @@
__dead void
usage(void)
@@ -235,7 +236,7 @@
@@ -104,7 +105,7 @@
struct imsg imsg;
int ctl_sock;
int done = 0;
- int n;
+ int n, verbose = 0;
/* parse options */
if ((res = parse(argc - 1, argv + 1)) == NULL)
@@ -185,6 +186,15 @@
case MONITOR:
imsg_compose(ibuf, IMSG_CTL_NOTIFY, 0, 0, -1, NULL, 0);
break;
+ case LOG_VERBOSE:
+ verbose = 2;
+ /* FALLTHROUGH */
+ case LOG_BRIEF:
+ imsg_compose(ibuf, IMSG_CTL_LOG_VERBOSE, 0, 0, -1,
+ &verbose, sizeof(verbose));
+ printf("logging request sent.\n");
+ done = 1;
+ break;
}
while (ibuf->w.queued)
@@ -224,6 +234,8 @@
done = show_command_output(&imsg);
break;
case NONE:
+ case LOG_VERBOSE:
+ case LOG_BRIEF:
break;
case MONITOR:
done = monitor(&imsg);
@@ -235,7 +247,7 @@
close(ctl_sock);
free(ibuf);
@ -17,7 +51,7 @@
}
struct imsgname *
@@ -431,6 +432,7 @@
@@ -431,6 +443,7 @@
break;
case IMSG_CTL_FAIL:
printf("command failed\n");

View File

@ -1,6 +1,13 @@
--- 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 @@
--- relayd/control.c.orig 2010-05-31 09:31:24.548916055 +0000
+++ relayd/control.c 2010-05-31 09:31:09.036333394 +0000
@@ -136,13 +136,13 @@
if ((connfd = accept(listenfd,
(struct sockaddr *)&sun, &len)) == -1) {
if (errno != EWOULDBLOCK && errno != EINTR)
- log_warn("control_accept");
+ log_warn("control_accept: accept");
return;
}
session_socket_blockmode(connfd, BM_NONBLOCK);
@ -9,3 +16,34 @@
close(connfd);
log_warn("control_accept");
return;
@@ -196,6 +196,7 @@
struct imsg imsg;
struct ctl_id id;
int n;
+ int verbose;
struct relayd *env = arg;
if ((c = control_connbyfd(fd)) == NULL) {
@@ -356,6 +357,22 @@
}
c->flags |= CTL_CONN_NOTIFY;
break;
+ case IMSG_CTL_LOG_VERBOSE:
+ if (imsg.hdr.len != IMSG_HEADER_SIZE +
+ sizeof(verbose))
+ break;
+
+ memcpy(&verbose, imsg.data, sizeof(verbose));
+
+ imsg_compose_event(iev_hce, IMSG_CTL_LOG_VERBOSE,
+ 0, 0, -1, &verbose, sizeof(verbose));
+ imsg_compose_event(iev_main, IMSG_CTL_LOG_VERBOSE,
+ 0, 0, -1, &verbose, sizeof(verbose));
+ memcpy(imsg.data, &verbose, sizeof(verbose));
+ control_imsg_forward(&imsg);
+
+ log_verbose(verbose);
+ break;
default:
log_debug("control_dispatch_imsg: "
"error handling imsg %d", imsg.hdr.type);

View File

@ -0,0 +1,66 @@
--- relayd/hce.c.orig 2010-05-31 08:54:55.771055422 +0200
+++ relayd/hce.c 2010-05-31 08:54:50.916277342 +0200
@@ -62,6 +62,11 @@
case SIGTERM:
hce_shutdown();
break;
+ case SIGCHLD:
+ case SIGHUP:
+ case SIGPIPE:
+ /* ignore */
+ break;
default:
fatalx("hce_sig_handler: unexpected signal");
}
@@ -75,8 +80,6 @@
pid_t pid;
struct passwd *pw;
int i;
- struct event ev_sigint;
- struct event ev_sigterm;
switch (pid = fork()) {
case -1:
@@ -135,12 +138,17 @@
iev_main->handler, iev_main);
event_add(&iev_main->ev, NULL);
- signal_set(&ev_sigint, SIGINT, hce_sig_handler, NULL);
- signal_set(&ev_sigterm, SIGTERM, hce_sig_handler, NULL);
- signal_add(&ev_sigint, NULL);
- signal_add(&ev_sigterm, NULL);
- signal(SIGPIPE, SIG_IGN);
- signal(SIGHUP, SIG_IGN);
+ signal_set(&env->sc_evsigint, SIGINT, hce_sig_handler, env);
+ signal_set(&env->sc_evsigterm, SIGTERM, hce_sig_handler, env);
+ signal_set(&env->sc_evsigchld, SIGCHLD, hce_sig_handler, env);
+ signal_set(&env->sc_evsighup, SIGHUP, hce_sig_handler, env);
+ signal_set(&env->sc_evsigpipe, SIGPIPE, hce_sig_handler, env);
+
+ signal_add(&env->sc_evsigint, NULL);
+ signal_add(&env->sc_evsigterm, NULL);
+ signal_add(&env->sc_evsigchld, NULL);
+ signal_add(&env->sc_evsighup, NULL);
+ signal_add(&env->sc_evsigpipe, NULL);
/* setup pipes */
close(pipe_pfe2hce[1]);
@@ -370,6 +378,7 @@
objid_t id;
struct host *host;
struct table *table;
+ int verbose;
iev = ptr;
ibuf = &iev->ibuf;
@@ -437,6 +446,10 @@
table->skipped = 0;
hce_launch_checks(-1, EV_TIMEOUT, env);
break;
+ case IMSG_CTL_LOG_VERBOSE:
+ memcpy(&verbose, imsg.data, sizeof(verbose));
+ log_verbose(verbose);
+ break;
default:
log_debug("hce_dispatch_msg: unexpected imsg %d",
imsg.hdr.type);

View File

@ -0,0 +1,40 @@
--- relayd/log.c.orig 2010-05-31 08:55:55.644112693 +0200
+++ relayd/log.c 2010-05-31 08:55:50.789959404 +0200
@@ -45,6 +45,7 @@
#include "relayd.h"
int debug;
+int verbose;
void vlog(int, const char *, va_list);
void logit(int, const char *, ...);
@@ -55,6 +56,7 @@
extern char *__progname;
debug = n_debug;
+ verbose = n_debug;
if (!debug)
openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
@@ -63,6 +65,12 @@
}
void
+log_verbose(int v)
+{
+ verbose = v;
+}
+
+void
logit(int pri, const char *fmt, ...)
{
va_list ap;
@@ -141,7 +149,7 @@
{
va_list ap;
- if (debug > 1) {
+ if (verbose > 1) {
va_start(ap, emsg);
vlog(LOG_DEBUG, emsg, ap);
va_end(ap);

View File

@ -0,0 +1,14 @@
--- relayd/parse.y.orig 2010-05-31 09:00:51.007686324 +0200
+++ relayd/parse.y 2010-05-31 09:00:42.736791085 +0200
@@ -2003,6 +2006,11 @@
bzero(&conf->sc_proto_default, sizeof(conf->sc_proto_default));
conf->sc_proto_default.flags = F_USED;
conf->sc_proto_default.cache = RELAY_CACHESIZE;
+ conf->sc_proto_default.tcpflags = TCPFLAG_DEFAULT;
+ conf->sc_proto_default.tcpbacklog = RELAY_BACKLOG;
+ conf->sc_proto_default.sslflags = SSLFLAG_DEFAULT;
+ (void)strlcpy(conf->sc_proto_default.sslciphers, SSLCIPHERS_DEFAULT,
+ sizeof(conf->sc_proto_default.sslciphers));
conf->sc_proto_default.type = RELAY_PROTO_TCP;
(void)strlcpy(conf->sc_proto_default.name, "default",
sizeof(conf->sc_proto_default.name));

View File

@ -0,0 +1,47 @@
--- relayd/pfe.c.orig 2010-05-31 09:07:56.755288041 +0200
+++ relayd/pfe.c 2010-05-31 09:07:52.006100566 +0200
@@ -62,6 +62,11 @@
case SIGTERM:
pfe_shutdown();
break;
+ case SIGCHLD:
+ case SIGHUP:
+ case SIGPIPE:
+ /* ignore */
+ break;
default:
fatalx("pfe_sig_handler: unexpected signal");
}
@@ -74,8 +79,6 @@
{
pid_t pid;
struct passwd *pw;
- struct event ev_sigint;
- struct event ev_sigterm;
int i;
size_t size;
@@ -121,12 +124,17 @@
event_init();
- signal_set(&ev_sigint, SIGINT, pfe_sig_handler, NULL);
- signal_set(&ev_sigterm, SIGTERM, pfe_sig_handler, NULL);
- signal_add(&ev_sigint, NULL);
- signal_add(&ev_sigterm, NULL);
- signal(SIGPIPE, SIG_IGN);
- signal(SIGHUP, SIG_IGN);
+ signal_set(&env->sc_evsigint, SIGINT, pfe_sig_handler, env);
+ signal_set(&env->sc_evsigterm, SIGTERM, pfe_sig_handler, env);
+ signal_set(&env->sc_evsigchld, SIGCHLD, pfe_sig_handler, env);
+ signal_set(&env->sc_evsighup, SIGHUP, pfe_sig_handler, env);
+ signal_set(&env->sc_evsigpipe, SIGPIPE, pfe_sig_handler, env);
+
+ signal_add(&env->sc_evsigint, NULL);
+ signal_add(&env->sc_evsigterm, NULL);
+ signal_add(&env->sc_evsigchld, NULL);
+ signal_add(&env->sc_evsighup, NULL);
+ signal_add(&env->sc_evsigpipe, NULL);
/* setup pipes */
close(pipe_pfe2hce[0]);

View File

@ -1,5 +1,5 @@
--- relayd/relay.c.orig 2010-05-27 11:10:01.121571779 +0200
+++ relayd/relay.c 2010-05-27 11:21:34.847047990 +0200
--- relayd/relay.c.orig 2010-05-31 09:13:05.908338459 +0200
+++ relayd/relay.c 2010-05-31 09:12:54.131616372 +0200
@@ -105,6 +105,7 @@
char *, size_t);
void relay_close_http(struct rsession *, u_int, const char *,
@ -8,7 +8,55 @@
SSL_CTX *relay_ssl_ctx_create(struct relay *);
void relay_ssl_transaction(struct rsession *,
@@ -1312,6 +1313,29 @@
@@ -148,6 +149,14 @@
case SIGTERM:
case SIGINT:
(void)event_loopexit(NULL);
+ break;
+ case SIGCHLD:
+ case SIGHUP:
+ case SIGPIPE:
+ /* ignore */
+ break;
+ default:
+ fatalx("relay_sig_handler: unexpected signal");
}
}
@@ -158,8 +167,6 @@
{
pid_t pid;
struct passwd *pw;
- struct event ev_sigint;
- struct event ev_sigterm;
int i;
switch (pid = fork()) {
@@ -213,12 +220,17 @@
/* Per-child initialization */
relay_init();
- signal_set(&ev_sigint, SIGINT, relay_sig_handler, NULL);
- signal_set(&ev_sigterm, SIGTERM, relay_sig_handler, NULL);
- signal_add(&ev_sigint, NULL);
- signal_add(&ev_sigterm, NULL);
- signal(SIGHUP, SIG_IGN);
- signal(SIGPIPE, SIG_IGN);
+ signal_set(&env->sc_evsigint, SIGINT, relay_sig_handler, env);
+ signal_set(&env->sc_evsigterm, SIGTERM, relay_sig_handler, env);
+ signal_set(&env->sc_evsigchld, SIGCHLD, relay_sig_handler, env);
+ signal_set(&env->sc_evsighup, SIGHUP, relay_sig_handler, env);
+ signal_set(&env->sc_evsigpipe, SIGPIPE, relay_sig_handler, env);
+
+ signal_add(&env->sc_evsigint, NULL);
+ signal_add(&env->sc_evsigterm, NULL);
+ signal_add(&env->sc_evsigchld, NULL);
+ signal_add(&env->sc_evsighup, NULL);
+ signal_add(&env->sc_evsigpipe, NULL);
/* setup pipes */
close(pipe_pfe2hce[0]);
@@ -1312,6 +1324,29 @@
}
void
@ -38,7 +86,7 @@
relay_read_http(struct bufferevent *bev, void *arg)
{
struct ctl_relay_event *cre = (struct ctl_relay_event *)arg;
@@ -1580,10 +1604,7 @@
@@ -1580,10 +1615,7 @@
if (relay_bufferevent_print(cre->dst, "\r\n") == -1)
goto fail;
@ -50,3 +98,22 @@
done:
if (cre->dir == RELAY_DIR_REQUEST && !cre->toread &&
@@ -2419,6 +2451,7 @@
struct table *table;
struct ctl_status st;
objid_t id;
+ int verbose;
iev = ptr;
ibuf = &iev->ibuf;
@@ -2522,6 +2555,10 @@
imsg_compose_event(iev, IMSG_CTL_END,
0, 0, -1, NULL, 0);
break;
+ case IMSG_CTL_LOG_VERBOSE:
+ memcpy(&verbose, imsg.data, sizeof(verbose));
+ log_verbose(verbose);
+ break;
default:
log_debug("relay_dispatch_msg: unexpected imsg %d",
imsg.hdr.type);

View File

@ -1,6 +1,54 @@
--- 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 @@
--- relayd/relayd.c.orig 2010-05-31 07:32:32.670912835 +0000
+++ relayd/relayd.c 2010-05-31 07:35:25.223559078 +0000
@@ -112,6 +112,9 @@
case SIGHUP:
reconfigure();
break;
+ case SIGPIPE:
+ /* ignore */
+ break;
default:
fatalx("unexpected signal");
}
@@ -136,10 +139,6 @@
u_int32_t opts;
struct relayd *env;
const char *conffile;
- struct event ev_sigint;
- struct event ev_sigterm;
- struct event ev_sigchld;
- struct event ev_sighup;
struct imsgev *iev;
opts = 0;
@@ -245,15 +244,17 @@
event_init();
- signal_set(&ev_sigint, SIGINT, main_sig_handler, env);
- signal_set(&ev_sigterm, SIGTERM, main_sig_handler, env);
- signal_set(&ev_sigchld, SIGCHLD, main_sig_handler, env);
- signal_set(&ev_sighup, SIGHUP, main_sig_handler, env);
- signal_add(&ev_sigint, NULL);
- signal_add(&ev_sigterm, NULL);
- signal_add(&ev_sigchld, NULL);
- signal_add(&ev_sighup, NULL);
- signal(SIGPIPE, SIG_IGN);
+ signal_set(&env->sc_evsigint, SIGINT, main_sig_handler, env);
+ signal_set(&env->sc_evsigterm, SIGTERM, main_sig_handler, env);
+ signal_set(&env->sc_evsigchld, SIGCHLD, main_sig_handler, env);
+ signal_set(&env->sc_evsighup, SIGHUP, main_sig_handler, env);
+ signal_set(&env->sc_evsigpipe, SIGPIPE, main_sig_handler, env);
+
+ signal_add(&env->sc_evsigint, NULL);
+ signal_add(&env->sc_evsigterm, NULL);
+ signal_add(&env->sc_evsigchld, NULL);
+ signal_add(&env->sc_evsighup, NULL);
+ signal_add(&env->sc_evsigpipe, NULL);
close(pipe_parent2pfe[1]);
close(pipe_parent2hce[1]);
@@ -306,6 +307,8 @@
#endif
event_dispatch();
@ -9,7 +57,26 @@
return (0);
}
@@ -972,6 +974,7 @@
@@ -626,6 +629,7 @@
#ifndef __FreeBSD__
struct ctl_demote demote;
#endif
+ int verbose;
iev = ptr;
ibuf = &iev->ibuf;
@@ -669,6 +673,10 @@
*/
reconfigure();
break;
+ case IMSG_CTL_LOG_VERBOSE:
+ memcpy(&verbose, imsg.data, sizeof(verbose));
+ log_verbose(verbose);
+ break;
default:
log_debug("main_dispatch_pfe: unexpected imsg %d",
imsg.hdr.type);
@@ -972,6 +980,7 @@
if (timercmp(&tv_next, &tv, >))
bcopy(&tv_next, &tv, sizeof(tv));
@ -17,7 +84,7 @@
event_set(ev, fd, event, fn, arg);
event_add(ev, &tv);
}
@@ -1129,6 +1132,7 @@
@@ -1129,6 +1138,7 @@
}
pn->key = strdup(pk->key);
if (pn->key == NULL) {

View File

@ -0,0 +1,40 @@
--- relayd/relayd.h.orig 2010-05-31 09:21:12.676718667 +0200
+++ relayd/relayd.h 2010-05-31 09:21:04.892410464 +0200
@@ -637,6 +637,13 @@
struct ctl_icmp_event sc_icmp_recv;
struct ctl_icmp_event sc_icmp6_send;
struct ctl_icmp_event sc_icmp6_recv;
+
+ /* Event and signal handlers */
+ struct event sc_evsigint;
+ struct event sc_evsigterm;
+ struct event sc_evsigchld;
+ struct event sc_evsighup;
+ struct event sc_evsigpipe;
};
#define RELAYD_OPT_VERBOSE 0x01
@@ -699,6 +706,7 @@
IMSG_CTL_NOTIFY,
IMSG_CTL_RDR_STATS,
IMSG_CTL_RELAY_STATS,
+ IMSG_CTL_LOG_VERBOSE,
IMSG_RDR_ENABLE, /* notifies from pfe to hce */
IMSG_RDR_DISABLE,
IMSG_TABLE_ENABLE,
@@ -799,7 +807,6 @@
int relay_cmp_af(struct sockaddr_storage *,
struct sockaddr_storage *);
-
RB_PROTOTYPE(proto_tree, protonode, se_nodes, relay_proto_cmp);
SPLAY_PROTOTYPE(session_tree, rsession, se_nodes, relay_session_cmp);
@@ -894,6 +901,7 @@
/* log.c */
void log_init(int);
+void log_verbose(int);
void log_warn(const char *, ...);
void log_warnx(const char *, ...);
void log_info(const char *, ...);