Commit Graph

21 Commits

Author SHA1 Message Date
Ian Bishop
0e3b74dbe2 replace syscall with golang.org/x/sys/unix 2017-10-26 09:45:08 -07:00
Vincent Bernat
c684918a4f Add more variant with options to subscribe functions
For link, address, route, add a `WithOptions` variant to the
`*Subscribe()` function to specify a namespace and an error
callback. Those options can be extended in the future without adding
more functions. For example, it could be possible to subscribe only
for a given family by adding a `Family` member to the appropriate
struct.

As a minor change, the private function is always suffixed by `At`,
since it was the case for route and raw netlink functions (but not for
address and link).
2017-09-24 11:01:49 -07:00
Vincent Bernat
cda96d38a7 route: add Equal() method to compare routes
All fields are compared for strict equality.
2017-09-24 11:00:50 -07:00
Vincent Bernat
bda7895ec3 route: introduce ipNetEqual() helper function
This tests equality between two IPNet pointers.
2017-09-24 11:00:50 -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
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
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
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
Alessandro Boch
fea1da6ef5 Allow to subscribe to events on a specfic netns (#142)
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-06-29 11:11:35 -05:00
Wataru Ishida
01c64f1d8a Support multipath (#134)
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
2016-06-14 22:02:24 -07:00
marek-polewski
889a43b83d remove routeFilter struct and use route and mask instead
rename iif to iLinkIndex
2015-12-08 23:35:55 +01:00
marek-polewski
b5b45b160b add route filtration structure 2015-11-26 16:31:53 +01:00
marek-polewski
dfdad47336 add protocol, priority, table, type, tos to route 2015-11-26 16:09:33 +01:00
Bryan Boreham
88f55bc25d Unit tests for LinkSubscribe and RouteSubscribe 2015-08-19 16:31:39 +01:00
Arnaud Porterie
8eb6423887 Fix panic when adding an incomplete route
RouteAdd expects at least Dst.IP, Src, or Gw to be set, but accesses the
destination IP without testing for Dst being nil in the first place.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
2015-02-24 11:13:56 -08:00
Dave Tucker
80a80badbd Implement basic route get functionality
This provides the basic functionality of the iproute2 `route get`
command. It allows you to query netlink for the route to a destination
IP.Net

While implementing I noticed that the `s.Receive()` function was hanging
after the netlink response was recieved, so I added an additional clause
to break from the loop and return the decoded message if the NLM_F_MULTI
flag is not set.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2015-01-11 18:15:59 +00:00
Eugene Yakubovich
e7911d879f Use LinkIndex instead of Link obj in Route, Neigh
Having object composition causes both client and library to
do potentially unecessary work to retrieve Link attributes
when only index is often sufficient.
2014-10-13 16:09:09 -07:00
Vishvananda Ishaya
9f98335fb3 Change route to hold pointers to structs 2014-09-07 11:27:46 -07:00
Vishvananda Ishaya
8dab8b7462 Initial commit of netlink package 2014-08-31 20:34:46 -07:00