Commit Graph

16 Commits

Author SHA1 Message Date
Martynas Pumputis 96dce1cb9f Add LinkIndex to Addr struct
Currently, it's cumbersome to get a link by an IP addr - one needs to
list all links and then call AddrList() for each of them.

Considering that ifindex is already available to to the parseAddr()
helper function, we can expose it to a user via the newly added
Addr.LinkIndex field. This makes the retrieving link by IP addr much
more simple.

Signed-off-by: Martynas Pumputis <m@lambda.lt>
2020-06-03 11:20:50 -07:00
semicomplete b1cc70dea2 fix prefixlen/local IP, incl. PtP addresses
From libnl addr.c comment:
IPv6 sends the local address as IFA_ADDRESS with no
IFA_LOCAL, IPv4 sends both IFA_LOCAL and IFA_ADDRESS
with IFA_ADDRESS being the peer address if they differ

But obviously, IPv6 sends IFA_LOCAL in case of PtP.

From iproute2 manual:
If a peer address is specified, the local address
cannot have a prefix length. The network prefix is
associated with the peer rather than with the local
address.
2018-06-17 08:27:03 -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
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
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
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
JC Martin 9438c6ff27 Add support for VTI and IPIP 2016-11-22 17:06:50 -08:00
Vishvananda Ishaya adb0f53af6 Cleanup from golint and go vet 2016-03-19 17:12:26 -07:00
Liu Hua 8580636726 add test for addList with wrong family number
Signed-off-by: Liu Hua <sdu.liu@huawei.com>
2016-02-14 15:01:37 +00:00
Vishvananda Ishaya d2daa64e4b fix and skip tests for travis 2015-12-18 12:05:30 -08:00
Hubert Krauze 124b1f4449 Table driven test for Addr 2015-12-09 11:53:28 +01:00
Hubert Krauze f351153998 Remove FlagsMask from Addr struct 2015-12-09 11:30:21 +01:00
Hubert Krauze 87df994490 Add scope and flags support for netlink address 2015-11-26 12:47:18 +01:00
Vishvananda Ishaya c84dba1b12 Convert syscall.AF_INET to FAMILY_V4 2014-09-17 09:33:53 -07:00
Vishvananda Ishaya 8dab8b7462 Initial commit of netlink package 2014-08-31 20:34:46 -07:00