From 4beac2bba3083d8ee73c49b9ad51e6af1e2c9af4 Mon Sep 17 00:00:00 2001 From: Kevin Webb Date: Mon, 25 Jan 2010 19:20:59 +0000 Subject: [PATCH] Added the option to manually specify which htb node/parent an identity should be associated with. This makes it easier for us to play nicely with the node manager. --- drl/config.c | 17 +++++++++++++++++ drl/config.h | 8 ++++++++ drl/ulogd_DRL.c | 42 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/drl/config.c b/drl/config.c index d9d9ede..261ce0c 100644 --- a/drl/config.c +++ b/drl/config.c @@ -113,6 +113,8 @@ static int parse_common(xmlDocPtr doc, xmlNodePtr ident, ident_config *common) { xmlChar *mainloop_intervals; xmlChar *communication_intervals; xmlChar *independent; + xmlChar *htb_node; + xmlChar *htb_parent; xmlNodePtr fields = ident->children; ident_peer *current = NULL; @@ -266,6 +268,21 @@ static int parse_common(xmlDocPtr doc, xmlNodePtr ident, ident_config *common) { xmlFree(independent); } + htb_node = xmlGetProp(ident, (const xmlChar *) "htb_node"); + htb_parent = xmlGetProp(ident, (const xmlChar *) "htb_parent"); + if (htb_node == NULL) { + common->htb_node = -1; + } else { + sscanf((const char *)htb_node, "%x", &common->htb_node); + xmlFree(htb_node); + } + if (htb_parent == NULL) { + common->htb_parent = -1; + } else { + sscanf((const char *)htb_parent, "%x", &common->htb_parent); + xmlFree(htb_parent); + } + while (fields != NULL) { if((!xmlStrcmp(fields->name, (const xmlChar *) "peer"))) { xmlChar *ip = xmlNodeListGetString(doc, fields->children, 1); diff --git a/drl/config.h b/drl/config.h index 883b641..f50ea3f 100644 --- a/drl/config.h +++ b/drl/config.h @@ -113,6 +113,14 @@ typedef struct ident_config { /** List of the identity's members (type IDENT_SET only). */ ident_member *members; + /** If NM is setting up the hierarchy for us, this is the htb node to use + * for this identity. */ + int htb_node; + + /** If NM is setting up the hierarchy for us, this is the htb parent node + * to use for this identity. */ + int htb_parent; + /** Pointer to the next ident in the list or NULL if this is the last. */ struct ident_config *next; } ident_config; diff --git a/drl/ulogd_DRL.c b/drl/ulogd_DRL.c index e24b41c..97f24bc 100644 --- a/drl/ulogd_DRL.c +++ b/drl/ulogd_DRL.c @@ -124,8 +124,16 @@ * Add the config options for DRL. */ -static config_entry_t enforce_on = { +static config_entry_t create_htb = { .next = NULL, + .key = "create_htb", + .type = CONFIG_TYPE_INT, + .options = CONFIG_OPT_NONE, + .u = { .value = 1 }, +}; + +static config_entry_t enforce_on = { + .next = &create_htb, .key = "enforce_on", .type = CONFIG_TYPE_INT, .options = CONFIG_OPT_NONE, @@ -697,6 +705,11 @@ static identity_t *new_identity(ident_config *config) { ident->comm.remote_nodes = comm_nodes; + if (!create_htb.u.value) { + ident->htb_node = config->htb_node; + ident->htb_parent = config->htb_parent; + } + return ident; } @@ -736,6 +749,17 @@ static int validate_config(ident_config *config) { return 1; } + if (!create_htb.u.value) { + if (config->htb_node < 0 || config->htb_parent < 0) { + 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; + } + } 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"); + } + } + /* Note: Parsing stage requires that each ident has at least one peer. */ return 0; } @@ -1080,6 +1104,14 @@ static int assign_htb_hierarchy(drl_instance_t *instance) { int i, j; int next_node = 0x100; + /* If we're not going to create our own htb hierarchy (for instance, + * if we're going to let PL's node manager do it for us), then we don't + * want this function to do anything. */ + if (!create_htb.u.value) { + printlog(LOG_DEBUG, "Skipping assign_htb_hierarchy becase ulogd.conf's create_htb set to 0.\n"); + return 0; + } + /* Chain machine nodes under 1:10. */ for (i = 0; i < instance->machine_count; ++i) { if (instance->machines[i]->parent == NULL) { @@ -1171,6 +1203,14 @@ static int create_htb_hierarchy(drl_instance_t *instance) { int i, j, k; uint64_t gigabit = 1024 * 1024 * 1024; + /* If we're not going to create our own htb hierarchy (for instance, + * if we're going to let PL's node manager do it for us), then we don't + * want this function to do anything. */ + if (!create_htb.u.value) { + printlog(LOG_DEBUG, "Skipping create_htb_hierarchy becase ulogd.conf's create_htb set to 0.\n"); + return 0; + } + /* Nuke the hierarchy. */ sprintf(cmd, "tc qdisc del dev eth0 root handle 1: htb"); execute_cmd(cmd); -- 2.43.0