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

Add support of tcp option wildcard "wscale *" #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

liu-song-6
Copy link

Summary:
In current script, we can either specify every tcp option of a packet,
or use <...> for "any tcp options". This is not flexible enough, as
some script may have requirements for some tcp options; while be flexible
with other options.

This patch tries to address this by adding wildcard for option wscale.
Specifically, "wscale *" in the tcp option list means any wscale value.

To mark a tcp option in the script as wildcard, we leverage the highest
bit of tcp_option->kind, as TCPOPT_WILDCARD (0x80). tcp_option->kind of
TCPOPT_WILDCARD | TCPOPT_WINDOW (0x83) means wscale option of any value.

verify_outbound_live_tcp_options() is updated to be able to understand
TCPOPT_WILDCARD.

Reviewed-by: Lawrence Brakmo [email protected]
Signed-off-by: Song Liu [email protected]

Summary:
In current script, we can either specify every tcp option of a packet,
or use <...> for "any tcp options". This is not flexible enough, as
some script may have requirements for some tcp options; while be flexible
with other options.

This patch tries to address this by adding wildcard for option wscale.
Specifically, "wscale *" in the tcp option list means any wscale value.

To mark a tcp option in the script as wildcard, we leverage the highest
bit of tcp_option->kind, as TCPOPT_WILDCARD (0x80). tcp_option->kind of
TCPOPT_WILDCARD | TCPOPT_WINDOW (0x83) means wscale option of any value.

verify_outbound_live_tcp_options() is updated to be able to understand
TCPOPT_WILDCARD.

Reviewed-by: Lawrence Brakmo <[email protected]>
Signed-off-by: Song Liu <[email protected]>
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@liu-song-6
Copy link
Author

I signed it!

1 similar comment
@liu-song-6
Copy link
Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@liu-song-6
Copy link
Author

@nealcardwell Could you please help review this PR? Or maybe there is any restrictions on external contributions?

Thanks in advance!

script_packet, a_opt, s_opt,
error) != STATUS_OK) {
/* skip btye-to-byte comparison of wildcard option */
if ((a_opt->kind | s_opt->kind) & TCPOPT_WILDCARD)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we only want to skip the verify_outbound_tcp_option() call if the script packet has the TCPOPT_WILDCARD bit set. If the actual packet has bit 0x80 set for some reason then AFAICT this indicates a kernel bug, and not something we should ignore. How about:

if (s_opt->kind & TCPOPT_WILDCARD)

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are options with the 0x80 bit set:
https://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml

So I would suggest tightening this up:

            /* Sometimes skip btye-to-byte comparison of wildcard option */
	if (s_opt->kind == (TCPOPT_WILDCARD | TCPOPT_WINDOW))

@@ -1248,14 +1248,18 @@ static int verify_outbound_live_tcp_options(
/* TCP options are expected to be a deterministic order. */
while (a_opt != NULL || s_opt != NULL) {
if (a_opt == NULL || s_opt == NULL ||
a_opt->kind != s_opt->kind) {
(a_opt->kind & ~TCPOPT_WILDCARD) !=
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like it would ignore cases where the actual packet has bit 0x80 set for some reason; AFAICT this would indicate a kernel bug, and is not something we should ignore.

There is also the case for an actual TCP option number that sets the 0x80 bit:
#define TCPOPT_EXP 254 /* Experimental */

If the script says the option type is supposed to be TCPOPT_EXP then we should check that all bits really match TCPOPT_EXP.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest tightening this up with something like:

if (a_opt == NULL || s_opt == NULL ||
(a_opt->kind != s_opt->kind &&
!(s_opt->kind == (TCPOPT_WILDCARD | TCPOPT_WINDOW) &&
a_opt->kind == TCPOPT_WINDOW)) {

Copy link
Collaborator

@nealcardwell nealcardwell left a comment

Choose a reason for hiding this comment

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

Thanks for posting this patch! Sorry for the very delayed review.

nit: for consistency with the other patches in the packetdrill code base, can you please use a first summary line like:

net-test: packetdrill: add support of tcp option wildcard "wscale *"

Thanks!

@chantra
Copy link

chantra commented Jun 26, 2023

Hi @nealcardwell !

So... a few years have passed by since this PR was last updated.

I like to get this going, but before putting work into it, want to check that this is something that you would still accept after addressing the comments.

Thanks

@chantra
Copy link

chantra commented Jun 26, 2023

@liu-song-6 and I discusses this offline and I will likely spinning up a new PR to take over his initial work.

@nealcardwell
Copy link
Collaborator

@liu-song-6 and I discusses this offline and I will likely spinning up a new PR to take over his initial work.

Great. I added some new comments today. Please address those as well:
#10

Thanks!

@chantra
Copy link

chantra commented Jun 28, 2023

ok, I have pushed this change in #75 .

I need to sort out the CLA and will probably force-push with my corporate email later. In the meantime, feedback is welcome.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants