Added the option to manually specify which htb node/parent an identity should be...
authorKevin Webb <kcwebb@ucsd.edu>
Mon, 25 Jan 2010 19:20:59 +0000 (19:20 +0000)
committerKevin Webb <kcwebb@ucsd.edu>
Mon, 25 Jan 2010 19:20:59 +0000 (19:20 +0000)
drl/config.c
drl/config.h
drl/ulogd_DRL.c

index d9d9ede..261ce0c 100644 (file)
@@ -113,6 +113,8 @@ static int parse_common(xmlDocPtr doc, xmlNodePtr ident, ident_config *common) {
     xmlChar *mainloop_intervals;
     xmlChar *communication_intervals;
     xmlChar *independent;
     xmlChar *mainloop_intervals;
     xmlChar *communication_intervals;
     xmlChar *independent;
+    xmlChar *htb_node;
+    xmlChar *htb_parent;
     xmlNodePtr fields = ident->children;
     ident_peer *current = NULL;
 
     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);
     }
 
         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);
     while (fields != NULL) {
         if((!xmlStrcmp(fields->name, (const xmlChar *) "peer"))) {
             xmlChar *ip = xmlNodeListGetString(doc, fields->children, 1);
index 883b641..f50ea3f 100644 (file)
@@ -113,6 +113,14 @@ typedef struct ident_config {
     /** List of the identity's members (type IDENT_SET only). */
     ident_member *members;
 
     /** 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;
     /** Pointer to the next ident in the list or NULL if this is the last. */
     struct ident_config *next;
 } ident_config;
index e24b41c..97f24bc 100644 (file)
  * Add the config options for DRL. 
  */
 
  * Add the config options for DRL. 
  */
 
-static config_entry_t enforce_on = {
+static config_entry_t create_htb = {
     .next = NULL,
     .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,
     .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;
 
 
     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;
 }
 
     return ident;
 }
 
@@ -736,6 +749,17 @@ static int validate_config(ident_config *config) {
         return 1;
     }
 
         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;
 }
     /* 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;
 
     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) {
     /* 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;
 
     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);
     /* Nuke the hierarchy. */
     sprintf(cmd, "tc qdisc del dev eth0 root handle 1: htb");
     execute_cmd(cmd);