Skip to content

Commit

Permalink
Retrieve VLAN and VNI when listing neighbour
Browse files Browse the repository at this point in the history
  • Loading branch information
lebauce authored and aboch committed Nov 27, 2017
1 parent fad79cb commit 9ce265f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions neigh.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type Neigh struct {
IP net.IP
HardwareAddr net.HardwareAddr
LLIPAddr net.IP //Used in the case of NHRP
Vlan int
VNI int
}

// String returns $ip/$hwaddr $label
Expand Down
14 changes: 14 additions & 0 deletions neigh_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ func neighHandle(neigh *Neigh, req *nl.NetlinkRequest) error {
req.AddData(hwData)
}

if neigh.Vlan != 0 {
vlanData := nl.NewRtAttr(NDA_VLAN, nl.Uint16Attr(uint16(neigh.Vlan)))
req.AddData(vlanData)
}

if neigh.VNI != 0 {
vniData := nl.NewRtAttr(NDA_VNI, nl.Uint32Attr(uint32(neigh.VNI)))
req.AddData(vniData)
}

_, err := req.Execute(unix.NETLINK_ROUTE, 0)
return err
}
Expand Down Expand Up @@ -268,6 +278,10 @@ func NeighDeserialize(m []byte) (*Neigh, error) {
} else {
neigh.HardwareAddr = net.HardwareAddr(attr.Value)
}
case NDA_VLAN:
neigh.Vlan = int(native.Uint16(attr.Value[0:2]))
case NDA_VNI:
neigh.VNI = int(native.Uint32(attr.Value[0:4]))
}
}

Expand Down

0 comments on commit 9ce265f

Please sign in to comment.