Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: add skb_get_dsfield() helper

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>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
70e939dd 19757ceb

+17
+17
include/net/inet_ecn.h
··· 188 188 return 0; 189 189 } 190 190 191 + static inline int skb_get_dsfield(struct sk_buff *skb) 192 + { 193 + switch (skb_protocol(skb, true)) { 194 + case cpu_to_be16(ETH_P_IP): 195 + if (!pskb_network_may_pull(skb, sizeof(struct iphdr))) 196 + break; 197 + return ipv4_get_dsfield(ip_hdr(skb)); 198 + 199 + case cpu_to_be16(ETH_P_IPV6): 200 + if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr))) 201 + break; 202 + return ipv6_get_dsfield(ipv6_hdr(skb)); 203 + } 204 + 205 + return -1; 206 + } 207 + 191 208 static inline int INET_ECN_set_ect1(struct sk_buff *skb) 192 209 { 193 210 switch (skb_protocol(skb, true)) {