Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: security group base acl direction #3690

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/ovs/ovn-nb-acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (c *OVNNbClient) CreateSgBaseACL(sgName, direction string) error {
acls := make([]*ovnnb.ACL, 0)

newACL := func(match string) {
acl, err := c.newACL(pgName, ovnnb.ACLDirectionToLport, util.SecurityGroupBasePriority, match, ovnnb.ACLActionAllowRelated)
acl, err := c.newACL(pgName, direction, util.SecurityGroupBasePriority, match, ovnnb.ACLActionAllowRelated)
if err != nil {
klog.Error(err)
klog.Errorf("new base ingress acl for security group %s: %v", sgName, err)
Expand Down
26 changes: 13 additions & 13 deletions pkg/ovs/ovn-nb-acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,11 @@ func (suite *OvnClientTestSuite) testCreateSgBaseACL() {

ovnClient := suite.ovnClient

expect := func(pg *ovnnb.PortGroup, match string) {
arpACL, err := ovnClient.GetACL(pg.Name, ovnnb.ACLDirectionToLport, util.SecurityGroupBasePriority, match, false)
expect := func(pg *ovnnb.PortGroup, match, direction string) {
arpACL, err := ovnClient.GetACL(pg.Name, direction, util.SecurityGroupBasePriority, match, false)
require.NoError(t, err)

expect := newACL(pg.Name, ovnnb.ACLDirectionToLport, util.SecurityGroupBasePriority, match, ovnnb.ACLActionAllowRelated, func(acl *ovnnb.ACL) {
expect := newACL(pg.Name, direction, util.SecurityGroupBasePriority, match, ovnnb.ACLActionAllowRelated, func(acl *ovnnb.ACL) {
acl.UUID = arpACL.UUID
})

Expand Down Expand Up @@ -477,23 +477,23 @@ func (suite *OvnClientTestSuite) testCreateSgBaseACL() {

// arp
match := fmt.Sprintf("%s == @%s && arp", portDirection, pgName)
expect(pg, match)
expect(pg, match, ovnnb.ACLDirectionToLport)

// icmpv6
match = fmt.Sprintf("%s == @%s && icmp6.type == {130, 134, 135, 136} && icmp6.code == 0 && ip.ttl == 255", portDirection, pgName)
expect(pg, match)
expect(pg, match, ovnnb.ACLDirectionToLport)

// dhcpv4
match = fmt.Sprintf("%s == @%s && udp.src == 67 && udp.dst == 68 && ip4", portDirection, pgName)
expect(pg, match)
expect(pg, match, ovnnb.ACLDirectionToLport)

// dhcpv6
match = fmt.Sprintf("%s == @%s && udp.src == 547 && udp.dst == 546 && ip6", portDirection, pgName)
expect(pg, match)
expect(pg, match, ovnnb.ACLDirectionToLport)

// vrrp
match = fmt.Sprintf("%s == @%s && ip.proto == 112", portDirection, pgName)
expect(pg, match)
expect(pg, match, ovnnb.ACLDirectionToLport)
})

t.Run("create sg base egress acl", func(t *testing.T) {
Expand All @@ -516,23 +516,23 @@ func (suite *OvnClientTestSuite) testCreateSgBaseACL() {

// arp
match := fmt.Sprintf("%s == @%s && arp", portDirection, pgName)
expect(pg, match)
expect(pg, match, ovnnb.ACLDirectionFromLport)

// icmpv6
match = fmt.Sprintf("%s == @%s && icmp6.type == {130, 133, 135, 136} && icmp6.code == 0 && ip.ttl == 255", portDirection, pgName)
expect(pg, match)
expect(pg, match, ovnnb.ACLDirectionFromLport)

// dhcpv4
match = fmt.Sprintf("%s == @%s && udp.src == 68 && udp.dst == 67 && ip4", portDirection, pgName)
expect(pg, match)
expect(pg, match, ovnnb.ACLDirectionFromLport)

// dhcpv6
match = fmt.Sprintf("%s == @%s && udp.src == 546 && udp.dst == 547 && ip6", portDirection, pgName)
expect(pg, match)
expect(pg, match, ovnnb.ACLDirectionFromLport)

// vrrp
match = fmt.Sprintf("%s == @%s && ip.proto == 112", portDirection, pgName)
expect(pg, match)
expect(pg, match, ovnnb.ACLDirectionFromLport)
})
}

Expand Down
Loading