aboutsummaryrefslogtreecommitdiffstats
path: root/net/ifstated
diff options
context:
space:
mode:
authorstefan <stefan@FreeBSD.org>2007-04-14 22:03:19 +0800
committerstefan <stefan@FreeBSD.org>2007-04-14 22:03:19 +0800
commit4f486efcb89a8eee0cb010e0bf685966410fce0d (patch)
tree75b0fa41628baf8e2333169e8f5ecaa575988990 /net/ifstated
parent9749a3f3b61f51fdd0a44377d15ef3cffb337903 (diff)
downloadfreebsd-ports-gnome-4f486efcb89a8eee0cb010e0bf685966410fce0d.tar.gz
freebsd-ports-gnome-4f486efcb89a8eee0cb010e0bf685966410fce0d.tar.zst
freebsd-ports-gnome-4f486efcb89a8eee0cb010e0bf685966410fce0d.zip
- Update to 3.7. [1]
- Integrate patch that fixes behaviour with multiple check criteria. [2] PR: 111129 [1], [2] Submitted by: maintainer [1] Artemiev Igor <ai@bmc.brk.ru> [2] Approved by: maintainer
Diffstat (limited to 'net/ifstated')
-rw-r--r--net/ifstated/Makefile7
-rw-r--r--net/ifstated/distinfo6
-rw-r--r--net/ifstated/files/patch-ifstated.c112
-rw-r--r--net/ifstated/pkg-descr6
4 files changed, 73 insertions, 58 deletions
diff --git a/net/ifstated/Makefile b/net/ifstated/Makefile
index 99a15cd9100b..08899c6edbd8 100644
--- a/net/ifstated/Makefile
+++ b/net/ifstated/Makefile
@@ -6,9 +6,12 @@
#
PORTNAME= ifstated
-PORTVERSION= 20050505
+PORTVERSION= 3.7
+PORTEPOCH= 1
CATEGORIES= net
-MASTER_SITES= http://skreuzer.f2o.org/mirror/ifstated/
+MASTER_SITES= http://skreuzer.f2o.org/mirror/ifstated/ \
+ http://www.atarininja.org/~wxs/distfiles/ \
+ http://www.pkix.net/mirror/f2o.org/ifstated/
MAINTAINER= skreuzer@f2o.org
COMMENT= Interface State daemon
diff --git a/net/ifstated/distinfo b/net/ifstated/distinfo
index 12da84fe90f5..7be17bc9edfc 100644
--- a/net/ifstated/distinfo
+++ b/net/ifstated/distinfo
@@ -1,3 +1,3 @@
-MD5 (ifstated-20050505.tar.gz) = 33faa596ababdc1133fbea840827b52a
-SHA256 (ifstated-20050505.tar.gz) = 3c34b5e59154b6a9dc521ee31f753c4f0c5631973e0633dbbe6ebdf101dda41e
-SIZE (ifstated-20050505.tar.gz) = 12341
+MD5 (ifstated-3.7.tar.gz) = 3c399ea13e546c9bbf2ba5e844b5728b
+SHA256 (ifstated-3.7.tar.gz) = e4bdd5d53c13daa4fa8936165c5522fe22c4a63a3c59c2c965ccc423aa91deaf
+SIZE (ifstated-3.7.tar.gz) = 12374
diff --git a/net/ifstated/files/patch-ifstated.c b/net/ifstated/files/patch-ifstated.c
index 981ff64c2ffe..f702334dfce0 100644
--- a/net/ifstated/files/patch-ifstated.c
+++ b/net/ifstated/files/patch-ifstated.c
@@ -1,14 +1,14 @@
---- ../ifstated-20050505.orig/ifstated.c Thu May 5 11:51:24 2005
-+++ ifstated.c Thu May 5 12:06:07 2005
+--- ifstated.c-orig Fri Apr 6 09:04:30 2007
++++ ifstated.c Fri Apr 6 09:05:30 2007
@@ -1,4 +1,5 @@
/* $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@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>
@@ -31,7 +31,14 @@
#include <unistd.h>
#include <syslog.h>
#include <stdarg.h>
-@@ -52,15 +54,15 @@
+@@ -47,20 +49,22 @@
+
+ #include "ifstated.h"
+
++#define MAX_TIMERS 100
++
+ struct ifsd_config *conf = NULL, *newconf = NULL;
+
int opts = 0;
int opt_debug = 0;
int opt_inhibit = 0;
@@ -40,7 +47,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 +60,33 @@
void external_async_exec(struct ifsd_external *);
void check_external_status(struct ifsd_state *);
void external_evtimer_setup(struct ifsd_state *, int);
-@@ -75,6 +77,8 @@
+@@ -75,6 +79,8 @@
void remove_expression(struct ifsd_expression *, struct ifsd_state *);
void log_init(int);
void logit(int, const char *, ...);
+int get_ifcount(void);
+int get_ifmib_general(int, struct ifmibdata *);
-
+
void
usage(void)
-@@ -89,7 +93,7 @@
+@@ -89,7 +95,7 @@
int
main(int argc, char *argv[])
{
- struct timeval tv;
+ struct timespec ts;
int ch;
-
+
while ((ch = getopt(argc, argv, "dD:f:hniv")) != -1) {
-@@ -136,26 +140,54 @@
+@@ -136,26 +142,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 +94,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);
@@ -111,7 +118,7 @@
+ rt_handler = kev.udata;
+ rt_handler(kev.ident);
+ }
-+ else if ((kev.filter == EVFILT_TIMER) && (kev.ident == IFSD_EVTIMER_EXTERNAL))
++ else if ((kev.filter == EVFILT_TIMER) && ((kev.ident - IFSD_EVTIMER_EXTERNAL) < MAX_TIMERS))
+ {
+ external_async_exec((struct ifsd_external *)kev.udata);
+ }
@@ -125,55 +132,55 @@
+ /* 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");
-@@ -165,18 +197,20 @@
+@@ -165,18 +199,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);
+ kevent(kq, &kev, 1, NULL, 0, &ts);
-+
+
+- signal_set(&sighup_ev, SIGHUP, sighup_handler, &sighup_ev);
+- signal_add(&sighup_ev, NULL);
+ 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)
-@@ -207,7 +241,7 @@
+@@ -207,7 +243,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;
-@@ -245,22 +279,6 @@
+@@ -245,22 +281,6 @@
}
-
+
void
-external_handler(int fd, short event, void *arg)
-{
@@ -194,26 +201,27 @@
external_async_exec(struct ifsd_external *external)
{
char *argp[] = {"sh", "-c", NULL, NULL};
-@@ -354,23 +372,25 @@
+@@ -354,23 +374,28 @@
external_evtimer_setup(struct ifsd_state *state, int action)
{
struct ifsd_external *external;
+ struct timespec ts;
+ int freq;
++ int imod = 0;
+
+ 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;
@@ -221,23 +229,27 @@
- external);
- evtimer_add(&external->ev, &tv);
+ freq = (external->frequency * 1000);
-+ EV_SET(&kev, IFSD_EVTIMER_EXTERNAL, EVFILT_TIMER, EV_ADD, 0, freq, (void *)external);
++ EV_SET(&kev, IFSD_EVTIMER_EXTERNAL + imod, EVFILT_TIMER, EV_ADD, 0, freq, (void *)external);
+ kevent(kq, &kev, 1, NULL, 0, &ts);
++ imod ++;
++ if(imod >= MAX_TIMERS) imod = 0;
}
break;
case IFSD_EVTIMER_DEL:
-@@ -380,7 +400,9 @@
+@@ -380,7 +405,11 @@
kill(external->pid, SIGKILL);
external->pid = 0;
}
- evtimer_del(&external->ev);
+ freq = (external->frequency * 1000);
-+ EV_SET(&kev, IFSD_EVTIMER_EXTERNAL, EVFILT_TIMER, EV_DELETE, 0, freq, (void *)external);
++ EV_SET(&kev, IFSD_EVTIMER_EXTERNAL + imod, EVFILT_TIMER, EV_DELETE, 0, freq, (void *)external);
++ imod ++;
++ if(imod < MAX_TIMERS)
+ kevent(kq, &kev, 1, NULL, 0, &ts);
}
break;
}
-@@ -504,7 +526,6 @@
+@@ -504,7 +533,6 @@
logit(IFSD_LOG_NORMAL, "changing state to %s",
conf->nextstate->name);
if (conf->curstate != NULL) {
@@ -245,10 +257,10 @@
external_evtimer_setup(conf->curstate,
IFSD_EVTIMER_DEL);
}
-@@ -550,6 +571,48 @@
+@@ -550,6 +578,48 @@
}
}
-
+
+
+int
+get_ifcount(void)
@@ -294,27 +306,27 @@
/*
* Fetch the current link states.
*/
-@@ -559,29 +622,34 @@
+@@ -559,29 +629,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;
+ for (i = 1; i <= ifcount; i++)
@@ -323,11 +335,11 @@
+ 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);
@@ -338,7 +350,7 @@
}
freeifaddrs(ifap);
close(sock);
-@@ -663,7 +731,6 @@
+@@ -663,7 +738,6 @@
TAILQ_REMOVE(&state->external_tests,
expression->u.external, entries);
free(expression->u.external->command);
diff --git a/net/ifstated/pkg-descr b/net/ifstated/pkg-descr
index c4abf5732402..5fc9afda3958 100644
--- a/net/ifstated/pkg-descr
+++ b/net/ifstated/pkg-descr
@@ -1,5 +1,7 @@
-This is a port of ifstated(8) from OpenBSD. From the manpage:
+This is a port of ifstated(8) from OpenBSD by Matthew George.
+
+From the manpage:
***
The ifstated daemon runs commands in response to network state changes,
@@ -11,5 +13,3 @@ rules.
***
It has been modified to use FreeBSD's kqueue/kevent mechanism and sysctl.
-
-Matthew George <mdg@secureworks.net>