Remove all trailing whitespace and space before tabs.
20 files changed:
perror("dump request failed");
exit(1);
}
perror("dump request failed");
exit(1);
}
}
static void get_kern_msg(void)
}
static void get_kern_msg(void)
eol, n->name);
eol = ",\n";
for (i=0; i<MAXS && stats[i]; i++)
eol, n->name);
eol = ",\n";
for (i=0; i<MAXS && stats[i]; i++)
- fprintf(fp, " \"%s\":%llu",
+ fprintf(fp, " \"%s\":%llu",
stats[i], vals[i]);
fprintf(fp, "}");
} else {
fprintf(fp, "%d %s ", n->ifindex, n->name);
for (i=0; i<MAXS; i++)
stats[i], vals[i]);
fprintf(fp, "}");
} else {
fprintf(fp, "%d %s ", n->ifindex, n->name);
for (i=0; i<MAXS; i++)
- fprintf(fp, "%llu %u ", vals[i],
+ fprintf(fp, "%llu %u ", vals[i],
(unsigned)rates[i]);
fprintf(fp, "\n");
}
(unsigned)rates[i]);
fprintf(fp, "\n");
}
{
int i, m;
const char *sep = " ";
{
int i, m;
const char *sep = " ";
m = show_errors ? 20 : 10;
fprintf(fp, " \"%s\":{", n->name);
for (i=0; i < m && stats[i]; i++) {
m = show_errors ? 20 : 10;
fprintf(fp, " \"%s\":{", n->name);
for (i=0; i < m && stats[i]; i++) {
- fprintf(fp, "%s\"%s\":%llu",
+ fprintf(fp, "%s\"%s\":%llu",
sep, stats[i], vals[i]);
sep = ", ";
}
sep, stats[i], vals[i]);
sep = ", ";
}
#define MAX_FIELDS 128
/* Maximum number of header lines */
#define MAX_FIELDS 128
/* Maximum number of header lines */
/* default field width if none specified */
#define FIELD_WIDTH_DEFAULT 8
/* default field width if none specified */
#define FIELD_WIDTH_DEFAULT 8
fputs("{\n", of);
for (i = 0; i < fp->num; i++) {
const struct lnstat_field *lf = fp->params[i].lf;
fputs("{\n", of);
for (i = 0; i < fp->num; i++) {
const struct lnstat_field *lf = fp->params[i].lf;
if (!base || lf->file->basename != base) {
if (base) fputs("},\n", of);
base = lf->file->basename;
if (!base || lf->file->basename != base) {
if (base) fputs("},\n", of);
base = lf->file->basename;
if (!fps->params[j].print.width)
fps->params[j].print.width =
FIELD_WIDTH_DEFAULT;
if (!fps->params[j].print.width)
fps->params[j].print.width =
FIELD_WIDTH_DEFAULT;
if (++j >= MAX_FIELDS - 1) {
fprintf(stderr,
"WARN: MAX_FIELDS (%d) reached,"
if (++j >= MAX_FIELDS - 1) {
fprintf(stderr,
"WARN: MAX_FIELDS (%d) reached,"
tok;
tok = strtok(NULL, ",")) {
if (fp.num >= MAX_FIELDS) {
tok;
tok = strtok(NULL, ",")) {
if (fp.num >= MAX_FIELDS) {
"WARN: too many keys"
" requested: (%d max)\n",
MAX_FIELDS);
"WARN: too many keys"
" requested: (%d max)\n",
MAX_FIELDS);
printf(" sk:");
if (r->id.idiag_cookie[1] != 0)
printf("%08x", r->id.idiag_cookie[1]);
printf(" sk:");
if (r->id.idiag_cookie[1] != 0)
printf("%08x", r->id.idiag_cookie[1]);
- printf("%08x", r->id.idiag_cookie[0]);
+ printf("%08x", r->id.idiag_cookie[0]);
if (tb[INET_DIAG_SHUTDOWN]) {
unsigned char mask;
mask = *(__u8 *)RTA_DATA(tb[INET_DIAG_SHUTDOWN]);
if (tb[INET_DIAG_SHUTDOWN]) {
unsigned char mask;
mask = *(__u8 *)RTA_DATA(tb[INET_DIAG_SHUTDOWN]);
int uid;
int ino;
unsigned long long sk;
int uid;
int ino;
unsigned long long sk;
if (preferred_family != AF_PACKET && !(f->states & (1 << SS_CLOSE)))
return 0;
if (preferred_family != AF_PACKET && !(f->states & (1 << SS_CLOSE)))
return 0;
/*
* f_flow.c Flow filter
*
/*
* f_flow.c Flow filter
*
- * 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.
+ * 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: Patrick McHardy <kaber@trash.net>
*/
*
* Authors: Patrick McHardy <kaber@trash.net>
*/
*argv_p = argv;
return res;
}
*argv_p = argv;
return res;
}
static int parse_ip6(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
{
int res = -1;
static int parse_ip6(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
{
int res = -1;
} else if (matches(*argv, "ether") == 0) {
NEXT_ARG();
res = parse_ether(&argc, &argv, sel);
} else if (matches(*argv, "ether") == 0) {
NEXT_ARG();
res = parse_ether(&argc, &argv, sel);
return -1;
*argc_p = argc;
return -1;
*argc_p = argc;
case 16: {
int bits = mask2bits(key->mask);
if (bits >= 0) {
case 16: {
int bits = mask2bits(key->mask);
if (bits >= 0) {
- fprintf(f, "\n %s %s/%d",
+ fprintf(f, "\n %s %s/%d",
key->off == 12 ? "match IP src" : "match IP dst",
inet_ntop(AF_INET, &key->val,
abuf, sizeof(abuf)),
key->off == 12 ? "match IP src" : "match IP dst",
inet_ntop(AF_INET, &key->val,
abuf, sizeof(abuf)),
case 16: {
int bits = mask2bits(key->mask);
if (bits >= 0) {
case 16: {
int bits = mask2bits(key->mask);
if (bits >= 0) {
- fprintf(f, "\n %s %s/%d",
+ fprintf(f, "\n %s %s/%d",
key->off == 12 ? "match IP src" : "match IP dst",
inet_ntop(AF_INET, &key->val,
abuf, sizeof(abuf)),
key->off == 12 ? "match IP src" : "match IP dst",
inet_ntop(AF_INET, &key->val,
abuf, sizeof(abuf)),
static void print_raw(FILE *f, const struct tc_u32_key *key)
{
static void print_raw(FILE *f, const struct tc_u32_key *key)
{
- fprintf(f, "\n match %08x/%08x at %s%d",
+ fprintf(f, "\n match %08x/%08x at %s%d",
(unsigned int)ntohl(key->val),
(unsigned int)ntohl(key->mask),
key->offmask ? "nexthdr+" : "",
(unsigned int)ntohl(key->val),
(unsigned int)ntohl(key->mask),
key->offmask ? "nexthdr+" : "",
/* We dont necessarily need class/flowids */
if (terminal_ok)
sel.sel.flags |= TC_U32_TERMINAL;
/* We dont necessarily need class/flowids */
if (terminal_ok)
sel.sel.flags |= TC_U32_TERMINAL;
if (order) {
if (TC_U32_NODE(t->tcm_handle) && order != TC_U32_NODE(t->tcm_handle)) {
fprintf(stderr, "\"order\" contradicts \"handle\"\n");
if (order) {
if (TC_U32_NODE(t->tcm_handle) && order != TC_U32_NODE(t->tcm_handle)) {
fprintf(stderr, "\"order\" contradicts \"handle\"\n");
if (htid)
addattr_l(n, MAX_MSG, TCA_U32_HASH, &htid, 4);
if (sel_ok)
if (htid)
addattr_l(n, MAX_MSG, TCA_U32_HASH, &htid, 4);
if (sel_ok)
- addattr_l(n, MAX_MSG, TCA_U32_SEL, &sel,
+ addattr_l(n, MAX_MSG, TCA_U32_SEL, &sel,
sizeof(sel.sel)+sel.sel.nkeys*sizeof(struct tc_u32_key));
tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
return 0;
sizeof(sel.sel)+sel.sel.nkeys*sizeof(struct tc_u32_key));
tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
return 0;
/*
* m_ipt.c iptables based targets
/*
* m_ipt.c iptables based targets
- * utilities mostly ripped from iptables <duh, its the linux way>
+ * utilities mostly ripped from iptables <duh, its the linux way>
*
* This program is free software; you can distribute it and/or
* modify it under the terms of the GNU General Public License
*
* This program is free software; you can distribute it and/or
* modify it under the terms of the GNU General Public License
* Authors: J Hadi Salim (hadi@cyberus.ca)
*
* TODO:
* Authors: J Hadi Salim (hadi@cyberus.ca)
*
* TODO:
- * 1) Big endian broken in some spots
- * 2) A lot of this stuff was added on the fly; get a big double-double
- * and clean it up at some point.
+ * 1) Big endian broken in some spots
+ * 2) A lot of this stuff was added on the fly; get a big double-double
+ * and clean it up at some point.
* Authors: J Hadi Salim <jhs@mojatatu.com>
*
* Pedagogical example. Adds a string that will be printed every time
* Authors: J Hadi Salim <jhs@mojatatu.com>
*
* Pedagogical example. Adds a string that will be printed every time
- * the simple instance is hit.
+ * the simple instance is hit.
* Use this as a skeleton action and keep modifying it to meet your needs.
* Look at linux/tc_act/tc_defact.h for the different components ids and
* definitions used in this actions
* Use this as a skeleton action and keep modifying it to meet your needs.
* Look at linux/tc_act/tc_defact.h for the different components ids and
* definitions used in this actions
*
hadi@noma1:$ tc qdisc add dev eth0 ingress
hadi@noma1:$tc filter add dev eth0 parent ffff: protocol ip prio 5 \
*
hadi@noma1:$ tc qdisc add dev eth0 ingress
hadi@noma1:$tc filter add dev eth0 parent ffff: protocol ip prio 5 \
- u32 match ip protocol 1 0xff flowid 1:1 action simple "Incoming ICMP"
-
+ u32 match ip protocol 1 0xff flowid 1:1 action simple "Incoming ICMP"
+
hadi@noma1:$ sudo tc -s filter ls dev eth0 parent ffff:
hadi@noma1:$ sudo tc -s filter ls dev eth0 parent ffff:
- filter protocol ip pref 5 u32
- filter protocol ip pref 5 u32 fh 800: ht divisor 1
- filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
+ filter protocol ip pref 5 u32
+ filter protocol ip pref 5 u32 fh 800: ht divisor 1
+ filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
match 00010000/00ff0000 at 8
match 00010000/00ff0000 at 8
- action order 1: Simple <Incoming ICMP>
- index 4 ref 1 bind 1 installed 29 sec used 29 sec
- Action statistics:
- Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
- backlog 0b 0p requeues 0
-
-
+ action order 1: Simple <Incoming ICMP>
+ index 4 ref 1 bind 1 installed 29 sec used 29 sec
+ Action statistics:
+ Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
+ backlog 0b 0p requeues 0
+
+
hadi@noma1$ ping -c 1 www.google.ca
PING www.google.ca (74.125.225.120) 56(84) bytes of data.
64 bytes from ord08s08-in-f24.1e100.net (74.125.225.120): icmp_req=1 ttl=53 time=31.3 ms
hadi@noma1$ ping -c 1 www.google.ca
PING www.google.ca (74.125.225.120) 56(84) bytes of data.
64 bytes from ord08s08-in-f24.1e100.net (74.125.225.120): icmp_req=1 ttl=53 time=31.3 ms
[135354.473951] simple: Incoming ICMP_1
hadi@noma1$ sudo tc/tc -s filter ls dev eth0 parent ffff:
[135354.473951] simple: Incoming ICMP_1
hadi@noma1$ sudo tc/tc -s filter ls dev eth0 parent ffff:
- filter protocol ip pref 5 u32
- filter protocol ip pref 5 u32 fh 800: ht divisor 1
- filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
+ filter protocol ip pref 5 u32
+ filter protocol ip pref 5 u32 fh 800: ht divisor 1
+ filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
match 00010000/00ff0000 at 8
action order 1: Simple <Incoming ICMP>
index 4 ref 1 bind 1 installed 206 sec used 67 sec
Action statistics:
match 00010000/00ff0000 at 8
action order 1: Simple <Incoming ICMP>
index 4 ref 1 bind 1 installed 206 sec used 67 sec
Action statistics:
- Sent 84 bytes 1 pkt (dropped 0, overlimits 0 requeues 0)
- backlog 0b 0p requeues 0
+ Sent 84 bytes 1 pkt (dropped 0, overlimits 0 requeues 0)
+ backlog 0b 0p requeues 0
static void explain(void)
{
fprintf(stderr, "Usage: ... simple STRING\n"
static void explain(void)
{
fprintf(stderr, "Usage: ... simple STRING\n"
- "STRING being an arbitrary string\n"
+ "STRING being an arbitrary string\n"
"example: \"simple blah\"\n");
}
"example: \"simple blah\"\n");
}
static void
explain(void)
{
static void
explain(void)
{
- fprintf(stderr, "Usage: ... skbedit <[QM] [PM] [MM]>\n"
+ fprintf(stderr, "Usage: ... skbedit <[QM] [PM] [MM]>\n"
"QM = queue_mapping QUEUE_MAPPING\n"
"PM = priority PRIORITY \n"
"MM = mark MARK \n"
"QM = queue_mapping QUEUE_MAPPING\n"
"PM = priority PRIORITY \n"
"MM = mark MARK \n"
/*
* m_xt.c xtables based targets
/*
* m_xt.c xtables based targets
- * utilities mostly ripped from iptables <duh, its the linux way>
+ * utilities mostly ripped from iptables <duh, its the linux way>
*
* This program is free software; you can distribute it and/or
* modify it under the terms of the GNU General Public License
*
* This program is free software; you can distribute it and/or
* modify it under the terms of the GNU General Public License
/*
* m_xt.c xtables based targets
/*
* m_xt.c xtables based targets
- * utilities mostly ripped from iptables <duh, its the linux way>
+ * utilities mostly ripped from iptables <duh, its the linux way>
*
* This program is free software; you can distribute it and/or
* modify it under the terms of the GNU General Public License
*
* This program is free software; you can distribute it and/or
* modify it under the terms of the GNU General Public License
- /* Compute default min/max thresholds based on
+ /* Compute default min/max thresholds based on
Sally Floyd's recommendations:
http://www.icir.org/floyd/REDparameters.txt
*/
Sally Floyd's recommendations:
http://www.icir.org/floyd/REDparameters.txt
*/
opt.qth_max = opt.limit / 4;
if (!opt.qth_min)
opt.qth_min = opt.qth_max / 3;
opt.qth_max = opt.limit / 4;
if (!opt.qth_min)
opt.qth_min = opt.qth_max / 3;
-static int init_gred(struct qdisc_util *qu, int argc, char **argv,
+static int init_gred(struct qdisc_util *qu, int argc, char **argv,
return -1;
}
if (def_dp < 0 || def_dp > dps) {
return -1;
}
if (def_dp < 0 || def_dp > dps) {
"\"default DP\" must be less than %d\n",
opt.DPs);
return -1;
"\"default DP\" must be less than %d\n",
opt.DPs);
return -1;
* Author: Alexander Duyck <alexander.h.duyck@intel.com>
*
* Original Authors: PJ Waskiewicz, <peter.p.waskiewicz.jr@intel.com> (RR)
* Author: Alexander Duyck <alexander.h.duyck@intel.com>
*
* Original Authors: PJ Waskiewicz, <peter.p.waskiewicz.jr@intel.com> (RR)
- * Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> (from PRIO)
+ * Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> (from PRIO)
fprintf(stderr, "loss in the weeds!\n");
return -1;
}
fprintf(stderr, "loss in the weeds!\n");
return -1;
}
addattr_nest_end(n, start);
}
addattr_nest_end(n, start);
}
gimodel = RTA_DATA(lb[NETEM_LOSS_GI]);
if (lb[NETEM_LOSS_GE])
gemodel = RTA_DATA(lb[NETEM_LOSS_GE]);
gimodel = RTA_DATA(lb[NETEM_LOSS_GI]);
if (lb[NETEM_LOSS_GE])
gemodel = RTA_DATA(lb[NETEM_LOSS_GE]);
if (tb[TCA_NETEM_RATE]) {
if (RTA_PAYLOAD(tb[TCA_NETEM_RATE]) < sizeof(*rate))
return -1;
if (tb[TCA_NETEM_RATE]) {
if (RTA_PAYLOAD(tb[TCA_NETEM_RATE]) < sizeof(*rate))
return -1;
fprintf(stderr, "Required parameter (redflowlimit) is missing\n");
return -1;
}
fprintf(stderr, "Required parameter (redflowlimit) is missing\n");
return -1;
}
- /* Compute default min/max thresholds based on
+ /* Compute default min/max thresholds based on
Sally Floyd's recommendations:
http://www.icir.org/floyd/REDparameters.txt
*/
Sally Floyd's recommendations:
http://www.icir.org/floyd/REDparameters.txt
*/
opt.qth_max = opt.limit / 4;
if (!opt.qth_min)
opt.qth_min = opt.qth_max / 3;
opt.qth_max = opt.limit / 4;
if (!opt.qth_min)
opt.qth_min = opt.qth_max / 3;
} else if (strcmp(*argv, "handle") == 0) {
fprintf(stderr, "Error: try \"classid\" instead of \"handle\"\n");
return -1;
} else if (strcmp(*argv, "handle") == 0) {
fprintf(stderr, "Error: try \"classid\" instead of \"handle\"\n");
return -1;
- } else if (strcmp(*argv, "root") == 0) {
+ } else if (strcmp(*argv, "root") == 0) {
if (req.t.tcm_parent) {
fprintf(stderr, "Error: \"root\" is duplicate parent ID.\n");
return -1;
if (req.t.tcm_parent) {
fprintf(stderr, "Error: \"root\" is duplicate parent ID.\n");
return -1;
if (d[0]) {
if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
if (d[0]) {
if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
filter_ifindex = t.tcm_ifindex;
}
filter_ifindex = t.tcm_ifindex;
}
- if (rtnl_dump_request(&rth, RTM_GETTCLASS, &t, sizeof(t)) < 0) {
+ if (rtnl_dump_request(&rth, RTM_GETTCLASS, &t, sizeof(t)) < 0) {
perror("Cannot send dump request");
return 1;
}
perror("Cannot send dump request");
return 1;
}
- if (rtnl_dump_filter(&rth, print_class, stdout) < 0) {
+ if (rtnl_dump_filter(&rth, print_class, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
return 1;
}
fprintf(stderr, "Dump terminated\n");
return 1;
}
if ((req.t.tcm_ifindex = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d);
if ((req.t.tcm_ifindex = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d);
t.tcm_info = TC_H_MAKE(prio<<16, protocol);
t.tcm_info = TC_H_MAKE(prio<<16, protocol);
if (d[0]) {
if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
if (d[0]) {
if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
filter_ifindex = t.tcm_ifindex;
}
filter_ifindex = t.tcm_ifindex;
}
- if (rtnl_dump_request(&rth, RTM_GETTFILTER, &t, sizeof(t)) < 0) {
+ if (rtnl_dump_request(&rth, RTM_GETTFILTER, &t, sizeof(t)) < 0) {
perror("Cannot send dump request");
return 1;
}
perror("Cannot send dump request");
return 1;
}
- if (rtnl_dump_filter(&rth, print_filter, stdout) < 0) {
+ if (rtnl_dump_filter(&rth, print_filter, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
return 1;
}
fprintf(stderr, "Dump terminated\n");
return 1;
}
if ((idx = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d);
if ((idx = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d);
if (d[0]) {
if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
if (d[0]) {
if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
filter_ifindex = t.tcm_ifindex;
}
filter_ifindex = t.tcm_ifindex;
}
- if (rtnl_dump_request(&rth, RTM_GETQDISC, &t, sizeof(t)) < 0) {
+ if (rtnl_dump_request(&rth, RTM_GETQDISC, &t, sizeof(t)) < 0) {
perror("Cannot send dump request");
return 1;
}
perror("Cannot send dump request");
return 1;
}
- if (rtnl_dump_filter(&rth, print_qdisc, stdout) < 0) {
+ if (rtnl_dump_filter(&rth, print_qdisc, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
return 1;
}
fprintf(stderr, "Dump terminated\n");
return 1;
}