Pull up following revision(s) (requested by mrg in ticket #1488): sys/altq/altq_cbq.c: revision 1.31 sys/altq/altq_hfsc.c: revision 1.27 sys/altq/altq_jobs.c: revision 1.11 sys/altq/altq_priq.c: revision 1.24 sys/altq/altq_wfq.c: revision 1.22 Zero buffers copied to userland to avoid stack disclosure. From Ilja Van Sprundel. -- Reject negative indices. (Would be nice to change the types too, and it's *probably* safe to replace int by u_int, but I'm reluctant to touch the ioctl definitions without at least a modicum more thought. Also one of them is a u_long, because why not?) From Ilja Van Sprundel.diff -r1.26 -r1.26.18.1 src/sys/altq/altq_cbq.c
(snj)
--- src/sys/altq/altq_cbq.c 2009/11/22 18:40:26 1.26
+++ src/sys/altq/altq_cbq.c 2017/08/19 05:37:06 1.26.18.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: altq_cbq.c,v 1.26 2009/11/22 18:40:26 mbalmer Exp $ */ | 1 | /* $NetBSD: altq_cbq.c,v 1.26.18.1 2017/08/19 05:37:06 snj Exp $ */ | |
2 | /* $KAME: altq_cbq.c,v 1.21 2005/04/13 03:44:24 suz Exp $ */ | 2 | /* $KAME: altq_cbq.c,v 1.21 2005/04/13 03:44:24 suz Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved. | 5 | * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * | 10 | * | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * | 13 | * | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * | 22 | * | |
23 | * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or | 23 | * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or | |
24 | * promote products derived from this software without specific prior | 24 | * promote products derived from this software without specific prior | |
25 | * written permission. | 25 | * written permission. | |
26 | * | 26 | * | |
27 | * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE | 27 | * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE | |
28 | * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is | 28 | * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is | |
29 | * provided "as is" without express or implied warranty of any kind. | 29 | * provided "as is" without express or implied warranty of any kind. | |
30 | * | 30 | * | |
31 | * These notices must be retained in any copies of any part of this software. | 31 | * These notices must be retained in any copies of any part of this software. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.26 2009/11/22 18:40:26 mbalmer Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.26.18.1 2017/08/19 05:37:06 snj Exp $"); | |
36 | 36 | |||
37 | #ifdef _KERNEL_OPT | 37 | #ifdef _KERNEL_OPT | |
38 | #include "opt_altq.h" | 38 | #include "opt_altq.h" | |
39 | #include "opt_inet.h" | 39 | #include "opt_inet.h" | |
40 | #include "pf.h" | 40 | #include "pf.h" | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #ifdef ALTQ_CBQ /* cbq is enabled by ALTQ_CBQ option in opt_altq.h */ | 43 | #ifdef ALTQ_CBQ /* cbq is enabled by ALTQ_CBQ option in opt_altq.h */ | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/malloc.h> | 46 | #include <sys/malloc.h> | |
47 | #include <sys/mbuf.h> | 47 | #include <sys/mbuf.h> | |
48 | #include <sys/socket.h> | 48 | #include <sys/socket.h> | |
@@ -462,26 +462,27 @@ cbq_getqstats(struct pf_altq *a, void *u | @@ -462,26 +462,27 @@ cbq_getqstats(struct pf_altq *a, void *u | |||
462 | struct rm_class *cl; | 462 | struct rm_class *cl; | |
463 | class_stats_t stats; | 463 | class_stats_t stats; | |
464 | int error = 0; | 464 | int error = 0; | |
465 | 465 | |||
466 | if ((cbqp = altq_lookup(a->ifname, ALTQT_CBQ)) == NULL) | 466 | if ((cbqp = altq_lookup(a->ifname, ALTQT_CBQ)) == NULL) | |
467 | return (EBADF); | 467 | return (EBADF); | |
468 | 468 | |||
469 | if ((cl = clh_to_clp(cbqp, a->qid)) == NULL) | 469 | if ((cl = clh_to_clp(cbqp, a->qid)) == NULL) | |
470 | return (EINVAL); | 470 | return (EINVAL); | |
471 | 471 | |||
472 | if (*nbytes < sizeof(stats)) | 472 | if (*nbytes < sizeof(stats)) | |
473 | return (EINVAL); | 473 | return (EINVAL); | |
474 | 474 | |||
475 | memset(&stats, 0, sizeof(stats)); | |||
475 | get_class_stats(&stats, cl); | 476 | get_class_stats(&stats, cl); | |
476 | 477 | |||
477 | if ((error = copyout((void *)&stats, ubuf, sizeof(stats))) != 0) | 478 | if ((error = copyout((void *)&stats, ubuf, sizeof(stats))) != 0) | |
478 | return (error); | 479 | return (error); | |
479 | *nbytes = sizeof(stats); | 480 | *nbytes = sizeof(stats); | |
480 | return (0); | 481 | return (0); | |
481 | } | 482 | } | |
482 | #endif /* NPF > 0 */ | 483 | #endif /* NPF > 0 */ | |
483 | 484 | |||
484 | /* | 485 | /* | |
485 | * int | 486 | * int | |
486 | * cbq_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pattr) | 487 | * cbq_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pattr) | |
487 | * - Queue data packets. | 488 | * - Queue data packets. | |
@@ -866,26 +867,27 @@ cbq_getstats(struct cbq_getstats *gsp) | @@ -866,26 +867,27 @@ cbq_getstats(struct cbq_getstats *gsp) | |||
866 | nclasses = gsp->nclasses; | 867 | nclasses = gsp->nclasses; | |
867 | usp = gsp->stats; | 868 | usp = gsp->stats; | |
868 | 869 | |||
869 | if ((cbqp = altq_lookup(ifacename, ALTQT_CBQ)) == NULL) | 870 | if ((cbqp = altq_lookup(ifacename, ALTQT_CBQ)) == NULL) | |
870 | return (EBADF); | 871 | return (EBADF); | |
871 | if (nclasses <= 0) | 872 | if (nclasses <= 0) | |
872 | return (EINVAL); | 873 | return (EINVAL); | |
873 | 874 | |||
874 | for (n = 0, i = 0; n < nclasses && i < CBQ_MAX_CLASSES; n++, i++) { | 875 | for (n = 0, i = 0; n < nclasses && i < CBQ_MAX_CLASSES; n++, i++) { | |
875 | while ((cl = cbqp->cbq_class_tbl[i]) == NULL) | 876 | while ((cl = cbqp->cbq_class_tbl[i]) == NULL) | |
876 | if (++i >= CBQ_MAX_CLASSES) | 877 | if (++i >= CBQ_MAX_CLASSES) | |
877 | goto out; | 878 | goto out; | |
878 | 879 | |||
880 | memset(&stats, 0, sizeof(stats)); | |||
879 | get_class_stats(&stats, cl); | 881 | get_class_stats(&stats, cl); | |
880 | stats.handle = cl->stats_.handle; | 882 | stats.handle = cl->stats_.handle; | |
881 | 883 | |||
882 | if ((error = copyout((void *)&stats, (void *)usp++, | 884 | if ((error = copyout((void *)&stats, (void *)usp++, | |
883 | sizeof(stats))) != 0) | 885 | sizeof(stats))) != 0) | |
884 | return (error); | 886 | return (error); | |
885 | } | 887 | } | |
886 | 888 | |||
887 | out: | 889 | out: | |
888 | gsp->nclasses = n; | 890 | gsp->nclasses = n; | |
889 | return (error); | 891 | return (error); | |
890 | } | 892 | } | |
891 | 893 |
--- src/sys/altq/altq_hfsc.c 2008/06/18 09:06:27 1.24
+++ src/sys/altq/altq_hfsc.c 2017/08/19 05:37:06 1.24.36.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: altq_hfsc.c,v 1.24 2008/06/18 09:06:27 yamt Exp $ */ | 1 | /* $NetBSD: altq_hfsc.c,v 1.24.36.1 2017/08/19 05:37:06 snj Exp $ */ | |
2 | /* $KAME: altq_hfsc.c,v 1.26 2005/04/13 03:44:24 suz Exp $ */ | 2 | /* $KAME: altq_hfsc.c,v 1.26 2005/04/13 03:44:24 suz Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 1997-1999 Carnegie Mellon University. All Rights Reserved. | 5 | * Copyright (c) 1997-1999 Carnegie Mellon University. All Rights Reserved. | |
6 | * | 6 | * | |
7 | * Permission to use, copy, modify, and distribute this software and | 7 | * Permission to use, copy, modify, and distribute this software and | |
8 | * its documentation is hereby granted (including for commercial or | 8 | * its documentation is hereby granted (including for commercial or | |
9 | * for-profit use), provided that both the copyright notice and this | 9 | * for-profit use), provided that both the copyright notice and this | |
10 | * permission notice appear in all copies of the software, derivative | 10 | * permission notice appear in all copies of the software, derivative | |
11 | * works, or modified versions, and any portions thereof. | 11 | * works, or modified versions, and any portions thereof. | |
12 | * | 12 | * | |
13 | * THIS SOFTWARE IS EXPERIMENTAL AND IS KNOWN TO HAVE BUGS, SOME OF | 13 | * THIS SOFTWARE IS EXPERIMENTAL AND IS KNOWN TO HAVE BUGS, SOME OF | |
14 | * WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON PROVIDES THIS | 14 | * WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON PROVIDES THIS | |
@@ -33,27 +33,27 @@ | @@ -33,27 +33,27 @@ | |||
33 | /* | 33 | /* | |
34 | * H-FSC is described in Proceedings of SIGCOMM'97, | 34 | * H-FSC is described in Proceedings of SIGCOMM'97, | |
35 | * "A Hierarchical Fair Service Curve Algorithm for Link-Sharing, | 35 | * "A Hierarchical Fair Service Curve Algorithm for Link-Sharing, | |
36 | * Real-Time and Priority Service" | 36 | * Real-Time and Priority Service" | |
37 | * by Ion Stoica, Hui Zhang, and T. S. Eugene Ng. | 37 | * by Ion Stoica, Hui Zhang, and T. S. Eugene Ng. | |
38 | * | 38 | * | |
39 | * Oleg Cherevko <olwi@aq.ml.com.ua> added the upperlimit for link-sharing. | 39 | * Oleg Cherevko <olwi@aq.ml.com.ua> added the upperlimit for link-sharing. | |
40 | * when a class has an upperlimit, the fit-time is computed from the | 40 | * when a class has an upperlimit, the fit-time is computed from the | |
41 | * upperlimit service curve. the link-sharing scheduler does not schedule | 41 | * upperlimit service curve. the link-sharing scheduler does not schedule | |
42 | * a class whose fit-time exceeds the current time. | 42 | * a class whose fit-time exceeds the current time. | |
43 | */ | 43 | */ | |
44 | 44 | |||
45 | #include <sys/cdefs.h> | 45 | #include <sys/cdefs.h> | |
46 | __KERNEL_RCSID(0, "$NetBSD: altq_hfsc.c,v 1.24 2008/06/18 09:06:27 yamt Exp $"); | 46 | __KERNEL_RCSID(0, "$NetBSD: altq_hfsc.c,v 1.24.36.1 2017/08/19 05:37:06 snj Exp $"); | |
47 | 47 | |||
48 | #ifdef _KERNEL_OPT | 48 | #ifdef _KERNEL_OPT | |
49 | #include "opt_altq.h" | 49 | #include "opt_altq.h" | |
50 | #include "opt_inet.h" | 50 | #include "opt_inet.h" | |
51 | #include "pf.h" | 51 | #include "pf.h" | |
52 | #endif | 52 | #endif | |
53 | 53 | |||
54 | #ifdef ALTQ_HFSC /* hfsc is enabled by ALTQ_HFSC option in opt_altq.h */ | 54 | #ifdef ALTQ_HFSC /* hfsc is enabled by ALTQ_HFSC option in opt_altq.h */ | |
55 | 55 | |||
56 | #include <sys/param.h> | 56 | #include <sys/param.h> | |
57 | #include <sys/malloc.h> | 57 | #include <sys/malloc.h> | |
58 | #include <sys/mbuf.h> | 58 | #include <sys/mbuf.h> | |
59 | #include <sys/socket.h> | 59 | #include <sys/socket.h> | |
@@ -303,26 +303,27 @@ hfsc_getqstats(struct pf_altq *a, void * | @@ -303,26 +303,27 @@ hfsc_getqstats(struct pf_altq *a, void * | |||
303 | struct hfsc_class *cl; | 303 | struct hfsc_class *cl; | |
304 | struct hfsc_classstats stats; | 304 | struct hfsc_classstats stats; | |
305 | int error = 0; | 305 | int error = 0; | |
306 | 306 | |||
307 | if ((hif = altq_lookup(a->ifname, ALTQT_HFSC)) == NULL) | 307 | if ((hif = altq_lookup(a->ifname, ALTQT_HFSC)) == NULL) | |
308 | return (EBADF); | 308 | return (EBADF); | |
309 | 309 | |||
310 | if ((cl = clh_to_clp(hif, a->qid)) == NULL) | 310 | if ((cl = clh_to_clp(hif, a->qid)) == NULL) | |
311 | return (EINVAL); | 311 | return (EINVAL); | |
312 | 312 | |||
313 | if (*nbytes < sizeof(stats)) | 313 | if (*nbytes < sizeof(stats)) | |
314 | return (EINVAL); | 314 | return (EINVAL); | |
315 | 315 | |||
316 | memset(&stats, 0, sizeof(stats)); | |||
316 | get_class_stats(&stats, cl); | 317 | get_class_stats(&stats, cl); | |
317 | 318 | |||
318 | if ((error = copyout((void *)&stats, ubuf, sizeof(stats))) != 0) | 319 | if ((error = copyout((void *)&stats, ubuf, sizeof(stats))) != 0) | |
319 | return (error); | 320 | return (error); | |
320 | *nbytes = sizeof(stats); | 321 | *nbytes = sizeof(stats); | |
321 | return (0); | 322 | return (0); | |
322 | } | 323 | } | |
323 | #endif /* NPF > 0 */ | 324 | #endif /* NPF > 0 */ | |
324 | 325 | |||
325 | /* | 326 | /* | |
326 | * bring the interface back to the initial state by discarding | 327 | * bring the interface back to the initial state by discarding | |
327 | * all the filters and classes except the root class. | 328 | * all the filters and classes except the root class. | |
328 | */ | 329 | */ |
--- src/sys/altq/altq_jobs.c 2014/11/03 15:08:44 1.6.14.1
+++ src/sys/altq/altq_jobs.c 2017/08/19 05:37:06 1.6.14.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: altq_jobs.c,v 1.6.14.1 2014/11/03 15:08:44 msaitoh Exp $ */ | 1 | /* $NetBSD: altq_jobs.c,v 1.6.14.2 2017/08/19 05:37:06 snj Exp $ */ | |
2 | /* $KAME: altq_jobs.c,v 1.11 2005/04/13 03:44:25 suz Exp $ */ | 2 | /* $KAME: altq_jobs.c,v 1.11 2005/04/13 03:44:25 suz Exp $ */ | |
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001, the Rector and Board of Visitors of the | 4 | * Copyright (c) 2001, the Rector and Board of Visitors of the | |
5 | * University of Virginia. | 5 | * University of Virginia. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, | 8 | * Redistribution and use in source and binary forms, | |
9 | * with or without modification, are permitted provided | 9 | * with or without modification, are permitted provided | |
10 | * that the following conditions are met: | 10 | * that the following conditions are met: | |
11 | * | 11 | * | |
12 | * Redistributions of source code must retain the above | 12 | * Redistributions of source code must retain the above | |
13 | * copyright notice, this list of conditions and the following | 13 | * copyright notice, this list of conditions and the following | |
14 | * disclaimer. | 14 | * disclaimer. | |
@@ -49,27 +49,27 @@ | @@ -49,27 +49,27 @@ | |||
49 | * Contributed by the Multimedia Networks Group at the University | 49 | * Contributed by the Multimedia Networks Group at the University | |
50 | * of Virginia. | 50 | * of Virginia. | |
51 | * | 51 | * | |
52 | * Papers and additional info can be found at | 52 | * Papers and additional info can be found at | |
53 | * http://qosbox.cs.virginia.edu | 53 | * http://qosbox.cs.virginia.edu | |
54 | * | 54 | * | |
55 | */ | 55 | */ | |
56 | 56 | |||
57 | /* | 57 | /* | |
58 | * JoBS queue | 58 | * JoBS queue | |
59 | */ | 59 | */ | |
60 | 60 | |||
61 | #include <sys/cdefs.h> | 61 | #include <sys/cdefs.h> | |
62 | __KERNEL_RCSID(0, "$NetBSD: altq_jobs.c,v 1.6.14.1 2014/11/03 15:08:44 msaitoh Exp $"); | 62 | __KERNEL_RCSID(0, "$NetBSD: altq_jobs.c,v 1.6.14.2 2017/08/19 05:37:06 snj Exp $"); | |
63 | 63 | |||
64 | #ifdef _KERNEL_OPT | 64 | #ifdef _KERNEL_OPT | |
65 | #include "opt_altq.h" | 65 | #include "opt_altq.h" | |
66 | #include "opt_inet.h" | 66 | #include "opt_inet.h" | |
67 | #endif | 67 | #endif | |
68 | 68 | |||
69 | #ifdef ALTQ_JOBS /* jobs is enabled by ALTQ_JOBS option in opt_altq.h */ | 69 | #ifdef ALTQ_JOBS /* jobs is enabled by ALTQ_JOBS option in opt_altq.h */ | |
70 | 70 | |||
71 | #include <sys/param.h> | 71 | #include <sys/param.h> | |
72 | #include <sys/malloc.h> | 72 | #include <sys/malloc.h> | |
73 | #include <sys/mbuf.h> | 73 | #include <sys/mbuf.h> | |
74 | #include <sys/socket.h> | 74 | #include <sys/socket.h> | |
75 | #include <sys/sockio.h> | 75 | #include <sys/sockio.h> | |
@@ -2101,30 +2101,29 @@ jobscmd_class_stats(struct jobs_class_st | @@ -2101,30 +2101,29 @@ jobscmd_class_stats(struct jobs_class_st | |||
2101 | struct jobs_class *cl; | 2101 | struct jobs_class *cl; | |
2102 | struct class_stats stats, *usp; | 2102 | struct class_stats stats, *usp; | |
2103 | int pri, error; | 2103 | int pri, error; | |
2104 | 2104 | |||
2105 | if ((jif = altq_lookup(ap->iface.jobs_ifname, ALTQT_JOBS)) == NULL) | 2105 | if ((jif = altq_lookup(ap->iface.jobs_ifname, ALTQT_JOBS)) == NULL) | |
2106 | return (EBADF); | 2106 | return (EBADF); | |
2107 | 2107 | |||
2108 | ap->maxpri = jif->jif_maxpri; | 2108 | ap->maxpri = jif->jif_maxpri; | |
2109 | 2109 | |||
2110 | /* then, read the next N classes */ | 2110 | /* then, read the next N classes */ | |
2111 | usp = ap->stats; | 2111 | usp = ap->stats; | |
2112 | for (pri = 0; pri <= jif->jif_maxpri; pri++) { | 2112 | for (pri = 0; pri <= jif->jif_maxpri; pri++) { | |
2113 | cl = jif->jif_classes[pri]; | 2113 | cl = jif->jif_classes[pri]; | |
2114 | (void)memset(&stats, 0, sizeof(stats)); | |||
2114 | if (cl != NULL) | 2115 | if (cl != NULL) | |
2115 | get_class_stats(&stats, cl); | 2116 | get_class_stats(&stats, cl); | |
2116 | else | |||
2117 | (void)memset(&stats, 0, sizeof(stats)); | |||
2118 | if ((error = copyout((void *)&stats, (void *)usp++, | 2117 | if ((error = copyout((void *)&stats, (void *)usp++, | |
2119 | sizeof(stats))) != 0) | 2118 | sizeof(stats))) != 0) | |
2120 | return (error); | 2119 | return (error); | |
2121 | } | 2120 | } | |
2122 | return (0); | 2121 | return (0); | |
2123 | } | 2122 | } | |
2124 | 2123 | |||
2125 | static void | 2124 | static void | |
2126 | get_class_stats(struct class_stats *sp, struct jobs_class *cl) | 2125 | get_class_stats(struct class_stats *sp, struct jobs_class *cl) | |
2127 | { | 2126 | { | |
2128 | u_int64_t now; | 2127 | u_int64_t now; | |
2129 | now = read_machclk(); | 2128 | now = read_machclk(); | |
2130 | 2129 |
--- src/sys/altq/altq_priq.c 2009/03/14 15:35:58 1.21
+++ src/sys/altq/altq_priq.c 2017/08/19 05:37:06 1.21.18.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: altq_priq.c,v 1.21 2009/03/14 15:35:58 dsl Exp $ */ | 1 | /* $NetBSD: altq_priq.c,v 1.21.18.1 2017/08/19 05:37:06 snj Exp $ */ | |
2 | /* $KAME: altq_priq.c,v 1.13 2005/04/13 03:44:25 suz Exp $ */ | 2 | /* $KAME: altq_priq.c,v 1.13 2005/04/13 03:44:25 suz Exp $ */ | |
3 | /* | 3 | /* | |
4 | * Copyright (C) 2000-2003 | 4 | * Copyright (C) 2000-2003 | |
5 | * Sony Computer Science Laboratories Inc. All rights reserved. | 5 | * Sony Computer Science Laboratories Inc. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | /* | 29 | /* | |
30 | * priority queue | 30 | * priority queue | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.21 2009/03/14 15:35:58 dsl Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.21.18.1 2017/08/19 05:37:06 snj Exp $"); | |
35 | 35 | |||
36 | #ifdef _KERNEL_OPT | 36 | #ifdef _KERNEL_OPT | |
37 | #include "opt_altq.h" | 37 | #include "opt_altq.h" | |
38 | #include "opt_inet.h" | 38 | #include "opt_inet.h" | |
39 | #include "pf.h" | 39 | #include "pf.h" | |
40 | #endif | 40 | #endif | |
41 | 41 | |||
42 | #ifdef ALTQ_PRIQ /* priq is enabled by ALTQ_PRIQ option in opt_altq.h */ | 42 | #ifdef ALTQ_PRIQ /* priq is enabled by ALTQ_PRIQ option in opt_altq.h */ | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/malloc.h> | 45 | #include <sys/malloc.h> | |
46 | #include <sys/mbuf.h> | 46 | #include <sys/mbuf.h> | |
47 | #include <sys/socket.h> | 47 | #include <sys/socket.h> | |
@@ -209,26 +209,27 @@ priq_getqstats(struct pf_altq *a, void * | @@ -209,26 +209,27 @@ priq_getqstats(struct pf_altq *a, void * | |||
209 | struct priq_class *cl; | 209 | struct priq_class *cl; | |
210 | struct priq_classstats stats; | 210 | struct priq_classstats stats; | |
211 | int error = 0; | 211 | int error = 0; | |
212 | 212 | |||
213 | if ((pif = altq_lookup(a->ifname, ALTQT_PRIQ)) == NULL) | 213 | if ((pif = altq_lookup(a->ifname, ALTQT_PRIQ)) == NULL) | |
214 | return (EBADF); | 214 | return (EBADF); | |
215 | 215 | |||
216 | if ((cl = clh_to_clp(pif, a->qid)) == NULL) | 216 | if ((cl = clh_to_clp(pif, a->qid)) == NULL) | |
217 | return (EINVAL); | 217 | return (EINVAL); | |
218 | 218 | |||
219 | if (*nbytes < sizeof(stats)) | 219 | if (*nbytes < sizeof(stats)) | |
220 | return (EINVAL); | 220 | return (EINVAL); | |
221 | 221 | |||
222 | memset(&stats, 0, sizeof(stats)); | |||
222 | get_class_stats(&stats, cl); | 223 | get_class_stats(&stats, cl); | |
223 | 224 | |||
224 | if ((error = copyout((void *)&stats, ubuf, sizeof(stats))) != 0) | 225 | if ((error = copyout((void *)&stats, ubuf, sizeof(stats))) != 0) | |
225 | return (error); | 226 | return (error); | |
226 | *nbytes = sizeof(stats); | 227 | *nbytes = sizeof(stats); | |
227 | return (0); | 228 | return (0); | |
228 | } | 229 | } | |
229 | #endif /* NPF > 0 */ | 230 | #endif /* NPF > 0 */ | |
230 | 231 | |||
231 | /* | 232 | /* | |
232 | * bring the interface back to the initial state by discarding | 233 | * bring the interface back to the initial state by discarding | |
233 | * all the filters and classes. | 234 | * all the filters and classes. | |
234 | */ | 235 | */ |
--- src/sys/altq/altq_wfq.c 2008/09/11 17:58:59 1.19
+++ src/sys/altq/altq_wfq.c 2017/08/19 05:37:06 1.19.34.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: altq_wfq.c,v 1.19 2008/09/11 17:58:59 joerg Exp $ */ | 1 | /* $NetBSD: altq_wfq.c,v 1.19.34.1 2017/08/19 05:37:06 snj Exp $ */ | |
2 | /* $KAME: altq_wfq.c,v 1.14 2005/04/13 03:44:25 suz Exp $ */ | 2 | /* $KAME: altq_wfq.c,v 1.14 2005/04/13 03:44:25 suz Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (C) 1997-2002 | 5 | * Copyright (C) 1997-2002 | |
6 | * Sony Computer Science Laboratories Inc. All rights reserved. | 6 | * Sony Computer Science Laboratories Inc. All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
27 | * SUCH DAMAGE. | 27 | * SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | /* | 29 | /* | |
30 | * March 27, 1997. Written by Hiroshi Kyusojin of Keio University | 30 | * March 27, 1997. Written by Hiroshi Kyusojin of Keio University | |
31 | * (kyu@mt.cs.keio.ac.jp). | 31 | * (kyu@mt.cs.keio.ac.jp). | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: altq_wfq.c,v 1.19 2008/09/11 17:58:59 joerg Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: altq_wfq.c,v 1.19.34.1 2017/08/19 05:37:06 snj Exp $"); | |
36 | 36 | |||
37 | #ifdef _KERNEL_OPT | 37 | #ifdef _KERNEL_OPT | |
38 | #include "opt_altq.h" | 38 | #include "opt_altq.h" | |
39 | #include "opt_inet.h" | 39 | #include "opt_inet.h" | |
40 | #endif | 40 | #endif | |
41 | 41 | |||
42 | #ifdef ALTQ_WFQ | 42 | #ifdef ALTQ_WFQ | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/malloc.h> | 45 | #include <sys/malloc.h> | |
46 | #include <sys/mbuf.h> | 46 | #include <sys/mbuf.h> | |
47 | #include <sys/uio.h> | 47 | #include <sys/uio.h> | |
48 | #include <sys/socket.h> | 48 | #include <sys/socket.h> | |
@@ -508,53 +508,54 @@ wfq_getqid(struct wfq_getqid *gqidp) | @@ -508,53 +508,54 @@ wfq_getqid(struct wfq_getqid *gqidp) | |||
508 | return (EBADF); | 508 | return (EBADF); | |
509 | 509 | |||
510 | gqidp->qid = (*wfqp->hash_func)(&gqidp->flow, wfqp->nums); | 510 | gqidp->qid = (*wfqp->hash_func)(&gqidp->flow, wfqp->nums); | |
511 | return 0; | 511 | return 0; | |
512 | } | 512 | } | |
513 | 513 | |||
514 | static int | 514 | static int | |
515 | wfq_setweight(struct wfq_setweight *swp) | 515 | wfq_setweight(struct wfq_setweight *swp) | |
516 | { | 516 | { | |
517 | wfq_state_t *wfqp; | 517 | wfq_state_t *wfqp; | |
518 | wfq *queue; | 518 | wfq *queue; | |
519 | int old; | 519 | int old; | |
520 | 520 | |||
521 | if (swp->weight < 0) { | 521 | if (swp->weight < 0) | |
522 | printf("set weight in natural number\n"); | |||
523 | return (EINVAL); | 522 | return (EINVAL); | |
524 | } | |||
525 | 523 | |||
526 | if ((wfqp = altq_lookup(swp->iface.wfq_ifacename, ALTQT_WFQ)) == NULL) | 524 | if ((wfqp = altq_lookup(swp->iface.wfq_ifacename, ALTQT_WFQ)) == NULL) | |
527 | return (EBADF); | 525 | return (EBADF); | |
528 | 526 | |||
527 | if (swp->qid < 0 || swp->qid >= wfqp->nums) | |||
528 | return (EINVAL); | |||
529 | ||||
529 | queue = &wfqp->queue[swp->qid]; | 530 | queue = &wfqp->queue[swp->qid]; | |
530 | old = queue->weight; | 531 | old = queue->weight; | |
531 | queue->weight = swp->weight; | 532 | queue->weight = swp->weight; | |
532 | swp->weight = old; | 533 | swp->weight = old; | |
533 | return 0; | 534 | return 0; | |
534 | } | 535 | } | |
535 | 536 | |||
536 | 537 | |||
537 | static int | 538 | static int | |
538 | wfq_getstats(struct wfq_getstats *gsp) | 539 | wfq_getstats(struct wfq_getstats *gsp) | |
539 | { | 540 | { | |
540 | wfq_state_t *wfqp; | 541 | wfq_state_t *wfqp; | |
541 | wfq *queue; | 542 | wfq *queue; | |
542 | queue_stats *stats; | 543 | queue_stats *stats; | |
543 | 544 | |||
544 | if ((wfqp = altq_lookup(gsp->iface.wfq_ifacename, ALTQT_WFQ)) == NULL) | 545 | if ((wfqp = altq_lookup(gsp->iface.wfq_ifacename, ALTQT_WFQ)) == NULL) | |
545 | return (EBADF); | 546 | return (EBADF); | |
546 | 547 | |||
547 | if (gsp->qid >= wfqp->nums) | 548 | if (gsp->qid < 0 || gsp->qid >= wfqp->nums) | |
548 | return (EINVAL); | 549 | return (EINVAL); | |
549 | 550 | |||
550 | queue = &wfqp->queue[gsp->qid]; | 551 | queue = &wfqp->queue[gsp->qid]; | |
551 | stats = &gsp->stats; | 552 | stats = &gsp->stats; | |
552 | 553 | |||
553 | stats->bytes = queue->bytes; | 554 | stats->bytes = queue->bytes; | |
554 | stats->weight = queue->weight; | 555 | stats->weight = queue->weight; | |
555 | stats->xmit_cnt = queue->xmit_cnt; | 556 | stats->xmit_cnt = queue->xmit_cnt; | |
556 | stats->drop_cnt = queue->drop_cnt; | 557 | stats->drop_cnt = queue->drop_cnt; | |
557 | 558 | |||
558 | return 0; | 559 | return 0; | |
559 | } | 560 | } | |
560 | 561 |