From 18fbdea74760834639eb1f1df71ab4cb672dfed0 Mon Sep 17 00:00:00 2001 From: Kevin Webb Date: Wed, 27 Jan 2010 16:06:59 +0000 Subject: [PATCH] When create_htb=0 is specified in ulogd.conf, DRL now ensures that each identity's specified htb_node and htb_parent exist and are valid. --- drl/ulogd_DRL.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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"); -- 2.43.0