summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2010-11-01 12:17:19 (GMT)
committerThomas Graf <tgraf@suug.ch>2010-11-01 12:17:19 (GMT)
commit4e48d90e7164f8877930c7ae585ce1acfba5b7f5 (patch)
tree27f8638e34854418f0d47294b0f1309d34a64d68 /lib
parent4267d8f336b11e8fbbf1a4b54499ee19012b1b28 (diff)
downloadlibnl-4e48d90e7164f8877930c7ae585ce1acfba5b7f5.zip
libnl-4e48d90e7164f8877930c7ae585ce1acfba5b7f5.tar.gz
libnl-4e48d90e7164f8877930c7ae585ce1acfba5b7f5.tar.bz2
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/route/classid.c7
1 files 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);