diff --git a/plugins/vpp/ifplugin/descriptor/interface_crud.go b/plugins/vpp/ifplugin/descriptor/interface_crud.go index 5b48b0a668..9b037b1299 100644 --- a/plugins/vpp/ifplugin/descriptor/interface_crud.go +++ b/plugins/vpp/ifplugin/descriptor/interface_crud.go @@ -580,6 +580,8 @@ func (d *InterfaceDescriptor) Retrieve(correlate []adapter.InterfaceKVWithMetada Vrf: intf.Interface.Vrf, IPAddresses: intf.Interface.IpAddresses, TAPHostIfName: tapHostIfName, + InternalName: intf.Meta.InternalName, + DevType: intf.Meta.DevType, } retrieved = append(retrieved, adapter.InterfaceKVWithMetadata{ Key: models.Key(intf.Interface), diff --git a/plugins/vpp/ifplugin/ifaceidx/ifaceidx.go b/plugins/vpp/ifplugin/ifaceidx/ifaceidx.go index b6e23869f2..9ba5ff6d20 100644 --- a/plugins/vpp/ifplugin/ifaceidx/ifaceidx.go +++ b/plugins/vpp/ifplugin/ifaceidx/ifaceidx.go @@ -63,6 +63,8 @@ type IfaceMetadata struct { Vrf uint32 IPAddresses []string // TODO: update from interfaceAddress descriptor with real IPs (not netalloc links) TAPHostIfName string /* host interface name set for the Linux-side of the TAP interface; empty for non-TAPs */ + InternalName string // internal VPP name + DevType string // device type } // GetIndex returns sw_if_index assigned to the interface. diff --git a/plugins/vpp/ifplugin/vppcalls/interface_handler_api.go b/plugins/vpp/ifplugin/vppcalls/interface_handler_api.go index 57fedd9902..f7b5f13f20 100644 --- a/plugins/vpp/ifplugin/vppcalls/interface_handler_api.go +++ b/plugins/vpp/ifplugin/vppcalls/interface_handler_api.go @@ -42,6 +42,7 @@ type InterfaceMeta struct { SupSwIfIndex uint32 `json:"sub_sw_if_index"` L2Address net.HardwareAddr `json:"l2_address"` InternalName string `json:"internal_name"` + DevType string `json:"dev_type"` IsAdminStateUp bool `json:"is_admin_state_up"` IsLinkStateUp bool `json:"is_link_state_up"` LinkDuplex uint32 `json:"link_duplex"` @@ -50,11 +51,14 @@ type InterfaceMeta struct { LinkSpeed uint32 `json:"link_speed"` SubID uint32 `json:"sub_id"` Tag string `json:"tag"` + // dhcp Dhcp *Dhcp `json:"dhcp"` + // vrf VrfIPv4 uint32 `json:"vrf_ipv4"` VrfIPv6 uint32 `json:"vrf_ipv6"` + // wmxnet3 Pci uint32 `json:"pci"` } diff --git a/plugins/vpp/ifplugin/vppcalls/vpp1908/dump_interface_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp1908/dump_interface_vppcalls.go index 64fd2ef339..4aec02f64c 100644 --- a/plugins/vpp/ifplugin/vppcalls/vpp1908/dump_interface_vppcalls.go +++ b/plugins/vpp/ifplugin/vppcalls/vpp1908/dump_interface_vppcalls.go @@ -95,14 +95,14 @@ func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppc return nil, fmt.Errorf("failed to dump interface: %v", err) } - ifaceName := strings.TrimRight(ifDetails.InterfaceName, "\x00") + internalName := strings.TrimRight(ifDetails.InterfaceName, "\x00") l2addr := net.HardwareAddr(ifDetails.L2Address[:ifDetails.L2AddressLength]) details := &vppcalls.InterfaceDetails{ Interface: &interfaces.Interface{ Name: strings.TrimRight(ifDetails.Tag, "\x00"), // the type may be amended later by further dumps - Type: guessInterfaceType(ifaceName), + Type: guessInterfaceType(internalName), Enabled: ifDetails.AdminUpDown > 0, PhysAddress: net.HardwareAddr(ifDetails.L2Address[:ifDetails.L2AddressLength]).String(), Mtu: getMtu(ifDetails.LinkMtu), @@ -111,7 +111,7 @@ func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppc SwIfIndex: ifDetails.SwIfIndex, SupSwIfIndex: ifDetails.SupSwIfIndex, L2Address: l2addr, - InternalName: ifaceName, + InternalName: internalName, IsAdminStateUp: uintToBool(ifDetails.AdminUpDown), IsLinkStateUp: uintToBool(ifDetails.LinkUpDown), LinkDuplex: uint32(ifDetails.LinkDuplex), @@ -140,18 +140,18 @@ func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppc // Fill name for physical interfaces (they are mostly without tag) switch details.Interface.Type { case interfaces.Interface_DPDK: - details.Interface.Name = ifaceName + details.Interface.Name = internalName case interfaces.Interface_AF_PACKET: details.Interface.Link = &interfaces.Interface_Afpacket{ Afpacket: &interfaces.AfpacketLink{ - HostIfName: strings.TrimPrefix(ifaceName, "host-"), + HostIfName: strings.TrimPrefix(internalName, "host-"), }, } } if details.Interface.Name == "" { // untagged interface - generate a logical name for it // (apart from local0 it will get removed by resync) - details.Interface.Name = untaggedIfPreffix + ifaceName + details.Interface.Name = untaggedIfPreffix + internalName } ifs[ifDetails.SwIfIndex] = details } diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_vppcalls.go index b8e80f8c78..7a9bbf0133 100644 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_vppcalls.go +++ b/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_vppcalls.go @@ -103,7 +103,8 @@ func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppc return nil, fmt.Errorf("failed to dump interface: %v", err) } - ifaceName := strings.TrimRight(ifDetails.InterfaceName, "\x00") + internalName := strings.TrimRight(ifDetails.InterfaceName, "\x00") + ifaceDevType := strings.TrimRight(ifDetails.InterfaceDevType, "\x00") physAddr := make(net.HardwareAddr, macLength) copy(physAddr, ifDetails.L2Address[:]) @@ -111,7 +112,7 @@ func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppc Interface: &ifs.Interface{ Name: strings.TrimRight(ifDetails.Tag, "\x00"), // the type may be amended later by further dumps - Type: guessInterfaceType(ifaceName), + Type: guessInterfaceType(internalName), Enabled: isAdminStateUp(ifDetails.Flags), PhysAddress: net.HardwareAddr(ifDetails.L2Address[:]).String(), Mtu: getMtu(ifDetails.LinkMtu), @@ -120,7 +121,8 @@ func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppc SwIfIndex: uint32(ifDetails.SwIfIndex), SupSwIfIndex: ifDetails.SupSwIfIndex, L2Address: physAddr, - InternalName: ifaceName, + InternalName: internalName, + DevType: ifaceDevType, IsAdminStateUp: isAdminStateUp(ifDetails.Flags), IsLinkStateUp: isLinkStateUp(ifDetails.Flags), LinkDuplex: uint32(ifDetails.LinkDuplex), @@ -149,18 +151,18 @@ func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppc // Fill name for physical interfaces (they are mostly without tag) switch details.Interface.Type { case ifs.Interface_DPDK: - details.Interface.Name = ifaceName + details.Interface.Name = internalName case ifs.Interface_AF_PACKET: details.Interface.Link = &ifs.Interface_Afpacket{ Afpacket: &ifs.AfpacketLink{ - HostIfName: strings.TrimPrefix(ifaceName, "host-"), + HostIfName: strings.TrimPrefix(internalName, "host-"), }, } } if details.Interface.Name == "" { // untagged interface - generate a logical name for it // (apart from local0 it will get removed by resync) - details.Interface.Name = untaggedIfPreffix + ifaceName + details.Interface.Name = untaggedIfPreffix + internalName } interfaces[uint32(ifDetails.SwIfIndex)] = details } diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2005/dump_interface_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2005/dump_interface_vppcalls.go index e2b53b509e..46680e3935 100644 --- a/plugins/vpp/ifplugin/vppcalls/vpp2005/dump_interface_vppcalls.go +++ b/plugins/vpp/ifplugin/vppcalls/vpp2005/dump_interface_vppcalls.go @@ -103,7 +103,8 @@ func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppc return nil, fmt.Errorf("failed to dump interface: %v", err) } - ifaceName := strings.TrimRight(ifDetails.InterfaceName, "\x00") + internalName := strings.TrimRight(ifDetails.InterfaceName, "\x00") + ifaceDevType := strings.TrimRight(ifDetails.InterfaceDevType, "\x00") physAddr := make(net.HardwareAddr, macLength) copy(physAddr, ifDetails.L2Address[:]) @@ -111,7 +112,7 @@ func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppc Interface: &ifs.Interface{ Name: strings.TrimRight(ifDetails.Tag, "\x00"), // the type may be amended later by further dumps - Type: guessInterfaceType(ifaceName), + Type: guessInterfaceType(ifaceDevType, internalName), Enabled: isAdminStateUp(ifDetails.Flags), PhysAddress: net.HardwareAddr(ifDetails.L2Address[:]).String(), Mtu: getMtu(ifDetails.LinkMtu), @@ -120,7 +121,8 @@ func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppc SwIfIndex: uint32(ifDetails.SwIfIndex), SupSwIfIndex: ifDetails.SupSwIfIndex, L2Address: physAddr, - InternalName: ifaceName, + InternalName: internalName, + DevType: ifaceDevType, IsAdminStateUp: isAdminStateUp(ifDetails.Flags), IsLinkStateUp: isLinkStateUp(ifDetails.Flags), LinkDuplex: uint32(ifDetails.LinkDuplex), @@ -149,18 +151,18 @@ func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppc // Fill name for physical interfaces (they are mostly without tag) switch details.Interface.Type { case ifs.Interface_DPDK: - details.Interface.Name = ifaceName + details.Interface.Name = internalName case ifs.Interface_AF_PACKET: details.Interface.Link = &ifs.Interface_Afpacket{ Afpacket: &ifs.AfpacketLink{ - HostIfName: strings.TrimPrefix(ifaceName, "host-"), + HostIfName: strings.TrimPrefix(internalName, "host-"), }, } } if details.Interface.Name == "" { // untagged interface - generate a logical name for it // (apart from local0 it will get removed by resync) - details.Interface.Name = untaggedIfPreffix + ifaceName + details.Interface.Name = untaggedIfPreffix + internalName } interfaces[uint32(ifDetails.SwIfIndex)] = details } @@ -928,7 +930,7 @@ func dhcpAddressToString(address vpp_dhcp.Address, maskWidth uint32, isIPv6 bool // guessInterfaceType attempts to guess the correct interface type from its internal name (as given by VPP). // This is required mainly for those interface types, that do not provide dump binary API, // such as loopback of af_packet. -func guessInterfaceType(ifName string) ifs.Interface_Type { +func guessInterfaceType(ifDevType, ifName string) ifs.Interface_Type { switch { case strings.HasPrefix(ifName, "loop"), strings.HasPrefix(ifName, "local"):