Commit Graph

917 Commits

Author SHA1 Message Date
David Ahern
9860becfe3 libnetlink: Add helper to add a group via setsockopt
groups > 31 have to be joined using the setsockopt. Since the nexthop
group is 32, add a helper to allow 'ip monitor' to listen for nexthop
messages.

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-06-11 10:30:48 -07:00
Matteo Croce
80a931d41c ip: reset netns after each command in batch mode
When creating a new netns or executing a program into an existing one,
the unshare() or setns() calls will change the current netns.
In batch mode, this can run commands on the wrong interfaces, as the
ifindex value is meaningful only in the current netns. For example, this
command fails because veth-c doesn't exists in the init netns:

    # ip -b - <<-'EOF'
        netns add client
        link add name veth-c type veth peer veth-s netns client
        addr add 192.168.2.1/24 dev veth-c
    EOF
    Cannot find device "veth-c"
    Command failed -:7

But if there are two devices with the same name in the init and new netns,
ip will build a wrong ll_map with indexes belonging to the new netns,
and will execute actions in the init netns using this wrong mapping.
This script will flush all eth0 addresses and bring it down, as it has
the same ifindex of veth0 in the new netns:

    # ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
        inet 192.168.122.76/24 brd 192.168.122.255 scope global dynamic eth0
           valid_lft 3598sec preferred_lft 3598sec

    # ip -b - <<-'EOF'
        netns add client
        link add name veth0 type veth peer name veth1
        link add name veth-ns type veth peer name veth0 netns client
        link set veth0 down
        address flush veth0
    EOF

    # ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000
        link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    3: veth1@veth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN group default qlen 1000
        link/ether c2:db:d0:34:13:4a brd ff:ff:ff:ff:ff:ff
    4: veth0@veth1: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN group default qlen 1000
        link/ether ca:9d:6b:5f:5f:8f brd ff:ff:ff:ff:ff:ff
    5: veth-ns@if2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
        link/ether 32:ef:22:df:51:0a brd ff:ff:ff:ff:ff:ff link-netns client

The same issue can be triggered by the netns exec subcommand with a
sligthy different script:

    # ip netns add client
    # ip -b - <<-'EOF'
        netns exec client true
        link add name veth0 type veth peer name veth1
        link add name veth-ns type veth peer name veth0 netns client
        link set veth0 down
        address flush veth0
    EOF

Fix this by adding two netns_{save,reset} functions, which are used
to get a file descriptor for the init netns, and restore it after
each batch command.
netns_save() is called before the unshare() or setns(),
while netns_restore() is called after each command.

Fixes: 0dc34c7713 ("iproute2: Add processless network namespace support")
Reviewed-and-tested-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-06-10 10:42:14 -07:00
David Ahern
ed624243da uapi: Import tc_ctinfo uapi
Add tc_ctinfo.h uapi file from kernel.

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-06-10 10:23:32 -07:00
David Ahern
b2f8eb7f8a Update kernel headers
Update kernel headers to commit:
    ad3a9ee0b623 ("ocelot: remove unused variable 'rc' in vcap_cmd()")

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-06-10 09:39:08 -07:00
David Ahern
2761769472 Update kernel headers
Update kernel headers to commit:
    1167187f2759 ("Merge branch 'qed-Fix-inifinite-spinning-of-PTP-poll-thread'")

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-05-29 12:36:58 -07:00
Stephen Hemminger
1bb38f6c5e uapi: minor upstream btf.h header change
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-05-24 15:51:06 -07:00
Stephen Hemminger
b60ed9a372 uapi: merge bpf.h from 5.2
Upstream commit to fix spelling errors.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-05-15 09:53:07 -07:00
Stephen Hemminger
2f31cb4fd6 uapi: add sockios.h
Forgot to add this to earlier commit.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-05-15 09:51:15 -07:00
Stephen Hemminger
afa588490b uapi: update headers to import asm-generic/sockios.h
import asm-generic/sockios.h to fix the compile errors from the
movement of timestamp macros.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-05-13 14:56:15 -07:00
Stephen Hemminger
0812dc7025 uapi: add include/linux/net.h
All kernel headers must come from this repo,
and ss is including linux/net.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-05-13 14:54:26 -07:00
Stephen Hemminger
f9339f8a8f uapi: update to elf-em header
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-05-10 08:56:52 -07:00
Stephen Hemminger
f9e2cf35eb Merge ../iproute2-next 2019-05-10 08:55:11 -07:00
Stephen Hemminger
3eea00d777 v5.1.0 2019-05-10 08:45:14 -07:00
David Ahern
fd6580972b Update kernel headers
Update kernel headers to commit
   a734d1f4c2fc ("net: openvswitch: return an error instead of doing BUG_ON()")

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-05-04 09:13:26 -07:00
David Ahern
420b36a874 uapi: wrap SIOCGSTAMP and SIOCGSTAMPNS in ifndef
These warnings:
    ../include/uapi/linux/sockios.h:42:0: warning: "SIOCGSTAMP" redefined
    ../include/uapi/linux/sockios.h:43:0: warning: "SIOCGSTAMPNS" redefined

are from kernel commit 0768e17073dc5 ("net: socket: implement 64-bit
timestamps"). This commit moved the definitions of SIOCGSTAMP and
SIOCGSTAMPNS from include/asm-generic/sockios.h to
include/uapi/linux/sockios.h. Older OS'es already define them in
/usr/include/asm-generic/sockios.h resulting in ugly compile errors now:

In file included from ll_types.c:24:0:
../include/uapi/linux/sockios.h:42:0: warning: "SIOCGSTAMP" redefined
 #define SIOCGSTAMP SIOCGSTAMP_OLD

In file included from /usr/include/x86_64-linux-gnu/asm/sockios.h:1:0,
                 from /usr/include/asm-generic/socket.h:5,
                 from /usr/include/x86_64-linux-gnu/asm/socket.h:1,
                 from /usr/include/x86_64-linux-gnu/bits/socket.h:368,
                 from /usr/include/x86_64-linux-gnu/sys/socket.h:38,
                 from ll_types.c:17:
/usr/include/asm-generic/sockios.h:11:0: note: this is the location of the previous definition
 #define SIOCGSTAMP 0x8906  /* Get stamp (timeval) */

so wrap them in #ifndef.

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-05-03 08:23:08 -07:00
David Ahern
70de8a7fa7 Update kernel headers
Update kernel headers to commit
    148f025d41a8 ("Merge branch 'hns3-next'")

Note, these warnings:
../include/uapi/linux/sockios.h:42:0: warning: "SIOCGSTAMP" redefined
../include/uapi/linux/sockios.h:43:0: warning: "SIOCGSTAMPNS" redefined

are due to kernel commit
    0768e17073dc5 ("net: socket: implement 64-bit timestamps")

which moved the definitions from include/asm-generic/sockios.h
to include/uapi/linux/sockios.h

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-04-26 11:11:03 -07:00
David Ahern
188c7fe6ea Update kernel headers
Update kernel headers to commit
    6b0a7f84ea1f ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net")

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-04-17 14:07:48 -07:00
Stephen Hemminger
41fc3fa04c uapi: update bpf.h
Updated bpf.h from 5.1-rc

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-04-05 15:00:48 -07:00
David Ahern
cdeb2674aa Update kernel headers
Update kernel headers to
    fa7e428c6b7e ("openvswitch: add seqadj extension when NAT is used.")

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-03-26 16:08:05 -07:00
Stephen Hemminger
dd4a2b6833 uapi: bpf add set_ce
New api from upstream.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-03-19 10:37:55 -07:00
Stephen Hemminger
828132fdd1 uapi: in6.h add router alert isolate
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-03-19 10:37:28 -07:00
Stephen Hemminger
a7cd7baded uapi: add CAKE FWMARK
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-03-19 10:36:56 -07:00
Stephen Hemminger
50cf634899 Merge branch 'master' of ../iproute2-next 2019-03-19 10:32:45 -07:00
Stephen Hemminger
93d0d92f61 v5.0.0 2019-03-19 10:06:19 -07:00
David Ahern
41fda879a1 Update kernel headers
Update kernel headers to commit:
    ff8285f81822 ("net: sched: pie: fix 64-bit division")

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-02-27 08:23:22 -08:00
David Ahern
25c6339b22 ll_map: Add function to remove link cache entry by index
Add ll_drop_by_index to remove an entry from the link cache.

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-02-22 18:51:15 -08:00
David Ahern
9f78e995a8 Merge branch 'iproute2-master' into next
Conflicts:
	misc/ss.c

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-02-22 18:50:39 -08:00
Stephen Hemminger
6f618a6a82 uapi: update inet_diag_info.h
Upstream changes.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-02-21 14:24:07 -08:00
David Ahern
6b2d60bdfc Update kernel headers
Update kernel headers to commit:
bfbae2eafe05 ("Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue")

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-02-06 08:45:41 -08:00
Ido Schimmel
264be1d887 bridge: fdb: Fix FDB dump with strict checking disabled
While iproute2 correctly uses ifinfomsg struct as the ancillary header
when requesting an FDB dump on old kernels, it sets the message type to
RTM_GETLINK. This results in wrong reply being returned.

Fix this by using RTM_GETNEIGH instead.

Before:
$ bridge fdb show brport dummy0
Not RTM_NEWNEIGH: 00000158 00000010 00000002

After:
$ bridge fdb show brport dummy0
2a:0b:41:1c:92:d3 vlan 1 master br0 permanent
2a:0b:41:1c:92:d3 master br0 permanent
33:33:00:00:00:01 self permanent
01:00:5e:00:00:01 self permanent

Fixes: 05880354c2 ("bridge: fdb: Fix filtering with strict checking disabled")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reported-by: LiLiang <liali@redhat.com>
Acked-by: David Ahern <dsahern@gmail.com>
Acked-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-02-05 15:27:28 -08:00
Davide Caratti
52d57f6bbd tc: full JSON support for 'bpf' actions
Add full JSON output support in the dump of 'act_bpf'.

Example using eBPF:

 # tc actions flush action bpf
 # tc action add action bpf object bpf/action.o section 'action-ok'
 # tc -j action list action bpf | jq
 [
   {
     "total acts": 1
   },
   {
     "actions": [
       {
         "order": 0,
         "kind": "bpf",
         "bpf_name": "action.o:[action-ok]",
         "prog": {
           "id": 33,
           "tag": "a04f5eef06a7f555",
           "jited": 1
         },
         "control_action": {
           "type": "pipe"
         },
         "index": 1,
         "ref": 1,
         "bind": 0
       }
     ]
   }
 ]

Example using cBPF:

 # tc actions flush action bpf
 # a=$(mktemp)
 # tcpdump -ddd not ether proto 0x888e >$a
 # tc action add action bpf bytecode-file $a index 42
 # rm $a
 # tc -j action list action bpf | jq
 [
   {
     "total acts": 1
   },
   {
     "actions": [
       {
         "order": 0,
         "kind": "bpf",
         "bytecode": {
           "length": 4,
           "insns": [
             {
               "code": 40,
               "jt": 0,
               "jf": 0,
               "k": 12
             },
             {
               "code": 21,
               "jt": 0,
               "jf": 1,
               "k": 34958
             },
             {
               "code": 6,
               "jt": 0,
               "jf": 0,
               "k": 0
             },
             {
               "code": 6,
               "jt": 0,
               "jf": 0,
               "k": 262144
             }
           ]
         },
         "control_action": {
           "type": "pipe"
         },
         "index": 42,
         "ref": 1,
         "bind": 0
       }
     ]
   }
 ]

Tested with:
 # ./tdc.py -c bpf

Cc: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2019-02-03 09:10:10 -08:00
Björn Töpel
2abc3d76e3 ss: add AF_XDP support
AF_XDP is an address family that is optimized for high performance
packet processing.

This patch adds AF_XDP support to ss(8) so that sockets can be queried
and monitored.

Example:
$ sudo ss --xdp -e -p -m
Recv-Q      Send-Q           Local Address:Port             Peer Address:Port

0           0                   enp134s0f0:q20                          *
 users:(("xdpsock",pid=17787,fd=3)) ino:39424 sk:4
        rx(entries:2048)
        tx(entries:2048)
        umem(id:1,size:8388608,num_pages:2048,chunk_size:2048,headroom:0,ifindex:7,
qid:20,zc:0,refs:1)
        fr(entries:2048)
        cr(entries:2048) skmem:(r0,rb212992,t0,tb212992,f0,w0,o0,bl0,d0)
0           0                    enp24s0f0:q0                           *
 users:(("xdpsock",pid=17780,fd=3)) ino:37384 sk:5
        rx(entries:2048)
        tx(entries:2048)
        umem(id:0,size:8388608,num_pages:2048,chunk_size:2048,headroom:0,ifindex:6,
qid:0,zc:1,refs:1)
        fr(entries:2048)
        cr(entries:2048) skmem:(r0,rb212992,t0,tb212992,f0,w0,o0,bl0,d0)

Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2019-01-30 20:57:45 -08:00
David Ahern
f79b7733b4 Update kernel headers and add xdp_diag.h
Update kernel headers to commit:
c829f5f52db9 ("cxgb4: cxgb4_tc_u32: use struct_size() in kvzalloc()")

and import xdp_diag.h for the next patch.

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-01-29 18:34:40 -08:00
David Ahern
b45664e064 Merge 'iproute2-master' into iproute2-next
Signed-off-by: David Ahern <dsahern@gmail.com>
2019-01-22 08:30:38 -08:00
Stephen Hemminger
3bc2dc7668 uapi: in.h change
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-01-22 16:03:31 +13:00
David Ahern
dad02ef478 Update kernel headers
Update kernel headers to commit
28f9d1a3d4fe ("Merge branch 'mlxsw-spectrum_router-Add-GRE-tunnel-support-for-Spectrum-2'")

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-01-21 08:29:26 -08:00
Stephen Hemminger
e1ccc46bdd uapi: update headers from 4.21-rc1
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
2019-01-07 11:39:26 -08:00
Stephen Hemminger
724ec5aeb0 Merge ../iproute2-next 2019-01-07 11:36:41 -08:00
Stephen Hemminger
97864a5af3 v4.20.0 2019-01-07 10:24:02 -08:00
David Ahern
285033bfeb libnetlink: Add RTNL_HANDLE_F_STRICT_CHK flag
Add RTNL_HANDLE_F_STRICT_CHK flag and set in rth flags to let know
commands know if the kernel supports strict checking.

Extracted from patch from Ido to fix filtering with strict checking
enabled.

Cc: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2019-01-04 12:17:17 -08:00
David Ahern
f255ab1225 libnetlink: Add filter function to rtnl_neighdump_req
Add filter function to rtnl_neighdump_req and a buffer to the
request for the filter functions to append attributes.

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-01-04 12:17:11 -08:00
David Ahern
aea41afcfd ip bridge: Set NETLINK_GET_STRICT_CHK on socket
iproute2 has been updated for the new strict policy in the kernel. Add a
helper to call setsockopt to enable the feature. Add a call to ip.c and
bridge.c

The setsockopt fails on older kernels and the error can be safely ignored
- any new fields or attributes are ignored by the older kernel.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-12-27 15:36:29 -08:00
David Ahern
8847097850 ip address: Set device index in dump request
Add a filter function to rtnl_addrdump_req to set device index in the
address dump request if the user is filtering addresses by device. In
addition, add a new ipaddr_link_get to do a single RTM_GETLINK request
instead of a device dump yet still store the data in the linfo list.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-12-27 15:35:49 -08:00
David Ahern
43fd93ae46 ip route: Remove rtnl_rtcache_request
Add a filter option to rtnl_routedump_req and use it to set rtm_flags
removing the need for rtnl_rtcache_request for dump requests.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-12-27 15:33:34 -08:00
David Ahern
fdce94d0d1 Update kernel headers
Update kernel headers to commit
ce28bb445388 ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-12-22 07:36:52 -08:00
Stephen Hemminger
c579ec14a7 uapi/iptunnel: make TUNNEL_FLAGS available
ip l add dev tun type gretap external
ip r a 10.0.0.1 encap ip dst 192.168.152.171 id 1000 dev gretap

For gretap Key example when the command set the id but don't set the
TUNNEL_KEY flags. There is no key field in the send packet

In the lwtunnel situation, some TUNNEL_FLAGS should can be set by
userspace

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-12-20 09:19:33 -08:00
Stephen Hemminger
2db63d290b uapi/netlink.h: rename NETLINK_DUMP_STRICT_CHK -> NETLINK_GET_STRICT_CHK
NETLINK_DUMP_STRICT_CHK can be used for all GET requests,
dumps as well as doit handlers.  Replace the DUMP in the
name with GET make that clearer.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-12-20 09:18:29 -08:00
Stephen Hemminger
ef7f9fae2e uapi/in.h: Allow class-e address assignment
While most distributions long ago switched to the iproute2 suite
of utilities, which allow class-e (240.0.0.0/4) address assignment,
distributions relying on busybox, toybox and other forms of
ifconfig cannot assign class-e addresses without this kernel patch.

While CIDR has been obsolete for 2 decades, and a survey of all the
open source code in the world shows the IN_whatever macros are also
obsolete... rather than obsolete CIDR from this ioctl entirely, this
patch merely enables class-e assignment, sanely.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-12-20 09:17:05 -08:00
David Ahern
17689d3075 Update kernel headers
Update kernel headers to commit
   055722716c39 ("tipc: fix uninitialized value for broadcast retransmission")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-12-19 12:47:29 -08:00
David Ahern
6065ddfaa7 Merge branch 'iproute2-master' into iproute2-next
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-12-19 12:02:17 -08:00
Stephen Hemminger
738aebe52b drop support for DECnet
DECnet belongs in the history museum of dead protocols along
with Appletalk and IPX.

Linux support has outlived its natural life and the time has
come to remove it from iproute2. Dead code is a source
of bugs and exploits.

If anyone actually has DECnet running on some old distribution
they can just keep to the old version of iproute2.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-12-13 12:50:01 -08:00
Stephen Hemminger
3a1f602ade remove redundant long int
Using unsigned long is sufficient no need to be more
verbose and use unsigned long int.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-12-13 11:36:59 -08:00
Stephen Hemminger
028766aed2 uapi: update bpf header
Changes from 4.20-rc6

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-12-10 09:22:23 -08:00
Shalom Toledo
a463fd4fa4 devlink: Add support for 'fw_load_policy' generic parameter
Add string to uint conversion for 'fw_load_policy' generic parameter.

Signed-off-by: Shalom Toledo <shalomt@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-12-07 13:00:40 -08:00
Stephen Hemminger
ce5071eda6 drop support for IPX
IPX has been depracted then removed from upstream kernels.
Drop support from ip route as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-11-24 07:27:56 -08:00
Jakub Kicinski
b640e85d2d json: add %hhu helpers
Add helpers for printing char-size values.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-11-24 07:09:53 -08:00
David Ahern
0868c8ab07 Merge branch 'iproute2-master' into iproute2-next
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-11-24 07:06:11 -08:00
David Ahern
8d42678dfb Update kernel headers
Update kernel headers to
  b1a200484143 ("net-next/hinic: fix a bug in rx data flow")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-11-20 14:33:09 -08:00
Stephen Hemminger
babc56b68c tc: drop unused name_to_id function
Not used in current code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-11-19 11:42:44 -08:00
Stephen Hemminger
1d2fac4145 libnetlnk: unused and local functions cleanup
rntl_talk_extack and parse_rtattr_index not used in current code.
rtnl_dump_filter_l is only used in this file.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-11-19 11:42:44 -08:00
Stephen Hemminger
cc5b7e37ac lib/ll_map: make local function static
ll_idx_a2n is only used in ll_map.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-11-19 11:42:44 -08:00
Stephen Hemminger
f7bf88dfd5 lib/color: make local functions static
color_enable etc, only used here.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-11-19 11:42:44 -08:00
Stephen Hemminger
b8795a3208 lib/utils: make local functions static
Some of the print/parsing is only used internally.
Drop unused get_s8/get_s16.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-11-19 11:42:44 -08:00
Stefano Brivio
64dbd03ea1 iplink_geneve: Add DF configuration
Allow to set the DF bit behaviour for outgoing IPv4 packets: it can be
always on, inherited from the inner header, or, by default, always off,
which is the current behaviour.

v2:
- Indicate in the man page what DF refers to, using RFC 791 wording
  (David Ahern)

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-11-09 08:51:47 -08:00
Stefano Brivio
3d98eba4fe iplink_vxlan: Add DF configuration
Allow to set the DF bit behaviour for outgoing IPv4 packets: it can be
always on, inherited from the inner header, or, by default, always off,
which is the current behaviour.

v2:
- Indicate in the man page what DF refers to, using RFC 791 wording
  (David Ahern)

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-11-09 08:51:12 -08:00
Stephen Hemminger
9abb69f8a0 uapi: sctp header change
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-11-09 08:18:26 -08:00
Luca Boccassi
6d2fd4a53f Include bsd/string.h only in include/utils.h
This is simpler and cleaner, and avoids having to include the header
from every file where the functions are used. The prototypes of the
internal implementation are in this header, so utils.h will have to be
included anyway for those.

Fixes: 508f3c231e ("Use libbsd for strlcpy if available")

Signed-off-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-11-05 08:38:32 -08:00
Stephen Hemminger
39776a8665 uapi: update headers to 4.20-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-11-05 08:37:41 -08:00
Peter Korsgaard
f900a21611 utils.h: provide fallback CLOCK_TAI definition
q_{etf,taprio}.c uses CLOCK_TAI, which isn't exposed by glibc < 2.21 or
uClibc, breaking the build. Provide a fallback definition like it is done
for IPPROTO_MPLS and others.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-10-29 09:54:52 -07:00
David Ahern
6e221408e6 Merge branch 'iproute2-master' into iproute2-next
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-23 10:55:09 -07:00
Stephen Hemminger
2808241af5 v4.19.0 2018-10-23 10:14:57 -07:00
David Ahern
cd554f2c2f Tree wide: Drop sockaddr_nl arg
No function, filter, or print function uses the sockaddr_nl arg,
so just drop it.

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
2018-10-22 09:43:48 -07:00
David Ahern
9d16a1de1f Merge branch 'iproute2-master' into iproute2-next
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-22 09:43:33 -07:00
Lorenzo Bianconi
9e030e77f2 uapi: add snmp header file
Introduce snmp header file. It will be used in subsequent patch in
order to parse device statistics reported in
IFLA_INET6_STATS/IFLA_INET6_ICMP6STATS netlink attributes

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-10-15 09:37:42 -07:00
Sabrina Dubroca
45ec4771d4 json: make 0xhex handle u64
Stephen converted macsec's sci to use 0xhex, but 0xhex handles
unsigned int's, not 64 bits ints. Thus, the output of the "ip macsec
show" command is mangled, with half of the SCI replaced with 0s:

# ip macsec show
11: macsec0: [...]
    cipher suite: GCM-AES-128, using ICV length 16
    TXSC: 0000000001560001 on SA 0

# ip -d link show macsec0
11: macsec0@ens3: [...]
    link/ether 52:54:00:12:01:56 brd ff:ff:ff:ff:ff:ff promiscuity 0
    macsec sci 5254001201560001 [...]

where TXSC and sci should match.

Fixes: c0b904de62 ("macsec: support JSON")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-10-15 09:32:18 -07:00
Jesus Sanchez-Palencia
d791f3ad86 libnetlink: Add helper for getting a __s32 from netlink msgs
This function retrieves a signed 32-bit integer from a netlink message
and returns it.

Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-07 10:31:35 -07:00
Vinicius Costa Gomes
de63cd9044 include: Add helper to retrieve a __s64 from a netlink msg
This allows signed 64-bit integers to be retrieved from a netlink
message.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-07 10:30:30 -07:00
Vinicius Costa Gomes
a066bac8a2 utils: Implement get_s64()
Add this helper to read signed 64-bit integers from a string.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-07 10:30:28 -07:00
David Ahern
720a44a751 Update kernel headers
update kernel headers to commit:
72438f8cef4e ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-07 10:29:25 -07:00
David Ahern
56eeeda978 libnetlink: Rename rtnl_wilddump_stats_req_filter to rtnl_statsdump_req_filter
rtnl_wilddump_stats_req_filter only takes RTM_GETSTATS as the type argument
so rename to rtnl_statsdump_req_filter for consistency with other request
functions and hardcode the type argument.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-02 18:39:36 -07:00
David Ahern
31ae2912f7 libnetlink: Rename rtnl_wilddump_* to rtnl_linkdump_*
Rename rtnl_wilddump_req_filter to rtnl_linkdump_req_filter,
rtnl_wilddump_request to rtnl_linkdump_req and
rtnl_wilddump_req_filter_fn to rtnl_linkdump_req_filter_fn.

In all cases drop the type argument which at this point is only
RTM_GETLINK and hardcode in the functions.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-02 18:39:08 -07:00
David Ahern
efb0b383d9 libnetlink: Convert GETNSID dumps to use rtnl_nsiddump_req
Add rtnl_nsiddump_req for namespace id dumps using the proper rtgenmsg
as the header. Convert existing RTM_GETNSID dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-02 18:39:04 -07:00
David Ahern
ff41db8a75 libnetlink: Convert GETNEIGHTBL dumps to use rtnl_neightbldump_req
Add rtnl_neightbldump_req for neighbor table dumps using the proper ndtmsg
as the header. Convert existing RTM_GETNEIGHTBL dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-02 18:39:02 -07:00
David Ahern
9e0ab19c4d libnetlink: Convert GETNEIGH dumps to use rtnl_neighdump_req
Add rtnl_neighdump_req for neighbor dumps using the proper ndmsg
as the header. Convert existing rtnl_wilddump_request for RTM_GETNEIGH
to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-02 18:38:59 -07:00
David Ahern
b05d9a3d58 libnetlink: Convert GETRULE dumps to use rtnl_ruledump_req
Add rtnl_ruledump_req for fib fule dumps using the proper fib_rule_hdr
as the header. Convert existing RTM_GETRULE dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-02 18:38:56 -07:00
David Ahern
ddee16bc96 libnetlink: Convert GETNETCONF dumps to use rtnl_netconfdump_req
Add rtnl_netconfdump_req for netconf dumps using the proper netconfmsg
as the header. Convert existing RTM_GETNETCONF dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-02 18:38:34 -07:00
David Ahern
9dbe6df411 libnetlink: Convert GETMDB dumps to use rtnl_mdbdump_req
Add rtnl_mdbdump_req for mdb dumps using the proper br_port_msg as
the header. Convert existing RTM_GETMDB dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-02 18:38:31 -07:00
David Ahern
393600231a libnetlink: Convert GETADDRLABEL dumps to use rtnl_addrlbldump_req
Add rtnl_addrlbldump_req for address label dumps using the proper
ifaddrlblmsg as the header. Convert existing RTM_GETADDRALBEL dumps
to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-02 18:38:29 -07:00
David Ahern
bfb27dfaac libnetlink: Convert GETROUTE dumps to use rtnl_routedump_req
Add rtnl_routedump_req for route dumps using the proper rtmsg
as the header. Convert existing RTM_GETROUTE dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-02 18:38:27 -07:00
David Ahern
46917d0895 libnetlink: Convert GETADDR dumps to use rtnl_addrdump_req
Add rtnl_addrdump_req for address dumps using the proper ifaddrmsg
as the header. Convert existing RTM_GETADDR dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-10-02 18:38:21 -07:00
David Ahern
d9c0be4e97 Update kernel headers
Update kernel headers to commit
a804e5e218754 ("selftests: forwarding: test for bridge sticky flag")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-09-28 10:51:15 -07:00
David Ahern
34212c73b7 Merge branch 'iproute2-master' into iproute2-next
Conflicts:
	ip/iproute_lwtunnel.c

In addition to merge conflict between bd59e5b151 and 94a8722f2f,
updated the code added by the latter commit based on the change of the
former (ie., added ret = to the new rta_addattr_l).

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-09-20 17:53:27 -07:00
Stephen Hemminger
b85076cd74 lib: introduce print_nl
Common pattern in iproute commands is to print a line seperator
in non-json mode. Make that a simple function.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-09-11 08:29:33 -07:00
Stephen Hemminger
ae775666cf genl: remove unnecessary extern
extern not necessary on function prototype.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-09-10 11:53:07 -07:00
Dave Taht
abf70ef494 tc: support conversions to or from 64 bit nanosecond-based time
Using a 32 bit field to represent time in nanoseconds results in a
maximum value of about 4.3 seconds, which is well below many observed
delays in WiFi and LTE, and barely in the ballpark for a trip past the
Earth's moon, Luna.

Using 64 bit time fields in nanoseconds allows us to simulate
network diameters of several hundred light-years. However, only
conversions to and from ns, us, ms, and seconds are provided.

The iproute2 64 bit api uses signed values for time. Being able to
represent positive or negative time allows us to calculate +/- deltas
between, for example, the CLOCK_TAI and CLOCK_REALTIME clocks.

Time related utility functions in tc_util.c are moved to lib/utils.c.

Signed-off-by: Yousuk Seung <ysseung@google.com>
Signed-off-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-08-30 11:04:38 -07:00
Mahesh Bandewar
5d5586b058 iproute: make clang happy
These are primarily fixes for "string is not string literal" warnings
/ errors (with -Werror -Wformat-nonliteral). This should be a no-op
change. I had to replace couple of print helper functions with the
code they call as it was becoming harder to eliminate these warnings,
however these helpers were used only at couple of places, so no
major change as such.

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-08-30 07:58:09 -07:00
Stephen Hemminger
0ebb420929 uapi: update bpf headers
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-08-30 07:55:49 -07:00
Phil Sutter
515a766cd2 lib: Make check_enable_color() return boolean
As suggested, turn return code into true/false although it's not checked
anywhere yet.

Fixes: 4d82962ccc ("Merge common code for conditionally colored output")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-08-20 08:55:16 -07:00
Phil Sutter
ff1ab8edf8 Make colored output configurable
Allow for -color={never,auto,always} to have colored output disabled,
enabled only if stdout is a terminal or enabled regardless of stdout
state.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-08-20 08:54:06 -07:00
David Ahern
ea9f9b910e Merge branch 'iproute2-master' into iproute2-next
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-08-15 09:56:30 -07:00