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

ipv6: helper function to get tclass

Implement helper inline function to get traffic class from IPv6 header.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jiri Benc and committed by
David S. Miller
7a3198a8 72e60278

+6 -1
+5
include/linux/ipv6.h
··· 233 233 return (struct ipv6hdr *)skb_transport_header(skb); 234 234 } 235 235 236 + static inline __u8 ipv6_tclass(const struct ipv6hdr *iph) 237 + { 238 + return (ntohl(*(__be32 *)iph) >> 20) & 0xff; 239 + } 240 + 236 241 /* 237 242 This structure contains results of exthdrs parsing 238 243 as offsets from skb->nh.
+1 -1
net/ipv6/datagram.c
··· 485 485 } 486 486 487 487 if (np->rxopt.bits.rxtclass) { 488 - int tclass = (ntohl(*(__be32 *)ipv6_hdr(skb)) >> 20) & 0xff; 488 + int tclass = ipv6_tclass(ipv6_hdr(skb)); 489 489 put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); 490 490 } 491 491