Don't allow to initialize an interface with MTU smaller than one.
This prevents a divide by zero and fixes PR #21474. ok tron@
This commit is contained in:
parent
8f3077c34d
commit
9cc4e60c56
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: altq_cbq.c,v 1.21 2006/10/20 21:55:56 elad Exp $ */
|
||||
/* $NetBSD: altq_cbq.c,v 1.22 2006/10/28 11:35:17 peter Exp $ */
|
||||
/* $KAME: altq_cbq.c,v 1.21 2005/04/13 03:44:24 suz Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.21 2006/10/20 21:55:56 elad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.22 2006/10/28 11:35:17 peter Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_altq.h"
|
||||
|
@ -314,7 +314,7 @@ cbq_add_queue(struct pf_altq *a)
|
|||
cbq_state_t *cbqp;
|
||||
struct rm_class *cl;
|
||||
struct cbq_opts *opts;
|
||||
int i;
|
||||
int i, error;
|
||||
|
||||
if ((cbqp = a->altq_disc) == NULL)
|
||||
return (EINVAL);
|
||||
|
@ -389,10 +389,12 @@ cbq_add_queue(struct pf_altq *a)
|
|||
* interface.
|
||||
*/
|
||||
if ((opts->flags & CBQCLF_CLASSMASK) == CBQCLF_ROOTCLASS) {
|
||||
rmc_init(cbqp->ifnp.ifq_, &cbqp->ifnp, opts->ns_per_byte,
|
||||
cbqrestart, a->qlimit, RM_MAXQUEUED,
|
||||
error = rmc_init(cbqp->ifnp.ifq_, &cbqp->ifnp,
|
||||
opts->ns_per_byte, cbqrestart, a->qlimit, RM_MAXQUEUED,
|
||||
opts->maxidle, opts->minidle, opts->offtime,
|
||||
opts->flags);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
cl = cbqp->ifnp.root_;
|
||||
} else {
|
||||
cl = rmc_newclass(a->priority,
|
||||
|
@ -704,7 +706,7 @@ cbq_class_create(cbq_state_t *cbqp, struct cbq_add_class *acp,
|
|||
struct rm_class *cl;
|
||||
cbq_class_spec_t *spec = &acp->cbq_class;
|
||||
u_int32_t chandle;
|
||||
int i;
|
||||
int i, error;
|
||||
|
||||
/*
|
||||
* allocate class handle
|
||||
|
@ -721,10 +723,12 @@ cbq_class_create(cbq_state_t *cbqp, struct cbq_add_class *acp,
|
|||
* interface.
|
||||
*/
|
||||
if ((spec->flags & CBQCLF_CLASSMASK) == CBQCLF_ROOTCLASS) {
|
||||
rmc_init(cbqp->ifnp.ifq_, &cbqp->ifnp, spec->nano_sec_per_byte,
|
||||
cbqrestart, spec->maxq, RM_MAXQUEUED,
|
||||
spec->maxidle, spec->minidle, spec->offtime,
|
||||
spec->flags);
|
||||
error = rmc_init(cbqp->ifnp.ifq_, &cbqp->ifnp,
|
||||
spec->nano_sec_per_byte, cbqrestart, spec->maxq,
|
||||
RM_MAXQUEUED, spec->maxidle, spec->minidle, spec->offtime,
|
||||
spec->flags);
|
||||
if (error)
|
||||
return (error);
|
||||
cl = cbqp->ifnp.root_;
|
||||
} else {
|
||||
cl = rmc_newclass(spec->priority,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: altq_rmclass.c,v 1.16 2006/10/24 02:48:04 mrg Exp $ */
|
||||
/* $NetBSD: altq_rmclass.c,v 1.17 2006/10/28 11:35:17 peter Exp $ */
|
||||
/* $KAME: altq_rmclass.c,v 1.19 2005/04/13 03:44:25 suz Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.16 2006/10/24 02:48:04 mrg Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.17 2006/10/28 11:35:17 peter Exp $");
|
||||
|
||||
#ident "@(#)rm_class.c 1.48 97/12/05 SMI"
|
||||
|
||||
|
@ -642,7 +642,7 @@ rmc_delete_class(struct rm_ifdat *ifd, struct rm_class *cl)
|
|||
|
||||
|
||||
/*
|
||||
* void
|
||||
* int
|
||||
* rmc_init(...) - Initialize the resource management data structures
|
||||
* associated with the output portion of interface 'ifp'. 'ifd' is
|
||||
* where the structures will be built (for backwards compatibility, the
|
||||
|
@ -654,23 +654,29 @@ rmc_delete_class(struct rm_ifdat *ifd, struct rm_class *cl)
|
|||
* is the maximum number of packets that the resource management
|
||||
* code will allow to be queued 'downstream' (this is typically 1).
|
||||
*
|
||||
* Returns: NONE
|
||||
* Returns: 0 on success
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
rmc_init(struct ifaltq *ifq, struct rm_ifdat *ifd, u_int nsecPerByte,
|
||||
void (*restart)(struct ifaltq *), int maxq, int maxqueued, u_int maxidle,
|
||||
int minidle, u_int offtime, int flags)
|
||||
{
|
||||
int i, mtu;
|
||||
int i, mtu;
|
||||
|
||||
/*
|
||||
* Initialize the CBQ tracing/debug facility.
|
||||
*/
|
||||
CBQTRACEINIT();
|
||||
|
||||
(void)memset((char *)ifd, 0, sizeof (*ifd));
|
||||
mtu = ifq->altq_ifp->if_mtu;
|
||||
if (mtu < 1) {
|
||||
printf("altq: %s: invalid MTU (interface not initialized?)\n",
|
||||
ifq->altq_ifp->if_xname);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
(void)memset((char *)ifd, 0, sizeof (*ifd));
|
||||
ifd->ifq_ = ifq;
|
||||
ifd->restart = restart;
|
||||
ifd->maxqueued_ = maxqueued;
|
||||
|
@ -718,9 +724,11 @@ rmc_init(struct ifaltq *ifq, struct rm_ifdat *ifd, u_int nsecPerByte,
|
|||
maxidle, minidle, offtime,
|
||||
0, 0)) == NULL) {
|
||||
printf("rmc_init: root class not allocated\n");
|
||||
return ;
|
||||
return (ENOMEM);
|
||||
}
|
||||
ifd->root_->depth_ = 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: altq_rmclass.h,v 1.7 2006/10/12 19:59:08 peter Exp $ */
|
||||
/* $NetBSD: altq_rmclass.h,v 1.8 2006/10/28 11:35:17 peter Exp $ */
|
||||
/* $KAME: altq_rmclass.h,v 1.10 2003/08/20 23:30:23 itojun Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -248,7 +248,7 @@ extern rm_class_t *rmc_newclass(int, struct rm_ifdat *, u_int,
|
|||
extern void rmc_delete_class(struct rm_ifdat *, struct rm_class *);
|
||||
extern int rmc_modclass(struct rm_class *, u_int, int,
|
||||
u_int, int, u_int, int);
|
||||
extern void rmc_init(struct ifaltq *, struct rm_ifdat *, u_int,
|
||||
extern int rmc_init(struct ifaltq *, struct rm_ifdat *, u_int,
|
||||
void (*)(struct ifaltq *),
|
||||
int, int, u_int, int, u_int, int);
|
||||
extern int rmc_queue_packet(struct rm_class *, mbuf_t *);
|
||||
|
|
Loading…
Reference in New Issue