diff options
Diffstat (limited to 'usr.sbin/eigrpd')
-rw-r--r-- | usr.sbin/eigrpd/eigrpd.c | 20 | ||||
-rw-r--r-- | usr.sbin/eigrpd/eigrpd.h | 19 | ||||
-rw-r--r-- | usr.sbin/eigrpd/eigrpe.c | 36 | ||||
-rw-r--r-- | usr.sbin/eigrpd/interface.c | 18 | ||||
-rw-r--r-- | usr.sbin/eigrpd/packet.c | 6 | ||||
-rw-r--r-- | usr.sbin/eigrpd/parse.y | 9 | ||||
-rw-r--r-- | usr.sbin/eigrpd/rde.c | 4 |
7 files changed, 58 insertions, 54 deletions
diff --git a/usr.sbin/eigrpd/eigrpd.c b/usr.sbin/eigrpd/eigrpd.c index c3ea3a3f0c8..e5103cc2631 100644 --- a/usr.sbin/eigrpd/eigrpd.c +++ b/usr.sbin/eigrpd/eigrpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpd.c,v 1.10 2016/04/15 13:18:38 renato Exp $ */ +/* $OpenBSD: eigrpd.c,v 1.11 2016/04/15 13:21:45 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -112,7 +112,7 @@ usage(void) exit(1); } -int cmd_opts; +struct eigrpd_global global; int main(int argc, char *argv[]) @@ -146,15 +146,15 @@ main(int argc, char *argv[]) conffile = optarg; break; case 'n': - cmd_opts |= EIGRPD_OPT_NOACTION; + global.cmd_opts |= EIGRPD_OPT_NOACTION; break; case 's': sockname = optarg; break; case 'v': - if (cmd_opts & EIGRPD_OPT_VERBOSE) - cmd_opts |= EIGRPD_OPT_VERBOSE2; - cmd_opts |= EIGRPD_OPT_VERBOSE; + if (global.cmd_opts & EIGRPD_OPT_VERBOSE) + global.cmd_opts |= EIGRPD_OPT_VERBOSE2; + global.cmd_opts |= EIGRPD_OPT_VERBOSE; break; default: usage(); @@ -186,10 +186,10 @@ main(int argc, char *argv[]) kif_clear(); exit(1); } - eigrpd_conf->csock = sockname; + global.csock = sockname; - if (cmd_opts & EIGRPD_OPT_NOACTION) { - if (cmd_opts & EIGRPD_OPT_VERBOSE) + if (global.cmd_opts & EIGRPD_OPT_NOACTION) { + if (global.cmd_opts & EIGRPD_OPT_VERBOSE) print_config(eigrpd_conf); else fprintf(stderr, "configuration OK\n"); @@ -206,7 +206,7 @@ main(int argc, char *argv[]) errx(1, "unknown user %s", EIGRPD_USER); log_init(debug); - log_verbose(cmd_opts & EIGRPD_OPT_VERBOSE); + log_verbose(global.cmd_opts & EIGRPD_OPT_VERBOSE); if (!debug) daemon(1, 0); diff --git a/usr.sbin/eigrpd/eigrpd.h b/usr.sbin/eigrpd/eigrpd.h index 6306bbf358a..da9efbba12e 100644 --- a/usr.sbin/eigrpd/eigrpd.h +++ b/usr.sbin/eigrpd/eigrpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpd.h,v 1.12 2016/04/15 13:18:38 renato Exp $ */ +/* $OpenBSD: eigrpd.h,v 1.13 2016/04/15 13:21:45 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -310,22 +310,25 @@ enum { struct eigrpd_conf { struct in_addr rtr_id; - int flags; -#define EIGRPD_FLAG_NO_FIB_UPDATE 0x0001 - - time_t uptime; - int eigrp_socket_v4; - int eigrp_socket_v6; unsigned int rdomain; uint8_t fib_priority_internal; uint8_t fib_priority_external; uint8_t fib_priority_summary; TAILQ_HEAD(, iface) iface_list; TAILQ_HEAD(, eigrp) instances; + int flags; +#define EIGRPD_FLAG_NO_FIB_UPDATE 0x0001 +}; + +struct eigrpd_global { + int cmd_opts; + time_t uptime; + int eigrp_socket_v4; + int eigrp_socket_v6; char *csock; }; -extern int cmd_opts; +extern struct eigrpd_global global; /* kroute */ struct kroute { diff --git a/usr.sbin/eigrpd/eigrpe.c b/usr.sbin/eigrpd/eigrpe.c index ed2f874227c..2702b5f05b4 100644 --- a/usr.sbin/eigrpd/eigrpe.c +++ b/usr.sbin/eigrpd/eigrpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpe.c,v 1.16 2016/04/15 13:10:56 renato Exp $ */ +/* $OpenBSD: eigrpe.c,v 1.17 2016/04/15 13:21:45 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -84,39 +84,39 @@ eigrpe(struct eigrpd_conf *xconf, int pipe_parent2eigrpe[2], } /* create eigrpd control socket outside chroot */ - if (control_init(xconf->csock) == -1) + if (control_init(global.csock) == -1) fatalx("control socket setup failed"); /* create the raw ipv4 socket */ - if ((xconf->eigrp_socket_v4 = socket(AF_INET, + if ((global.eigrp_socket_v4 = socket(AF_INET, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, IPPROTO_EIGRP)) == -1) fatal("error creating raw ipv4 socket"); /* set some defaults */ - if (if_set_ipv4_mcast_ttl(xconf->eigrp_socket_v4, EIGRP_IP_TTL) == -1) + if (if_set_ipv4_mcast_ttl(global.eigrp_socket_v4, EIGRP_IP_TTL) == -1) fatal("if_set_ipv4_mcast_ttl"); - if (if_set_ipv4_mcast_loop(xconf->eigrp_socket_v4) == -1) + if (if_set_ipv4_mcast_loop(global.eigrp_socket_v4) == -1) fatal("if_set_ipv4_mcast_loop"); - if (if_set_ipv4_recvif(xconf->eigrp_socket_v4, 1) == -1) + if (if_set_ipv4_recvif(global.eigrp_socket_v4, 1) == -1) fatal("if_set_ipv4_recvif"); - if (if_set_ipv4_hdrincl(xconf->eigrp_socket_v4) == -1) + if (if_set_ipv4_hdrincl(global.eigrp_socket_v4) == -1) fatal("if_set_ipv4_hdrincl"); - if_set_sockbuf(xconf->eigrp_socket_v4); + if_set_sockbuf(global.eigrp_socket_v4); /* create the raw ipv6 socket */ - if ((xconf->eigrp_socket_v6 = socket(AF_INET6, + if ((global.eigrp_socket_v6 = socket(AF_INET6, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, IPPROTO_EIGRP)) == -1) fatal("error creating raw ipv6 socket"); /* set some defaults */ - if (if_set_ipv6_mcast_loop(xconf->eigrp_socket_v6) == -1) + if (if_set_ipv6_mcast_loop(global.eigrp_socket_v6) == -1) fatal("if_set_ipv6_mcast_loop"); - if (if_set_ipv6_pktinfo(xconf->eigrp_socket_v6, 1) == -1) + if (if_set_ipv6_pktinfo(global.eigrp_socket_v6, 1) == -1) fatal("if_set_ipv6_pktinfo"); - if (if_set_ipv6_dscp(xconf->eigrp_socket_v6, + if (if_set_ipv6_dscp(global.eigrp_socket_v6, IPTOS_PREC_NETCONTROL) == -1) fatal("if_set_ipv6_dscp"); - if_set_sockbuf(xconf->eigrp_socket_v6); + if_set_sockbuf(global.eigrp_socket_v6); econf = xconf; @@ -171,11 +171,11 @@ eigrpe(struct eigrpd_conf *xconf, int pipe_parent2eigrpe[2], iev_main->handler, iev_main); event_add(&iev_main->ev, NULL); - event_set(&ev4, econf->eigrp_socket_v4, EV_READ|EV_PERSIST, + event_set(&ev4, global.eigrp_socket_v4, EV_READ|EV_PERSIST, recv_packet_v4, econf); event_add(&ev4, NULL); - event_set(&ev6, econf->eigrp_socket_v6, EV_READ|EV_PERSIST, + event_set(&ev6, global.eigrp_socket_v6, EV_READ|EV_PERSIST, recv_packet_v6, econf); event_add(&ev6, NULL); @@ -203,14 +203,14 @@ eigrpe(struct eigrpd_conf *xconf, int pipe_parent2eigrpe[2], void eigrpe_shutdown(void) { - control_cleanup(econf->csock); + control_cleanup(global.csock); config_clear(econf); event_del(&ev4); event_del(&ev6); - close(econf->eigrp_socket_v4); - close(econf->eigrp_socket_v6); + close(global.eigrp_socket_v4); + close(global.eigrp_socket_v6); /* clean up */ msgbuf_write(&iev_rde->ibuf.w); diff --git a/usr.sbin/eigrpd/interface.c b/usr.sbin/eigrpd/interface.c index eea1e1478f4..5226376d993 100644 --- a/usr.sbin/eigrpd/interface.c +++ b/usr.sbin/eigrpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.16 2016/04/15 13:10:56 renato Exp $ */ +/* $OpenBSD: interface.c,v 1.17 2016/04/15 13:21:45 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -122,11 +122,11 @@ if_init(struct eigrpd_conf *xconf, struct iface *iface) /* set rdomain */ strlcpy(ifr.ifr_name, iface->name, sizeof(ifr.ifr_name)); - if (ioctl(econf->eigrp_socket_v4, SIOCGIFRDOMAIN, (caddr_t)&ifr) == -1) + if (ioctl(global.eigrp_socket_v4, SIOCGIFRDOMAIN, (caddr_t)&ifr) == -1) rdomain = 0; else { rdomain = ifr.ifr_rdomainid; - if (setsockopt(econf->eigrp_socket_v4, SOL_SOCKET, SO_RTABLE, + if (setsockopt(global.eigrp_socket_v4, SOL_SOCKET, SO_RTABLE, &rdomain, sizeof(rdomain)) == -1) fatal("failed to set rdomain"); } @@ -564,7 +564,7 @@ if_join_ipv4_group(struct iface *iface, struct in_addr *addr) mreq.imr_multiaddr = *addr; mreq.imr_interface.s_addr = if_primary_addr(iface); - if (setsockopt(econf->eigrp_socket_v4, IPPROTO_IP, IP_ADD_MEMBERSHIP, + if (setsockopt(global.eigrp_socket_v4, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof(mreq)) < 0) { log_warn("%s: error IP_ADD_MEMBERSHIP, interface %s address %s", __func__, iface->name, inet_ntoa(*addr)); @@ -589,7 +589,7 @@ if_leave_ipv4_group(struct iface *iface, struct in_addr *addr) mreq.imr_multiaddr = *addr; mreq.imr_interface.s_addr = if_primary_addr(iface); - if (setsockopt(econf->eigrp_socket_v4, IPPROTO_IP, IP_DROP_MEMBERSHIP, + if (setsockopt(global.eigrp_socket_v4, IPPROTO_IP, IP_DROP_MEMBERSHIP, (void *)&mreq, sizeof(mreq)) < 0) { log_warn("%s: error IP_DROP_MEMBERSHIP, interface %s " "address %s", iface->name, __func__, inet_ntoa(*addr)); @@ -619,7 +619,7 @@ if_set_ipv4_mcast(struct iface *iface) addr = if_primary_addr(iface); - if (setsockopt(econf->eigrp_socket_v4, IPPROTO_IP, IP_MULTICAST_IF, + if (setsockopt(global.eigrp_socket_v4, IPPROTO_IP, IP_MULTICAST_IF, &addr, sizeof(addr)) < 0) { log_warn("%s: error setting IP_MULTICAST_IF, interface %s", __func__, iface->name); @@ -682,7 +682,7 @@ if_join_ipv6_group(struct iface *iface, struct in6_addr *addr) mreq.ipv6mr_multiaddr = *addr; mreq.ipv6mr_interface = iface->ifindex; - if (setsockopt(econf->eigrp_socket_v6, IPPROTO_IPV6, IPV6_JOIN_GROUP, + if (setsockopt(global.eigrp_socket_v6, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof(mreq)) < 0) { log_warn("%s: error IPV6_JOIN_GROUP, interface %s address %s", __func__, iface->name, log_in6addr(addr)); @@ -707,7 +707,7 @@ if_leave_ipv6_group(struct iface *iface, struct in6_addr *addr) mreq.ipv6mr_multiaddr = *addr; mreq.ipv6mr_interface = iface->ifindex; - if (setsockopt(econf->eigrp_socket_v6, IPPROTO_IPV6, IPV6_LEAVE_GROUP, + if (setsockopt(global.eigrp_socket_v6, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (void *)&mreq, sizeof(mreq)) < 0) { log_warn("%s: error IPV6_LEAVE_GROUP, interface %s address %s", __func__, iface->name, log_in6addr(addr)); @@ -720,7 +720,7 @@ if_leave_ipv6_group(struct iface *iface, struct in6_addr *addr) int if_set_ipv6_mcast(struct iface *iface) { - if (setsockopt(econf->eigrp_socket_v6, IPPROTO_IPV6, IPV6_MULTICAST_IF, + if (setsockopt(global.eigrp_socket_v6, IPPROTO_IPV6, IPV6_MULTICAST_IF, &iface->ifindex, sizeof(iface->ifindex)) < 0) { log_warn("%s: error setting IPV6_MULTICAST_IF, interface %s", __func__, iface->name); diff --git a/usr.sbin/eigrpd/packet.c b/usr.sbin/eigrpd/packet.c index 9cb7a801ee2..6b343ce7414 100644 --- a/usr.sbin/eigrpd/packet.c +++ b/usr.sbin/eigrpd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.13 2016/04/15 13:10:56 renato Exp $ */ +/* $OpenBSD: packet.c,v 1.14 2016/04/15 13:21:45 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -105,7 +105,7 @@ send_packet_v4(struct iface *iface, struct nbr *nbr, struct ibuf *buf) return (-1); } - if (sendmsg(econf->eigrp_socket_v4, &msg, 0) == -1) { + if (sendmsg(global.eigrp_socket_v4, &msg, 0) == -1) { log_warn("%s: error sending packet on interface %s", __func__, iface->name); return (-1); @@ -138,7 +138,7 @@ send_packet_v6(struct iface *iface, struct nbr *nbr, struct ibuf *buf) return (-1); } - if (sendto(econf->eigrp_socket_v6, buf->buf, buf->wpos, 0, + if (sendto(global.eigrp_socket_v6, buf->buf, buf->wpos, 0, (struct sockaddr *)&sa6, sizeof(sa6)) == -1) { log_warn("%s: error sending packet on interface %s", __func__, iface->name); diff --git a/usr.sbin/eigrpd/parse.y b/usr.sbin/eigrpd/parse.y index 2cbf8505739..5fa2ea58ba6 100644 --- a/usr.sbin/eigrpd/parse.y +++ b/usr.sbin/eigrpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.11 2016/04/15 13:18:38 renato Exp $ */ +/* $OpenBSD: parse.y,v 1.12 2016/04/15 13:21:45 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -197,7 +197,7 @@ eigrp_af : IPV4 { $$ = AF_INET; } ; varset : STRING '=' string { - if (cmd_opts & EIGRPD_OPT_VERBOSE) + if (global.cmd_opts & EIGRPD_OPT_VERBOSE) printf("%s = \"%s\"\n", $1, $3); if (symset($1, $3, 0) == -1) fatal("cannot store variable"); @@ -959,7 +959,8 @@ parse_config(char *filename) defs->bandwidth = DEFAULT_BANDWIDTH; defs->splithorizon = 1; - if ((file = pushfile(filename, !(cmd_opts & EIGRPD_OPT_NOACTION))) == NULL) { + if ((file = pushfile(filename, + !(global.cmd_opts & EIGRPD_OPT_NOACTION))) == NULL) { free(conf); return (NULL); } @@ -975,7 +976,7 @@ parse_config(char *filename) /* Free macros and check which have not been used. */ for (sym = TAILQ_FIRST(&symhead); sym != NULL; sym = next) { next = TAILQ_NEXT(sym, entry); - if ((cmd_opts & EIGRPD_OPT_VERBOSE2) && !sym->used) + if ((global.cmd_opts & EIGRPD_OPT_VERBOSE2) && !sym->used) fprintf(stderr, "warning: macro '%s' not " "used\n", sym->nam); if (!sym->persist) { diff --git a/usr.sbin/eigrpd/rde.c b/usr.sbin/eigrpd/rde.c index 3cf98b38db9..622be7914cc 100644 --- a/usr.sbin/eigrpd/rde.c +++ b/usr.sbin/eigrpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.11 2016/02/21 18:56:49 renato Exp $ */ +/* $OpenBSD: rde.c,v 1.12 2016/04/15 13:21:45 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -146,7 +146,7 @@ rde(struct eigrpd_conf *xconf, int pipe_parent2rde[2], int pipe_eigrpe2rde[2], event_add(&iev_main->ev, NULL); gettimeofday(&now, NULL); - rdeconf->uptime = now.tv_sec; + global.uptime = now.tv_sec; TAILQ_FOREACH(eigrp, &rdeconf->instances, entry) rde_instance_init(eigrp); |