Skip to content

Commit a950c11

Browse files
hedibouattoursknat
authored andcommitted
use single pbl index per pod
This patch addresses an issue where upon dataplane restart a pod with PBL enabled would find itself with multiple PBL instances as we did use a list and did not check for existing entries on recreation. This patch solves this using a single entry per pod while waiting for a proper refactoring.
1 parent 8f26b60 commit a950c11

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

calico-vpp-agent/cni/network_vpp_routes.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (s *Server) RoutePblPortsPodInterface(podSpec *storage.LocalPodSpec, stack
150150
} else {
151151
stack.Push(s.vpp.DelPblClient, pblIndex)
152152
}
153-
podSpec.PblIndexes = append(podSpec.PblIndexes, pblIndex)
153+
podSpec.PblIndex = pblIndex
154154

155155
if !isL3 {
156156
s.log.Infof("pod(add) neighbor if[%d] %s", swIfIndex, containerIP.IP.String())
@@ -169,12 +169,10 @@ func (s *Server) RoutePblPortsPodInterface(podSpec *storage.LocalPodSpec, stack
169169
}
170170

171171
func (s *Server) UnroutePblPortsPodInterface(podSpec *storage.LocalPodSpec, swIfIndex uint32) {
172-
for _, pblIndex := range podSpec.PblIndexes {
173-
s.log.Infof("pod(del) PBL client[%d]", pblIndex)
174-
err := s.vpp.DelPblClient(pblIndex)
175-
if err != nil {
176-
s.log.Warnf("Error deleting pbl conf %s", err)
177-
}
172+
s.log.Infof("pod(del) PBL client[%d]", podSpec.PblIndex)
173+
err := s.vpp.DelPblClient(podSpec.PblIndex)
174+
if err != nil {
175+
s.log.Warnf("Error deleting pbl conf %s", err)
178176
}
179177
}
180178

calico-vpp-agent/cni/storage/storage.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ func (ps *LocalPodSpec) FullString() string {
126126
for _, e := range routes {
127127
routesLst = append(routesLst, e.String())
128128
}
129-
pblIndexes := ps.PblIndexes
130-
pblIndexesLst := make([]string, 0, len(pblIndexes))
131-
for _, e := range pblIndexes {
132-
pblIndexesLst = append(pblIndexesLst, fmt.Sprint(e))
133-
}
134129
s := fmt.Sprintf("InterfaceName: %s\n", ps.InterfaceName)
135130
s += fmt.Sprintf("NetnsName: %s\n", ps.NetnsName)
136131
s += fmt.Sprintf("AllowIPForwarding: %t\n", ps.AllowIPForwarding)
@@ -151,7 +146,7 @@ func (ps *LocalPodSpec) FullString() string {
151146
s += fmt.Sprintf("TunTapSwIfIndex: %d\n", ps.TunTapSwIfIndex)
152147
s += fmt.Sprintf("MemifSwIfIndex: %d\n", ps.MemifSwIfIndex)
153148
s += fmt.Sprintf("LoopbackSwIfIndex: %d\n", ps.LoopbackSwIfIndex)
154-
s += fmt.Sprintf("PblIndexes: %s\n", strings.Join(pblIndexesLst, ", "))
149+
s += fmt.Sprintf("PblIndexes: %d\n", ps.PblIndex)
155150
s += fmt.Sprintf("V4VrfID: %d\n", ps.V4VrfID)
156151
s += fmt.Sprintf("V6VrfID: %d\n", ps.V6VrfID)
157152
return s
@@ -238,8 +233,7 @@ type LocalPodSpec struct {
238233
TunTapSwIfIndex uint32
239234
MemifSwIfIndex uint32
240235
LoopbackSwIfIndex uint32
241-
PblIndexesLen int `struc:"int16,sizeof=PblIndexes"`
242-
PblIndexes []uint32
236+
PblIndex uint32
243237

244238
/**
245239
* These fields are only a runtime cache, but we also store them
@@ -268,7 +262,6 @@ func (ps *LocalPodSpec) Copy() LocalPodSpec {
268262
newPs.ContainerIps = append(make([]LocalIP, 0), ps.ContainerIps...)
269263
newPs.HostPorts = append(make([]HostPortBinding, 0), ps.HostPorts...)
270264
newPs.IfPortConfigs = append(make([]LocalIfPortConfigs, 0), ps.IfPortConfigs...)
271-
newPs.PblIndexes = append(make([]uint32, 0), ps.PblIndexes...)
272265

273266
return newPs
274267

0 commit comments

Comments
 (0)