ports/80667: [MAINTAINER] net/ifstated: integrate upstream changes
Matthew George
mdg at secureworks.net
Thu May 5 17:00:21 UTC 2005
>Number: 80667
>Category: ports
>Synopsis: [MAINTAINER] net/ifstated: integrate upstream changes
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: maintainer-update
>Submitter-Id: current-users
>Arrival-Date: Thu May 05 17:00:16 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Matthew George
>Release: FreeBSD 5.4-STABLE i386
>Organization:
SecureWorks
>Environment:
>Description:
A couple of nits have been corrected, but the most notable change is in
the configuration file grammar. From the OpenBSD CVS logs:
Simplify the ifstated syntax:
"carp0 link up" => carp0.link.up
"and" => &&
"or" => ||
* Allow one line actions after if statements without braces.
* Remove unecessary parentheses in the example config.
>How-To-Repeat:
>Fix:
diff -ur ../ifstated.orig/Makefile ./Makefile
--- ../ifstated.orig/Makefile Thu May 5 12:22:16 2005
+++ ./Makefile Thu May 5 12:24:08 2005
@@ -6,7 +6,7 @@
#
PORTNAME= ifstated
-PORTVERSION= 20041117
+PORTVERSION= 20050505
CATEGORIES= net
MASTER_SITES= ftp://ftp.secureworks.net/pub/ifstated/
diff -ur ../ifstated.orig/distinfo ./distinfo
--- ../ifstated.orig/distinfo Thu May 5 12:22:16 2005
+++ ./distinfo Thu May 5 12:25:11 2005
@@ -1,2 +1,2 @@
-MD5 (ifstated-20041117.tar.gz) = 3255839ec706b5c40b7445677a8e7aa9
-SIZE (ifstated-20041117.tar.gz) = 12270
+MD5 (ifstated-20050505.tar.gz) = 33faa596ababdc1133fbea840827b52a
+SIZE (ifstated-20050505.tar.gz) = 12341
diff -ur ../ifstated.orig/files/patch-Makefile ./files/patch-Makefile
--- ../ifstated.orig/files/patch-Makefile Sat Nov 20 22:08:36 2004
+++ ./files/patch-Makefile Thu May 5 12:11:19 2005
@@ -1,14 +1,14 @@
---- Makefile 18 Nov 2004 21:43:12 -0000 1.1.1.1
-+++ Makefile 18 Nov 2004 23:33:55 -0000 1.4
+--- ../ifstated-20050505.orig/Makefile Thu May 5 11:51:24 2005
++++ Makefile Thu May 5 12:06:07 2005
@@ -1,4 +1,5 @@
- # $OpenBSD: Makefile,v 1.3 2004/02/05 02:26:23 mcbride Exp $
-+# $Id: Makefile,v 1.4 2004/11/18 23:33:55 mdg Exp $
-
+ # $OpenBSD: Makefile,v 1.4 2004/12/14 10:24:15 mpf Exp $
++# $Id: Makefile,v 1.5 2005/05/05 16:06:07 mdg Exp $
+
PROG= ifstated
SRCS= ifstated.c parse.y
-@@ -7,6 +8,14 @@
- CLFAGS+= -Wmissing-declarations -Wredundant-decls
+@@ -8,6 +9,14 @@
CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
+ YFLAGS=
MAN= ifstated.8
-LDADD+=-lutil -levent
+
@@ -20,5 +20,5 @@
+install-man:
+ $(INSTALL) -m 444 -g bin -o bin ifstated.8 $(PREFIX)/man/man8
+
-
+
.include <bsd.prog.mk>
diff -ur ../ifstated.orig/files/patch-etc-ifstated.conf ./files/patch-etc-ifstated.conf
--- ../ifstated.orig/files/patch-etc-ifstated.conf Sat Nov 20 22:08:36 2004
+++ ./files/patch-etc-ifstated.conf Thu May 5 12:12:13 2005
@@ -1,34 +1,34 @@
---- etc/ifstated.conf 18 Nov 2004 21:43:12 -0000 1.1.1.1
-+++ etc/ifstated.conf 18 Nov 2004 21:48:39 -0000 1.2
+--- ../ifstated-20050505.orig/etc/ifstated.conf Thu May 5 11:51:24 2005
++++ etc/ifstated.conf Thu May 5 12:06:08 2005
@@ -1,4 +1,5 @@
- # $OpenBSD: ifstated.conf,v 1.4 2004/04/28 01:01:27 deraadt Exp $
-+# $Id: ifstated.conf,v 1.2 2004/11/18 21:48:39 mdg Exp $
+ # $OpenBSD: ifstated.conf,v 1.6 2005/02/07 06:08:10 david Exp $
++# $Id: ifstated.conf,v 1.3 2005/05/05 16:06:08 mdg Exp $
# This is a sample config for a pair of firewalls with two interfaces
#
# carp0 and carp1 have ip addresses on 192.168.3.0/24 and 192.168.6.0/24
@@ -7,7 +8,7 @@
# net.inet.carp.preempt must be enabled (set to 1) for this to work correctly.
-
+
# Uncomment one of the following lines to force primary/backup status.
-# init-state primary
+init-state primary
# init-state backup
-
- carp_up = "((carp0 link up) and (carp1 link up))"
+
+ carp_up = "carp0.link.up && carp1.link.up"
@@ -18,12 +19,12 @@
# The "net" addresses are other addresses which can be used to determine
# whether we have connectivity. Make sure the hosts are always up, or
# test multiple ip's, 'or'-ing the tests.
--net = '( "ping -q -c 1 -w 1 192.168.6.8 > /dev/null" every 10 and \
+-net = '( "ping -q -c 1 -w 1 192.168.6.8 > /dev/null" every 10 && \
- "ping -q -c 1 -w 1 192.168.3.8 > /dev/null" every 10)'
-+net = '( "ping -q -c 1 -t 1 192.168.6.8 > /dev/null" every 10 and \
++net = '( "ping -q -c 1 -t 1 192.168.6.8 > /dev/null" every 10 && \
+ "ping -q -c 1 -t 1 192.168.3.8 > /dev/null" every 10)'
-
+
# The peer addresses below are the real ip addresses of the OTHER firewall
--peer = '( "ping -q -c 1 -w 1 192.168.6.7 > /dev/null" every 10 and \
+-peer = '( "ping -q -c 1 -w 1 192.168.6.7 > /dev/null" every 10 && \
- "ping -q -c 1 -w 1 192.168.3.7 > /dev/null" every 10)'
-+peer = '( "ping -q -c 1 -t 1 192.168.6.7 > /dev/null" every 10 and \
++peer = '( "ping -q -c 1 -t 1 192.168.6.7 > /dev/null" every 10 && \
+ "ping -q -c 1 -t 1 192.168.3.7 > /dev/null" every 10)'
-
+
state auto {
- if $carp_up {
+ if $carp_up
diff -ur ../ifstated.orig/files/patch-ifstated.8 ./files/patch-ifstated.8
--- ../ifstated.orig/files/patch-ifstated.8 Sat Nov 20 22:08:36 2004
+++ ./files/patch-ifstated.8 Thu May 5 12:13:12 2005
@@ -1,8 +1,8 @@
---- ifstated.8 18 Nov 2004 21:43:12 -0000 1.1.1.1
-+++ ifstated.8 18 Nov 2004 22:14:58 -0000 1.3
+--- ../ifstated-20050505.orig/ifstated.8 Thu May 5 11:51:24 2005
++++ ifstated.8 Thu May 5 12:06:07 2005
@@ -1,4 +1,5 @@
.\" $OpenBSD: ifstated.8,v 1.5 2004/09/27 22:26:26 jaredy Exp $
-+.\" $Id: ifstated.8,v 1.3 2004/11/18 22:14:58 mdg Exp $
++.\" $Id: ifstated.8,v 1.4 2005/05/05 16:06:07 mdg Exp $
.\"
.\" Copyright (c) 2004 Ryan McBride <mcbride at openbsd.org>
.\"
diff -ur ../ifstated.orig/files/patch-ifstated.c ./files/patch-ifstated.c
--- ../ifstated.orig/files/patch-ifstated.c Sat Nov 20 22:08:36 2004
+++ ./files/patch-ifstated.c Thu May 5 12:13:43 2005
@@ -1,14 +1,14 @@
---- ifstated.c 18 Nov 2004 21:43:12 -0000 1.1.1.1
-+++ ifstated.c 18 Nov 2004 21:48:39 -0000 1.2
+--- ../ifstated-20050505.orig/ifstated.c Thu May 5 11:51:24 2005
++++ ifstated.c Thu May 5 12:06:07 2005
@@ -1,4 +1,5 @@
- /* $OpenBSD: ifstated.c,v 1.20 2004/10/05 21:17:02 mpf Exp $ */
-+/* $Id: ifstated.c,v 1.2 2004/11/18 21:48:39 mdg Exp $ */
-
+ /* $OpenBSD: ifstated.c,v 1.21 2005/02/07 12:38:44 mcbride Exp $ */
++/* $Id: ifstated.c,v 1.3 2005/05/05 16:06:07 mdg Exp $ */
+
/*
* Copyright (c) 2004 Marco Pfatschbacher <mpf at openbsd.org>
@@ -23,12 +24,15 @@
*/
-
+
#include <sys/types.h>
+#include <sys/event.h>
#include <sys/time.h>
@@ -16,12 +16,12 @@
#include <sys/socket.h>
#include <sys/wait.h>
+#include <sys/sysctl.h>
-
+
#include <net/if.h>
+#include <net/if_mib.h>
#include <net/route.h>
#include <netinet/in.h>
-
+
@@ -38,8 +42,6 @@
#include <fcntl.h>
#include <signal.h>
@@ -40,7 +40,7 @@
+char *configfile = "%%PREFIX%%/etc/ifstated.conf";
+int kq;
+struct kevent kev;
-
+
-void startup_handler(int, short, void *);
-void sighup_handler(int, short, void *);
+void startup_handler(void);
@@ -53,33 +53,33 @@
void external_async_exec(struct ifsd_external *);
void check_external_status(struct ifsd_state *);
void external_evtimer_setup(struct ifsd_state *, int);
-@@ -76,6 +78,8 @@
+@@ -75,6 +77,8 @@
void remove_expression(struct ifsd_expression *, struct ifsd_state *);
void log_init(int);
- void logit(int level, const char *fmt, ...);
+ void logit(int, const char *, ...);
+int get_ifcount(void);
+int get_ifmib_general(int, struct ifmibdata *);
-
+
void
usage(void)
-@@ -90,7 +94,7 @@
+@@ -89,7 +93,7 @@
int
main(int argc, char *argv[])
{
- struct timeval tv;
+ struct timespec ts;
int ch;
-
+
while ((ch = getopt(argc, argv, "dD:f:hniv")) != -1) {
-@@ -137,26 +141,54 @@
+@@ -136,26 +140,54 @@
setproctitle(NULL);
}
-
+
- event_init();
+ kq = kqueue();
+
log_init(opt_debug);
-
+
- signal_set(&sigchld_ev, SIGCHLD, sigchld_handler, &sigchld_ev);
- signal_add(&sigchld_ev, NULL);
+ ts.tv_sec = 0;
@@ -87,13 +87,13 @@
+
+ EV_SET(&kev, SIGCHLD, EVFILT_SIGNAL, EV_ADD, 0, 0, (void *)sigchld_handler);
+ kevent(kq, &kev, 1, NULL, 0, &ts);
-
+
/* Loading the config needs to happen in the event loop */
- tv.tv_usec = 0;
- tv.tv_sec = 0;
- evtimer_set(&startup_ev, startup_handler, &startup_ev);
- evtimer_add(&startup_ev, &tv);
-
+
- event_loop(0);
+ EV_SET(&kev, IFSD_EVTIMER_STARTUP, EVFILT_TIMER, EV_ADD|EV_ONESHOT, 0, 0, (void *)startup_handler);
+ kevent(kq, &kev, 1, NULL, 0, &ts);
@@ -125,26 +125,26 @@
+ /* NOTREACHED */
exit(0);
}
-
+
void
-startup_handler(int fd, short event, void *arg)
+startup_handler()
{
int rt_fd;
+ struct timespec ts;
-
+
if (load_config() != 0) {
logit(IFSD_LOG_NORMAL, "unable to load config");
-@@ -166,18 +198,20 @@
+@@ -165,18 +197,20 @@
if ((rt_fd = socket(PF_ROUTE, SOCK_RAW, 0)) < 0)
err(1, "no routing socket");
-
+
- event_set(&rt_msg_ev, rt_fd, EV_READ|EV_PERSIST,
- rt_msg_handler, &rt_msg_ev);
- event_add(&rt_msg_ev, NULL);
+ ts.tv_sec = 0;
+ ts.tv_nsec = 0;
-
+
- signal_set(&sighup_ev, SIGHUP, sighup_handler, &sighup_ev);
- signal_add(&sighup_ev, NULL);
+ EV_SET(&kev, rt_fd, EVFILT_READ, EV_ADD, 0, 0, (void *)rt_msg_handler);
@@ -152,28 +152,28 @@
+
+ EV_SET(&kev, SIGHUP, EVFILT_SIGNAL, EV_ADD, 0, 0, (void *)sighup_handler);
+ kevent(kq, &kev, 1, NULL, 0, &ts);
-
+
logit(IFSD_LOG_NORMAL, "started");
}
-
+
void
-sighup_handler(int fd, short event, void *arg)
+sighup_handler()
{
logit(IFSD_LOG_NORMAL, "reloading config");
if (load_config() != 0)
-@@ -208,7 +242,7 @@
+@@ -207,7 +241,7 @@
}
-
+
void
-rt_msg_handler(int fd, short event, void *arg)
+rt_msg_handler(int fd)
{
char msg[2048];
struct rt_msghdr *rtm = (struct rt_msghdr *)&msg;
-@@ -246,22 +280,6 @@
+@@ -245,22 +279,6 @@
}
-
+
void
-external_handler(int fd, short event, void *arg)
-{
@@ -194,7 +194,7 @@
external_async_exec(struct ifsd_external *external)
{
char *argp[] = {"sh", "-c", NULL, NULL};
-@@ -355,23 +373,25 @@
+@@ -354,23 +372,25 @@
external_evtimer_setup(struct ifsd_state *state, int action)
{
struct ifsd_external *external;
@@ -203,18 +203,17 @@
+
+ ts.tv_nsec = 0;
+ ts.tv_sec = 0;
-
+
if (state != NULL) {
switch (action) {
case IFSD_EVTIMER_ADD:
TAILQ_FOREACH(external,
&state->external_tests, entries) {
- struct timeval tv;
--
-+
+
/* run it once right away */
external_async_exec(external);
-
+
/* schedule it for later */
- tv.tv_usec = 0;
- tv.tv_sec = external->frequency;
@@ -227,7 +226,7 @@
}
break;
case IFSD_EVTIMER_DEL:
-@@ -381,7 +401,9 @@
+@@ -380,7 +400,9 @@
kill(external->pid, SIGKILL);
external->pid = 0;
}
@@ -238,7 +237,7 @@
}
break;
}
-@@ -505,7 +527,6 @@
+@@ -504,7 +526,6 @@
logit(IFSD_LOG_NORMAL, "changing state to %s",
conf->nextstate->name);
if (conf->curstate != NULL) {
@@ -246,10 +245,10 @@
external_evtimer_setup(conf->curstate,
IFSD_EVTIMER_DEL);
}
-@@ -551,6 +572,48 @@
+@@ -550,6 +571,48 @@
}
}
-
+
+
+int
+get_ifcount(void)
@@ -295,41 +294,40 @@
/*
* Fetch the current link states.
*/
-@@ -560,29 +623,34 @@
+@@ -559,29 +622,34 @@
struct ifaddrs *ifap, *ifa;
char *oname = NULL;
int sock = socket(AF_INET, SOCK_DGRAM, 0);
+ int ifcount = get_ifcount();
+ int i;
-
+
- if (getifaddrs(&ifap) != 0)
+ if (getifaddrs(&ifap) != 0 || ifcount == -1)
err(1, "getifaddrs");
-
+
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
- struct ifreq ifr;
- struct if_data ifrdat;
+ struct ifmibdata ifmd;
+ struct if_data ifdata;
-
+
if (oname && !strcmp(oname, ifa->ifa_name))
continue;
oname = ifa->ifa_name;
-
+
- strlcpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name));
- ifr.ifr_data = (caddr_t)&ifrdat;
--
-- if (ioctl(sock, SIOCGIFDATA, (caddr_t)&ifr) == -1)
-- continue;
+ for (i = 1; i <= ifcount; i++)
+ {
+ get_ifmib_general(i, &ifmd);
+ if (! strcmp(ifmd.ifmd_name, oname))
+ break;
+ }
-+
+
+- if (ioctl(sock, SIOCGIFDATA, (caddr_t)&ifr) == -1)
+- continue;
+ ifdata = ifmd.ifmd_data;
-
+
scan_ifstate(if_nametoindex(ifa->ifa_name),
- ifrdat.ifi_link_state, &conf->always);
+ ifdata.ifi_link_state, &conf->always);
@@ -340,7 +338,7 @@
}
freeifaddrs(ifap);
close(sock);
-@@ -664,7 +732,6 @@
+@@ -663,7 +731,6 @@
TAILQ_REMOVE(&state->external_tests,
expression->u.external, entries);
free(expression->u.external->command);
diff -ur ../ifstated.orig/files/patch-ifstated.h ./files/patch-ifstated.h
--- ../ifstated.orig/files/patch-ifstated.h Sat Nov 20 22:08:36 2004
+++ ./files/patch-ifstated.h Thu May 5 12:14:15 2005
@@ -1,13 +1,13 @@
---- ifstated.h 18 Nov 2004 21:43:12 -0000 1.1.1.1
-+++ ifstated.h 18 Nov 2004 21:48:39 -0000 1.2
+--- ../ifstated-20050505.orig/ifstated.h Thu May 5 11:51:24 2005
++++ ifstated.h Thu Nov 18 16:48:39 2004
@@ -1,4 +1,5 @@
/* $OpenBSD: ifstated.h,v 1.4 2004/03/10 00:13:38 deraadt Exp $ */
+/* $Id: ifstated.h,v 1.2 2004/11/18 21:48:39 mdg Exp $ */
-
+
/*
* Copyright (c) 2004 Ryan McBride
@@ -47,7 +48,7 @@
-
+
struct ifsd_external {
TAILQ_ENTRY(ifsd_external) entries;
- struct event ev;
@@ -17,7 +17,7 @@
int prevstatus;
@@ -107,7 +108,7 @@
TAILQ_HEAD(ifsd_external_list, ifsd_external);
-
+
struct ifsd_state {
- struct event ev;
+ struct kevent kev;
@@ -26,7 +26,7 @@
TAILQ_ENTRY(ifsd_state) entries;
@@ -138,6 +139,7 @@
};
-
+
enum { IFSD_EVTIMER_ADD, IFSD_EVTIMER_DEL };
+enum { IFSD_EVTIMER_STARTUP, IFSD_EVTIMER_EXTERNAL };
struct ifsd_config *parse_config(char *, int);
diff -ur ../ifstated.orig/files/patch-parse.y ./files/patch-parse.y
--- ../ifstated.orig/files/patch-parse.y Sat Nov 20 22:08:36 2004
+++ ./files/patch-parse.y Thu May 5 12:14:40 2005
@@ -1,9 +1,9 @@
---- parse.y 18 Nov 2004 21:43:12 -0000 1.1.1.1
-+++ parse.y 18 Nov 2004 21:48:39 -0000 1.2
+--- ../ifstated-20050505.orig/parse.y Thu May 5 11:51:24 2005
++++ parse.y Thu May 5 12:06:07 2005
@@ -1,4 +1,5 @@
- /* $OpenBSD: parse.y,v 1.7 2004/04/28 01:00:50 deraadt Exp $ */
-+/* $Id: parse.y,v 1.2 2004/11/18 21:48:39 mdg Exp $ */
-
+ /* $OpenBSD: parse.y,v 1.9 2005/02/07 12:41:53 mcbride Exp $ */
++/* $Id: parse.y,v 1.3 2005/05/05 16:06:07 mdg Exp $ */
+
/*
* Copyright (c) 2004 Ryan McBride <mcbride at openbsd.org>
@@ -24,6 +25,7 @@
@@ -20,6 +20,6 @@
#include <syslog.h>
-#include <event.h>
+#include <sys/event.h>
-
+
#include "ifstated.h"
-
+
>Release-Note:
>Audit-Trail:
>Unformatted:
SEND-PR: -*- send-pr -*-
SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as
SEND-PR: will all comments (text enclosed in `<' and `>').
SEND-PR:
SEND-PR: Please consult the following URL if you are not sure how to
SEND-PR: fill out a problem report:
SEND-PR: http://www.freebsd.org/doc/en/articles/problem-reports/
SEND-PR:
SEND-PR: Note that the Synopsis field is mandatory.
SEND-PR:
SEND-PR: Please note that (unless you state otherwise) if your report
SEND-PR: includes a patch then it will be taken under the same license as
SEND-PR: the one on the file(s) you want to change.
SEND-PR:
SEND-PR: BE ADVISED THAT FREEBSD PROBLEM REPORTS ARE PUBLIC INFORMATION AND
SEND-PR: WILL BE PUBLISHED AS-IS ON THE PROJECT'S MAILING LISTS AND WEB SITES.
SEND-PR: DO NOT SUBMIT ANY INFORMATION YOU DO NOT WANT MADE PUBLIC.
SEND-PR:
SEND-PR: If you wish to submit a problem report confidentially, then contact
SEND-PR: the FreeBSD bugmaster (bugmaster at FreeBSD.org) to arrange for a
SEND-PR: relevant developer to be contacted.
SEND-PR:
SEND-PR: For sensitive security issues, consider contacting the FreeBSD
SEND-PR: security officer team (security-officer at freebsd.org) directly.
SEND-PR:
SEND-PR: Choose from the following categories:
SEND-PR:
SEND-PR: advocacy alpha amd64 bin conf docs
SEND-PR: gnu i386 ia64 java kern misc
SEND-PR: ports powerpc sparc64 standards threads www
SEND-PR:
SEND-PR:
More information about the freebsd-ports-bugs
mailing list