]> git.proxmox.com Git - mirror_iproute2.git/log
mirror_iproute2.git
7 years agoip {link,address}: add 'macsec' item to TYPE list
Davide Caratti [Tue, 26 Jul 2016 09:03:19 +0000 (11:03 +0200)]
ip {link,address}: add 'macsec' item to TYPE list

fix output of "ip address help" and "ip link help". Update TYPE list in man
pages ip-address.8 and ip-link.8 as well.

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
7 years agoman: macsec: fix macsec related typos
Davide Caratti [Tue, 26 Jul 2016 09:03:18 +0000 (11:03 +0200)]
man: macsec: fix macsec related typos

- ip-macsec.8: fix wrong 'device' keyword in 'ip link add device eth0';
add missing description of 'validate' keyword; remove spurious bracket
near 'encrypt' keyword; add missing reference to configuration of 'port'
and 'sci'
- ip-link.8 fix wrong 'es' and 'encoding' keywords in MACsec section

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
7 years agoman/man8/tc-flow.8: minor corrections
Michal Soltys [Sun, 24 Jul 2016 00:00:29 +0000 (02:00 +0200)]
man/man8/tc-flow.8: minor corrections

- baseclass: major handle must match that of class's, Y defaults to 1
- flow map example: maps to 1-256, not 1-257

Signed-off-by: Michal Soltys <soltys@ziu.info>
7 years agotc: util: No need for action_n2a() to be reentrant
Phil Sutter [Sat, 23 Jul 2016 11:28:10 +0000 (13:28 +0200)]
tc: util: No need for action_n2a() to be reentrant

This allows to remove some buffers here and there. While at it, make it
return a const value.

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agotc: use action_a2n() everywhere
Phil Sutter [Sat, 23 Jul 2016 11:28:09 +0000 (13:28 +0200)]
tc: use action_a2n() everywhere

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agotc: util: bore up action_a2n()
Phil Sutter [Sat, 23 Jul 2016 11:28:08 +0000 (13:28 +0200)]
tc: util: bore up action_a2n()

It's a pitty this function is used nowhere, so let's polish it for use:

* Loop over branch names, makes it clear that every former conditional
  was exactly identical.
* Support 'pipe' branch name, too.
* Make number parsing optional.

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agotc: Reformat tc_util.h
Phil Sutter [Sat, 23 Jul 2016 11:28:07 +0000 (13:28 +0200)]
tc: Reformat tc_util.h

* Drop 'extern' keyword before function declarations.
* Add parameter names where they were missing for matters of
  consistency.
* Drop fancy indenting (e.g. tab between type and name).
* Break long lines to not exceed 80 columns.

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agol2tp: add udp checksum control flags
Shanker Wang [Thu, 21 Jul 2016 10:59:10 +0000 (18:59 +0800)]
l2tp: add udp checksum control flags

Three options are added for the user to control
whether the checksum is enabled

Signed-off-by: Miao Wang <miao.wang@tuna.tsinghua.edu.cn>
7 years agoip-address.8: Document autojoin flag
Phil Sutter [Tue, 12 Jul 2016 07:56:16 +0000 (09:56 +0200)]
ip-address.8: Document autojoin flag

Description copied from related kernel support commit message with a
little tailoring to fit.

While at it, fix font of non-terminal CONFFLAG-LIST in synopsis.

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agotc: ematch: Ignore all-zero mask value when printing filters
Phil Sutter [Thu, 14 Jul 2016 21:10:53 +0000 (23:10 +0200)]
tc: ematch: Ignore all-zero mask value when printing filters

The optional mask which may be added to int values is considered by the
kernel only if it is non-zero, therefore tc should only then also print
it.

Without this, not passing a mask value like so:

| # tc filter add dev d0 parent 8001: \
|  basic match meta\(vlan eq 1\) \
|  classid 8001:1

Would lead to tc printing an all-zero mask later:

| # tc filter show dev d0
| filter parent 8001: protocol all pref 49151 basic
| filter parent 8001: protocol all pref 49151 basic handle 0x1 flowid 8001:1
|   meta(vlan mask 0x00000000 eq 1)

This is obviously confusing as an all-zero mask strictly means to
eliminate all bits from the value, but the opposite is the case.

Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agoMakefile: Allow to override CC
Phil Sutter [Mon, 18 Jul 2016 14:48:45 +0000 (16:48 +0200)]
Makefile: Allow to override CC

This makes it easier to build iproute2 with a custom compiler.

While at it, make HOSTCC default to the value of CC if not explicitly
set elsewhere.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoNo need to initialize rtattr fields before parsing
Phil Sutter [Mon, 18 Jul 2016 14:48:44 +0000 (16:48 +0200)]
No need to initialize rtattr fields before parsing

Since parse_rtattr_flags() calls memset already, there is no need for
callers to do so themselves.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoReplace malloc && memset by calloc
Phil Sutter [Mon, 18 Jul 2016 14:48:43 +0000 (16:48 +0200)]
Replace malloc && memset by calloc

This only replaces occurrences where the newly allocated memory is
cleared completely afterwards, as in other cases it is a theoretical
performance hit although code would be cleaner this way.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoUse C99 style initializers everywhere
Phil Sutter [Mon, 18 Jul 2016 14:48:42 +0000 (16:48 +0200)]
Use C99 style initializers everywhere

This big patch was compiled by vimgrepping for memset calls and changing
to C99 initializer if applicable. One notable exception is the
initialization of union bpf_attr in tc/tc_bpf.c: changing it would break
for older gcc versions (at least <=3.4.6).

Calls to memset for struct rtattr pointer fields for parse_rtattr*()
were just dropped since they are not needed.

The changes here allowed the compiler to discover some unused variables,
so get rid of them, too.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
7 years agotc: m_action: Improve conversion to C99 style initializers
Phil Sutter [Mon, 18 Jul 2016 14:48:41 +0000 (16:48 +0200)]
tc: m_action: Improve conversion to C99 style initializers

This improves my initial change in the following points:

- Flatten embedded struct's initializers.
- No need to initialize variables to zero as the key feature of C99
  initializers is to do this implicitly.
- By relocating the declaration of struct rtattr *tail, it can be
  initialized at the same time.

Fixes: a0a73b298a579 ("tc: m_action: Use C99 style initializers for struct req")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoip-link.8: Fix font choices
Phil Sutter [Sat, 9 Jul 2016 09:22:50 +0000 (11:22 +0200)]
ip-link.8: Fix font choices

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agoip-link.8: Add slave type option descriptions
Phil Sutter [Sat, 9 Jul 2016 09:22:49 +0000 (11:22 +0200)]
ip-link.8: Add slave type option descriptions

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agoip-link.8: Place 'ip link set' warning more prominently
Phil Sutter [Sat, 9 Jul 2016 09:22:48 +0000 (11:22 +0200)]
ip-link.8: Place 'ip link set' warning more prominently

This moves the warning to the beginning of the section about 'ip link
set' which makes it still stand out after adding more text to it's end.

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agoip-link.8: Extend type list in synopsis
Phil Sutter [Sat, 9 Jul 2016 09:22:47 +0000 (11:22 +0200)]
ip-link.8: Extend type list in synopsis

'ip link set' supports passing a type to set type-specific parameters.
Add this missing piece of information to the synopsis section.

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agoiplink: bond_slave: Add missing help functions
Phil Sutter [Sat, 9 Jul 2016 09:22:46 +0000 (11:22 +0200)]
iplink: bond_slave: Add missing help functions

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agoiplink: List valid 'type' argument in ip link help text
Phil Sutter [Sat, 9 Jul 2016 09:22:45 +0000 (11:22 +0200)]
iplink: List valid 'type' argument in ip link help text

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agobridge: remove unused variable
Stephen Hemminger [Wed, 20 Jul 2016 19:03:33 +0000 (12:03 -0700)]
bridge: remove unused variable

Debris from JSON changes.

7 years agobridge: update man page
Roopa Prabhu [Wed, 22 Jun 2016 13:45:55 +0000 (06:45 -0700)]
bridge: update man page

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agobridge: add json schema for bridge fdb show
Anuradha Karuppiah [Wed, 22 Jun 2016 13:45:54 +0000 (06:45 -0700)]
bridge: add json schema for bridge fdb show

Storing the schema file for the json format will be useful for doc
purposes as optional paramaters are typically suppressed in the json
sample outputs.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
7 years agobridge: add json support for bridge fdb show
Anuradha Karuppiah [Wed, 22 Jun 2016 13:45:53 +0000 (06:45 -0700)]
bridge: add json support for bridge fdb show

Sample output:
$bridge -j fdb show
[{
        "mac": "44:38:39:00:69:88",
        "dev": "swp2s0",
        "vlan": 2,
        "master": "br0",
        "state": "permanent"
    },{
        "mac": "00:02:00:00:00:01",
        "dev": "swp2s0",
        "vlan": 2,
        "master": "br0"
    },{
        "mac": "00:02:00:00:00:02",
        "dev": "swp2s1",
        "vlan": 2,
        "master": "br0"
    },{
        "mac": "44:38:39:00:69:89",
        "dev": "swp2s1",
        "master": "br0",
        "state": "permanent"
    },{
        "mac": "44:38:39:00:69:89",
        "dev": "swp2s1",
        "vlan": 2,
        "master": "br0",
        "state": "permanent"
    },{
        "mac": "44:38:39:00:69:88",
        "dev": "br0",
        "master": "br0",
        "state": "permanent"
    }
]

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agobridge: add json support for bridge vlan show
Roopa Prabhu [Wed, 22 Jun 2016 13:45:52 +0000 (06:45 -0700)]
bridge: add json support for bridge vlan show

$bridge -c vlan show
port vlan ids
swp1  1 PVID Egress Untagged
 10-13

swp2  1 PVID Egress Untagged
 10-13

br0  1 PVID Egress Untagged

$bridge  -json vlan show
{
    "swp1": [{
            "vlan": 1,
            "flags": ["PVID","Egress Untagged"
            ]
        },{
            "vlan": 10
        },{
            "vlan": 11
        },{
            "vlan": 12
        },{
            "vlan": 13
        }
    ],
    "swp2": [{
            "vlan": 1,
            "flags": ["PVID","Egress Untagged"
            ]
        },{
            "vlan": 10
        },{
            "vlan": 11
        },{
            "vlan": 12
        },{
            "vlan": 13
        }
    ],
    "br0": [{
            "vlan": 1,
            "flags": ["PVID","Egress Untagged"
            ]
        }
    ]
}

$bridge -c -json vlan show
{
    "swp1": [{
            "vlan": 1,
            "flags": ["PVID","Egress Untagged"
            ]
        },{
            "vlan": 10,
            "vlanEnd": 13
        }
    ],
    "swp2": [{
            "vlan": 1,
            "flags": ["PVID","Egress Untagged"
            ]
        },{
            "vlan": 10,
            "vlanEnd": 13
        }
    ],
    "br0": [{
            "vlan": 1,
            "flags": ["PVID","Egress Untagged"
            ]
        }
    ]
}

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agojson_writer: Removed automatic json-object type from the constructor
Anuradha Karuppiah [Wed, 22 Jun 2016 13:45:51 +0000 (06:45 -0700)]
json_writer: Removed automatic json-object type from the constructor

Top level can be any json type and can be created using
jsonw_start_object/jsonw_end_object etc.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
7 years agoss: Add option to suppress header line
David Ahern [Fri, 15 Jul 2016 22:45:39 +0000 (15:45 -0700)]
ss: Add option to suppress header line

Add option to suppress header line. When used the following line
is not shown:
"State  Recv-Q Send-Q     Local Address:Port  Peer Address:Port"

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoss: Fix support for device filter by index
David Ahern [Fri, 15 Jul 2016 22:41:35 +0000 (15:41 -0700)]
ss: Fix support for device filter by index

Support was recently added for device filters. The intent was to allow
the device to be specified by name or index, and using the if%u format
(dev == if5) or the simpler and more intuitive index alone (dev == 5).
The latter case is broken since the index is not saved to the filter
after the strtoul conversion. Further, the tmp variable used for the
conversion shadows another variable used in the function. Fix both.

With this change all 3 variants work as expected:
$ ss -t 'dev == 62'
State   Recv-Q Send-Q         Local Address:Port    Peer Address:Port
ESTAB       0      224         10.0.1.3%mgmt:ssh   192.168.0.50:58442

$ ss -t 'dev == mgmt'
State   Recv-Q Send-Q         Local Address:Port    Peer Address:Port
ESTAB       0      224         10.0.1.3%mgmt:ssh   192.168.0.50:58442

$ ss -t 'dev == if62'
State   Recv-Q Send-Q         Local Address:Port    Peer Address:Port
ESTAB       0      36          10.0.1.3%mgmt:ssh   192.168.0.50:58442

Fixes: 2d2932125616 ("ss: Add support to filter on device")
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agobpf: also check elf for official e_machine value
Daniel Borkmann [Mon, 18 Jul 2016 23:09:52 +0000 (01:09 +0200)]
bpf: also check elf for official e_machine value

Use the official BPF ELF e_machine value that was assigned recently [1]
and will be propagated to glibc, libelf et al. LLVM will switch to it
in 3.9 release, therefore we need to prepare tc to check for EM_ELF as
well, older version still have the EM_NONE.

  [1] https://github.com/llvm-mirror/llvm/commit/36b9c09330bfb5e771914cfe307588f30d5510d2

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
7 years agoman: Point to 'devlink-sb' from 'devlink' man page
Ido Schimmel [Wed, 13 Jul 2016 06:53:54 +0000 (09:53 +0300)]
man: Point to 'devlink-sb' from 'devlink' man page

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
7 years agoman: Add devlink man pages to Makefile
Ido Schimmel [Wed, 13 Jul 2016 06:53:53 +0000 (09:53 +0300)]
man: Add devlink man pages to Makefile

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
7 years agoiproute: constify rtattr_cmp
Stephen Hemminger [Fri, 15 Jul 2016 18:34:45 +0000 (11:34 -0700)]
iproute: constify rtattr_cmp

7 years agoip route: restore route entries in correct order
Xin Long [Tue, 12 Jul 2016 13:37:58 +0000 (21:37 +0800)]
ip route: restore route entries in correct order

Sometimes we cannot restore route entries, because in kernel
  [1] fib_check_nh()
  [2] fib_valid_prefsrc()
cause some routes to depend on existence of others while adding.

For example, we saved all the routes, and flushed all tables
  [a] default via 192.168.122.1 dev eth0
  [b] 192.168.122.0/24 dev eth0 src 192.168.122.21
  [c] broadcast 127.0.0.0 dev lo table local src 127.0.0.1
  [d] local 127.0.0.0/8 dev lo table local  src 127.0.0.1
  [e] local 127.0.0.1 dev lo table local src 127.0.0.1
  [f] broadcast 127.255.255.255 dev lo table local src 127.0.0.1
  [g] broadcast 192.168.122.0 dev eth0 table local src 192.168.122.21
  [h] local 192.168.122.21 dev eth0 table local src 192.168.122.21
  [i] broadcast 192.168.122.255 dev eth0 table local src 192.168.122.21

  Now start to restore them:
    If we want to add [a], we have to add [b] first, as [1] and
    'via 192.168.122.1' in [a].
    If we want to add [b], we have to add [h] first, as [2] and
    'src 192.168.122.21' in [b].

  So the correct order to restore should be like:
    [e][h] -> [b][c][d][f][g][i] -> [a]

This patch fixes it by traversing the file 3 times, it only restores
part of them in each run according to the following conditions, to
make sure every entry can be restored successfully.
  1. !gw && (!fib_prefsrc || fib_prefsrc == cfg->fc_dst)
  2. !gw && (fib_prefsrc != cfg->fc_dst)
  3. gw

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Phil Sutter <phil@nwl.cc>
7 years agoip: link style cleanup
Stephen Hemminger [Fri, 15 Jul 2016 18:31:20 +0000 (11:31 -0700)]
ip: link style cleanup

break long lines and other trivial changes

7 years agoAdd support for configuring Infiniband GUIDs
Eli Cohen [Thu, 7 Jul 2016 21:09:03 +0000 (16:09 -0500)]
Add support for configuring Infiniband GUIDs

Add two NLA's that allow configuration of Infiniband node or port GUIDs
by referencing the IPoIB net device set over the physical function. The
format to be used is as follows:

ip link set dev ib0 vf 0 node_guid 00:02:c9:03:00:21:6e:70
ip link set dev ib0 vf 0 port_guid 00:02:c9:03:00:21:6e:78

Signed-off-by: Eli Cohen <eli@mellanox.com>
7 years agoip route: Add support for vrf keyword
David Ahern [Wed, 29 Jun 2016 18:27:02 +0000 (11:27 -0700)]
ip route: Add support for vrf keyword

Add vrf keyword to 'ip route' commands. Allows:
1. Users can list routes by VRF name:
       $ ip route show vrf NAME

   VRF tables have all routes including local and broadcast routes.
   The VRF keyword filters LOCAL and BROADCAST routes; to see all
   routes the table option can be used. Or to see local routes only
   for a VRF:
       $ ip route show vrf NAME type local

2. Add or delete a route for a VRF:
       $ ip route {add|delete} vrf NAME <route spec>

3. Do a route lookup for a VRF:
       $ ip route get vrf NAME ADDRESS

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoip vrf: Add ipvrf_get_table
David Ahern [Wed, 29 Jun 2016 18:27:01 +0000 (11:27 -0700)]
ip vrf: Add ipvrf_get_table

Add ipvrf_get_table to lookup table id for device name. Returns 0
on any error or if name is not a VRF device.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoip route: Change type mask to bitmask
David Ahern [Wed, 29 Jun 2016 18:27:00 +0000 (11:27 -0700)]
ip route: Change type mask to bitmask

Allow option to select multiple route types to show or exlude
specific route types.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoip neigh: Add support for keyword
David Ahern [Wed, 29 Jun 2016 18:26:59 +0000 (11:26 -0700)]
ip neigh: Add support for keyword

Add vrf keyword to 'ip neigh' commands. Allows listing neighbor
entries for all links associated with a given VRF.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoip link/addr: Add support for vrf keyword
David Ahern [Wed, 29 Jun 2016 18:26:58 +0000 (11:26 -0700)]
ip link/addr: Add support for vrf keyword

Add vrf keyword to 'ip link' and 'ip addr' commands (common list code).

Allows:
1. Adding a link to a VRF
       $ ip link set NAME vrf NAME

   Removing a link from a VRF still uses 'ip link set NAME nomaster'

2. Showing links associated with a VRF:
       $ ip link show vrf NAME

3. List addresses associated with links in a VRF
       $ ip -br addr show vrf red

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoip vrf: Add name_is_vrf
David Ahern [Wed, 29 Jun 2016 18:26:57 +0000 (11:26 -0700)]
ip vrf: Add name_is_vrf

Add name_is_vrf function to determine if given name corresponds to a
VRF device.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agotc: flower: Add skip_{hw|sw} support
Amir Vadai [Mon, 4 Jul 2016 07:34:11 +0000 (10:34 +0300)]
tc: flower: Add skip_{hw|sw} support

On devices that support TC flower offloads, these flags enable a filter to be
added only to HW or only to SW. skip_sw and skip_hw are mutually exclusive
flags. By default without any flags, the filter is added to both HW and SW,
but no error checks are done in case of failure to add to HW.
With skip-sw, failure to add to HW is treated as an error.

Here is a sample script that adds 2 filters, one with skip_sw and the other
with skip_hw flag.

   # add ingress qdisc
   tc qdisc add dev enp0s9 ingress

   # enable hw tc offload.
   ethtool -K enp0s9 hw-tc-offload on

   # add a flower filter with skip-sw flag.
   tc filter add dev enp0s9 protocol ip parent ffff: flower \
   ip_proto 1 indev enp0s9 skip_sw \
   action drop

   # add a flower filter with skip-hw flag.
   tc filter add dev enp0s9 protocol ip parent ffff: flower \
   ip_proto 3 indev enp0s9 skip_hw \
   action drop

Signed-off-by: Amir Vadai <amirva@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
7 years agoip-address: constify match_link_kind arg
Phil Sutter [Thu, 30 Jun 2016 14:47:02 +0000 (16:47 +0200)]
ip-address: constify match_link_kind arg

Since the function won't ever change the data 'kind' is pointing at, it
can sanely be made const.

Fixes: e0513807f6dbb ("ip-address: Support filtering by slave type, too")
Suggested-by: Stephen Hemminger <shemming@brocade.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agoiproute2: unmangle netdev/my emails in man pages (hfsc, stab)
Michal Soltys [Sat, 2 Jul 2016 11:03:12 +0000 (13:03 +0200)]
iproute2: unmangle netdev/my emails in man pages (hfsc, stab)

No other man pages do so, hiding netdev is kind of silly and I don't
mind having my own address normally visible.

7 years agoman: rtacct: add missing TP marker
Masatake YAMATO [Tue, 5 Jul 2016 09:08:50 +0000 (18:08 +0900)]
man: rtacct: add missing TP marker

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agobridge: man: fix STP LISTENING description
Vivien Didelot [Wed, 29 Jun 2016 19:26:29 +0000 (15:26 -0400)]
bridge: man: fix STP LISTENING description

Correct the unclear and poorly conjugated STP LISTENING documentation.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
7 years agobridge: man: fix BPUD typo
Vivien Didelot [Wed, 29 Jun 2016 19:26:10 +0000 (15:26 -0400)]
bridge: man: fix BPUD typo

s/BPUD/BPDU/ in guard description.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
7 years agoip route: timeout for routes has to be set in seconds
Andrew Vagin [Tue, 28 Jun 2016 23:27:14 +0000 (02:27 +0300)]
ip route: timeout for routes has to be set in seconds

Currently a timeout is multiplied by HZ in user-space and
then it multiplied by HZ in kernel-space.

$ ./ip/ip r add 2002::0/64 dev veth1 expires 10
$ ./ip/ip -6 r
2002::/64 dev veth1  metric 1024 linkdown  expires 996sec pref medium

Cc: Xin Long <lucien.xin@gmail.com>
Cc: Hangbin Liu <liuhangbin@gmail.com>
Cc: Stephen Hemminger <shemming@brocade.com>
Fixes: 68eede250500 ("route: allow routes to be configured with expire values")
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
7 years agoip-address: Align type list in help and man page
Phil Sutter [Tue, 28 Jun 2016 13:07:17 +0000 (15:07 +0200)]
ip-address: Align type list in help and man page

This adds missing entries on both sides until they are identical.

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agoip-address: Support filtering by slave type, too
Phil Sutter [Tue, 28 Jun 2016 13:07:16 +0000 (15:07 +0200)]
ip-address: Support filtering by slave type, too

This patch allows to query all interfaces enslaved to a bridge or bond
using the following syntax:

| ip addr show type bridge_slave

Filtering has to be done in userspace since the kernel does not support
filtering on IFLA_INFO_SLAVE_KIND.

Functionality introduced in this patch is not fully complete since it
does not allow to match on type and slave type at the same time, but it
doesn't prevent implementing a dedicated slave_type match, either.

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agoUse ARRAY_SIZE macro everywhere
Phil Sutter [Tue, 28 Jun 2016 16:42:15 +0000 (18:42 +0200)]
Use ARRAY_SIZE macro everywhere

This patch was generated by the following semantic patch (a trimmed down
version of what is shipped with Linux sources):

@@
type T;
T[] E;
@@
(
- (sizeof(E)/sizeof(*E))
+ ARRAY_SIZE(E)
|
- (sizeof(E)/sizeof(E[...]))
+ ARRAY_SIZE(E)
|
- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
)

The only manual adjustment was to include utils.h in misc/nstat.c to make
the macro known there.

Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agoss: Add support to filter on device
David Ahern [Mon, 27 Jun 2016 18:34:25 +0000 (11:34 -0700)]
ss: Add support to filter on device

Add support for device names in the filter. Example:

    root@kenny:~# ss -t  'sport == :22 && dev == red'
    State      Recv-Q Send-Q     Local Address:Port      Peer Address:Port
    ESTAB      0      0          10.100.1.2%red:ssh      10.100.1.254:47814
    ESTAB      0      0           2100:1::2%red:ssh        2100:1::64:49406

Since kernel does not support iface in the filter specifying a
device name means all filtering is done in userspace.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoss: Allow ssfilter_bytecompile to return 0
David Ahern [Mon, 27 Jun 2016 18:34:24 +0000 (11:34 -0700)]
ss: Allow ssfilter_bytecompile to return 0

Allow ssfilter_bytecompile to return 0 for filter ops the kernel
does not support. If such an op is in the filter string then all
filtering is done in userspace.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoss: Refactor inet_show_sock
David Ahern [Mon, 27 Jun 2016 18:34:23 +0000 (11:34 -0700)]
ss: Refactor inet_show_sock

Extract parsing of sockstat and filter from inet_show_sock.
While moving run_ssfilter into callers of inet_show_sock enable
userspace filtering before the kill.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agoip/tcp_metrics: Simplify process_msg a bit
Jakub Sitnicki [Wed, 22 Jun 2016 11:34:13 +0000 (13:34 +0200)]
ip/tcp_metrics: Simplify process_msg a bit

On Tue, Jun 21, 2016 at 06:18 PM CEST, Phil Sutter <phil@nwl.cc> wrote:
> By combining the attribute extraction and check for existence, the
> additional indentation level in the 'else' clause can be avoided.
>
> In addition to that, common actions for 'daddr' are combined since the
> function returns if neither of the branches are taken.
>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
>  ip/tcp_metrics.c | 45 ++++++++++++++++++---------------------------
>  1 file changed, 18 insertions(+), 27 deletions(-)
>
> diff --git a/ip/tcp_metrics.c b/ip/tcp_metrics.c
> index f82604f458ada..899830c127bcb 100644
> --- a/ip/tcp_metrics.c
> +++ b/ip/tcp_metrics.c
> @@ -112,47 +112,38 @@ static int process_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
>   parse_rtattr(attrs, TCP_METRICS_ATTR_MAX, (void *) ghdr + GENL_HDRLEN,
>        len);
>
> - a = attrs[TCP_METRICS_ATTR_ADDR_IPV4];
> - if (a) {
> + if ((a = attrs[TCP_METRICS_ATTR_ADDR_IPV4])) {

Copy the pointer inside the branch?

Same gain on indentation while keeping checkpatch happy.

I only compile-tested the patch below.

Thanks,
Jakub

7 years agoman: ip-link: Add vrf type
David Ahern [Tue, 21 Jun 2016 23:29:01 +0000 (16:29 -0700)]
man: ip-link: Add vrf type

Add description for vrf type to ip-link man page.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
7 years agobridge: man: fix "brige" typo
Vivien Didelot [Tue, 21 Jun 2016 19:28:50 +0000 (15:28 -0400)]
bridge: man: fix "brige" typo

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
7 years agobridge: vlan: fix a few "fdb" typos in vlan doc
Vivien Didelot [Tue, 21 Jun 2016 19:28:26 +0000 (15:28 -0400)]
bridge: vlan: fix a few "fdb" typos in vlan doc

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
7 years agoFix MAC address length check
Phil Sutter [Wed, 22 Jun 2016 10:05:38 +0000 (12:05 +0200)]
Fix MAC address length check

I forgot to change the variable in the conditional, too.

Fixes: 8fe58d58941f4 ("iplink: Check address length via netlink")
Signed-off-by: Phil Sutter <phil@nwl.cc>
7 years agoman: ip-address, ip-link: Document 'type' quirk
Phil Sutter [Fri, 24 Jun 2016 10:14:23 +0000 (12:14 +0200)]
man: ip-address, ip-link: Document 'type' quirk

This covers the fact that calling 'ip {link|addr} show type foobar' does
not return an error.

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agoif: add missing kernel headers
Stephen Hemminger [Tue, 21 Jun 2016 18:24:52 +0000 (11:24 -0700)]
if: add missing kernel headers

Add kernel headers for all headers that included by current source.

8 years agoiplink: Check address length via netlink
Phil Sutter [Thu, 16 Jun 2016 14:19:40 +0000 (16:19 +0200)]
iplink: Check address length via netlink

This is a feature which was lost during the conversion to netlink
interface: If the device exists and a user tries to change the link
layer address, query the kernel for the old address first and reject the
new one if sizes differ.

This patch adds the same check when setting VF address by assuming same
length as PF device.

Note that at least for VFs the check can't be done in kernel space since
struct ifla_vf_mac lacks a length field and due to netlink padding the
exact size can't be communicated to the kernel.

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agoiplink: Add missing variable initialization
Phil Sutter [Thu, 16 Jun 2016 14:19:39 +0000 (16:19 +0200)]
iplink: Add missing variable initialization

Without this, we might feed garbage to the kernel when the address is
shorter than expected.

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agoss: Add tcp_info fields data_segs_in/out
Martin KaFai Lau [Sat, 18 Jun 2016 00:38:53 +0000 (17:38 -0700)]
ss: Add tcp_info fields data_segs_in/out

tcp_info fields, data_segs_in and data_segs_out, have been added to the
kernel in commit a44d6eacdaf5 ("tcp: Add RFC4898 tcpEStatsPerfDataSegsOut/In")
since kernel 4.6.

This patch supports those fileds in ss:

ESTAB      801736 360                            face:face:face:face::1:22                                      face:face:face:face::face:46779
         cubic wscale:9,7 rto:223 rtt:22.195/8.202 ato:40 mss:1428 cwnd:11 ssthresh:7 bytes_acked:203649 bytes_received:334034603 segs_out:18513 segs_in:241825 data_segs_out:4192 data_segs_in:241672 send 5.7Mbps lastsnd:2 lastack:3 pacing_rate 6.8Mbps unacked:10 retrans:0/1 rcv_rtt:29.375 rcv_space:1241704 minrtt:0.013

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
8 years agotc: m_action: Drop unused variable nladdr in tc_action_gd()
Phil Sutter [Wed, 15 Jun 2016 22:50:39 +0000 (00:50 +0200)]
tc: m_action: Drop unused variable nladdr in tc_action_gd()

This has been there since the introduction of tc/m_action.c back in 2004
and was apparently never in use.

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc: m_action: Use C99 style initializers for struct req
Phil Sutter [Wed, 15 Jun 2016 22:50:38 +0000 (00:50 +0200)]
tc: m_action: Use C99 style initializers for struct req

Instead of initializing fields after (or sometimes even before) zeroing
the whole struct via memset(), initialize the whole thing at declaration
time.

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc: let m_ipt work with new iptables API headers
Alexander Aring [Sun, 29 May 2016 18:27:13 +0000 (20:27 +0200)]
tc: let m_ipt work with new iptables API headers

Since commit 5cd1adb ("Update to current iptables headers") the build
with m_ipt.o and the following config will fail:

TC_CONFIG_XT:=n
TC_CONFIG_XT_OLD:=n
TC_CONFIG_XT_OLD_H:=n

This patch renames "iptables_target" to "xtables_target" and some other
things which gets renamed and I noticed while reading iptables git log.
Functions which are not used in m_ipt.c and not exported by the header
are removed, if they still used in m_ipt.c I added a static to the function.

Reported-by: Clemens Gruber <clemens.gruber@pqgruber.com>
Signed-off-by: Alexander Aring <aar@pengutronix.de>
8 years agom_xt: whitespace cleanup
Stephen Hemminger [Tue, 14 Jun 2016 21:40:53 +0000 (14:40 -0700)]
m_xt: whitespace cleanup

Make it 99% checkpatch clean.

8 years agotc: m_xt: Introduce get_xtables_target_opts()
Phil Sutter [Fri, 10 Jun 2016 11:42:08 +0000 (13:42 +0200)]
tc: m_xt: Introduce get_xtables_target_opts()

This pulls common code from parse_ipt() and print_ipt() functions
together.

While here, also fix for incorrect use of the global 'optarg' variable
in print_ipt().

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc: m_xt: Simplify argc adjusting in parse_ipt()
Phil Sutter [Fri, 10 Jun 2016 11:42:07 +0000 (13:42 +0200)]
tc: m_xt: Simplify argc adjusting in parse_ipt()

And while at it, also improve the error message in case too few
parameters have been given.

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc: m_xt: Get rid of iargc variable in parse_ipt()
Phil Sutter [Fri, 10 Jun 2016 11:42:06 +0000 (13:42 +0200)]
tc: m_xt: Get rid of iargc variable in parse_ipt()

After dropping the unused decrement of argc in the function's tail, it
can fully take over what iargc has been used for.

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc: m_xt: Get rid of rargc in parse_ipt()
Phil Sutter [Fri, 10 Jun 2016 11:42:05 +0000 (13:42 +0200)]
tc: m_xt: Get rid of rargc in parse_ipt()

No need to copy the passed parameter, it's changed only once right
before function return.

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc: m_xt: Drop unused variable fw in parse_ipt()
Phil Sutter [Fri, 10 Jun 2016 11:42:04 +0000 (13:42 +0200)]
tc: m_xt: Drop unused variable fw in parse_ipt()

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc: m_xt: Get rid of one indentation level in parse_ipt()
Phil Sutter [Fri, 10 Jun 2016 11:42:03 +0000 (13:42 +0200)]
tc: m_xt: Get rid of one indentation level in parse_ipt()

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc: m_xt: Fix indenting
Phil Sutter [Fri, 10 Jun 2016 11:42:02 +0000 (13:42 +0200)]
tc: m_xt: Fix indenting

By exiting early if xtables_find_target() fails, one indenting level can
be dropped. Some of the wrongly indented code then happens to sit at the
right spot by accident which is why this patch is smaller than expected.

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc: m_xt: Fix segfault when adding multiple actions at once
Phil Sutter [Fri, 10 Jun 2016 11:42:01 +0000 (13:42 +0200)]
tc: m_xt: Fix segfault when adding multiple actions at once

Without this, the following call to tc would segfault:

| tc filter add dev d0 parent ffff: u32 match u32 0 0 \
|  action xt -j MARK --set-mark 0x1 \
|  action xt -j MARK --set-mark 0x1

The reason is basically the same as for 6e2e5ec28bad4 ("fix print_ipt:
segfault if more then one filter with action -j MARK.") but in
parse_ipt() instead of print_ipt().

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc: m_xt: Prevent segfault with standard targets
Phil Sutter [Fri, 10 Jun 2016 11:42:00 +0000 (13:42 +0200)]
tc: m_xt: Prevent segfault with standard targets

Iptables standard targets like DROP or REJECT don't implement the print
callback in libxtables. Hence the following command would segfault:

| tc filter add dev d0 parent ffff: u32 match u32 0 0 action xt -j DROP

With this patch standard targets still can't be used (and are not really
useful anyway), but at least it doesn't crash anymore.

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agopedit: fix whitespace etc
Stephen Hemminger [Tue, 14 Jun 2016 21:31:37 +0000 (14:31 -0700)]
pedit: fix whitespace etc

Minor changes from checkpatch

8 years agoaction pedit: stylistic changes
Jamal Hadi Salim [Sun, 12 Jun 2016 21:40:34 +0000 (17:40 -0400)]
action pedit: stylistic changes

More modern layout.

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
8 years agoman: ip-link: Document query_rss option
Phil Sutter [Fri, 10 Jun 2016 14:39:50 +0000 (16:39 +0200)]
man: ip-link: Document query_rss option

Doc text shamelessly stolen from the introducing commit's message
(6c55c8c4617c5 ['ip link set vf: Added "query_rss" command']).

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agoutils: fix hex digits parsing in hexstring_a2n()
Beniamino Galvani [Tue, 14 Jun 2016 20:55:17 +0000 (22:55 +0200)]
utils: fix hex digits parsing in hexstring_a2n()

strtoul() only modifies errno on overflow, so if errno is not zero
before calling the function its value is preserved and makes the
function fail for valid inputs; initialize it.

Signed-off-by: Beniamino Galvani <bgalvani@redhat.com>
8 years agoipaddress: Allow listing addresses by type
Phil Sutter [Thu, 9 Jun 2016 17:20:36 +0000 (19:20 +0200)]
ipaddress: Allow listing addresses by type

Not sure why this was limited to ip-link before. It is semantically
equal to the 'master' keyword, which is not restricted at all.

The man page and help text adjustments include the 'master' keyword as
well since that is also supported but wasn't documented before.

Cc: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc: f_u32 cleanup indentation and long lines
Stephen Hemminger [Wed, 8 Jun 2016 23:45:26 +0000 (16:45 -0700)]
tc: f_u32 cleanup indentation and long lines

Several long lines and too long messages here.

8 years agotc: f_u32: Add support for skip_hw and skip_sw flags
Samudrala, Sridhar [Wed, 8 Jun 2016 23:16:01 +0000 (16:16 -0700)]
tc: f_u32: Add support for skip_hw and skip_sw flags

On devices that support TC U32 offloads, these flags enable a filter to be
added only to HW or only to SW. skip_sw and skip_hw are mutually exclusive
flags. By default without any flags, the filter is added to both HW and SW,
but no error checks are done in case of failure to add to HW.
With skip-sw, failure to add to HW is treated as an error.

Here is a sample script that adds 2 filters, one with skip_sw and the other
with skip_hw flag.

   # add ingress qdisc
   tc qdisc add dev p4p1 ingress

   # enable hw tc offload.
   ethtool -K p4p1 hw-tc-offload on

   # add u32 filter with skip-sw flag.
   tc filter add dev p4p1 parent ffff: protocol ip prio 99 \
      handle 800:0:1 u32 ht 800: flowid 800:1 \
      skip-sw \
      match ip src 192.168.1.0/24 \
      action drop

   # add u32 filter with skip-hw flag.
   tc filter add dev p4p1 parent ffff: protocol ip prio 99 \
      handle 800:0:2 u32 ht 800: flowid 800:2 \
      skip-hw \
      match ip src 192.168.2.0/24 \
      action drop

Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
8 years agoip: add MACsec support
Sabrina Dubroca [Wed, 8 Jun 2016 16:34:21 +0000 (09:34 -0700)]
ip: add MACsec support

Extend ip-link to create MACsec devices

  ip link add link <master> <macsec> type macsec [options]

Add `ip macsec` command to configure receive-side secure channels and
secure associations within a macsec netdevice.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Phil Sutter <phil@nwl.cc>
8 years agoutils: provide get_hex to read a hex digit from a char
Sabrina Dubroca [Fri, 3 Jun 2016 14:45:47 +0000 (16:45 +0200)]
utils: provide get_hex to read a hex digit from a char

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Phil Sutter <phil@nwl.cc>
8 years agoutils: add get_be{16, 32, 64}, use them where possible
Sabrina Dubroca [Fri, 3 Jun 2016 14:45:46 +0000 (16:45 +0200)]
utils: add get_be{16, 32, 64}, use them where possible

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Phil Sutter <phil@nwl.cc>
8 years agoutils: make hexstring_a2n provide the number of hex digits parsed
Sabrina Dubroca [Fri, 3 Jun 2016 14:45:45 +0000 (16:45 +0200)]
utils: make hexstring_a2n provide the number of hex digits parsed

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Phil Sutter <phil@nwl.cc>
8 years agoip: minor checkpatch cleanup
Stephen Hemminger [Wed, 8 Jun 2016 16:15:52 +0000 (09:15 -0700)]
ip: minor checkpatch cleanup

8 years agofq_codel: add per queue memory limit
Eric Dumazet [Wed, 8 Jun 2016 15:42:00 +0000 (08:42 -0700)]
fq_codel: add per queue memory limit

This patch adds support for TCA_FQ_CODEL_MEMORY_LIMIT attribute.

..
qdisc fq_codel 8008: root refcnt 257 limit 10240p flows 1024
 quantum 1514 target 5.0ms interval 100.0ms memory_limit 4Mb ecn
 Sent 2083566791363 bytes 1376214889 pkt (dropped 4994406, overlimits 0
requeues 21705223)
 rate 9841Mbit 812549pps backlog 3906120b 376p requeues 21705223
  maxpacket 68130 drop_overlimit 4994406 new_flow_count 28855414
  ecn_mark 0 memory_used 4190048 drop_overmemory 4994406
new_flows_len 1 old_flows_len 177

Signed-off-by: Eric Dumazet <edumazet@google.com>
8 years agoman: tc-ife.8: man page for ife action
Lucas Bates [Sun, 5 Jun 2016 13:17:15 +0000 (09:17 -0400)]
man: tc-ife.8: man page for ife action

Signed-off-by: Lucas Bates <lucasb@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Acked-by: Phil Sutter <phil@nwl.cc>
8 years agoman: rtpr: Fix minor typo
Phil Sutter [Wed, 1 Jun 2016 19:58:21 +0000 (21:58 +0200)]
man: rtpr: Fix minor typo

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agomisc/ss: Add family list to -f option in _usage()
Fabien Siron [Mon, 6 Jun 2016 14:53:38 +0000 (14:53 +0000)]
misc/ss: Add family list to -f option in _usage()

Signed-off-by: Fabien Siron <fabien.siron@epita.fr>
8 years agoman: ip-link: Added HSR part
Peter Heise [Wed, 1 Jun 2016 07:43:15 +0000 (09:43 +0200)]
man: ip-link: Added HSR part

Added HSR part to manpage as follow-up to last commit's
feedback.

Signed-off-by: Peter Heise <peter.heise@airbus.com>
8 years agotc action policer: enable timestamp display
Jamal Hadi Salim [Wed, 25 May 2016 10:05:49 +0000 (06:05 -0400)]
tc action policer: enable timestamp display

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
8 years agotc: update headers for TCA_POLICE
Stephen Hemminger [Tue, 31 May 2016 20:02:28 +0000 (13:02 -0700)]
tc: update headers for TCA_POLICE

These are from linux-net but will be in next rc.

8 years agoman: ip, ip-link: Fix ip option location
Phil Sutter [Mon, 30 May 2016 18:46:27 +0000 (20:46 +0200)]
man: ip, ip-link: Fix ip option location

This patch drops the redundant description of some of ip's options in
ip-link.8's description of the 'show' subcommand, preserving the
description of -iec (but appending it to the list in ip.8 with minor
fixes).

Signed-off-by: Phil Sutter <phil@nwl.cc>
8 years agotc filter u32: Coding style fixes
Jamal Hadi Salim [Wed, 25 May 2016 10:11:55 +0000 (06:11 -0400)]
tc filter u32: Coding style fixes

"handle" was being used several times for different things.
Fix the 80 character limit abuse and other little issues while at it.

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
8 years agotc: action result is u32
Stephen Hemminger [Tue, 31 May 2016 19:22:45 +0000 (12:22 -0700)]
tc: action result is u32

In kernel action result is u32 not int in netlink messages.