Commit Graph

106 Commits

Author SHA1 Message Date
Parav Pandit
332a6983d9 Add devlink commands for devlink device information
This patch adds very basic support for getting information about
devlink devices which are typically PCI devices which exposes Networking
switch or legacy devices.

This information includes bus name, device name and eswitch modes.
This is done through devlink family of commands via generic netlink
sockets provided by Linux kernel.

DevlinkDevice represents a devlink device which is identified by bus
name and device name (unlike interface index for netdevices).
It contains the DevlinkDevAttrs device attributes.
Currently only eswitch attributes are queried. In future more attributes
such as port, shared buffer, traffic class will be added.

Signed-off-by: Parav Pandit <parav@mellanox.com>
2018-12-19 14:37:14 -08:00
Julian Kornberger
023a6dafdc Make go vet happier 2018-11-08 14:21:39 -08:00
Julian Kornberger
aa5b058fc0 Simplify code 2018-10-30 10:31:46 -07:00
Julian Kornberger
e137ed6e2c Replace nl.NewRtAttrChild with method on struct 2018-10-30 10:31:19 -07:00
Parav Pandit
b48eed5d7d Add an API to rename rdma device name
Add an API RdmaLinkSetName() and test case to rename a
rdma device name.

Signed-off-by: Parav Pandit <parav@mellanox.com>
2018-10-29 12:38:29 -07:00
Julian Kornberger
d3a23fd178 Make AddChild more generic 2018-10-18 13:50:19 -07:00
Will Kelleher
56b1bd27a9 fix: BRIDGE_FLAGS_* constants off-by-one 2018-09-10 11:41:28 -07:00
Casey Callendrello
3ac69fdec7 Add network namespace ID management.
Adds the ability to set and retrieve network namespace IDs. This is
useful, for example, for determining the "other side" of a veth pair.
2018-07-19 10:40:23 -07:00
Francis Begyn
1006cf4f24 Implementation of HFSC
Testing and functionality for the use of HFSC has been implemented.
The use of service curves is implenented closely as to how they behave
with the TC implementation.
Automated checks and testing were succesful.
2018-07-16 12:14:02 -07:00
Piotr Skamruk
a06dabf159 Increase size of receive buffer
Closes #354

Previous attemt to fix #354 was only hiding a true issue with too small
buffer to pick up the message from kernel.
According to https://github.com/vishvananda/netlink/issues/354#issuecomment-401559441
such situation could occur not only during dump of VF list, but also
 * statistics
 * tc rules and tc filters
 * large conn track dump
 * rdma resource details dump for debugging
or any other place where kernel can return more data than default (4kB)
sized buffer could hold.

iproute2 in this case for rtnl_dump_filter_l has buffer with size of
16kB, but we don't have distinction between different receiving funcs,
so I'm proposing to stick with original issue cause finder (kudos to
Parav Pandit aka paravmellanox) who is proposing 64kB as a buffer size.
2018-07-05 15:07:35 -07:00
Kentaro Ebisawa
16769db002 Support LWTUNNEL_ENCAP_SEG6_LOCAL (including tests) 2018-05-08 09:50:31 -07:00
Parav Pandit
1970aef3ab Add RDMA netlink socket for RDMA device information
This patch adds very basic support for getting information about RDMA
networking device; starting with device index, name, firmware version,
node GUID and system image GUID.
This is done through RDMA netlink socket.

RDMA devices are some what similar to Ethernet devices.
However there are few major differences between them.
RDMA devices usually have one or two ports, unlike Ethernet devices.
Each port has its own attributes, state and network addresses which are
different than Ethernet devices (Link and LinkAttrs). They almost don't
overlap with Link and LinkAttrs.

Therefore it doesn't derive Link and LinkAttrs structure; instead they
are represented using RdmaLink and RdmaLinkAttrs.

RdmaLink represents a RDMA device containing its attributes.
All Rdma device communication occurs through rdma subsystem's netlink
socket.

Signed-off-by: Parav Pandit parav@mellanox.com
2018-04-28 17:02:23 -07:00
Taku Fukushima
85aa3b74a4 Add statistics to class attributes
This patch adds ClassStatistics, a struct that represents the stats
of a class based on genric networking stats for netlink, to ClassAttrs.
The parsers for rtattrs in type of TCA_STATS and TCA_STATS2 are
introduced as well and the stats are appropriately parsed as a part
of ClassAttrs struct.

The practical tests for stats are not contained in this patch yet since
it requires the actual packet sending/receiving in the random timing,
which makes the tests complicated and flaky. Once we figure it out how
to test them in the proper way, they shall be added.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2018-03-27 21:08:57 -07:00
Parav Pandit
aa0edbe0c9 Add support for setting InfininBand Node and Port GUID of a VF
Add support for setting InfiniBand Node and Port GUID address
configuration of a VF when InfiniBand HCA are used with SR-IOV mode.

Signed-off-by: Parav Pandit <parav@mellanox.com>
2018-03-26 21:49:05 -07:00
Yang Guan
41009d533b Read conntrack flow statistics
This PR allows populating per-connection packet and byte counts to
ConntrackFlow object when nf_conntrack_acct is enabled.
2018-03-16 14:29:24 -07:00
Tobias Klauser
5236321576 Use IFLA_* constants from x/sys/unix
The IFLA_* constants in in x/sys/unix were updated to Linux 4.15 in
golang/sys@88d2dcc510, so use these instead of locally duplicating
them.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2018-02-23 09:35:37 -08:00
Sargun Dhillon
a2af46a09c Add FQ Codel 2018-02-05 10:22:15 -08:00
Sargun Dhillon
465b5fef28 Add Fq Qdisc support 2018-02-05 10:22:15 -08:00
Sargun Dhillon
1882fa99fc Add Matchall filter 2018-01-05 09:42:30 -08:00
Luke Granger-Brown
016ba6f67a Add support for managing source MACVLANs 2017-11-27 22:19:10 -08:00
Vishvananda Ishaya Abrams
63ca7e48f5 Support setting and retrieving route MTU/AdvMSS 2017-11-09 14:04:31 -08:00
Kentaro Ebisawa
eb7ed874fe Support LWTUNNEL_ENCAP_SEG6 2017-11-08 03:33:01 -08:00
Reinier Schoof
c29ba20204 added encapsulation attributes to Iptun
added encapsulation attributes to Gretun
implemented Sittun struct for supporting SIT tunnels
2017-10-26 09:48:08 -07:00
Ian Bishop
0e3b74dbe2 replace syscall with golang.org/x/sys/unix 2017-10-26 09:45:08 -07:00
Flavio Crisciani
ef2b2c42e6 Add test to cover recv on close leak
This test spawns a go routine that subscribe for some
events while the main thread will close the socket.
The go routine will returns after 5s when the timetout
on the recv fires and the fd is actually == -1

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-10-20 10:09:56 -07:00
Flavio Crisciani
6177f17de7 Add method to set netlink recv timeout
If the socket is closed the recv that are waiting for messages
are not woken up. The result especially for Subscribe socket is
most likely a go routine leak.
This commit introduces a method to set the timeout

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-10-20 10:09:56 -07:00
Zvi "CtrlZvi" Effron
933b978eae Add support for loading XDP programs with flags 2017-09-05 23:17:00 -07:00
Parav Pandit
70cf3c74a8 Add support for setting trust state of a VF
Add support for setting trust state of a VF. This allows restricting
certain operations on VF when its untrusted such as disabling
promiscuous mode.

Signed-off-by: Parav Pandit <parav@mellanox.com>
2017-08-07 09:10:47 -07:00
Sibi Chakravarthy
aeeae373ad constant bug fix 2017-07-18 16:23:47 -07:00
Tobias Klauser
8c5a115d79 Add support for IFLA_XDP_PROG_ID
Allow to get IFLA_XDP_PROG_ID which will be part of Linux kernel 4.13+.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-07-09 20:04:06 -07:00
Chun Chen
7593cff56f Add bridge vlan support 2017-06-13 11:04:51 -07:00
Aaron Lehmann
bd6d5de5cc nl: Use atomic load/store for fd field
This allows Close to be called concurrently with Receive without
triggering a data race.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2017-06-06 09:06:09 -07:00
Stuart McLaren
7bd45e5974 Add extra bond parameters
Add bond parameters corresponding to:

* IFLA_BOND_AD_ACTOR_SYS_PRIO
* IFLA_BOND_AD_USER_PORT_KEY
* IFLA_BOND_AD_ACTOR_SYSTEM
* IFLA_BOND_TLB_DYNAMIC_LB

These are available in new(ish) kernels.
2017-05-31 12:03:01 -07:00
Wataru Ishida
58c32ae2d7 Add support for GPRS Tunnelling Protocol(GTP)
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
2017-05-06 23:07:19 -07:00
Wataru Ishida
fe2e32c2fb Add support for generic netlink
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
2017-05-06 23:07:19 -07:00
Tobias Klauser
90380e4b76 Add support for IFLA_XDP_FLAGS
Allow to get/set IFLA_XDP_FLAGS which is part of Linux kernel >= 4.10.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-05-06 23:05:39 -07:00
Craig Furman
2632e243fb Can set some bridge flags
* Multicast snooping and hello time are the only ones supported at the
  moment
* Only pass values to kernel when user sets them, otherwise let kernel
  decide default
* Can set multicast snooping on existing bridges
* Tests disabled on Travis CI as the kernel version is too old
* All bridge flags copied from Kernel code, but only the two mentioned
  above work
  (5a7ad1146c/include/uapi/linux/if_link.h (L232-L281))

Signed-off-by: Petar Petrov <pppepito86@gmail.com>
Signed-off-by: Ed King <eking@pivotal.io>
Signed-off-by: Konstantinos Karampogias <konstantinos.karampogias@swisscom.com>
Signed-off-by: Will Martin <wmartin@pivotal.io>
2017-04-25 08:25:47 -07:00
David J. Wilder
b71e0bb214 Add support for BR_PROXYARP and BR_PROXYARP_WIFI.
Bridge ports can be set to use the proxy arp features by calling
either LinkSetBrProxyArp() or LinkSetBrProxyArpWiFi().

Signed-off-by: David Wilder <wilder@us.ibm.com>
2017-04-22 12:52:14 -07:00
Toke Høiland-Jørgensen
69df5c75fb addr: Parse address lifetime information from IFA_CACHEINFO attr
This adds parsing of the preferred and valid lifetime information from the
netlink IFA_CACHEINFO attribute. They are stored as PreferedLft and ValidLft in
the Addr struct if found.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
2017-04-12 11:24:37 -07:00
Flavio Crisciani
24a3a2da61 Introduce Conntrack support
- Conntrack table FLUSH
- Conntrack table DELETE with filter
    The filter is only for IP field
- Conntrack table GET
  The flow information is not complete, but the method
  returns a simplified structure with basic flow info

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-04-05 16:02:07 -07:00
Alessandro Boch
c682914b0b Set SOCK_CLOEXEC when creating netlink socket
- So that the socket is not shared across execs

Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-03-29 10:46:00 -07:00
ISHIDA Wataru
fe3b5664d2 support MPLS
$ ip -M route add 100 dev eth0
$ ip -M route add 100 as to 200/300 dev eth0
$ ip -M route add 100 nexthop dev eth0 as to 200 \
                      nexthop dev eth1 as to 300
$ ip route add 10.10.0.0/24 encap mpls 200/300 dev eth0
$ ip route add 10.0.0.0/24 nexthop encap mpls 200 dev eth0 \
                           nexthop encap mpls 300 dev eth1

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
2017-02-20 12:07:19 -08:00
Aithal
dedc638a06 Fix compilation errors for non linux platforms.
The go get command and make both fail when executed on
non-linux platforms. Modified it so that there are no
compilation errors when developing in such an
environment.
2017-02-20 12:00:54 -08:00
Vishvananda Ishaya Abrams
a1d6c19f19 Fix build issue on linux/s390x
Fixes issue #194
2017-02-19 15:32:03 -08:00
Sebastien Boving
a3f0be6352 Add support for tcp diags. 2017-02-04 16:48:17 -08:00
Martynas Pumputis
43948793f6 Add support of ESN 2017-02-03 08:10:37 -08:00
Martynas Pumputis
3c27c1c1e3 Add XfrmAllocSpi 2017-02-02 13:02:12 -08:00
Martynas Pumputis
9a7970b3b6 Add XfrmMonitor
The implementation subscribes only to XFRMNLGRP_EXPIRE.
2017-02-02 12:58:44 -08:00
kishiguro
ade05d5c8f Add support for VRF. With this change we can create VRF interface.
$ sudo ip link add vrf1 type vrf table 1
2017-01-05 13:05:17 -08:00
Vishvananda Ishaya Abrams
c750a61f18 Set rates higher than 32bit integers 2016-12-13 18:04:10 -08:00