Commit Graph

53 Commits

Author SHA1 Message Date
Riccardo Manfrin
ec93726159 Adds strings translation methods
RTPROT_KEEPALIVED is commented to interop with earlier go versions (1.13, 1.14)
2021-03-04 14:52:04 -08:00
Steve Shaw
fbe60771a0 Adding support for RTA_VIA
Signed-off-by: Steve Shaw <shaw38@gmail.com>
2020-12-03 10:12:37 -08:00
Oliver Herms
ffba2c833f RouteGetWithOptions: Add source address option 2020-11-21 22:56:51 -08:00
bianze
fb953eb4ce Add whole route metrics for netlink
There are lots of route metrics to be added, such as rto_min,
quick_ack and so on, and these metrics are useful for users to
tune network performance, so we add all these metrics.

Signed-off-by: bianze <bianze1993@gmail.com>
2020-10-19 15:37:56 -04:00
Amit Nishry
5a869a71f0 Introduce RouteGetWithOptions that allows to modify the RouteGet
Add support for VrfName as the RouteGetOptions

Signed-off-by: Amit Nishry <amit.nishry@gmail.com>
2020-06-03 12:09:39 -07:00
Chris Tarazi
564132f787 Implement RuleListFiltered
This commit adds the ability to list rules in a filtered manner, similar
to RouteListFiltered.

Signed-off-by: Chris Tarazi <tarazichris@gmail.com>
2020-06-03 11:26:35 -07:00
takt
d71301a47b Attach RTA_ENCAP_TYPE to children, not rtAttrs, when using Multipath 2019-11-13 10:34:27 -08: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
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
Andrei Vagin
e281812e70 Fix typos
Signed-off-by: Andrei Vagin <avagin@google.com>
2019-03-19 08:22:03 -07:00
Magesh GV
1404979ff6 Add support for hoplimit metric in routes 2018-10-16 12:33:37 -07:00
Kentaro Ebisawa
16769db002 Support LWTUNNEL_ENCAP_SEG6_LOCAL (including tests) 2018-05-08 09:50:31 -07:00
eriknordmark
5f5d5cddcf Add a 'ListExisting' option to get the existing entries in the
route/addr/link tables as part of RouteSubscribeWithOptions,
AddrSubscribeWithOptions, and LinkSubscribeWithOptions.
2018-01-23 14:25:48 -08:00
Vishvananda Ishaya Abrams
63ca7e48f5 Support setting and retrieving route MTU/AdvMSS 2017-11-09 14:04:31 -08:00
Kentaro Ebisawa
eb7ed874fe Support LWTUNNEL_ENCAP_SEG6 2017-11-08 03:33:01 -08:00
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
46962a8c5d Optionally report subscription fatal errors to a callback function
When a fatal error happens in a `*Subscribe*()` function, the error
was not available to the user. We add a callback function that will be
invoked when such an error happens.

This also modifies the behavior of `AddrSubscribe*()` function to turn
parse errors into fatal errors, as it happens with the other functions.
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
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
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
Kunihiro Ishiguro
d631d40de2 Multipath route is not installed due to gwData is newly allocated in block. (#159) 2016-08-23 15:58:51 -07: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
Vish Ishaya
0bc457d244 fix darwin build by moving code (#138)
Fixes issue #135
2016-06-15 08:44:14 -07: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
Alessandro Boch
f116a3048a Use package empty handle for pkg APIs (#117)
- Package methods only need an empty handle.
  Not a regular Handle with a couple of
  sockets creation/delete.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-05-09 16:55:00 -07:00
Alessandro Boch
14f41c27fa Provide netlink handle (#104)
- Ties to a netlink socket. All client requests
  will re-use same socket. Socket released at
  handle deletion.
- Also network namespace can be specified during
  handle creation. Socket will be opened on the
  specified network namespace.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-05-08 11:35:49 -07:00
Anton Aksola
7ff102806b Add support for setting route flags back
Removed in dfdad47 probably unintentionally.

resolves #93
2016-02-23 13:13:02 +02: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
Anton Aksola
a2c125fb6c Add support for setting nexthop flags for routes
There are few nexthop flags that are usable in some scenarios: onlink
and pervasive. This patch allows to set, clear and list them.
2015-10-09 11:17:13 +03:00
Vish Ishaya
ecf47fd573 Merge pull request #46 from bboreham/subscribe
Async updates on links and routes
2015-09-15 10:05:05 -07:00
fmzhen
c0038eeedc Fix typo
Fix typo

Signed-off-by: Mingzhen Feng <fmzhen@zju.edu.cn>
2015-09-07 14:35:08 +08:00
Bryan Boreham
69942a0c81 Subscribe for async updates on links and routes 2015-08-19 15:42:33 +01:00
Bryan Boreham
dfc070d6fa Don't expose deserializeRoute 2015-08-19 15:41:41 +01:00
Bryan Boreham
80dddfa1b9 Factor out common code to decode a binary netlink message into a Route struct 2015-08-19 11:38:52 +01:00
Vishvananda Ishaya
b8d3e51d2a actually ignore routes from other interfaces 2015-08-17 17:37:46 -07:00
Vishvananda Ishaya
27f66da7b4 allow RouteDel to work on kernel routes 2015-07-27 09:32:07 -07:00
Alexander Morozov
12f4097df1 Fix some style issues as suggested by golint
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-06-18 17:41:46 -07: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
f87c54f846 Make links have different types 2014-09-24 16:32:16 -07:00
Vishvananda Ishaya
1a26b9f251 Move all low level calls into nl subpackage 2014-09-18 19:04:48 -07:00
Vishvananda Ishaya
c84dba1b12 Convert syscall.AF_INET to FAMILY_V4 2014-09-17 09:33:53 -07:00