Commit Graph

48 Commits

Author SHA1 Message Date
Maxime Soulé
7f562ed576 RouteUpdate gains NlFlags field
It allows to distinguish between a new created route or a replaced one.

Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
2024-03-01 13:06:15 -08:00
Maxime Soulé
124bb8e721 Add RouteChange API
Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
2024-02-26 09:50:43 -08:00
Hasan Mahmood
42d9a053ea Add IifIndex option to RouteGetOptions 2024-02-23 09:54:32 -08:00
Tao Li
8d48f50f55 Added ip6tnlEncap to insert ip6tnl encap route
This commit added support to allow the operation of ip6tnl encapsulation.
It is equivalent to the iproute2 command, e.g., ip route add 192.168.99.0/24 encap ip6 dst 2001:db8:: dev ip6-tunnel
The limitation include that the options field defined in encap nl route attribute is not implenmented yet.
Testcase is included.
2024-01-23 10:47:39 -08:00
Tobias Klauser
586148b818 Use valid Tos value in TestRouteFilterAllTables and TestRouteExtraFields
TestRouteFilterAllTables and TestRouteExtraFields started failing a
while ago after GitHub actions images bumped the kernel version from
5.15.x to 6.2.x [1].

This is because newer kernels containing commit [2] started rejecting
Tos values with the ECN bits set to non-zero, this leads to the
following error being reported when adding routes:

    invalid argument: Invalid dsfield (tos): ECN bits must be 0

Fix this by using a valid Tos value in TestRouteFilterAllTables and
TestRouteExtraFields.

[1] https://github.com/vishvananda/netlink/pull/773#issuecomment-1754436653
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f55fbb6afb8d
2023-10-24 09:29:12 -07:00
Yutaro Hayakawa
bd5868794c Support fibmatch flag for RouteGetWithOptions
Support `ip route get fibmatch` equivalent with RouteGetWithOptions by
adding FIBMatch flag to RouteGetOptions.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
2023-07-05 17:39:32 +02:00
Li Chun
acdc658b86 Add "default" dst while no DST attr responsed from nl
Signed-off-by: Li Chun <chun2.li@intel.com>
2023-06-03 21:11:57 -07:00
Steffen Vogel
d3b7a6fadd Add firewall mark option to RouteGetOptions
This option allows performing FIB lookups for a particular
firewall mark. It is equivalent to iproute2's 'ip route get mark'
option.
2022-11-07 10:26:17 -08:00
chengzhycn
337a587de1 fix RouteList can't list routes properly when unspecifying link
Signed-off-by: chengzhycn <chengzhycn@gmail.com>
2022-10-26 10:42:34 -07:00
Manjiri Gadagkar
6e2993d135 RouteGetWithOptions: Add UID option 2022-08-02 12:21:20 +02:00
Vishvananda Abrams
523ee65ce3 fix the tests to run again 2022-01-12 16:05:20 -06:00
yuwenchao
f055e5464f Add linux route get oif option.
This option is equivalent to "ip route get ... dev ...", which is useful when the route is multipath.

Signed-off-by: yuwenchao <yuwenchao@qiyi.com>
2021-09-21 09:12:08 -05:00
张祖建
b8aac10bba fix staticcheck issues 2021-09-21 09:10:48 -05:00
Tobias Urdin
65349edba8 Add support for RTA_FLOW
This adds support for the RTA_FLOW routing msg
attribute and adds the Realm field to the Route
object.
2021-09-20 10:45:34 -07:00
TheDiveO
626202eca8 Provide handle Close() and deprecate Delete() 2021-09-18 09:03:48 -07:00
bersoare
079db23e21 lwtunnel: add support for encap type bpf
add bpf program types

add unit tests

don't use strings to determine type

fix camel case
2021-07-03 11:44:22 +02:00
yaocw2020
c30d9bc9e7 Add ip route append
Signed-off-by: yaocw2020 <yaocanwu@gmail.com>
2021-03-15 00:21:01 -07: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
Julian Kornberger
78a3099b70 Make test suite more deterministic
expectNeighUpdate might fail on unexpected updates
2018-12-08 10:04:51 -08: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
Kentaro Ebisawa
b7f066956c Add test to Add/Del IPv6 route. 2018-05-04 07:33:55 -04:00
Kentaro Ebisawa
f07d9d5231 Run both Inline/Encap mode in TestSEG6RouteAddDel 2018-05-01 15:34:56 -07:00
Sargun Dhillon
c27b7f7359 Run gofmt -s -w on the project 2018-02-01 10:46:57 -08: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
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