mirror of
https://github.com/vishvananda/netlink
synced 2025-03-25 04:26:51 +00:00
Add route get iif option
This commit is contained in:
parent
e838b0f0e0
commit
66ddd91f7d
@ -1150,6 +1150,7 @@ func deserializeRoute(m []byte) (Route, error) {
|
|||||||
// RouteGetOptions contains a set of options to use with
|
// RouteGetOptions contains a set of options to use with
|
||||||
// RouteGetWithOptions
|
// RouteGetWithOptions
|
||||||
type RouteGetOptions struct {
|
type RouteGetOptions struct {
|
||||||
|
Iif string
|
||||||
VrfName string
|
VrfName string
|
||||||
SrcAddr net.IP
|
SrcAddr net.IP
|
||||||
}
|
}
|
||||||
@ -1207,6 +1208,21 @@ func (h *Handle) RouteGetWithOptions(destination net.IP, options *RouteGetOption
|
|||||||
req.AddData(nl.NewRtAttr(unix.RTA_OIF, b))
|
req.AddData(nl.NewRtAttr(unix.RTA_OIF, b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(options.Iif) > 0 {
|
||||||
|
link, err := LinkByName(options.Iif)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
b = make([]byte, 4)
|
||||||
|
native = nl.NativeEndian()
|
||||||
|
)
|
||||||
|
native.PutUint32(b, uint32(link.Attrs().Index))
|
||||||
|
|
||||||
|
req.AddData(nl.NewRtAttr(unix.RTA_IIF, b))
|
||||||
|
}
|
||||||
|
|
||||||
if options.SrcAddr != nil {
|
if options.SrcAddr != nil {
|
||||||
var srcAddr []byte
|
var srcAddr []byte
|
||||||
if family == FAMILY_V4 {
|
if family == FAMILY_V4 {
|
||||||
|
Loading…
Reference in New Issue
Block a user