Commit Graph

31 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
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
tcely
f5a6f697a5 Calculate the broadcast address
This is like "ip addr add 127.0.0.1/8 broadcast +" and prevents interfaces without broadcast addresses.

Configuring the IP and netmask, but not the broadcast address leaves many applications in a broken state on Linux interfaces.
2017-08-08 08:43:08 -07:00
Pengfei Ni
1e045880fb Get broadcast addr in AddrList
Signed-off-by: Pengfei Ni <feiskyer@gmail.com>
2017-05-02 09:48:45 -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
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
kishiguro
6b895203a7 Broadcast address can be specified when adding address. 2017-02-02 13:05:14 -08:00
JC Martin
9438c6ff27 Add support for VTI and IPIP 2016-11-22 17:06:50 -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
Alessandro Boch
259a962435 Properly pass IP address flags (#121)
- during ip address configuration

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-05-12 10:51:33 -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
Everton Marques
7f8533eaaf Filter address family correctly in AddrList() based on message family. 2016-03-22 21:46:16 -03:00
Everton Marques
148ac55d0a Fix return of address family in parseAddr helper.
I broke return of family in commit 9462941794
2016-03-21 14:14:59 -03:00
Everton Marques
988716e658 Return correct underlying error. 2016-03-18 18:08:51 -03:00
Everton Marques
9462941794 Move common code from AddrList,AddrSubscribe into new helper func parseAddr. 2016-03-18 17:44:53 -03:00
Everton Marques
0499fc4776 Merge remote-tracking branch 'upstream/master' 2016-03-18 14:45:31 -03:00
Liu Hua
89b71e9bbf force AddList to get rid of unexpected information
Signed-off-by: Liu Hua <sdu.liu@huawei.com>
2016-02-14 14:04:38 +00:00
Everton Marques
afa33d45e9 AddrSubscribe(): receive updates for changes in link addresses. 2016-01-28 17:27:24 -02: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
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
Eugene Yakubovich
efb2ec546f prefer IFA_LOCAL address when dumping addresses
IFA_LOCAL and IFA_ADDRESS are the same for bcast interfaces,
however for point-to-point links, IFA_ADDRESS is the remote
address while IFA_LOCAL is the interface address.
2015-05-09 18:37:25 -07:00
xuzhaokui
c3cc0540f8 fix addradd docs 2014-12-01 11:31:00 +08: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
349cca1850 Formatting cleanup 2014-09-15 17:06:08 -07:00
Vishvananda Ishaya
0e7e6d493a Convert addr and xfrm to use IPNet pointers 2014-09-07 11:27:46 -07:00
Vishvananda Ishaya
8dab8b7462 Initial commit of netlink package 2014-08-31 20:34:46 -07:00