Correctly parse and generate classids

Make sure to parse strings starting with a hex represention letter
but not representing a valid number as tc names.

Fix typo while generating classid.
This commit is contained in:
Thomas Graf 2010-11-01 13:17:19 +01:00
parent 4267d8f336
commit 4e48d90e71

View file

@ -170,6 +170,7 @@ int rtnl_tc_str2handle(const char *str, uint32_t *res)
/* MAJ is not a number */
if (colon == str) {
not_a_number:
if (*colon == ':') {
/* :YYYY */
h = 0;
@ -233,7 +234,7 @@ update:
/* XXXXYYYY */
*res = h;
} else
return -NLE_INVAL;
goto not_a_number;
return 0;
}
@ -384,9 +385,9 @@ int rtnl_classid_generate(const char *name, uint32_t *result, uint32_t parent)
} else {
classid = TC_H_MAJ(parent);
do {
if (++classid == TC_H_MIN(TC_H_ROOT))
if (TC_H_MIN(++classid) == TC_H_MIN(TC_H_ROOT))
return -NLE_RANGE;
} while (name_lookup(base));
} while (name_lookup(classid));
}
NL_DBG(2, "Generated new classid %#x\n", classid);