| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* |
| 3 |
* q_multiq.c Multiqueue aware qdisc |
| 4 |
* |
| 5 |
* Copyright (c) 2008, Intel Corporation. |
| 6 |
* |
| 7 |
* Author: Alexander Duyck <[email protected]> |
| 8 |
* |
| 9 |
* Original Authors: PJ Waskiewicz, <[email protected]> (RR) |
| 10 |
* Alexey Kuznetsov, <[email protected]> (from PRIO) |
| 11 |
* |
| 12 |
*/ |
| 13 |
|
| 14 |
#include <stdio.h> |
| 15 |
#include <stdlib.h> |
| 16 |
#include <unistd.h> |
| 17 |
#include <fcntl.h> |
| 18 |
#include <sys/socket.h> |
| 19 |
#include <netinet/in.h> |
| 20 |
#include <arpa/inet.h> |
| 21 |
#include <string.h> |
| 22 |
|
| 23 |
#include "utils.h" |
| 24 |
#include "tc_util.h" |
| 25 |
|
| 26 |
static void explain(void) |
| 27 |
{ |
| 28 |
fprintf(stderr, "Usage: ... multiq [help]\n"); |
| 29 |
} |
| 30 |
|
| 31 |
static int multiq_parse_opt(const struct qdisc_util *qu, int argc, char **argv, |
| 32 |
struct nlmsghdr *n, const char *dev) |
| 33 |
{ |
| 34 |
struct tc_multiq_qopt opt = {}; |
| 35 |
|
| 36 |
if (argc) { |
| 37 |
if (strcmp(*argv, "help") == 0) { |
| 38 |
explain(); |
| 39 |
return -1; |
| 40 |
} else { |
| 41 |
fprintf(stderr, "What is \"%s\"?\n", *argv); |
| 42 |
explain(); |
| 43 |
return -1; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt)); |
| 48 |
return 0; |
| 49 |
} |
| 50 |
|
| 51 |
static int multiq_print_opt(const struct qdisc_util *qu, FILE *f, struct rtattr *opt) |
| 52 |
{ |
| 53 |
struct tc_multiq_qopt *qopt; |
| 54 |
|
| 55 |
if (opt == NULL) |
| 56 |
return 0; |
| 57 |
if (RTA_PAYLOAD(opt) < sizeof(*qopt)) |
| 58 |
return 0; |
| 59 |
|
| 60 |
qopt = RTA_DATA(opt); |
| 61 |
|
| 62 |
fprintf(f, "bands %u/%u ", qopt->bands, qopt->max_bands); |
| 63 |
|
| 64 |
return 0; |
| 65 |
} |
| 66 |
|
| 67 |
struct qdisc_util multiq_qdisc_util = { |
| 68 |
.id = "multiq", |
| 69 |
.parse_qopt = multiq_parse_opt, |
| 70 |
.print_qopt = multiq_print_opt, |
| 71 |
}; |