summaryrefslogtreecommitdiffstats
path: root/contrib/pf
diff options
context:
space:
mode:
authormlaier <mlaier@FreeBSD.org>2008-03-29 00:24:36 +0000
committermlaier <mlaier@FreeBSD.org>2008-03-29 00:24:36 +0000
commit5cb64aae6314c928aa4d07409d7f9e057a1ade46 (patch)
treeb0363f790c9c62f1567a85647536e62fccc84fb5 /contrib/pf
parent3ae2dd85c9a4f6b76d94bab696618df9eecef039 (diff)
downloadFreeBSD-src-5cb64aae6314c928aa4d07409d7f9e057a1ade46.zip
FreeBSD-src-5cb64aae6314c928aa4d07409d7f9e057a1ade46.tar.gz
Make ALTQ cope with disappearing interfaces (particularly common with mpd
and netgraph in gernal). This also allows to add queues for an interface that is not yet existing (you have to provide the bandwidth for the interface, however). PR: kern/106400, kern/117827 MFC after: 2 weeks
Diffstat (limited to 'contrib/pf')
-rw-r--r--contrib/pf/pfctl/pfctl_altq.c12
-rw-r--r--contrib/pf/pfctl/pfctl_qstats.c26
2 files changed, 38 insertions, 0 deletions
diff --git a/contrib/pf/pfctl/pfctl_altq.c b/contrib/pf/pfctl/pfctl_altq.c
index 3f2efee..b90e7c6 100644
--- a/contrib/pf/pfctl/pfctl_altq.c
+++ b/contrib/pf/pfctl/pfctl_altq.c
@@ -153,6 +153,10 @@ print_altq(const struct pf_altq *a, unsigned level, struct node_queue_bw *bw,
return;
}
+#ifdef __FreeBSD__
+ if (a->local_flags & PFALTQ_FLAG_IF_REMOVED)
+ printf("INACTIVE ");
+#endif
printf("altq on %s ", a->ifname);
switch (a->scheduler) {
@@ -187,6 +191,10 @@ print_queue(const struct pf_altq *a, unsigned level, struct node_queue_bw *bw,
{
unsigned i;
+#ifdef __FreeBSD__
+ if (a->local_flags & PFALTQ_FLAG_IF_REMOVED)
+ printf("INACTIVE ");
+#endif
printf("queue ");
for (i = 0; i < level; ++i)
printf(" ");
@@ -1145,7 +1153,11 @@ getifmtu(char *ifname)
sizeof(ifr.ifr_name))
errx(1, "getifmtu: strlcpy");
if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) == -1)
+#ifdef __FreeBSD__
+ ifr.ifr_mtu = 1500;
+#else
err(1, "SIOCGIFMTU");
+#endif
if (shutdown(s, SHUT_RDWR) == -1)
err(1, "shutdown");
if (close(s))
diff --git a/contrib/pf/pfctl/pfctl_qstats.c b/contrib/pf/pfctl/pfctl_qstats.c
index 28535c2..d4089d6 100644
--- a/contrib/pf/pfctl/pfctl_qstats.c
+++ b/contrib/pf/pfctl/pfctl_qstats.c
@@ -118,6 +118,10 @@ pfctl_show_altq(int dev, const char *iface, int opts, int verbose2)
for (node = root; node != NULL; node = node->next) {
if (iface != NULL && strcmp(node->altq.ifname, iface))
continue;
+#ifdef __FreeBSD__
+ if (node->altq.local_flags & PFALTQ_FLAG_IF_REMOVED)
+ continue;
+#endif
pfctl_print_altq_node(dev, node, 0, opts);
}
}
@@ -157,7 +161,12 @@ pfctl_update_qstats(int dev, struct pf_altq_node **root)
warn("DIOCGETALTQ");
return (-1);
}
+#ifdef __FreeBSD__
+ if (pa.altq.qid > 0 &&
+ !(pa.altq.local_flags & PFALTQ_FLAG_IF_REMOVED)) {
+#else
if (pa.altq.qid > 0) {
+#endif
pq.nr = nr;
pq.ticket = pa.ticket;
pq.buf = &qstats.data;
@@ -175,6 +184,19 @@ pfctl_update_qstats(int dev, struct pf_altq_node **root)
pfctl_insert_altq_node(root, pa.altq, qstats);
}
}
+#ifdef __FreeBSD__
+ else if (pa.altq.local_flags & PFALTQ_FLAG_IF_REMOVED) {
+ memset(&qstats.data, 0, sizeof(qstats.data));
+ if ((node = pfctl_find_altq_node(*root, pa.altq.qname,
+ pa.altq.ifname)) != NULL) {
+ memcpy(&node->qstats.data, &qstats.data,
+ sizeof(qstats.data));
+ update_avg(node);
+ } else {
+ pfctl_insert_altq_node(root, pa.altq, qstats);
+ }
+ }
+#endif
}
return (mnr);
}
@@ -280,6 +302,10 @@ pfctl_print_altq_nodestat(int dev, const struct pf_altq_node *a)
{
if (a->altq.qid == 0)
return;
+#ifdef __FreeBSD__
+ if (a->altq.local_flags & PFALTQ_FLAG_IF_REMOVED)
+ return;
+#endif
switch (a->altq.scheduler) {
case ALTQT_CBQ:
OpenPOWER on IntegriCloud