From: Jiri Benc <jbenc@redhat.com>
To: netdev@vger.kernel.org
Subject: [PATCH 1/2 net-next] ipv6: helper function to get tclass
Date: Thu, 9 Feb 2012 20:34:41 +0100 [thread overview]
Message-ID: <20120209203441.24c97aa3@griffin> (raw)
Implement helper inline function to get traffic class from IPv6 header.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
include/linux/ipv6.h | 5 +++++
net/ipv6/datagram.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -233,6 +233,11 @@ static inline struct ipv6hdr *ipipv6_hdr
return (struct ipv6hdr *)skb_transport_header(skb);
}
+static inline __u8 ipv6_tclass(const struct ipv6hdr *iph)
+{
+ return (ntohl(*(__be32 *)iph) >> 20) & 0xff;
+}
+
/*
This structure contains results of exthdrs parsing
as offsets from skb->nh.
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -485,7 +485,7 @@ int datagram_recv_ctl(struct sock *sk, s
}
if (np->rxopt.bits.rxtclass) {
- int tclass = (ntohl(*(__be32 *)ipv6_hdr(skb)) >> 20) & 0xff;
+ int tclass = ipv6_tclass(ipv6_hdr(skb));
put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass);
}
next reply other threads:[~2012-02-09 19:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-09 19:34 Jiri Benc [this message]
2012-02-09 19:35 ` [PATCH 2/2 net-next] net: implement IP_RECVTOS for IP_PKTOPTIONS Jiri Benc
2012-02-13 5:49 ` David Miller
2012-02-13 5:49 ` [PATCH 1/2 net-next] ipv6: helper function to get tclass David Miller
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=20120209203441.24c97aa3@griffin \
--to=jbenc@redhat.com \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.