lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20180117231244.26318-1-jesus.sanchez-palencia@intel.com>
Date:   Wed, 17 Jan 2018 15:12:44 -0800
From:   Jesus Sanchez-Palencia <jesus.sanchez-palencia@...el.com>
To:     netdev@...r.kernel.org
Cc:     jhs@...atatu.com, xiyou.wangcong@...il.com, jiri@...nulli.us,
        Vinicius Costa Gomes <vinicius.gomes@...el.com>
Subject: [RFC iproute2] tc: Add support for the TBS Qdisc

From: Vinicius Costa Gomes <vinicius.gomes@...el.com>

The Time Based Scheduler (TBS) queueing discipline allows precise
control of the transmission time of packets.

The syntax is:

tc qdisc add dev DEV parent NODE tbs delta <DELTA>
                     clockid <CLOCKID> offload <1|0>

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@...el.com>
---
 include/uapi/linux/pkt_sched.h |  17 ++++++
 tc/Makefile                    |   1 +
 tc/q_tbs.c                     | 119 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 tc/q_tbs.c

diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
index af3cc2f4..514cb742 100644
--- a/include/uapi/linux/pkt_sched.h
+++ b/include/uapi/linux/pkt_sched.h
@@ -935,4 +935,21 @@ enum {
 
 #define TCA_CBS_MAX (__TCA_CBS_MAX - 1)
 
+
+/* TBS */
+struct tc_tbs_qopt {
+	__u8 offload;
+	__u8 _pad[3];
+	__s32 delta;
+	__s32 clockid;
+};
+
+enum {
+	TCA_TBS_UNSPEC,
+	TCA_TBS_PARMS,
+	__TCA_TBS_MAX,
+};
+
+#define TCA_TBS_MAX (__TCA_TBS_MAX - 1)
+
 #endif
diff --git a/tc/Makefile b/tc/Makefile
index 3716dd6a..3c87b0dc 100644
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -71,6 +71,7 @@ TCMODULES += q_clsact.o
 TCMODULES += e_bpf.o
 TCMODULES += f_matchall.o
 TCMODULES += q_cbs.o
+TCMODULES += q_tbs.o
 
 TCSO :=
 ifeq ($(TC_CONFIG_ATM),y)
diff --git a/tc/q_tbs.c b/tc/q_tbs.c
new file mode 100644
index 00000000..f4a73b58
--- /dev/null
+++ b/tc/q_tbs.c
@@ -0,0 +1,119 @@
+/*
+ * q_tbs.c		TBS.
+ *
+ *		This program is free software; you can redistribute it and/or
+ *		modify it under the terms of the GNU General Public License
+ *		as published by the Free Software Foundation; either version
+ *		2 of the License, or (at your option) any later version.
+ *
+ * Authors:	Vinicius Costa Gomes <vinicius.gomes@...el.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+#include "utils.h"
+#include "tc_util.h"
+
+static void explain(void)
+{
+	fprintf(stderr, "Usage: ... tbs delta NANOS guardband NANOS clockid CLOCKID [offload 0|1]\n");
+
+}
+
+static void explain1(const char *arg, const char *val)
+{
+	fprintf(stderr, "tbs: illegal value for \"%s\": \"%s\"\n", arg, val);
+}
+
+static int tbs_parse_opt(struct qdisc_util *qu, int argc,
+			 char **argv, struct nlmsghdr *n, const char *dev)
+{
+	struct tc_tbs_qopt opt = {};
+	struct rtattr *tail;
+
+	while (argc > 0) {
+		if (matches(*argv, "offload") == 0) {
+			NEXT_ARG();
+			if (opt.offload) {
+				fprintf(stderr, "tbs: duplicate \"offload\" specification\n");
+				return -1;
+			}
+			if (get_u8(&opt.offload, *argv, 0)) {
+				explain1("offload", *argv);
+				return -1;
+			}
+		} else if (matches(*argv, "delta") == 0) {
+			NEXT_ARG();
+			if (opt.delta) {
+				fprintf(stderr, "tbs: duplicate \"delta\" specification\n");
+				return -1;
+			}
+			if (get_s32(&opt.delta, *argv, 0)) {
+				explain1("hicredit", *argv);
+				return -1;
+			}
+		} else if (matches(*argv, "clockid") == 0) {
+			NEXT_ARG();
+			if (opt.clockid) {
+				fprintf(stderr, "tbs: duplicate \"clockid\" specification\n");
+				return -1;
+			}
+			if (get_s32(&opt.clockid, *argv, 0)) {
+				explain1("clockid", *argv);
+				return -1;
+			}
+		} else if (strcmp(*argv, "help") == 0) {
+			explain();
+			return -1;
+		} else {
+			fprintf(stderr, "tbs: unknown parameter \"%s\"\n", *argv);
+			explain();
+			return -1;
+		}
+		argc--; argv++;
+	}
+
+	tail = NLMSG_TAIL(n);
+	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+	addattr_l(n, 2024, TCA_TBS_PARMS, &opt, sizeof(opt));
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+	return 0;
+}
+
+static int tbs_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+{
+	struct rtattr *tb[TCA_TBS_MAX+1];
+	struct tc_tbs_qopt *qopt;
+
+	if (opt == NULL)
+		return 0;
+
+	parse_rtattr_nested(tb, TCA_TBS_MAX, opt);
+
+	if (tb[TCA_TBS_PARMS] == NULL)
+		return -1;
+
+	qopt = RTA_DATA(tb[TCA_TBS_PARMS]);
+	if (RTA_PAYLOAD(tb[TCA_TBS_PARMS])  < sizeof(*qopt))
+		return -1;
+
+	fprintf(f, "clockid %d ", qopt->clockid);
+	fprintf(f, "delta %d ", qopt->delta);
+	fprintf(f, "offload %d ", qopt->offload);
+
+	return 0;
+}
+
+struct qdisc_util tbs_qdisc_util = {
+	.id		= "tbs",
+	.parse_qopt	= tbs_parse_opt,
+	.print_qopt	= tbs_print_opt,
+};
-- 
2.15.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ