Skip to content

Commit

Permalink
cni: move the PBL to punt when VCL is on
Browse files Browse the repository at this point in the history
This patch moves the PBL to the pod's VRF as it was previously
in the main VRF. This will enable pod to self communication
respecting the port mapping defined in the annotation.

When VCL is enabled on the pod, we add the PBL in the punt table
so that traffic is first looked up in VPP's session table, then
hits the port lookup in the PBL. This allows using all three
(memif,VCL,tuntap) for a single pod.

Signed-off-by: Nathan Skrzypczak <[email protected]>
  • Loading branch information
sknat authored and hedibouattour committed Oct 17, 2023
1 parent 90ffeaa commit 704bbbd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ test/vagrant/.vagrant

# macOS
.DS_Store
*.bkp

# build artefacts
calico-vpp-agent/version
Expand Down
19 changes: 10 additions & 9 deletions calico-vpp-agent/cni/network_vpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ func (s *Server) AddVppInterface(podSpec *storage.LocalPodSpec, doHostSideConf b
* ourselves in s.podInterfaceMap
*/
s.removeConflictingContainers(podSpec.ContainerIps, podSpec.NetworkName)

var swIfIndex uint32
var isL3 bool
stack := s.vpp.NewCleanupStack()
var vni uint32
err = s.checkAvailableBuffers(podSpec)
Expand Down Expand Up @@ -209,7 +210,7 @@ func (s *Server) AddVppInterface(podSpec *storage.LocalPodSpec, doHostSideConf b
goto err
}
} else {
swIfIndex, isL3 := podSpec.GetParamsForIfType(podSpec.DefaultIfType)
swIfIndex, isL3 = podSpec.GetParamsForIfType(podSpec.DefaultIfType)
if swIfIndex != types.InvalidID {
s.log.Infof("pod(add) Default routes to swIfIndex=%d isL3=%t", swIfIndex, isL3)
err = s.RoutePodInterface(podSpec, stack, swIfIndex, isL3)
Expand All @@ -219,14 +220,14 @@ func (s *Server) AddVppInterface(podSpec *storage.LocalPodSpec, doHostSideConf b
} else {
s.log.Warn("No default if type for pod")
}
}

swIfIndex, isL3 = podSpec.GetParamsForIfType(podSpec.PortFilteredIfType)
if swIfIndex != types.InvalidID {
s.log.Infof("pod(add) PBL routes to %d l3?:%t", swIfIndex, isL3)
err = s.RoutePblPortsPodInterface(podSpec, stack, swIfIndex, isL3)
if err != nil {
goto err
}
swIfIndex, isL3 = podSpec.GetParamsForIfType(podSpec.PortFilteredIfType)
if swIfIndex != types.InvalidID {
s.log.Infof("pod(add) PBL routes to %d l3?:%t", swIfIndex, isL3)
err = s.RoutePblPortsPodInterface(podSpec, stack, swIfIndex, isL3)
if err != nil {
goto err
}
}

Expand Down
10 changes: 7 additions & 3 deletions calico-vpp-agent/cni/network_vpp_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,19 @@ func (s *Server) RoutePblPortsPodInterface(podSpec *storage.LocalPodSpec, stack
})
}

// See docs/drawio/vrfs.drawio
client := types.PblClient{
ID: vpplink.InvalidID,
// TableId: podSpec.VrfId,
ID: vpplink.InvalidID,
TableId: podSpec.GetVrfId(vpplink.IpFamilyFromIPNet(containerIP)),
Addr: containerIP.IP,
Path: path,
PortRanges: portRanges,
}
if podSpec.EnableVCL {
client.TableId = common.PuntTableId
}

vrfId := podSpec.GetVrfId(vpplink.IpFamilyV4) // pbl only supports v4 ?
vrfId := podSpec.GetVrfId(vpplink.IpFamilyFromIPNet(containerIP)) // pbl only supports v4 ?
s.log.Infof("pod(add) PBL client for %s VRF %d", containerIP.IP, vrfId)
pblIndex, err := s.vpp.AddPblClient(&client)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions docs/drawio/vrfs.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="Electron" modified="2023-10-11T15:40:42.257Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/20.8.10 Chrome/106.0.5249.199 Electron/21.3.5 Safari/537.36" etag="J7iTVJT6-A_H6t-E5FFg" version="20.8.10" type="device"><diagram id="RxcxJ1UT-itXMrFT2446" name="archi">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b2pB7KfW2I54oN8Yj64AYRw50ujJccwh8yMdbSgJXK3WsDJoQyovOtxX5dPVy/vf7f73fno+nirz/97/8ub74C3vj1xbuz/OeIRmmZDr+fjAmiVGgu4gCBkSODFdZggkA+yH6hrFK11UnZPJ62PCO6NED880y4GoPiZz6PNeaMwuW0sqV72K+2IZVK8HtivaSqeE9AgNb2StycEXf71tirzXjC3i7SNGtOZxo+fZ+OcpC//D8=</diagram></mxfile>
Binary file added docs/drawio/vrfs.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 704bbbd

Please sign in to comment.