Commit Graph

329 Commits

Author SHA1 Message Date
Manohar Castelino
7d0c00f02e gre tunnel: Add support for gre tunnels
Add support for creating and managing gre tunnels.
This is equivalent to

Point to Point:
ip tunnel add tun4 mode gre local 192.0.2.1 remote 203.0.113.6 key 123

Point to Multipoint:
ip tunnel add tun8 mode gre local 192.0.2.1 key 1234

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
2017-09-05 23:15:55 -07:00
Manohar Castelino
921f7441f1 ip neighbour: Add support for lladdr to be an IP address
The ip neighbour supports adding of peers statically using commands
where the lladdr is an IP address.

ip neighbor add 10.0.0.2 lladdr 203.0.113.6 dev tun8

This is used in the case of point-to-multipoint GRE to setup the
remote end point of the tunnel

Note that link-layer address and neighbor address are both IP addresses

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
2017-09-05 23:15:55 -07:00
Dan Winship
8a610f1e24 Add LinkSetTxQLen 2017-09-05 23:13:55 -07:00
kishiguro
4fe6bd0383 Add Family to struct Rule so that user can specify address family. 2017-09-05 23:13:17 -07:00
Vishvananda Ishaya Abrams
a98f31ffc7 filter pfifo qdiscs in tests 2017-09-05 22:56:13 -07:00
tcely
f5a6f697a5 Calculate the broadcast address
This is like "ip addr add 127.0.0.1/8 broadcast +" and prevents interfaces without broadcast addresses.

Configuring the IP and netmask, but not the broadcast address leaves many applications in a broken state on Linux interfaces.
2017-08-08 08:43:08 -07:00
Parav Pandit
06ccf872a2 Corrected library function to have Vf prefix
Corrected function signature to have correct name LinkSetVfTrust
instead of LinkSetTrust.
This aligns with code comment and rest of the other VF functions.

Signed-off-by: Parav Pandit <parav@mellanox.com>
2017-08-07 21:21:46 -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
Parav Pandit
a956595377 Add support to set spoof check attribute for VF
Add support to enable/disable spoof check for a VF

Signed-off-by: Parav Pandit <parav@mellanox.com>
2017-08-01 18:23:44 -07:00
Sibi Chakravarthy
8d7f7aad19 added missing mark in Sprintf 2017-07-18 16:23:47 -07:00
Sibi Chakravarthy
aeeae373ad constant bug fix 2017-07-18 16:23:47 -07:00
sibi
a56439f1e4 added-mark 2017-07-18 14:16:10 -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
Tobias Klauser
b1eba2e916 Fix go vet issues in tests
Fix the following two issues reported by go vet:

  bridge_linux_test.go:41: possible formatting directive in Fatal call
  filter_test.go:204: possible formatting directive in Fatal call

by using Fatalf instead of Fatal when using formatting directives.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-07-05 07:46:37 -07:00
John-Lin
a43807d906 fixed build error and imported not used 2017-06-30 17:10:56 -07:00
Shaun Crampton
6e453822d8 Make conntrack filter into an interface to allow for custom filters. 2017-06-30 11:43:20 -07:00
Thomas Graf
4e28683688 link: Add support for IFLA_*_COLLECT_METADATA
- Implemented for VXLAN and GRE via a flag `FlowBased`
- Added unit tests to verify ability

Signed-off-by: Thomas Graf <tgraf@tgraf.ch>
2017-06-13 11:05:35 -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
Mohamed Elawadi
7d9b424492 link-add: support hardware address 2017-05-31 12:01:59 -07:00
Anirudh Aithal
99091d8440 add a named error when links are not found
A new error type LinkNotFoundError is returned instead
of the default error type to facilitate better error
handling by downstream consumers of this package
2017-05-24 13:54:39 -07:00
Fabio Kung
0872fbf301 allow listing all routes tables with a Table:RT_TABLE_UNSPEC filter
Replicate the behavior of ip route show table all, which is the same as
ip route show table 0

Signed-off-by: Fabio Kung <fabio.kung@gmail.com>
2017-05-17 17:11:14 -07:00
Taku Fukushima
a66e14955d Fix byte order and reference bug of U32 filters
This patch fixes the bug of U32 filters which byte orders are not
appropriately updated based on the endianess of the host. Golang's
range returns copied values instead of their references when it
iterates through a map and the indices should be used to access the
specific value of the map by reference.

This patch also fixes the bug of netlink.FilterAdd that breaks the user
facing model changing  the type of cSel, the copied TcU32Sel, from its
pointer to the struct. Previously the pointer is copied and therefore
the data that is given by the users is modified if the endiannesses of
the fields in it need to be changed.

To validate these changes, I added the validation that the user facing
model is identical before and after netlink.FilterAdd. In addition to
that, the fix for the reference bug enables the endianness validations
in the same test case.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2017-05-15 20:56:34 -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
Pengfei Ni
1e045880fb Get broadcast addr in AddrList
Signed-off-by: Pengfei Ni <feiskyer@gmail.com>
2017-05-02 09:48:45 -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
Daniel Nardo
838b9b5fcb Set the change flags to IFF_PROMISC instead of IFF_UP on the SetPromiscOn/Off functions. 2017-04-22 12:51:05 -07:00
Taku Fukushima
f321bd7f3a Remove unnecessary condition of parsing U32 data
This patch removes the unnecessary condition of parsing U32 data that
checks if sel.Flags has nl.TC_U32_TERMINAL or sel.Nkeys is not 1.
Because of the modification to U32 that enalbed to specify multiple sel
keys, this condition is not valid anymore. This condition stops the
parsing of U32 fliter data with multiple attributes and this prevents
the users from getting all the necessary attributes, e.g., the class Id
of the filter.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2017-04-21 19:36:00 -07:00
Toke Høiland-Jørgensen
1d1fee5b18 AddrUpdate: Include flags, scope and lifetimes
Having the extra data available in the notification for new addresses is useful
to, for instance, filter out temporary addresses or keep track of address
lifetimes.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
2017-04-12 14:03:27 -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
Stuart McLaren
40e43c1d63 Ensure bond settings are populated correctly
Currently a LinkByName("bondX") doesn't return the bond specific attributes.

parseBondData needs to update the link that is passed in in order for
the bond's Mode, Miimon etc to be populated correctly.
2017-04-12 10:36:44 -07:00
Vishvananda Ishaya Abrams
b7148c6755 skip inconsistent test 2017-04-12 10:28:41 -07:00
Flavio Crisciani
1e86b2bee5 AddIP prototype change and fix for go 1.6
Removed extra pointer not needed in AddIP
Updated tests

Removed the use of io.SeekCurrent and defined it as a const

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-04-07 11:04:30 -07:00
Taku Fukushima
8bf4a3aacd Add advanced u32 match feature support
This patch adds the advanced u32 match feature support with the
selection keys. It enables the users to crate a complex filter as follow
for instance:

  $ tc filter add dev eth0 parent 1: prio 1 u32 match ip dport 80 0xff \
                match u32 0x146ca 0xffff at 32 flowid 1:46cb

To expose TcU32Sel and TcU32Key defined in nl package, this patch copies
them to filte.go and their values that require Big-endianness are
handled appropriately in FilterAdd function in filter_linux.go.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2017-04-07 11:03:16 -07:00
Flavio Crisciani
0ac4d252c6 Added conntrack_unspecified
Enable compilation in non linux environments

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-04-05 16:02:07 -07:00
Flavio Crisciani
c771f0b9d2 Conntrack testing
Added tests for:
Table FLUSH
Table GET
Table DELETE with filter
Filter match

Use a simple UDP client to create flows into the conntrack for testing purpose
Each test will run in a separate network namespace so can run in parallel
Added kernel module dependencies into the travis file

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-04-05 16:02:07 -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
Taku Fukushima
1b53666767 Add class ID parsing to parseU32Data
This patch adds a new switch case that handles the class ID attribute of
the U32 filter data listed by FilterList. Without this case block the
class ID of the U32 filter is always set to zero. The new test
conditions are added to TestFilterAddDel and TestFilterU32BpfAddDel in
filter_test.go as well.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2017-04-05 14:49:35 -07:00
Stuart McLaren
aec6f885c2 Add AddrReplace
Add an AddrReplace call (and tests).

Equivalent to:
 $ ip addr replace $addr dev $link
2017-03-31 10:10:22 -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
David Gee
d71ebad8a5 Mended LinkSetMaster signature mismatch
Signature mismatches when you try and compile on non-Linux machines. Instead of ErrNotImplemented, you get a message about wrongly using *Bridge.
2017-03-29 10:07:30 -07:00
David McClure
6c782366d2 Add LinkSetARPOff and LinkSetARPOn
Signed-off-by: Jay Dunkelberger <ldunkelberger@pivotal.io>
2017-03-21 02:39:47 -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
Wataru Ishida
87909c6dad Add Flags in NexthopInfo
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
2017-02-13 13:53:26 -08:00