]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
Merge branch 'iproute2-master' into iproute2-next
authorDavid Ahern <dsahern@gmail.com>
Wed, 19 Dec 2018 20:02:17 +0000 (12:02 -0800)
committerDavid Ahern <dsahern@gmail.com>
Wed, 19 Dec 2018 20:02:17 +0000 (12:02 -0800)
Signed-off-by: David Ahern <dsahern@gmail.com>
40 files changed:
Makefile
bridge/link.c
configure
examples/cbq.init-v0.7.3 [deleted file]
examples/dhcp-client-script [deleted file]
include/json_print.h
include/json_writer.h
include/uapi/linux/bpf.h
ip/ipaddress.c
ip/iplink_bridge.c
ip/iplink_bridge_slave.c
ip/iplink_geneve.c
ip/iplink_vxlan.c
ip/ipmacsec.c
ip/ipntable.c
ip/iproute.c
ip/iproute_lwtunnel.c
ip/iprule.c
ip/iptuntap.c
ip/link_gre.c
ip/link_gre6.c
ip/link_ip6tnl.c
ip/link_iptnl.c
ip/link_vti.c
ip/link_vti6.c
lib/bpf.c
lib/json_print.c
lib/json_writer.c
lib/utils.c
man/man8/rtpr.8
man/man8/ss.8
rdma/dev.c
tc/Makefile
tc/m_ife.c
tc/q_htb.c
tc/q_taprio.c
testsuite/Makefile
testsuite/tests/ip/route/add_default_route.t
testsuite/tests/ip/tunnel/add_tunnel.t
testsuite/tests/tc/dsmark.t

index ad96fd541580ae287350349752e3a7d1eb49aa18..a513cf38ae6949b4457796d085ab6d8ca227cd7a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -113,7 +113,7 @@ clobber:
 
 distclean: clobber
 
-check:
+check: all
        cd testsuite && $(MAKE) && $(MAKE) alltests
 
 cscope:
index 3290c16f0951680ab056f323c285e55fd3340577..32317e53b0361a96c8d817b74d0fe45ed6cb150f 100644 (file)
@@ -90,7 +90,7 @@ static void print_hwmode(__u16 mode)
 {
        if (mode >= ARRAY_SIZE(hw_mode))
                print_0xhex(PRINT_ANY, "hwmode",
-                           "hwmode %#hx ", mode);
+                           "hwmode %#llx ", mode);
        else
                print_string(PRINT_ANY, "hwmode",
                             "hwmode %s ", hw_mode[mode]);
index 5df6082bbd84e7d67455c36b3ea27aad79dcc71f..b85eb58b2ba9e72ac17f19f53c21744def68899d 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,4 +1,4 @@
-#! /bin/bash
+#!/bin/sh
 # SPDX-License-Identifier: GPL-2.0
 # This is not an autoconf generated configure
 #
@@ -11,12 +11,6 @@ CONFIG=config.mk
 TMPDIR=$(mktemp -d config.XXXXXX)
 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
 
-check_prog()
-{
-    echo -n "$2"
-    command -v $1 >/dev/null 2>&1 && (echo "$3:=y" >> $CONFIG; echo "yes") || (echo "no"; return 1)
-}
-
 check_toolchain()
 {
     : ${PKG_CONFIG:=pkg-config}
@@ -38,9 +32,7 @@ int main(int argc, char **argv) {
 }
 EOF
 
-    $CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1
-    if [ $? -eq 0 ]
-    then
+    if $CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1; then
        echo "TC_CONFIG_ATM:=y" >>$CONFIG
        echo yes
     else
@@ -51,8 +43,7 @@ EOF
 
 check_xtables()
 {
-       if ! ${PKG_CONFIG} xtables --exists
-       then
+       if ! ${PKG_CONFIG} xtables --exists; then
                echo "TC_CONFIG_NO_XT:=y" >>$CONFIG
        fi
 }
@@ -80,8 +71,7 @@ int main(int argc, char **argv)
 EOF
 
     if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL \
-       $(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1
-    then
+       $(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1; then
        echo "TC_CONFIG_XT:=y" >>$CONFIG
        echo "using xtables"
     fi
@@ -91,10 +81,7 @@ EOF
 check_xt_old()
 {
     # bail if previous XT checks has already succeeded.
-    if grep -q TC_CONFIG_XT $CONFIG
-    then
-       return
-    fi
+    grep -q TC_CONFIG_XT $CONFIG && return
 
     #check if we don't need our internal header ..
     cat >$TMPDIR/ipttest.c <<EOF
@@ -118,9 +105,7 @@ int main(int argc, char **argv) {
 
 EOF
 
-    $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
-    if [ $? -eq 0 ]
-    then
+    if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1; then
        echo "TC_CONFIG_XT_OLD:=y" >>$CONFIG
        echo "using old xtables (no need for xt-internal.h)"
     fi
@@ -130,10 +115,7 @@ EOF
 check_xt_old_internal_h()
 {
     # bail if previous XT checks has already succeeded.
-    if grep -q TC_CONFIG_XT $CONFIG
-    then
-       return
-    fi
+    grep -q if grep -q TC_CONFIG_XT $CONFIG && return
 
     #check if we need our own internal.h
     cat >$TMPDIR/ipttest.c <<EOF
@@ -157,10 +139,7 @@ int main(int argc, char **argv) {
 }
 
 EOF
-       $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
-
-       if [ $? -eq 0 ]
-       then
+       if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1; then
            echo "using old xtables with xt-internal.h"
            echo "TC_CONFIG_XT_OLD_H:=y" >>$CONFIG
        fi
@@ -169,8 +148,7 @@ EOF
 
 check_ipt()
 {
-       if ! grep TC_CONFIG_XT $CONFIG > /dev/null
-       then
+       if ! grep TC_CONFIG_XT $CONFIG > /dev/null; then
                echo "using iptables"
        fi
 }
@@ -184,9 +162,9 @@ check_ipt_lib_dir()
                return
        fi
 
-       for dir in /lib /usr/lib /usr/local/lib
-       do
-               for file in $dir/{xtables,iptables}/lib*t_*so ; do
+       for dir in /lib /usr/lib /usr/local/lib; do
+               for file in "xtables" "iptables"; do
+                       file="$dir/$file/lib*t_*so"
                        if [ -f $file ]; then
                                echo ${file%/*}
                                echo "IPT_LIB_DIR:=${file%/*}" >> $CONFIG
@@ -207,9 +185,7 @@ int main(int argc, char **argv)
        return 0;
 }
 EOF
-    $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
-    if [ $? -eq 0 ]
-    then
+    if $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1; then
        echo "IP_CONFIG_SETNS:=y" >>$CONFIG
        echo "yes"
        echo "CFLAGS += -DHAVE_SETNS" >>$CONFIG
@@ -240,8 +216,7 @@ int main(void)
 #endif
 EOF
 
-    if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1
-    then
+    if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1; then
        echo "TC_CONFIG_IPSET:=y" >>$CONFIG
        echo "yes"
     else
@@ -252,8 +227,7 @@ EOF
 
 check_elf()
 {
-    if ${PKG_CONFIG} libelf --exists
-    then
+    if ${PKG_CONFIG} libelf --exists; then
        echo "HAVE_ELF:=y" >>$CONFIG
        echo "yes"
 
@@ -267,8 +241,7 @@ check_elf()
 check_selinux()
 # SELinux is a compile time option in the ss utility
 {
-       if ${PKG_CONFIG} libselinux --exists
-       then
+       if ${PKG_CONFIG} libselinux --exists; then
                echo "HAVE_SELINUX:=y" >>$CONFIG
                echo "yes"
 
@@ -281,8 +254,7 @@ check_selinux()
 
 check_mnl()
 {
-       if ${PKG_CONFIG} libmnl --exists
-       then
+       if ${PKG_CONFIG} libmnl --exists; then
                echo "HAVE_MNL:=y" >>$CONFIG
                echo "yes"
 
@@ -304,9 +276,7 @@ int main(int argc, char **argv) {
        return 0;
 }
 EOF
-    $CC -I$INCLUDE -o $TMPDIR/dbtest $TMPDIR/dbtest.c -ldb >/dev/null 2>&1
-    if [ $? -eq 0 ]
-    then
+    if $CC -I$INCLUDE -o $TMPDIR/dbtest $TMPDIR/dbtest.c -ldb >/dev/null 2>&1; then
        echo "HAVE_BERKELEY_DB:=y" >>$CONFIG
        echo "yes"
     else
@@ -325,13 +295,10 @@ int main(int argc, char **argv) {
        return 0;
 }
 EOF
-    $CC -I$INCLUDE -o $TMPDIR/strtest $TMPDIR/strtest.c >/dev/null 2>&1
-    if [ $? -eq 0 ]
-    then
+    if $CC -I$INCLUDE -o $TMPDIR/strtest $TMPDIR/strtest.c >/dev/null 2>&1; then
        echo "no"
     else
-       if ${PKG_CONFIG} libbsd --exists
-       then
+       if ${PKG_CONFIG} libbsd --exists; then
                echo 'CFLAGS += -DHAVE_LIBBSD' `${PKG_CONFIG} libbsd --cflags` >>$CONFIG
                echo 'LDLIBS +=' `${PKG_CONFIG} libbsd --libs` >> $CONFIG
                echo "no"
@@ -345,8 +312,7 @@ EOF
 
 check_cap()
 {
-       if ${PKG_CONFIG} libcap --exists
-       then
+       if ${PKG_CONFIG} libcap --exists; then
                echo "HAVE_CAP:=y" >>$CONFIG
                echo "yes"
 
@@ -394,8 +360,7 @@ echo -n " ATM       "
 check_atm
 
 check_xtables
-if ! grep -q TC_CONFIG_NO_XT $CONFIG
-then
+if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
        echo -n " IPT   "
        check_xt
        check_xt_old
@@ -407,8 +372,7 @@ then
 fi
 
 echo
-if ! grep -q TC_CONFIG_NO_XT $CONFIG
-then
+if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
        echo -n "iptables modules directory: "
        check_ipt_lib_dir
 fi
diff --git a/examples/cbq.init-v0.7.3 b/examples/cbq.init-v0.7.3
deleted file mode 100644 (file)
index ec78394..0000000
+++ /dev/null
@@ -1,983 +0,0 @@
-#!/bin/bash
-#
-#    cbq.init v0.7.3
-#    Copyright (C) 1999  Pavel Golubev <pg@ksi-linux.com>
-#    Copyright (C) 2001-2004  Lubomir Bulej <pallas@kadan.cz>
-#
-#    chkconfig:   2345 11 89
-#    description: sets up CBQ-based traffic control
-#
-#    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 distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-#    To get the latest version, check on Freshmeat for actual location:
-#
-#              http://freshmeat.net/projects/cbq.init
-#
-#
-# VERSION HISTORY
-# ---------------
-# v0.7.3- Deepak Singhal <singhal at users.sourceforge.net>
-#        - fix timecheck to not ignore regular TIME rules after
-#          encountering a TIME rule that spans over midnight
-#      - Nathan Shafer <nicodemus at users.sourceforge.net>
-#        - allow symlinks to class files
-#      - Seth J. Blank <antifreeze at users.sourceforge.net>
-#        - replace hardcoded ip/tc location with variables
-#      - Mark Davis <mark.davis at gmx.de>
-#        - allow setting of PRIO_{MARK,RULE,REALM} in class file
-#      - Fernando Sanch <toptnc at users.sourceforge.net>
-#        - allow underscores in interface names
-# v0.7.2- Paulo Sedrez
-#        - fix time2abs to allow hours with leading zero in TIME rules
-#      - Svetlin Simeonov <zvero at yahoo.com>
-#        - fix cbq_device_list to allow VLAN interfaces
-#      - Mark Davis <mark.davis at gmx.de>
-#        - ignore *~ backup files when looking for classes
-#      - Mike Boyer <boyer at administrative.com>
-#        - fix to allow arguments to be passed to "restart" command
-# v0.7.1- Lubomir Bulej <pallas at kadan.cz>
-#        - default value for PERTURB
-#        - fixed small bug in RULE parser to correctly parse rules with
-#          identical source and destination fields
-#        - faster initial scanning of DEVICE fields
-# v0.7 - Lubomir Bulej <pallas at kadan.cz>
-#        - lots of various cleanups and reorganizations; the parsing is now
-#          some 40% faster, but the class ID must be in range 0x0002-0xffff
-#          (again). Because of the number of internal changes and the above
-#          class ID restriction, I bumped the version to 0.7 to indicate
-#          something might have got broken :)
-#        - changed PRIO_{U32,FW,ROUTE} to PRIO_{RULE,MARK,REALM}
-#          for consistency with filter keywords
-#        - exposed "compile" command
-#      - Catalin Petrescu <taz at dntis.ro>
-#        - support for port masks in RULE (u32) filter
-#      - Jordan Vrtanoski <obeliks at mt.net.mk>
-#        - support for week days in TIME rules
-# v0.6.4- Lubomir Bulej <pallas at kadan.cz>
-#        - added PRIO_* variables to allow easy control of filter priorities
-#        - added caching to speed up CBQ start, the cache is invalidated
-#          whenever any of the configuration files changes
-#        - updated the readme section + some cosmetic fixes
-# v0.6.3- Lubomir Bulej <pallas at kadan.cz>
-#        - removed setup of (unnecessary) class 1:1 - all classes
-#          now use qdisc's default class 1:0 as their parent
-#        - minor fix in the timecheck branch - classes
-#          without leaf qdisc were not updated
-#        - minor fix to avoid timecheck failure when run
-#          at time with minutes equal to 08 or 09
-#        - respect CBQ_PATH setting in environment
-#        - made PRIO=5 default, rendering it optional in configs
-#        - added support for route filter, see notes about REALM keyword
-#        - added support for fw filter, see notes about MARK keyword
-#        - added filter display to "list" and "stats" commands
-#        - readme section update + various cosmetic fixes
-# v0.6.2- Catalin Petrescu <taz at dntis.ro>
-#        - added tunnels interface handling
-# v0.6.1- Pavel Golubev <pg at ksi-linux.com>
-#        - added sch_prio module loading
-#          (thanks johan at iglo.virtual.or.id for reminding)
-#        - resolved errors resulting from stricter syntax checking in bash2
-#      - Lubomir Bulej <pallas at kadan.cz>
-#        - various cosmetic fixes
-# v0.6 - Lubomir Bulej <pallas at kadan.cz>
-#        - attempt to limit number of spawned processes by utilizing
-#          more of sed power (use sed instead of grep+cut)
-#        - simplified TIME parser, using bash builtins
-#        - added initial support for SFQ as leaf qdisc
-#        - reworked the documentation part a little
-#        - incorporated pending patches and ideas submitted by
-#          following people for versions 0.3 into version 0.6
-#      - Miguel Freitas <miguel at cetuc.puc-rio.br>
-#        - in case of overlapping TIME parameters, the last match is taken
-#      - Juanjo Ciarlante <jjo at mendoza.gov.ar>
-#        - chkconfig tags, list + stats startup parameters
-#        - optional tc & ip command logging (into /var/run/cbq-*)
-#      - Rafal Maszkowski <rzm at icm.edu.pl>
-#        - PEAK parameter for setting TBF's burst peak rate
-#        - fix for many config files (use find instead of ls)
-# v0.5.1- Lubomir Bulej <pallas at kadan.cz>
-#        - fixed little but serious bug in RULE parser
-# v0.5 - Lubomir Bulej <pallas at kadan.cz>
-#        - added options PARENT, LEAF, ISOLATED and BOUNDED. This allows
-#          (with some attention to config file ordering) for creating
-#          hierarchical structures of shapers with classes able (or unable)
-#          to borrow bandwidth from their parents.
-#        - class ID check allows hexadecimal numbers
-#        - rewritten & simplified RULE parser
-#        - cosmetic changes to improve readability
-#        - reorganization to avoid duplicate code (timecheck etc.)
-#        - timecheck doesn't check classes without TIME fields anymore
-# v0.4  - Lubomir Bulej <pallas at kadan.cz>
-#        - small bugfix in RULE parsing code
-#        - simplified configuration parsing code
-#        - several small cosmetic changes
-#        - TIME parameter can be now specified more than once allowing you to
-#          differentiate RATE throughout the whole day. Time overlapping is
-#          not checked, first match is taken. Midnight wrap (eg. 20:00-6:00)
-#          is allowed and taken care of.
-# v0.3a4- fixed small bug in IF operator. Thanks to
-#        Rafal Maszkowski <rzm at icm.edu.pl>
-# v0.3a3- fixed grep bug when using more than 10 eth devices. Thanks to David
-#        Trcka <trcka at poda.cz>.
-# v0.3a2- fixed bug in "if" operator. Thanks kad at dgtu.donetsk.ua.
-# v0.3a - added TIME parameter. Example: TIME=00:00-19:00;64Kbit/6Kbit
-#        So, between 00:00 and 19:00 the RATE will be 64Kbit.
-#        Just start "cbq.init timecheck" periodically from cron
-#        (every 10 minutes for example). DON'T FORGET though, to run
-#        "cbq.init start" for CBQ to initialize.
-# v0.2  - Some cosmetic changes. Now it is more compatible with old bash
-#        version. Thanks to Stanislav V. Voronyi <stas at cnti.uanet.kharkov.ua>.
-# v0.1  - First public release
-#
-#
-# README
-# ------
-#
-# First of all - this is just a SIMPLE EXAMPLE of CBQ power.
-# Don't ask me "why" and "how" :)
-#
-# This script is meant to simplify setup and management of relatively simple
-# CBQ-based traffic control on Linux. Access to advanced networking features
-# of Linux kernel is provided by "ip" and "tc" utilities from A. Kuznetsov's
-# iproute2 package, available at ftp://ftp.inr.ac.ru/ip-routing. Because the
-# utilities serve primarily to translate user wishes to RTNETLINK commands,
-# their interface is rather spartan, intolerant and requires quite a lot of
-# typing. And typing is what this script attempts to reduce :)
-#
-# The advanced networking stuff in Linux is pretty flexible and this script
-# aims to bring some of its features to the not-so-hard-core Linux users. Of
-# course, there is a tradeoff between simplicity and flexibility and you may
-# realize that the flexibility suffered too much for your needs -- time to
-# face "ip" and "tc" interface.
-#
-# To speed up the "start" command, simple caching was introduced in version
-# 0.6.4. The caching works so that the sequence of "tc" commands for given
-# configuration is stored in a file (/var/cache/cbq.init by default) which
-# is used next time the "start" command is run to avoid repeated parsing of
-# configuration files. This cache is invalidated whenever any of the CBQ
-# configuration files changes. If you want to run "cbq.init start" without
-# caching, run it as "cbq.init start nocache". If you want to force cache
-# invalidation, run it as "cbq.init start invalidate". Caching is disabled
-# if you have logging enabled (ie. CBQ_DEBUG is not empty).
-#
-# If you only want cqb.init to translate your configuration to "tc" commands,
-# use "compile" command which will output "tc" commands required to build
-# your configuration. Bear in mind that "compile" does not check if the "tc"
-# commands were successful - this is done (in certain places) only when the
-# "start nocache" command is used, which is also useful when creating the
-# configuration to check whether it is completely valid.
-#
-# All CBQ parameters are valid for Ethernet interfaces only, The script was
-# tested on various Linux kernel versions from series 2.1 to 2.4 and several
-# distributions with KSI Linux (Nostromo version) as the premier one.
-#
-#
-# HOW DOES IT WORK?
-# -----------------
-#
-# Every traffic class must be described by a file in the $CBQ_PATH directory
-# (/etc/sysconfig/cbq by default) - one file per class.
-#
-# The config file names must obey mandatory format: cbq-<clsid>.<name> where
-# <clsid> is two-byte hexadecimal number in range <0002-FFFF> (which in fact
-# is a CBQ class ID) and <name> is the name of the class -- anything to help
-# you distinguish the configuration files. For small amount of classes it is
-# often possible (and convenient) to let <clsid> resemble bandwidth of the
-# class.
-#
-# Example of valid config name:
-#      cbq-1280.My_first_shaper
-#
-#
-# The configuration file may contain the following parameters:
-#
-### Device parameters
-#
-# DEVICE=<ifname>,<bandwidth>[,<weight>]       mandatory
-# DEVICE=eth0,10Mbit,1Mbit
-#
-#      <ifname> is the name of the interface you want to control
-#              traffic on, e.g. eth0
-#      <bandwidth> is the physical bandwidth of the device, e.g. for
-#              ethernet 10Mbit or 100Mbit, for arcnet 2Mbit
-#      <weight> is tuning parameter that should be proportional to
-#              <bandwidth>. As a rule of thumb: <weight> = <bandwidth> / 10
-#
-# When you have more classes on one interface, it is enough to specify
-# <bandwidth> [and <weight>] only once, therefore in other files you only
-# need to set DEVICE=<ifname>.
-#
-### Class parameters
-#
-# RATE=<speed>                                 mandatory
-# RATE=5Mbit
-#
-#      Bandwidth allocated to the class. Traffic going through the class is
-#      shaped to conform to specified rate. You can use Kbit, Mbit or bps,
-#      Kbps and Mbps as suffices. If you don't specify any unit, bits/sec
-#      are used. Also note that "bps" means "bytes per second", not bits.
-#
-# WEIGHT=<speed>                               mandatory
-# WEIGHT=500Kbit
-#
-#      Tuning parameter that should be proportional to RATE. As a rule
-#      of thumb, use WEIGHT ~= RATE / 10.
-#
-# PRIO=<1-8>                                   optional, default 5
-# PRIO=5
-#
-#      Priority of class traffic. The higher the number, the lesser
-#      the priority. Priority of 5 is just fine.
-#
-# PARENT=<clsid>                               optional, default not set
-# PARENT=1280
-#
-#      Specifies ID of the parent class to which you want this class be
-#      attached. You might want to use LEAF=none for the parent class as
-#      mentioned below. By using this parameter and carefully ordering the
-#      configuration files, it is possible to create simple hierarchical
-#      structures of CBQ classes. The ordering is important so that parent
-#      classes are constructed prior to their children.
-#
-# LEAF=none|tbf|sfq                            optional, default "tbf"
-#
-#      Tells the script to attach specified leaf queueing discipline to CBQ
-#      class. By default, TBF is used. Note that attaching TBF to CBQ class
-#      shapes the traffic to conform to TBF parameters and prevents the class
-#      from borrowing bandwidth from its parent even if you have BOUNDED set
-#      to "no". To allow the class to borrow bandwidth (provided it is not
-#      bounded), you must set LEAF to "none" or "sfq".
-#
-#      If you want to ensure (approximately) fair sharing of bandwidth among
-#      several hosts in the same class, you might want to specify LEAF=sfq to
-#      attach SFQ as leaf queueing discipline to that class.
-#
-# BOUNDED=yes|no                               optional, default "yes"
-#
-#      If set to "yes", the class is not allowed to borrow bandwidth from
-#      its parent class in overlimit situation. If set to "no", the class
-#      will be allowed to borrow bandwidth from its parent.
-#
-# Note:        Don't forget to set LEAF to "none" or "sfq", otherwise the class will
-#      have TBF attached to itself and will not be able to borrow unused
-#      bandwidth from its parent.
-#
-# ISOLATED=yes|no                              optional, default "no"
-#
-#      If set to "yes", the class will not lend unused bandwidth to
-#      its children.
-#
-### TBF qdisc parameters
-#
-# BUFFER=<bytes>[/<bytes>]                     optional, default "10Kb/8"
-#
-#      This parameter controls the depth of the token bucket. In other
-#      words it represents the maximal burst size the class can send.
-#      The optional part of parameter is used to determine the length
-#      of intervals in packet sizes, for which the transmission times
-#      are kept.
-#
-# LIMIT=<bytes>                                        optional, default "15Kb"
-#
-#      This parameter determines the maximal length of backlog. If
-#      the queue contains more data than specified by LIMIT, the
-#      newly arriving packets are dropped. The length of backlog
-#      determines queue latency in case of congestion.
-#
-# PEAK=<speed>                                 optional, default not set
-#
-#      Maximal peak rate for short-term burst traffic. This allows you
-#      to control the absolute peak rate the class can send at, because
-#      single TBF that allows 256Kbit/s would of course allow rate of
-#      512Kbit for half a second or 1Mbit for a quarter of second.
-#
-# MTU=<bytes>                                          optional, default "1500"
-#
-#      Maximum number of bytes that can be sent at once over the
-#      physical medium. This parameter is required when you specify
-#      PEAK parameter. It defaults to MTU of ethernet - for other
-#      media types you might want to change it.
-#
-# Note: Setting TBF as leaf qdisc will effectively prevent the class from
-#      borrowing bandwidth from the ancestor class, because even if the
-#      class allows more traffic to pass through, it is then shaped to
-#      conform to TBF.
-#
-### SFQ qdisc parameters
-#
-# The SFQ queueing discipline is a cheap way for sharing class bandwidth
-# among several hosts. As it is stochastic, the fairness is approximate but
-# it will do the job in most cases. If you want real fairness, you should
-# probably use WRR (weighted round robin) or WFQ queueing disciplines. Note
-# that SFQ does not do any traffic shaping - the shaping is done by the CBQ
-# class the SFQ is attached to.
-#
-# QUANTUM=<bytes>                              optional, default not set
-#
-#      This parameter should not be set lower than link MTU, for ethernet
-#      it is 1500b, or (with MAC header) 1514b which is the value used
-#      in Alexey Kuznetsov's examples.
-#
-# PERTURB=<seconds>                            optional, default "10"
-#
-#      Period of hash function perturbation. If unset, hash reconfiguration
-#      will never take place which is what you probably don't want. The
-#      default value of 10 seconds is probably a good one.
-#
-### Filter parameters
-#
-# RULE=[[saddr[/prefix]][:port[/mask]],][daddr[/prefix]][:port[/mask]]
-#
-#      These parameters make up "u32" filter rules that select traffic for
-#      each of the classes. You can use multiple RULE fields per config.
-#
-#      The optional port mask should only be used by advanced users who
-#      understand how the u32 filter works.
-#
-# Some examples:
-#
-#      RULE=10.1.1.0/24:80
-#              selects traffic going to port 80 in network 10.1.1.0
-#
-#      RULE=10.2.2.5
-#              selects traffic going to any port on single host 10.2.2.5
-#
-#      RULE=10.2.2.5:20/0xfffe
-#              selects traffic going to ports 20 and 21 on host 10.2.2.5
-#
-#      RULE=:25,10.2.2.128/26:5000
-#              selects traffic going from anywhere on port 50 to
-#              port 5000 in network 10.2.2.128
-#
-#      RULE=10.5.5.5:80,
-#              selects traffic going from port 80 of single host 10.5.5.5
-#
-#
-#
-# REALM=[srealm,][drealm]
-#
-#      These parameters make up "route" filter rules that classify traffic
-#      according to packet source/destination realms. For information about
-#      realms, see Alexey Kuznetsov's IP Command Reference. This script
-#      does not define any realms, it justs builds "tc filter" commands
-#      for you if you need to classify traffic this way.
-#
-#      Realm is either a decimal number or a string referencing entry in
-#      /etc/iproute2/rt_realms (usually).
-#
-# Some examples:
-#
-#      REALM=russia,internet
-#              selects traffic going from realm "russia" to realm "internet"
-#
-#      REALM=freenet,
-#              selects traffic going from realm "freenet"
-#
-#      REALM=10
-#              selects traffic going to realm 10
-#
-#
-#
-# MARK=<mark>
-#
-#      These parameters make up "fw" filter rules that select traffic for
-#      each of the classes according to firewall "mark". Mark is a decimal
-#      number packets are tagged with if firewall rules say so. You can
-#      use multiple MARK fields per config.
-#
-#
-# Note: Rules for different filter types can be combined. Attention must be
-#      paid to the priority of filter rules, which can be set below using
-#      PRIO_{RULE,MARK,REALM} variables.
-#
-### Time ranging parameters
-#
-# TIME=[<dow>,<dow>, ...,<dow>/]<from>-<till>;<rate>/<weight>[/<peak>]
-# TIME=0,1,2,5/18:00-06:00;256Kbit/25Kbit
-# TIME=60123/18:00-06:00;256Kbit/25Kbit
-# TIME=18:00-06:00;256Kbit/25Kbit
-#
-#      This parameter allows you to differentiate the class bandwidth
-#      throughout the day. You can specify multiple TIME parameters, if
-#      the times overlap, last match is taken. The fields <rate>, <weight>
-#      and <peak> correspond to parameters RATE, WEIGHT and PEAK (which
-#      is optional and applies to TBF leaf qdisc only).
-#
-#      You can also specify days of week when the TIME rule applies. <dow>
-#      is numeric, 0 corresponds to sunday, 1 corresponds to monday, etc.
-#
-###
-#
-# Sample configuration file: cbq-1280.My_first_shaper
-#
-# --------------------------------------------------------------------------
-# DEVICE=eth0,10Mbit,1Mbit
-# RATE=128Kbit
-# WEIGHT=10Kbit
-# PRIO=5
-# RULE=192.128.1.0/24
-# --------------------------------------------------------------------------
-#
-# The configuration says that we will control traffic on 10Mbit ethernet
-# device eth0 and the traffic going to network 192.168.1.0 will be
-# processed with priority 5 and shaped to rate of 128Kbit.
-#
-# Note that you can control outgoing traffic only. If you want to control
-# traffic in both directions, you must set up CBQ for both interfaces.
-#
-# Consider the following example:
-#
-#                    +---------+      192.168.1.1
-# BACKBONE -----eth0-|  linux  |-eth1------*-[client]
-#                    +---------+
-#
-# Imagine you want to shape traffic from backbone to the client to 28Kbit
-# and traffic in the opposite direction to 128Kbit. You need to setup CBQ
-# on both eth0 and eth1 interfaces, thus you need two config files:
-#
-# cbq-028.backbone-client
-# --------------------------------------------------------------------------
-# DEVICE=eth1,10Mbit,1Mbit
-# RATE=28Kbit
-# WEIGHT=2Kbit
-# PRIO=5
-# RULE=192.168.1.1
-# --------------------------------------------------------------------------
-#
-# cbq-128.client-backbone
-# --------------------------------------------------------------------------
-# DEVICE=eth0,10Mbit,1Mbit
-# RATE=128Kbit
-# WEIGHT=10Kbit
-# PRIO=5
-# RULE=192.168.1.1,
-# --------------------------------------------------------------------------
-#
-# Pay attention to comma "," in the RULE field - it denotes source address!
-#
-# Enjoy.
-#
-#############################################################################
-
-export LC_ALL=C
-
-### Command locations
-TC=/sbin/tc
-IP=/sbin/ip
-MP=/sbin/modprobe
-
-### Default filter priorities (must be different)
-PRIO_RULE_DEFAULT=${PRIO_RULE:-100}
-PRIO_MARK_DEFAULT=${PRIO_MARK:-200}
-PRIO_REALM_DEFAULT=${PRIO_REALM:-300}
-
-### Default CBQ_PATH & CBQ_CACHE settings
-CBQ_PATH=${CBQ_PATH:-/etc/sysconfig/cbq}
-CBQ_CACHE=${CBQ_CACHE:-/var/cache/cbq.init}
-
-### Uncomment to enable logfile for debugging
-#CBQ_DEBUG="/var/run/cbq-$1"
-
-### Modules to probe for. Uncomment the last CBQ_PROBE
-### line if you have QoS support compiled into kernel
-CBQ_PROBE="sch_cbq sch_tbf sch_sfq sch_prio"
-CBQ_PROBE="$CBQ_PROBE cls_fw cls_u32 cls_route"
-#CBQ_PROBE=""
-
-### Keywords required for qdisc & class configuration
-CBQ_WORDS="DEVICE|RATE|WEIGHT|PRIO|PARENT|LEAF|BOUNDED|ISOLATED"
-CBQ_WORDS="$CBQ_WORDS|PRIO_MARK|PRIO_RULE|PRIO_REALM|BUFFER"
-CBQ_WORDS="$CBQ_WORDS|LIMIT|PEAK|MTU|QUANTUM|PERTURB"
-
-### Source AVPKT if it exists
-[ -r /etc/sysconfig/cbq/avpkt ] && . /etc/sysconfig/cbq/avpkt
-AVPKT=${AVPKT:-3000}
-
-
-#############################################################################
-############################# SUPPORT FUNCTIONS #############################
-#############################################################################
-
-### Get list of network devices
-cbq_device_list () {
-       ip link show| sed -n "/^[0-9]/ \
-               { s/^[0-9]\+: \([a-z0-9._]\+\)[:@].*/\1/; p; }"
-} # cbq_device_list
-
-
-### Remove root class from device $1
-cbq_device_off () {
-       tc qdisc del dev $1 root 2> /dev/null
-} # cbq_device_off
-
-
-### Remove CBQ from all devices
-cbq_off () {
-       for dev in `cbq_device_list`; do
-               cbq_device_off $dev
-       done
-} # cbq_off
-
-
-### Prefixed message
-cbq_message () {
-       echo -e "**CBQ: $*"
-} # cbq_message
-
-### Failure message
-cbq_failure () {
-       cbq_message "$@"
-       exit 1
-} # cbq_failure
-
-### Failure w/ cbq-off
-cbq_fail_off () {
-       cbq_message "$@"
-       cbq_off
-       exit 1
-} # cbq_fail_off
-
-
-### Convert time to absolute value
-cbq_time2abs () {
-       local min=${1##*:}; min=${min##0}
-       local hrs=${1%%:*}; hrs=${hrs##0}
-       echo $[hrs*60 + min]
-} # cbq_time2abs
-
-
-### Display CBQ setup
-cbq_show () {
-       for dev in `cbq_device_list`; do
-               [ "`tc qdisc show dev $dev| wc -l`" -eq 0 ] && continue
-               echo -e "### $dev: queueing disciplines\n"
-               tc $1 qdisc show dev $dev; echo
-
-               [ "`tc class show dev $dev| wc -l`" -eq 0 ] && continue
-               echo -e "### $dev: traffic classes\n"
-               tc $1 class show dev $dev; echo
-
-               [ "`tc filter show dev $dev| wc -l`" -eq 0 ] && continue
-               echo -e "### $dev: filtering rules\n"
-               tc $1 filter show dev $dev; echo
-       done
-} # cbq_show
-
-
-### Check configuration and load DEVICES, DEVFIELDS and CLASSLIST from $1
-cbq_init () {
-       ### Get a list of configured classes
-       CLASSLIST=`find $1 -maxdepth 1 \( -type f -or -type l \) -name 'cbq-*' \
-               -not -name '*~' -printf "%f\n"| sort`
-       [ -z "$CLASSLIST" ] &&
-               cbq_failure "no configuration files found in $1!"
-
-       ### Gather all DEVICE fields from $1/cbq-*
-       DEVFIELDS=`find $1 -maxdepth 1 \( -type f -or -type l \) -name 'cbq-*' \
-                 -not -name '*~' -print0 | xargs -0 sed -n 's/#.*//; \
-                 s/[[:space:]]//g; /^DEVICE=[^,]*,[^,]*\(,[^,]*\)\?/ \
-                 { s/.*=//; p; }'| sort -u`
-       [ -z "$DEVFIELDS" ] &&
-               cbq_failure "no DEVICE field found in $1/cbq-*!"
-
-       ### Check for different DEVICE fields for the same device
-       DEVICES=`echo "$DEVFIELDS"| sed 's/,.*//'| sort -u`
-       [ "`echo "$DEVICES"| wc -l`" -ne "`echo "$DEVFIELDS"| wc -l`" ] &&
-               cbq_failure "different DEVICE fields for single device!\n$DEVFIELDS"
-} # cbq_init
-
-
-### Load class configuration from $1/$2
-cbq_load_class () {
-       CLASS=`echo $2| sed 's/^cbq-0*//; s/^\([0-9a-fA-F]\+\).*/\1/'`
-       CFILE=`sed -n 's/#.*//; s/[[:space:]]//g; /^[[:alnum:]_]\+=[[:alnum:].,:;/*@-_]\+$/ p' $1/$2`
-
-       ### Check class number
-       IDVAL=`/usr/bin/printf "%d" 0x$CLASS 2> /dev/null`
-       [ $? -ne 0 -o $IDVAL -lt 2 -o $IDVAL -gt 65535 ] &&
-               cbq_fail_off "class ID of $2 must be in range <0002-FFFF>!"
-
-       ### Set defaults & load class
-       RATE=""; WEIGHT=""; PARENT=""; PRIO=5
-       LEAF=tbf; BOUNDED=yes; ISOLATED=no
-       BUFFER=10Kb/8; LIMIT=15Kb; MTU=1500
-       PEAK=""; PERTURB=10; QUANTUM=""
-
-       PRIO_RULE=$PRIO_RULE_DEFAULT
-       PRIO_MARK=$PRIO_MARK_DEFAULT
-       PRIO_REALM=$PRIO_REALM_DEFAULT
-
-       eval "`echo "$CFILE"| grep -E "^($CBQ_WORDS)="`"
-
-       ### Require RATE/WEIGHT
-       [ -z "$RATE" -o -z "$WEIGHT" ] &&
-               cbq_fail_off "missing RATE or WEIGHT in $2!"
-
-       ### Class device
-       DEVICE=${DEVICE%%,*}
-       [ -z "$DEVICE" ] && cbq_fail_off "missing DEVICE field in $2!"
-
-       BANDWIDTH=`echo "$DEVFIELDS"| sed -n "/^$DEVICE,/ \
-                 { s/[^,]*,\([^,]*\).*/\1/; p; q; }"`
-
-       ### Convert to "tc" options
-       PEAK=${PEAK:+peakrate $PEAK}
-       PERTURB=${PERTURB:+perturb $PERTURB}
-       QUANTUM=${QUANTUM:+quantum $QUANTUM}
-
-       [ "$BOUNDED" = "no" ] && BOUNDED="" || BOUNDED="bounded"
-       [ "$ISOLATED" = "yes" ] && ISOLATED="isolated" || ISOLATED=""
-} # cbq_load_class
-
-
-#############################################################################
-#################################### INIT ###################################
-#############################################################################
-
-### Check for presence of ip-route2 in usual place
-[ -x $TC -a -x $IP ] ||
-       cbq_failure "ip-route2 utilities not installed or executable!"
-
-
-### ip/tc wrappers
-if [ "$1" = "compile" ]; then
-       ### no module probing
-       CBQ_PROBE=""
-
-       ip () {
-               $IP "$@"
-       } # ip
-
-       ### echo-only version of "tc" command
-       tc () {
-               echo "$TC $*"
-       } # tc
-
-elif [ -n "$CBQ_DEBUG" ]; then
-       echo -e "# `date`" > $CBQ_DEBUG
-
-       ### Logging version of "ip" command
-       ip () {
-               echo -e "\n# ip $*" >> $CBQ_DEBUG
-               $IP "$@" 2>&1 | tee -a $CBQ_DEBUG
-       } # ip
-
-       ### Logging version of "tc" command
-       tc () {
-               echo -e "\n# tc $*" >> $CBQ_DEBUG
-               $TC "$@" 2>&1 | tee -a $CBQ_DEBUG
-       } # tc
-else
-       ### Default wrappers
-       
-       ip () {
-               $IP "$@"
-       } # ip
-       
-       tc () {
-               $TC "$@"
-       } # tc
-fi # ip/tc wrappers
-
-
-case "$1" in
-
-#############################################################################
-############################### START/COMPILE ###############################
-#############################################################################
-
-start|compile)
-
-### Probe QoS modules (start only)
-for module in $CBQ_PROBE; do
-       $MP $module || cbq_failure "failed to load module $module"
-done
-
-### If we are in compile/nocache/logging mode, don't bother with cache
-if [ "$1" != "compile" -a "$2" != "nocache" -a -z "$CBQ_DEBUG" ]; then
-       VALID=1
-
-       ### validate the cache
-       [ "$2" = "invalidate" -o ! -f $CBQ_CACHE ] && VALID=0
-       if [ $VALID -eq 1 ]; then
-               [ "`find $CBQ_PATH -maxdepth 1 -newer $CBQ_CACHE| \
-                 wc -l`" -gt 0 ] && VALID=0
-       fi
-
-       ### compile the config if the cache is invalid
-       if [ $VALID -ne 1 ]; then
-               $0 compile > $CBQ_CACHE ||
-                       cbq_fail_off "failed to compile CBQ configuration!"
-       fi
-
-       ### run the cached commands
-       exec /bin/sh $CBQ_CACHE 2> /dev/null
-fi
-
-### Load DEVICES, DEVFIELDS and CLASSLIST
-cbq_init $CBQ_PATH
-
-
-### Setup root qdisc on all configured devices
-for dev in $DEVICES; do
-       ### Retrieve device bandwidth and, optionally, weight
-       DEVTEMP=`echo "$DEVFIELDS"| sed -n "/^$dev,/ { s/$dev,//; p; q; }"`
-       DEVBWDT=${DEVTEMP%%,*}; DEVWGHT=${DEVTEMP##*,}
-       [ "$DEVBWDT" = "$DEVWGHT" ] && DEVWGHT=""
-
-       ### Device bandwidth is required
-       if [ -z "$DEVBWDT" ]; then
-               cbq_message "could not determine bandwidth for device $dev!"
-               cbq_failure "please set up the DEVICE fields properly!"
-       fi
-
-       ### Check if the device is there
-       ip link show $dev &> /dev/null ||
-               cbq_fail_off "device $dev not found!"
-
-       ### Remove old root qdisc from device
-       cbq_device_off $dev
-
-
-       ### Setup root qdisc + class for device
-       tc qdisc add dev $dev root handle 1 cbq \
-       bandwidth $DEVBWDT avpkt $AVPKT cell 8
-
-       ### Set weight of the root class if set
-       [ -n "$DEVWGHT" ] &&
-               tc class change dev $dev root cbq weight $DEVWGHT allot 1514
-
-       [ "$1" = "compile" ] && echo
-done # dev
-
-
-### Setup traffic classes
-for classfile in $CLASSLIST; do
-       cbq_load_class $CBQ_PATH $classfile
-
-       ### Create the class
-       tc class add dev $DEVICE parent 1:$PARENT classid 1:$CLASS cbq \
-       bandwidth $BANDWIDTH rate $RATE weight $WEIGHT prio $PRIO \
-       allot 1514 cell 8 maxburst 20 avpkt $AVPKT $BOUNDED $ISOLATED ||
-               cbq_fail_off "failed to add class $CLASS with parent $PARENT on $DEVICE!"
-
-       ### Create leaf qdisc if set
-       if [ "$LEAF" = "tbf" ]; then
-               tc qdisc add dev $DEVICE parent 1:$CLASS handle $CLASS tbf \
-               rate $RATE buffer $BUFFER limit $LIMIT mtu $MTU $PEAK
-       elif [ "$LEAF" = "sfq" ]; then
-               tc qdisc add dev $DEVICE parent 1:$CLASS handle $CLASS sfq \
-               $PERTURB $QUANTUM
-       fi
-
-
-       ### Create fw filter for MARK fields
-       for mark in `echo "$CFILE"| sed -n '/^MARK/ { s/.*=//; p; }'`; do
-               ### Attach fw filter to root class
-               tc filter add dev $DEVICE parent 1:0 protocol ip \
-               prio $PRIO_MARK handle $mark fw classid 1:$CLASS
-       done ### mark
-
-       ### Create route filter for REALM fields
-       for realm in `echo "$CFILE"| sed -n '/^REALM/ { s/.*=//; p; }'`; do
-               ### Split realm into source & destination realms
-               SREALM=${realm%%,*}; DREALM=${realm##*,}
-               [ "$SREALM" = "$DREALM" ] && SREALM=""
-
-               ### Convert asterisks to empty strings
-               SREALM=${SREALM#\*}; DREALM=${DREALM#\*}
-
-               ### Attach route filter to the root class
-               tc filter add dev $DEVICE parent 1:0 protocol ip \
-               prio $PRIO_REALM route ${SREALM:+from $SREALM} \
-               ${DREALM:+to $DREALM} classid 1:$CLASS
-       done ### realm
-
-       ### Create u32 filter for RULE fields
-       for rule in `echo "$CFILE"| sed -n '/^RULE/ { s/.*=//; p; }'`; do
-               ### Split rule into source & destination
-               SRC=${rule%%,*}; DST=${rule##*,}
-               [ "$SRC" = "$rule" ] && SRC=""
-
-
-               ### Split destination into address, port & mask fields
-               DADDR=${DST%%:*}; DTEMP=${DST##*:}
-               [ "$DADDR" = "$DST" ] && DTEMP=""
-
-               DPORT=${DTEMP%%/*}; DMASK=${DTEMP##*/}
-               [ "$DPORT" = "$DTEMP" ] && DMASK="0xffff"
-
-
-               ### Split up source (if specified)
-               SADDR=""; SPORT=""
-               if [ -n "$SRC" ]; then
-                       SADDR=${SRC%%:*}; STEMP=${SRC##*:}
-                       [ "$SADDR" = "$SRC" ] && STEMP=""
-
-                       SPORT=${STEMP%%/*}; SMASK=${STEMP##*/}
-                       [ "$SPORT" = "$STEMP" ] && SMASK="0xffff"
-               fi
-
-
-               ### Convert asterisks to empty strings
-               SADDR=${SADDR#\*}; DADDR=${DADDR#\*}
-
-               ### Compose u32 filter rules
-               u32_s="${SPORT:+match ip sport $SPORT $SMASK}"
-               u32_s="${SADDR:+match ip src $SADDR} $u32_s"
-               u32_d="${DPORT:+match ip dport $DPORT $DMASK}"
-               u32_d="${DADDR:+match ip dst $DADDR} $u32_d"
-
-               ### Uncomment the following if you want to see parsed rules
-               #echo "$rule: $u32_s $u32_d"
-
-               ### Attach u32 filter to the appropriate class
-               tc filter add dev $DEVICE parent 1:0 protocol ip \
-               prio $PRIO_RULE u32 $u32_s $u32_d classid 1:$CLASS
-       done ### rule
-
-       [ "$1" = "compile" ] && echo
-done ### classfile
-;;
-
-
-#############################################################################
-################################# TIME CHECK ################################
-#############################################################################
-
-timecheck)
-
-### Get time + weekday
-TIME_TMP=`date +%w/%k:%M`
-TIME_DOW=${TIME_TMP%%/*}
-TIME_NOW=${TIME_TMP##*/}
-
-### Load DEVICES, DEVFIELDS and CLASSLIST
-cbq_init $CBQ_PATH
-
-### Run through all classes
-for classfile in $CLASSLIST; do
-       ### Gather all TIME rules from class config
-       TIMESET=`sed -n 's/#.*//; s/[[:space:]]//g; /^TIME/ { s/.*=//; p; }' \
-               $CBQ_PATH/$classfile`
-       [ -z "$TIMESET" ] && continue
-
-       MATCH=0; CHANGE=0
-       for timerule in $TIMESET; do
-               TIME_ABS=`cbq_time2abs $TIME_NOW`
-               
-               ### Split TIME rule to pieces
-               TIMESPEC=${timerule%%;*}; PARAMS=${timerule##*;}
-               WEEKDAYS=${TIMESPEC%%/*}; INTERVAL=${TIMESPEC##*/}
-               BEG_TIME=${INTERVAL%%-*}; END_TIME=${INTERVAL##*-}
-
-               ### Check the day-of-week (if present)
-               [ "$WEEKDAYS" != "$INTERVAL" -a \
-                 -n "${WEEKDAYS##*$TIME_DOW*}" ] && continue
-
-               ### Compute interval boundaries
-               BEG_ABS=`cbq_time2abs $BEG_TIME`
-               END_ABS=`cbq_time2abs $END_TIME`
-
-               ### Midnight wrap fixup
-               if [ $BEG_ABS -gt $END_ABS ]; then
-                       [ $TIME_ABS -le $END_ABS ] &&
-                               TIME_ABS=$[TIME_ABS + 24*60]
-
-                       END_ABS=$[END_ABS + 24*60]
-               fi
-
-               ### If the time matches, remember params and set MATCH flag
-               if [ $TIME_ABS -ge $BEG_ABS -a $TIME_ABS -lt $END_ABS ]; then
-                       TMP_RATE=${PARAMS%%/*}; PARAMS=${PARAMS#*/}
-                       TMP_WGHT=${PARAMS%%/*}; TMP_PEAK=${PARAMS##*/}
-
-                       [ "$TMP_PEAK" = "$TMP_WGHT" ] && TMP_PEAK=""
-                       TMP_PEAK=${TMP_PEAK:+peakrate $TMP_PEAK}
-
-                       MATCH=1
-               fi
-       done ### timerule
-
-
-       cbq_load_class $CBQ_PATH $classfile
-
-       ### Get current RATE of CBQ class
-       RATE_NOW=`tc class show dev $DEVICE| sed -n \
-                "/cbq 1:$CLASS / { s/.*rate //; s/ .*//; p; q; }"`
-       [ -z "$RATE_NOW" ] && continue
-
-       ### Time interval matched
-       if [ $MATCH -ne 0 ]; then
-
-               ### Check if there is any change in class RATE
-               if [ "$RATE_NOW" != "$TMP_RATE" ]; then
-                       NEW_RATE="$TMP_RATE"
-                       NEW_WGHT="$TMP_WGHT"
-                       NEW_PEAK="$TMP_PEAK"
-                       CHANGE=1
-               fi
-
-       ### Match not found, reset to default RATE if necessary
-       elif [ "$RATE_NOW" != "$RATE" ]; then
-               NEW_WGHT="$WEIGHT"
-               NEW_RATE="$RATE"
-               NEW_PEAK="$PEAK"
-               CHANGE=1
-       fi
-
-       ### If there are no changes, go for next class
-       [ $CHANGE -eq 0 ] && continue
-
-       ### Replace CBQ class
-       tc class replace dev $DEVICE classid 1:$CLASS cbq \
-       bandwidth $BANDWIDTH rate $NEW_RATE weight $NEW_WGHT prio $PRIO \
-       allot 1514 cell 8 maxburst 20 avpkt $AVPKT $BOUNDED $ISOLATED
-
-       ### Replace leaf qdisc (if any)
-       if [ "$LEAF" = "tbf" ]; then
-               tc qdisc replace dev $DEVICE handle $CLASS tbf \
-               rate $NEW_RATE buffer $BUFFER limit $LIMIT mtu $MTU $NEW_PEAK
-       fi
-
-       cbq_message "$TIME_NOW: class $CLASS on $DEVICE changed rate ($RATE_NOW -> $NEW_RATE)"
-done ### class file
-;;
-
-
-#############################################################################
-################################## THE REST #################################
-#############################################################################
-
-stop)
-       cbq_off
-       ;;
-
-list)
-       cbq_show
-       ;;
-
-stats)
-       cbq_show -s
-       ;;
-
-restart)
-       shift
-       $0 stop
-       $0 start "$@"
-       ;;
-
-*)
-       echo "Usage: `basename $0` {start|compile|stop|restart|timecheck|list|stats}"
-esac
diff --git a/examples/dhcp-client-script b/examples/dhcp-client-script
deleted file mode 100644 (file)
index f39bc10..0000000
+++ /dev/null
@@ -1,446 +0,0 @@
-#!/bin/bash
-#
-# dhclient-script for Linux.
-#
-#              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:     Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
-#
-# Probably, I did not understand, what this funny feature as "alias"
-# means exactly. For now I suppose, that it is a static address, which
-# we should install and preserve.
-#
-
-exec >> /var/log/DHS.log 2>&1
-
-echo dhc-script $* reason=$reason
-set | grep "^\(old_\|new_\|check_\)"
-
-LOG () {
-    echo LOG $* ;
-}
-
-# convert 8bit mask to length
-# arg: $1 = mask
-#
-Mask8ToLen() {
-       local l=0;
-
-       while [ $l -le 7 ]; do
-               if [ $[ ( 1 << $l ) + $1 ] -eq 256 ]; then
-                       return  $[ 8 - $l ]
-               fi
-               l=$[ $l + 1 ]
-       done
-       return 0;
-}
-
-# convert inet dotted quad mask to length
-# arg: $1 = dotquad mask
-#
-MaskToLen() {
- local masklen=0
- local mask8=$1
-
- case $1 in
- 0.0.0.0)
-       return 0;
-       ;;
- 255.*.0.0)
-       masklen=8
-       mask8=${mask8#255.}
-       mask8=${mask8%.0.0}
-       ;;
- 255.255.*.0)
-       masklen=16
-       mask8=${mask8#255.255.}
-       mask8=${mask8%.0}
-       ;;
- 255.255.255.*)
-       masklen=24
-       mask8=${mask8#255.255.255.}
-       ;;
- *)
-       return 255
-       ;;
- esac
- Mask8ToLen $mask8
- return $[ $? + $masklen ]
-}
-
-# calculate ABC "natural" mask
-# arg: $1 = dotquad address
-#
-ABCMask () {
- local class;
-
- class=${1%%.*}
-
- if [ "$1" = "255.255.255.255" ]; then
-    echo $1
- elif [ "$1" = "0.0.0.0" ]; then
-    echo $1
- elif [ $class -ge 224 ]; then
-    echo 240.0.0.0
- elif [ $class -ge 192 ]; then
-    echo 255.255.255.0
- elif [ $class -ge 128 ]; then
-    echo 255.255.0.0
- else
-    echo 255.0.0.0
- fi
-}
-
-# calculate ABC "natural" mask length
-# arg: $1 = dotquad address
-#
-ABCMaskLen () {
- local class;
-
- class=${1%%.*}
-
- if [ "$1" = "255.255.255.255" ]; then
-    return 32
- elif [ "$1" = "0.0.0.0" ]; then
-    return 0
- elif [ $class -ge 224 ]; then
-    return 4;
- elif [ $class -ge 192 ]; then
-    return 24;
- elif [ $class -ge 128 ]; then
-    return 16;
- else
-    return 8;
- fi
-}
-
-# Delete IP address
-# args: $1 = interface
-#       $2 = address
-#       $3 = mask
-#       $4 = broadcast
-#       $5 = label
-#
-DelINETAddr () {
-  local masklen=32
-  local addrid=$1
-
-  LOG DelINETAddr $*
-
-  if [ "$5" ]; then
-    addrid=$addrid:$5
-  fi
-  LOG ifconfig $addrid down
-  ifconfig $addrid down
-}
-
-# Add IP address
-# args: $1 = interface
-#       $2 = address
-#       $3 = mask
-#       $4 = broadcast
-#       $5 = label
-#
-AddINETAddr () {
-  local mask_arg
-  local brd_arg
-  local addrid=$1
-
-  LOG AddINETAddr $*
-
-  if [ "$5" ]; then
-    addrid=$addrid:$5
-  fi
-  if [ "$3" ]; then
-    mask_arg="netmask $3"
-  fi
-  if [ "$4" ]; then
-    brd_arg="broadcast $4"
-  fi
-
-  LOG ifconfig $addrid $2 $mask_arg $brd_arg up
-  ifconfig $addrid $2 $mask_arg $brd_arg up
-}
-
-# Add default routes
-# args: $1 = routers list
-#
-AddDefaultRoutes() {
-    local router
-
-    if [ "$1" ]; then
-      LOG AddDefaultRoutes $*
-      for router in $1; do
-        LOG route add default gw $router
-        route add default gw $router
-      done ;
-    fi
-}
-
-# Delete default routes
-# args: $1 = routers list
-#
-DelDefaultRoutes() {
-    local router
-
-    if [ "$1" ]; then
-      LOG DelDefaultRoutes $*
-
-      for router in $1; do
-        LOG route del default gw $router
-        route del default gw $router
-      done
-    fi
-}
-
-# ping a host
-# args: $1 = dotquad address of the host
-#
-PingNode() {
-    LOG PingNode $*
-    if ping -q -c 1 -w 2 $1 ; then
-       return 0;
-    fi
-    return 1;
-}
-
-# Check (and add route, if alive) default routers
-# args: $1 = routers list
-# returns: 0 if at least one router is alive.
-#
-CheckRouterList() {
-    local router
-    local succeed=1
-
-    LOG CheckRouterList $*
-
-    for router in $1; do
-      if PingNode $router ; then
-       succeed=0
-        route add default gw $router
-      fi
-    done
-    return $succeed
-}
-
-# Delete/create static routes.
-# args: $1 = operation (del/add)
-#       $2 = routes list in format "dst1 nexthop1 dst2 ..."
-#
-# BEWARE: this feature of DHCP is obsolete, because does not
-#         support subnetting.
-#
-X-StaticRouteList() {
-    local op=$1
-    local lst="$2"
-    local masklen
-
-    LOG X-StaticRouteList $*
-
-    if [ "$lst" ]; then
-      set $lst
-      while [ $# -gt 1 ]; do
-       route $op -net $1 netmask `ABCMask "$1"` gw $2
-       shift; shift;
-      done
-   fi
-}
-
-# Create static routes.
-# arg: $1 = routes list in format "dst1 nexthop1 dst2 ..."
-#
-AddStaticRouteList() {
-    LOG AddStaticRouteList $*
-    X-StaticRouteList add "$1"
-}
-
-# Delete static routes.
-# arg: $1 = routes list in format "dst1 nexthop1 dst2 ..."
-#
-DelStaticRouteList() {
-    LOG DelStaticRouteList $*
-    X-StaticRouteList del "$1"
-}
-
-# Broadcast unsolicited ARP to update neighbours' caches.
-# args: $1 = interface
-#       $2 = address
-#
-UnsolicitedARP() {
-    if [ -f /sbin/arping ]; then
-       /sbin/arping -A -c 1 -I "$1" "$2" &
-       (sleep 2 ; /sbin/arping -U -c 1 -I "$1" "$2" ) &
-    fi
-}
-
-# Duplicate address detection.
-# args: $1 = interface
-#       $2 = test address
-# returns: 0, if DAD succeeded.
-DAD() {
-  if [ -f /sbin/arping ]; then
-       /sbin/arping -c 2 -w 3 -D -I "$1" "$2"
-       return $?
-  fi
-  return 0
-}
-
-
-# Setup resolver.
-# args: NO
-#       domain and nameserver list are passed in global variables.
-#
-# NOTE: we try to be careful and not to break user supplied resolv.conf.
-#       The script mangles it, only if it has dhcp magic signature.
-#
-UpdateDNS() {
-    local nameserver
-    local idstring="#### Generated by DHCPCD"
-
-    LOG UpdateDNS $*
-
-    if [ "$new_domain_name" = "" -a "$new_domain_name_servers" = "" ]; then
-       return 0;
-    fi
-
-    echo $idstring > /etc/resolv.conf.dhcp
-    if [ "$new_domain_name" ]; then
-       echo search $new_domain_name >> /etc/resolv.conf.dhcp
-    fi
-    echo options ndots:1 >> /etc/resolv.conf.dhcp
-
-    if [ "$new_domain_name_servers" ]; then
-       for nameserver in $new_domain_name_servers; do
-           echo nameserver $nameserver >> /etc/resolv.conf.dhcp
-       done
-    else
-       echo nameserver 127.0.0.1 >> /etc/resolv.conf.dhcp
-    fi
-
-    if [ -f /etc/resolv.conf ]; then
-       if [ "`head -1 /etc/resolv.conf`" != "$idstring" ]; then
-           return 0
-       fi
-       if [ "$old_domain_name" = "$new_domain_name" -a
-            "$new_domain_name_servers" = "$old_domain_name_servers" ]; then
-            return 0
-       fi
-    fi
-    mv /etc/resolv.conf.dhcp /etc/resolv.conf
-}
-
-case $reason in
-NBI)
-  exit 1
-  ;;
-
-MEDIUM)
-  exit 0
-  ;;
-
-PREINIT)
-  ifconfig $interface:dhcp down
-  ifconfig $interface:dhcp1 down
-  if [ -d /proc/sys/net/ipv4/conf/$interface ]; then
-    ifconfig $interface:dhcp 10.10.10.10 netmask 255.255.255.255
-    ifconfig $interface:dhcp down
-    if [ -d /proc/sys/net/ipv4/conf/$interface ]; then
-       LOG The interface $interface already configured.
-    fi
-  fi
-  ifconfig $interface:dhcp up
-  exit 0
-  ;;
-
-ARPSEND)
-  exit 0
-  ;;
-
-ARPCHECK)
-  if DAD "$interface" "$check_ip_address" ; then
-    exit 0
-  fi
-  exit 1
-  ;;
-
-BOUND|RENEW|REBIND|REBOOT)
-  if [ "$old_ip_address" -a "$alias_ip_address" -a \
-       "$alias_ip_address" != "$old_ip_address" ]; then
-    DelINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1
-  fi
-  if [ "$old_ip_address" -a "$old_ip_address" != "$new_ip_address" ]; then
-    DelINETAddr "$interface" "$old_ip_address" "$old_subnet_mask" "$old_broadcast_address" dhcp
-    DelDefaultRoutes "$old_routers"
-    DelStaticRouteList "$old_static_routes"
-  fi
-  if [ "$old_ip_address" = "" -o "$old_ip_address" != "$new_ip_address" -o \
-       "$reason" = "BOUND" -o "$reason" = "REBOOT" ]; then
-    AddINETAddr "$interface" "$new_ip_address" "$new_subnet_mask" "$new_broadcast_address" dhcp
-    AddStaticRouteList "$new_static_routes"
-    AddDefaultRoutes "$new_routers"
-    UnsolicitedARP "$interface" "$new_ip_address"
-  fi
-  if [ "$new_ip_address" != "$alias_ip_address" -a "$alias_ip_address" ]; then
-    AddINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1
-  fi
-  UpdateDNS
-  exit 0
-  ;;
-
-EXPIRE|FAIL)
-  if [ "$alias_ip_address" ]; then
-    DelINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1
-  fi
-  if [ "$old_ip_address" ]; then
-    DelINETAddr "$interface" "$old_ip_address" "$old_subnet_mask" "$old_broadcast_address" dhcp
-    DelDefaultRoutes "$old_routers"
-    DelStaticRouteList "$old_static_routes"
-  fi
-  if [ "$alias_ip_address" ]; then
-    AddINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1
-  fi
-  exit 0
-  ;;
-
-TIMEOUT)
-  if [ "$alias_ip_address" ]; then
-    DelINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1
-  fi
-# Seems, <null address> means, that no more old leases found.
-# Or does it mean bug in dhcpcd? 8) Fail for now.
-  if [ "$new_ip_address" = "<null address>" ]; then
-    if [ "$old_ip_address" ]; then
-       DelINETAddr "$interface" "$old_ip_address" "$old_subnet_mask" "$old_broadcast_address" dhcp
-    fi
-    if [ "$alias_ip_address" ]; then
-        AddINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1
-    fi
-    exit 1
-  fi
-  if DAD "$interface" "$new_ip_address" ; then
-    AddINETAddr "$interface" "$new_ip_address" "$new_subnet_mask" "$new_broadcast_address" dhcp
-    UnsolicitedARP "$interface" "$new_ip_address"
-    if [ "$alias_ip_address" -a "$alias_ip_address" != "$new_ip_address" ]; then
-      AddINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1
-      UnsolicitedARP "$interface" "$alias_ip_address"
-    fi
-    if CheckRouterList "$new_routers" ; then
-       AddStaticRouteList "$new_static_routes"
-       UpdateDNS
-       exit 0
-    fi
-  fi
-  DelINETAddr "$interface" "$new_ip_address" "$new_subnet_mask" "$new_broadcast_address" dhcp
-  DelDefaultRoutes "$old_routers"
-  DelStaticRouteList "$old_static_routes"
-  if [ "$alias_ip_address" ]; then
-    AddINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1
-  fi
-  exit 1
-  ;;
-esac
-
-exit 0
index 25954070db27117f88d4f1e8533ff1b4ba768a45..dbdc90e2316ab7ed7c1ec9a133a7c069f9b15cda 100644 (file)
@@ -67,9 +67,9 @@ _PRINT_FUNC(u64, uint64_t);
 _PRINT_FUNC(hhu, unsigned char);
 _PRINT_FUNC(hu, unsigned short);
 _PRINT_FUNC(hex, unsigned int);
-_PRINT_FUNC(0xhex, unsigned long long int);
-_PRINT_FUNC(luint, unsigned long int);
-_PRINT_FUNC(lluint, unsigned long long int);
+_PRINT_FUNC(0xhex, unsigned long long);
+_PRINT_FUNC(luint, unsigned long);
+_PRINT_FUNC(lluint, unsigned long long);
 _PRINT_FUNC(float, double);
 #undef _PRINT_FUNC
 
index 354c27541e896128978ca8f2fa9ea16bb2f341a1..b52dc2d08a2f6b0fb5a14abe4cbaed56b965a3e6 100644 (file)
@@ -43,8 +43,8 @@ void jsonw_hu(json_writer_t *self, unsigned short number);
 void jsonw_int(json_writer_t *self, int number);
 void jsonw_s64(json_writer_t *self, int64_t number);
 void jsonw_null(json_writer_t *self);
-void jsonw_luint(json_writer_t *self, unsigned long int num);
-void jsonw_lluint(json_writer_t *self, unsigned long long int num);
+void jsonw_luint(json_writer_t *self, unsigned long num);
+void jsonw_lluint(json_writer_t *self, unsigned long long num);
 
 /* Useful Combinations of name and value */
 void jsonw_string_field(json_writer_t *self, const char *prop, const char *val);
@@ -59,9 +59,9 @@ void jsonw_int_field(json_writer_t *self, const char *prop, int num);
 void jsonw_s64_field(json_writer_t *self, const char *prop, int64_t num);
 void jsonw_null_field(json_writer_t *self, const char *prop);
 void jsonw_luint_field(json_writer_t *self, const char *prop,
-                       unsigned long int num);
+                       unsigned long num);
 void jsonw_lluint_field(json_writer_t *self, const char *prop,
-                       unsigned long long int num);
+                       unsigned long long num);
 
 /* Collections */
 void jsonw_start_object(json_writer_t *self);
index 2bbe33db8aefa0e68ce1cf93620cc7a973bec417..ff651ca6613083363ee11098274ecf83c97ec230 100644 (file)
@@ -2170,7 +2170,7 @@ union bpf_attr {
  *     Return
  *             0 on success, or a negative error in case of failure.
  *
- * struct bpf_sock *bpf_sk_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u32 netns, u64 flags)
+ * struct bpf_sock *bpf_sk_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags)
  *     Description
  *             Look for TCP socket matching *tuple*, optionally in a child
  *             network namespace *netns*. The return value must be checked,
@@ -2187,12 +2187,14 @@ union bpf_attr {
  *             **sizeof**\ (*tuple*\ **->ipv6**)
  *                     Look for an IPv6 socket.
  *
- *             If the *netns* is zero, then the socket lookup table in the
- *             netns associated with the *ctx* will be used. For the TC hooks,
- *             this in the netns of the device in the skb. For socket hooks,
- *             this in the netns of the socket. If *netns* is non-zero, then
- *             it specifies the ID of the netns relative to the netns
- *             associated with the *ctx*.
+ *             If the *netns* is a negative signed 32-bit integer, then the
+ *             socket lookup table in the netns associated with the *ctx* will
+ *             will be used. For the TC hooks, this is the netns of the device
+ *             in the skb. For socket hooks, this is the netns of the socket.
+ *             If *netns* is any other signed 32-bit value greater than or
+ *             equal to zero then it specifies the ID of the netns relative to
+ *             the netns associated with the *ctx*. *netns* values beyond the
+ *             range of 32-bit integers are reserved for future use.
  *
  *             All values for *flags* are reserved for future usage, and must
  *             be left at zero.
@@ -2201,8 +2203,10 @@ union bpf_attr {
  *             **CONFIG_NET** configuration option.
  *     Return
  *             Pointer to *struct bpf_sock*, or NULL in case of failure.
+ *             For sockets with reuseport option, the *struct bpf_sock*
+ *             result is from reuse->socks[] using the hash of the tuple.
  *
- * struct bpf_sock *bpf_sk_lookup_udp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u32 netns, u64 flags)
+ * struct bpf_sock *bpf_sk_lookup_udp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags)
  *     Description
  *             Look for UDP socket matching *tuple*, optionally in a child
  *             network namespace *netns*. The return value must be checked,
@@ -2219,12 +2223,14 @@ union bpf_attr {
  *             **sizeof**\ (*tuple*\ **->ipv6**)
  *                     Look for an IPv6 socket.
  *
- *             If the *netns* is zero, then the socket lookup table in the
- *             netns associated with the *ctx* will be used. For the TC hooks,
- *             this in the netns of the device in the skb. For socket hooks,
- *             this in the netns of the socket. If *netns* is non-zero, then
- *             it specifies the ID of the netns relative to the netns
- *             associated with the *ctx*.
+ *             If the *netns* is a negative signed 32-bit integer, then the
+ *             socket lookup table in the netns associated with the *ctx* will
+ *             will be used. For the TC hooks, this is the netns of the device
+ *             in the skb. For socket hooks, this is the netns of the socket.
+ *             If *netns* is any other signed 32-bit value greater than or
+ *             equal to zero then it specifies the ID of the netns relative to
+ *             the netns associated with the *ctx*. *netns* values beyond the
+ *             range of 32-bit integers are reserved for future use.
  *
  *             All values for *flags* are reserved for future usage, and must
  *             be left at zero.
@@ -2233,6 +2239,8 @@ union bpf_attr {
  *             **CONFIG_NET** configuration option.
  *     Return
  *             Pointer to *struct bpf_sock*, or NULL in case of failure.
+ *             For sockets with reuseport option, the *struct bpf_sock*
+ *             result is from reuse->socks[] using the hash of the tuple.
  *
  * int bpf_sk_release(struct bpf_sock *sk)
  *     Description
@@ -2405,6 +2413,9 @@ enum bpf_func_id {
 /* BPF_FUNC_perf_event_output for sk_buff input context. */
 #define BPF_F_CTXLEN_MASK              (0xfffffULL << 32)
 
+/* Current network namespace */
+#define BPF_F_CURRENT_NETNS            (-1L)
+
 /* Mode for BPF_FUNC_skb_adjust_room helper. */
 enum bpf_adj_room_mode {
        BPF_ADJ_ROOM_NET,
@@ -2422,6 +2433,12 @@ enum bpf_lwt_encap_mode {
        BPF_LWT_ENCAP_SEG6_INLINE
 };
 
+#define __bpf_md_ptr(type, name)       \
+union {                                        \
+       type name;                      \
+       __u64 :64;                      \
+} __attribute__((aligned(8)))
+
 /* user accessible mirror of in-kernel sk_buff.
  * new fields can only be added to the end of this structure
  */
@@ -2456,7 +2473,7 @@ struct __sk_buff {
        /* ... here. */
 
        __u32 data_meta;
-       struct bpf_flow_keys *flow_keys;
+       __bpf_md_ptr(struct bpf_flow_keys *, flow_keys);
 };
 
 struct bpf_tunnel_key {
@@ -2572,8 +2589,8 @@ enum sk_action {
  * be added to the end of this structure
  */
 struct sk_msg_md {
-       void *data;
-       void *data_end;
+       __bpf_md_ptr(void *, data);
+       __bpf_md_ptr(void *, data_end);
 
        __u32 family;
        __u32 remote_ip4;       /* Stored in network byte order */
@@ -2589,8 +2606,9 @@ struct sk_reuseport_md {
         * Start of directly accessible data. It begins from
         * the tcp/udp header.
         */
-       void *data;
-       void *data_end;         /* End of directly accessible data */
+       __bpf_md_ptr(void *, data);
+       /* End of directly accessible data */
+       __bpf_md_ptr(void *, data_end);
        /*
         * Total length of packet (starting from the tcp/udp header).
         * Note that the directly accessible bytes (data_end - data)
index 21985a5ee6f3bb28d4a1528f7f29c2deee9fe703..016662e910e971d170b073bd829d319a701949f2 100644 (file)
@@ -129,7 +129,7 @@ static void print_operstate(FILE *f, __u8 state)
                if (is_json_context())
                        print_uint(PRINT_JSON, "operstate_index", NULL, state);
                else
-                       print_0xhex(PRINT_FP, NULL, "state %#x", state);
+                       print_0xhex(PRINT_FP, NULL, "state %#llx", state);
        } else if (brief) {
                print_color_string(PRINT_ANY,
                                   oper_state_color(state),
index 0ba6be3f47da0843403547cca18b9f7e99e01853..fbf8a79bfbbb6ec7009db1d9cb26e6059091acb3 100644 (file)
@@ -524,7 +524,7 @@ static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
        if (tb[IFLA_BR_GROUP_FWD_MASK])
                print_0xhex(PRINT_ANY,
                            "group_fwd_mask",
-                           "group_fwd_mask %#x ",
+                           "group_fwd_mask %#llx ",
                            rta_getattr_u16(tb[IFLA_BR_GROUP_FWD_MASK]));
 
        if (tb[IFLA_BR_GROUP_ADDR]) {
index 8b4f93f265be9f2519c85236aabe29184724868d..85e6b424315fd3fc7dbc6e568335c27a93c3ee7b 100644 (file)
@@ -168,11 +168,11 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
                             rta_getattr_u8(tb[IFLA_BRPORT_UNICAST_FLOOD]));
 
        if (tb[IFLA_BRPORT_ID])
-               print_0xhex(PRINT_ANY, "id", "port_id 0x%x ",
+               print_0xhex(PRINT_ANY, "id", "port_id %#llx ",
                            rta_getattr_u16(tb[IFLA_BRPORT_ID]));
 
        if (tb[IFLA_BRPORT_NO])
-               print_0xhex(PRINT_ANY, "no", "port_no 0x%x ",
+               print_0xhex(PRINT_ANY, "no", "port_no %#llx ",
                           rta_getattr_u16(tb[IFLA_BRPORT_NO]));
 
        if (tb[IFLA_BRPORT_DESIGNATED_PORT])
@@ -267,7 +267,7 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
 
                fwd_mask = rta_getattr_u16(tb[IFLA_BRPORT_GROUP_FWD_MASK]);
                print_0xhex(PRINT_ANY, "group_fwd_mask",
-                           "group_fwd_mask 0x%x ", fwd_mask);
+                           "group_fwd_mask %#llx ", fwd_mask);
                _bitmask2str(fwd_mask, convbuf, sizeof(convbuf), fwd_mask_tbl);
                print_string(PRINT_ANY, "group_fwd_mask_str",
                             "group_fwd_mask_str %s ", convbuf);
index 1872b74c5d701170869af966ac9b331614a9501f..278a6e23b311a629eaeadd2c40c593d5c60a8ef8 100644 (file)
@@ -300,7 +300,7 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                tos = rta_getattr_u8(tb[IFLA_GENEVE_TOS]);
        if (tos) {
                if (is_json_context() || tos != 1)
-                       print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+                       print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
                else
                        print_string(PRINT_FP, NULL, "tos %s ", "inherit");
        }
@@ -321,8 +321,7 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
                if (label)
                        print_0xhex(PRINT_ANY,
-                                   "label",
-                                   "flowlabel %#x ",
+                                   "label", "flowlabel %#llx ",
                                    ntohl(label));
        }
 
index 86afbe1334f0e5c23ba70119756d1f610939a082..497affc0c90b36492ddb7c1259e4760679fe1739 100644 (file)
@@ -540,7 +540,7 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                tos = rta_getattr_u8(tb[IFLA_VXLAN_TOS]);
        if (tos) {
                if (is_json_context() || tos != 1)
-                       print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+                       print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
                else
                        print_string(PRINT_FP, NULL, "tos %s ", "inherit");
        }
@@ -571,10 +571,8 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                __u32 label = rta_getattr_u32(tb[IFLA_VXLAN_LABEL]);
 
                if (label)
-                       print_0xhex(PRINT_ANY,
-                                   "label",
-                                   "flowlabel %#x ",
-                                   ntohl(label));
+                       print_0xhex(PRINT_ANY, "label",
+                                   "flowlabel %#llx ", ntohl(label));
        }
 
        if (tb[IFLA_VXLAN_AGEING]) {
index 9b991065e4836a52438bff34dad544b492be555c..54cd2b8c97e46f0188d753645ec5e7751cc9d2e5 100644 (file)
@@ -640,9 +640,11 @@ static void print_attrs(struct rtattr *attrs[])
        }
 }
 
-static __u64 getattr_u64(struct rtattr *stat)
+static __u64 getattr_u64(const struct rtattr *stat)
 {
-       switch (RTA_PAYLOAD(stat)) {
+       size_t len = RTA_PAYLOAD(stat);
+
+       switch (len) {
        case sizeof(__u64):
                return rta_getattr_u64(stat);
        case sizeof(__u32):
@@ -652,8 +654,8 @@ static __u64 getattr_u64(struct rtattr *stat)
        case sizeof(__u8):
                return rta_getattr_u8(stat);
        default:
-               fprintf(stderr, "invalid attribute length %lu\n",
-                       RTA_PAYLOAD(stat));
+               fprintf(stderr, "invalid attribute length %zu\n",
+                       len);
                exit(-1);
        }
 }
index 5b61dd5cb001da598d171fd77fb35278631ff3ad..50fc949f1fcc43fa63df03094b604fbbf0f47bfd 100644 (file)
@@ -360,7 +360,7 @@ static void print_ndtconfig(const struct ndt_config *ndtc)
        print_uint(PRINT_ANY, "hash_rnd",
                   "        hash_rnd %u ", ndtc->ndtc_hash_rnd);
        print_0xhex(PRINT_ANY, "hash_mask",
-                   "hash_mask %08x ", ndtc->ndtc_hash_mask);
+                   "hash_mask %08llx ", ndtc->ndtc_hash_mask);
 
        print_uint(PRINT_ANY, "hash_chain_gc",
                   "hash_chain_gc %u ", ndtc->ndtc_hash_chain_gc);
index 60e46e03cb4931c88543211f7d40b84cfed52dfb..d347246925531ead5e7a6eb40e9bdbbfcb9b4bc2 100644 (file)
@@ -346,7 +346,7 @@ static void print_rtax_features(FILE *fp, unsigned int features)
 
        if (features)
                print_0xhex(PRINT_ANY,
-                           "features", "0x%x ", of);
+                           "features", "%#llx ", of);
 }
 
 static void print_rt_flags(FILE *fp, unsigned int flags)
@@ -483,10 +483,10 @@ static void print_rta_cacheinfo(FILE *fp, const struct rta_cacheinfo *ci)
        }
        if (ci->rta_id)
                print_0xhex(PRINT_ANY, "ipid",
-                           "ipid 0x%04x ", ci->rta_id);
+                           "ipid 0x%04llx ", ci->rta_id);
        if (ci->rta_ts || ci->rta_tsage) {
                print_0xhex(PRINT_ANY, "ts",
-                           "ts 0x%x", ci->rta_ts);
+                           "ts 0x%llx", ci->rta_ts);
                print_uint(PRINT_ANY, "tsage",
                           "tsage %usec ", ci->rta_tsage);
        }
@@ -885,7 +885,7 @@ int print_route(struct nlmsghdr *n, void *arg)
                                print_uint(PRINT_JSON, "mark", NULL, mark);
                        else if (mark >= 16)
                                print_0xhex(PRINT_FP, NULL,
-                                           "mark 0x%x ", mark);
+                                           "mark 0x%llx ", mark);
                        else
                                print_uint(PRINT_FP, NULL,
                                           "mark %u ", mark);
index 85ab13cb31746b4ecf25c86e0d4ceb956dc57b2b..aee18ac558b5da34701d6519cd26f1f0bee2474d 100644 (file)
@@ -115,7 +115,7 @@ static void print_srh(FILE *fp, struct ipv6_sr_hdr *srh)
 
                tlv = (struct sr6_tlv_hmac *)((char *)srh + offset);
                print_0xhex(PRINT_ANY, "hmac",
-                           "hmac 0x%X ", ntohl(tlv->hmackeyid));
+                           "hmac %llX ", ntohl(tlv->hmackeyid));
        }
 }
 
index 9aa411ceb8aa4e1e4f1cf9eab8b7c20dcd1a5843..6af71cab653479f3c467958f70d169fb7c963817 100644 (file)
@@ -299,10 +299,10 @@ int print_rule(struct nlmsghdr *n, void *arg)
 
                if (tb[FRA_FWMASK] &&
                    (mask = rta_getattr_u32(tb[FRA_FWMASK])) != 0xFFFFFFFF) {
-                       print_0xhex(PRINT_ANY, "fwmark", "fwmark 0x%x", mark);
-                       print_0xhex(PRINT_ANY, "fwmask", "/0x%x ", mask);
+                       print_0xhex(PRINT_ANY, "fwmark", "fwmark %#llx", mark);
+                       print_0xhex(PRINT_ANY, "fwmask", "/%#llx ", mask);
                } else {
-                       print_0xhex(PRINT_ANY, "fwmark", "fwmark 0x%x ", mark);
+                       print_0xhex(PRINT_ANY, "fwmark", "fwmark %#llx ", mark);
                }
        }
 
index 528055a0bf46440ca3c3d7514ce715c37b18f70d..03238c3f6518bb6133c7824deb012db2960d503a 100644 (file)
@@ -254,7 +254,7 @@ static void print_flags(long flags)
        flags &= ~(IFF_TUN | IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE |
                   IFF_VNET_HDR | IFF_PERSIST | IFF_NOFILTER);
        if (flags)
-               print_0xhex(PRINT_ANY, NULL, "%#x", flags);
+               print_0xhex(PRINT_ANY, NULL, "%#llx", flags);
 
        close_json_array(PRINT_JSON, NULL);
 }
index 1ee7ee13ab6cdcc90132efff8c353e22266faaac..d754fa9a3425fa89e992b53e571b12c243147a18 100644 (file)
@@ -463,7 +463,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                tos = rta_getattr_u8(tb[IFLA_GRE_TOS]);
        if (tos) {
                if (is_json_context() || tos != 1)
-                       print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+                       print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
                else
                        print_string(PRINT_FP, NULL, "tos %s ", "inherit");
        }
@@ -508,7 +508,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
                if (fwmark) {
                        print_0xhex(PRINT_ANY,
-                                   "fwmark", "fwmark 0x%x ", fwmark);
+                                   "fwmark", "fwmark %#llx ", fwmark);
                }
        }
 
@@ -541,7 +541,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                __u16 erspan_hwid = rta_getattr_u16(tb[IFLA_GRE_ERSPAN_HWID]);
 
                print_0xhex(PRINT_ANY,
-                           "erspan_hwid", "erspan_hwid 0x%x ", erspan_hwid);
+                           "erspan_hwid", "erspan_hwid %#llx ", erspan_hwid);
        }
 
        tnl_print_encap(tb,
index 20f930596027972d23d4798cebb167e9c54d7d32..6c4671e5a820693b5e22ad8722f41511a1c8eddd 100644 (file)
@@ -576,7 +576,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
                if (fwmark) {
                        print_0xhex(PRINT_ANY,
-                                   "fwmark", "fwmark 0x%x ", fwmark);
+                                   "fwmark", "fwmark %#llx ", fwmark);
                }
        }
 
@@ -609,7 +609,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                __u16 erspan_hwid = rta_getattr_u16(tb[IFLA_GRE_ERSPAN_HWID]);
 
                print_0xhex(PRINT_ANY,
-                           "erspan_hwid", "erspan_hwid 0x%x ", erspan_hwid);
+                           "erspan_hwid", "erspan_hwid %#llx ", erspan_hwid);
        }
 
        tnl_print_encap(tb,
index cfe2c5aa372422f9e1ff40cc6cd4b577e207fadc..711988a150a5ad4c469c2260a8defb0bbc03da8b 100644 (file)
@@ -457,7 +457,7 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
 
                if (fwmark) {
                        print_0xhex(PRINT_ANY,
-                                   "fwmark", "fwmark 0x%x ", fwmark);
+                                   "fwmark", "fwmark %#llx ", fwmark);
                }
        }
 
index 7ec1594d071679440df26218b78a968418497ae0..d4a56de40061523cd4436509c33a1be8e4d99fa7 100644 (file)
@@ -418,7 +418,7 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
                tos = rta_getattr_u8(tb[IFLA_IPTUN_TOS]);
        if (tos) {
                if (is_json_context() || tos != 1)
-                       print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+                       print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
                else
                        print_string(PRINT_FP, NULL, "tos %s ", "inherit");
        }
@@ -476,7 +476,7 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
 
                if (fwmark) {
                        print_0xhex(PRINT_ANY,
-                                   "fwmark", "fwmark 0x%x ", fwmark);
+                                   "fwmark", "fwmark %#llx ", fwmark);
                }
        }
 
index 3fff4417de11b1158ec5768cccef77afaf929f85..b974c62b27545b51b1e7f38eb3fd0ce642af2f0a 100644 (file)
@@ -208,7 +208,7 @@ static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
                if (fwmark) {
                        print_0xhex(PRINT_ANY,
-                                   "fwmark", "fwmark 0x%x ", fwmark);
+                                   "fwmark", "fwmark %#llx ", fwmark);
                }
        }
 }
index f5a267a81d9de8c6fe5ebfca3a57da3e19090068..f13c08583103a5f0a67e0fec5c31a600ac13dfd8 100644 (file)
@@ -210,7 +210,7 @@ static void vti6_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
                if (fwmark) {
                        print_0xhex(PRINT_ANY,
-                                   "fwmark", "fwmark 0x%x ", fwmark);
+                                   "fwmark", "fwmark %#llx ", fwmark);
                }
        }
 }
index 6aff8f7bad7fbc92879a1736740a66e481ad5319..5e85cfc0bdd5b607f57bbc03a8f131e028c400d1 100644 (file)
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -102,11 +102,6 @@ static const struct bpf_prog_meta __bpf_prog_meta[] = {
        },
 };
 
-static bool bpf_map_offload_neutral(enum bpf_map_type type)
-{
-       return type == BPF_MAP_TYPE_PERF_EVENT_ARRAY;
-}
-
 static const char *bpf_prog_to_subdir(enum bpf_prog_type type)
 {
        assert(type < ARRAY_SIZE(__bpf_prog_meta) &&
@@ -1610,6 +1605,11 @@ static bool bpf_is_map_in_map_type(const struct bpf_elf_map *map)
               map->type == BPF_MAP_TYPE_HASH_OF_MAPS;
 }
 
+static bool bpf_map_offload_neutral(enum bpf_map_type type)
+{
+       return type == BPF_MAP_TYPE_PERF_EVENT_ARRAY;
+}
+
 static int bpf_map_attach(const char *name, struct bpf_elf_ctx *ctx,
                          const struct bpf_elf_map *map, struct bpf_map_ext *ext,
                          int *have_map_in_map)
index 4f5fef195fdede3dced6254b0267bc82bd0df6ec..4eb2d0dc3c848b2d7d64ee3da402c5894546160f 100644 (file)
@@ -122,8 +122,8 @@ _PRINT_FUNC(hhu, unsigned char);
 _PRINT_FUNC(hu, unsigned short);
 _PRINT_FUNC(uint, unsigned int);
 _PRINT_FUNC(u64, uint64_t);
-_PRINT_FUNC(luint, unsigned long int);
-_PRINT_FUNC(lluint, unsigned long long int);
+_PRINT_FUNC(luint, unsigned long);
+_PRINT_FUNC(lluint, unsigned long long);
 _PRINT_FUNC(float, double);
 #undef _PRINT_FUNC
 
index 46eff6ad98289edfe716bdabe2d1f9fad61fee6d..5004c181e6225bb2e4e3aba4859ee7ebce42445d 100644 (file)
@@ -236,12 +236,12 @@ void jsonw_xint(json_writer_t *self, uint64_t num)
        jsonw_printf(self, "%"PRIx64, num);
 }
 
-void jsonw_luint(json_writer_t *self, unsigned long int num)
+void jsonw_luint(json_writer_t *self, unsigned long num)
 {
        jsonw_printf(self, "%lu", num);
 }
 
-void jsonw_lluint(json_writer_t *self, unsigned long long int num)
+void jsonw_lluint(json_writer_t *self, unsigned long long num)
 {
        jsonw_printf(self, "%llu", num);
 }
@@ -307,7 +307,7 @@ void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num)
 
 void jsonw_luint_field(json_writer_t *self,
                        const char *prop,
-                       unsigned long int num)
+                       unsigned long num)
 {
        jsonw_name(self, prop);
        jsonw_luint(self, num);
@@ -315,7 +315,7 @@ void jsonw_luint_field(json_writer_t *self,
 
 void jsonw_lluint_field(json_writer_t *self,
                        const char *prop,
-                       unsigned long long int num)
+                       unsigned long long num)
 {
        jsonw_name(self, prop);
        jsonw_lluint(self, num);
index 9ebc82746d39360005d5b257098cf264e042c7f7..a81c070069fedecab440e57756aa018bc0eee321 100644 (file)
@@ -1453,7 +1453,7 @@ char *int_to_str(int val, char *buf)
 
 int get_guid(__u64 *guid, const char *arg)
 {
-       unsigned long int tmp;
+       unsigned long tmp;
        char *endptr;
        int i;
 
index 1b04a821ae2fe27cf2ca6421aeeec9d8b0971801..87f291ab50ac026da82f063293cb0ac5e1fbd440 100644 (file)
@@ -5,7 +5,7 @@ rtpr \- replace backslashes with newlines.
 
 .SH DESCRIPTION
 .B rtpr
-is a trivial bash script which converts backslashes in standard input to newlines. It's sole purpose is to be fed with input from
+is a trivial shell script which converts backslashes in standard input to newlines. It's sole purpose is to be fed with input from
 .B ip
 when executed with it's
 .B --oneline
index 699a12711ba5b503b6af0ddea744d425dce1c069..f138c91a1fcc4edcde9e1fde4d44316c4f4568b1 100644 (file)
@@ -163,7 +163,7 @@ the congestion algorithm name, the default congestion algorithm is "cubic"
 .P
 .TP
 .B wscale:<snd_wscale>:<rcv_wscale>
-if window scale option is used, this field shows the send scale factory and receive scale factory
+if window scale option is used, this field shows the send scale factor and receive scale factor
 .P
 .TP
 .B rto:<icsk_rto>
index 760b7fb3bb18fd2011c39890217ab3dd13190192..60ff4b31e3204cb32fa16c0642b84ffa9bf0af00 100644 (file)
@@ -20,7 +20,7 @@ static int dev_help(struct rd *rd)
 
 static const char *dev_caps_to_str(uint32_t idx)
 {
-#define RDMA_DEV_FLAGS(x) \
+#define RDMA_DEV_FLAGS_LOW(x) \
        x(RESIZE_MAX_WR, 0) \
        x(BAD_PKEY_CNTR, 1) \
        x(BAD_QKEY_CNTR, 2) \
@@ -50,21 +50,39 @@ static const char *dev_caps_to_str(uint32_t idx)
        x(CROSS_CHANNEL, 27) \
        x(MANAGED_FLOW_STEERING, 29) \
        x(SIGNATURE_HANDOVER, 30) \
-       x(ON_DEMAND_PAGING, 31) \
-       x(SG_GAPS_REG, 32) \
-       x(VIRTUAL_FUNCTION, 33) \
-       x(RAW_SCATTER_FCS, 34) \
-       x(RDMA_NETDEV_OPA_VNIC, 35) \
-       x(PCI_WRITE_END_PADDING, 36)
-
-       enum { RDMA_DEV_FLAGS(RDMA_BITMAP_ENUM) };
+       x(ON_DEMAND_PAGING, 31)
+
+#define RDMA_DEV_FLAGS_HIGH(x) \
+       x(SG_GAPS_REG, 0) \
+       x(VIRTUAL_FUNCTION, 1) \
+       x(RAW_SCATTER_FCS, 2) \
+       x(RDMA_NETDEV_OPA_VNIC, 3) \
+       x(PCI_WRITE_END_PADDING, 4)
+
+       /*
+        * Separation below is needed to allow compilation of rdmatool
+        * on 32bits systems. On such systems, C-enum is limited to be
+        * int and can't hold more than 32 bits.
+        */
+       enum { RDMA_DEV_FLAGS_LOW(RDMA_BITMAP_ENUM) };
+       enum { RDMA_DEV_FLAGS_HIGH(RDMA_BITMAP_ENUM) };
 
        static const char * const
-               rdma_dev_names[] = { RDMA_DEV_FLAGS(RDMA_BITMAP_NAMES) };
-       #undef RDMA_DEV_FLAGS
+               rdma_dev_names_low[] = { RDMA_DEV_FLAGS_LOW(RDMA_BITMAP_NAMES) };
+       static const char * const
+               rdma_dev_names_high[] = { RDMA_DEV_FLAGS_HIGH(RDMA_BITMAP_NAMES) };
+       uint32_t high_idx;
+       #undef RDMA_DEV_FLAGS_LOW
+       #undef RDMA_DEV_FLAGS_HIGH
+
+       if (idx < ARRAY_SIZE(rdma_dev_names_low) && rdma_dev_names_low[idx])
+               return rdma_dev_names_low[idx];
+
+       high_idx = idx - ARRAY_SIZE(rdma_dev_names_low);
+       if (high_idx <  ARRAY_SIZE(rdma_dev_names_high) &&
+           rdma_dev_names_high[high_idx])
+               return rdma_dev_names_high[high_idx];
 
-       if (idx < ARRAY_SIZE(rdma_dev_names) && rdma_dev_names[idx])
-               return rdma_dev_names[idx];
        return "UNKNOWN";
 }
 
index f8010d3c0ba1e864538152c3236b4557b3a4b347..2edaf2c8836475c78e713e789a05203e1c598327 100644 (file)
@@ -171,7 +171,7 @@ em_ipset.o: CFLAGS += $$($(PKG_CONFIG) xtables --cflags)
 em_ipt.o: CFLAGS += $$($(PKG_CONFIG) xtables --cflags)
 
 ifeq ($(TC_CONFIG_XT),y)
-  LDFLAGS += $$($(PKG_CONFIG) xtables --libs)
+  LDLIBS += $$($(PKG_CONFIG) xtables --libs)
 endif
 
 %.yacc.c: %.y
index 20e9c73d9a0edb7ee20365dd199a5942f294a293..2bf9f2047b46df7e6ce15351011b488fffb384ab 100644 (file)
@@ -247,7 +247,7 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
        if (tb[TCA_IFE_TYPE]) {
                ife_type = rta_getattr_u16(tb[TCA_IFE_TYPE]);
                has_optional = 1;
-               print_0xhex(PRINT_ANY, "type", "type 0x%X ", ife_type);
+               print_0xhex(PRINT_ANY, "type", "type %#llX ", ife_type);
        }
 
        if (has_optional)
index 5fb11d28c5c3a37cb0de5f29c54bb876b441db32..520522266e0098837f456b6e2310e803f26aa5eb 100644 (file)
@@ -332,7 +332,7 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
                if (RTA_PAYLOAD(tb[TCA_HTB_INIT])  < sizeof(*gopt)) return -1;
 
                print_int(PRINT_ANY, "r2q", "r2q %d", gopt->rate2quantum);
-               print_0xhex(PRINT_ANY, "default", " default %x", gopt->defcls);
+               print_0xhex(PRINT_ANY, "default", " default %#llx", gopt->defcls);
                print_uint(PRINT_ANY, "direct_packets_stat",
                           " direct_packets_stat %u", gopt->direct_pkts);
                if (show_details) {
index 562dacb874f0fce5650b54f1cac59722201f926a..8f6b263a4141f341094bde76ddfeeb0cf86759aa 100644 (file)
@@ -328,7 +328,7 @@ static int print_sched_list(FILE *f, struct rtattr *list)
                open_json_object(NULL);
                print_uint(PRINT_ANY, "index", "\tindex %u", index);
                print_string(PRINT_ANY, "cmd", " cmd %s", entry_cmd_to_str(command));
-               print_0xhex(PRINT_ANY, "gatemask", " gatemask %#x", gatemask);
+               print_0xhex(PRINT_ANY, "gatemask", " gatemask %#llx", gatemask);
                print_uint(PRINT_ANY, "interval", " interval %u", interval);
                close_json_object();
 
index 46b243b016ee65356701aee628dacd8316c0b42c..9b0f1c157a3980a3ac80b8489d316128622698aa 100644 (file)
@@ -53,7 +53,7 @@ clean: testclean
 distclean: clean
        echo "Entering iproute2" && cd iproute2 && $(MAKE) distclean && cd ..;
 
-$(TESTS): testclean
+$(TESTS): generate_nlmsg testclean
 ifeq (,$(IPVERS))
        $(error Please run make first)
 endif
index 569ba1f84cdc36d5d931c9bf80dde4eb13f2b490..ded4edc3fb39a789169fa2475b26a109196ecf98 100755 (executable)
@@ -31,3 +31,5 @@ ts_ip "$0" "Add another IPv6 route dst cafe:babe::/64" -6 route add cafe:babe::/
 ts_ip "$0" "Show IPv6 default route" -6 route show default
 test_on "default via dead:beef::2 dev $DEV"
 test_lines_count 1
+
+ts_ip "$0" "Del $DEV dummy interface"  link del dev $DEV
index 3f5a9d3c1acfc581dce677a1a3871c2cfcdf6ad0..65db431cdefe5b445d8373628f270430d6b38479 100755 (executable)
@@ -3,6 +3,16 @@
 . lib/generic.sh
 
 TUNNEL_NAME="tunnel_test_ip"
+KMODS="ip6_gre ip6_tunnel ip_gre ip_tunnel gre"
+
+# unload kernel modules to remove dummy interfaces only if they were not in use beforehand
+kmods_remove=
+# note that checkbashism reports command -v, but dash supports it and it's POSIX 2008 compliant
+if command -v lsmod >/dev/null 2>&1 && command -v rmmod >/dev/null 2>&1; then
+    for i in $KMODS; do
+        lsmod | grep -q "^$i" || kmods_remove="$kmods_remove $i";
+    done
+fi
 
 ts_log "[Testing add/del tunnels]"
 
@@ -12,3 +22,6 @@ ts_ip "$0" "Del GRE tunnel over IPv4" tunnel del $TUNNEL_NAME
 ts_ip "$0" "Add GRE tunnel over IPv6" tunnel add name $TUNNEL_NAME mode ip6gre local dead:beef::1 remote dead:beef::2
 ts_ip "$0" "Del GRE tunnel over IPv6" tunnel del $TUNNEL_NAME
 
+for mod in $kmods_remove; do
+    sudo rmmod "$mod"
+done
index 177585e63363e71dba0f982c84e70bf719b79a85..3f1d5ef25850a755b5706afb3a9ff2d2eb30b7bf 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # vim: ft=sh
 
 . lib/generic.sh