Commit Graph

496 Commits

Author SHA1 Message Date
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: 921f7441f1
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
Julian Kornberger
78a3099b70 Make test suite more deterministic
expectNeighUpdate might fail on unexpected updates
2018-12-08 10:04:51 -08:00
Michal Rostecki
25298936a6 genetlink: Add missing error check
Before this change, error returned by `parseFamilies` was silently
ignored.

Signed-off-by: Michal Rostecki <mrostecki@suse.de>
2018-11-30 08:41:18 -08:00
callmehollow
91b013f9ed code simplification 2018-11-19 16:40:56 -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
Julian Kornberger
3b1c596ccb Run TravisCI with Go 1.10 and 1.11 2018-10-30 10:30:53 -07:00
Julian Kornberger
d741264626 Reduce allocations 2018-10-29 15:31:34 -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
Flavio Crisciani
02a383156a Adjust conntrack filters
Today the filter implementation implements
only ip matching for src,dst,reply src,reply dst.
Updating the comments on the filter to reflect that
more clearly and deprecate confusing constants

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2018-10-24 12:03:49 -07:00
Julian Kornberger
d3a23fd178 Make AddChild more generic 2018-10-18 13:50:19 -07:00
Magesh GV
1404979ff6 Add support for hoplimit metric in routes 2018-10-16 12:33:37 -07:00
Yuya Kusakabe
6d53654d01 Add support for neighbor subscription 2018-10-16 12:05:02 -07:00
Joe Stringer
531df7a209 Avoid serializing empty TCA_OPTIONS in qdisc messages
This was causing a QdiscReplace() call for a generic qdisc
(QdiscType="clsact", Parent=HANDLE_CLSACT) to fail with the error
"invalid argument" after the qdisc was first created.

Signed-off-by: Joe Stringer <joe@wand.net.nz>
2018-10-16 11:53:53 -07:00
Will Kelleher
56b1bd27a9 fix: BRIDGE_FLAGS_* constants off-by-one 2018-09-10 11:41:28 -07:00
Chris Telfer
8aa85bfa77 Add support for action and ifindex in XFRM policy
The action and ifindex fields aren't represented in the XfrmPolicy type
although they exist in the the linux equivalent data structures.   They
are represented in the serialized versions of those datatypes.  So this
patch simply exposes those fields to the user-consumable side of the
API.  This patch makes the policy's action a specific type in the same
style as the Dir field in XfrmPolicy.

Update the existing unit tests to compare Ifindex and Action fields in
the XFRM structure.  Verify that the default policy returns an action of
ALLOW and an ifindex of 0.  Add a unit test to add and read back a
policy to the loopback interface (ifindex 1) with action "block".

Signed-off-by: Chris Telfer <ctelfer@docker.com>
2018-08-14 10:33:37 -07:00
Sean Karlage
9eab419334 Netlink: Fix Darwin build
Having fou.go build only for linux breaks builds for darwin:
```
$ go build main.go
src/github.com/vishvananda/netlink/fou_unspecified.go:5:15: undefined: Fou
src/github.com/vishvananda/netlink/fou_unspecified.go:9:15: undefined: Fou
src/github.com/vishvananda/netlink/fou_unspecified.go:13:26: undefined: Fou
```

Instead, build fou.go for all platforms since it doesn't have platform-specific code:
```
$ go build main.go
$ ./main
not implemented
```
2018-07-30 08:32:48 -07:00
Div Arora
2cbcf73e3d Add a test for Vlan filtering support for bridges. 2018-07-23 11:15:57 -07:00
Div Arora
0bbc55bea9 Initial support for vlan aware bridges. 2018-07-23 11:15:57 -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
Parav Pandit
d68dce480e Ingress qdisc add/del Test case 2018-07-17 08:26:44 -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
Ralph Schmieder
d85e18ed5b Allow Tuntap non-persist, allow empty tuntap name
chg: addtl comment and made minor logic optimization as disscussed in PR #296
chg: flipped Persist to NonPersist
chg: comments, only unpersist tuntap if flag is set
chg: tuntap persist optional, allow empty intfc name
chg: added conditional build
Signed-off-by: Ralph Schmieder <ralph.schmieder@gmail.com>
2018-07-16 09:40:17 -07:00
James O. D. Hunt
d77c86a2e2 protinfo: Check if object is nil
Avoid segfaults in certain environments by checking if the Stringer
interface pointer receiver function is `nil` and return "<nil>" in
those scenarios.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2018-07-06 09:00:30 -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
Piotr Skamruk
3e48e44812 Revert "RTEXT_FILTER_VF doesn't always work with dump request, fixes #354"
This reverts commit 028453c77c.
2018-07-05 15:07:35 -07:00
Semicomplete
028453c77c RTEXT_FILTER_VF doesn't always work with dump request, fixes #354 2018-06-23 12:29:17 -07:00
semicomplete
ee06b1df73 add vti6 support
Signed-off-by: semicomplete <example@example.com>
2018-06-19 08:48:34 -07:00
semicomplete
b1cc70dea2 fix prefixlen/local IP, incl. PtP addresses
From libnl addr.c comment:
IPv6 sends the local address as IFA_ADDRESS with no
IFA_LOCAL, IPv4 sends both IFA_LOCAL and IFA_ADDRESS
with IFA_ADDRESS being the peer address if they differ

But obviously, IPv6 sends IFA_LOCAL in case of PtP.

From iproute2 manual:
If a peer address is specified, the local address
cannot have a prefix length. The network prefix is
associated with the peer rather than with the local
address.
2018-06-17 08:27:03 -07:00
Francis Begyn
7c0b5944a3 Implemented String() for netem, fq and fq_codel in qdisc 2018-05-15 08:54:30 -07:00