summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorKenjiro Cho <kjc@cvs.openbsd.org>2001-08-16 12:59:44 +0000
committerKenjiro Cho <kjc@cvs.openbsd.org>2001-08-16 12:59:44 +0000
commitb5c8e7c1615165eaa2f24583a32abe1059bea123 (patch)
treecd2bd3c3763dd3e03ab4e2c08f93d6fc11feac9a /usr.sbin
parentd64a7d79fc33fe1332cb6af09067b0140772da17 (diff)
sync with KAME.
altq userland cleanup: - string operation audit - remove variable names from function prototypes - clean up error messages
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/altq/altqd/altqd.c26
-rw-r--r--usr.sbin/altq/altqd/libaltq2.c42
-rw-r--r--usr.sbin/altq/altqstat/altqstat.c20
-rw-r--r--usr.sbin/altq/altqstat/altqstat.h22
-rw-r--r--usr.sbin/altq/altqstat/qdisc_blue.c7
-rw-r--r--usr.sbin/altq/altqstat/qdisc_cbq.c9
-rw-r--r--usr.sbin/altq/altqstat/qdisc_cdnr.c11
-rw-r--r--usr.sbin/altq/altqstat/qdisc_conf.c8
-rw-r--r--usr.sbin/altq/altqstat/qdisc_fifoq.c5
-rw-r--r--usr.sbin/altq/altqstat/qdisc_hfsc.c9
-rw-r--r--usr.sbin/altq/altqstat/qdisc_priq.c9
-rw-r--r--usr.sbin/altq/altqstat/qdisc_red.c7
-rw-r--r--usr.sbin/altq/altqstat/qdisc_rio.c7
-rw-r--r--usr.sbin/altq/altqstat/qdisc_wfq.c5
-rw-r--r--usr.sbin/altq/altqstat/quip_client.c51
-rw-r--r--usr.sbin/altq/altqstat/quip_client.h23
-rw-r--r--usr.sbin/altq/libaltq/parser.c204
-rw-r--r--usr.sbin/altq/libaltq/qop.c106
-rw-r--r--usr.sbin/altq/libaltq/qop_blue.c20
-rw-r--r--usr.sbin/altq/libaltq/qop_cbq.c88
-rw-r--r--usr.sbin/altq/libaltq/qop_cdnr.c50
-rw-r--r--usr.sbin/altq/libaltq/qop_dummy.c37
-rw-r--r--usr.sbin/altq/libaltq/qop_fifoq.c20
-rw-r--r--usr.sbin/altq/libaltq/qop_hfsc.c88
-rw-r--r--usr.sbin/altq/libaltq/qop_priq.c40
-rw-r--r--usr.sbin/altq/libaltq/qop_red.c20
-rw-r--r--usr.sbin/altq/libaltq/qop_rio.c20
-rw-r--r--usr.sbin/altq/libaltq/qop_wfq.c24
-rw-r--r--usr.sbin/altq/libaltq/quip_server.c182
-rw-r--r--usr.sbin/altq/libaltq/quip_server.h9
30 files changed, 600 insertions, 569 deletions
diff --git a/usr.sbin/altq/altqd/altqd.c b/usr.sbin/altq/altqd/altqd.c
index 0e093528b55..300bd8f0a3a 100644
--- a/usr.sbin/altq/altqd/altqd.c
+++ b/usr.sbin/altq/altqd/altqd.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: altqd.c,v 1.2 2001/08/08 07:07:27 deraadt Exp $ */
-/* $KAME: altqd.c,v 1.2 2000/10/18 09:15:15 kjc Exp $ */
+/* $OpenBSD: altqd.c,v 1.3 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: altqd.c,v 1.5 2001/08/16 10:39:16 kjc Exp $ */
/*
* Copyright (c) 2001 Theo de Raadt
* All rights reserved.
@@ -86,6 +86,12 @@ fd_set fds, t_fds;
#define DEFAULT_DEBUG_MASK 0
#define DEFAULT_LOGGING_LEVEL LOG_INFO
+void usage(void);
+void sig_pipe(int);
+void sig_hup(int);
+void sig_int(int);
+void sig_term(int);
+
void
usage(void)
{
@@ -105,19 +111,19 @@ sig_pipe(int sig)
int gotsig_hup, gotsig_int, gotsig_term;
void
-sig_hup()
+sig_hup(int sig)
{
gotsig_hup = 1;
}
void
-sig_int()
+sig_int(int sig)
{
gotsig_int = 1;
}
void
-sig_term()
+sig_term(int sig)
{
gotsig_term = 1;
}
@@ -175,7 +181,7 @@ main(int argc, char **argv)
* open a unix domain socket for altqd clients
*/
if ((altqd_socket = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0)
- LOG(LOG_ERR, errno, "can't open unix domain socket\n");
+ LOG(LOG_ERR, errno, "can't open unix domain socket");
else {
struct sockaddr_un addr;
@@ -185,13 +191,13 @@ main(int argc, char **argv)
unlink(QUIP_PATH);
if (bind(altqd_socket, (struct sockaddr *)&addr,
sizeof(addr)) < 0) {
- LOG(LOG_ERR, errno, "can't bind to %s\n", QUIP_PATH);
+ LOG(LOG_ERR, errno, "can't bind to %s", QUIP_PATH);
close(altqd_socket);
altqd_socket = -1;
}
chmod(QUIP_PATH, 0666);
if (listen(altqd_socket, SOMAXCONN) < 0) {
- LOG(LOG_ERR, errno, "can't listen to %s\n", QUIP_PATH);
+ LOG(LOG_ERR, errno, "can't listen to %s", QUIP_PATH);
close(altqd_socket);
altqd_socket = -1;
}
@@ -298,7 +304,7 @@ main(int argc, char **argv)
printf("\nEnter ? or command:\n");
FD_SET(fileno(infp), &fds);
} else {
- LOG(LOG_INFO, 0, "Exiting.\n");
+ LOG(LOG_INFO, 0, "Exiting.");
(void) qcmd_destroyall();
exit(0);
}
@@ -314,7 +320,7 @@ main(int argc, char **argv)
int newsock = accept(altqd_socket, NULL, NULL);
if (newsock == -1) {
- LOG(LOG_ERR, errno, "accept error\n");
+ LOG(LOG_ERR, errno, "accept");
continue;
}
FD_SET(newsock, &fds);
diff --git a/usr.sbin/altq/altqd/libaltq2.c b/usr.sbin/altq/altqd/libaltq2.c
index 7c08d00de98..f4515042488 100644
--- a/usr.sbin/altq/altqd/libaltq2.c
+++ b/usr.sbin/altq/altqd/libaltq2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: libaltq2.c,v 1.2 2001/08/08 07:04:50 deraadt Exp $ */
+/* $KAME: libaltq2.c,v 1.3 2001/08/16 10:39:16 kjc Exp $ */
/*
* Copyright (C) 1997-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -68,29 +68,27 @@ log_write(int severity, int syserr, const char *format, ...)
#endif
if (severity <= l_debug) {
- if (!daemonize)
+ if (!daemonize) {
vfprintf(stderr, format, ap);
- else
- vsyslog(severity, format, ap);
- }
-
- va_end(ap);
+ if (syserr != 0) {
+ if (syserr < sys_nerr)
+ fprintf(stderr, ": %s", sys_errlist[syserr]);
+ else
+ fprintf(stderr, ": errno %d", syserr);
+ }
+ fprintf(stderr, "\n");
+ } else {
+ if (syserr == 0)
+ vsyslog(severity, format, ap);
+ else {
+ char buf[512];
- if (syserr == 0) {
- /* Do nothing for now */
- } else if (syserr < sys_nerr) {
- if (severity <= l_debug) {
- if (!daemonize)
- fprintf(stderr, ": %s\n", sys_errlist[syserr]);
- else
- syslog(severity, ": %s", sys_errlist[syserr]);
- }
- } else {
- if (severity <= l_debug) {
- if (!daemonize)
- fprintf(stderr, ": errno %d\n", syserr);
- else
- syslog(severity, ": errno %d", syserr);
+ strlcpy(buf, format, sizeof(buf));
+ strlcat(buf, ": %m", sizeof(buf));
+ vsyslog(severity, buf, ap);
+ }
}
}
+
+ va_end(ap);
}
diff --git a/usr.sbin/altq/altqstat/altqstat.c b/usr.sbin/altq/altqstat/altqstat.c
index 5c66b740d79..ec4baeaa965 100644
--- a/usr.sbin/altq/altqstat/altqstat.c
+++ b/usr.sbin/altq/altqstat/altqstat.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: altqstat.c,v 1.1 2001/06/27 18:23:19 kjc Exp $ */
-/* $KAME: altqstat.c,v 1.4 2000/12/03 05:44:19 kawa Exp $ */
+/* $OpenBSD: altqstat.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: altqstat.c,v 1.6 2001/08/16 07:43:14 itojun Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -55,7 +55,7 @@ char *qdisc_name = NULL;
stat_loop_t *stat_loop;
-static void sig_handler(int sig);
+static void sig_handler(int);
static void usage(void);
static void
@@ -90,7 +90,7 @@ main (int argc, char **argv)
while ((ch = getopt(argc, argv, "I:c:ei:nrsw:")) != -1) {
switch (ch) {
case 'I':
- sprintf(input, "_%s", optarg);
+ snprintf(input, sizeof(input), "_%s", optarg);
interface = input;
break;
case 'c':
@@ -161,7 +161,7 @@ main (int argc, char **argv)
printf("%s: %s on interface %s\n",
argv[0], qdisc_name, interface);
- sprintf(device, "%s/%s", DEV_PATH, qdisc_name);
+ snprintf(device, sizeof(device), "%s/%s", DEV_PATH, qdisc_name);
if ((qdiscfd = open(device, O_RDONLY)) < 0)
err(1, "can't open %s", device);
@@ -204,12 +204,12 @@ calc_pps(u_int64_t new_pkts, u_int64_t last_pkts, double interval)
}
#define R2S_BUFS 8
-
+#define RATESTR_MAX 16
char *
rate2str(double rate)
{
char *buf;
- static char r2sbuf[R2S_BUFS][16]; /* ring bufer for up to R2S_BUFS */
+ static char r2sbuf[R2S_BUFS][RATESTR_MAX]; /* ring bufer */
static int idx = 0;
buf = r2sbuf[idx++];
@@ -217,10 +217,10 @@ rate2str(double rate)
idx = 0;
if (rate == 0.0)
- sprintf(buf, "0");
+ snprintf(buf, RATESTR_MAX, "0");
else if (rate >= 1000000.0)
- sprintf(buf, "%.2fM", rate / 1000000.0);
+ snprintf(buf, RATESTR_MAX, "%.2fM", rate / 1000000.0);
else
- sprintf(buf, "%.2fK", rate / 1000.0);
+ snprintf(buf, RATESTR_MAX, "%.2fK", rate / 1000.0);
return (buf);
}
diff --git a/usr.sbin/altq/altqstat/altqstat.h b/usr.sbin/altq/altqstat/altqstat.h
index 077d15ddac3..c33ea599560 100644
--- a/usr.sbin/altq/altqstat/altqstat.h
+++ b/usr.sbin/altq/altqstat/altqstat.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: altqstat.h,v 1.1 2001/06/27 18:23:19 kjc Exp $ */
-/* $KAME: altqstat.h,v 1.2 2000/10/18 09:15:16 kjc Exp $ */
+/* $OpenBSD: altqstat.h,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: altqstat.h,v 1.4 2001/08/16 07:43:14 itojun Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -53,15 +53,15 @@ stat_loop_t priq_stat_loop;
struct redstats;
-void chandle2name(const char *ifname, u_long handle, char *name);
-stat_loop_t *qdisc2stat_loop(const char *qdisc_name);
-int ifname2qdisc(const char *ifname, char *qname);
-double calc_interval(struct timeval *cur_time, struct timeval *last_time);
-double calc_rate(u_int64_t new_bytes, u_int64_t last_bytes, double interval);
-double calc_pps(u_int64_t new_pkts, u_int64_t last_pkts, double interval);
-char *rate2str(double rate);
-int print_redstats(struct redstats *rp);
-int print_riostats(struct redstats *rp);
+void chandle2name(const char *, u_long, char *, size_t);
+stat_loop_t *qdisc2stat_loop(const char *);
+int ifname2qdisc(const char *, char *);
+double calc_interval(struct timeval *, struct timeval *);
+double calc_rate(u_int64_t, u_int64_t, double);
+double calc_pps(u_int64_t, u_int64_t, double);
+char *rate2str(double);
+int print_redstats(struct redstats *);
+int print_riostats(struct redstats *);
diff --git a/usr.sbin/altq/altqstat/qdisc_blue.c b/usr.sbin/altq/altqstat/qdisc_blue.c
index f540f8b2ddf..611ae52f8a9 100644
--- a/usr.sbin/altq/altqstat/qdisc_blue.c
+++ b/usr.sbin/altq/altqstat/qdisc_blue.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qdisc_blue.c,v 1.1 2001/06/27 18:23:19 kjc Exp $ */
-/* $KAME: qdisc_blue.c,v 1.2 2000/10/18 09:15:16 kjc Exp $ */
+/* $OpenBSD: qdisc_blue.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qdisc_blue.c,v 1.3 2001/08/15 12:51:58 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -54,7 +54,8 @@ blue_stat_loop(int fd, const char *ifname, int count, int interval)
double sec;
int cnt = count;
- strcpy(blue_stats.iface.blue_ifname, ifname);
+ strlcpy(blue_stats.iface.blue_ifname, ifname,
+ sizeof(blue_stats.iface.blue_ifname));
gettimeofday(&last_time, NULL);
last_time.tv_sec -= interval;
diff --git a/usr.sbin/altq/altqstat/qdisc_cbq.c b/usr.sbin/altq/altqstat/qdisc_cbq.c
index 7bf6b72d90a..4360cc169fe 100644
--- a/usr.sbin/altq/altqstat/qdisc_cbq.c
+++ b/usr.sbin/altq/altqstat/qdisc_cbq.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qdisc_cbq.c,v 1.1 2001/06/27 18:23:20 kjc Exp $ */
-/* $KAME: qdisc_cbq.c,v 1.3 2000/12/29 06:39:27 kjc Exp $ */
+/* $OpenBSD: qdisc_cbq.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qdisc_cbq.c,v 1.4 2001/08/15 12:51:58 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -68,7 +68,8 @@ cbq_stat_loop(int fd, const char *ifname, int count, int interval)
double flow_bps, sec;
int cnt = count;
- strcpy(get_stats.iface.cbq_ifacename, ifname);
+ strlcpy(get_stats.iface.cbq_ifacename, ifname,
+ sizeof(get_stats.iface.cbq_ifacename));
new = &stats1[0];
last = &stats2[0];
@@ -90,7 +91,7 @@ cbq_stat_loop(int fd, const char *ifname, int count, int interval)
if (sp->handle != clhandles[i]) {
quip_chandle2name(ifname, sp->handle,
- clnames[i]);
+ clnames[i], sizeof(clnames[0]));
clhandles[i] = sp->handle;
continue;
}
diff --git a/usr.sbin/altq/altqstat/qdisc_cdnr.c b/usr.sbin/altq/altqstat/qdisc_cdnr.c
index 8b5e525ae26..f2ebf23ed5f 100644
--- a/usr.sbin/altq/altqstat/qdisc_cdnr.c
+++ b/usr.sbin/altq/altqstat/qdisc_cdnr.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qdisc_cdnr.c,v 1.1 2001/06/27 18:23:20 kjc Exp $ */
-/* $KAME: qdisc_cdnr.c,v 1.3 2000/10/18 09:15:16 kjc Exp $ */
+/* $OpenBSD: qdisc_cdnr.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qdisc_cdnr.c,v 1.4 2001/08/15 12:51:58 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -69,9 +69,10 @@ cdnr_stat_loop(int fd, const char *ifname, int count, int interval)
if (ifname[0] == '_')
ifname++;
- sprintf(_ifname, "_%s", ifname);
+ snprintf(_ifname, sizeof(_ifname), "_%s", ifname);
- strcpy(get_stats.iface.cdnr_ifname, ifname);
+ strlcpy(get_stats.iface.cdnr_ifname, ifname,
+ sizeof(get_stats.iface.cdnr_ifname));
new = &stats1[0];
last = &stats2[0];
@@ -104,7 +105,7 @@ cdnr_stat_loop(int fd, const char *ifname, int count, int interval)
if (sp->tce_handle != lp->tce_handle) {
quip_chandle2name(_ifname, sp->tce_handle,
- cdnrnames[i]);
+ cdnrnames[i], sizeof(cdnrnames[0]));
continue;
}
diff --git a/usr.sbin/altq/altqstat/qdisc_conf.c b/usr.sbin/altq/altqstat/qdisc_conf.c
index e574d7a1af1..96331950dd8 100644
--- a/usr.sbin/altq/altqstat/qdisc_conf.c
+++ b/usr.sbin/altq/altqstat/qdisc_conf.c
@@ -1,4 +1,4 @@
-/* $KAME: qdisc_conf.c,v 1.3 2000/10/18 09:15:16 kjc Exp $ */
+/* $KAME: qdisc_conf.c,v 1.4 2001/08/15 12:51:59 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -78,11 +78,11 @@ ifname2qdisc(const char *ifname, char *qname)
if (ifname[0] == '_') {
/* input interface */
if (qname != NULL)
- strcpy(qname, "cdnr");
+ strlcpy(qname, "cdnr", 64);
return (ALTQT_CDNR);
}
- strcpy(qtypereq.ifname, ifname);
+ strlcpy(qtypereq.ifname, ifname, sizeof(qtypereq.ifname));
if ((fd = open(ALTQ_DEVICE, O_RDONLY)) < 0) {
warn("can't open %s", ALTQ_DEVICE);
return (0);
@@ -99,7 +99,7 @@ ifname2qdisc(const char *ifname, char *qname)
qtype = qtypereq.arg;
for (stat = qdisc_table; stat->qdisc_name != NULL; stat++)
if (stat->altqtype == qtype)
- strcpy(qname, stat->qdisc_name);
+ strlcpy(qname, stat->qdisc_name, 64);
}
return (qtype);
diff --git a/usr.sbin/altq/altqstat/qdisc_fifoq.c b/usr.sbin/altq/altqstat/qdisc_fifoq.c
index bea260c40b7..69bbd5f452f 100644
--- a/usr.sbin/altq/altqstat/qdisc_fifoq.c
+++ b/usr.sbin/altq/altqstat/qdisc_fifoq.c
@@ -1,4 +1,4 @@
-/* $KAME: qdisc_fifoq.c,v 1.3 2000/10/18 09:15:16 kjc Exp $ */
+/* $KAME: qdisc_fifoq.c,v 1.4 2001/08/15 12:51:59 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -53,7 +53,8 @@ fifoq_stat_loop(int fd, const char *ifname, int count, int interval)
double sec;
int cnt = count;
- strcpy(get_stats.iface.fifoq_ifname, ifname);
+ strlcpy(get_stats.iface.fifoq_ifname, ifname,
+ sizeof(get_stats.iface.fifoq_ifname));
gettimeofday(&last_time, NULL);
last_time.tv_sec -= interval;
diff --git a/usr.sbin/altq/altqstat/qdisc_hfsc.c b/usr.sbin/altq/altqstat/qdisc_hfsc.c
index 79c6213b662..7bf19e4e790 100644
--- a/usr.sbin/altq/altqstat/qdisc_hfsc.c
+++ b/usr.sbin/altq/altqstat/qdisc_hfsc.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qdisc_hfsc.c,v 1.1 2001/06/27 18:23:21 kjc Exp $ */
-/* $KAME: qdisc_hfsc.c,v 1.3 2000/10/18 09:15:17 kjc Exp $ */
+/* $OpenBSD: qdisc_hfsc.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qdisc_hfsc.c,v 1.4 2001/08/15 12:51:59 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -60,7 +60,8 @@ hfsc_stat_loop(int fd, const char *ifname, int count, int interval)
double sec;
int cnt = count;
- strcpy(get_stats.iface.hfsc_ifname, ifname);
+ strlcpy(get_stats.iface.hfsc_ifname, ifname,
+ sizeof(get_stats.iface.hfsc_ifname));
new = &stats1[0];
last = &stats2[0];
@@ -89,7 +90,7 @@ hfsc_stat_loop(int fd, const char *ifname, int count, int interval)
if (sp->class_id != lp->class_id) {
quip_chandle2name(ifname, sp->class_handle,
- clnames[i]);
+ clnames[i], sizeof(clnames[0]));
continue;
}
diff --git a/usr.sbin/altq/altqstat/qdisc_priq.c b/usr.sbin/altq/altqstat/qdisc_priq.c
index 868407eb836..db4a2f55279 100644
--- a/usr.sbin/altq/altqstat/qdisc_priq.c
+++ b/usr.sbin/altq/altqstat/qdisc_priq.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qdisc_priq.c,v 1.1 2001/06/27 18:23:21 kjc Exp $ */
-/* $KAME: qdisc_priq.c,v 1.1 2000/10/18 09:15:17 kjc Exp $ */
+/* $OpenBSD: qdisc_priq.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qdisc_priq.c,v 1.2 2001/08/15 12:51:59 kjc Exp $ */
/*
* Copyright (C) 2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -58,7 +58,8 @@ priq_stat_loop(int fd, const char *ifname, int count, int interval)
double sec;
int cnt = count;
- strcpy(get_stats.iface.ifname, ifname);
+ strlcpy(get_stats.iface.ifname, ifname,
+ sizeof(get_stats.iface.ifname));
new = &stats1[0];
last = &stats2[0];
@@ -86,7 +87,7 @@ priq_stat_loop(int fd, const char *ifname, int count, int interval)
if (sp->class_handle != lp->class_handle) {
quip_chandle2name(ifname, sp->class_handle,
- clnames[i]);
+ clnames[i], sizeof(clnames[0]));
continue;
}
diff --git a/usr.sbin/altq/altqstat/qdisc_red.c b/usr.sbin/altq/altqstat/qdisc_red.c
index 75550bb4e14..87dd9795a91 100644
--- a/usr.sbin/altq/altqstat/qdisc_red.c
+++ b/usr.sbin/altq/altqstat/qdisc_red.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qdisc_red.c,v 1.1 2001/06/27 18:23:21 kjc Exp $ */
-/* $KAME: qdisc_red.c,v 1.2 2000/10/18 09:15:17 kjc Exp $ */
+/* $OpenBSD: qdisc_red.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qdisc_red.c,v 1.3 2001/08/15 12:51:59 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -56,7 +56,8 @@ red_stat_loop(int fd, const char *ifname, int count, int interval)
double sec;
int cnt = count;
- strcpy(red_stats.iface.red_ifname, ifname);
+ strlcpy(red_stats.iface.red_ifname, ifname,
+ sizeof(red_stats.iface.red_ifname));
gettimeofday(&last_time, NULL);
last_time.tv_sec -= interval;
diff --git a/usr.sbin/altq/altqstat/qdisc_rio.c b/usr.sbin/altq/altqstat/qdisc_rio.c
index a7193ff8aec..01d07d57b10 100644
--- a/usr.sbin/altq/altqstat/qdisc_rio.c
+++ b/usr.sbin/altq/altqstat/qdisc_rio.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qdisc_rio.c,v 1.1 2001/06/27 18:23:21 kjc Exp $ */
-/* $KAME: qdisc_rio.c,v 1.3 2001/05/17 08:01:47 kjc Exp $ */
+/* $OpenBSD: qdisc_rio.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qdisc_rio.c,v 1.4 2001/08/15 12:51:59 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -58,7 +58,8 @@ rio_stat_loop(int fd, const char *ifname, int count, int interval)
int cnt = count;
bzero(&rio_stats, sizeof(rio_stats));
- strcpy(rio_stats.iface.rio_ifname, ifname);
+ strlcpy(rio_stats.iface.rio_ifname, ifname,
+ sizeof(rio_stats.iface.rio_ifname));
gettimeofday(&last_time, NULL);
last_time.tv_sec -= interval;
diff --git a/usr.sbin/altq/altqstat/qdisc_wfq.c b/usr.sbin/altq/altqstat/qdisc_wfq.c
index f829b27e194..c8a16a6942c 100644
--- a/usr.sbin/altq/altqstat/qdisc_wfq.c
+++ b/usr.sbin/altq/altqstat/qdisc_wfq.c
@@ -1,4 +1,4 @@
-/* $KAME: qdisc_wfq.c,v 1.2 2000/10/18 09:15:17 kjc Exp $ */
+/* $KAME: qdisc_wfq.c,v 1.3 2001/08/15 12:51:59 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -67,7 +67,8 @@ wfq_stat_loop(int fd, const char *ifname, int count, int interval)
struct wfqinfo *qinfo, **top;
int cnt = count;
- strcpy(wfq_stats.iface.wfq_ifacename, ifname);
+ strlcpy(wfq_stats.iface.wfq_ifacename, ifname,
+ sizeof(wfq_stats.iface.wfq_ifacename));
/*
* first, find out how many queues are available
diff --git a/usr.sbin/altq/altqstat/quip_client.c b/usr.sbin/altq/altqstat/quip_client.c
index 10d4cd16271..c7b7d5cbbaa 100644
--- a/usr.sbin/altq/altqstat/quip_client.c
+++ b/usr.sbin/altq/altqstat/quip_client.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: quip_client.c,v 1.1 2001/06/27 18:23:22 kjc Exp $ */
-/* $KAME: quip_client.c,v 1.2 2000/10/18 09:15:17 kjc Exp $ */
+/* $OpenBSD: quip_client.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: quip_client.c,v 1.4 2001/08/16 07:43:15 itojun Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -104,7 +104,7 @@ enum nametype { INTERFACE, CLASS, FILTER, CONDITIONER };
static FILE *server = NULL;
int quip_echo = 0;
-static char *extract_ifname(const char *name);
+static char *extract_ifname(const char *);
int
quip_openserver(void)
@@ -117,7 +117,7 @@ quip_openserver(void)
bzero(&addr, sizeof(addr));
addr.sun_family = AF_LOCAL;
- strcpy(addr.sun_path, QUIP_PATH);
+ strlcpy(addr.sun_path, QUIP_PATH,sizeof(addr.sun_path));
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
fprintf(stderr, "can't talk to altqd!\n"
@@ -143,18 +143,20 @@ quip_closeserver(void)
void
quip_sendrequest(FILE *fp, const char *request)
{
- char buf[1024], *cp;
+ char buf[QUIPMSG_MAXSIZE], *cp;
int n;
if ((cp = strstr(request, "QUIP")) == NULL) {
cp = strchr(request, '\n');
n = cp - request;
+ if (cp == NULL || n > REQ_MAXSIZE - 10)
+ return;
strncpy(buf, request, n);
- n += sprintf(buf + n, " QUIP/1.0");
- strcpy(buf + n, cp);
+ n += snprintf(buf + n, REQ_MAXSIZE - n, " QUIP/1.0");
+ strlcpy(buf + n, cp, REQ_MAXSIZE - n);
}
else
- strcpy(buf, request);
+ strlcpy(buf, request, REQ_MAXSIZE);
if (fputs(buf, fp) != 0)
err(1, "fputs");
@@ -173,7 +175,7 @@ quip_sendrequest(FILE *fp, const char *request)
int
quip_recvresponse(FILE *fp, char *header, char *body, int *blen)
{
- char buf[1024], version[64];
+ char buf[QUIPMSG_MAXSIZE], version[64];
int code, resid;
int end_of_header = 0;
@@ -181,7 +183,7 @@ quip_recvresponse(FILE *fp, char *header, char *body, int *blen)
*blen = 0;
code = 0;
resid = 0;
- while (fgets(buf, 1024, fp) != 0) {
+ while (fgets(buf, sizeof(buf), fp) != 0) {
if (quip_echo) {
fputs("> ", stdout);
fputs(buf, stdout);
@@ -190,7 +192,7 @@ quip_recvresponse(FILE *fp, char *header, char *body, int *blen)
if (!end_of_header) {
/* process message header */
if (header != NULL)
- header += sprintf(header, "%s", buf);
+ header += snprintf(header, RES_MAXSIZE, "%s", buf);
if (code == 0) {
/* status line expected */
@@ -219,7 +221,10 @@ quip_recvresponse(FILE *fp, char *header, char *body, int *blen)
cp = buf;
field = strsep(&cp, ":");
if (strcmp(field, "Content-Length") == 0) {
- sscanf(cp, "%d", &resid);
+ if (sscanf(cp, "%d", &resid) != 1) {
+ fpurge(fp);
+ return (-1);
+ }
if (blen != NULL)
*blen = resid;
}
@@ -230,7 +235,7 @@ quip_recvresponse(FILE *fp, char *header, char *body, int *blen)
int len;
if (body != NULL) {
- len = sprintf(body, "%s", buf);
+ len = snprintf(body, BODY_MAXSIZE, "%s", buf);
body += len;
}
else
@@ -319,7 +324,7 @@ quip_selectinterface(char *ifname)
char *
quip_selectqdisc(char *ifname, char *qdisc_name)
{
- char buf[8192], req[256];
+ char buf[BODY_MAXSIZE], req[REQ_MAXSIZE];
int result_code, len;
static char qdisc[64];
@@ -331,7 +336,7 @@ quip_selectqdisc(char *ifname, char *qdisc_name)
}
/* get qdisc info from the server */
- sprintf(req, "GET qdisc?%s\n", ifname);
+ snprintf(req, sizeof(req), "GET qdisc?%s\n", ifname);
quip_sendrequest(server, req);
result_code = quip_recvresponse(server, NULL, buf, &len);
@@ -349,9 +354,9 @@ quip_selectqdisc(char *ifname, char *qdisc_name)
}
void
-quip_chandle2name(const char *ifname, u_long handle, char *name)
+quip_chandle2name(const char *ifname, u_long handle, char *name, size_t size)
{
- char buf[8192], req[256], *cp;
+ char buf[BODY_MAXSIZE], req[REQ_MAXSIZE], *cp;
int result_code, len;
name[0] = '\0';
@@ -359,7 +364,7 @@ quip_chandle2name(const char *ifname, u_long handle, char *name)
return;
/* get class name from the server */
- sprintf(req, "GET handle-to-name?%s:%#lx\n", ifname, handle);
+ snprintf(req, sizeof(req), "GET handle-to-name?%s:%#lx\n", ifname, handle);
quip_sendrequest(server, req);
result_code = quip_recvresponse(server, NULL, buf, &len);
@@ -369,13 +374,13 @@ quip_chandle2name(const char *ifname, u_long handle, char *name)
if ((cp = strchr(buf, '\n')) != NULL)
*cp = '\0';
if ((cp = strrchr(buf, '/')) != NULL)
- strcpy(name, cp+1);
+ strlcpy(name, cp+1, size);
}
void
quip_printqdisc(const char *ifname)
{
- char buf[8192], req[256], *cp;
+ char buf[BODY_MAXSIZE], req[REQ_MAXSIZE], *cp;
int result_code, len;
if (server == NULL) {
@@ -384,7 +389,7 @@ quip_printqdisc(const char *ifname)
}
/* get qdisc info from the server */
- sprintf(req, "GET qdisc?%s\n", ifname);
+ snprintf(req, sizeof(req), "GET qdisc?%s\n", ifname);
quip_sendrequest(server, req);
result_code = quip_recvresponse(server, NULL, buf, &len);
@@ -402,11 +407,11 @@ quip_printqdisc(const char *ifname)
void
quip_printfilter(const char *ifname, const u_long handle)
{
- char buf[8192], req[256], *cp;
+ char buf[BODY_MAXSIZE], req[REQ_MAXSIZE], *cp;
int result_code, len;
/* get qdisc info from the server */
- sprintf(req, "GET filter?%s::%#lx\n", ifname, handle);
+ snprintf(req, sizeof(req), "GET filter?%s::%#lx\n", ifname, handle);
quip_sendrequest(server, req);
result_code = quip_recvresponse(server, NULL, buf, &len);
diff --git a/usr.sbin/altq/altqstat/quip_client.h b/usr.sbin/altq/altqstat/quip_client.h
index 7a107b999af..038be02fe5c 100644
--- a/usr.sbin/altq/altqstat/quip_client.h
+++ b/usr.sbin/altq/altqstat/quip_client.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: quip_client.h,v 1.1 2001/06/27 18:23:22 kjc Exp $ */
-/* $KAME: quip_client.h,v 1.2 2000/10/18 09:15:17 kjc Exp $ */
+/* $OpenBSD: quip_client.h,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: quip_client.h,v 1.4 2001/08/16 07:43:15 itojun Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -32,18 +32,23 @@
/* unix domain socket for quip */
#define QUIP_PATH "/var/run/altq_quip"
+#define REQ_MAXSIZE 256 /* max request size */
+#define RES_MAXSIZE 256 /* max reply header size */
+#define BODY_MAXSIZE 8192 /* max reply body size */
+#define QUIPMSG_MAXSIZE (RES_MAXSIZE+BODY_MAXSIZE) /* max message size */
+
extern int quip_echo;
int quip_openserver(void);
int quip_closeserver(void);
-void quip_sendrequest(FILE *fp, const char *request);
-int quip_recvresponse(FILE *fp, char *header, char *body, int *blen);
+void quip_sendrequest(FILE *, const char *);
+int quip_recvresponse(FILE *, char *, char *, int *);
void quip_rawmode(void);
-char *quip_selectinterface(char *ifname);
-char *quip_selectqdisc(char *ifname, char *qdisc_name);
-void quip_chandle2name(const char *ifname, u_long handle, char *name);
-void quip_printqdisc(const char *ifname);
-void quip_printfilter(const char *ifname, const u_long handle);
+char *quip_selectinterface(char *);
+char *quip_selectqdisc(char *, char *);
+void quip_chandle2name(const char *, u_long, char *, size_t);
+void quip_printqdisc(const char *);
+void quip_printfilter(const char *, const u_long);
void quip_printconfig(void);
#endif /* _QUIP_CLIENT_H_ */
diff --git a/usr.sbin/altq/libaltq/parser.c b/usr.sbin/altq/libaltq/parser.c
index b0afdac7eb7..2fb0a65351d 100644
--- a/usr.sbin/altq/libaltq/parser.c
+++ b/usr.sbin/altq/libaltq/parser.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: parser.c,v 1.3 2001/08/06 06:57:37 itojun Exp $ */
-/* $KAME: parser.c,v 1.6 2001/05/30 10:30:44 kjc Exp $ */
+/* $OpenBSD: parser.c,v 1.4 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: parser.c,v 1.12 2001/08/16 10:39:13 kjc Exp $ */
/*******************************************************************
Copyright (c) 1996 by the University of Southern California
@@ -54,37 +54,33 @@
/*
* Forward & External Declarations
*/
-static int is_qdisc_name(const char *qname);
-static int qdisc_interface_parser(const char * qname, const char *ifname,
- int argc, char **argv);
-static int qdisc_class_parser(const char *qname, const char *ifname,
- const char *class_name, const char *parent_name,
- int argc, char **argv);
-
-static int pfxcmp(const char *s1, const char *s2);
-static int next_word(char **cpp, char *b);
-
-static int do_cmd(int op, char *cmdbuf);
-static int get_ifname(char **cpp, char **ifnamep);
-static int get_addr(char **cpp, struct in_addr *addr, struct in_addr *mask);
-static int get_port(const char *name, u_int16_t *port_no);
-static int get_proto(const char *name, int *proto_no);
-static int get_fltr_opts(char **cpp, char *fltr_name, int *ruleno);
-static int interface_parser(char *cmdbuf);
-static int class_parser(char *cmdbuf) ;
-static int filter_parser(char *cmdbuf);
+static int is_qdisc_name(const char *);
+static int qdisc_interface_parser(const char *, const char *, int, char **);
+static int qdisc_class_parser(const char *, const char *, const char *,
+ const char *, int, char **);
+
+static int pfxcmp(const char *, const char *);
+static int next_word(char **, char *);
+
+static int do_cmd(int, char *);
+static int get_ifname(char **, char **);
+static int get_addr(char **, struct in_addr *, struct in_addr *);
+static int get_port(const char *, u_int16_t *);
+static int get_proto(const char *, int *);
+static int get_fltr_opts(char **, char *, size_t, int *);
+static int interface_parser(char *);
+static int class_parser(char *) ;
+static int filter_parser(char *);
#ifdef INET6
-static int filter6_parser(char *cmdbuf);
-static int get_ip6addr(char **cpp, struct in6_addr *addr,
- struct in6_addr *mask);
+static int filter6_parser(char *);
+static int get_ip6addr(char **, struct in6_addr *, struct in6_addr *);
#endif
-static int ctl_parser(char *cmdbuf);
-static int delete_parser(char *cmdbuf);
-static int red_parser(char *cmdbuf);
-static int rio_parser(char *cmdbuf);
-static int conditioner_parser(char *cmdbuf);
-static int tc_action_parser(char *ifname, char **cpp,
- struct tc_action *action);
+static int ctl_parser(char *);
+static int delete_parser(char *);
+static int red_parser(char *);
+static int rio_parser(char *);
+static int conditioner_parser(char *);
+static int tc_action_parser(char *, char **, struct tc_action *);
/*
* Globals
@@ -185,13 +181,13 @@ qdisc_class_parser(const char *qname, const char *ifname,
}
if ((ifinfo = ifname2ifinfo(ifname)) == NULL) {
LOG(LOG_ERR, 0,
- "no such interface, line %d\n", line_no);
+ "no such interface, line %d", line_no);
return (0);
}
if (strncmp(ifinfo->qdisc->qname, qname,
strlen(ifinfo->qdisc->qname)) != 0) {
LOG(LOG_ERR, 0,
- "qname doesn't match the interface, line %d\n",
+ "qname doesn't match the interface, line %d",
line_no);
return (0);
}
@@ -219,11 +215,11 @@ qcmd_config(void)
for (i = 0; i < MAX_T; i++)
if_names[i][0] = '\0';
- LOG(LOG_INFO, 0, "ALTQ config file is %s\n", altqconfigfile);
+ LOG(LOG_INFO, 0, "ALTQ config file is %s", altqconfigfile);
f = fopen(altqconfigfile, "r");
if (f == NULL) {
- LOG(LOG_ERR, errno, "Can't open %s", altqconfigfile, 0);
+ LOG(LOG_ERR, errno, "can't open %s", altqconfigfile, 0);
return (QOPERR_INVAL);
}
line_no = 0;
@@ -293,7 +289,7 @@ DoCommand(char *infile, FILE *infp)
if (rc == 0) {
if (infile) {
/* error in the config file. cleanup and exit. */
- LOG(LOG_ERR, 0, "Config failed. Exiting.\n");
+ LOG(LOG_ERR, 0, "config failed. exiting...");
(void) qcmd_destroyall();
(void) fclose(infp);
exit(1);
@@ -442,7 +438,7 @@ get_ifname(char **cpp, char **ifnamep)
if (strcmp(w, ifnp->if_name) == 0) {
/* if_name found. advance the word pointer */
*cpp = ocp;
- strcpy(if_names[TNO], w);
+ strlcpy(if_names[TNO], w, sizeof(if_names[TNO]));
*ifnamep = if_names[TNO];
return (1);
}
@@ -535,7 +531,7 @@ get_proto(const char *name, int *proto_no)
}
static int
-get_fltr_opts(char **cpp, char *fltr_name, int *ruleno)
+get_fltr_opts(char **cpp, char *fltr_name, size_t len, int *ruleno)
{
char w[128], *ocp;
@@ -544,7 +540,7 @@ get_fltr_opts(char **cpp, char *fltr_name, int *ruleno)
if (EQUAL(w, "name")) {
if (!next_word(&ocp, w))
return (0);
- strcpy(fltr_name, w);
+ strlcpy(fltr_name, w, len);
*cpp = ocp;
} else if (EQUAL(w, "ruleno")) {
if (!next_word(&ocp, w))
@@ -568,7 +564,7 @@ interface_parser(char *cmdbuf)
int argc, rval;
if (!get_ifname(&cp, &ifname)) {
- LOG(LOG_ERR, 0, "missing interface name in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing interface name in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -581,7 +577,7 @@ interface_parser(char *cmdbuf)
ap = w;
while (next_word(&cp, ap)) {
if (is_qdisc_name(ap))
- strcpy(qdisc_name, ap);
+ strlcpy(qdisc_name, ap, sizeof(qdisc_name));
argv[argc] = ap;
ap += strlen(ap) + 1;
@@ -590,7 +586,7 @@ interface_parser(char *cmdbuf)
rval = qdisc_interface_parser(qdisc_name, ifname, argc, argv);
if (rval == 0) {
- LOG(LOG_ERR, 0, "Error in %s, line %d\n",
+ LOG(LOG_ERR, 0, "Error in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -609,34 +605,34 @@ class_parser(char *cmdbuf)
/* get scheduling class */
if (!next_word(&cp, qdisc_name)) {
- LOG(LOG_ERR, 0, "missing scheduling discipline in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing scheduling discipline in %s, line %d",
altqconfigfile, line_no);
return (0);
}
if (!is_qdisc_name(qdisc_name)) {
LOG(LOG_ERR, 0,
- "unknown scheduling discipline '%s' in %s, line %d\n",
+ "unknown scheduling discipline '%s' in %s, line %d",
qdisc_name, altqconfigfile, line_no);
return (0);
}
/* get interface name */
if (!get_ifname(&cp, &ifname)) {
- LOG(LOG_ERR, 0, "missing interface name in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing interface name in %s, line %d",
altqconfigfile, line_no);
return (0);
}
/* get class name */
if (!next_word(&cp, class_name)) {
- LOG(LOG_ERR, 0, "missing class name in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing class name in %s, line %d",
altqconfigfile, line_no);
return (0);
}
/* get parent name */
if (!next_word(&cp, parent_name)) {
- LOG(LOG_ERR, 0, "missing parent class in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing parent class in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -657,7 +653,7 @@ class_parser(char *cmdbuf)
rval = qdisc_class_parser(qdisc_name, ifname, clname, parent,
argc, argv);
if (rval == 0) {
- LOG(LOG_ERR, 0, "can't add class '%s' on interface '%s'\n",
+ LOG(LOG_ERR, 0, "can't add class '%s' on interface '%s'",
clname, ifname);
return (0);
}
@@ -681,23 +677,23 @@ filter_parser(char *cmdbuf)
sfilt.ff_flow.fi_family = AF_INET;
if (!get_ifname(&cp, &ifname)) {
- LOG(LOG_ERR, 0, "missing interface name in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing interface name in %s, line %d",
altqconfigfile, line_no);
return (0);
}
if (!next_word(&cp, class_name)) {
LOG(LOG_ERR, 0,
- "missing class name in %s, line %d\n",
+ "missing class name in %s, line %d",
altqconfigfile, line_no);
return (0);
}
fltr_name[0] = '\0';
ruleno = 0;
- if (!get_fltr_opts(&cp, &fltr_name[0], &ruleno)) {
+ if (!get_fltr_opts(&cp, &fltr_name[0], sizeof(fltr_name), &ruleno)) {
LOG(LOG_ERR, 0,
- "bad filter option in %s, line %d\n",
+ "bad filter option in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -708,7 +704,7 @@ filter_parser(char *cmdbuf)
/* get filter destination Address */
if (!get_addr(&cp, &sfilt.ff_flow.fi_dst, &sfilt.ff_mask.mask_dst)) {
LOG(LOG_ERR, 0,
- "bad filter destination address in %s, line %d\n",
+ "bad filter destination address in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -716,43 +712,43 @@ filter_parser(char *cmdbuf)
/* get filter destination port */
if (!next_word(&cp, w)) {
LOG(LOG_ERR, 0,
- "missing filter destination port in %s, line %d\n",
+ "missing filter destination port in %s, line %d",
altqconfigfile, line_no);
return (0);
}
if (!get_port(w, &sfilt.ff_flow.fi_dport)) {
- LOG(LOG_ERR, 0, "bad filter destination port in %s, line %d\n",
+ LOG(LOG_ERR, 0, "bad filter destination port in %s, line %d",
altqconfigfile, line_no);
return (0);
}
/* get filter source address */
if (!get_addr(&cp, &sfilt.ff_flow.fi_src, &sfilt.ff_mask.mask_src)) {
- LOG(LOG_ERR, 0, "bad filter source address in %s, line %d\n",
+ LOG(LOG_ERR, 0, "bad filter source address in %s, line %d",
altqconfigfile, line_no);
return (0);
}
/* get filter source port */
if (!next_word(&cp, w)) {
- LOG(LOG_ERR, 0, "missing filter source port in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing filter source port in %s, line %d",
altqconfigfile, line_no);
return (0);
}
if (!get_port(w, &sfilt.ff_flow.fi_sport)) {
- LOG(LOG_ERR, 0, "bad filter source port in %s, line %d\n",
+ LOG(LOG_ERR, 0, "bad filter source port in %s, line %d",
altqconfigfile, line_no);
return (0);
}
/* get filter protocol id */
if (!next_word(&cp, w)) {
- LOG(LOG_ERR, 0, "missing filter protocol id in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing filter protocol id in %s, line %d",
altqconfigfile, line_no);
return (0);
}
if (!get_proto(w, &protocol)) {
- LOG(LOG_ERR, 0, "bad protocol in %s, line %d\n",
+ LOG(LOG_ERR, 0, "bad protocol in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -793,7 +789,7 @@ filter_parser(char *cmdbuf)
filter_dontwarn = 0; /* XXX */
if (error) {
LOG(LOG_ERR, 0,
- "can't add filter to class '%s' on interface '%s'\n",
+ "can't add filter to class '%s' on interface '%s'",
class_name, ifname);
return (0);
}
@@ -818,22 +814,22 @@ filter6_parser(char *cmdbuf)
sfilt.ff_flow6.fi6_family = AF_INET6;
if (!get_ifname(&cp, &ifname)) {
- LOG(LOG_ERR, 0, "missing interface name in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing interface name in %s, line %d",
altqconfigfile, line_no);
return (0);
}
if (!next_word(&cp, class_name)) {
- LOG(LOG_ERR, 0, "missing class name in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing class name in %s, line %d",
altqconfigfile, line_no);
return (0);
}
fltr_name[0] = '\0';
ruleno = 0;
- if (!get_fltr_opts(&cp, &fltr_name[0], &ruleno)) {
+ if (!get_fltr_opts(&cp, &fltr_name[0], sizeof(fltr_name), &ruleno)) {
LOG(LOG_ERR, 0,
- "bad filter option in %s, line %d\n",
+ "bad filter option in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -844,52 +840,52 @@ filter6_parser(char *cmdbuf)
/* get filter destination address */
if (!get_ip6addr(&cp, &sfilt.ff_flow6.fi6_dst,
&sfilt.ff_mask6.mask6_dst)) {
- LOG(LOG_ERR, 0, "bad destination address in %s, line %d\n",
+ LOG(LOG_ERR, 0, "bad destination address in %s, line %d",
altqconfigfile, line_no);
return (0);
}
-
+
/* get filter destination port */
if (!next_word(&cp, w)) {
LOG(LOG_ERR, 0,
- "missing filter destination port in %s, line %d\n",
+ "missing filter destination port in %s, line %d",
altqconfigfile, line_no);
return (0);
}
if (!get_port(w, &sfilt.ff_flow6.fi6_dport)) {
- LOG(LOG_ERR, 0, "bad filter destination port in %s, line %d\n",
+ LOG(LOG_ERR, 0, "bad filter destination port in %s, line %d",
altqconfigfile, line_no);
return (0);
}
-
+
/* get filter source address */
if (!get_ip6addr(&cp, &sfilt.ff_flow6.fi6_src,
&sfilt.ff_mask6.mask6_src)) {
- LOG(LOG_ERR, 0, "bad source address in %s, line %d\n",
+ LOG(LOG_ERR, 0, "bad source address in %s, line %d",
altqconfigfile, line_no);
return (0);
}
/* get filter source port */
if (!next_word(&cp, w)) {
- LOG(LOG_ERR, 0, "missing filter source port in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing filter source port in %s, line %d",
altqconfigfile, line_no);
return (0);
}
if (!get_port(w, &sfilt.ff_flow6.fi6_sport)) {
- LOG(LOG_ERR, 0, "bad filter source port in %s, line %d\n",
+ LOG(LOG_ERR, 0, "bad filter source port in %s, line %d",
altqconfigfile, line_no);
return (0);
}
/* get filter protocol id */
if (!next_word(&cp, w)) {
- LOG(LOG_ERR, 0, "missing filter protocol id in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing filter protocol id in %s, line %d",
altqconfigfile, line_no);
return (0);
}
if (!get_proto(w, &protocol)) {
- LOG(LOG_ERR, 0, "bad protocol in %s, line %d\n",
+ LOG(LOG_ERR, 0, "bad protocol in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -910,8 +906,8 @@ filter6_parser(char *cmdbuf)
}
}
}
- sfilt.ff_flow6.fi6_tclass = tclass;
- sfilt.ff_mask6.mask6_tclass = tclassmask;
+ sfilt.ff_flow6.fi6_tclass = tclass;
+ sfilt.ff_mask6.mask6_tclass = tclassmask;
} else if (EQUAL(w, "gpi")) {
if (next_word(&cp, w)) {
sfilt.ff_flow6.fi6_gpi =
@@ -939,7 +935,7 @@ filter6_parser(char *cmdbuf)
filter_dontwarn = 0; /* XXX */
if (ret) {
LOG(LOG_ERR, 0,
- "can't add filter to class '%s' on interface '%s'\n",
+ "can't add filter to class '%s' on interface '%s'",
class_name, ifname);
return (0);
}
@@ -1019,7 +1015,7 @@ ctl_parser(char *cmdbuf)
state ? "enabled" : "disabled", ifname);
return (1);
}
-
+
if (EQUAL(w, "enable")) {
rval = qcmd_enable(ifname);
printf("altq %s on %s\n",
@@ -1053,7 +1049,7 @@ delete_parser(char *cmdbuf)
if (!next_word(&cp, class_name)) {
LOG(LOG_ERR, 0,
- "missing class name in %s, line %d\n",
+ "missing class name in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -1061,7 +1057,7 @@ delete_parser(char *cmdbuf)
ret = qcmd_delete_class(ifname, class_name);
if (ret) {
LOG(LOG_ERR, 0,
- "can't delete class '%s' on interface '%s'\n",
+ "can't delete class '%s' on interface '%s'",
class_name, ifname);
return (0);
}
@@ -1088,14 +1084,14 @@ red_parser(char *cmdbuf)
inv_pmax = (int)strtol(w, NULL, 0);
if (qop_red_set_defaults(th_min, th_max, inv_pmax) != 0) {
- LOG(LOG_ERR, 0, "can't set red default parameters\n");
+ LOG(LOG_ERR, 0, "can't set red default parameters");
return (0);
}
return (1);
bad:
- LOG(LOG_ERR, 0, "bad red parameter in %s, line %d\n",
+ LOG(LOG_ERR, 0, "bad red parameter in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -1122,14 +1118,14 @@ rio_parser(char *cmdbuf)
}
if (qop_rio_set_defaults(&params[0]) != 0) {
- LOG(LOG_ERR, 0, "can't set rio default parameters\n");
+ LOG(LOG_ERR, 0, "can't set rio default parameters");
return (0);
}
return (1);
bad:
- LOG(LOG_ERR, 0, "bad rio parameter in %s, line %d\n",
+ LOG(LOG_ERR, 0, "bad rio parameter in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -1142,14 +1138,14 @@ conditioner_parser(char *cmdbuf)
struct tc_action action[64];
if (!get_ifname(&cp, &ifname)) {
- LOG(LOG_ERR, 0, "missing interface name in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing interface name in %s, line %d",
altqconfigfile, line_no);
return (0);
}
/* get conditioner name */
if (!next_word(&cp, cdnr_name)) {
- LOG(LOG_ERR, 0, "missing cdnr name in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing cdnr name in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -1173,14 +1169,14 @@ tc_action_parser(char *ifname, char **cpp, struct tc_action *action)
char type[128], w[128];
int depth, i;
struct tb_profile profile[2];
-
+
/*
* find a possibly nested pair of '<' and '>',
* make them pointed by 'start' and 'end'.
*/
start = strchr(*cpp, '<');
if (start == NULL) {
- LOG(LOG_ERR, 0, "conditioner action missing in %s, line %d\n",
+ LOG(LOG_ERR, 0, "conditioner action missing in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -1190,7 +1186,7 @@ tc_action_parser(char *ifname, char **cpp, struct tc_action *action)
end = strpbrk(cp, "<>");
if (end == NULL) {
LOG(LOG_ERR, 0,
- "conditioner action delimiter mismatch in %s, line %d\n",
+ "conditioner action delimiter mismatch in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -1210,18 +1206,18 @@ tc_action_parser(char *ifname, char **cpp, struct tc_action *action)
if (!next_word(&cp, type)) {
LOG(LOG_ERR, 0,
- "missing conditioner action type in %s, line %d\n",
+ "missing conditioner action type in %s, line %d",
altqconfigfile, line_no);
return (0);
}
-
+
/*
* action type specific process
*/
if (EQUAL(type, "conditioner")) {
if (!next_word(&cp, w)) {
LOG(LOG_ERR, 0,
- "missing conditioner name in %s, line %d\n",
+ "missing conditioner name in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -1229,7 +1225,7 @@ tc_action_parser(char *ifname, char **cpp, struct tc_action *action)
action->tca_handle = cdnr_name2handle(ifname, w);
if (action->tca_handle == CDNR_NULL_HANDLE) {
LOG(LOG_ERR, 0,
- "wrong conditioner name %s in %s, line %d\n",
+ "wrong conditioner name %s in %s, line %d",
w, altqconfigfile, line_no);
return (0);
}
@@ -1239,7 +1235,7 @@ tc_action_parser(char *ifname, char **cpp, struct tc_action *action)
action->tca_code = TCACODE_DROP;
} else if (EQUAL(type, "mark")) {
if (!next_word(&cp, w)) {
- LOG(LOG_ERR, 0, "missing dscp in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing dscp in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -1247,13 +1243,13 @@ tc_action_parser(char *ifname, char **cpp, struct tc_action *action)
action->tca_dscp = (u_int8_t)strtol(w, NULL, 0);
} else if (EQUAL(type, "tbmeter")) {
if (!next_word(&cp, w)) {
- LOG(LOG_ERR, 0, "missing tb profile in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing tb profile in %s, line %d",
altqconfigfile, line_no);
return (0);
}
profile[0].rate = atobps(w);
if (!next_word(&cp, w)) {
- LOG(LOG_ERR, 0, "missing tb profile in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing tb profile in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -1272,14 +1268,14 @@ tc_action_parser(char *ifname, char **cpp, struct tc_action *action)
for (i=0; i<2; i++) {
if (!next_word(&cp, w)) {
LOG(LOG_ERR, 0,
- "missing tb profile in %s, line %d\n",
+ "missing tb profile in %s, line %d",
altqconfigfile, line_no);
return (0);
}
profile[i].rate = atobps(w);
if (!next_word(&cp, w)) {
LOG(LOG_ERR, 0,
- "missing tb profile in %s, line %d\n",
+ "missing tb profile in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -1307,21 +1303,21 @@ tc_action_parser(char *ifname, char **cpp, struct tc_action *action)
u_int32_t cmtd_rate, peak_rate, avg_interval;
if (!next_word(&cp, w)) {
- LOG(LOG_ERR, 0, "missing cmtd rate in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing cmtd rate in %s, line %d",
altqconfigfile, line_no);
return (0);
}
cmtd_rate = atobps(w);
if (!next_word(&cp, w)) {
- LOG(LOG_ERR, 0, "missing peak rate in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing peak rate in %s, line %d",
altqconfigfile, line_no);
return (0);
}
peak_rate = atobps(w);
if (!next_word(&cp, w)) {
- LOG(LOG_ERR, 0, "missing avg interval in %s, line %d\n",
+ LOG(LOG_ERR, 0, "missing avg interval in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -1341,11 +1337,11 @@ tc_action_parser(char *ifname, char **cpp, struct tc_action *action)
return (0);
} else {
LOG(LOG_ERR, 0,
- "Unkown action type %s in %s, line %d\n",
+ "Unkown action type %s in %s, line %d",
type, altqconfigfile, line_no);
return (0);
}
-
+
*end = '>'; /* restore the end delimiter */
return (1);
diff --git a/usr.sbin/altq/libaltq/qop.c b/usr.sbin/altq/libaltq/qop.c
index 361e60eae9f..e817e369fe1 100644
--- a/usr.sbin/altq/libaltq/qop.c
+++ b/usr.sbin/altq/libaltq/qop.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qop.c,v 1.1 2001/06/27 18:23:26 kjc Exp $ */
-/* $KAME: qop.c,v 1.6 2000/10/18 09:15:18 kjc Exp $ */
+/* $OpenBSD: qop.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qop.c,v 1.10 2001/08/16 10:39:13 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -87,17 +87,16 @@ int Debug_mode = 0; /* nosched (dummy mode) */
/*
* internal functions
*/
-static int get_ifmtu(const char *ifname);
-static void tbr_install(const char *ifname);
-static void tbr_deinstall(const char *ifname);
-static int add_filter_rule(struct ifinfo *ifinfo, struct fltrinfo *fltrinfo,
- struct fltrinfo **conflict);
-static int remove_filter_rule(struct ifinfo *ifinfo,
- struct fltrinfo *fltrinfo);
-static int filt_check_relation(struct flow_filter *front,
- struct flow_filter *back);
-static int filt_disjoint(struct flow_filter *front, struct flow_filter *back);
-static int filt_subset(struct flow_filter *front, struct flow_filter *back);
+static int get_ifmtu(const char *);
+static void tbr_install(const char *);
+static void tbr_deinstall(const char *);
+static int add_filter_rule(struct ifinfo *, struct fltrinfo *,
+ struct fltrinfo **);
+static int remove_filter_rule(struct ifinfo *,
+ struct fltrinfo *);
+static int filt_check_relation(struct flow_filter *, struct flow_filter *);
+static int filt_disjoint(struct flow_filter *, struct flow_filter *);
+static int filt_subset(struct flow_filter *, struct flow_filter *);
/*
* QCMD (Queue Command) API
@@ -109,13 +108,12 @@ qcmd_init(void)
/* read config file and execute commands */
error = qcmd_config();
+ if (error != 0)
+ return (error);
- if (error == 0)
- error = qcmd_enableall();
-
+ error = qcmd_enableall();
if (error != 0)
- LOG(LOG_ERR, errno, "%s: qcmd_init failed.\n",
- qoperror(error));
+ LOG(LOG_ERR, errno, "%s: qcmd_init failed", qoperror(error));
return (error);
}
@@ -132,10 +130,10 @@ qcmd_enable(const char *ifname)
error = qop_enable(ifinfo);
if (error == 0) {
- LOG(LOG_INFO, 0, "%s enabled on interface %s (mtu:%d)\n",
+ LOG(LOG_INFO, 0, "%s enabled on interface %s (mtu:%d)",
ifinfo->qdisc->qname, ifname, ifinfo->ifmtu);
} else
- LOG(LOG_ERR, errno, "%s: enable failed!\n", qoperror(error));
+ LOG(LOG_ERR, errno, "%s: enable failed!", qoperror(error));
return (error);
}
@@ -152,7 +150,7 @@ qcmd_disable(const char *ifname)
error = qop_disable(ifinfo);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: disable failed!\n", qoperror(error));
+ LOG(LOG_ERR, errno, "%s: disable failed!", qoperror(error));
return (error);
}
@@ -165,7 +163,7 @@ qcmd_enableall()
LIST_FOREACH(ifinfo, &qop_iflist, next) {
if ((error = qop_enable(ifinfo)) != 0)
return (error);
- LOG(LOG_INFO, 0, "%s enabled on interface %s (mtu:%d)\n",
+ LOG(LOG_INFO, 0, "%s enabled on interface %s (mtu:%d)",
ifinfo->qdisc->qname, ifinfo->ifname, ifinfo->ifmtu);
}
return (0);
@@ -196,7 +194,7 @@ qcmd_clear(const char *ifname)
if (error == 0)
error = qop_clear(ifinfo);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: clear failed!\n", qoperror(error));
+ LOG(LOG_ERR, errno, "%s: clear failed!", qoperror(error));
return (error);
}
@@ -232,7 +230,7 @@ qcmd_delete_class(const char *ifname, const char *clname)
if (error == 0)
error = qop_delete_class(clinfo);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: delete_class failed\n",
+ LOG(LOG_ERR, errno, "%s: delete_class failed",
qoperror(error));
return (error);
}
@@ -263,10 +261,10 @@ qcmd_add_filter(const char *ifname, const char *clname, const char *flname,
error = qop_add_filter(NULL, clinfo, flname, fltr, NULL);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: add filter failed!\n",
+ LOG(LOG_ERR, errno, "%s: add filter failed!",
qoperror(error));
else if (IsDebug(DEBUG_ALTQ)) {
- LOG(LOG_DEBUG, 0, "%s: add a filter %s to class %s\n",
+ LOG(LOG_DEBUG, 0, "%s: add a filter %s to class %s",
ifname, flname ? flname : "(null)",
clname ? clname : "(null)");
print_filter(fltr);
@@ -303,7 +301,7 @@ qcmd_delete_filter(const char *ifname, const char *clname, const char *flname)
if (error == 0)
error = qop_delete_filter(fltrinfo);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: delete filter failed!\n",
+ LOG(LOG_ERR, errno, "%s: delete filter failed!",
qoperror(error));
return (error);
}
@@ -316,7 +314,7 @@ qcmd_tbr_register(const char *ifname, u_int rate, u_int size)
if ((info = calloc(1, sizeof(struct tbrinfo))) == NULL)
return (QOPERR_NOMEM);
- strcpy(info->ifname, ifname);
+ strlcpy(info->ifname, ifname, sizeof(info->ifname));
info->tb_prof.rate = rate;
info->tb_prof.depth = size;
info->installed = 0;
@@ -336,7 +334,7 @@ qop_add_if(struct ifinfo **rp, const char *ifname, u_int bandwidth,
int error;
if (ifname2ifinfo(ifname) != NULL) {
- LOG(LOG_ERR, 0, "qop_add_if: %s already exists!\n", ifname);
+ LOG(LOG_ERR, 0, "qop_add_if: %s already exists!", ifname);
return (QOPERR_BADIF);
}
@@ -665,7 +663,7 @@ qoperror(int qoperrno)
if (qoperrno <= QOPERR_MAX)
return (qop_errlist[qoperrno]);
- sprintf(buf, "unknown error %d", qoperrno);
+ snprintf(buf, sizeof(buf), "unknown error %d", qoperrno);
return (buf);
}
@@ -886,7 +884,7 @@ tbr_install(const char *ifname)
if (req.tb_prof.rate != 0) {
LOG(LOG_INFO, 0,
"tbr is already installed on %s,\n"
- " using the current setting (rate:%.2fM size:%.2fK).\n",
+ " using the current setting (rate:%.2fM size:%.2fK).",
info->ifname,
(double)req.tb_prof.rate/1000000.0,
(double)req.tb_prof.depth/1024.0);
@@ -918,7 +916,7 @@ tbr_install(const char *ifname)
if (ioctl(fd, ALTQTBRSET, &req) < 0)
err(1, "ALTQTBRSET for interface %s", req.ifname);
LOG(LOG_INFO, 0,
- "tbr installed on %s (rate:%.2fM size:%.2fK)\n",
+ "tbr installed on %s (rate:%.2fM size:%.2fK)",
info->ifname,
(double)info->tb_prof.rate/1000000.0,
(double)info->tb_prof.depth/1024.0);
@@ -962,15 +960,15 @@ print_filter(const struct flow_filter *filt)
in_addr.s_addr = filt->ff_flow.fi_dst.s_addr;
LOG(LOG_DEBUG, 0,
- " Filter Dest Addr: %s (mask %#x) Port: %d\n",
+ " Filter Dest Addr: %s (mask %#x) Port: %d",
inet_ntoa(in_addr), ntoh32(filt->ff_mask.mask_dst.s_addr),
ntoh16(filt->ff_flow.fi_dport));
in_addr.s_addr = filt->ff_flow.fi_src.s_addr;
LOG(LOG_DEBUG, 0,
- " Src Addr: %s (mask %#x) Port: %d\n",
+ " Src Addr: %s (mask %#x) Port: %d",
inet_ntoa(in_addr), ntoh32(filt->ff_mask.mask_src.s_addr),
ntoh16(filt->ff_flow.fi_sport));
- LOG(LOG_DEBUG, 0, " Protocol: %d TOS %#x (mask %#x)\n",
+ LOG(LOG_DEBUG, 0, " Protocol: %d TOS %#x (mask %#x)",
filt->ff_flow.fi_proto, filt->ff_flow.fi_tos,
filt->ff_mask.mask_tos);
}
@@ -992,7 +990,7 @@ print_filter(const struct flow_filter *filt)
inet_ntop(AF_INET6, &sfilt6->ff_mask6.mask6_src,
str2, sizeof(str2)),
ntoh16(sfilt6->ff_flow6.fi6_sport));
- LOG(LOG_DEBUG, 0, " Protocol: %d TCLASS %#x (mask %#x)\n",
+ LOG(LOG_DEBUG, 0, " Protocol: %d TCLASS %#x (mask %#x)",
sfilt6->ff_flow6.fi6_proto, sfilt6->ff_flow6.fi6_tclass,
sfilt6->ff_mask6.mask6_tclass);
}
@@ -1057,7 +1055,7 @@ add_filter_rule(struct ifinfo *ifinfo, struct fltrinfo *fltrinfo,
case FILT_SUPERSET:
if (front->dontwarn == 0 && back->dontwarn == 0)
LOG(LOG_ERR, 0,
- "filters for \"%s\" at line %d and for \"%s\" at line %d has an order problem!\n",
+ "filters for \"%s\" at line %d and for \"%s\" at line %d has an order problem!",
front->clinfo->clname, front->line_no,
back->clinfo->clname, back->line_no);
@@ -1075,7 +1073,7 @@ add_filter_rule(struct ifinfo *ifinfo, struct fltrinfo *fltrinfo,
break;
if (front->dontwarn == 0 && back->dontwarn == 0)
LOG(LOG_WARNING, 0,
- "warning: filter for \"%s\" at line %d could override filter for \"%s\" at line %d\n",
+ "warning: filter for \"%s\" at line %d could override filter for \"%s\" at line %d",
front->clinfo->clname, front->line_no,
back->clinfo->clname, back->line_no);
break;
@@ -1355,7 +1353,7 @@ qop_red_set_defaults(int th_min, int th_max, int inv_pmax)
int fd;
if ((fd = open(RED_DEVICE, O_RDWR)) < 0) {
- LOG(LOG_ERR, errno, "RED open\n");
+ LOG(LOG_ERR, errno, "RED open");
return (QOPERR_SYSCALL);
}
@@ -1364,7 +1362,7 @@ qop_red_set_defaults(int th_min, int th_max, int inv_pmax)
params.inv_pmax = inv_pmax;
if (ioctl(fd, RED_SETDEFAULTS, &params) < 0) {
- LOG(LOG_ERR, errno, "RED_SETDEFAULTS\n");
+ LOG(LOG_ERR, errno, "RED_SETDEFAULTS");
return (QOPERR_SYSCALL);
}
@@ -1381,16 +1379,16 @@ qop_rio_set_defaults(struct redparams *params)
for (i = 1; i < RIO_NDROPPREC; i++) {
if (params[i].th_max > params[i-1].th_min)
LOG(LOG_WARNING, 0,
- "warning: overlap found in RIO thresholds\n");
+ "warning: overlap found in RIO thresholds");
}
if ((fd = open(RIO_DEVICE, O_RDWR)) < 0) {
- LOG(LOG_ERR, errno, "RIO open\n");
+ LOG(LOG_ERR, errno, "RIO open");
return (QOPERR_SYSCALL);
}
if (ioctl(fd, RIO_SETDEFAULTS, params) < 0) {
- LOG(LOG_ERR, errno, "RIO_SETDEFAULTS\n");
+ LOG(LOG_ERR, errno, "RIO_SETDEFAULTS");
return (QOPERR_SYSCALL);
}
@@ -1400,39 +1398,47 @@ qop_rio_set_defaults(struct redparams *params)
/*
* try to load and open KLD module
+ * (also check the altq device file)
*/
int
open_module(const char *devname, int flags)
{
#if defined(__FreeBSD__) && (__FreeBSD_version > 300000)
- char modname[64], filename[256], *cp;
+ char modname[64], filename[MAXPATHLEN], *cp;
int fd;
+#endif
struct stat sbuf;
+ /* check if the altq device exists */
+ if (stat(devname, &sbuf) < 0) {
+ LOG(LOG_ERR, errno, "can't access %s!", devname);
+ return (-1);
+ }
+
+#if defined(__FreeBSD__) && (__FreeBSD_version > 300000)
/* turn discipline name into module name */
- strcpy(modname, "altq_");
+ strlcpy(modname, "altq_", sizeof(modname));
if ((cp = strrchr(devname, '/')) == NULL)
return (-1);
- strcat(modname, cp+1);
+ strlcat(modname, cp + 1, sizeof(modname));
/* check if the kld module exists */
- sprintf(filename, "/modules/%s.ko", modname);
+ snprintf(filename, sizeof(filename), "/modules/%s.ko", modname);
if (stat(filename, &sbuf) < 0) {
/* module file doesn't exist */
return (-1);
}
if (kldload(modname) < 0) {
- LOG(LOG_ERR, errno, "kldload %s failed!\n", modname);
+ LOG(LOG_ERR, errno, "kldload %s failed!", modname);
return (-1);
}
/* successfully loaded, open the device */
- LOG(LOG_INFO, 0, "kld module %s loaded\n", modname);
+ LOG(LOG_INFO, 0, "kld module %s loaded", modname);
fd = open(devname, flags);
return (fd);
#else
return (-1);
#endif
}
-
diff --git a/usr.sbin/altq/libaltq/qop_blue.c b/usr.sbin/altq/libaltq/qop_blue.c
index a9dd8269a57..e3a2d61ffbf 100644
--- a/usr.sbin/altq/libaltq/qop_blue.c
+++ b/usr.sbin/altq/libaltq/qop_blue.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qop_blue.c,v 1.1 2001/06/27 18:23:27 kjc Exp $ */
-/* $KAME: qop_blue.c,v 1.3 2000/10/18 09:15:18 kjc Exp $ */
+/* $OpenBSD: qop_blue.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qop_blue.c,v 1.5 2001/08/16 10:39:13 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -50,10 +50,10 @@
#include "altq_qop.h"
#include "qop_blue.h"
-static int blue_attach(struct ifinfo *ifinfo);
-static int blue_detach(struct ifinfo *ifinfo);
-static int blue_enable(struct ifinfo *ifinfo);
-static int blue_disable(struct ifinfo *ifinfo);
+static int blue_attach(struct ifinfo *);
+static int blue_detach(struct ifinfo *);
+static int blue_enable(struct ifinfo *);
+static int blue_disable(struct ifinfo *);
#define BLUE_DEVICE "/dev/altq/blue"
@@ -125,7 +125,7 @@ blue_interface_parser(const char *ifname, int argc, char **argv)
} else if (EQUAL(*argv, "ecn")) {
flags |= BLUEF_ECN;
} else {
- LOG(LOG_ERR, 0, "Unknown keyword '%s'\n", argv);
+ LOG(LOG_ERR, 0, "Unknown keyword '%s'", argv);
return (0);
}
argc--; argv++;
@@ -154,7 +154,7 @@ qcmd_blue_add_if(const char *ifname, u_int bandwidth, int max_pmark,
error = qop_blue_add_if(NULL, ifname, bandwidth, max_pmark, hold_time,
qlimit, pkttime, flags);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: can't add blue on interface '%s'\n",
+ LOG(LOG_ERR, errno, "%s: can't add blue on interface '%s'",
qoperror(error), ifname);
return (error);
}
@@ -204,7 +204,7 @@ blue_attach(struct ifinfo *ifinfo)
if (blue_fd < 0 &&
(blue_fd = open(BLUE_DEVICE, O_RDWR)) < 0 &&
(blue_fd = open_module(BLUE_DEVICE, O_RDWR)) < 0) {
- LOG(LOG_ERR, errno, "BLUE open\n");
+ LOG(LOG_ERR, errno, "BLUE open");
return (QOPERR_SYSCALL);
}
@@ -228,7 +228,7 @@ blue_attach(struct ifinfo *ifinfo)
return (QOPERR_SYSCALL);
#if 1
- LOG(LOG_INFO, 0, "blue attached to %s\n", iface.blue_ifname);
+ LOG(LOG_INFO, 0, "blue attached to %s", iface.blue_ifname);
#endif
return (0);
}
diff --git a/usr.sbin/altq/libaltq/qop_cbq.c b/usr.sbin/altq/libaltq/qop_cbq.c
index 2e627090dde..7cc35b3aca2 100644
--- a/usr.sbin/altq/libaltq/qop_cbq.c
+++ b/usr.sbin/altq/libaltq/qop_cbq.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qop_cbq.c,v 1.1 2001/06/27 18:23:29 kjc Exp $ */
-/* $KAME: qop_cbq.c,v 1.3 2000/10/18 09:15:18 kjc Exp $ */
+/* $OpenBSD: qop_cbq.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qop_cbq.c,v 1.5 2001/08/16 10:39:14 kjc Exp $ */
/*
* Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved.
*
@@ -55,27 +55,25 @@
#include "altq_qop.h"
#include "qop_cbq.h"
-static int qcmd_cbq_add_ctl_filters(const char *ifname, const char *clname);
+static int qcmd_cbq_add_ctl_filters(const char *, const char *);
-static int qop_cbq_enable_hook(struct ifinfo *ifinfo);
-static int qop_cbq_delete_class_hook(struct classinfo *clinfo);
+static int qop_cbq_enable_hook(struct ifinfo *);
+static int qop_cbq_delete_class_hook(struct classinfo *);
-static int cbq_class_spec(struct ifinfo *ifinfo, u_long parent_class,
- u_long borrow_class, u_int pri, int flags,
- u_int bandwidth, u_int maxdelay, u_int maxburst,
- u_int minburst, u_int av_pkt_size,
- u_int max_pkt_size, cbq_class_spec_t *cl_spec);
+static int cbq_class_spec(struct ifinfo *, u_long, u_long, u_int, int,
+ u_int, u_int, u_int, u_int, u_int,
+ u_int, cbq_class_spec_t *);
-static int cbq_attach(struct ifinfo *ifinfo);
-static int cbq_detach(struct ifinfo *ifinfo);
-static int cbq_clear(struct ifinfo *ifinfo);
-static int cbq_enable(struct ifinfo *ifinfo);
-static int cbq_disable(struct ifinfo *ifinfo);
-static int cbq_add_class(struct classinfo *clinfo);
-static int cbq_modify_class(struct classinfo *clinfo, void *arg);
-static int cbq_delete_class(struct classinfo *clinfo);
-static int cbq_add_filter(struct fltrinfo *fltrinfo);
-static int cbq_delete_filter(struct fltrinfo *fltrinfo);
+static int cbq_attach(struct ifinfo *);
+static int cbq_detach(struct ifinfo *);
+static int cbq_clear(struct ifinfo *);
+static int cbq_enable(struct ifinfo *);
+static int cbq_disable(struct ifinfo *);
+static int cbq_add_class(struct classinfo *);
+static int cbq_modify_class(struct classinfo *, void *);
+static int cbq_delete_class(struct classinfo *);
+static int cbq_add_filter(struct fltrinfo *);
+static int cbq_delete_filter(struct fltrinfo *);
#define CTL_PBANDWIDTH 2
#define NS_PER_MS (1000000.0)
@@ -136,7 +134,7 @@ cbq_interface_parser(const char *ifname, int argc, char **argv)
} else if (EQUAL(*argv, "cbq-prr")) {
is_wrr = 0;
} else {
- LOG(LOG_ERR, 0, "Unknown keyword '%s'\n", argv);
+ LOG(LOG_ERR, 0, "Unknown keyword '%s'", argv);
return (0);
}
argc--; argv++;
@@ -195,7 +193,7 @@ cbq_class_parser(const char *ifname, const char *class_name,
admission_type = CBQ_QOS_NONE;
else {
LOG(LOG_ERR, 0,
- "unknown admission type - %s, line %d\n",
+ "unknown admission type - %s, line %d",
*argv, line_no);
return (0);
}
@@ -220,7 +218,7 @@ cbq_class_parser(const char *ifname, const char *class_name,
pbandwidth = strtoul(*argv, NULL, 0);
if (pbandwidth > 100) {
LOG(LOG_ERR, 0,
- "bad pbandwidth %d for %s!\n",
+ "bad pbandwidth %d for %s!",
pbandwidth, class_name);
return (0);
}
@@ -256,7 +254,7 @@ cbq_class_parser(const char *ifname, const char *class_name,
flags |= CBQCLF_CLEARDSCP;
} else {
LOG(LOG_ERR, 0,
- "Unknown keyword '%s' in %s, line %d\n",
+ "Unknown keyword '%s' in %s, line %d",
*argv, altqconfigfile, line_no);
return (0);
}
@@ -266,7 +264,7 @@ cbq_class_parser(const char *ifname, const char *class_name,
if ((flags & (CBQCLF_RED|CBQCLF_RIO)) == (CBQCLF_RED|CBQCLF_RIO)) {
LOG(LOG_ERR, 0,
- "both red and rio defined on interface '%s'\n",
+ "both red and rio defined on interface '%s'",
ifname);
return (0);
}
@@ -304,7 +302,7 @@ qcmd_cbq_add_if(const char *ifname, u_int bandwidth, int is_wrr, int efficient)
error = qop_cbq_add_if(NULL, ifname, bandwidth, is_wrr, efficient);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: can't add cbq on interface '%s'\n",
+ LOG(LOG_ERR, errno, "%s: can't add cbq on interface '%s'",
qoperror(error), ifname);
return (error);
}
@@ -356,7 +354,7 @@ qcmd_cbq_add_class(const char *ifname, const char *class_name,
admission_type, flags);
if (error != 0)
LOG(LOG_ERR, errno,
- "cbq: %s: can't add class '%s' on interface '%s'\n",
+ "cbq: %s: can't add class '%s' on interface '%s'",
qoperror(error), class_name, ifname);
if (ctl_bandwidth != 0) {
@@ -432,7 +430,7 @@ qcmd_cbq_add_ctl_filters(const char *ifname, const char *clname)
filter_dontwarn = 0; /* XXX */
if (error) {
LOG(LOG_ERR, 0,
- "can't add ctl class filter on interface '%s'\n",
+ "can't add ctl class filter on interface '%s'",
ifname);
return (error);
}
@@ -448,7 +446,7 @@ qcmd_cbq_add_ctl_filters(const char *ifname, const char *clname)
(struct flow_filter *)&sfilt6);
if (error) {
LOG(LOG_WARNING, 0,
- "can't add ctl class IPv6 filter on interface '%s'\n",
+ "can't add ctl class IPv6 filter on interface '%s'",
ifname);
return (error);
}
@@ -532,14 +530,14 @@ qop_cbq_add_class(struct classinfo **rp, const char *class_name,
parent_clinfo->bandwidth - parent_clinfo->allocated) {
#ifdef ALLOW_OVERCOMMIT
LOG(LOG_WARNING, 0,
- "bandwidth overcommitted %uK requested but only %dK available (%uK already allocated)\n",
+ "bandwidth overcommitted %uK requested but only %dK available (%uK already allocated)",
bandwidth / 1000,
((int)parent_clinfo->bandwidth -
parent_clinfo->allocated) / 1000,
parent_clinfo->allocated / 1000);
#else /* !ALLOW_OVERCOMMIT */
LOG(LOG_ERR, 0,
- "cbq admission failed! %uK requested but only %uK available (%uK already allocated)\n",
+ "cbq admission failed! %uK requested but only %uK available (%uK already allocated)",
bandwidth / 1000,
(parent_clinfo->bandwidth -
parent_clinfo->allocated) / 1000,
@@ -611,7 +609,7 @@ qop_cbq_add_class(struct classinfo **rp, const char *class_name,
case CBQ_QOS_CNTR_DELAY:
if (ifinfo->resv_class != NULL) {
LOG(LOG_ERR, 0,
- "%s: duplicate resv meta class\n", class_name);
+ "%s: duplicate resv meta class", class_name);
return (QOPERR_CLASS);
}
ifinfo->resv_class = clinfo;
@@ -733,12 +731,12 @@ qop_cbq_enable_hook(struct ifinfo *ifinfo)
cbq_ifinfo = ifinfo->private;
if (cbq_ifinfo->root_class == NULL) {
- LOG(LOG_ERR, 0, "cbq: no root class on interface %s!\n",
+ LOG(LOG_ERR, 0, "cbq: no root class on interface %s!",
ifinfo->ifname);
return (QOPERR_CLASS);
}
if (cbq_ifinfo->default_class == NULL) {
- LOG(LOG_ERR, 0, "cbq: no default class on interface %s!\n",
+ LOG(LOG_ERR, 0, "cbq: no default class on interface %s!",
ifinfo->ifname);
return (QOPERR_CLASS);
}
@@ -790,7 +788,7 @@ cbq_class_spec(struct ifinfo *ifinfo, u_long parent_class,
* (bandwidth < 6Kbps when max_pkt_size=1500)
*/
if (bandwidth != 0)
- LOG(LOG_WARNING, 0, "warning: class is too slow!!\n");
+ LOG(LOG_WARNING, 0, "warning: class is too slow!!");
nsPerByte = (double)(INT_MAX / max_pkt_size);
}
#endif
@@ -808,19 +806,19 @@ cbq_class_spec(struct ifinfo *ifinfo, u_long parent_class,
if (IsDebug(DEBUG_ALTQ)) {
int packet_time;
LOG(LOG_DEBUG, 0,
- "cbq_flowspec: maxburst=%d,minburst=%d,pkt_size=%d\n",
+ "cbq_flowspec: maxburst=%d,minburst=%d,pkt_size=%d",
maxburst, minburst, av_pkt_size);
LOG(LOG_DEBUG, 0,
- " nsPerByte=%.2f ns, link's nsPerByte=%.2f, f=%.3f\n",
+ " nsPerByte=%.2f ns, link's nsPerByte=%.2f, f=%.3f",
nsPerByte, cbq_ifinfo->nsPerByte, f);
packet_time = av_pkt_size * (int)nsPerByte / 1000;
LOG(LOG_DEBUG, 0,
" packet time=%d [us]\n", packet_time);
if (maxburst * packet_time < 20000) {
LOG(LOG_WARNING, 0,
- "warning: maxburst smaller than timer granularity!\n");
+ "warning: maxburst smaller than timer granularity!");
LOG(LOG_WARNING, 0,
- " maxburst=%d, packet_time=%d [us]\n",
+ " maxburst=%d, packet_time=%d [us]",
maxburst, packet_time);
}
}
@@ -833,14 +831,14 @@ cbq_class_spec(struct ifinfo *ifinfo, u_long parent_class,
else
maxidle = ptime * maxidle_s;
if (IsDebug(DEBUG_ALTQ))
- LOG(LOG_DEBUG, 0, " maxidle=%.2f us\n", maxidle/1000.0);
+ LOG(LOG_DEBUG, 0, " maxidle=%.2f us", maxidle/1000.0);
if (minburst)
offtime = cptime * (1.0 + 1.0/(1.0 - g) * (1.0 - gtom) / gtom);
else
offtime = cptime;
minidle = -((double)max_pkt_size * (double)nsPerByte);
if (IsDebug(DEBUG_ALTQ))
- LOG(LOG_DEBUG, 0, " offtime=%.2f us minidle=%.2f us\n",
+ LOG(LOG_DEBUG, 0, " offtime=%.2f us minidle=%.2f us",
offtime/1000.0, minidle/1000.0);
maxidle = ((maxidle * 8.0) / nsPerByte) * pow(2, RM_FILTER_GAIN);
@@ -863,7 +861,7 @@ cbq_class_spec(struct ifinfo *ifinfo, u_long parent_class,
maxq = ((double) maxdelay * NS_PER_MS) / (nsPerByte * av_pkt_size);
if (maxq < 4) {
LOG(LOG_WARNING, 0,
- "warning: maxq (%d) is too small. set to %d\n",
+ "warning: maxq (%d) is too small. set to %d",
(int)maxq, 4);
maxq = 4;
}
@@ -874,12 +872,12 @@ cbq_class_spec(struct ifinfo *ifinfo, u_long parent_class,
if (IsDebug(DEBUG_ALTQ)) {
if ((u_int)maxq < maxburst)
LOG(LOG_WARNING, 0,
- "warning: maxq (%d) is smaller than maxburst(%d)\n",
+ "warning: maxq (%d) is smaller than maxburst(%d)",
(int)maxq, maxburst);
else if (maxq > 100.0)
LOG(LOG_WARNING, 0,
"warning: maxq %d too large\n", (int)maxq);
- LOG(LOG_DEBUG, 0, " maxq=%d\n", (int)maxq);
+ LOG(LOG_DEBUG, 0, " maxq=%d", (int)maxq);
}
if (parent_class == NULL_CLASS_HANDLE) {
@@ -920,7 +918,7 @@ cbq_attach(struct ifinfo *ifinfo)
if (cbq_fd < 0 &&
(cbq_fd = open(CBQ_DEVICE, O_RDWR)) < 0 &&
(cbq_fd = open_module(CBQ_DEVICE, O_RDWR)) < 0) {
- LOG(LOG_ERR, errno, "CBQ open\n");
+ LOG(LOG_ERR, errno, "CBQ open");
return (QOPERR_SYSCALL);
}
diff --git a/usr.sbin/altq/libaltq/qop_cdnr.c b/usr.sbin/altq/libaltq/qop_cdnr.c
index 8c490c01581..a59b827f14c 100644
--- a/usr.sbin/altq/libaltq/qop_cdnr.c
+++ b/usr.sbin/altq/libaltq/qop_cdnr.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qop_cdnr.c,v 1.1 2001/06/27 18:23:30 kjc Exp $ */
-/* $KAME: qop_cdnr.c,v 1.6 2000/10/18 09:15:19 kjc Exp $ */
+/* $OpenBSD: qop_cdnr.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qop_cdnr.c,v 1.9 2001/08/16 10:39:14 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -55,17 +55,17 @@
* we use the existing qop interface to support conditioner.
*/
-static struct ifinfo *cdnr_ifname2ifinfo(const char *ifname);
-static int cdnr_attach(struct ifinfo *ifinfo);
-static int cdnr_detach(struct ifinfo *ifinfo);
-static int cdnr_enable(struct ifinfo *ifinfo);
-static int cdnr_disable(struct ifinfo *ifinfo);
-static int cdnr_add_class(struct classinfo *clinfo);
-static int cdnr_modify_class(struct classinfo *clinfo, void *arg);
-static int cdnr_delete_class(struct classinfo *clinfo);
-static int cdnr_add_filter(struct fltrinfo *fltrinfo);
-static int cdnr_delete_filter(struct fltrinfo *fltrinfo);
-static int verify_tbprofile(struct tb_profile *profile, const char *cdnr_name);
+static struct ifinfo *cdnr_ifname2ifinfo(const char *);
+static int cdnr_attach(struct ifinfo *);
+static int cdnr_detach(struct ifinfo *);
+static int cdnr_enable(struct ifinfo *);
+static int cdnr_disable(struct ifinfo *);
+static int cdnr_add_class(struct classinfo *);
+static int cdnr_modify_class(struct classinfo *, void *);
+static int cdnr_delete_class(struct classinfo *);
+static int cdnr_add_filter(struct fltrinfo *);
+static int cdnr_delete_filter(struct fltrinfo *);
+static int verify_tbprofile(struct tb_profile *, const char *);
#define CDNR_DEVICE "/dev/altq/cdnr"
@@ -123,10 +123,10 @@ cdnr_ifname2ifinfo(const char *ifname)
return (NULL);
input_ifname[0] = '_';
- strcpy(input_ifname+1, ifname);
+ strlcpy(input_ifname+1, ifname, sizeof(input_ifname)-1);
if (qop_add_if(&ifinfo, input_ifname, 0, &cdnr_qdisc, NULL) != 0) {
LOG(LOG_ERR, errno,
- "cdnr_ifname2ifinfo: can't add a input interface %s\n",
+ "cdnr_ifname2ifinfo: can't add a input interface %s",
ifname);
return (NULL);
}
@@ -146,7 +146,7 @@ qcmd_cdnr_add_element(struct tc_action *rp, const char *ifname,
if ((error = qop_cdnr_add_element(&clinfo, cdnr_name, ifinfo,
action)) != 0) {
- LOG(LOG_ERR, errno, "%s: add element failed!\n",
+ LOG(LOG_ERR, errno, "%s: add element failed!",
qoperror(error));
return (error);
}
@@ -176,7 +176,7 @@ qcmd_cdnr_add_tbmeter(struct tc_action *rp, const char *ifname,
if ((error = qop_cdnr_add_tbmeter(&clinfo, cdnr_name, ifinfo,
profile, in_action, out_action)) != 0) {
- LOG(LOG_ERR, errno, "%s: add tbmeter failed!\n",
+ LOG(LOG_ERR, errno, "%s: add tbmeter failed!",
qoperror(error));
return (error);
}
@@ -211,7 +211,7 @@ qcmd_cdnr_add_trtcm(struct tc_action *rp, const char *ifname,
cmtd_profile, peak_profile,
green_action, yellow_action, red_action,
coloraware)) != 0) {
- LOG(LOG_ERR, errno, "%s: add trtcm failed!\n",
+ LOG(LOG_ERR, errno, "%s: add trtcm failed!",
qoperror(error));
return (error);
}
@@ -240,7 +240,7 @@ qcmd_cdnr_add_tswtcm(struct tc_action *rp, const char *ifname,
if (cmtd_rate > peak_rate) {
LOG(LOG_ERR, 0,
- "add tswtcm: cmtd_rate larger than peak_rate!\n");
+ "add tswtcm: cmtd_rate larger than peak_rate!");
return (QOPERR_INVAL);
}
@@ -248,7 +248,7 @@ qcmd_cdnr_add_tswtcm(struct tc_action *rp, const char *ifname,
cmtd_rate, peak_rate, avg_interval,
green_action, yellow_action,
red_action)) != 0) {
- LOG(LOG_ERR, errno, "%s: add tswtcm failed!\n",
+ LOG(LOG_ERR, errno, "%s: add tswtcm failed!",
qoperror(error));
return (error);
}
@@ -308,7 +308,7 @@ qop_add_cdnr(struct classinfo **rp, const char *cdnr_name,
if ((error = qop_add_class(&root, "cdnr_root",
ifinfo, NULL, NULL)) != 0) {
LOG(LOG_ERR, errno,
- "cdnr: %s: can't create dummy root cdnr on %s!\n",
+ "cdnr: %s: can't create dummy root cdnr on %s!",
qoperror(error), ifinfo->ifname);
return (QOPERR_CLASS);
}
@@ -362,7 +362,7 @@ qop_delete_cdnr(struct classinfo *clinfo)
int error;
if ((root = get_rootclass(clinfo->ifinfo)) == NULL) {
- LOG(LOG_ERR, 0, "qop_delete_cdnr: no root cdnr!\n");
+ LOG(LOG_ERR, 0, "qop_delete_cdnr: no root cdnr!");
return (QOPERR_CLASS);
}
@@ -671,7 +671,7 @@ cdnr_attach(struct ifinfo *ifinfo)
if (cdnr_fd < 0 &&
(cdnr_fd = open(CDNR_DEVICE, O_RDWR)) < 0 &&
(cdnr_fd = open_module(CDNR_DEVICE, O_RDWR)) < 0) {
- LOG(LOG_ERR, errno, "CDNR open\n");
+ LOG(LOG_ERR, errno, "CDNR open");
return (QOPERR_SYSCALL);
}
@@ -682,7 +682,7 @@ cdnr_attach(struct ifinfo *ifinfo)
if (ioctl(cdnr_fd, CDNR_IF_ATTACH, &iface) < 0)
return (QOPERR_SYSCALL);
#if 1
- LOG(LOG_INFO, 0, "conditioner attached to %s\n", iface.cdnr_ifname);
+ LOG(LOG_INFO, 0, "conditioner attached to %s", iface.cdnr_ifname);
#endif
return (0);
}
@@ -924,7 +924,7 @@ verify_tbprofile(struct tb_profile *profile, const char *cdnr_name)
{
if (profile->depth < 1500) {
LOG(LOG_WARNING, 0,
- "warning: token bucket depth for %s is too small (%d)\n",
+ "warning: token bucket depth for %s is too small (%d)",
cdnr_name, profile->depth);
return (-1);
}
diff --git a/usr.sbin/altq/libaltq/qop_dummy.c b/usr.sbin/altq/libaltq/qop_dummy.c
index b46f0f69814..ab0e59beb34 100644
--- a/usr.sbin/altq/libaltq/qop_dummy.c
+++ b/usr.sbin/altq/libaltq/qop_dummy.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qop_dummy.c,v 1.1 2001/06/27 18:23:30 kjc Exp $ */
-/* $KAME: qop_dummy.c,v 1.2 2000/10/18 09:15:19 kjc Exp $ */
+/* $OpenBSD: qop_dummy.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qop_dummy.c,v 1.4 2001/08/16 10:39:14 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -37,20 +37,19 @@
#include <altq/altq.h>
#include "altq_qop.h"
-int null_interface_parser(const char *ifname, int argc, char **argv);
-int null_class_parser(const char *ifname, const char *class_name,
- const char *parent_name, int argc, char **argv);
-int qcmd_nop_add_if(const char *ifname);
-static int nop_attach(struct ifinfo *ifinfo);
-static int nop_detach(struct ifinfo *ifinfo);
-static int nop_clear(struct ifinfo *ifinfo);
-static int nop_enable(struct ifinfo *ifinfo);
-static int nop_disable(struct ifinfo *ifinfo);
-static int nop_add_class(struct classinfo *clinfo);
-static int nop_modify_class(struct classinfo *clinfo, void *arg);
-static int nop_delete_class(struct classinfo *clinfo);
-static int nop_add_filter(struct fltrinfo *fltrinfo);
-static int nop_delete_filter(struct fltrinfo *fltrinfo);
+int null_interface_parser(const char *, int, char **);
+int null_class_parser(const char *, const char *, const char *, int, char **);
+int qcmd_nop_add_if(const char *);
+static int nop_attach(struct ifinfo *);
+static int nop_detach(struct ifinfo *);
+static int nop_clear(struct ifinfo *);
+static int nop_enable(struct ifinfo *);
+static int nop_disable(struct ifinfo *);
+static int nop_add_class(struct classinfo *);
+static int nop_modify_class(struct classinfo *, void *);
+static int nop_delete_class(struct classinfo *);
+static int nop_add_filter(struct fltrinfo *);
+static int nop_delete_filter(struct fltrinfo *);
struct qdisc_ops nop_qdisc = {
ALTQT_NONE,
@@ -91,7 +90,7 @@ null_interface_parser(const char *ifname, int argc, char **argv)
if (argc > 0)
tbrsize = atobytes(*argv);
} else {
- LOG(LOG_ERR, 0, "Unknown keyword '%s'\n", argv);
+ LOG(LOG_ERR, 0, "Unknown keyword '%s'", argv);
return (0);
}
argc--; argv++;
@@ -114,7 +113,7 @@ null_class_parser(const char *ifname, const char *class_name,
const char *parent_name, int argc, char **argv)
{
LOG(LOG_ERR, 0,
- "class cannot be defined without a queueing discipline in %s, line %d\n",
+ "class cannot be defined without a queueing discipline in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -129,7 +128,7 @@ qcmd_nop_add_if(const char *ifname)
error = qop_add_if(NULL, ifname, 0, &nop_qdisc, NULL);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: can't add nop on interface '%s'\n",
+ LOG(LOG_ERR, errno, "%s: can't add nop on interface '%s'",
qoperror(error), ifname);
return (error);
}
diff --git a/usr.sbin/altq/libaltq/qop_fifoq.c b/usr.sbin/altq/libaltq/qop_fifoq.c
index cedf6a46eb9..3ba1f60d097 100644
--- a/usr.sbin/altq/libaltq/qop_fifoq.c
+++ b/usr.sbin/altq/libaltq/qop_fifoq.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qop_fifoq.c,v 1.1 2001/06/27 18:23:31 kjc Exp $ */
-/* $KAME: qop_fifoq.c,v 1.3 2000/10/18 09:15:19 kjc Exp $ */
+/* $OpenBSD: qop_fifoq.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qop_fifoq.c,v 1.5 2001/08/16 10:39:14 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -50,10 +50,10 @@
#include "altq_qop.h"
#include "qop_fifoq.h"
-static int fifoq_attach(struct ifinfo *ifinfo);
-static int fifoq_detach(struct ifinfo *ifinfo);
-static int fifoq_enable(struct ifinfo *ifinfo);
-static int fifoq_disable(struct ifinfo *ifinfo);
+static int fifoq_attach(struct ifinfo *);
+static int fifoq_detach(struct ifinfo *);
+static int fifoq_enable(struct ifinfo *);
+static int fifoq_disable(struct ifinfo *);
#define FIFOQ_DEVICE "/dev/altq/fifoq"
@@ -106,7 +106,7 @@ fifoq_interface_parser(const char *ifname, int argc, char **argv)
} else if (EQUAL(*argv, "fifoq")) {
/* just skip */
} else {
- LOG(LOG_ERR, 0, "Unknown keyword '%s'\n", argv);
+ LOG(LOG_ERR, 0, "Unknown keyword '%s'", argv);
return (0);
}
argc--; argv++;
@@ -130,7 +130,7 @@ qcmd_fifoq_add_if(const char *ifname, u_int bandwidth, int qlimit)
error = qop_fifoq_add_if(NULL, ifname, bandwidth, qlimit);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: can't add fifoq on interface '%s'\n",
+ LOG(LOG_ERR, errno, "%s: can't add fifoq on interface '%s'",
qoperror(error), ifname);
return (error);
}
@@ -175,7 +175,7 @@ fifoq_attach(struct ifinfo *ifinfo)
if (fifoq_fd < 0 &&
(fifoq_fd = open(FIFOQ_DEVICE, O_RDWR)) < 0 &&
(fifoq_fd = open_module(FIFOQ_DEVICE, O_RDWR)) < 0) {
- LOG(LOG_ERR, errno, "FIFOQ open\n");
+ LOG(LOG_ERR, errno, "FIFOQ open");
return (QOPERR_SYSCALL);
}
@@ -196,7 +196,7 @@ fifoq_attach(struct ifinfo *ifinfo)
return (QOPERR_SYSCALL);
}
#if 1
- LOG(LOG_INFO, 0, "fifoq attached to %s\n", iface.fifoq_ifname);
+ LOG(LOG_INFO, 0, "fifoq attached to %s", iface.fifoq_ifname);
#endif
return (0);
}
diff --git a/usr.sbin/altq/libaltq/qop_hfsc.c b/usr.sbin/altq/libaltq/qop_hfsc.c
index b9e9d40a532..b83e3d376d5 100644
--- a/usr.sbin/altq/libaltq/qop_hfsc.c
+++ b/usr.sbin/altq/libaltq/qop_hfsc.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qop_hfsc.c,v 1.1 2001/06/27 18:23:33 kjc Exp $ */
-/* $KAME: qop_hfsc.c,v 1.4 2000/10/18 09:15:19 kjc Exp $ */
+/* $OpenBSD: qop_hfsc.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qop_hfsc.c,v 1.6 2001/08/16 10:39:14 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -50,34 +50,31 @@
#include "altq_qop.h"
#include "qop_hfsc.h"
-static int read_sc(int *argcp, char ***argvp,
- int *type, u_int *m1, u_int *d, u_int *m2);
-static int qop_hfsc_enable_hook(struct ifinfo *ifinfo);
-static int qop_hfsc_delete_class_hook(struct classinfo *clinfo);
-static int validate_sc(struct service_curve *sc);
-
-static void gsc_add_sc(struct gen_sc *gsc, struct service_curve *sc);
-static void gsc_sub_sc(struct gen_sc *gsc, struct service_curve *sc);
-static int is_gsc_under_sc(struct gen_sc *gsc, struct service_curve *sc);
-static void gsc_destroy(struct gen_sc *gsc);
-static struct segment *gsc_getentry(struct gen_sc *gsc, double x);
-static int gsc_add_seg(struct gen_sc *gsc,
- double x, double y, double d, double m);
-static int gsc_sub_seg(struct gen_sc *gsc,
- double x, double y, double d, double m);
-static void gsc_compress(struct gen_sc *gsc);
-static double sc_x2y(struct service_curve *sc, double x);
-
-static int hfsc_attach(struct ifinfo *ifinfo);
-static int hfsc_detach(struct ifinfo *ifinfo);
-static int hfsc_clear(struct ifinfo *ifinfo);
-static int hfsc_enable(struct ifinfo *ifinfo);
-static int hfsc_disable(struct ifinfo *ifinfo);
-static int hfsc_add_class(struct classinfo *clinfo);
-static int hfsc_modify_class(struct classinfo *clinfo, void *arg);
-static int hfsc_delete_class(struct classinfo *clinfo);
-static int hfsc_add_filter(struct fltrinfo *fltrinfo);
-static int hfsc_delete_filter(struct fltrinfo *fltrinfo);
+static int read_sc(int *, char ***, int *, u_int *, u_int *, u_int *);
+static int qop_hfsc_enable_hook(struct ifinfo *);
+static int qop_hfsc_delete_class_hook(struct classinfo *);
+static int validate_sc(struct service_curve *);
+
+static void gsc_add_sc(struct gen_sc *, struct service_curve *);
+static void gsc_sub_sc(struct gen_sc *, struct service_curve *);
+static int is_gsc_under_sc(struct gen_sc *, struct service_curve *);
+static void gsc_destroy(struct gen_sc *);
+static struct segment *gsc_getentry(struct gen_sc *, double);
+static int gsc_add_seg(struct gen_sc *, double, double, double, double);
+static int gsc_sub_seg(struct gen_sc *, double, double, double, double);
+static void gsc_compress(struct gen_sc *);
+static double sc_x2y(struct service_curve *, double);
+
+static int hfsc_attach(struct ifinfo *);
+static int hfsc_detach(struct ifinfo *);
+static int hfsc_clear(struct ifinfo *);
+static int hfsc_enable(struct ifinfo *);
+static int hfsc_disable(struct ifinfo *);
+static int hfsc_add_class(struct classinfo *);
+static int hfsc_modify_class(struct classinfo *, void *);
+static int hfsc_delete_class(struct classinfo *);
+static int hfsc_add_filter(struct fltrinfo *);
+static int hfsc_delete_filter(struct fltrinfo *);
#define HFSC_DEVICE "/dev/altq/hfsc"
@@ -126,7 +123,7 @@ hfsc_interface_parser(const char *ifname, int argc, char **argv)
} else if (EQUAL(*argv, "hfsc")) {
/* just skip */
} else {
- LOG(LOG_ERR, 0, "Unknown keyword '%s'\n", argv);
+ LOG(LOG_ERR, 0, "Unknown keyword '%s'", argv);
return (0);
}
argc--; argv++;
@@ -154,7 +151,7 @@ hfsc_class_parser(const char *ifname, const char *class_name,
if (*argv[0] == '[') {
if (read_sc(&argc, &argv, &type, &m1, &d, &m2) != 0) {
LOG(LOG_ERR, 0,
- "Bad service curve in %s, line %d\n",
+ "Bad service curve in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -198,7 +195,7 @@ hfsc_class_parser(const char *ifname, const char *class_name,
/* nothing */
} else {
LOG(LOG_ERR, 0,
- "unknown admission type - %s, line %d\n",
+ "unknown admission type - %s, line %d",
*argv, line_no);
return (0);
}
@@ -213,7 +210,7 @@ hfsc_class_parser(const char *ifname, const char *class_name,
flags |= HFCF_CLEARDSCP;
} else {
LOG(LOG_ERR, 0,
- "Unknown keyword '%s' in %s, line %d\n",
+ "Unknown keyword '%s' in %s, line %d",
*argv, altqconfigfile, line_no);
return (0);
}
@@ -223,7 +220,7 @@ hfsc_class_parser(const char *ifname, const char *class_name,
if (type == 0) {
LOG(LOG_ERR, 0,
- "hfsc: service curve not specified in %s, line %d\n",
+ "hfsc: service curve not specified in %s, line %d",
altqconfigfile, line_no);
return (0);
}
@@ -261,7 +258,7 @@ hfsc_class_parser(const char *ifname, const char *class_name,
if (ifinfo->resv_class != NULL) {
LOG(LOG_ERR, 0,
- "more than one admission class specified: %s\n",
+ "more than one admission class specified: %s",
class_name);
return (0);
}
@@ -269,7 +266,7 @@ hfsc_class_parser(const char *ifname, const char *class_name,
}
if (error) {
- LOG(LOG_ERR, errno, "hfsc_class_parser: %s\n",
+ LOG(LOG_ERR, errno, "hfsc_class_parser: %s",
qoperror(error));
return (0);
}
@@ -328,7 +325,7 @@ qcmd_hfsc_add_if(const char *ifname, u_int bandwidth, int flags)
error = qop_hfsc_add_if(NULL, ifname, bandwidth, flags);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: can't add hfsc on interface '%s'\n",
+ LOG(LOG_ERR, errno, "%s: can't add hfsc on interface '%s'",
qoperror(error), ifname);
return (error);
}
@@ -359,7 +356,7 @@ qcmd_hfsc_add_class(const char *ifname, const char *class_name,
&sc, qlimit, flags);
if (error != 0)
LOG(LOG_ERR, errno,
- "hfsc: %s: can't add class '%s' on interface '%s'\n",
+ "hfsc: %s: can't add class '%s' on interface '%s'",
qoperror(error), class_name, ifname);
return (error);
}
@@ -415,7 +412,7 @@ qop_hfsc_add_if(struct ifinfo **rp, const char *ifname,
if ((error = qop_hfsc_add_class(&hfsc_ifinfo->root_class, "root",
ifinfo, NULL, &sc, 0, 0)) != 0) {
LOG(LOG_ERR, errno,
- "hfsc: %s: can't create dummy root class on %s!\n",
+ "hfsc: %s: can't create dummy root class on %s!",
qoperror(error), ifname);
(void)qop_delete_if(ifinfo);
return (QOPERR_CLASS);
@@ -636,18 +633,19 @@ qop_hfsc_enable_hook(struct ifinfo *ifinfo)
hfsc_ifinfo = ifinfo->private;
if (hfsc_ifinfo->default_class == NULL) {
- LOG(LOG_ERR, 0, "hfsc: no default class on interface %s!\n",
+ LOG(LOG_ERR, 0, "hfsc: no default class on interface %s!",
ifinfo->ifname);
return (QOPERR_CLASS);
} else if (hfsc_ifinfo->default_class->child != NULL) {
- LOG(LOG_ERR, 0, "hfsc: default class on %s must be a leaf!\n",
+ LOG(LOG_ERR, 0, "hfsc: default class on %s must be a leaf!",
ifinfo->ifname);
return (QOPERR_CLASS);
}
LIST_FOREACH(clinfo, &ifinfo->cllist, next) {
if (clinfo->child != NULL && !LIST_EMPTY(&clinfo->fltrlist)) {
- LOG(LOG_ERR, 0, "hfsc: internal class \"%s\" should not have a filter!\n",
+ LOG(LOG_ERR, 0,
+ "hfsc: internal class \"%s\" should not have a filter!",
clinfo->clname);
return (QOPERR_CLASS);
}
@@ -661,7 +659,7 @@ validate_sc(struct service_curve *sc)
{
/* the 1st segment of a concave curve must be zero */
if (sc->m1 < sc->m2 && sc->m1 != 0) {
- LOG(LOG_ERR, 0, "m1 must be 0 for convex!\n");
+ LOG(LOG_ERR, 0, "m1 must be 0 for convex!");
return (-1);
}
return (0);
@@ -913,7 +911,7 @@ hfsc_attach(struct ifinfo *ifinfo)
if (hfsc_fd < 0 &&
(hfsc_fd = open(HFSC_DEVICE, O_RDWR)) < 0 &&
(hfsc_fd = open_module(HFSC_DEVICE, O_RDWR)) < 0) {
- LOG(LOG_ERR, errno, "HFSC open\n");
+ LOG(LOG_ERR, errno, "HFSC open");
return (QOPERR_SYSCALL);
}
diff --git a/usr.sbin/altq/libaltq/qop_priq.c b/usr.sbin/altq/libaltq/qop_priq.c
index 71bbb947248..1387d27bc13 100644
--- a/usr.sbin/altq/libaltq/qop_priq.c
+++ b/usr.sbin/altq/libaltq/qop_priq.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qop_priq.c,v 1.1 2001/06/27 18:23:34 kjc Exp $ */
-/* $KAME: qop_priq.c,v 1.1 2000/10/18 09:15:19 kjc Exp $ */
+/* $OpenBSD: qop_priq.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qop_priq.c,v 1.3 2001/08/16 10:39:14 kjc Exp $ */
/*
* Copyright (C) 2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -50,18 +50,18 @@
#include "altq_qop.h"
#include "qop_priq.h"
-static int qop_priq_enable_hook(struct ifinfo *ifinfo);
+static int qop_priq_enable_hook(struct ifinfo *);
-static int priq_attach(struct ifinfo *ifinfo);
-static int priq_detach(struct ifinfo *ifinfo);
-static int priq_clear(struct ifinfo *ifinfo);
-static int priq_enable(struct ifinfo *ifinfo);
-static int priq_disable(struct ifinfo *ifinfo);
-static int priq_add_class(struct classinfo *clinfo);
-static int priq_modify_class(struct classinfo *clinfo, void *arg);
-static int priq_delete_class(struct classinfo *clinfo);
-static int priq_add_filter(struct fltrinfo *fltrinfo);
-static int priq_delete_filter(struct fltrinfo *fltrinfo);
+static int priq_attach(struct ifinfo *);
+static int priq_detach(struct ifinfo *);
+static int priq_clear(struct ifinfo *);
+static int priq_enable(struct ifinfo *);
+static int priq_disable(struct ifinfo *);
+static int priq_add_class(struct classinfo *);
+static int priq_modify_class(struct classinfo *, void *);
+static int priq_delete_class(struct classinfo *);
+static int priq_add_filter(struct fltrinfo *);
+static int priq_delete_filter(struct fltrinfo *);
#define PRIQ_DEVICE "/dev/altq/priq"
@@ -110,7 +110,7 @@ priq_interface_parser(const char *ifname, int argc, char **argv)
} else if (EQUAL(*argv, "priq")) {
/* just skip */
} else {
- LOG(LOG_ERR, 0, "Unknown keyword '%s'\n", argv);
+ LOG(LOG_ERR, 0, "Unknown keyword '%s'", argv);
return (0);
}
argc--; argv++;
@@ -152,7 +152,7 @@ priq_class_parser(const char *ifname, const char *class_name,
flags |= PRCF_CLEARDSCP;
} else {
LOG(LOG_ERR, 0,
- "Unknown keyword '%s' in %s, line %d\n",
+ "Unknown keyword '%s' in %s, line %d",
*argv, altqconfigfile, line_no);
return (0);
}
@@ -166,7 +166,7 @@ priq_class_parser(const char *ifname, const char *class_name,
error = qcmd_priq_add_class(ifname, class_name, pri, qlimit, flags);
if (error) {
- LOG(LOG_ERR, errno, "priq_class_parser: %s\n",
+ LOG(LOG_ERR, errno, "priq_class_parser: %s",
qoperror(error));
return (0);
}
@@ -183,7 +183,7 @@ qcmd_priq_add_if(const char *ifname, u_int bandwidth, int flags)
error = qop_priq_add_if(NULL, ifname, bandwidth, flags);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: can't add priq on interface '%s'\n",
+ LOG(LOG_ERR, errno, "%s: can't add priq on interface '%s'",
qoperror(error), ifname);
return (error);
}
@@ -203,7 +203,7 @@ qcmd_priq_add_class(const char *ifname, const char *class_name,
pri, qlimit, flags);
if (error != 0)
LOG(LOG_ERR, errno,
- "priq: %s: can't add class '%s' on interface '%s'\n",
+ "priq: %s: can't add class '%s' on interface '%s'",
qoperror(error), class_name, ifname);
return (error);
}
@@ -334,7 +334,7 @@ qop_priq_enable_hook(struct ifinfo *ifinfo)
priq_ifinfo = ifinfo->private;
if (priq_ifinfo->default_class == NULL) {
- LOG(LOG_ERR, 0, "priq: no default class on interface %s!\n",
+ LOG(LOG_ERR, 0, "priq: no default class on interface %s!",
ifinfo->ifname);
return (QOPERR_CLASS);
}
@@ -355,7 +355,7 @@ priq_attach(struct ifinfo *ifinfo)
if (priq_fd < 0 &&
(priq_fd = open(PRIQ_DEVICE, O_RDWR)) < 0 &&
(priq_fd = open_module(PRIQ_DEVICE, O_RDWR)) < 0) {
- LOG(LOG_ERR, errno, "PRIQ open\n");
+ LOG(LOG_ERR, errno, "PRIQ open");
return (QOPERR_SYSCALL);
}
diff --git a/usr.sbin/altq/libaltq/qop_red.c b/usr.sbin/altq/libaltq/qop_red.c
index 516d55a2e43..233b82b84cb 100644
--- a/usr.sbin/altq/libaltq/qop_red.c
+++ b/usr.sbin/altq/libaltq/qop_red.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qop_red.c,v 1.1 2001/06/27 18:23:35 kjc Exp $ */
-/* $KAME: qop_red.c,v 1.3 2000/10/18 09:15:19 kjc Exp $ */
+/* $OpenBSD: qop_red.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qop_red.c,v 1.5 2001/08/16 10:39:14 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -50,10 +50,10 @@
#include "altq_qop.h"
#include "qop_red.h"
-static int red_attach(struct ifinfo *ifinfo);
-static int red_detach(struct ifinfo *ifinfo);
-static int red_enable(struct ifinfo *ifinfo);
-static int red_disable(struct ifinfo *ifinfo);
+static int red_attach(struct ifinfo *);
+static int red_detach(struct ifinfo *);
+static int red_enable(struct ifinfo *);
+static int red_disable(struct ifinfo *);
#define RED_DEVICE "/dev/altq/red"
@@ -137,7 +137,7 @@ red_interface_parser(const char *ifname, int argc, char **argv)
} else if (EQUAL(*argv, "flowvalve")) {
flags |= REDF_FLOWVALVE;
} else {
- LOG(LOG_ERR, 0, "Unknown keyword '%s'\n", argv);
+ LOG(LOG_ERR, 0, "Unknown keyword '%s'", argv);
return (0);
}
argc--; argv++;
@@ -181,7 +181,7 @@ qcmd_red_add_if(const char *ifname, u_int bandwidth, int weight,
error = qop_red_add_if(NULL, ifname, bandwidth, weight, inv_pmax,
th_min, th_max, qlimit, pkttime, flags);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: can't add red on interface '%s'\n",
+ LOG(LOG_ERR, errno, "%s: can't add red on interface '%s'",
qoperror(error), ifname);
return (error);
}
@@ -233,7 +233,7 @@ red_attach(struct ifinfo *ifinfo)
if (red_fd < 0 &&
(red_fd = open(RED_DEVICE, O_RDWR)) < 0 &&
(red_fd = open_module(RED_DEVICE, O_RDWR)) < 0) {
- LOG(LOG_ERR, errno, "RED open\n");
+ LOG(LOG_ERR, errno, "RED open");
return (QOPERR_SYSCALL);
}
@@ -258,7 +258,7 @@ red_attach(struct ifinfo *ifinfo)
return (QOPERR_SYSCALL);
#if 1
- LOG(LOG_INFO, 0, "red attached to %s\n", iface.red_ifname);
+ LOG(LOG_INFO, 0, "red attached to %s", iface.red_ifname);
#endif
return (0);
}
diff --git a/usr.sbin/altq/libaltq/qop_rio.c b/usr.sbin/altq/libaltq/qop_rio.c
index 792d792a6b5..009306db601 100644
--- a/usr.sbin/altq/libaltq/qop_rio.c
+++ b/usr.sbin/altq/libaltq/qop_rio.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qop_rio.c,v 1.1 2001/06/27 18:23:35 kjc Exp $ */
-/* $KAME: qop_rio.c,v 1.3 2000/10/18 09:15:20 kjc Exp $ */
+/* $OpenBSD: qop_rio.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qop_rio.c,v 1.5 2001/08/16 10:39:15 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -51,10 +51,10 @@
#include "altq_qop.h"
#include "qop_rio.h"
-static int rio_attach(struct ifinfo *ifinfo);
-static int rio_detach(struct ifinfo *ifinfo);
-static int rio_enable(struct ifinfo *ifinfo);
-static int rio_disable(struct ifinfo *ifinfo);
+static int rio_attach(struct ifinfo *);
+static int rio_detach(struct ifinfo *);
+static int rio_enable(struct ifinfo *);
+static int rio_disable(struct ifinfo *);
#define RIO_DEVICE "/dev/altq/rio"
@@ -166,7 +166,7 @@ rio_interface_parser(const char *ifname, int argc, char **argv)
} else if (EQUAL(*argv, "ecn")) {
flags |= RIOF_ECN;
} else {
- LOG(LOG_ERR, 0, "Unknown keyword '%s'\n", argv);
+ LOG(LOG_ERR, 0, "Unknown keyword '%s'", argv);
return (0);
}
argc--; argv++;
@@ -226,7 +226,7 @@ qcmd_rio_add_if(const char *ifname, u_int bandwidth, int weight,
error = qop_rio_add_if(NULL, ifname, bandwidth, weight, red_params,
qlimit, pkttime, flags);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: can't add rio on interface '%s'\n",
+ LOG(LOG_ERR, errno, "%s: can't add rio on interface '%s'",
qoperror(error), ifname);
return (error);
}
@@ -278,7 +278,7 @@ rio_attach(struct ifinfo *ifinfo)
if (rio_fd < 0 &&
(rio_fd = open(RIO_DEVICE, O_RDWR)) < 0 &&
(rio_fd = open_module(RIO_DEVICE, O_RDWR)) < 0) {
- LOG(LOG_ERR, errno, "RIO open\n");
+ LOG(LOG_ERR, errno, "RIO open");
return (QOPERR_SYSCALL);
}
@@ -302,7 +302,7 @@ rio_attach(struct ifinfo *ifinfo)
return (QOPERR_SYSCALL);
#if 1
- LOG(LOG_INFO, 0, "rio attached to %s\n", iface.rio_ifname);
+ LOG(LOG_INFO, 0, "rio attached to %s", iface.rio_ifname);
#endif
return (0);
}
diff --git a/usr.sbin/altq/libaltq/qop_wfq.c b/usr.sbin/altq/libaltq/qop_wfq.c
index 72dc0bf2b09..4b77b7aaa4b 100644
--- a/usr.sbin/altq/libaltq/qop_wfq.c
+++ b/usr.sbin/altq/libaltq/qop_wfq.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: qop_wfq.c,v 1.1 2001/06/27 18:23:36 kjc Exp $ */
-/* $KAME: qop_wfq.c,v 1.3 2000/10/18 09:15:20 kjc Exp $ */
+/* $OpenBSD: qop_wfq.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: qop_wfq.c,v 1.5 2001/08/16 10:39:15 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -50,10 +50,10 @@
#include "altq_qop.h"
#include "qop_wfq.h"
-static int wfq_attach(struct ifinfo *ifinfo);
-static int wfq_detach(struct ifinfo *ifinfo);
-static int wfq_enable(struct ifinfo *ifinfo);
-static int wfq_disable(struct ifinfo *ifinfo);
+static int wfq_attach(struct ifinfo *);
+static int wfq_detach(struct ifinfo *);
+static int wfq_enable(struct ifinfo *);
+static int wfq_disable(struct ifinfo *);
#define WFQ_DEVICE "/dev/altq/wfq"
@@ -120,7 +120,7 @@ wfq_interface_parser(const char *ifname, int argc, char **argv)
hash_policy = WFQ_HASH_SRCPORT;
else {
LOG(LOG_ERR, 0,
- "Unknown hash policy '%s'\n",
+ "Unknown hash policy '%s'",
argv);
return (0);
}
@@ -128,7 +128,7 @@ wfq_interface_parser(const char *ifname, int argc, char **argv)
} else if (EQUAL(*argv, "wfq")) {
/* just skip */
} else {
- LOG(LOG_ERR, 0, "Unknown keyword '%s'\n", argv);
+ LOG(LOG_ERR, 0, "Unknown keyword '%s'", argv);
return (0);
}
argc--; argv++;
@@ -160,7 +160,7 @@ qcmd_wfq_add_if(const char *ifname, u_int bandwidth, int hash_policy,
error = qop_wfq_add_if(NULL, ifname, bandwidth,
hash_policy, nqueues, qsize);
if (error != 0)
- LOG(LOG_ERR, errno, "%s: can't add wfq on interface '%s'\n",
+ LOG(LOG_ERR, errno, "%s: can't add wfq on interface '%s'",
qoperror(error), ifname);
return (error);
}
@@ -207,7 +207,7 @@ wfq_attach(struct ifinfo *ifinfo)
if (wfq_fd < 0 &&
(wfq_fd = open(WFQ_DEVICE, O_RDWR)) < 0 &&
(wfq_fd = open_module(WFQ_DEVICE, O_RDWR)) < 0) {
- LOG(LOG_ERR, errno, "WFQ open\n");
+ LOG(LOG_ERR, errno, "WFQ open");
return (QOPERR_SYSCALL);
}
@@ -228,12 +228,12 @@ wfq_attach(struct ifinfo *ifinfo)
conf.nqueues = wfq_ifinfo->nqueues;
conf.qlimit = wfq_ifinfo->qsize;
if (ioctl(wfq_fd, WFQ_CONFIG, &conf) < 0) {
- LOG(LOG_ERR, errno, "WFQ_CONFIG\n");
+ LOG(LOG_ERR, errno, "WFQ_CONFIG");
return (QOPERR_SYSCALL);
}
}
#if 1
- LOG(LOG_INFO, 0, "wfq attached to %s\n", iface.wfq_ifacename);
+ LOG(LOG_INFO, 0, "wfq attached to %s", iface.wfq_ifacename);
#endif
return (0);
}
diff --git a/usr.sbin/altq/libaltq/quip_server.c b/usr.sbin/altq/libaltq/quip_server.c
index 2d7b7a56877..c41dd1bf2d9 100644
--- a/usr.sbin/altq/libaltq/quip_server.c
+++ b/usr.sbin/altq/libaltq/quip_server.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: quip_server.c,v 1.1 2001/06/27 18:23:31 kjc Exp $ */
-/* $KAME: quip_server.c,v 1.2 2000/10/18 09:15:21 kjc Exp $ */
+/* $OpenBSD: quip_server.c,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: quip_server.c,v 1.5 2001/08/16 07:43:17 itojun Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -53,21 +53,22 @@ extern LIST_HEAD(qop_iflist, ifinfo) qop_iflist;
#define EQUAL(s1, s2) (strcmp((s1), (s2)) == 0)
-static int next_word(char **cpp, char *b);
+static int next_word(char **, char *);
-static int query_list(const char *cmd, const char *arg, char *msg);
-static int query_handle2name(const char *cmd, const char *arg, char *msg);
-static int query_qdisc(const char *cmd, const char *arg, char *msg);
-static int query_filterspec(const char *cmd, const char *arg, char *msg);
+static int query_list(const char *, const char *, char *, size_t);
+static int query_handle2name(const char *, const char *, char *, size_t);
+static int query_qdisc(const char *, const char *, char *, size_t);
+static int query_filterspec(const char *, const char *, char *, size_t);
int
quip_input(FILE *fp)
{
- char request[256], result[256], body[8192], w[256], *cp, *query;
+ char request[REQ_MAXSIZE], result[RES_MAXSIZE], body[BODY_MAXSIZE],
+ w[REQ_MAXSIZE], *cp, *query;
int n = 0;
while (1) {
- if (fgets(request, 128, fp) == NULL) /* EOF */
+ if (fgets(request, REQ_MAXSIZE, fp) == NULL) /* EOF */
return (-1);
/* skip preceding blank lines */
if (request[0] == '\n')
@@ -85,12 +86,12 @@ quip_input(FILE *fp)
body[0] = '\0';
cp = request;
if (!next_word(&cp, w)) {
- sprintf(result, "400 Bad request\n");
+ snprintf(result, sizeof(result), "400 Bad request\n");
goto done;
}
if (EQUAL(w, "GET")) {
if (!next_word(&cp, w)) {
- sprintf(result, "400 Bad request\n");
+ snprintf(result, sizeof(result), "400 Bad request\n");
goto done;
}
if ((query = strchr(w, '?')) != NULL) {
@@ -100,30 +101,30 @@ quip_input(FILE *fp)
}
if (EQUAL(w, "list")) {
- n = query_list(w, query, body);
+ n = query_list(w, query, body, BODY_MAXSIZE);
} else if (EQUAL(w, "handle-to-name")) {
- n = query_handle2name(w, query, body);
+ n = query_handle2name(w, query, body, BODY_MAXSIZE);
} else if (EQUAL(w, "qdisc")) {
- n = query_qdisc(w, query, body);
+ n = query_qdisc(w, query, body, BODY_MAXSIZE);
} else if (EQUAL(w, "filter")) {
- n = query_filterspec(w, query, body);
+ n = query_filterspec(w, query, body, BODY_MAXSIZE);
} else {
- sprintf(result, "400 Bad request\n");
+ snprintf(result, sizeof(result), "400 Bad request\n");
goto done;
}
} else {
- sprintf(result, "400 Bad request\n");
+ snprintf(result, sizeof(result), "400 Bad request\n");
goto done;
}
if (n == 0) {
- sprintf(result, "204 No content\n");
+ snprintf(result, sizeof(result), "204 No content\n");
} else if (n < 0) {
- sprintf(result, "400 Bad request\n");
+ snprintf(result, sizeof(result), "400 Bad request\n");
} else {
- sprintf(result, "200 OK\nContent-Length:%d\n", n);
+ snprintf(result, sizeof(result), "200 OK\nContent-Length:%d\n", n);
}
-
+
done:
/* send a result line and a blank line */
if (fputs ("QUIP/1.0 ", fp) != 0 ||
@@ -167,25 +168,27 @@ next_word(char **cpp, char *b)
* <ifname>:/<root_name>/../<parent_name>/<class_name>
*/
static int
-expand_classname(struct classinfo *clinfo, char *name)
+expand_classname(struct classinfo *clinfo, char *name, size_t maxname)
{
struct classinfo *ci = clinfo;
- char buf[2][256], *b0, *b1, *tmp;
+#define CLASSNAMEMAX 256
+ char buf[2][CLASSNAMEMAX], *b0, *b1, *tmp;
b0 = buf[0]; b1 = buf[1];
b1[0] = '\0';
while (ci != NULL) {
- strcpy(b0, "/");
- strcat(b0, ci->clname);
- strcat(b0, b1);
+ strlcpy(b0, "/", CLASSNAMEMAX);
+ strlcat(b0, ci->clname, CLASSNAMEMAX);
+ strlcat(b0, b1, CLASSNAMEMAX);
ci = ci->parent;
tmp = b0; b0 = b1; b1 = tmp;
}
- sprintf(b0, "%s:", clinfo->ifinfo->ifname);
- strcat(b0, b1);
- strcpy(name, b0);
+ snprintf(b0, CLASSNAMEMAX, "%s:", clinfo->ifinfo->ifname);
+ strlcat(b0, b1, CLASSNAMEMAX);
+ strlcpy(name, b0, CLASSNAMEMAX);
return (strlen(name));
+#undef CLASSNAMEMAX
}
/*
@@ -193,17 +196,17 @@ expand_classname(struct classinfo *clinfo, char *name)
* <ifname>:/<root_name>/../<parent_name>/<class_name>:<fltr_name>
*/
static int
-expand_filtername(struct fltrinfo *fltrinfo, char *name)
+expand_filtername(struct fltrinfo *fltrinfo, char *name, size_t maxname)
{
int len;
- len = expand_classname(fltrinfo->clinfo, name);
- sprintf(name + len, ":%s", fltrinfo->flname);
- return (len + strlen(name + len));
+ len = expand_classname(fltrinfo->clinfo, name, maxname);
+ len += snprintf(name + len, maxname - len, ":%s", fltrinfo->flname);
+ return (len);
}
static int
-query_handle2name(const char *cmd, const char *arg, char *msg)
+query_handle2name(const char *cmd, const char *arg, char *msg, size_t maxmsg)
{
struct ifinfo *ifinfo;
struct classinfo *clinfo;
@@ -212,7 +215,7 @@ query_handle2name(const char *cmd, const char *arg, char *msg)
u_long handle;
int len, size;
- strcpy(buf, arg);
+ strlcpy(buf, arg, sizeof(buf));
cp = buf;
ifname = strsep(&cp, ":");
class_field = strsep(&cp, ":");
@@ -226,7 +229,7 @@ query_handle2name(const char *cmd, const char *arg, char *msg)
if ((fltrinfo = flhandle2fltrinfo(ifinfo, handle)) == NULL)
return (-1);
- len = expand_filtername(fltrinfo, msg);
+ len = expand_filtername(fltrinfo, msg, maxmsg);
} else {
if (sscanf(class_field, "%lx", &handle) != 1)
return (-1);
@@ -235,14 +238,14 @@ query_handle2name(const char *cmd, const char *arg, char *msg)
if ((clinfo = clhandle2clinfo(ifinfo, handle)) == NULL)
return (-1);
- len = expand_classname(clinfo, msg);
+ len = expand_classname(clinfo, msg, maxmsg);
}
- size = len + sprintf(msg + len, "\n");
+ size = len + snprintf(msg + len, maxmsg - len, "\n");
return (size);
}
static int
-query_qdisc(const char *cmd, const char *arg, char *msg)
+query_qdisc(const char *cmd, const char *arg, char *msg, size_t maxmsg)
{
struct ifinfo *ifinfo;
int size;
@@ -250,14 +253,14 @@ query_qdisc(const char *cmd, const char *arg, char *msg)
if ((ifinfo = ifname2ifinfo(arg)) == NULL)
return (-1);
- size = sprintf(msg, "%s\nbandwidth:%.2fMbps\nstatus:%s\n",
- ifinfo->qdisc->qname, (double)ifinfo->bandwidth/1000000,
- (ifinfo->enabled ? "enabled" : "disabled"));
+ size = snprintf(msg, maxmsg, "%s\nbandwidth:%.2fMbps\nstatus:%s\n",
+ ifinfo->qdisc->qname, (double)ifinfo->bandwidth/1000000,
+ (ifinfo->enabled ? "enabled" : "disabled"));
return (size);
}
static int
-query_filterspec(const char *cmd, const char *arg, char *msg)
+query_filterspec(const char *cmd, const char *arg, char *msg, size_t maxmsg)
{
struct ifinfo *ifinfo;
struct fltrinfo *fltrinfo;
@@ -266,7 +269,7 @@ query_filterspec(const char *cmd, const char *arg, char *msg)
u_long handle;
int size;
- strcpy(buf, arg);
+ strlcpy(buf, arg, sizeof(buf));
cp = buf;
ifname = strsep(&cp, ":");
class_field = strsep(&cp, ":");
@@ -288,42 +291,42 @@ query_filterspec(const char *cmd, const char *arg, char *msg)
char src[128], dst[128], smask[128], dmask[128], tos[128];
if (filt->ff_flow.fi_dst.s_addr == 0) {
- sprintf(dst, "0");
+ snprintf(dst, sizeof(dst), "0");
dmask[0] = '\0';
} else {
- sprintf(dst, "%s", inet_ntoa(filt->ff_flow.fi_dst));
-
+ snprintf(dst, sizeof(dst), "%s",
+ inet_ntoa(filt->ff_flow.fi_dst));
if (filt->ff_mask.mask_dst.s_addr == 0xffffffff)
dmask[0] = '\0';
else
- sprintf(dmask, " mask %#x",
- ntoh32(filt->ff_mask.mask_dst.s_addr));
+ snprintf(dmask, sizeof(dmask), " mask %#x",
+ ntoh32(filt->ff_mask.mask_dst.s_addr));
}
if (filt->ff_flow.fi_src.s_addr == 0) {
- sprintf(src, "0");
+ snprintf(src, sizeof(src), "0");
smask[0] = '\0';
} else {
- sprintf(src, "%s", inet_ntoa(filt->ff_flow.fi_src));
-
+ snprintf(src, sizeof(src), "%s",
+ inet_ntoa(filt->ff_flow.fi_src));
if (filt->ff_mask.mask_src.s_addr == 0xffffffff)
smask[0] = '\0';
else
- sprintf(smask, " mask %#x",
- ntoh32(filt->ff_mask.mask_src.s_addr));
+ snprintf(smask, sizeof(smask), " mask %#x",
+ ntoh32(filt->ff_mask.mask_src.s_addr));
}
if (filt->ff_flow.fi_tos == 0)
tos[0] = '\0';
else
- sprintf(tos, " tos %#x tosmask %#x",
- filt->ff_flow.fi_tos,
- filt->ff_mask.mask_tos);
-
- size = sprintf(msg, "inet %s%s %d %s%s %d %d%s\n",
- dst, dmask,
- ntoh16(filt->ff_flow.fi_dport),
- src, smask,
- ntoh16(filt->ff_flow.fi_sport),
- filt->ff_flow.fi_proto, tos);
+ snprintf(tos, sizeof(tos), " tos %#x tosmask %#x",
+ filt->ff_flow.fi_tos,
+ filt->ff_mask.mask_tos);
+
+ size = snprintf(msg, maxmsg, "inet %s%s %d %s%s %d %d%s\n",
+ dst, dmask,
+ ntoh16(filt->ff_flow.fi_dport),
+ src, smask,
+ ntoh16(filt->ff_flow.fi_sport),
+ filt->ff_flow.fi_proto, tos);
}
#ifdef INET6
else if (filt->ff_flow.fi_family == AF_INET6) {
@@ -337,7 +340,7 @@ query_filterspec(const char *cmd, const char *arg, char *msg)
filt6 = (struct flow_filter6 *)&fltrinfo->fltr;
if (IN6_IS_ADDR_UNSPECIFIED(&filt6->ff_flow6.fi6_dst)) {
- sprintf(dst6, "0");
+ snprintf(dst6, sizeof(dst6), "0");
dmask6[0] = '\0';
} else {
inet_ntop(AF_INET6, &filt6->ff_flow6.fi6_dst,
@@ -346,14 +349,14 @@ query_filterspec(const char *cmd, const char *arg, char *msg)
&filt6->ff_mask6.mask6_dst))
dmask6[0] = '\0';
else {
- sprintf(dmask6, " mask ");
+ snprintf(dmask6, sizeof(dmask6), " mask ");
inet_ntop(AF_INET6, &filt6->ff_mask6.mask6_dst,
dmask6 + 6, sizeof(dmask6) -6);
}
}
if (IN6_IS_ADDR_UNSPECIFIED(&filt6->ff_flow6.fi6_src)) {
- sprintf(src6, "0");
+ snprintf(src6, sizeof(src6), "0");
smask6[0] = '\0';
} else {
inet_ntop(AF_INET6, &filt6->ff_flow6.fi6_src,
@@ -362,7 +365,7 @@ query_filterspec(const char *cmd, const char *arg, char *msg)
&filt6->ff_mask6.mask6_src))
smask6[0] = '\0';
else {
- sprintf(smask6, " mask ");
+ snprintf(smask6, sizeof(smask6), " mask ");
inet_ntop(AF_INET6, &filt6->ff_mask6.mask6_src,
smask6 + 6, sizeof(smask6) -6);
}
@@ -370,16 +373,17 @@ query_filterspec(const char *cmd, const char *arg, char *msg)
if (filt6->ff_flow6.fi6_tclass == 0)
tclass6[0] = '\0';
else
- sprintf(tclass6, " tclass %#x tclassmask %#x",
- filt6->ff_flow6.fi6_tclass,
- filt6->ff_mask6.mask6_tclass);
-
- size = sprintf(msg, "inet6 %s%s %d %s%s %d %d%s\n",
- dst6, dmask6,
- ntoh16(filt6->ff_flow6.fi6_dport),
- src6, smask6,
- ntoh16(filt6->ff_flow6.fi6_sport),
- filt6->ff_flow6.fi6_proto, tclass6);
+ snprintf(tclass6, sizeof(tclass6),
+ " tclass %#x tclassmask %#x",
+ filt6->ff_flow6.fi6_tclass,
+ filt6->ff_mask6.mask6_tclass);
+
+ size = snprintf(msg, maxmsg, "inet6 %s%s %d %s%s %d %d%s\n",
+ dst6, dmask6,
+ ntoh16(filt6->ff_flow6.fi6_dport),
+ src6, smask6,
+ ntoh16(filt6->ff_flow6.fi6_sport),
+ filt6->ff_flow6.fi6_proto, tclass6);
}
#endif /* INET6 */
@@ -428,9 +432,9 @@ string_match(const char *s1, const char *s2)
}
static int
-query_list(const char *cmd, const char *arg, char *msg)
+query_list(const char *cmd, const char *arg, char *msg, size_t maxmsg)
{
- char tmp[256], *cp;
+ char tmp[256], *cp, *ep;
struct ifinfo *ifinfo;
struct classinfo *clinfo;
struct fltrinfo *fltrinfo;
@@ -450,29 +454,31 @@ query_list(const char *cmd, const char *arg, char *msg)
}
cp = msg;
+ ep = msg + maxmsg;
LIST_FOREACH(ifinfo, &qop_iflist, next) {
if (print_if) {
- strcpy(tmp, ifinfo->ifname);
+ strlcpy(tmp, ifinfo->ifname, sizeof(tmp));
if (arg == NULL || string_match(arg, tmp))
- cp += sprintf(cp, "%#010x\t%s\n",
- ifinfo->ifindex, tmp);
+ cp += snprintf(cp, ep - cp, "%#010x\t%s\n",
+ ifinfo->ifindex, tmp);
}
if (!print_class && !print_fltr)
continue;
for (clinfo = get_rootclass(ifinfo);
clinfo != NULL; clinfo = get_nextclass(clinfo)) {
if (print_class) {
- expand_classname(clinfo, tmp);
+ expand_classname(clinfo, tmp, sizeof(tmp));
if (arg == NULL || string_match(arg, tmp))
- cp += sprintf(cp, "%#010lx\t%s\n",
- clinfo->handle, tmp);
+ cp += snprintf(cp, ep - cp,
+ "%#010lx\t%s\n",
+ clinfo->handle, tmp);
}
if (!print_fltr)
continue;
LIST_FOREACH(fltrinfo, &clinfo->fltrlist, next) {
- expand_filtername(fltrinfo, tmp);
+ expand_filtername(fltrinfo, tmp, sizeof(tmp));
if (arg == NULL || string_match(arg, tmp))
- cp += sprintf(cp, "%#010lx\t%s\n",
+ cp += snprintf(cp, ep - cp, "%#010lx\t%s\n",
fltrinfo->handle, tmp);
}
}
diff --git a/usr.sbin/altq/libaltq/quip_server.h b/usr.sbin/altq/libaltq/quip_server.h
index 5c937fea36d..397acea9780 100644
--- a/usr.sbin/altq/libaltq/quip_server.h
+++ b/usr.sbin/altq/libaltq/quip_server.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: quip_server.h,v 1.1 2001/06/27 18:23:36 kjc Exp $ */
-/* $KAME: quip_server.h,v 1.2 2000/10/18 09:15:21 kjc Exp $ */
+/* $OpenBSD: quip_server.h,v 1.2 2001/08/16 12:59:43 kjc Exp $ */
+/* $KAME: quip_server.h,v 1.3 2001/08/15 12:51:58 kjc Exp $ */
/*
* Copyright (C) 1999-2000
* Sony Computer Science Laboratories, Inc. All rights reserved.
@@ -32,6 +32,11 @@
/* unix domain socket for quip */
#define QUIP_PATH "/var/run/altq_quip"
+#define REQ_MAXSIZE 256 /* max request size */
+#define RES_MAXSIZE 256 /* max reply header size */
+#define BODY_MAXSIZE 8192 /* max reply body size */
+#define QUIPMSG_MAXSIZE (RES_MAXSIZE+BODY_MAXSIZE) /* max message size */
+
int quip_input(FILE *fp);
#endif /* _QUIP_SERVER_H_ */