Sitelet https://github.com/iputils/iputils/pull/468
Skip to content

ping6: Improve handling of option '-Q'. - #468

Closed
gault wants to merge 2 commits into
iputils:masterfrom
gault:ipv6_dscp
Closed

gault wants to merge 2 commits into
iputils:masterfrom
gault:ipv6_dscp

Conversation

@gault

@gault gault commented May 18, 2023

Copy link
Copy Markdown
Contributor

Using ping6 -Q on a system using ip-rules can fail because the probe_fd
doesn't set IPV6_TCLASS. Therefore, probe_fd might make its route
lookup in a different table than the one that will be used to really
send the packet. This is fixed by patch 1.

Patch 2 then cleans up some dead code also related to IPV6_TCLASS.

gault added 2 commits May 18, 2023 18:49
Set the IPV6_TCLASS option on probe_fd. Otherwise ip-rule is unaware
of the DSCP value at connect() time and can lookup the remote address
in the wrong routing table.

For example:

  ip route add table main unreachable 2001:db8::10/124

  ip route add table 100 2001:db8::10/124 dev eth0
  ip -6 rule add dsfield 0x04 table 100

  ping -Q 0x04 2001:db8::11

Without this patch, probe_fd fails to connect to 2001:db8::11 (No route
to host) since the route lookup is done in the main table instead of
table 100.

Note that, to work correctly, this patch also depends on a Linux kernel
bug fix (see
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e010ae08c71fda8be3d6bda256837795a0b3ea41).
That kernel patch has been backported to Linux stable trees and should
have already reached most distributions.

Fixes: 3337034 ("Initial import of iputils")
Signed-off-by: Guillaume Nault <guillaume.nault@wanadoo.fr>
The IPV6_TCLASS socket option is already set in main(). There's no need
to set it again in ping6_run().

This was dead code anyway as ->opt_tclass was never set. Let's remove
this field since it's not used anywhere anymore.

Signed-off-by: Guillaume Nault <guillaume.nault@wanadoo.fr>
@pevik pevik added this to the next release milestone May 18, 2023
@pevik pevik self-assigned this May 18, 2023
@pevik

pevik commented May 18, 2023

Copy link
Copy Markdown
Contributor

Thank you. LGTM, I just need time to do some testing.

@gault

gault commented Jul 7, 2023

Copy link
Copy Markdown
Contributor Author

Thank you. LGTM, I just need time to do some testing.

Thanks @pevik. Do you have any feedback for these patches?

@pevik

pevik commented Jul 10, 2023

Copy link
Copy Markdown
Contributor

@gault I'm sorry to keep you waiting so long. I'll try to have look this week.

@pevik

pevik commented Jul 11, 2023

Copy link
Copy Markdown
Contributor

@gault I'm ok to require kernel fixes, because it was merged in 2023-02-22 to even v4.14.y.

And yes, following code really works with your changes:

ip route add table main unreachable 2001:db8::10/124
ip route add table 100 2001:db8::10/124 dev eth0
ip -6 rule add dsfield 0x04 table 100
ping -Q 0x04 2001:db8::11

Would you mind to share other setup required for ping to be successfully get reply? Ideally using network namespaces. It could be used in the testing suite I'm planning to write.

Comment thread ping/ping6_common.c
error(0, 0, _("traffic class is not supported"));
#endif
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@gault I wonder if 78aa5c1 brought the regression or if it was later by some Pavel Simerda changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it's commit ebad35f ("ping: merge ping6 command into ping"). It removed the "options |= F_TCLASS;" statement that was in ping6_main(), but didn't remove the "if (options & F_TCLASS) {" test in ping6_run().

I didn't put any Fixes: tag because that was just dead code elimination. But if we want to point to a commit, I think that should be ebad35f.

@pevik

pevik commented Jul 12, 2023

Copy link
Copy Markdown
Contributor

To both commits:

Reviewed-by: Petr Vorel <pvorel@suse.cz>

@gault

gault commented Jul 12, 2023

Copy link
Copy Markdown
Contributor Author

Would you mind to share other setup required for ping to be successfully get
reply? Ideally using network namespaces. It could be used in the testing suite I'm planning to write.

Here's a simple, self-contained, shell script that uses two network namespaces connected by a veth (Github doesn't seem to accept shell scripts, so I've renamed the file with a .txt extension).
ping_selftest.txt

pevik pushed a commit that referenced this pull request Jul 14, 2023
Set the IPV6_TCLASS option on probe_fd. Otherwise ip-rule is unaware
of the DSCP value at connect() time and can lookup the remote address
in the wrong routing table.

For example:

  ip route add table main unreachable 2001:db8::10/124

  ip route add table 100 2001:db8::10/124 dev eth0
  ip -6 rule add dsfield 0x04 table 100

  ping -Q 0x04 2001:db8::11

Without this patch, probe_fd fails to connect to 2001:db8::11 (No route
to host) since the route lookup is done in the main table instead of
table 100.

Note that, to work correctly, this patch also depends on a Linux kernel
bug fix (see
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e010ae08c71fda8be3d6bda256837795a0b3ea41).
That kernel patch has been backported to Linux stable trees and should
have already reached most distributions.

Fixes: 3337034 ("Initial import of iputils")
Link: #468
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Guillaume Nault <guillaume.nault@wanadoo.fr>
@pevik pevik closed this in d38519a Jul 14, 2023
@gault
gault deleted the ipv6_dscp branch July 14, 2023 09:31
@gault

gault commented Jul 14, 2023

Copy link
Copy Markdown
Contributor Author

Thanks pevik!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants