X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drl%2Fulogd_DRL.c;h=97f24bc7fb97334df7e969d802da649cf09d0e53;hb=91a15e535c5d367183c02d6624ada2d1b03e3870;hp=f9d6d5642ea19ddef4773b289506d8cd24984c23;hpb=9f79e9f0c22d7d87c4369ca6441571d9c155bf95;p=distributedratelimiting.git diff --git a/drl/ulogd_DRL.c b/drl/ulogd_DRL.c index f9d6d56..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, @@ -140,8 +148,16 @@ static config_entry_t partition = { .u = { .value = 0xfffffff }, }; -static config_entry_t netem_slice = { +static config_entry_t sfq_slice = { .next = &partition, + .key = "sfq_slice", + .type = CONFIG_TYPE_STRING, + .options = CONFIG_OPT_NONE, + .u = { .string = "NONE" }, +}; + +static config_entry_t netem_slice = { + .next = &sfq_slice, .key = "netem_slice", .type = CONFIG_TYPE_STRING, .options = CONFIG_OPT_NONE, @@ -271,9 +287,9 @@ extern FILE *logfile; extern uint8_t system_loglevel; extern uint8_t do_enforcement; -/* From peer_comm.c - used to simulate partition. */ -extern int do_partition; -extern int partition_set; +/* Used to simulate partitions. */ +int do_partition = 0; +int partition_set = 0xfffffff; /* functions */ @@ -689,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; } @@ -728,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; } @@ -1072,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) { @@ -1141,11 +1181,36 @@ static inline int add_htb_netem(const char *iface, const uint32_t parent_major, return execute_cmd(cmd); } +static inline int add_htb_sfq(const char *iface, const uint32_t parent_major, + const uint32_t parent_minor, const uint32_t handle, + const int perturb) { + char cmd[300]; + + sprintf(cmd, "/sbin/tc qdisc del dev %s parent %x:%x handle %x pfifo", iface, parent_major, + parent_minor, handle); + printlog(LOG_WARN, "HTB_cmd: %s\n", cmd); + if (execute_cmd(cmd)) + printlog(LOG_WARN, "HTB_cmd: Previous deletion did not succeed.\n"); + + sprintf(cmd, "/sbin/tc qdisc replace dev %s parent %x:%x handle %x sfq perturb %d", + iface, parent_major, parent_minor, handle, perturb); + printlog(LOG_WARN, "HTB_cmd: %s\n", cmd); + return execute_cmd(cmd); +} + static int create_htb_hierarchy(drl_instance_t *instance) { char cmd[300]; 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); @@ -1273,6 +1338,30 @@ static int create_htb_hierarchy(drl_instance_t *instance) { } } + /* Turn on SFQ for experimentation. */ + if (strcmp(sfq_slice.u.string, "NONE")) { + if (!strcmp(sfq_slice.u.string, "ALL")) { + if (add_htb_sfq("eth0", 1, 0x1000, 0x1000, 30)) + return 1; + if (add_htb_sfq("eth0", 1, 0x1fff, 0x1fff, 30)) + return 1; + + for (k = 0; k < instance->leaf_count; ++k) { + if (add_htb_sfq("eth0", 1, (0x1000 | instance->leaves[k].xid), + (0x1000 | instance->leaves[k].xid), 30)) { + return 1; + } + } + } else { + uint32_t slice_xid; + + sscanf(sfq_slice.u.string, "%x", &slice_xid); + + if (add_htb_sfq("eth0", 1, slice_xid, slice_xid, 30)) + return 1; + } + } + return 0; }