Commit Graph

301 Commits

Author SHA1 Message Date
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
Vishvananda Ishaya Abrams
c19091b1c6 Add support for peakrate and minburst. 2017-02-08 10:29:21 -08:00
Sebastien Boving
dbc72376c8 Properly skip tests which require root.
All these tests currently fail with 'Operation not permitted' when run as
non-root.
2017-02-06 09:09:57 -08:00
Erik Dahl
e0c5e75bb2 Add RouteReplace API
Add RouteReplace

run go fmt on changes

Add test for RouteReplace
2017-02-06 09:06:54 -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
kishiguro
6b895203a7 Broadcast address can be specified when adding address. 2017-02-02 13:05:14 -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
Alessandro Boch
ebdfb74020 Return 64 bits link statistics
Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-01-17 08:21:17 -08:00
Ethan J. Jackson
90b9ee5358 Fix the RouteList() prototype on non-linux platforms
The RouteList() function prototype had become out of sync with its
Linux counterpart.  This patch updates it.
2017-01-10 14:32:23 -08:00
Vishvananda Ishaya Abrams
1890b34fa3 Fix a panic in parseTbfData.
Include all 8 bytes when generating the native Uint64 otherwise this
code may encounter an index out of range panic.
2017-01-05 15:59:13 -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
Ethan J. Jackson
9f67bd458b Update netlink_unspecified with new Addr function prototypes
At some point the function prototypes for the `AddrAdd` and `AddrDel`
functions got out of sync with addr_linix.go.  This patch fixes it.
2017-01-05 13:01:20 -08:00
Ethan J. Jackson
13fb20a978 Update link functions on non-Linux builds
The non-Linux stub implementation found in netlink_unspecified.go was
missing quite a few Link related functions.  Also, some of the
functions that were there took a `*Link` instead of a `Link`.
2016-12-19 10:14:57 -08:00
Ethan J. Jackson
e8a63ddd86 Implement handle on non-linux platforms
When developing for Linux on a non-Linux platform, it's useful to have
mock method implementations so the code can easily build locally.
This patch adds such mock implementations for the handle struct, as is
already done in netlink_unspecified.go and route_unspecified.go.
2016-12-19 10:14:29 -08:00
Vishvananda Ishaya Abrams
c750a61f18 Set rates higher than 32bit integers 2016-12-13 18:04:10 -08:00
unclejack
05458f3920 protinfo: return value of evaluated expression 2016-12-13 10:57:44 -08:00
Shaun Crampton
7a823e360e Parse the IFLA_OPERSTATE flag and recort in the link attributes. (#180)
The operstate gives the best picture of whether the interface is really up.
2016-12-09 14:08:27 -08:00
Martynas Pumputis
266f02d3a8 Parse IFLA_PROTINFO in LinkDeserialize
Extract and parse IFLA_PROTINFO fields from RTM_NEWLINK AF_BRIDGE
netlink messages.
2016-12-02 16:05:43 -08:00
Vish Ishaya
a4f22d8ad2 Change to kernel ordering of BOND_MODE (#178)
Fixes Issue #177
2016-11-22 17:07:05 -08:00
JC Martin
9438c6ff27 Add support for VTI and IPIP 2016-11-22 17:06:50 -08:00
Sylvain Baubeau
18675e4393 Expose LinkDeserialize function (#173) 2016-11-22 12:39:47 -08:00
JC Martin
916fa8422d Enable RouteListFiltered to seach default routes
The current implementation of RouteListFiltered checks for null Dst in
filter and this prevents filtering for default routes.
2016-11-22 12:30:53 -08:00
Roman Verchikov
482f7a52b7 Inconsistent AddrList() interface
The issue was noticed when building coreos/flannel on Mac. By default
the build would fail with:

    pkg/ip/iface.go:32: cannot use link (type *netlink.Device) as type
    *netlink.Link in argument to netlink.AddrList:
        *netlink.Link is pointer to interface, not interface

Resolved by making interfaces of AddList() implementations the same,
although the reason for having `netlink_unspecified.go` is not fully
clear to me and given that there's only one implementation available.
Perhaps a better idea would be to remove the "interface" altoghether.
2016-11-19 14:19:31 -08:00
Alessandro Boch
17ea11b5a1 Allow setting socket timeout on Handle
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-11-15 11:01:07 -08:00
Vishvananda Ishaya
ffec63e1f1 add support for LinkSetVfTxRate 2016-11-07 08:35:30 -08:00
Lincoln Stoll
a1f8555521 Add ipvlan l3s mode
Commit 4fbae7d83c98c30efcf0a2a2ac55fbb75ef5a1a5 added l3s mode
support to the kernel, add the value here.
2016-11-03 19:53:15 -07:00
Nicolas PLANEL
8b4e34d697 [link] add Link Encapsulation Type in LinkAttr
Retreive the link type from Netlink GetLink information.
Aim to return the same value as nl-link-list for example :

gre0 gre <noarp,up,running,lowerup> slave-of NONE group 0 ipgre : gre0
gretap0 ether <broadcast,multicast> slave-of NONE group 0 ipgre : gretap0
dummy0 ether 36:d5:87:cf:eb:35 <broadcast,noarp> group 0
tun0 none <pointopoint,multicast,noarp> group 0
tap0 ether 4e:ce:43:4a:82:c2 <broadcast,multicast> group 0

Signed-off-by: Nicolas PLANEL <nplanel@redhat.com>
2016-11-03 19:52:05 -07:00