@@ -22,28 +22,32 @@ import (
22
22
func (c * OVNNbClient ) UpdateIngressACLOps (pgName , asIngressName , asExceptName , protocol string , npp []netv1.NetworkPolicyPort , logEnable bool , namedPortMap map [string ]* util.NamedPortInfo ) ([]ovsdb.Operation , error ) {
23
23
acls := make ([]* ovnnb.ACL , 0 )
24
24
25
- ipSuffix := "ip4"
26
- if protocol == kubeovnv1 .ProtocolIPv6 {
27
- ipSuffix = "ip6"
28
- }
25
+ if strings .HasSuffix (asIngressName , ".0" ) || strings .HasSuffix (asIngressName , ".all" ) {
26
+ // create the default drop rule for only once
27
+ ipSuffix := "ip4"
28
+ if protocol == kubeovnv1 .ProtocolIPv6 {
29
+ ipSuffix = "ip6"
30
+ }
29
31
30
- /* default drop acl */
31
- allIPMatch := NewAndACLMatch (
32
- NewACLMatch ("outport" , "==" , "@" + pgName , "" ),
33
- NewACLMatch (ipSuffix , "" , "" , "" ),
34
- )
35
- options := func (acl * ovnnb.ACL ) {
36
- if logEnable {
37
- acl .Log = true
38
- acl .Severity = & ovnnb .ACLSeverityWarning
32
+ /* default drop acl */
33
+ allIPMatch := NewAndACLMatch (
34
+ NewACLMatch ("outport" , "==" , "@" + pgName , "" ),
35
+ NewACLMatch (ipSuffix , "" , "" , "" ),
36
+ )
37
+ options := func (acl * ovnnb.ACL ) {
38
+ if logEnable {
39
+ acl .Log = true
40
+ acl .Severity = & ovnnb .ACLSeverityWarning
41
+ }
39
42
}
40
43
41
- defaultDropACL , err := c .newACLWithoutCheck (pgName , ovnnb .ACLDirectionToLport , util .IngressDefaultDrop , allIPMatch .String (), ovnnb .ACLActionDrop , options )
42
- if err != nil {
43
- return nil , fmt .Errorf ("new default drop ingress acl for port group %s: %v" , pgName , err )
44
- }
44
+ defaultDropACL , err := c .newACLWithoutCheck (pgName , ovnnb .ACLDirectionToLport , util .IngressDefaultDrop , allIPMatch .String (), ovnnb .ACLActionDrop , options )
45
+ if err != nil {
46
+ return nil , fmt .Errorf ("new default drop ingress acl for port group %s: %v" , pgName , err )
47
+ }
45
48
46
- acls = append (acls , defaultDropACL )
49
+ acls = append (acls , defaultDropACL )
50
+ }
47
51
48
52
/* allow acl */
49
53
matches := newNetworkPolicyACLMatch (pgName , asIngressName , asExceptName , protocol , ovnnb .ACLDirectionToLport , npp , namedPortMap )
@@ -68,26 +72,17 @@ func (c *OVNNbClient) UpdateIngressACLOps(pgName, asIngressName, asExceptName, p
68
72
func (c * OVNNbClient ) UpdateEgressACLOps (pgName , asEgressName , asExceptName , protocol string , npp []netv1.NetworkPolicyPort , logEnable bool , namedPortMap map [string ]* util.NamedPortInfo ) ([]ovsdb.Operation , error ) {
69
73
acls := make ([]* ovnnb.ACL , 0 )
70
74
71
- ipSuffix := "ip4 "
72
- if protocol == kubeovnv1.ProtocolIPv6 {
73
- ipSuffix = "ip6 "
74
- }
75
-
76
- /* default drop acl */
77
- allIPMatch := NewAndACLMatch (
78
- NewACLMatch ("inport" , "==" , "@" + pgName , "" ),
79
- NewACLMatch (ipSuffix , "" , "" , "" ),
80
- )
81
- options := func (acl * ovnnb .ACL ) {
82
- if logEnable {
83
- acl .Log = true
84
- acl .Severity = & ovnnb .ACLSeverityWarning
75
+ if strings .HasSuffix (asEgressName , ".0" ) || strings .HasSuffix (asEgressName , ".all" ) {
76
+ // create the default drop rule for only once
77
+ ipSuffix := "ip4"
78
+ if protocol == kubeovnv1 .ProtocolIPv6 {
79
+ ipSuffix = "ip6"
85
80
}
86
81
87
82
/* default drop acl */
88
- allIpMatch := NewAndAclMatch (
89
- NewAclMatch ("inport" , "==" , "@" + pgName , "" ),
90
- NewAclMatch (ipSuffix , "" , "" , "" ),
83
+ allIPMatch := NewAndACLMatch (
84
+ NewACLMatch ("inport" , "==" , "@" + pgName , "" ),
85
+ NewACLMatch (ipSuffix , "" , "" , "" ),
91
86
)
92
87
options := func (acl * ovnnb.ACL ) {
93
88
if logEnable {
@@ -101,13 +96,14 @@ func (c *OVNNbClient) UpdateEgressACLOps(pgName, asEgressName, asExceptName, pro
101
96
acl .Options ["apply-after-lb" ] = "true"
102
97
}
103
98
104
- defaultDropACL , err := c .newACLWithoutCheck (pgName , ovnnb .ACLDirectionFromLport , util .EgressDefaultDrop , allIPMatch .String (), ovnnb .ACLActionDrop , options )
105
- if err != nil {
106
- klog .Error (err )
107
- return nil , fmt .Errorf ("new default drop egress acl for port group %s: %v" , pgName , err )
108
- }
99
+ defaultDropACL , err := c .newACLWithoutCheck (pgName , ovnnb .ACLDirectionFromLport , util .EgressDefaultDrop , allIPMatch .String (), ovnnb .ACLActionDrop , options )
100
+ if err != nil {
101
+ klog .Error (err )
102
+ return nil , fmt .Errorf ("new default drop egress acl for port group %s: %v" , pgName , err )
103
+ }
109
104
110
- acls = append (acls , defaultDropACL )
105
+ acls = append (acls , defaultDropACL )
106
+ }
111
107
112
108
/* allow acl */
113
109
matches := newNetworkPolicyACLMatch (pgName , asEgressName , asExceptName , protocol , ovnnb .ACLDirectionFromLport , npp , namedPortMap )
0 commit comments