X-Git-Url: http://git.onelab.eu/?p=distributedratelimiting.git;a=blobdiff_plain;f=drl%2Fulogd_DRL.c;h=8d9b20c178e3f546d175b575515a87b9d4ef33a6;hp=170ab4375ea7e122ce901ec224882f9ebcd51332;hb=18fbdea74760834639eb1f1df71ab4cb672dfed0;hpb=9b2d5bae89c66b965393d43ef6294112ff78919b diff --git a/drl/ulogd_DRL.c b/drl/ulogd_DRL.c index 170ab43..8d9b20c 100644 --- a/drl/ulogd_DRL.c +++ b/drl/ulogd_DRL.c @@ -713,6 +713,25 @@ static identity_t *new_identity(ident_config *config) { return ident; } +static int validate_htb_exists(int node, int parent) { + FILE *pipe = popen("/sbin/tc class show dev eth0", "r"); + char line[200]; + + while (fgets(line, 200, pipe) != NULL) { + int n, p; + char ignore[200]; + + sscanf(line, "class htb 1:%x parent 1:%x prio %s", &n, &p, ignore); + if (n == node && p == parent) { + pclose(pipe); + return 0; + } + } + + pclose(pipe); + return 1; +} + /* Determines the validity of the parameters of one ident_config. * * 0 valid @@ -754,6 +773,11 @@ static int validate_config(ident_config *config) { printlog(LOG_CRITICAL, "When create_htb is disabled in ulogd.conf, an identity must specify the htb_node and htb_parent propertities in its configuration.\n"); return 1; } + + if (validate_htb_exists(config->htb_node, config->htb_parent)) { + printlog(LOG_CRITICAL, "Identity specified htb node %x with parent %x. No such node/parent combo seems to exist!\n", config->htb_node, config->htb_parent); + return 1; + } } else { if (config->htb_node > -1 || config->htb_parent > -1) { printlog(LOG_WARN, "htb_node or htb_parent are configured but ignored because we're configured to create our own htb hierarchy.\n");