diff mbox series

[net-next,6/6] xfrm: Convert __xfrm4_dst_lookup() to dscp_t.

Message ID 6069820d4452ed34b153c03da3a6ea52c279bda7.1728982714.git.gnault@redhat.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series xfrm: Convert __xfrm4_dst_lookup() and its callers to dscp_t. | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-15--15-00 (tests: 776)

Commit Message

Guillaume Nault Oct. 15, 2024, 9:11 a.m. UTC
Pass a dscp_t variable to __xfrm4_dst_lookup(), instead of an int, to
prevent accidental setting of ECN bits in ->flowi4_tos.

Callers of __xfrm4_dst_lookup() to consider are:

  * xfrm4_dst_lookup(), which already has a dscp_t variable to pass as
    parameter. We just need to remove the inet_dscp_to_dsfield()
    conversion.

  * xfrm4_get_saddr(). This function sets the tos parameter to 0, which
    is already a valid dscp_t value, so it doesn't need to be adjusted
    for the new prototype.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
 net/ipv4/xfrm4_policy.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 342a0158da91..b1968ae756c9 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -18,8 +18,9 @@ 
 #include <net/ip.h>
 #include <net/l3mdev.h>
 
-static struct dst_entry *__xfrm4_dst_lookup(struct net *net, struct flowi4 *fl4,
-					    int tos, int oif,
+static struct dst_entry *__xfrm4_dst_lookup(struct net *net,
+					    struct flowi4 *fl4, dscp_t dscp,
+					    int oif,
 					    const xfrm_address_t *saddr,
 					    const xfrm_address_t *daddr,
 					    u32 mark)
@@ -28,7 +29,7 @@  static struct dst_entry *__xfrm4_dst_lookup(struct net *net, struct flowi4 *fl4,
 
 	memset(fl4, 0, sizeof(*fl4));
 	fl4->daddr = daddr->a4;
-	fl4->flowi4_tos = tos;
+	fl4->flowi4_tos = inet_dscp_to_dsfield(dscp);
 	fl4->flowi4_l3mdev = l3mdev_master_ifindex_by_index(net, oif);
 	fl4->flowi4_mark = mark;
 	if (saddr)
@@ -48,8 +49,7 @@  static struct dst_entry *xfrm4_dst_lookup(struct net *net, dscp_t dscp,
 {
 	struct flowi4 fl4;
 
-	return __xfrm4_dst_lookup(net, &fl4, inet_dscp_to_dsfield(dscp), oif,
-				  saddr, daddr, mark);
+	return __xfrm4_dst_lookup(net, &fl4, dscp, oif, saddr, daddr, mark);
 }
 
 static int xfrm4_get_saddr(struct net *net, int oif,