In ifc_alloc_unit():
- In the !wildcard case, return ENOSPC instead of confusing EEXIST in case if ifc->ifc_maxunit reached. - Fix unit leak, that I've introduced in previous revision. Submitted by: Daan Vreeken <Daan vitsch.nl>
This commit is contained in:
parent
f2fbdacbf8
commit
3932d76033
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=239905
@ -443,21 +443,30 @@ ifc_alloc_unit(struct if_clone *ifc, int *unit)
|
||||
|
||||
wildcard = (*unit < 0);
|
||||
retry:
|
||||
if (wildcard) {
|
||||
if (*unit > ifc->ifc_maxunit)
|
||||
return (ENOSPC);
|
||||
if (*unit < 0) {
|
||||
*unit = alloc_unr(ifc->ifc_unrhdr);
|
||||
if (*unit == -1)
|
||||
return (ENOSPC);
|
||||
} else {
|
||||
*unit = alloc_unr_specific(ifc->ifc_unrhdr, *unit);
|
||||
if (*unit == -1)
|
||||
return (EEXIST);
|
||||
if (*unit == -1) {
|
||||
if (wildcard) {
|
||||
(*unit)++;
|
||||
goto retry;
|
||||
} else
|
||||
return (EEXIST);
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(name, IFNAMSIZ, "%s%d", ifc->ifc_name, *unit);
|
||||
if (ifunit(name) != NULL) {
|
||||
if (wildcard)
|
||||
goto retry; /* XXXGL: yep, it's a unit leak */
|
||||
else
|
||||
free_unr(ifc->ifc_unrhdr, *unit);
|
||||
if (wildcard) {
|
||||
(*unit)++;
|
||||
goto retry;
|
||||
} else
|
||||
return (EEXIST);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user