@@ -36,7 +36,6 @@ import (
3636 "github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/cni/model"
3737 "github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/cni/podinterface"
3838 "github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/common"
39- "github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/watchers"
4039 "github.com/projectcalico/vpp-dataplane/v3/config"
4140 "github.com/projectcalico/vpp-dataplane/v3/vpplink"
4241 "github.com/projectcalico/vpp-dataplane/v3/vpplink/types"
@@ -53,7 +52,7 @@ type Server struct {
5352
5453 podInterfaceMap map [string ]model.LocalPodSpec
5554 lock sync.Mutex /* protects Add/DelVppInterace/RescanState */
56- cniEventChan chan common. CalicoVppEvent
55+ cniEventChan chan any
5756
5857 memifDriver * podinterface.MemifPodInterfaceDriver
5958 tuntapDriver * podinterface.TunTapPodInterfaceDriver
@@ -65,7 +64,7 @@ type Server struct {
6564 RedirectToHostClassifyTableIndex uint32
6665
6766 networkDefinitions sync.Map
68- cniMultinetEventChan chan common. CalicoVppEvent
67+ cniMultinetEventChan chan any
6968 nodeBGPSpec * common.LocalNodeSpec
7069}
7170
@@ -96,9 +95,9 @@ func (s *Server) Add(ctx context.Context, request *cniproto.AddRequest) (*cnipro
9695 if ! ok {
9796 return nil , fmt .Errorf ("trying to create a pod in an unexisting network %s" , podSpec .NetworkName )
9897 } else {
99- networkDefinition , ok := value .(* watchers .NetworkDefinition )
98+ networkDefinition , ok := value .(* common .NetworkDefinition )
10099 if ! ok || networkDefinition == nil {
101- panic ("Value is not of type *watchers .NetworkDefinition" )
100+ panic ("Value is not of type *common .NetworkDefinition" )
102101 }
103102 _ , route , err := net .ParseCIDR (networkDefinition .Range )
104103 if err == nil {
@@ -283,7 +282,7 @@ func NewCNIServer(vpp *vpplink.VppLink, felixServerIpam common.FelixServerIpam,
283282 log : log ,
284283
285284 felixServerIpam : felixServerIpam ,
286- cniEventChan : make (chan common. CalicoVppEvent , common .ChanSize ),
285+ cniEventChan : make (chan any , common .ChanSize ),
287286
288287 grpcServer : grpc .NewServer (),
289288 podInterfaceMap : make (map [string ]model.LocalPodSpec ),
@@ -292,7 +291,7 @@ func NewCNIServer(vpp *vpplink.VppLink, felixServerIpam common.FelixServerIpam,
292291 vclDriver : podinterface .NewVclPodInterfaceDriver (vpp , log ),
293292 loopbackDriver : podinterface .NewLoopbackPodInterfaceDriver (vpp , log ),
294293
295- cniMultinetEventChan : make (chan common. CalicoVppEvent , common .ChanSize ),
294+ cniMultinetEventChan : make (chan any , common .ChanSize ),
296295 }
297296 reg := common .RegisterHandler (server .cniEventChan , "CNI server events" )
298297 reg .ExpectEvents (
@@ -313,7 +312,11 @@ forloop:
313312 select {
314313 case <- t .Dying ():
315314 break forloop
316- case evt := <- s .cniEventChan :
315+ case msg := <- s .cniEventChan :
316+ evt , ok := msg .(common.CalicoVppEvent )
317+ if ! ok {
318+ continue
319+ }
317320 switch evt .Type {
318321 case common .FelixConfChanged :
319322 if new , _ := evt .New .(* felixConfig.Config ); new != nil {
@@ -434,21 +437,25 @@ func (s *Server) ServeCNI(t *tomb.Tomb) error {
434437 case <- t .Dying ():
435438 s .log .Warn ("Cni server asked to exit" )
436439 return
437- case event := <- s .cniMultinetEventChan :
440+ case msg := <- s .cniMultinetEventChan :
441+ event , ok := msg .(common.CalicoVppEvent )
442+ if ! ok {
443+ continue
444+ }
438445 switch event .Type {
439446 case common .NetsSynced :
440447 netsSynced <- true
441448 case common .NetAddedOrUpdated :
442- netDef , ok := event .New .(* watchers .NetworkDefinition )
449+ netDef , ok := event .New .(* common .NetworkDefinition )
443450 if ! ok {
444- s .log .Errorf ("event.New is not a *watchers .NetworkDefinition %v" , event .New )
451+ s .log .Errorf ("event.New is not a *common .NetworkDefinition %v" , event .New )
445452 continue
446453 }
447454 s .networkDefinitions .Store (netDef .Name , netDef )
448455 case common .NetDeleted :
449- netDef , ok := event .Old .(* watchers .NetworkDefinition )
456+ netDef , ok := event .Old .(* common .NetworkDefinition )
450457 if ! ok {
451- s .log .Errorf ("event.Old is not a *watchers .NetworkDefinition %v" , event .Old )
458+ s .log .Errorf ("event.Old is not a *common .NetworkDefinition %v" , event .Old )
452459 continue
453460 }
454461 s .networkDefinitions .Delete (netDef .Name )
@@ -488,6 +495,6 @@ func (s *Server) ServeCNI(t *tomb.Tomb) error {
488495
489496// ForceAddingNetworkDefinition will add another NetworkDefinition to this CNI server.
490497// The usage is mainly for testing purposes.
491- func (s * Server ) ForceAddingNetworkDefinition (networkDefinition * watchers .NetworkDefinition ) {
498+ func (s * Server ) ForceAddingNetworkDefinition (networkDefinition * common .NetworkDefinition ) {
492499 s .networkDefinitions .Store (networkDefinition .Name , networkDefinition )
493500}
0 commit comments