summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/vppinstance.go
diff options
context:
space:
mode:
authorMaros Ondrejicka <mondreji@cisco.com>2023-02-23 13:19:15 +0100
committerFlorin Coras <florin.coras@gmail.com>2023-02-27 17:26:41 +0000
commit40cba405c5c06a3dc086a55143cb3ffd1094597e (patch)
tree0263e3834a316d73863b1a6cc2da9beac916ac45 /extras/hs-test/vppinstance.go
parent9cb3e15c9f5b0eed296c3517c6475bd17a33441e (diff)
hs-test: refactor netconfig
This joins separate representations of veth and tap interfaces into a single struct. It removes the need for type interface and embedding which simplifies the code. Type: test Signed-off-by: Maros Ondrejicka <mondreji@cisco.com> Change-Id: I1b2c368bfe90a5bdfaaa9a5129c27d7d96f8fe3b
Diffstat (limited to 'extras/hs-test/vppinstance.go')
-rw-r--r--extras/hs-test/vppinstance.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/extras/hs-test/vppinstance.go b/extras/hs-test/vppinstance.go
index 2ecb4de3ecd..29b86d5adcb 100644
--- a/extras/hs-test/vppinstance.go
+++ b/extras/hs-test/vppinstance.go
@@ -172,10 +172,8 @@ func (vpp *VppInstance) waitForApp(appName string, timeout int) error {
}
func (vpp *VppInstance) createAfPacket(
- netInterface NetInterface,
+ veth *NetInterface,
) (interface_types.InterfaceIndex, error) {
- veth := netInterface.(*NetworkInterfaceVeth)
-
createReq := &af_packet.AfPacketCreateV2{
UseRandomHwAddr: true,
HostIfName: veth.Name(),
@@ -206,7 +204,7 @@ func (vpp *VppInstance) createAfPacket(
if veth.AddressWithPrefix() == (AddressWithPrefix{}) {
var err error
var ip4Address string
- if ip4Address, err = veth.addresser.NewIp4Address(veth.peerNetworkNumber); err == nil {
+ if ip4Address, err = veth.addresser.NewIp4Address(veth.Peer().networkNumber); err == nil {
veth.SetAddress(ip4Address)
} else {
return 0, err
@@ -255,15 +253,15 @@ func (vpp *VppInstance) addAppNamespace(
}
func (vpp *VppInstance) createTap(
- hostInterfaceName string,
- hostIp4Address IP4AddressWithPrefix,
- vppIp4Address AddressWithPrefix,
+ id uint32,
+ tap *NetInterface,
) error {
createTapReq := &tapv2.TapCreateV2{
+ ID: id,
HostIfNameSet: true,
- HostIfName: hostInterfaceName,
+ HostIfName: tap.Name(),
HostIP4PrefixSet: true,
- HostIP4Prefix: hostIp4Address,
+ HostIP4Prefix: tap.IP4AddressWithPrefix(),
}
createTapReply := &tapv2.TapCreateV2Reply{}
@@ -276,7 +274,7 @@ func (vpp *VppInstance) createTap(
addAddressReq := &interfaces.SwInterfaceAddDelAddress{
IsAdd: true,
SwIfIndex: createTapReply.SwIfIndex,
- Prefix: vppIp4Address,
+ Prefix: tap.Peer().AddressWithPrefix(),
}
addAddressReply := &interfaces.SwInterfaceAddDelAddressReply{}