Do more than r236298 did in the projects/pf branch: use M_NOWAIT in

altq_add() and its descendants. Currently altq(4) in FreeBSD is configured
via pf(4) ioctls, which can't configure altq(4) w/o holding locks.
Fortunately, altq(4) code in spife of using M_WAITOK is ready to receive
NULL from malloc(9), so change is mostly mechanical. While here, utilize
M_ZERO instead of bzero().

A large redesign needed to achieve M_WAITOK usage when configuring altq(4).
Or an alternative (not pf(4)) configuration interface should be implemented.

Reported by:	pluknet
This commit is contained in:
Gleb Smirnoff 2012-09-18 12:34:35 +00:00
parent 38f2be1c54
commit 32726fe911
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=240646
3 changed files with 11 additions and 19 deletions

View File

@ -400,15 +400,13 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc,
}
#endif
cl = malloc(sizeof(struct hfsc_class), M_DEVBUF, M_WAITOK);
cl = malloc(sizeof(struct hfsc_class), M_DEVBUF, M_NOWAIT | M_ZERO);
if (cl == NULL)
return (NULL);
bzero(cl, sizeof(struct hfsc_class));
cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, M_WAITOK);
cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, M_NOWAIT | M_ZERO);
if (cl->cl_q == NULL)
goto err_ret;
bzero(cl->cl_q, sizeof(class_queue_t));
cl->cl_actc = actlist_alloc();
if (cl->cl_actc == NULL)
@ -466,7 +464,7 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc,
if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0)) {
cl->cl_rsc = malloc(sizeof(struct internal_sc),
M_DEVBUF, M_WAITOK);
M_DEVBUF, M_NOWAIT);
if (cl->cl_rsc == NULL)
goto err_ret;
sc2isc(rsc, cl->cl_rsc);
@ -475,7 +473,7 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc,
}
if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0)) {
cl->cl_fsc = malloc(sizeof(struct internal_sc),
M_DEVBUF, M_WAITOK);
M_DEVBUF, M_NOWAIT);
if (cl->cl_fsc == NULL)
goto err_ret;
sc2isc(fsc, cl->cl_fsc);
@ -483,7 +481,7 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc,
}
if (usc != NULL && (usc->m1 != 0 || usc->m2 != 0)) {
cl->cl_usc = malloc(sizeof(struct internal_sc),
M_DEVBUF, M_WAITOK);
M_DEVBUF, M_NOWAIT);
if (cl->cl_usc == NULL)
goto err_ret;
sc2isc(usc, cl->cl_usc);

View File

@ -316,17 +316,15 @@ priq_class_create(struct priq_if *pif, int pri, int qlimit, int flags, int qid)
red_destroy(cl->cl_red);
#endif
} else {
cl = malloc(sizeof(struct priq_class),
M_DEVBUF, M_WAITOK);
cl = malloc(sizeof(struct priq_class), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (cl == NULL)
return (NULL);
bzero(cl, sizeof(struct priq_class));
cl->cl_q = malloc(sizeof(class_queue_t),
M_DEVBUF, M_WAITOK);
cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (cl->cl_q == NULL)
goto err_ret;
bzero(cl->cl_q, sizeof(class_queue_t));
}
pif->pif_classes[pri] = cl;

View File

@ -218,19 +218,15 @@ rmc_newclass(int pri, struct rm_ifdat *ifd, u_int nsecPerByte,
}
#endif
cl = malloc(sizeof(struct rm_class),
M_DEVBUF, M_WAITOK);
cl = malloc(sizeof(struct rm_class), M_DEVBUF, M_NOWAIT | M_ZERO);
if (cl == NULL)
return (NULL);
bzero(cl, sizeof(struct rm_class));
CALLOUT_INIT(&cl->callout_);
cl->q_ = malloc(sizeof(class_queue_t),
M_DEVBUF, M_WAITOK);
cl->q_ = malloc(sizeof(class_queue_t), M_DEVBUF, M_NOWAIT | M_ZERO);
if (cl->q_ == NULL) {
free(cl, M_DEVBUF);
return (NULL);
}
bzero(cl->q_, sizeof(class_queue_t));
/*
* Class initialization.