Skip to content

Commit a4c9b09

Browse files
committed
np: allow icmpv6 to ipv6 ready check
So that we can remove trigger all np updates when subnet gw or uo2ip change. Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
1 parent c74c5c2 commit a4c9b09

File tree

9 files changed

+185
-417
lines changed

9 files changed

+185
-417
lines changed

mocks/pkg/ovs/interface.go

Lines changed: 148 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controller/network_policy.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,13 @@ func (c *Controller) handleUpdateNp(key string) error {
149149
return err
150150
}
151151

152-
var subnets []*kubeovnv1.Subnet
153152
protocolSet := strset.NewWithSize(2)
154153
for _, subnetName := range subnetNames {
155154
subnet, err := c.subnetsLister.Get(subnetName)
156155
if err != nil {
157156
klog.Errorf("failed to get pod's subnet %s, %v", subnetName, err)
158157
return err
159158
}
160-
subnets = append(subnets, subnet)
161159

162160
if subnet.Spec.Protocol == kubeovnv1.ProtocolDual {
163161
protocolSet.Add(kubeovnv1.ProtocolIPv4, kubeovnv1.ProtocolIPv6)
@@ -468,12 +466,10 @@ func (c *Controller) handleUpdateNp(key string) error {
468466
}
469467
}
470468

471-
if !enforcementLax {
472-
for _, subnet := range subnets {
473-
if err = c.OVNNbClient.CreateGatewayACL("", pgName, subnet.Spec.Gateway, subnet.Status.U2OInterconnectionIP); err != nil {
474-
klog.Errorf("create gateway acl: %v", err)
475-
return err
476-
}
469+
if !enforcementLax && protocolSet.Has(kubeovnv1.ProtocolIPv6) {
470+
if err = c.OVNNbClient.CreateGatewayACL("", pgName); err != nil {
471+
klog.Errorf("create gateway acl: %v", err)
472+
return err
477473
}
478474
}
479475
return nil

pkg/controller/subnet.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,6 @@ func (c *Controller) enqueueUpdateSubnet(oldObj, newObj any) {
6565
newSubnet := newObj.(*kubeovnv1.Subnet)
6666
key := cache.MetaObjectToName(newSubnet).String()
6767

68-
// Trigger network policy refresh only if they are enabled, otherwise the lister will be nil
69-
if c.npsLister != nil {
70-
if newSubnet.Spec.Gateway != oldSubnet.Spec.Gateway || newSubnet.Status.U2OInterconnectionIP != oldSubnet.Status.U2OInterconnectionIP {
71-
policies, err := c.npsLister.List(labels.Everything())
72-
if err != nil {
73-
klog.Errorf("failed to list network policies: %v", err)
74-
} else {
75-
for _, np := range policies {
76-
c.enqueueAddNp(np)
77-
}
78-
}
79-
}
80-
}
81-
8268
if newSubnet.Spec.Protocol == kubeovnv1.ProtocolIPv6 {
8369
usingIPs = newSubnet.Status.V6UsingIPs
8470
} else {

pkg/daemon/ovs.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func pingGateway(gw, src string, verbose bool, maxRetry int, done chan struct{})
2121
return 0, fmt.Errorf("failed to init pinger: %w", err)
2222
}
2323
pinger.SetPrivileged(true)
24-
// CNITimeoutSec = 220, cannot exceed
2524
pinger.Count = maxRetry
2625
pinger.Timeout = time.Duration(maxRetry) * time.Second
2726
pinger.Interval = time.Second
@@ -49,12 +48,10 @@ func pingGateway(gw, src string, verbose bool, maxRetry int, done chan struct{})
4948
finish <- struct{}{}
5049
}
5150
go func() {
52-
// stop pinger when cancel signal received
5351
select {
5452
case <-done:
5553
pinger.Stop()
5654
case <-finish:
57-
// do nothing here
5855
}
5956
}()
6057
}
@@ -76,7 +73,6 @@ func pingGateway(gw, src string, verbose bool, maxRetry int, done chan struct{})
7673
if verbose {
7774
klog.Infof("%s network ready after %d ping to gateway %s", src, pinger.PacketsSent, gw)
7875
}
79-
8076
return pinger.PacketsSent, nil
8177
}
8278

pkg/daemon/ovs_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ func waitNetworkReady(nic, ipAddr, gateway string, verbose bool, maxRetry int, d
616616
return err
617617
}
618618
if verbose {
619-
klog.Infof("MAC addresses of gateway %s is %s", gw, mac.String())
619+
klog.Infof("MAC address of gateway %s is %s", gw, mac.String())
620620
klog.Infof("network %s with gateway %s is ready for interface %s after %d checks", ips[i], gw, nic, count)
621621
}
622622
} else {

pkg/ovs/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ type ACL interface {
163163
UpdateDefaultBlockExceptionsACLOps(npName, pgName, npNamespace, direction string) ([]ovsdb.Operation, error)
164164
UpdateIngressACLOps(pgName, asIngressName, asExceptName, protocol, aclName string, npp []netv1.NetworkPolicyPort, logEnable bool, logACLActions []ovnnb.ACLAction, logRate int, namedPortMap map[string]*util.NamedPortInfo) ([]ovsdb.Operation, error)
165165
UpdateEgressACLOps(pgName, asEgressName, asExceptName, protocol, aclName string, npp []netv1.NetworkPolicyPort, logEnable bool, logACLActions []ovnnb.ACLAction, logRate int, namedPortMap map[string]*util.NamedPortInfo) ([]ovsdb.Operation, error)
166-
CreateGatewayACL(lsName, pgName, gateway, u2oInterconnectionIP string) error
166+
CreateGatewayACL(lsName, pgName string) error
167167
CreateNodeACL(pgName, nodeIPStr, joinIPStr string) error
168168
CreateSgDenyAllACL(sgName string) error
169169
CreateSgBaseACL(sgName, direction string) error

0 commit comments

Comments
 (0)