Commit 86c392f9 authored by Stephen Hemminger's avatar Stephen Hemminger

Merge branch 'master' into net-next

parents c518d3a7 1473bda9
......@@ -263,4 +263,3 @@ int do_ipaddrlabel(int argc, char **argv)
fprintf(stderr, "Command \"%s\" is unknown, try \"ip addrlabel help\".\n", *argv);
exit(-1);
}
......@@ -156,4 +156,3 @@ int do_ipfou(int argc, char **argv)
fprintf(stderr, "Command \"%s\" is unknown, try \"ip fou help\".\n", *argv);
exit(-1);
}
......@@ -113,4 +113,3 @@ struct link_util bond_slave_link_util = {
.parse_opt = bond_slave_parse_opt,
.slave = true,
};
......@@ -107,4 +107,3 @@ int print_prefix(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
return 0;
}
......@@ -1842,4 +1842,3 @@ int do_iproute(int argc, char **argv)
fprintf(stderr, "Command \"%s\" is unknown, try \"ip route help\".\n", *argv);
exit(-1);
}
......@@ -508,4 +508,3 @@ int do_tcp_metrics(int argc, char **argv)
"try \"ip tcp_metrics help\".\n", *argv);
exit(-1);
}
......@@ -12,7 +12,9 @@ MAN8PAGES = $(TARGETS) ip.8 arpd.8 lnstat.8 routel.8 rtacct.8 rtmon.8 rtpr.8 ss.
ip-netns.8 ip-ntable.8 ip-rule.8 ip-tunnel.8 ip-xfrm.8 \
ip-tcp_metrics.8 ip-netconf.8 ip-token.8 \
tipc.8 tipc-bearer.8 tipc-link.8 tipc-media.8 tipc-nametable.8 \
tipc-node.8 tipc-socket.8
tipc-node.8 tipc-socket.8 \
tc-basic.8 tc-cgroup.8 tc-flow.8 tc-flower.8 tc-fw.8 tc-route.8 \
tc-tcindex.8 tc-u32.8
all: $(TARGETS)
......
.TH "Basic classifier in tc" 8 "21 Oct 2015" "iproute2" "Linux"
.SH NAME
basic \- basic traffic control filter
.SH SYNOPSIS
.in +8
.ti -8
.BR tc " " filter " ... " basic " [ " match
.IR EMATCH_TREE " ] [ "
.B action
.IR ACTION_SPEC " ] [ "
.B classid
.IR CLASSID " ]"
.SH DESCRIPTION
The
.B basic
filter allows to classify packets using the extended match infrastructure.
.SH OPTIONS
.TP
.BI action " ACTION_SPEC"
Apply an action from the generic actions framework on matching packets.
.TP
.BI classid " CLASSID"
Push matching packets into the class identified by
.IR CLASSID .
.TP
.BI match " EMATCH_TREE"
Match packets using the extended match infrastructure. See
.BR tc-ematch (8)
for a detailed description of the allowed syntax in
.IR EMATCH_TREE .
.SH SEE ALSO
.BR tc (8),
.BR tc-ematch (8)
.TH "Cgroup classifier in tc" 8 " 21 Oct 2015" "iproute2" "Linux"
.SH NAME
cgroup \- control group based traffic control filter
.SH SYNOPSIS
.in +8
.ti -8
.BR tc " " filter " ... " cgroup " [ " match
.IR EMATCH_TREE " ] [ "
.B action
.IR ACTION_SPEC " ]"
.SH DESCRIPTION
This filter serves as a hint to
.B tc
that the assigned class ID of the net_cls control group the process the packet
originates from belongs to should be used for classification. Obviously, it is
useful for locally generated packets only.
.SH OPTIONS
.TP
.BI action " ACTION_SPEC"
Apply an action from the generic actions framework on matching packets.
.TP
.BI match " EMATCH_TREE"
Match packets using the extended match infrastructure. See
.BR tc-ematch (8)
for a detailed description of the allowed syntax in
.IR EMATCH_TREE .
.SH EXAMPLES
In order to use this filter, a net_cls control group has to be created first and
class as well as process ID(s) assigned to it. The following creates a net_cls
cgroup named "foobar":
.RS
.EX
modprobe cls_cgroup
mkdir /sys/fs/cgroup/net_cls
mount -t cgroup -onet_cls net_cls /sys/fs/cgroup/net_cls
mkdir /sys/fs/cgroup/net_cls/foobar
.EE
.RE
To assign a class ID to the created cgroup, a file named
.I net_cls.classid
has to be created which contains the class ID to be assigned as a hexadecimal,
64bit wide number. The upper 32bits are reserved for the major handle, the
remaining hold the minor. So a class ID of e.g.
.B ff:be
has to be written like so:
.B 0xff00be
(leading zeroes may be omitted). To continue the above example, the following
assigns class ID 1:2 to foobar cgroup:
.RS
.EX
echo 0x10002 > /sys/fs/cgroup/net_cls/foobar/net_cls.classid
.EE
.RE
Finally some PIDs can be assigned to the given cgroup:
.RS
.EX
echo 1234 > /sys/fs/cgroup/net_cls/foobar/tasks
echo 5678 > /sys/fs/cgroup/net_cls/foobar/tasks
.EE
.RE
Now by simply attaching a
.B cgroup
filter to a
.B qdisc
makes packets from PIDs 1234 and 5678 be pushed into class 1:2.
.SH SEE ALSO
.BR tc (8),
.BR tc-ematch (8),
.br
the file
.I Documentation/cgroups/net_cls.txt
of the Linux kernel tree
.TH "Flow filter in tc" 8 "20 Oct 2015" "iproute2" "Linux"
.SH NAME
flow \- flow based traffic control filter
.SH SYNOPSIS
.TP
Mapping mode:
.RS
.in +8
.ti -8
.BR tc " " filter " ... " "flow map key "
.IR KEY " [ " OPS " ] [ " OPTIONS " ] "
.RE
.TP
Hashing mode:
.RS
.in +8
.ti -8
.BR tc " " filter " ... " "flow hash keys "
.IR KEY_LIST " [ "
.B perturb
.IR secs " ] [ " OPTIONS " ] "
.RE
.in +8
.ti -8
.IR OPS " := [ " OPS " ] " OP
.ti -8
.IR OPTIONS " := [ "
.B divisor
.IR NUM " ] [ "
.B baseclass
.IR ID " ] [ "
.B match
.IR EMATCH_TREE " ] [ "
.B action
.IR ACTION_SPEC " ]"
.ti -8
.IR KEY_LIST " := [ " KEY_LIST " ] " KEY
.ti -8
.IR OP " := { "
.BR or " | " and " | " xor " | " rshift " | " addend " } "
.I NUM
.ti -8
.IR ID " := " X : Y
.ti -8
.IR KEY " := { "
.BR src " | " dst " | " proto " | " proto-src " | " proto-dst " | " iif " | "
.BR priority " | " mark " | " nfct " | " nfct-src " | " nfct-dst " | "
.BR nfct-proto-src " | " nfct-proto-dst " | " rt-classid " | " sk-uid " | "
.BR sk-gid " | " vlan-tag " | " rxhash " }"
.SH DESCRIPTION
The
.B flow
classifier is meant to extend the
.B SFQ
hashing capabilities without hard-coding new hash functions. It also allows
deterministic mappings of keys to classes.
.SH OPTIONS
.TP
.BI action " ACTION_SPEC"
Apply an action from the generic actions framework on matching packets.
.TP
.BI baseclass " ID"
An offset for the resulting class ID.
.I ID
may be
.BR root ", " none
or a hexadecimal class ID in the form [\fIX\fB:\fR]\fIY\fR. If \fIX\fR is
omitted, it is assumed to be zero.
.TP
.BI divisor " NUM"
Number of buckets to use for sorting into. Keys are calculated modulo
.IR NUM .
.TP
.BI "hash keys " KEY-LIST
Perform a
.B jhash2
operation over the keys in
.IR KEY-LIST ,
the result (modulo the
.B divisor
if given) is taken as class ID, optionally offset by the value of
.BR baseclass .
It is possible to specify an interval (in seconds) after which
.BR jhash2 's
entropy source is recreated using the
.B perturb
parameter.
.TP
.BI "map key " KEY
Packet data identified by
.I KEY
is translated into class IDs to push the packet into. The value may be mangled by
.I OPS
before using it for the mapping. They are applied in the order listed here:
.RS
.TP 4
.BI and " NUM"
Perform bitwise
.B AND
operation with numeric value
.IR NUM .
.TP
.BI or " NUM"
Perform bitwise
.B OR
operation with numeric value
.IR NUM .
.TP
.BI xor " NUM"
Perform bitwise
.B XOR
operation with numeric value
.IR NUM .
.TP
.BI rshift " NUM"
Shift the value of
.I KEY
to the right by
.I NUM
bits.
.TP
.BI addend " NUM"
Add
.I NUM
to the value of
.IR KEY .
.RE
.RS
For the
.BR or ", " and ", " xor " and " rshift
operations,
.I NUM
is assumed to be an unsigned, 32bit integer value. For the
.B addend
operation,
.I NUM
may be much more complex: It may be prefixed by a minus ('-') sign to cause
subtraction instead of addition and for keys of
.BR src ", " dst ", " nfct-src " and " nfct-dst
it may be given in IP address notation. See below for an illustrating example.
.RE
.TP
.BI match " EMATCH_TREE"
Match packets using the extended match infrastructure. See
.BR tc-ematch (8)
for a detailed description of the allowed syntax in
.IR EMATCH_TREE .
.SH KEYS
In mapping mode, a single key is used (after optional permutation) to build a
class ID. The resulting ID is deducible in most cases. In hashing more, a number
of keys may be specified which are then hashed and the output used as class ID.
This ID is not deducible in beforehand, and may even change over time for a
given flow if a
.B perturb
interval has been given.
The range of class IDs can be limited by the
.B divisor
option, which is used for a modulus.
.TP
.BR src ", " dst
Use source or destination address as key. In case of IPv4 and TIPC, this is the
actual address value. For IPv6, the 128bit address is folded into a 32bit value
by XOR'ing the four 32bit words. In all other cases, the kernel-internal socket
address is used (after folding into 32bits on 64bit systems).
.TP
.B proto
Use the layer four protocol number as key.
.TP
.B proto-src
Use the layer four source port as key. If not available, the kernel-internal
socket address is used instead.
.TP
.B proto-dst
Use the layer four destination port as key. If not available, the associated
kernel-internal dst_entry address is used after XOR'ing with the packet's
layer three protocol number.
.TP
.B iif
Use the incoming interface index as key.
.TP
.B priority
Use the packet's priority as key. Usually this is the IP header's DSCP/ECN
value.
.TP
.B mark
Use the netfilter
.B fwmark
as key.
.TP
.B nfct
Use the associated conntrack entry address as key.
.TP
.BR nfct-src ", " nfct-dst ", " nfct-proto-src ", " nfct-proto-dst
These are conntrack-aware variants of
.BR src ", " dst ", " proto-src " and " proto-dst .
In case of NAT, these are basically the packet header's values before NAT was
applied.
.TP
.B rt-classid
Use the packet's destination routing table entry's realm as key.
.TP
.B sk-uid
.TQ
.B sk-gid
For locally generated packets, use the user or group ID the originating socket
belongs to as key.
.TP
.B vlan-tag
Use the packet's vlan ID as key.
.TP
.B rxhash
Use the flow hash as key.
.SH EXAMPLES
.TP
Classic SFQ hash:
.EX
tc filter add ... flow hash \\
keys src,dst,proto,proto-src,proto-dst divisor 1024
.EE
.TP
Classic SFQ hash, but using information from conntrack to work properly in combination with NAT:
.EX
tc filter add ... flow hash \\
keys nfct-src,nfct-dst,proto,nfct-proto-src,nfct-proto-dst \\
divisor 1024
.EE
.TP
Map destination IPs of 192.168.0.0/24 to classids 1-257:
.EX
tc filter add ... flow map \\
key dst addend -192.168.0.0 divisor 256
.EE
.TP
Alternative to the above:
.EX
tc filter add ... flow map \\
key dst and 0xff
.EE
.TP
The same, but in reverse order:
.EX
tc filter add ... flow map \\
key dst and 0xff xor 0xff
.EE
.SH SEE ALSO
.BR tc (8),
.BR tc-ematch (8),
.BR tc-sfq (8)
.TH "Flower filter in tc" 8 "22 Oct 2015" "iproute2" "Linux"
.SH NAME
flower \- flow based traffic control filter
.SH SYNOPSIS
.in +8
.ti -8
.BR tc " " filter " ... " flower " [ "
.IR MATCH_LIST " ] [ "
.B action
.IR ACTION_SPEC " ] [ "
.B classid
.IR CLASSID " ]"
.ti -8
.IR MATCH_LIST " := [ " MATCH_LIST " ] " MATCH
.ti -8
.IR MATCH " := { "
.B indev
.IR ifname " | { "
.BR dst_mac " | " src_mac " } "
.IR mac_address " | "
.BR eth_type " { " ipv4 " | " ipv6 " | "
.IR ETH_TYPE " } | "
.BR ip_proto " { " tcp " | " udp " | "
.IR IP_PROTO " } | { "
.BR dst_ip " | " src_ip " } { "
.IR ipv4_address " | " ipv6_address " } | { "
.BR dst_port " | " src_port " } "
.IR port_number " }"
.SH DESCRIPTION
The
.B flower
filter matches flows to the set of keys specified and assigns an arbitrarily
chosen class ID to packets belonging to them. Additionally (or alternatively) an
action from the generic action framework may be called.
.SH OPTIONS
.TP
.BI action " ACTION_SPEC"
Apply an action from the generic actions framework on matching packets.
.TP
.BI classid " CLASSID"
Specify a class to pass matching packets on to.
.I CLASSID
is in the form
.BR X : Y ", while " X " and " Y
are interpreted as numbers in hexadecimal format.
.TP
.BI indev " ifname"
Match on incoming interface name. Obviously this makes sense only for forwarded
flows.
.I ifname
is the name of an interface which must exist at the time of
.B tc
invocation.
.TP
.BI dst_mac " mac_address"
.TQ
.BI src_mac " mac_address"
Match on source or destination MAC address.
.TP
.BI eth_type " ETH_TYPE"
Match on layer three protocol.
.I ETH_TYPE
may be either
.BR ipv4 , ipv6
or an unsigned 16bit value in hexadecimal format.
.TP
.BI ip_proto " IP_PROTO"
Match on layer four protocol.
.I IP_PROTO
may be either
.BR tcp , udp
or an unsigned 8bit value in hexadecimal format.
.TP
.BI dst_ip " ADDRESS"
.TQ
.BI src_ip " ADDRESS"
Match on source or destination IP address.
.I ADDRESS
must be a valid IPv4 or IPv6 address, depending on
.BR ether_type ,
which has to be specified in beforehand.
.TP
.BI dst_port " NUMBER"
.TQ
.BI src_port " NUMBER"
Match on layer 4 protocol source or destination port number. Only available for
.BR ip_proto " values " udp " and " tcp ,
which has to be specified in beforehand.
.SH NOTES
As stated above where applicable, matches of a certain layer implicitly depend
on the matches of the next lower layer. Precisely, layer one and two matches (
.BR indev , dst_mac , src_mac " and " eth_type )
have no dependency, layer three matches (
.BR ip_proto , dst_ip " and " src_ip )
require
.B eth_type
being set to either
.BR ipv4 " or " ipv6 ,
and finally layer four matches (
.BR dst_port " and " src_port )
depend on
.B ip_proto
being set to either
.BR tcp " or " udp .
.P
There can be only used one mask per one prio. If user needs to specify different
mask, he has to use different prio.
.SH SEE ALSO
.BR tc (8),
.BR tc-flow (8)
.TH "Firewall mark classifier in tc" 8 "21 Oct 2015" "iproute2" "Linux"
.SH NAME
fw \- fwmark traffic control filter
.SH SYNOPSIS
.in +8
.ti -8
.BR tc " " filter " ... " fw " [ " classid
.IR CLASSID " ] [ "
.B action
.IR ACTION_SPEC " ]"
.SH DESCRIPTION
the
.B fw
filter allows to classify packets based on a previously set
.BR fwmark " by " iptables .
If it is identical to the filter's
.BR handle ,
the filter matches.
.B iptables
allows to mark single packets with the
.B MARK
target, or whole connections using
.BR CONNMARK .
The benefit of using this filter instead of doing the
heavy-lifting with
.B tc
itself is that on one hand it might be convenient to keep packet filtering and
classification in one place, possibly having to match a packet just once, and on
the other users familiar with
.BR iptables " but not " tc
will have a less hard time adding QoS to their setups.
.SH OPTIONS
.TP
.BI classid " CLASSID"
Push matching packets to the class identified by
.IR CLASSID .
.TP
.BI action " ACTION_SPEC"
Apply an action from the generic actions framework on matching packets.
.SH EXAMPLES
Take e.g. the following tc filter statement:
.RS
.EX
tc filter add ... handle 6 fw classid 1:1
.EE
.RE
will match if the packet's
.B fwmark
value is
.BR 6 .
This is a sample
.B iptables
statement marking packets coming in on eth0:
.RS
.EX
iptables -t mangle -A PREROUTING -i eth0 -j MARK --set-mark 6
.EE
.RE
.SH SEE ALSO
.BR tc (8),
.BR iptables (8),
.BR iptables-extensions (8)
.TH "Route classifier in tc" 8 "21 Oct 2015" "iproute2" "Linux"
.SH NAME
route \- route traffic control filter
.SH SYNOPSIS
.in +8
.ti -8
.BR tc " " filter " ... " route " [ " from
.IR REALM " | "
.B fromif
.IR TAG " ] [ "
.B to
.IR REALM " ] [ "
.B classid
.IR CLASSID " ] [ "
.B action
.IR ACTION_SPEC " ]"
.SH DESCRIPTION
Match packets based on routing table entries. This filter centers around the
possibility to assign a
.B realm
to routing table entries. For any packet to be classified by this filter, a
routing table lookup is performed and the returned
.B realm
is used to decide on whether the packet is a match or not.
.SH OPTIONS
.TP
.BI action " ACTION_SPEC"
Apply an action from the generic actions framework on matching packets.
.TP
.BI classid " CLASSID"
Push matching packets into the class identified by
.IR CLASSID .
.TP
.BI from " REALM"
.TQ
.BI fromif " TAG"
Perform source route lookups.
.I TAG
is the name of an interface which must be present on the system at the time of
.B tc
invocation.
.TP
.BI to " REALM"
Match if normal (i.e., destination) routing returns the given
.IR REALM .
.SH EXAMPLES
Consider the subnet 192.168.2.0/24 being attached to eth0:
.RS
.EX
ip route add 192.168.2.0/24 dev eth0 realm 2
.EE
.RE
The following
.B route
filter will then match packets from that subnet:
.RS
.EX
tc filter add ... route from 2 classid 1:2
.EE
.RE
and pass packets on to class 1:2.
.SH NOTES
Due to implementation details,
.B realm
values must be in a range from 0 to 255, inclusive. Alternatively, a verbose
name defined in /etc/iproute2/rt_realms may be given instead.
.SH SEE ALSO
.BR tc (8),
.BR ip-route (8)
.TH "Traffic control index filter" 8 "21 Oct 2015" "iproute2" "Linux"
.SH NAME
tcindex \- traffic control index filter
.SH SYNOPSIS
.in +8
.ti -8
.BR tc " " filter " ... " tcindex " [ " hash
.IR SIZE " ] [ "
.B mask
.IR MASK " ] [ "
.B shift
.IR SHIFT " ] [ "
.BR pas_on " | " fall_through " ] [ " classid
.IR CLASSID " ] [ "
.B action
.BR ACTION_SPEC " ]"
.SH DESCRIPTION
This filter allows to match packets based on their
.B tcindex
field value, i.e. the combination of the DSCP and ECN fields as present in IPv4
and IPv6 headers.
.SH OPTIONS
.TP
.BI action " ACTION_SPEC"
Apply an action from the generic actions framework on matching packets.
.TP
.BI classid " CLASSID"
Push matching packets into the class identified by
.IR CLASSID .
.TP
.BI hash " SIZE"
Hash table size in entries to use. Defaults to 64.
.TP
.BI mask " MASK"
An optional bitmask to binary
.BR AND " to the packet's " tcindex
field before use.
.TP
.BI shift " SHIFT"
The number of bits to right-shift a packet's
.B tcindex
value before use. If a
.B mask
has been set, masking is done before shifting.
.TP
.B pass_on
If this flag is set, failure to find a class for the resulting ID will make the
filter fail and lead to the next filter being consulted.
.TP
.B fall_through
This is the opposite of
.B pass_on
and the default. The filter will classify the packet even if there is no class
present for the resulting class ID.
.SH SEE ALSO
.BR tc (8)
This diff is collapsed.
......@@ -144,6 +144,50 @@ It is important to notice that filters reside
.B within
qdiscs - they are not masters of what happens.
The available filters are:
.TP
basic
Filter packets based on an ematch expression. See
.BR tc-ematch (8)
for details.
.TP
bpf
Filter packets using (e)BPF, see
.BR tc-bpf (8)
for details.
.TP
cgroup
Filter packets based on the control group of their process. See
. BR tc-cgroup (8)
for details.
.TP
flow, flower
Flow-based classifiers, filtering packets based on their flow (identified by selectable keys). See
.BR tc-flow "(8) and"
.BR tc-flower (8)
for details.
.TP
fw
Filter based on fwmark. Directly maps fwmark value to traffic class. See
.BR tc-fw (8).
.TP
route
Filter packets based on routing table. See
.BR tc-route (8)
for details.
.TP
rsvp
Match Resource Reservation Protocol (RSVP) packets.
.TP
tcindex
Filter packets based on traffic control index. See
.BR tc-index (8).
.TP
u32
Generic filtering on arbitrary packet data, assisted by syntax to abstract common operations. See
.BR tc-u32 (8)
for details.
.SH CLASSLESS QDISCS
The classless qdiscs are:
.TP
......@@ -655,15 +699,20 @@ Shows classes as ASCII graph with stats info under each class.
.B tc
was written by Alexey N. Kuznetsov and added in Linux 2.2.
.SH SEE ALSO
.BR tc-basic (8),
.BR tc-bfifo (8),
.BR tc-bpf (8),
.BR tc-cbq (8),
.BR tc-cgroup (8),
.BR tc-choke (8),
.BR tc-codel (8),
.BR tc-drr (8),
.BR tc-ematch (8),
.BR tc-flow (8),
.BR tc-flower (8),
.BR tc-fq (8),
.BR tc-fq_codel (8),
.BR tc-fw (8),
.BR tc-hfsc (7),
.BR tc-hfsc (8),
.BR tc-htb (8),
......@@ -671,10 +720,13 @@ was written by Alexey N. Kuznetsov and added in Linux 2.2.
.BR tc-pfifo (8),
.BR tc-pfifo_fast (8),
.BR tc-red (8),
.BR tc-route (8),
.BR tc-sfb (8),
.BR tc-sfq (8),
.BR tc-stab (8),
.BR tc-tbf (8),
.BR tc-tcindex (8),
.BR tc-u32 (8),
.br
.RB "User documentation at " http://lartc.org/ ", but please direct bugreports and patches to: " <netdev@vger.kernel.org>
......
......@@ -272,7 +272,7 @@ static void dump_raw_db(FILE *fp, int to_hist)
if (jw) {
jsonw_name(jw, n->name);
jsonw_start_object(jw);
for (i=0; i<MAXS && stats[i]; i++)
jsonw_uint_field(jw, stats[i], vals[i]);
jsonw_end_object(jw);
......
......@@ -377,4 +377,3 @@ int main(int argc, char **argv)
return 1;
}
......@@ -43,5 +43,3 @@ It is available only for alpha and pentiums with correct
CPU timestamp. It is the fastest way, use it when it is available,
but remember: not all pentiums have this facility, and
a lot of them have clock, broken by APM etc. etc.
......@@ -98,4 +98,3 @@ invert:
{
ematch_err = strdup(s);
}
......@@ -28,7 +28,7 @@ static void explain(void)
fprintf(stderr, " [ action ACTION-SPEC ] [ classid CLASSID ]\n");
fprintf(stderr, "\n");
fprintf(stderr, "Where: MATCH-LIST := [ MATCH-LIST ] MATCH\n");
fprintf(stderr, " MATCH := [ indev DEV-NAME | \n");
fprintf(stderr, " MATCH := { indev DEV-NAME | \n");
fprintf(stderr, " dst_mac MAC-ADDR | \n");
fprintf(stderr, " src_mac MAC-ADDR | \n");
fprintf(stderr, " eth_type [ipv4 | ipv6 | ETH-TYPE ] | \n");
......@@ -36,7 +36,7 @@ static void explain(void)
fprintf(stderr, " dst_ip [ IPV4-ADDR | IPV6-ADDR ] | \n");
fprintf(stderr, " src_ip [ IPV4-ADDR | IPV6-ADDR ] | \n");
fprintf(stderr, " dst_port PORT-NUMBER | \n");
fprintf(stderr, " src_port PORT-NUMBER | \n");
fprintf(stderr, " src_port PORT-NUMBER }\n");
fprintf(stderr, " FILTERID := X:Y:Z\n");
fprintf(stderr, " ACTION-SPEC := ... look at individual actions\n");
fprintf(stderr, "\n");
......
......@@ -28,7 +28,7 @@
static void explain(void)
{
fprintf(stderr, "Usage: ... route [ from REALM | fromif TAG ] [ to REALM ]\n");
fprintf(stderr, " [ flowid CLASSID ] [ action ACTION_SPEC ]]\n");
fprintf(stderr, " [ classid CLASSID ] [ action ACTION_SPEC ]\n");
fprintf(stderr, " ACTION_SPEC := ... look at individual actions\n");
fprintf(stderr, " CLASSID := X:Y\n");
fprintf(stderr, "\nNOTE: CLASSID is parsed as hexadecimal input.\n");
......
......@@ -27,7 +27,7 @@
static void explain(void)
{
fprintf(stderr, "Usage: ... rsvp ipproto PROTOCOL session DST[/PORT | GPI ]\n");
fprintf(stderr, " [ sender SRC[/PORT | GPI ]\n");
fprintf(stderr, " [ sender SRC[/PORT | GPI ] ]\n");
fprintf(stderr, " [ classid CLASSID ] [ action ACTION_SPEC ]\n");
fprintf(stderr, " [ tunnelid ID ] [ tunnel ID skip NUMBER ]\n");
fprintf(stderr, "Where: GPI := { flowlabel NUMBER | spi/ah SPI | spi/esp SPI |\n");
......
......@@ -61,14 +61,14 @@ static int get_u32_handle(__u32 *handle, const char *str)
if (htid>=0x1000)
return -1;
if (*tmp) {
str = tmp+1;
str = tmp + 1;
hash = strtoul(str, &tmp, 16);
if (tmp == str && *str != ':' && *str != 0)
return -1;
if (hash>=0x100)
return -1;
if (*tmp) {
str = tmp+1;
str = tmp + 1;
nodeid = strtoul(str, &tmp, 16);
if (tmp == str && *str != 0)
return -1;
......@@ -124,9 +124,9 @@ static int pack_key(struct tc_u32_sel *sel, __u32 key, __u32 mask,
for (i=0; i<hwm; i++) {
if (sel->keys[i].off == off && sel->keys[i].offmask == offmask) {
__u32 intersect = mask&sel->keys[i].mask;
__u32 intersect = mask & sel->keys[i].mask;
if ((key^sel->keys[i].val) & intersect)
if ((key ^ sel->keys[i].val) & intersect)
return -1;
sel->keys[i].val |= key;
sel->keys[i].mask |= mask;
......@@ -346,7 +346,7 @@ static int parse_ip_addr(int *argc_p, char ***argv_p, struct tc_u32_sel *sel,
mask = 0;
if (addr.bitlen)
mask = htonl(0xFFFFFFFF<<(32-addr.bitlen));
mask = htonl(0xFFFFFFFF << (32 - addr.bitlen));
if (pack_key(sel, addr.data[0], mask, off, offmask) < 0)
return -1;
res = 0;
......@@ -381,17 +381,17 @@ static int parse_ip6_addr(int *argc_p, char ***argv_p,
}
plen = addr.bitlen;
for (i=0; i<plen; i+=32) {
// if (((i+31)&~0x1F)<=plen) {
for (i = 0; i < plen; i += 32) {
// if (((i + 31) & ~0x1F) <= plen) {
if (i + 31 <= plen) {
res = pack_key(sel, addr.data[i/32],
0xFFFFFFFF, off+4*(i/32), offmask);
res = pack_key(sel, addr.data[i / 32],
0xFFFFFFFF, off + 4 * (i / 32), offmask);
if (res < 0)
return -1;
} else if (i < plen) {
__u32 mask = htonl(0xFFFFFFFF << (32 - (plen -i )));
res = pack_key(sel, addr.data[i/32],
mask, off+4*(i/32), offmask);
__u32 mask = htonl(0xFFFFFFFF << (32 - (plen - i)));
res = pack_key(sel, addr.data[i / 32],
mask, off + 4 * (i / 32), offmask);
if (res < 0)
return -1;
}
......@@ -496,7 +496,8 @@ static int parse_ip(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
NEXT_ARG();
res = parse_ip_addr(&argc, &argv, sel, 16);
} else if (strcmp(*argv, "tos") == 0 ||
matches(*argv, "dsfield") == 0) {
matches(*argv, "dsfield") == 0 ||
matches(*argv, "precedence") == 0) {
NEXT_ARG();
res = parse_u8(&argc, &argv, sel, 1, 0);
} else if (strcmp(*argv, "ihl") == 0) {
......@@ -505,9 +506,6 @@ static int parse_ip(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
} else if (strcmp(*argv, "protocol") == 0) {
NEXT_ARG();
res = parse_u8(&argc, &argv, sel, 9, 0);
} else if (matches(*argv, "precedence") == 0) {
NEXT_ARG();
res = parse_u8(&argc, &argv, sel, 1, 0);
} else if (strcmp(*argv, "nofrag") == 0) {
argc--; argv++;
res = pack_key16(sel, 0, 0x3FFF, 6, 0);
......@@ -1072,9 +1070,9 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
return -1;
}
if (sample_ok)
htid = (htid&0xFF000)|(handle&0xFFF00000);
htid = (htid & 0xFF000) | (handle & 0xFFF00000);
else
htid = (handle&0xFFFFF000);
htid = (handle & 0xFFFFF000);
} else if (strcmp(*argv, "sample") == 0) {
__u32 hash;
unsigned divisor = 0x100;
......@@ -1103,10 +1101,10 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
}
NEXT_ARG();
}
hash = sel2.sel.keys[0].val&sel2.sel.keys[0].mask;
hash ^= hash>>16;
hash ^= hash>>8;
htid = ((hash%divisor)<<12)|(htid&0xFFF00000);
hash = sel2.sel.keys[0].val & sel2.sel.keys[0].mask;
hash ^= hash >> 16;
hash ^= hash >> 8;
htid = ((hash % divisor) << 12) | (htid & 0xFFF00000);
sample_ok = 1;
continue;
} else if (strcmp(*argv, "indev") == 0) {
......@@ -1165,7 +1163,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
addattr_l(n, MAX_MSG, TCA_U32_HASH, &htid, 4);
if (sel_ok)
addattr_l(n, MAX_MSG, TCA_U32_SEL, &sel,
sizeof(sel.sel)+sel.sel.nkeys*sizeof(struct tc_u32_key));
sizeof(sel.sel) + sel.sel.nkeys * sizeof(struct tc_u32_key));
tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
return 0;
}
......@@ -1173,7 +1171,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
__u32 handle)
{
struct rtattr *tb[TCA_U32_MAX+1];
struct rtattr *tb[TCA_U32_MAX + 1];
struct tc_u32_sel *sel = NULL;
struct tc_u32_pcnt *pf = NULL;
......@@ -1209,9 +1207,9 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
if (tb[TCA_U32_CLASSID]) {
SPRINT_BUF(b1);
fprintf(f, "%sflowid %s ",
!sel || !(sel->flags&TC_U32_TERMINAL) ? "*" : "",
!sel || !(sel->flags & TC_U32_TERMINAL) ? "*" : "",
sprint_tc_classid(rta_getattr_u32(tb[TCA_U32_CLASSID]), b1));
} else if (sel && sel->flags&TC_U32_TERMINAL) {
} else if (sel && sel->flags & TC_U32_TERMINAL) {
fprintf(f, "terminal flowid ??? ");
}
if (tb[TCA_U32_LINK]) {
......@@ -1254,16 +1252,16 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
}
}
if (sel->flags&(TC_U32_VAROFFSET|TC_U32_OFFSET)) {
if (sel->flags & (TC_U32_VAROFFSET | TC_U32_OFFSET)) {
fprintf(f, "\n offset ");
if (sel->flags&TC_U32_VAROFFSET)
if (sel->flags & TC_U32_VAROFFSET)
fprintf(f, "%04x>>%d at %d ",
ntohs(sel->offmask),
sel->offshift, sel->offoff);
if (sel->off)
fprintf(f, "plus %d ", sel->off);
}
if (sel->flags&TC_U32_EAT)
if (sel->flags & TC_U32_EAT)
fprintf(f, " eat ");
if (sel->hmask) {
......
......@@ -648,4 +648,3 @@ int do_action(int argc, char **argv)
return 0;
}
......@@ -618,4 +618,3 @@ struct action_util ipt_action_util = {
.parse_aopt = parse_ipt,
.print_aopt = print_ipt,
};
......@@ -433,4 +433,3 @@ struct action_util ipt_action_util = {
.parse_aopt = parse_ipt,
.print_aopt = print_ipt,
};
......@@ -34,5 +34,3 @@ struct m_pedit_util p_pedit_tcp = {
"tcp",
parse_tcp,
};
......@@ -35,4 +35,3 @@ struct m_pedit_util p_pedit_udp = {
"udp",
parse_udp,
};
......@@ -582,4 +582,3 @@ struct qdisc_util cbq_qdisc_util = {
.parse_copt = cbq_parse_class_opt,
.print_copt = cbq_print_opt,
};
......@@ -688,4 +688,3 @@ struct qdisc_util netem_qdisc_util = {
.parse_qopt = netem_parse_opt,
.print_qopt = netem_print_opt,
};
......@@ -122,4 +122,3 @@ struct qdisc_util prio_qdisc_util = {
.parse_qopt = prio_parse_opt,
.print_qopt = prio_print_opt,
};
......@@ -328,4 +328,3 @@ struct qdisc_util tbf_qdisc_util = {
.parse_qopt = tbf_parse_opt,
.print_qopt = tbf_print_opt,
};
......@@ -375,4 +375,3 @@ int do_filter(int argc, char **argv)
fprintf(stderr, "Command \"%s\" is unknown, try \"tc filter help\".\n", *argv);
return -1;
}
......@@ -148,4 +148,3 @@ void print_size_table(FILE *fp, const char *prefix, struct rtattr *rta)
}
#endif
}
......@@ -608,4 +608,3 @@ compat_xstats:
if (tb[TCA_XSTATS] && xstats)
*xstats = tb[TCA_XSTATS];
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment