Skip to content

Commit 2b45ac3

Browse files
fgschwanrastislavs
authored andcommitted
SRv6 implementation of SFC renderer (#1663)
* temporal updated of vpp-agent dependency to get some fixes Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech> * added implementation of SFC renderer using SRv6 Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech> * vendor cleanup Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech> * fix for new version of helm Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech> * finished implementation of additional features of SRv6 SFC renderer Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech> * fixed bad caching of pod main IP Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech> * dropped GetNetworkVrfID in ipnet API in favour of GetOrAllocateVrfID Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech> * fixed helm version for Vagrant Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech> * update of helm and reverting of template fixes for previous broken helm version Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech> * reverted vendor changes that are not needed to stay in sync with output of dep tool Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech> * IPAM is supposed to handle external interface IP updates Signed-off-by: Jakub <jakub.gallo@pantheon.tech> * Initialize external interface IP info on Resync (move init at correct place) Signed-off-by: Jakub <jakub.gallo@pantheon.tech> * Correction of external interface custom network handling Signed-off-by: Jakub <jakub.gallo@pantheon.tech> * updated IPAM API godoc Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech> * fixed initial resync errors by removal of remote pod IP caching for pods outside of pod networks (i.e. host network pods) Signed-off-by: Filip Gschwandtner <filip.gschwandtner@pantheon.tech>
1 parent c8826f3 commit 2b45ac3

32 files changed

+3193
-371
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ test:
9797
go test ./plugins/crd/validator/l2 -tags="${GO_BUILD_TAGS}"
9898
go test ./plugins/crd/validator/l3 -tags="${GO_BUILD_TAGS}"
9999
#go test ./plugins/crd/cache -tags="${GO_BUILD_TAGS}"
100+
go test ./plugins/sfc/renderer/srv6 -tags="${GO_BUILD_TAGS}"
100101

101102
# Run tests with race
102103
test-race:

docs/dev-guide/SFC.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,40 @@ the following components:
3232
![SFC Plugin](sfc/SFC-plugin-layers.png)
3333

3434

35+
## SRv6 Renderer
36+
The SRv6 renderer uses SRv6 components supported in VPP to create SFC chain. The SFC chain
37+
rendered with the SRv6 renderer always starts with SRv6 steering. The steering forwards the packet
38+
to the SRv6 policy that determinates the rest of the packet route by using the SRv6 localsid's SIDs.
39+
For the inner links of chain are always used LocalSID with the End.AD end function (dynamic SR-proxy).
40+
The end link of the SFC chain is localsid with End.DX2/End.DX4/End.DX6 end function depending on the
41+
end link interface (L2,L3 IPv4/IPV6).
42+
43+
The SRv6 renderer supports:
44+
- [x] Support for L2, L3 IPv4 and L3 IPv6 interfaces (all interfaces going in/out of VPP and that are
45+
meant for SFC chain must by of the same Layer and address family)
46+
- [x] SFC chain on multiple nodes
47+
- [x] Pod rescheduling (on the same or different node) with already set SFC chain
48+
- [x] Using 1 or 2 interfaces for communication between SR-Proxy and SR-unaware inner link
49+
- [x] Basic multipaths: multiple pods per inner link of the SFC chain are used to create separate
50+
paths that is loadbalances by SRv6 policy (1 inner pod can be part of only one path)
51+
- [x] Support for custom networks (custom pod VRF tables) (supported only L3 IPv6 interfaces because
52+
L2 implementation is the same as when using stub interfaces and L3 IPv4 implementation would bypass
53+
almost all custom networks due to the IPv6 nature of SRv6)
54+
- [x] Support for external interfaces(i.e. DPDK) for first and last link of SFC chain
55+
56+
The SRv6 doesn't support:
57+
- [ ] Bidirectional feature of SFC chain. The SRv6-rendered SFC chain is currently always unidirectional.
58+
- [ ] Extended multipaths: multipaths with more complicated logic how to create path from pods
59+
selected for SFC chain
60+
- [ ] Start and end link of SFC chain on the same node (problem with IP collision in the same VRF table)
61+
62+
63+
3564
## SFC implementation progress
3665
**SFC in Contiv-VPP is still work in progress**. The progress is tracked in the following list:
3766

3867
- [X] define service function chain CRD API ([example](../../k8s/crd/servicefunctionchain.yaml))
3968
- [x] SFC CRD reflector on KSR
4069
- [x] SFC plugin skeleton + SFC Processor
70+
- [x] SRv6 renderer (for supported features see)
4171
- [ ] l2xconn renderer **(in progress)**
42-
- [ ] SRv6 renderer **(assigned)**

k8s/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ manually or using the [helm options](contiv-vpp/README.md#configuration):
5959
- `useSRv6ForServices`: use SRv6(IPv6) for k8s service (this handles only packet from service client to backend, but
6060
in case of response packet, other networking settings handle it because it is normal pod/host-to-pod/host connectivity)
6161
- `useDX6ForSrv6NodetoNodeTransport`: enable usage of DX6 instead of DT6 for node-to-node communication (only for pod-to-pod case with full IPv6 environment), default is false
62+
- `useSRv6ForServiceFunctionChaining`: use SRv6(IPv6) for Service Function Chaining in k8s service
6263
- `useTAPInterfaces`: use TAP interfaces instead of VETHs for Pod-to-VPP and VPP-to-Host interconnection
6364
- `tAPInterfaceVersion`: select `1` to use the standard VPP TAP interface or `2`
6465
for a faster, virtio-based, VPP TAPv2 interface (default);
@@ -93,14 +94,20 @@ manually or using the [helm options](contiv-vpp/README.md#configuration):
9394
- `nodeToNodeHostLocalSIDSubnetCIDR`: subnet applied to node IP to get unique sid for SRv6 Localsid that is the only segment in node-to-node Srv6 tunnel. Traffic from tunnel continues routing by looking into main VRF table (DT6 end function of localsid)
9495
- `nodeToNodePodPolicySIDSubnetCIDR`: subnet applied to node IP to get unique bsid for SRv6 policy that defines path in node-to-node Srv6 tunnel as mentioned in `srv6NodeToNodePodLocalSIDSubnetCIDR`
9596
- `nodeToNodeHostPolicySIDSubnetCIDR`: subnet applied to node IP to get unique bsid for SRv6 policy that defines path in node-to-node Srv6 tunnel as mentioned in `srv6NodeToNodeHostLocalSIDSubnetCIDR`.
97+
- `sfcPolicyBSIDSubnetCIDR`: subnet applied to SFC ID(trimmed hash of SFC name) to get unique binding sid for SRv6 policy used in SFC
98+
- `sfcServiceFunctionSIDSubnetCIDR`: subnet applied to combination of SFC ID(trimmed hash of SFC name) and service function pod IP address to get unique sid for SRv6 Localsid referring to SFC service function
99+
- `sfcEndLocalSIDSubnetCIDR`: subnet applied to the IP address of last link of SFC to get unique sid for last localsid in the segment routing path representing SFC chain
100+
- `sfcIDLengthUsedInSidForServiceFunction`: length(in bits) of SFC ID(trimmed hash of SFC name) that should be used by computing SFC ServiceFunction localsid SID. A hash is computed from SFC name, trimmed by length (this setting) and used in computation of SFC ServiceFunction localsid SID (SID=prefix from sfcServiceFunctionSIDSubnetCIDR + trimmed hash of SFC name + service function pod IP address).
96101

97102
Default config values for SRv6 SID/BSID subnets follow these rules to gain more clarity in debugging/maintaining/adding new functionality(adding new sids/bsids):
98103
- 8fff::/16 = service policy
104+
- 8eee::/16 = sfc policy
99105
- 8\<XYZ\>::/16 = policy for node-to-node communication ending in locasid with SID 9\<XYZ\>::/16
100106
- 9000::/16 = localsid with end function End
101107
- 9100::/16 = localsid with end function End.DX2 (crossconnect target could be found out from non-prefix part of SID (target interface leads to target pod/node and sid is created from IP of that pod/node))
102108
- 9200::/16 = localsid with end function End.DX4 (crossconnect target is known as in DX2 case)
103-
- 9300::/16 = localsid with end function End.DX6 (crossconnect target is known as in DX2 case)
109+
- 9300::/16 = localsid with end function End.DX6 (crossconnect target is known as in DX2 case), no SFC usage
110+
- 9310::/16 = localsid with end function End.DX6 (crossconnect target is known as in DX2 case), SFC usage
104111
- 94\<YZ\>::/16 = localsid with end function End.DT4 (\<YZ\> is id of target ipv4 VRF table)
105112
- 95\<YZ\>::/16 = localsid with end function End.DT6 (\<YZ\> is id of target ipv6 VRF table)
106113
- 9600::/16 = localsid with end function End.AD (crossconnect target is known as in DX2 case)

k8s/contiv-vpp-arm64.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ data:
2424
contiv.conf: |-
2525
nodeToNodeTransport: vxlan
2626
useSRv6ForServices: false
27+
useSRv6ForServiceFunctionChaining: false
2728
useDX6ForSrv6NodetoNodeTransport: false
2829
useTAPInterfaces: true
2930
tapInterfaceVersion: 2
@@ -57,6 +58,10 @@ data:
5758
nodeToNodeHostLocalSIDSubnetCIDR: 9500::/16
5859
nodeToNodePodPolicySIDSubnetCIDR: 8501::/16
5960
nodeToNodeHostPolicySIDSubnetCIDR: 8500::/16
61+
sfcPolicyBSIDSubnetCIDR: 8eee::/16
62+
sfcServiceFunctionSIDSubnetCIDR: 9600::/16
63+
sfcEndLocalSIDSubnetCIDR: 9310::/16
64+
sfcIDLengthUsedInSidForServiceFunction: 16
6065
controller.conf: |
6166
enableRetry: true
6267
delayRetry: 1000000000

k8s/contiv-vpp.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ data:
2424
contiv.conf: |-
2525
nodeToNodeTransport: vxlan
2626
useSRv6ForServices: false
27+
useSRv6ForServiceFunctionChaining: false
2728
useDX6ForSrv6NodetoNodeTransport: false
2829
useTAPInterfaces: true
2930
tapInterfaceVersion: 2
@@ -57,6 +58,10 @@ data:
5758
nodeToNodeHostLocalSIDSubnetCIDR: 9500::/16
5859
nodeToNodePodPolicySIDSubnetCIDR: 8501::/16
5960
nodeToNodeHostPolicySIDSubnetCIDR: 8500::/16
61+
sfcPolicyBSIDSubnetCIDR: 8eee::/16
62+
sfcServiceFunctionSIDSubnetCIDR: 9600::/16
63+
sfcEndLocalSIDSubnetCIDR: 9310::/16
64+
sfcIDLengthUsedInSidForServiceFunction: 16
6065
controller.conf: |
6166
enableRetry: true
6267
delayRetry: 1000000000

k8s/contiv-vpp/Chart.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ description: Deploys Contiv VPP networking
44
icon: https://contivpp.io/img/logo.png
55
home: https://contivpp.io/
66
version: v3.3.2
7+
apiVersion: v1

k8s/contiv-vpp/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Parameter | Description | Default
6262
--------- | ----------- | -------
6363
`contiv.nodeToNodeTransport` | Transportation used for node-to-node communication | `vxlan`
6464
`contiv.useSRv6ForServices` | Enable usage of SRv6 for k8s service | `false`
65+
`contiv.useSRv6ForServiceFunctionChaining` | Enable use SRv6(IPv6) for Service Function Chaining in k8s service | `false`
6566
`contiv.useDX6ForSrv6NodetoNodeTransport` | Enable usage of DX6 instead of DT6 for node-to-node communication (only for pod-to-pod case with full IPv6 environment) | `false`
6667
`contiv.mtuSize` | MTU Size | 1450
6768
`contiv.useTAPInterfaces` | Enable TAP interfaces | `True`
@@ -88,6 +89,18 @@ Parameter | Description | Default
8889
`contiv.ipamConfig.nodeInterconnectCIDR` | Node interconnect CIDR, uses DHCP if empty | `""`
8990
`contiv.ipamConfig.serviceCIDR` | Service CIDR | `""`
9091
`contiv.ipamConfig.defaultGateway` | Default gateway for all nodes (can be overridden by a nodeconfig)| `""`
92+
`contiv.ipamConfig.srv6.servicePolicyBSIDSubnetCIDR` | Subnet applied to lowest k8s service IP to get unique (per service,per node) binding sid for SRv6 policy | `8fff::/16`
93+
`contiv.ipamConfig.srv6.servicePodLocalSIDSubnetCIDR` | Subnet applied to k8s service local pod backend IP to get unique sid for SRv6 Localsid referring to local pod beckend using DX6 end function | `9300::/16`
94+
`contiv.ipamConfig.srv6.serviceHostLocalSIDSubnetCIDR` | Subnet applied to k8s service host pod backend IP to get unique sid for SRv6 Localsid referring to local host beckend using DX6 end function | `9300::/16`
95+
`contiv.ipamConfig.srv6.serviceNodeLocalSIDSubnetCIDR` | Subnet applied to node IP to get unique sid for SRv6 Localsid that is intermediate segment routing to other nodes in Srv6 segment list (used in k8s services) | `9000::/16`
96+
`contiv.ipamConfig.srv6.nodeToNodePodLocalSIDSubnetCIDR` | Subnet applied to node IP to get unique sid for SRv6 Localsid that is the only segment in node-to-node Srv6 tunnel. Traffic from tunnel continues routing by looking into pod VRF table (DT6 end function of localsid) | `9501::/16`
97+
`contiv.ipamConfig.srv6.nodeToNodeHostLocalSIDSubnetCIDR` | Subnet applied to node IP to get unique sid for SRv6 Localsid that is the only segment in node-to-node Srv6 tunnel. Traffic from tunnel continues routing by looking into main VRF table (DT6 end function of localsid) | `9500::/16`
98+
`contiv.ipamConfig.srv6.nodeToNodePodPolicySIDSubnetCIDR` | Subnet applied to node IP to get unique bsid for SRv6 policy that defines path in node-to-node Srv6 tunnel as mentioned in `srv6NodeToNodePodLocalSIDSubnetCIDR` | `8501::/16`
99+
`contiv.ipamConfig.srv6.nodeToNodeHostPolicySIDSubnetCIDR` | Subnet applied to node IP to get unique bsid for SRv6 policy that defines path in node-to-node Srv6 tunnel as mentioned in `srv6NodeToNodeHostLocalSIDSubnetCIDR`. | `8500::/16`
100+
`contiv.ipamConfig.srv6.sfcPolicyBSIDSubnetCIDR` | Subnet applied to SFC ID(trimmed hash of SFC name) to get unique binding sid for SRv6 policy used in SFC | `8eee::/16`
101+
`contiv.ipamConfig.srv6.sfcServiceFunctionSIDSubnetCIDR` | Subnet applied to combination of SFC ID(trimmed hash of SFC name) and service function pod IP address to get unique sid for SRv6 Localsid referring to SFC service function | `9600::/16`
102+
`contiv.ipamConfig.srv6.sfcEndLocalSIDSubnetCIDR` | Subnet applied to the IP address of last link of SFC to get unique sid for last localsid in the segment routing path representing SFC chain | `9310::/16`
103+
`contiv.ipamConfig.srv6.sfcIDLengthUsedInSidForServiceFunction` | Length(in bits) of SFC ID(trimmed hash of SFC name) that should be used by computing SFC ServiceFunction localsid SID. A hash is computed from SFC name, trimmed by length (this setting) and used in computation of SFC ServiceFunction localsid SID (SID=prefix from sfcServiceFunctionSIDSubnetCIDR + trimmed hash of SFC name + service function pod IP address). | `16`
91104
`contiv.nodeConfig.*` | List of node configs, see example section in values.yaml | `""`
92105
`contiv.vswitch.useSocketVPPConnection` | use unix domain socket for connection to VPP | `false`
93106
`contiv.vswitch.defineMemoryLimits` | define memory requests & limits for vswitch container | `true`

k8s/contiv-vpp/templates/vpp.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ data:
3333
contiv.conf: |-
3434
nodeToNodeTransport: {{ .Values.contiv.nodeToNodeTransport }}
3535
useSRv6ForServices: {{ .Values.contiv.useSRv6ForServices }}
36+
useSRv6ForServiceFunctionChaining: {{ .Values.contiv.useSRv6ForServiceFunctionChaining}}
3637
useDX6ForSrv6NodetoNodeTransport: {{ .Values.contiv.useDX6ForSrv6NodetoNodeTransport }}
3738
useTAPInterfaces: {{ .Values.contiv.useTAPInterfaces }}
3839
tapInterfaceVersion: {{ .Values.contiv.tapInterfaceVersion }}
@@ -98,6 +99,10 @@ data:
9899
nodeToNodeHostLocalSIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.nodeToNodeHostLocalSIDSubnetCIDR }}
99100
nodeToNodePodPolicySIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.nodeToNodePodPolicySIDSubnetCIDR }}
100101
nodeToNodeHostPolicySIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.nodeToNodeHostPolicySIDSubnetCIDR }}
102+
sfcPolicyBSIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.sfcPolicyBSIDSubnetCIDR}}
103+
sfcServiceFunctionSIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.sfcServiceFunctionSIDSubnetCIDR}}
104+
sfcEndLocalSIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.sfcEndLocalSIDSubnetCIDR}}
105+
sfcIDLengthUsedInSidForServiceFunction: {{ .Values.contiv.ipamConfig.srv6.sfcIDLengthUsedInSidForServiceFunction}}
101106
{{- if .Values.contiv.nodeConfig }}
102107
nodeConfig:
103108
{{- range .Values.contiv.nodeConfig }}

k8s/contiv-vpp/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
contiv:
33
nodeToNodeTransport: "vxlan" # possible values: "vxlan", "srv6", "nooverlay"
44
useSRv6ForServices: false
5+
useSRv6ForServiceFunctionChaining: false
56
useDX6ForSrv6NodetoNodeTransport: false
67
useTAPInterfaces: true
78
tapInterfaceVersion: 2
@@ -68,6 +69,10 @@ contiv:
6869
nodeToNodeHostLocalSIDSubnetCIDR: 9500::/16
6970
nodeToNodePodPolicySIDSubnetCIDR: 8501::/16
7071
nodeToNodeHostPolicySIDSubnetCIDR: 8500::/16
72+
sfcPolicyBSIDSubnetCIDR: 8eee::/16
73+
sfcServiceFunctionSIDSubnetCIDR: 9600::/16
74+
sfcEndLocalSIDSubnetCIDR: 9310::/16
75+
sfcIDLengthUsedInSidForServiceFunction: 16
7176
logs:
7277
defaultLevel: debug
7378

mock/ipnet/ipnet_mock.go

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,25 @@ const (
3131
type MockIPNet struct {
3232
sync.Mutex
3333

34-
podIf map[podmodel.ID]string
35-
hostIPs []net.IP
36-
nodeIP *net.IPNet
37-
hostInterconnect string
38-
vxlanBVIIfName string
39-
vniID uint32
40-
vrfID uint32
34+
podIf map[podmodel.ID]string
35+
networkToVRFID map[string]uint32
36+
podInterfaceToNetwork map[string]string
37+
externalInterfaceToNetwork map[string]string
38+
hostIPs []net.IP
39+
nodeIP *net.IPNet
40+
hostInterconnect string
41+
vxlanBVIIfName string
42+
vniID uint32
4143
}
4244

4345
// NewMockIPNet is a constructor for MockIPNet.
4446
func NewMockIPNet() *MockIPNet {
45-
return &MockIPNet{podIf: make(map[podmodel.ID]string)}
47+
return &MockIPNet{
48+
podIf: make(map[podmodel.ID]string),
49+
networkToVRFID: make(map[string]uint32),
50+
podInterfaceToNetwork: make(map[string]string),
51+
externalInterfaceToNetwork: make(map[string]string),
52+
}
4653
}
4754

4855
// SetPodIfName allows to create a fake association between a pod and an interface.
@@ -74,16 +81,34 @@ func (mn *MockIPNet) SetHostIPs(ips []net.IP) {
7481
mn.hostIPs = ips
7582
}
7683

84+
// SetGetPodCustomIfNetworkName sets network name that pod custom interface belongs to.
85+
func (mn *MockIPNet) SetGetPodCustomIfNetworkName(podID podmodel.ID, ifName string, networkName string) {
86+
mn.podInterfaceToNetwork[fmt.Sprintf("%s/%s", podID.String(), ifName)] = networkName
87+
}
88+
89+
// SetGetExternalIfNetworkName sets network name that external interface belongs to.
90+
func (mn *MockIPNet) SetGetExternalIfNetworkName(ifName string, networkName string) {
91+
mn.externalInterfaceToNetwork[ifName] = networkName
92+
}
93+
94+
// SetNetworkVrfID sets VRF table ID to network name that it should belong to.
95+
func (mn *MockIPNet) SetNetworkVrfID(networkName string, vrfID uint32) {
96+
mn.networkToVRFID[networkName] = vrfID
97+
}
98+
7799
// GetPodIfNames returns pod's interface name as set previously using SetPodIfName.
78-
func (mn *MockIPNet) GetPodIfNames(podNamespace string, podName string) (vppIfName, linuxIfName, loopIfName string, exists bool) {
100+
func (mn *MockIPNet) GetPodIfNames(podNamespace string, podName string) (vppIfName, linuxIfName,
101+
loopIfName string, exists bool) {
79102
vppIfName, exists = mn.podIf[podmodel.ID{Name: podName, Namespace: podNamespace}]
80103
return vppIfName, "", mn.GetPodLoopIfName(podNamespace, podName), exists
81104
}
82105

83-
// GetPodCustomIfName looks up logical interface name that corresponds to the custom interface
106+
// GetPodCustomIfNames looks up logical interface name that corresponds to the custom interface
84107
// with specified name and type associated with the given local pod name + namespace.
85-
func (mn *MockIPNet) GetPodCustomIfName(podNamespace, podName, customIfName string) (ifName string, exists bool) {
86-
return "", false
108+
func (mn *MockIPNet) GetPodCustomIfNames(podNamespace, podName, customIfName string) (ifName string,
109+
linuxIfName string, exists bool) {
110+
//return "", linuxIfName, false
111+
return customIfName, customIfName, true
87112
}
88113

89114
// GetExternalIfName returns logical name that corresponds to the specified external interface name and VLAN ID.
@@ -94,6 +119,7 @@ func (mn *MockIPNet) GetExternalIfName(extIfName string, vlan uint32) (ifName st
94119
return fmt.Sprintf("%s.%d", extIfName, vlan)
95120
}
96121

122+
// GetPodLoopIfName computes logical name of loop interface for given pod
97123
func (mn *MockIPNet) GetPodLoopIfName(podNamespace string, podName string) string {
98124
return podLinuxLoopLogicalNamePrefix + "-" + podName + "-" + podNamespace
99125
}
@@ -154,10 +180,22 @@ func (mn *MockIPNet) ReleaseVxlanVNI(networkName string) (err error) {
154180
// GetOrAllocateVrfID returns the allocated VRF ID number for the given network.
155181
// Allocates a new VRF ID if not already allocated.
156182
func (mn *MockIPNet) GetOrAllocateVrfID(networkName string) (vrf uint32, err error) {
157-
return mn.vrfID, err
183+
return mn.networkToVRFID[networkName], err
158184
}
159185

160186
// ReleaseVrfID releases the allocated VRF ID number for the given network.
161187
func (mn *MockIPNet) ReleaseVrfID(networkName string) (err error) {
162188
return nil
163189
}
190+
191+
// GetPodCustomIfNetworkName returns the name of custom network which should contain given
192+
// pod custom interface or error otherwise. This supports both type of pods, remote and local
193+
func (mn *MockIPNet) GetPodCustomIfNetworkName(podID podmodel.ID, ifName string) (string, error) {
194+
return mn.podInterfaceToNetwork[fmt.Sprintf("%s/%s", podID.String(), ifName)], nil
195+
}
196+
197+
// GetExternalIfNetworkName returns the name of custom network which should contain given
198+
// external interface or error otherwise.
199+
func (mn *MockIPNet) GetExternalIfNetworkName(ifName string) (string, error) {
200+
return mn.externalInterfaceToNetwork[ifName], nil
201+
}

mock/podmanager/podmanager_mock.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func (m *MockPodManager) AddRemotePod(pod *podmanager.Pod) {
6363
// DeletePod allows to simulate DeletePod event.
6464
func (m *MockPodManager) DeletePod(podID podmodel.ID) *podmanager.DeletePod {
6565
delete(m.localPods, podID)
66+
delete(m.pods, podID)
6667
return &podmanager.DeletePod{
6768
Pod: podID,
6869
}

0 commit comments

Comments
 (0)