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

Set default flag to 2 for TCP traceflow #4948

Merged
merged 1 commit into from
May 22, 2023

Conversation

luolanzone
Copy link
Contributor

Resolves #4897

@luolanzone luolanzone requested a review from tnqn May 8, 2023 06:58
antoninbas
antoninbas previously approved these changes May 8, 2023
Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

I am fine with merging this, but maybe we should revisit this old issue (#1852) and instead make Traceflow more user-friendly by automatically setting the SYN bit. Users would still be able to clear the TCP flags by providing tcp_flags=0.

@luolanzone
Copy link
Contributor Author

@antoninbas thanks for the input, I do feel we'd better to keep the same behaviors for both cases when Pod or Service as the destination. I noticed that the flag is set as 2 when the destination is Service by default in traceflow controller, not sure why it's not set for Pod case. Let's see what's @tnqn opinion.

@luolanzone luolanzone added the kind/documentation Categorizes issue or PR as related to a documentation. label May 10, 2023
@tnqn
Copy link
Member

tnqn commented May 11, 2023

@antoninbas thanks for the input, I do feel we'd better to keep the same behaviors for both cases when Pod or Service as the destination. I noticed that the flag is set as 2 when the destination is Service by default in traceflow controller, not sure why it's not set for Pod case. Let's see what's @tnqn opinion.

I don't know the history regarding this. But defaulting tcp flags works for me. Where is the flag set for Service?

@luolanzone
Copy link
Contributor Author

@tnqn here is the code https://github.com/antrea-io/antrea/blob/main/pkg/agent/controller/traceflow/traceflow_controller.go#L500-L504, when it's not live traffic traceflow, it will set default flag as 2.

@luolanzone
Copy link
Contributor Author

@tnqn @antoninbas could you review again? I updated the code to set a TCP flag to 2 by default.

@luolanzone luolanzone changed the title Update traceflow samples Set default flag to 2 for TCP traceflow May 15, 2023
@@ -536,6 +536,9 @@ func (c *Controller) preparePacket(tf *crdv1alpha1.Traceflow, intf *interfacesto
if tf.Spec.Packet.TransportHeader.TCP.Flags != 0 {
packet.TCPFlags = uint8(tf.Spec.Packet.TransportHeader.TCP.Flags)
}
if !liveTraffic && tf.Spec.Packet.TransportHeader.TCP.Flags == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

this code needs to be revisited for this PR:

if !liveTraffic {
// Set the SYN flag. In encap mode, the SYN flag is only required for
// Service traffic, but probably we should always set it.
packet.TCPFlags = 2
}

The comment is no longer relevant and it is confusing to set the TCP flags in 2 places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove this part since we always set it as 2 by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I guess by setting the TCP flags here, it is not possible for the users to force the flags to be 0. I don't know if this is an issue at all though, since Traceflow is unlikely to be useful when the SYN flag is not set.

@tnqn what do you think? When we promote the API to beta, should be make the Flags field a pointer instead (*int32)?

Copy link
Member

Choose a reason for hiding this comment

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

tcp_flags 0 seems only useful when we want to verify the pipeline can drop TCP NULL scan. I'm fine with changing the field to pointer to make the use case supported.

docs/antctl.md Outdated
Comment on lines 479 to 481
# Start a Traceflow from pod1 to pod2, with a TCP SYN packet to destination port 1234
# tcp_flags will be 2 by default when it's not provided.
$ antctl traceflow -S pod1 -D pod2 -f tcp,tcp_dst=1234,tcp_flags=2
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why we are adding this example at all, since the flags are now being set by default. Explicitly using tcp_flags=2 is a bit misleading?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@@ -89,6 +89,7 @@ spec:
tcp:
srcPort: 10000 # Source port needs to be set when Protocol is TCP/UDP.
dstPort: 80 # Destination port needs to be set when Protocol is TCP/UDP.
flags: 2 # Construct a SYN packet, when Protocol is TCP, flags will be set to 2 by default when it's not provided.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
flags: 2 # Construct a SYN packet, when Protocol is TCP, flags will be set to 2 by default when it's not provided.
flags: 2 # Construct a SYN packet: 2 is also the default value when the flags field is omitted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Signed-off-by: Lan Luo <luola@vmware.com>
@antoninbas antoninbas removed the kind/documentation Categorizes issue or PR as related to a documentation. label May 16, 2023
Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

LGTM
Waiting for @tnqn to review

@@ -536,6 +536,9 @@ func (c *Controller) preparePacket(tf *crdv1alpha1.Traceflow, intf *interfacesto
if tf.Spec.Packet.TransportHeader.TCP.Flags != 0 {
packet.TCPFlags = uint8(tf.Spec.Packet.TransportHeader.TCP.Flags)
}
if !liveTraffic && tf.Spec.Packet.TransportHeader.TCP.Flags == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

So I guess by setting the TCP flags here, it is not possible for the users to force the flags to be 0. I don't know if this is an issue at all though, since Traceflow is unlikely to be useful when the SYN flag is not set.

@tnqn what do you think? When we promote the API to beta, should be make the Flags field a pointer instead (*int32)?

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@antoninbas
Copy link
Contributor

/test-all

@tnqn
Copy link
Member

tnqn commented May 22, 2023

/test-e2e

@tnqn tnqn added the action/release-note Indicates a PR that should be included in release notes. label May 22, 2023
@tnqn tnqn added this to the Antrea v1.12 release milestone May 22, 2023
@tnqn tnqn merged commit e10ec6a into antrea-io:main May 22, 2023
@tnqn tnqn mentioned this pull request May 31, 2023
9 tasks
ceclinux pushed a commit to ceclinux/antrea that referenced this pull request Jun 5, 2023
Signed-off-by: Lan Luo <luola@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/release-note Indicates a PR that should be included in release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Traceflow failed when using tcp protocol
3 participants