diff options
author | Jiri Benc <jbenc@redhat.com> | 2012-02-09 04:34:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-02-13 00:45:38 -0500 |
commit | 7a3198a89722ad9521d22b05938d357eac7460fa (patch) | |
tree | ca5766b459c7a9a1502fa519a9d287c7c29dcd9c | |
parent | 72e60278d7e4a600fd6e067b42a5822e72946d6e (diff) |
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>
-rw-r--r-- | include/linux/ipv6.h | 5 | ||||
-rw-r--r-- | net/ipv6/datagram.c | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 743a16a41040..4847a64d3c0a 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h | |||
@@ -233,6 +233,11 @@ static inline struct ipv6hdr *ipipv6_hdr(const struct sk_buff *skb) | |||
233 | return (struct ipv6hdr *)skb_transport_header(skb); | 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 | This structure contains results of exthdrs parsing | 242 | This structure contains results of exthdrs parsing |
238 | as offsets from skb->nh. | 243 | as offsets from skb->nh. |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 251e7cd75e89..76832c8dc89d 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
@@ -485,7 +485,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) | |||
485 | } | 485 | } |
486 | 486 | ||
487 | if (np->rxopt.bits.rxtclass) { | 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 | put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); | 489 | put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); |
490 | } | 490 | } |
491 | 491 | ||