Updates to autotools for library detection
[distributedratelimiting.git] / drl / ulogd_DRL.c
index f9d6d56..e24b41c 100644 (file)
@@ -140,8 +140,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 +279,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 */
 
@@ -1141,6 +1149,23 @@ 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;
@@ -1273,6 +1298,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;
 }