diff options
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/unwind/parse.y | 12 | ||||
-rw-r--r-- | sbin/unwind/printconf.c | 9 | ||||
-rw-r--r-- | sbin/unwind/resolver.c | 17 | ||||
-rw-r--r-- | sbin/unwind/unwind.c | 7 | ||||
-rw-r--r-- | sbin/unwind/unwind.h | 10 |
5 files changed, 30 insertions, 25 deletions
diff --git a/sbin/unwind/parse.y b/sbin/unwind/parse.y index 7196ce72348..b5d891b6013 100644 --- a/sbin/unwind/parse.y +++ b/sbin/unwind/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.18 2019/11/27 17:09:12 florian Exp $ */ +/* $OpenBSD: parse.y,v 1.19 2019/11/27 17:11:00 florian Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -189,7 +189,7 @@ block_list : BLOCK LIST STRING log { } ; -uw_pref : PREFERENCE { conf->res_pref_len = 0; } pref_block +uw_pref : PREFERENCE { conf->res_pref.len = 0; } pref_block ; pref_block : '{' optnl prefopts_l '}' @@ -203,11 +203,11 @@ prefopts_l : prefopts_l prefoptsl optnl prefoptsl : prefopt { if (!check_pref_uniq($1)) YYERROR; - if (conf->res_pref_len >= UW_RES_NONE) { + if (conf->res_pref.len >= UW_RES_NONE) { yyerror("preference list too long"); YYERROR; } - conf->res_pref[conf->res_pref_len++] = $1; + conf->res_pref.types[conf->res_pref.len++] = $1; } ; @@ -873,8 +873,8 @@ check_pref_uniq(enum uw_resolver_type type) { int i; - for (i = 0; i < conf->res_pref_len; i++) - if (conf->res_pref[i] == type) { + for (i = 0; i < conf->res_pref.len; i++) + if (conf->res_pref.types[i] == type) { yyerror("%s is already in the preference list", uw_resolver_type_str[type]); return (0); diff --git a/sbin/unwind/printconf.c b/sbin/unwind/printconf.c index 3e8ce2240bf..eb38e3c71ae 100644 --- a/sbin/unwind/printconf.c +++ b/sbin/unwind/printconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printconf.c,v 1.13 2019/11/27 17:09:12 florian Exp $ */ +/* $OpenBSD: printconf.c,v 1.14 2019/11/27 17:11:00 florian Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -68,10 +68,11 @@ print_config(struct uw_conf *conf) struct uw_forwarder *uw_forwarder; int i; - if (conf->res_pref_len > 0) { + if (conf->res_pref.len > 0) { printf("preference {"); - for (i = 0; i < conf->res_pref_len; i++) { - printf(" %s", uw_resolver_type_str[conf->res_pref[i]]); + for (i = 0; i < conf->res_pref.len; i++) { + printf(" %s", + uw_resolver_type_str[conf->res_pref.types[i]]); } printf(" }\n"); } diff --git a/sbin/unwind/resolver.c b/sbin/unwind/resolver.c index a2f0447cf9d..7b8f9a5afea 100644 --- a/sbin/unwind/resolver.c +++ b/sbin/unwind/resolver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolver.c,v 1.78 2019/11/27 17:09:12 florian Exp $ */ +/* $OpenBSD: resolver.c,v 1.79 2019/11/27 17:11:00 florian Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -1362,12 +1362,12 @@ best_resolver(void) resolvers[UW_RES_ASR] != NULL ? uw_resolver_state_str[resolvers[UW_RES_ASR]->state] : "NA"); - res = resolvers[resolver_conf->res_pref[0]]; + res = resolvers[resolver_conf->res_pref.types[0]]; - for (i = 1; i < resolver_conf->res_pref_len; i++) + for (i = 1; i < resolver_conf->res_pref.len; i++) if (resolver_cmp(res, - resolvers[resolver_conf->res_pref[i]]) < 0) - res = resolvers[resolver_conf->res_pref[i]]; + resolvers[resolver_conf->res_pref.types[i]]) < 0) + res = resolvers[resolver_conf->res_pref.types[i]]; if (res != NULL) log_debug("%s: %s state: %s%s", __func__, @@ -1423,11 +1423,12 @@ show_status(enum uw_resolver_type type, pid_t pid) switch(type) { case UW_RES_NONE: - for (i = 0; i < resolver_conf->res_pref_len; i++) + for (i = 0; i < resolver_conf->res_pref.len; i++) send_resolver_info( - resolvers[resolver_conf->res_pref[i]], - resolvers[resolver_conf->res_pref[i]] == + resolvers[resolver_conf->res_pref.types[i]], + resolvers[resolver_conf->res_pref.types[i]] == best, pid); + TAILQ_FOREACH(uw_forwarder, &autoconf_forwarder_list, entry) { memset(&cfi, 0, sizeof(cfi)); cfi.if_index = uw_forwarder->if_index; diff --git a/sbin/unwind/unwind.c b/sbin/unwind/unwind.c index 6e94bb89f40..80b917ce72f 100644 --- a/sbin/unwind/unwind.c +++ b/sbin/unwind/unwind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unwind.c,v 1.40 2019/11/27 17:09:12 florian Exp $ */ +/* $OpenBSD: unwind.c,v 1.41 2019/11/27 17:11:00 florian Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -639,7 +639,6 @@ merge_config(struct uw_conf *conf, struct uw_conf *xconf) free(uw_forwarder); } - conf->res_pref_len = xconf->res_pref_len; memcpy(&conf->res_pref, &xconf->res_pref, sizeof(conf->res_pref)); @@ -680,9 +679,9 @@ config_new_empty(void) if (xconf == NULL) fatal(NULL); - memcpy(&xconf->res_pref, &default_res_pref, + memcpy(&xconf->res_pref.types, &default_res_pref, sizeof(default_res_pref)); - xconf->res_pref_len = 5; + xconf->res_pref.len = nitems(default_res_pref); TAILQ_INIT(&xconf->uw_forwarder_list); TAILQ_INIT(&xconf->uw_dot_forwarder_list); diff --git a/sbin/unwind/unwind.h b/sbin/unwind/unwind.h index f4f6316a4e3..38114bfa92a 100644 --- a/sbin/unwind/unwind.h +++ b/sbin/unwind/unwind.h @@ -1,4 +1,4 @@ -/* $OpenBSD: unwind.h,v 1.37 2019/11/27 17:09:12 florian Exp $ */ +/* $OpenBSD: unwind.h,v 1.38 2019/11/27 17:11:00 florian Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -120,12 +120,16 @@ struct uw_forwarder { uint16_t port; }; +struct resolver_preference { + enum uw_resolver_type types[UW_RES_NONE]; + int len; +}; + TAILQ_HEAD(uw_forwarder_head, uw_forwarder); struct uw_conf { struct uw_forwarder_head uw_forwarder_list; struct uw_forwarder_head uw_dot_forwarder_list; - enum uw_resolver_type res_pref[UW_RES_NONE]; - int res_pref_len; + struct resolver_preference res_pref; char *blocklist_file; int blocklist_log; }; |