From: Eric Dumazet <eric.dumazet@gmail•com>
To: "David S . Miller" <davem@davemloft•net>,
Jakub Kicinski <kuba@kernel•org>
Cc: netdev <netdev@vger•kernel.org>,
Eric Dumazet <edumazet@google•com>,
Eric Dumazet <eric.dumazet@gmail•com>,
Neal Cardwell <ncardwell@google•com>,
Ingemar Johansson S <ingemar.s.johansson@ericsson•com>,
Tom Henderson <tomh@tomh•org>
Subject: [PATCH net-next 1/2] net: add skb_get_dsfield() helper
Date: Thu, 14 Oct 2021 10:59:17 -0700 [thread overview]
Message-ID: <20211014175918.60188-2-eric.dumazet@gmail.com> (raw)
In-Reply-To: <20211014175918.60188-1-eric.dumazet@gmail.com>
From: Eric Dumazet <edumazet@google•com>
skb_get_dsfield(skb) gets dsfield from skb, or -1
if an error was found.
This is basically a wrapper around ipv4_get_dsfield()
and ipv6_get_dsfield().
Used by following patch for fq_codel.
Signed-off-by: Eric Dumazet <edumazet@google•com>
Cc: Neal Cardwell <ncardwell@google•com>
Cc: Ingemar Johansson S <ingemar.s.johansson@ericsson•com>
Cc: Tom Henderson <tomh@tomh•org>
---
include/net/inet_ecn.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
index ba77f47ef61ed3dbb38504ece304c00825f461fd..ea32393464a291aad77400b34fcdcb5031f01676 100644
--- a/include/net/inet_ecn.h
+++ b/include/net/inet_ecn.h
@@ -188,6 +188,23 @@ static inline int INET_ECN_set_ce(struct sk_buff *skb)
return 0;
}
+static inline int skb_get_dsfield(struct sk_buff *skb)
+{
+ switch (skb_protocol(skb, true)) {
+ case cpu_to_be16(ETH_P_IP):
+ if (!pskb_network_may_pull(skb, sizeof(struct iphdr)))
+ break;
+ return ipv4_get_dsfield(ip_hdr(skb));
+
+ case cpu_to_be16(ETH_P_IPV6):
+ if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr)))
+ break;
+ return ipv6_get_dsfield(ipv6_hdr(skb));
+ }
+
+ return -1;
+}
+
static inline int INET_ECN_set_ect1(struct sk_buff *skb)
{
switch (skb_protocol(skb, true)) {
--
2.33.0.1079.g6e70778dc9-goog
next prev parent reply other threads:[~2021-10-14 17:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-14 17:59 [PATCH net-next 0/2] net/sched: implement L4S style ce_threshold_ect1 marking Eric Dumazet
2021-10-14 17:59 ` Eric Dumazet [this message]
2021-10-14 17:59 ` [PATCH net-next 2/2] fq_codel: " Eric Dumazet
2021-10-14 19:54 ` Toke Høiland-Jørgensen
2021-10-14 21:35 ` Eric Dumazet
2021-10-14 23:24 ` Toke Høiland-Jørgensen
2021-10-16 7:39 ` Jonathan Morton
2021-10-17 11:22 ` Bob Briscoe
2021-10-17 12:18 ` Jonathan Morton
2021-10-18 19:43 ` Gorry Fairhurst
2021-10-15 12:59 ` Bob Briscoe
2021-10-15 14:08 ` Eric Dumazet
2021-10-15 15:49 ` Neal Cardwell
2021-10-17 0:42 ` Bob Briscoe
2021-10-18 11:42 ` Dave Taht
2021-10-15 10:40 ` [PATCH net-next 0/2] net/sched: " patchwork-bot+netdevbpf
2021-10-15 13:01 ` Toke Høiland-Jørgensen
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=20211014175918.60188-2-eric.dumazet@gmail.com \
--to=eric.dumazet@gmail$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=ingemar.s.johansson@ericsson$(echo .)com \
--cc=kuba@kernel$(echo .)org \
--cc=ncardwell@google$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=tomh@tomh$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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