1 /*
2 * q_multiq.c Multiqueue aware qdisc
3 *
4 * Copyright (c) 2008, Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses>.
17 *
18 * Author: Alexander Duyck <alexander.h.duyck@intel.com>
19 *
20 * Original Authors: PJ Waskiewicz, <peter.p.waskiewicz.jr@intel.com> (RR)
21 * Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> (from PRIO)
22 *
23 */
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <unistd.h>
28 #include <syslog.h>
29 #include <fcntl.h>
30 #include <sys/socket.h>
31 #include <netinet/in.h>
32 #include <arpa/inet.h>
33 #include <string.h>
34
35 #include "utils.h"
36 #include "tc_util.h"
37
explain(void)38 static void explain(void)
39 {
40 fprintf(stderr, "Usage: ... multiq [help]\n");
41 }
42
multiq_parse_opt(struct qdisc_util * qu,int argc,char ** argv,struct nlmsghdr * n)43 static int multiq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
44 struct nlmsghdr *n)
45 {
46 struct tc_multiq_qopt opt;
47
48 if (argc) {
49 if (strcmp(*argv, "help") == 0) {
50 explain();
51 return -1;
52 } else {
53 fprintf(stderr, "What is \"%s\"?\n", *argv);
54 explain();
55 return -1;
56 }
57 }
58
59 addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
60 return 0;
61 }
62
multiq_print_opt(struct qdisc_util * qu,FILE * f,struct rtattr * opt)63 static int multiq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
64 {
65 struct tc_multiq_qopt *qopt;
66
67 if (opt == NULL)
68 return 0;
69 if (RTA_PAYLOAD(opt) < sizeof(*qopt))
70 return 0;
71
72 qopt = RTA_DATA(opt);
73
74 fprintf(f, "bands %u/%u ", qopt->bands, qopt->max_bands);
75
76 return 0;
77 }
78
79 struct qdisc_util multiq_qdisc_util = {
80 .id = "multiq",
81 .parse_qopt = multiq_parse_opt,
82 .print_qopt = multiq_print_opt,
83 };
84