Commit Graph

476 Commits

Author SHA1 Message Date
Takushi Fujiwara
2ec5bdc52b Change LinkSetMaster's master argument type. (*Bridge -> Link)
LinkSetMaster also works with Bond device.
So this PR changes the type of master argument to Link.
2019-09-30 07:54:47 -07:00
Yakushi Fujiwara
ac5f4df047 Add support for parsing IFLA_BOND_ARP_IP_TARGET 2019-09-24 13:57:46 -07:00
Oleg Senin
6b3a223c53 Add ip6tnl support 2019-09-24 13:56:29 -07:00
Ihar Hrachyshka
07ace697be Introduce constants for known VF link states 2019-09-24 13:55:40 -07:00
Sam Gwydir
205d80393d Support setting link state for SR-IOV VFs 2019-09-24 13:55:40 -07:00
Takushi Fujiwara
205a160d2e Add bond slave information
This PR refers to PR@lebauce and add some changes.
- Added some tests to retrieve bond slave information.
- Link.BondSlave is changed to LinkSlave interface.
- BondSlaveState.String() returns UPPER case. (same as iproute2)
- BondSlaveMiiStatus.String() returns UPPER case. (same as iproute2)
2019-09-16 08:52:39 -07:00
Laurent Bernaille
e906d22624 Add support for output-mark 2019-09-16 08:26:04 -07:00
Tobias Klauser
36d367fd76 Remove unused *_PROTO constants
These are unused since commit 941b4de9e151f1c3662f3f1fa23ec263999f09de

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-09-13 09:58:27 -07:00
Juan-Luis de Sousa-Valadas Castaño
07130f38b9 Fix parsing of IFLA_GRE_COLLECT_METADATA 2019-09-12 09:05:07 -07:00
Nicolas Belouin
a1c9a648f7 neighSubscribeAt: AF_BRIDGE entries not listed when listExisting is true
When subscribing to neigh updates, the updates for all neigh
protocol families are received. However when listExisting is set,
the request is made with AF_UNSPEC family, this request does not
include AF_BRIDGE entries.

This patch add a second request for AF_BRIDGE entries.

Add test for existing AF_BRIDGE entry and make expectNeighUpdate
take a slice of expected updates

Creates a VXLAN interface for this test as its AF_BRIDGE entries
looks a lot like usual ones

Also add support for latest (2014+) neighbour attributes

NDA_MASTER was added back in 2014, it indicates whether a neigh
entry is linked to a master interface and index of this interface.

The other entries, namely NDA_LINK_NETNSID and NDA_SRC_VNI were
added later and will need extra handling.

Signed-off-by: Nicolas Belouin <nicolas.belouin@gandi.net>
2019-08-23 11:29:04 -07:00
GopiKrishna Kodali
941b4de9e1 Read connection marking information from CT flow TLV 2019-08-23 11:20:03 -07:00
Yakushi Fujiwara
254c8a89c5 Replace values defined in unix package.
- replace following values to unix.*
  AF_MPLS, RTA_NEWDST, RTA_ENCAP_TYPE, RTA_ENCAP
2019-08-23 11:17:48 -07:00
Naiming Shen
e825b754c0 Add Timestamp, Timeout to conntrack
Signed-off-by: Naiming Shen <naiming@zededa.com>
2019-08-12 12:01:13 -07:00
Adrian Chiris
46ae81cf70 Add support for IPoIB interfaces
- Add a new Link type, IPoIB, that exposes the following IPoIB attributes:
    * IFLA_IPOIB_PKEY
    * IFLA_IPOIB_MODE
    * IFLA_IPOIB_UMCAST
- Suppport Deserialize for IPoIB link attributes in LinkDeserialize()
- Support IPoIB attributes in LinkAdd()
2019-08-12 04:46:40 -07:00
Thomas Bucher
b4e9f47a11 Update netlink_unspecified.go
AddrReplace was missing, could not compile on OSX
2019-07-26 00:49:17 +02:00
Adrian Chiris
28720742a4 Add support for IFLA_VF_RATE
Today netlink package supports Get/Set of a VF's max TX rate
via IFLA_VF_TX_RATE netlink attribute.

This patch add support to Get/Set of a VFs min and max TX rate
via IFLA_VF_RATE netlink attribute.

- Add support to set min/max tx rate for VF via IFLA_VF_RATE
- Added IFLA_VF_RATE min/max tx rate attributes to netlink.VfInfo
  including parsing support in netlink.parseVfInfo()

NOTE: According to [1] IFLA_VF_RATE takes precedence over
      IFLA_VF_TX_RATE. Dealing with the co-existance of these
      netlink attributes is left for the user to handle.

[1]https://lists.openwall.net/netdev/2014/05/22/42
2019-07-25 03:38:53 +02:00
bingshen.wbs
14bd2e6fd2 support ipvlan flag
Signed-off-by: bingshen.wbs <bingshen.wbs@alibaba-inc.com>
2019-07-25 03:37:08 +02:00
Daniel Borkmann
b1e9859792 netlink: enforce similar pid checks as in iproute2
iproute2's own netlink library asserts that the sockaddr sender pid
has to be the one of the kernel [0]. It also doesn't bail out on pid
mismatch but only skips the message instead. We've seen cases where
the latter had a pid 0; in such case we should skip to the next nl
message instead of hard bail out.

  [0] https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/lib/libnetlink.c
      rtnl_dump_filter_l(), __rtnl_talk_iov()

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2019-07-18 17:26:53 -07:00
Przemyslaw Lal
43af4161ea Add support for setting VLAN QoS for VF links
This change adds support for setting VLAN QoS (priority) field for the
SR-IOV Virtual Function links.
2019-07-15 07:57:55 -07:00
Anton Aksola
df01369528 add support for link groups (IFLA_GROUP) 2019-07-13 20:34:27 -07:00
Farid Zakaria
2e4a68ee6c Add support for additional TC BPF filter attributes
In order to support BPF_SYSCALL `PROG_GET_FD_BY_ID` -- the ID of the
eBPF must be available.

Add the additional enumerations and handle them when parsing the BPF
filter.
2019-07-01 11:37:39 -07:00
Lorenz Bauer
a8241965b5 Allow replacing filters
Add a function FilterReplace, which mirrors the behaviour of
QdiscReplace, etc. This makes it possible to swap out filters
with a single netlink message.
2019-06-24 06:52:36 -07:00
Martynas Pumputis
99a56c251a veth: Set peer hardware addr when creating
This commit extends LinkAdd function for Veth by allowing to specify
peer hardware addr.

Signed-off-by: Martynas Pumputis <m@lambda.lt>
2019-06-18 07:33:17 -07:00
Parav Pandit
123a384710 Add an API to change net namespace of RDMA device
Add an API to change net namespace of RDMA device similar to

$ rdma dev set [DEV] netns NSNAME

Signed-off-by: Parav Pandit <parav@mellanox.com>
2019-06-13 22:19:36 -07:00
Sargun Dhillon
d50d15ce3f Set Link TX / RX Queues on Deserialization
This deserializes the tx queue, and rx queue count on link
deserialization. We already supported it on serialization.

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
2019-06-12 19:02:44 -07:00
eriknordmark
3a1f6536f6 Make AddrSubscribe more robust against kernel reporting errors 2019-06-10 08:41:22 -07:00
Parav Pandit
0f040b9e2c Add an API to set RDMA subsystem network namespace mode
Add an API to change the RDMA subsystem network namespace mode as either
shared or exclusive similar to

$ rdma system set netns { shared | exclusive }

Signed-off-by: Parav Pandit <parav@mellanox.com>
2019-06-07 21:21:07 -07:00
Parav Pandit
4666477197 Add an API to query RDMA subsystem net namespace mode
RDMA subsystem can be running in shared or exclusive mode with regards
to sharing RDMA device sharing among multiple network namespaces.

Add and API to query such mode of kernel similar to iproute2 command
$ rdma system show netns

Signed-off-by: Parav Pandit <parav@mellanox.com>
2019-06-07 21:21:07 -07:00
yandong.yan
c8c507c80e fix: fix ip rule goto bug 2019-06-03 19:20:42 -07:00
Archana Shinde
db99c040b9 tuntap: Return TunTapLink instead of GenericLink
For tuntap interfaces, return a TunTap Interface instead of
a Generic link when retrieving the interface.
Use netlink extended attributes to populate the Link attributes
for the tuntap link.
In case of older tun driver which does not provide these
attributes, use sysfs to retrieve these attributes.

This commit also adds Owner and Group attributes for the TunTap
Link.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2019-06-03 12:01:21 -07:00
Manohar Castelino
e99361632b Fix unit test failure: TestNeighAddDelLLIPAddr
TestNeighAddDelLLIPAddr was failing due to the Neighbour table
not getting properly populated when using a ipip tunnel.
This matches the behaviour in the latest kernel when using
the ip command.

Switch the tunnel type to a gre point to multi-point tunnel.
The neighbour table gets properly populated in this case.

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
2019-06-03 08:12:13 -07:00
Krister Johansen
fb5fbae935 Mirred and connmark clobber their ActionAttrs
Encountered this in a local test.  It turns out that in parseActions
mirred has a bug where it parses the action attributes but then on the
very next line overwrites this hard work by assigning an empty
ActionAttrs struct on top.  I copy pasta'd this into connmark.  Fix both
instances and amend the unit tests to catch this going forward.

Signed-off-by: Krister Johansen <krister.johansen@oracle.com>
2019-05-31 09:24:53 -07:00
Vishvananda Abrams
1187dc9297 Fix tests 2019-05-29 19:32:31 -07:00
Krister Johansen
00009fb860 Add support for TC_ACT_CONNMARK
Implements the connmark action described in tc-connmark(8)

Signed-off-by: Krister Johansen <krister.johansen@oracle.com>
2019-05-22 08:35:24 -07:00
soyking
fafc1e7b60 support vlan protocol 2019-05-03 14:23:34 -07:00
Parav Pandit
fd97bf4e47 Add command to set devlink device switchdev mode
Devlink device currently has legacy and switchdev mode.
Add an API to set devlink device mode for discovered devlink device.

Signed-off-by: Parav Pandit <parav@mellanox.com>
2019-05-01 11:37:24 -07:00
Parav Pandit
bcb80b237c Add devlink command by to get specific device name
Add a command to get information about a specific devlink device
referenced by device name (bus, device).

Remove unused setupDevlinkKModule().

Signed-off-by: Parav Pandit <parav@mellanox.com>
2019-05-01 11:37:24 -07:00
CodeLingo Bot
f504738125 Fix function comments based on best practices from Effective Go
Signed-off-by: CodeLingo Bot <bot@codelingo.io>
2019-03-19 09:31:22 -07:00
Andrei Vagin
e281812e70 Fix typos
Signed-off-by: Andrei Vagin <avagin@google.com>
2019-03-19 08:22:03 -07:00
Andrei Vagin
adb577d4a4 Add support for IFLA_GSO_*
IFLA_GSO_MAX_SIZE - maximum GSO segment size
IFLA_GSO_MAX_SEGS - maximum number of GSO segments

Signed-off-by: Andrei Vagin <avagin@google.com>
2019-03-17 17:31:49 -07:00
Andrei Vagin
aa950f24b9 travis: run tests with Go 1.12.x
Signed-off-by: Andrei Vagin <avagin@google.com>
2019-03-17 17:31:49 -07:00
Andrei Vagin
b64d7bc44d travis: specify go_import_path
This will allow to enable travis for forks.

Signed-off-by: Andrei Vagin <avagin@google.com>
2019-03-17 17:31:49 -07:00
Iskander Sharipov
b9cafe4a85 remove redundant type assertions in type switch
Use type switch var to get properly-typed value
inside case clauses.

Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
2019-02-06 11:24:39 -08:00
Matt Ellison
1e2e7ab670 Add Support for Virtual XFRM Interfaces
XFRM interfaces are available in Linux Kernel 4.19+

When an IF_ID is applied to a XFRM policy and state, the corresponding
traffic will be sent through the virtual interface with the same IF_ID.
2019-01-05 11:40:40 -08:00
Matt Ellison
48a75e0e38 Fix Race Condition in TestXfrmMonitorExpire 2019-01-04 09:44:57 -08:00
Milan Lenco
e37f4b431a Avoid 64K allocation on the heap with each Receive
Currently each call to Receive() allocates 64K buffer on the heap
for the data to receive from a netlink socket. This is rather costly
considering that in most cases only fraction of this memory is actually
needed.

A quick fix is to make sure that the large buffer does not "escape" -
i.e. that it is sufficient to have it allocated on the stack.
Then only the prefix of the buffer that was actually used
is copied to the heap.

Fix for issue: #379

Signed-off-by: Milan Lenco <milan.lenco@pantheon.tech>
2019-01-03 08:31:59 -08:00
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
Nicolas Belouin
cb78b18701 neigh_linux: Fix failure on deleted link neighs updates
The kernel sends a RTM_DELNEIGH for every neighbours on link
deletion by the time the message is deserialized, the interface
no longer exists so we cannot call LinkByIndex on it.

This call to LinkByIndex is only used to get the encapType to be
able to set either IP or HardwareAddr correctly. The attrLen
attribute can be used here as only ipv4 are used with a size of 4,
and only ipv6 and FireWire HWaddr have a size of 16.

As such this change decrease the number of calls to LinkByIndex,
so it is called only when needed to choose between ipv6 or
FireWire Hwaddr, it also fallback to HWaddr in case of error with
LinkByIndex.

Fix: 921f7441f1ad68ebc6bbebe00664dfad83a7dbc6
Fix #409

Signed-off-by: Nicolas Belouin <nicolas.belouin@gandi.net>
2018-12-18 15:35:59 -08:00
Taku Fukushima
2bc5004800 Replace redundant copied u32 types with type aliases
This patch replaces TcU32Sel and TcU32Key that are copied from nl
package with type aliases for the original types. This eliminates the
usages of unsafe packages and redundant copied structs that are
identical to the original ones.

Type aliases are newly introduced in Go 1.9 and it is not backward
compatibile. Therefore this patch shall be merged only if the project is
entirely migrated to Go 1.9. Currently we are building this project
with Go 1.10 and Go 1.11, so it is reasonable to require Go version
greater than 1.9.

See #206 and #261, which is the previous life of this patch.

This patch also moves TcU32Sel, TcU32Key and U32 structs from filter.go
to filter_linux.go to make it possible to build on macOS. See #243 for
more details.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2018-12-16 11:33:25 -08:00
Julian Kornberger
093e80f9fa Pass Ndmsg to NeighListExecute 2018-12-09 07:20:04 -08:00