From: Guillaume Nault <gnault@redhat.com>
To: David Miller <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>
Cc: netdev@vger.kernel.org, David Ahern <dsahern@kernel.org>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Subject: [PATCH net-next 5/7] ipv4: Convert ip_mc_validate_source() to dscp_t.
Date: Mon, 7 Oct 2024 20:24:54 +0200 [thread overview]
Message-ID: <c91b2cca04718b7ee6cf5b9c1d5b40507d65a8d4.1728302212.git.gnault@redhat.com> (raw)
In-Reply-To: <cover.1728302212.git.gnault@redhat.com>
Pass a dscp_t variable to ip_mc_validate_source(), instead of a plain
u8, to prevent accidental setting of ECN bits in ->flowi4_tos.
Callers of ip_mc_validate_source() to consider are:
* ip_route_input_mc() which already has a dscp_t variable to pass as
parameter. We just need to remove the inet_dscp_to_dsfield()
conversion.
* udp_v4_early_demux() which gets the DSCP directly from the IPv4
header and can simply use the ip4h_dscp() helper.
Also, stop including net/inet_dscp.h in udp.c as we don't use any of
its declarations anymore.
Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
include/net/route.h | 3 ++-
net/ipv4/route.c | 8 ++++----
net/ipv4/udp.c | 4 ++--
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/net/route.h b/include/net/route.h
index c219c0fecdcf..586e59f7ed8a 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -198,8 +198,9 @@ static inline struct rtable *ip_route_output_gre(struct net *net, struct flowi4
fl4->fl4_gre_key = gre_key;
return ip_route_output_key(net, fl4);
}
+
int ip_mc_validate_source(struct sk_buff *skb, __be32 daddr, __be32 saddr,
- u8 tos, struct net_device *dev,
+ dscp_t dscp, struct net_device *dev,
struct in_device *in_dev, u32 *itag);
int ip_route_input_noref(struct sk_buff *skb, __be32 daddr, __be32 saddr,
dscp_t dscp, struct net_device *dev);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 527121be1ba2..1efb65e647c1 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1666,7 +1666,7 @@ EXPORT_SYMBOL(rt_dst_clone);
/* called in rcu_read_lock() section */
int ip_mc_validate_source(struct sk_buff *skb, __be32 daddr, __be32 saddr,
- u8 tos, struct net_device *dev,
+ dscp_t dscp, struct net_device *dev,
struct in_device *in_dev, u32 *itag)
{
int err;
@@ -1687,7 +1687,8 @@ int ip_mc_validate_source(struct sk_buff *skb, __be32 daddr, __be32 saddr,
ip_hdr(skb)->protocol != IPPROTO_IGMP)
return -EINVAL;
} else {
- err = fib_validate_source(skb, saddr, 0, tos, 0, dev,
+ err = fib_validate_source(skb, saddr, 0,
+ inet_dscp_to_dsfield(dscp), 0, dev,
in_dev, itag);
if (err < 0)
return err;
@@ -1705,8 +1706,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
u32 itag = 0;
int err;
- err = ip_mc_validate_source(skb, daddr, saddr,
- inet_dscp_to_dsfield(dscp), dev, in_dev,
+ err = ip_mc_validate_source(skb, daddr, saddr, dscp, dev, in_dev,
&itag);
if (err)
return err;
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 8accbf4cb295..4b74a25d0b6e 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -100,6 +100,7 @@
#include <net/net_namespace.h>
#include <net/icmp.h>
#include <net/inet_hashtables.h>
+#include <net/ip.h>
#include <net/ip_tunnels.h>
#include <net/route.h>
#include <net/checksum.h>
@@ -115,7 +116,6 @@
#include <net/addrconf.h>
#include <net/udp_tunnel.h>
#include <net/gro.h>
-#include <net/inet_dscp.h>
#if IS_ENABLED(CONFIG_IPV6)
#include <net/ipv6_stubs.h>
#endif
@@ -2619,7 +2619,7 @@ int udp_v4_early_demux(struct sk_buff *skb)
if (!inet_sk(sk)->inet_daddr && in_dev)
return ip_mc_validate_source(skb, iph->daddr,
iph->saddr,
- iph->tos & INET_DSCP_MASK,
+ ip4h_dscp(iph),
skb->dev, in_dev, &itag);
}
return 0;
--
2.39.2
next prev parent reply other threads:[~2024-10-07 18:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-07 18:24 [PATCH net-next 0/7] ipv4: Convert __fib_validate_source() and its callers to dscp_t Guillaume Nault
2024-10-07 18:24 ` [PATCH net-next 1/7] ipv4: Convert ip_route_use_hint() " Guillaume Nault
2024-10-07 18:24 ` [PATCH net-next 2/7] ipv4: Convert ip_mkroute_input() " Guillaume Nault
2024-10-07 18:24 ` [PATCH net-next 3/7] ipv4: Convert __mkroute_input() " Guillaume Nault
2024-10-07 18:24 ` [PATCH net-next 4/7] ipv4: Convert ip_route_input_mc() " Guillaume Nault
2024-10-07 18:24 ` Guillaume Nault [this message]
2024-10-07 18:25 ` [PATCH net-next 6/7] ipv4: Convert fib_validate_source() " Guillaume Nault
2024-10-07 18:25 ` [PATCH net-next 7/7] ipv4: Convert __fib_validate_source() " Guillaume Nault
2024-10-08 8:37 ` [PATCH net-next 0/7] ipv4: Convert __fib_validate_source() and its callers " Ido Schimmel
2024-10-08 14:50 ` David Ahern
2024-10-10 0:40 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c91b2cca04718b7ee6cf5b9c1d5b40507d65a8d4.1728302212.git.gnault@redhat.com \
--to=gnault@redhat.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).