Message ID | b827a871f8dbc204f08e7f741242ba7f7d5cb8ab.1675875519.git.gnault@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Commit | e010ae08c71fda8be3d6bda256837795a0b3ea41 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | ipv6: Fix socket connection with DSCP fib-rules. | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net |
netdev/fixes_present | success | Fixes tag present in non-next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/cc_maintainers | success | CCed 7 of 7 maintainers |
netdev/build_clang | success | Errors and warnings before: 0 this patch: 0 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | Fixes tag looks correct |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 8 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Wed, Feb 8, 2023 at 6:14 PM Guillaume Nault <gnault@redhat.com> wrote: > > Take into account the IPV6_TCLASS socket option (DSCP) in > ip6_datagram_flow_key_init(). Otherwise fib6_rule_match() can't > properly match the DSCP value, resulting in invalid route lookup. > > > Fixes: 2cc67cc731d9 ("[IPV6] ROUTE: Routing by Traffic Class.") > Signed-off-by: Guillaume Nault <gnault@redhat.com> Reviewed-by: Eric Dumazet <edumazet@google.com>
On 2/8/23 10:13 AM, Guillaume Nault wrote: > Take into account the IPV6_TCLASS socket option (DSCP) in > ip6_datagram_flow_key_init(). Otherwise fib6_rule_match() can't > properly match the DSCP value, resulting in invalid route lookup. > > For example: > > ip route add unreachable table main 2001:db8::10/124 > > ip route add table 100 2001:db8::10/124 dev eth0 > ip -6 rule add dsfield 0x04 table 100 > > echo test | socat - UDP6:[2001:db8::11]:54321,ipv6-tclass=0x04 > > Without this patch, socat fails at connect() time ("No route to host") > because the fib-rule doesn't jump to table 100 and the lookup ends up > being done in the main table. > > Fixes: 2cc67cc731d9 ("[IPV6] ROUTE: Routing by Traffic Class.") > Signed-off-by: Guillaume Nault <gnault@redhat.com> > --- > net/ipv6/datagram.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > Reviewed-by: David Ahern <dsahern@kernel.org>
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index e624497fa992..9b6818453afe 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -51,7 +51,7 @@ static void ip6_datagram_flow_key_init(struct flowi6 *fl6, struct sock *sk) fl6->flowi6_mark = sk->sk_mark; fl6->fl6_dport = inet->inet_dport; fl6->fl6_sport = inet->inet_sport; - fl6->flowlabel = np->flow_label; + fl6->flowlabel = ip6_make_flowinfo(np->tclass, np->flow_label); fl6->flowi6_uid = sk->sk_uid; if (!oif)
Take into account the IPV6_TCLASS socket option (DSCP) in ip6_datagram_flow_key_init(). Otherwise fib6_rule_match() can't properly match the DSCP value, resulting in invalid route lookup. For example: ip route add unreachable table main 2001:db8::10/124 ip route add table 100 2001:db8::10/124 dev eth0 ip -6 rule add dsfield 0x04 table 100 echo test | socat - UDP6:[2001:db8::11]:54321,ipv6-tclass=0x04 Without this patch, socat fails at connect() time ("No route to host") because the fib-rule doesn't jump to table 100 and the lookup ends up being done in the main table. Fixes: 2cc67cc731d9 ("[IPV6] ROUTE: Routing by Traffic Class.") Signed-off-by: Guillaume Nault <gnault@redhat.com> --- net/ipv6/datagram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)