From 4e48d90e7164f8877930c7ae585ce1acfba5b7f5 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Mon, 1 Nov 2010 13:17:19 +0100 Subject: [PATCH] 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. --- lib/route/classid.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/route/classid.c b/lib/route/classid.c index 0cb89b5..35cafe6 100644 --- a/lib/route/classid.c +++ b/lib/route/classid.c @@ -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);