Alexander Duyck | fe1a34f | 2008-12-05 14:16:42 -0800 | [diff] [blame] | 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 | * |
Stephen Hemminger | 4d98ab0 | 2013-12-06 15:05:07 -0800 | [diff] [blame] | 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>. |
Alexander Duyck | fe1a34f | 2008-12-05 14:16:42 -0800 | [diff] [blame] | 17 | * |
| 18 | * Author: Alexander Duyck <alexander.h.duyck@intel.com> |
| 19 | * |
| 20 | * Original Authors: PJ Waskiewicz, <peter.p.waskiewicz.jr@intel.com> (RR) |
Stephen Hemminger | 3d0b743 | 2014-12-20 15:47:17 -0800 | [diff] [blame] | 21 | * Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> (from PRIO) |
Alexander Duyck | fe1a34f | 2008-12-05 14:16:42 -0800 | [diff] [blame] | 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 | |
| 38 | static void explain(void) |
| 39 | { |
| 40 | fprintf(stderr, "Usage: ... multiq [help]\n"); |
| 41 | } |
| 42 | |
Alexander Duyck | fe1a34f | 2008-12-05 14:16:42 -0800 | [diff] [blame] | 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 | |
Petr Sabata | 5582c0c | 2011-06-10 03:19:07 +0000 | [diff] [blame] | 48 | if (argc) { |
Alexander Duyck | fe1a34f | 2008-12-05 14:16:42 -0800 | [diff] [blame] | 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 | } |
Alexander Duyck | fe1a34f | 2008-12-05 14:16:42 -0800 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt)); |
| 60 | return 0; |
| 61 | } |
| 62 | |
Stephen Hemminger | d1f28cf | 2013-02-12 11:09:03 -0800 | [diff] [blame] | 63 | static int multiq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) |
Alexander Duyck | fe1a34f | 2008-12-05 14:16:42 -0800 | [diff] [blame] | 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 | }; |