* [PATCH net-next] ipv6: move IPV6_TCLASS_SHIFT into ipv6.h
@ 2014-01-08 9:37 roy.qing.li
2014-01-09 10:18 ` RongQing Li
0 siblings, 1 reply; 2+ messages in thread
From: roy.qing.li @ 2014-01-08 9:37 UTC (permalink / raw)
To: netdev
From: Li RongQing <roy.qing.li@gmail.com>
Two places defined IPV6_TCLASS_SHIFT, so we should move it into ipv6.h,
and use this macro as possible.
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
include/net/ipv6.h | 1 +
net/ipv6/fib6_rules.c | 4 +++-
net/ipv6/ip6_gre.c | 2 --
net/ipv6/ip6_tunnel.c | 2 --
net/ipv6/ipv6_sockglue.c | 4 +++-
5 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 12079c6..d819f7a 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -239,6 +239,7 @@ struct ip6_flowlabel {
#define IPV6_FLOWINFO_MASK cpu_to_be32(0x0FFFFFFF)
#define IPV6_FLOWLABEL_MASK cpu_to_be32(0x000FFFFF)
#define IPV6_TCLASS_MASK (IPV6_FLOWINFO_MASK & ~IPV6_FLOWLABEL_MASK)
+#define IPV6_TCLASS_SHIFT 20
struct ipv6_fl_socklist {
struct ipv6_fl_socklist __rcu *next;
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 3fd0a57..d50c5ca 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -150,6 +150,8 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
{
struct fib6_rule *r = (struct fib6_rule *) rule;
struct flowi6 *fl6 = &fl->u.ip6;
+ u8 tclass = (ntohl(fl6->flowlabel) & IPV6_TCLASS_MASK) >>
+ IPV6_TCLASS_SHIFT;
if (r->dst.plen &&
!ipv6_prefix_equal(&fl6->daddr, &r->dst.addr, r->dst.plen))
@@ -169,7 +171,7 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
return 0;
}
- if (r->tclass && r->tclass != ((ntohl(fl6->flowlabel) >> 20) & 0xff))
+ if (r->tclass && r->tclass != tclass)
return 0;
return 1;
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index e7a440d..f3ffb43 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -61,8 +61,6 @@ static bool log_ecn_error = true;
module_param(log_ecn_error, bool, 0644);
MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
-#define IPV6_TCLASS_SHIFT 20
-
#define HASH_SIZE_SHIFT 5
#define HASH_SIZE (1 << HASH_SIZE_SHIFT)
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 1e5e240..5db8d31 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -69,8 +69,6 @@ MODULE_ALIAS_NETDEV("ip6tnl0");
#define IP6_TNL_TRACE(x...) do {;} while(0)
#endif
-#define IPV6_TCLASS_SHIFT 20
-
#define HASH_SIZE_SHIFT 5
#define HASH_SIZE (1 << HASH_SIZE_SHIFT)
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index af0ecb9..1c9aa35 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -1019,7 +1019,9 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
put_cmsg(&msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim);
}
if (np->rxopt.bits.rxtclass) {
- int tclass = ntohl(np->rcv_flowinfo & IPV6_TCLASS_MASK) >> 20;
+ int tclass = ntohl(np->rcv_flowinfo &
+ IPV6_TCLASS_MASK) >>
+ IPV6_TCLASS_SHIFT;
put_cmsg(&msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass);
}
if (np->rxopt.bits.rxoinfo) {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next] ipv6: move IPV6_TCLASS_SHIFT into ipv6.h
2014-01-08 9:37 [PATCH net-next] ipv6: move IPV6_TCLASS_SHIFT into ipv6.h roy.qing.li
@ 2014-01-09 10:18 ` RongQing Li
0 siblings, 0 replies; 2+ messages in thread
From: RongQing Li @ 2014-01-09 10:18 UTC (permalink / raw)
To: netdev
On Wed, Jan 8, 2014 at 5:37 PM, <roy.qing.li@gmail.com> wrote:
> From: Li RongQing <roy.qing.li@gmail.com>
>
> Two places defined IPV6_TCLASS_SHIFT, so we should move it into ipv6.h,
> and use this macro as possible.
>
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
> ---
> include/net/ipv6.h | 1 +
> net/ipv6/fib6_rules.c | 4 +++-
> net/ipv6/ip6_gre.c | 2 --
> net/ipv6/ip6_tunnel.c | 2 --
> net/ipv6/ipv6_sockglue.c | 4 +++-
> 5 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> index 12079c6..d819f7a 100644
> --- a/include/net/ipv6.h
> +++ b/include/net/ipv6.h
> @@ -239,6 +239,7 @@ struct ip6_flowlabel {
> #define IPV6_FLOWINFO_MASK cpu_to_be32(0x0FFFFFFF)
> #define IPV6_FLOWLABEL_MASK cpu_to_be32(0x000FFFFF)
> #define IPV6_TCLASS_MASK (IPV6_FLOWINFO_MASK & ~IPV6_FLOWLABEL_MASK)
> +#define IPV6_TCLASS_SHIFT 20
>
> struct ipv6_fl_socklist {
> struct ipv6_fl_socklist __rcu *next;
> diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
> index 3fd0a57..d50c5ca 100644
> --- a/net/ipv6/fib6_rules.c
> +++ b/net/ipv6/fib6_rules.c
> @@ -150,6 +150,8 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
> {
> struct fib6_rule *r = (struct fib6_rule *) rule;
> struct flowi6 *fl6 = &fl->u.ip6;
> + u8 tclass = (ntohl(fl6->flowlabel) & IPV6_TCLASS_MASK) >>
> + IPV6_TCLASS_SHIFT;
Please drop this patch, it has bug.
The correct should be:
u8 tclass =ntohl(fl6->flowlabe & IPV6_TCLASS_MASK) >> IPV6_TCLASS_SHIFT
Thanks
-Roy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-09 10:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-08 9:37 [PATCH net-next] ipv6: move IPV6_TCLASS_SHIFT into ipv6.h roy.qing.li
2014-01-09 10:18 ` RongQing Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).