mirror of
https://github.com/vishvananda/netlink
synced 2025-01-03 21:42:03 +00:00
Adds vrf slave link slave data parse
This commit is contained in:
parent
a3836f0b5d
commit
af1e63ea7b
8
link.go
8
link.go
@ -960,6 +960,14 @@ func (b *BondSlave) SlaveType() string {
|
||||
return "bond"
|
||||
}
|
||||
|
||||
type VrfSlave struct {
|
||||
Table uint32
|
||||
}
|
||||
|
||||
func (v *VrfSlave) SlaveType() string {
|
||||
return "vrf"
|
||||
}
|
||||
|
||||
// Geneve devices must specify RemoteIP and ID (VNI) on create
|
||||
// https://github.com/torvalds/linux/blob/47ec5303d73ea344e84f46660fff693c57641386/drivers/net/geneve.c#L1209-L1223
|
||||
type Geneve struct {
|
||||
|
@ -1783,7 +1783,10 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
|
||||
switch slaveType {
|
||||
case "bond":
|
||||
linkSlave = &BondSlave{}
|
||||
case "vrf":
|
||||
linkSlave = &VrfSlave{}
|
||||
}
|
||||
|
||||
case nl.IFLA_INFO_SLAVE_DATA:
|
||||
switch slaveType {
|
||||
case "bond":
|
||||
@ -1792,6 +1795,12 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
|
||||
return nil, err
|
||||
}
|
||||
parseBondSlaveData(linkSlave, data)
|
||||
case "vrf":
|
||||
data, err := nl.ParseRouteAttr(info.Value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
parseVrfSlaveData(linkSlave, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2414,6 +2423,16 @@ func parseBondSlaveData(slave LinkSlave, data []syscall.NetlinkRouteAttr) {
|
||||
}
|
||||
}
|
||||
|
||||
func parseVrfSlaveData(slave LinkSlave, data []syscall.NetlinkRouteAttr) {
|
||||
vrfSlave := slave.(*VrfSlave)
|
||||
for i := range data {
|
||||
switch data[i].Attr.Type {
|
||||
case nl.IFLA_BOND_SLAVE_STATE:
|
||||
vrfSlave.Table = native.Uint32(data[i].Value[0:4])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func parseIPVlanData(link Link, data []syscall.NetlinkRouteAttr) {
|
||||
ipv := link.(*IPVlan)
|
||||
for _, datum := range data {
|
||||
|
Loading…
Reference in New Issue
Block a user