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 tunnelDstIP field in traceflow on dual-stack #4529

Merged
merged 1 commit into from
Mar 3, 2023

Conversation

Atish-iaf
Copy link
Contributor

@Atish-iaf Atish-iaf commented Jan 3, 2023

On dual-stack testbed, Inter-Node traceflow observation for
IPv4 packet in encap mode has empty tunnelDstIP field because
isIPv6 variable is set.

Change the logic to set isIPv6 variable based on the packet
IPv4 or IPv6.

Fixes #4502

Signed-off-by: Kumar Atish atish.iaf@gmail.com

@codecov
Copy link

codecov bot commented Jan 3, 2023

Codecov Report

Merging #4529 (6131384) into main (bc74667) will increase coverage by 4.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4529      +/-   ##
==========================================
+ Coverage   65.52%   69.54%   +4.02%     
==========================================
  Files         390      400      +10     
  Lines       58147    58235      +88     
==========================================
+ Hits        38098    40498    +2400     
+ Misses      17361    14962    -2399     
- Partials     2688     2775      +87     
Flag Coverage Δ
e2e-tests 38.22% <100.00%> (-0.12%) ⬇️
integration-tests 34.59% <ø> (-0.01%) ⬇️
kind-e2e-tests 47.05% <100.00%> (-0.96%) ⬇️
unit-tests 59.56% <100.00%> (+1.89%) ⬆️
Impacted Files Coverage Δ
pkg/agent/controller/traceflow/packetin.go 67.46% <100.00%> (+0.08%) ⬆️
pkg/agent/util/ethtool/ethtool_linux.go 0.00% <0.00%> (-70.00%) ⬇️
pkg/agent/flowexporter/exporter/exporter.go 70.96% <0.00%> (-4.04%) ⬇️
pkg/agent/consistenthash/consistenthash.go 93.75% <0.00%> (-3.75%) ⬇️
pkg/controller/networkpolicy/mutate.go 63.47% <0.00%> (-3.48%) ⬇️
...agent/flowexporter/connections/deny_connections.go 87.09% <0.00%> (-3.23%) ⬇️
pkg/controller/traceflow/controller.go 74.72% <0.00%> (-2.53%) ⬇️
...ntroller/networkpolicy/networkpolicy_controller.go 70.66% <0.00%> (-2.48%) ⬇️
...catesigningrequest/ipsec_csr_signing_controller.go 61.65% <0.00%> (-2.46%) ⬇️
pkg/agent/controller/networkpolicy/reject.go 74.03% <0.00%> (-2.41%) ⬇️
... and 81 more

@Atish-iaf
Copy link
Contributor Author

/test-ipv6-e2e

isIPv6 = etherData.Ethertype == protocol.IPv6_MSG
} else {
isIPv6 = c.nodeConfig.NodeIPv6Addr != nil
}
if match := getMatchTunnelDstField(matchers, isIPv6); match != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we'd better get both IPv4 tunnel dst and IPv6 tunnel dst, and set tunnelDstIP with valid one.

You can also add verification in traceflow_test.go:testTraceflowInterNode, to check if the traceflow observation has expected tunnelDstIP.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Even if we get both IPv4 tunnel dst and IPv6 tunnel dst, tunnelDstIP value will be decided according to isIPv6. The current code sets the value of tunnelDstIP according to isIPv6 directly without getting both tunnel dst. So, why to get both tunnel dst explicitly?

testTraceflowInterNode currently runs in both encap mode and no encap mode. If tunnelDstIP is added then we have to make the test run only in encap mode. Is it ok to change this test to run only in encap mode?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whether it is dual stack / non dual stack, in both the cases handling can be done with isIPv6 flag with right packet type, With this logic isIPv6 flag remain false if packet is not of ipv6 type irrespective of stack and hence tunnelDstIP will be assigned with ipv4 and vice versa.

UT testing can be extended to see the right values in tunnelDstIP, if the mode is encap.

Copy link
Contributor

@gran-vmv gran-vmv Jan 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Even if we get both IPv4 tunnel dst and IPv6 tunnel dst, tunnelDstIP value will be decided according to isIPv6. The current code sets the value of tunnelDstIP according to isIPv6 directly without getting both tunnel dst. So, why to get both tunnel dst explicitly?

testTraceflowInterNode currently runs in both encap mode and no encap mode. If tunnelDstIP is added then we have to make the test run only in encap mode. Is it ok to change this test to run only in encap mode?

Because reading both ipv4/ipv6 tunnel dst is more simple to decide the tunnel dst, and it won't depend on the flow logic in OVS table.
Currently only IPv4 tunnel dst is used in DualStack env. Please check: https://github.com/antrea-io/antrea/blob/main/pkg/agent/openflow/client.go#L485

You can add the TunnelDstIP into testTraceflowInterNode like

node2TunnelDstIP = ""
switch encapMode {
case config.TrafficEncapModeEncap:
	node2TunnelDstIP = nodeIP(nodeIdx1)
case config.TrafficEncapModeHybrid:
	// check more
}
...
{
	Component:     v1alpha1.ComponentForwarding,
	ComponentInfo: "Output",
	Action:        v1alpha1.ActionForwarded,
	TunnelDstIP:   node2TunnelDstIP,
},

And add the comparison into compareObservations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wenyingd
Do we use peer Node IPv4 as tunnelDst for IPv4 packet and peer Node IPv6 as tunnelDst for IPv6 packet?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer to use tunnel format IPv4OverIPv4 and IPv6OverIPv6.

@Atish-iaf
Copy link
Contributor Author

/test-ipv6-e2e

@Atish-iaf
Copy link
Contributor Author

/test-ipv6-e2e

@gran-vmv
Copy link
Contributor

/test-all
/test-flexible-ipam-e2e
/test-ipv6-only-all
/test-ipv6-networkpolicy
/test-ipv6-conformance
/test-windows-all

@gran-vmv
Copy link
Contributor

/test-multicluster-e2e

@gran-vmv
Copy link
Contributor

/test-all

1 similar comment
@gran-vmv
Copy link
Contributor

/test-all

@gran-vmv
Copy link
Contributor

/test-windows-containerd-networkpolicy
/test-windows-networkpolicy

@Atish-iaf
Copy link
Contributor Author

/test-ipv6-only-e2e

@Atish-iaf
Copy link
Contributor Author

/test-all-features-conformance
/test-hw-offload
/test-ipv6-only-e2e

var isIPv6 bool
// On dual stack, decide according to packet.
if c.nodeConfig.NodeIPv4Addr != nil && c.nodeConfig.NodeIPv6Addr != nil {
isIPv6 = etherData.Ethertype == protocol.IPv6_MSG
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confused that you already check the L3 protocol from the packet header, what this if-condition c.nodeConfig.NodeIPv4Addr != nil && c.nodeConfig.NodeIPv6Addr != nil is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review.
You are correct, this condition check isn't required. Changed to decide based on packet only for any(ipv4/ipv6/dual) stack cluster.

isIPv6 = etherData.Ethertype == protocol.IPv6_MSG
} else {
isIPv6 = c.nodeConfig.NodeIPv6Addr != nil
}
if match := getMatchTunnelDstField(matchers, isIPv6); match != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer to use tunnel format IPv4OverIPv4 and IPv6OverIPv6.

@Atish-iaf
Copy link
Contributor Author

/test-all
/test-flexible-ipam-e2e
/test-ipv6-only-all
/test-ipv6-networkpolicy
/test-ipv6-conformance
/test-windows-all

@Atish-iaf
Copy link
Contributor Author

/test-ipv6-e2e

@Atish-iaf Atish-iaf mentioned this pull request Feb 17, 2023
@gran-vmv gran-vmv added this to the Antrea v1.11 release milestone Feb 24, 2023
@gran-vmv gran-vmv added kind/bug Categorizes issue or PR as related to a bug. area/ops/traceflow Issues or PRs related to the Traceflow feature area/transit/ipv6 Issues or PRs related to IPv6. labels Feb 24, 2023
// check if node1 and node2 are in same subnet.
node2IP := net.ParseIP(nodeIP(nodeIdx1))
cmd := getPingCommand(pingCount, 0, "", &node2IP)
stdout, _, err := data.RunCommandFromPod(data.testNamespace, node1Pods[0], agnhostContainerName, cmd)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use antrea-agent Pod antrea-agent container on node1 to run the command.

case config.TrafficEncapModeEncap:
node2TunnelDstIPv4 = clusterInfo.nodes[nodeIdx1].ipv4Addr
node2TunnelDstIPv6 = clusterInfo.nodes[nodeIdx1].ipv6Addr
// TODO: Add case for Hybrid mode when Nodes are in different subnet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the test in hybrid mode would fail if the nodes are not in the same subnet as the expectation is empty but the actual observation is not?

Copy link
Contributor Author

@Atish-iaf Atish-iaf Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but we can keep it for now if our testbeds on which e2e tests run are in same subnet so that tunnelIP validation can be done for all cases except one i.e Nodes on different subnet in hybrid mode.

Edit : Will remove tunnelIP validation.

tnqn
tnqn previously approved these changes Mar 2, 2023
@tnqn
Copy link
Member

tnqn commented Mar 2, 2023

/test-e2e
/test-ipv6-e2e
/test-ipv6-only-e2e
/skip-conformance
/skip-networkpolicy

@Atish-iaf
Copy link
Contributor Author

Atish-iaf commented Mar 2, 2023

/test-ipv6-e2e

@Atish-iaf
Copy link
Contributor Author

/test-ipv6-e2e
/test-ipv6-only-e2e

1 similar comment
@Atish-iaf
Copy link
Contributor Author

/test-ipv6-e2e
/test-ipv6-only-e2e

@jianjuns
Copy link
Contributor

jianjuns commented Mar 2, 2023

/test-ipv6-e2e

@jianjuns
Copy link
Contributor

jianjuns commented Mar 2, 2023

/test-ipv6-only-e2e

@Atish-iaf
Copy link
Contributor Author

/test-ipv6-e2e
/test-ipv6-only-e2e

@tnqn
Copy link
Member

tnqn commented Mar 3, 2023

The test error may be related to #4673, which will be fixed by #4674

@tnqn
Copy link
Member

tnqn commented Mar 3, 2023

#4674 has been merged, could you rebase to see if e2e-ipv6 can pass now?

On dual-stack testbed, Inter-Node traceflow observation for
IPv4 packet in encap mode has empty tunnelDstIP field because
isIPv6 variable is set.

Change the logic to set isIPv6 variable based on the packet
IPv4 or IPv6.

Fixes antrea-io#4502

Signed-off-by: Kumar Atish <atish.iaf@gmail.com>
@Atish-iaf
Copy link
Contributor Author

/test-e2e
/test-ipv6-e2e
/test-ipv6-only-e2e
/skip-conformance
/skip-networkpolicy

@Atish-iaf
Copy link
Contributor Author

/test-e2e

@tnqn
Copy link
Member

tnqn commented Mar 3, 2023

/skip-conformance

@tnqn
Copy link
Member

tnqn commented Mar 3, 2023

/skip-networkpolicy

@tnqn tnqn merged commit 9c95110 into antrea-io:main Mar 3, 2023
GraysonWu pushed a commit to GraysonWu/antrea that referenced this pull request Mar 3, 2023
On dual-stack testbed, Inter-Node traceflow observation for
IPv4 packet in encap mode has empty tunnelDstIP field because
isIPv6 variable is set.

Change the logic to set isIPv6 variable based on the packet
IPv4 or IPv6.

Fixes antrea-io#4502

Signed-off-by: Kumar Atish <atish.iaf@gmail.com>
jainpulkit22 pushed a commit to urharshitha/antrea that referenced this pull request Apr 28, 2023
On dual-stack testbed, Inter-Node traceflow observation for
IPv4 packet in encap mode has empty tunnelDstIP field because
isIPv6 variable is set.

Change the logic to set isIPv6 variable based on the packet
IPv4 or IPv6.

Fixes antrea-io#4502

Signed-off-by: Kumar Atish <atish.iaf@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ops/traceflow Issues or PRs related to the Traceflow feature area/transit/ipv6 Issues or PRs related to IPv6. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TestTraceflow/testTraceflowEgress/egressFromRemoteNode failing consistently on dual-stack testbed
6 participants