Skip to content

Commit

Permalink
Fix dumping OVS flows of a NetworkPolicy
Browse files Browse the repository at this point in the history
Fixes #3306.

This commit adds test to verify the changes made to solve the nil pointer dereference error while dumping ovsflows of NetworkPolicy.

Signed-off-by: Pulkit Jain <jainpu@vmware.com>
  • Loading branch information
Pulkit Jain committed Feb 23, 2022
1 parent 742e16c commit cddadf1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/agent/openflow/network_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ type policyRuleConjunction struct {
serviceClause *clause
actionFlows []binding.Flow
metricFlows []binding.Flow
// NetworkPolicy reference information for debugging usage.
// NetworkPolicy reference information for debugging usage, its' value can be nil
// when a new DNS Conjunction is added to the policyCache.
npRef *v1beta2.NetworkPolicyReference
ruleTableID uint8
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/agent/openflow/network_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ func TestInstallPolicyRuleFlows(t *testing.T) {
assert.Equal(t, 3, getChangedFlowOPCount(matchFlows2, insertion))
err = c.applyConjunctiveMatchFlows(ctxChanges2)
require.Nil(t, err)
// dnsID will store the ID for New DNS packet, that is created,
// to test for nil NetworkPolicyReference.
dnsID := uint32(107)
c.NewDNSpacketInConjunction(dnsID)

assert.Equal(t, 0, len(c.GetNetworkPolicyFlowKeys("np1", "ns1")))
err = c.InstallPolicyRuleFlows(rule2)
Expand Down

0 comments on commit cddadf1

Please sign in to comment.