]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ipv6: move IPV6_TCLASS_SHIFT into ipv6.h and define a helper
authorLi RongQing <roy.qing.li@gmail.com>
Wed, 15 Jan 2014 09:03:30 +0000 (17:03 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Jan 2014 23:53:18 +0000 (15:53 -0800)
Two places defined IPV6_TCLASS_SHIFT, so we should move it into ipv6.h,
and use this macro as possible. And define ip6_tclass helper to return
tclass

Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ipv6.h
net/ipv6/fib6_rules.c
net/ipv6/ip6_gre.c
net/ipv6/ip6_tunnel.c
net/ipv6/ipv6_sockglue.c

index 12079c65ea3ed69b3c361cd83efd3908eac5841f..6d80f51897a5eb24452bfdfe40d307f68f00ae35 100644 (file)
@@ -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;
@@ -681,6 +682,10 @@ static inline __be32 ip6_flowlabel(const struct ipv6hdr *hdr)
        return *(__be32 *)hdr & IPV6_FLOWLABEL_MASK;
 }
 
+static inline u8 ip6_tclass(__be32 flowinfo)
+{
+       return ntohl(flowinfo & IPV6_TCLASS_MASK) >> IPV6_TCLASS_SHIFT;
+}
 /*
  *     Prototypes exported by ipv6
  */
index 3fd0a578329e523828fc56b40b6ffe217fd850dc..b4d5e1d97c1b2576fc02a15b7a05a773197bb8e0 100644 (file)
@@ -169,7 +169,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 != ip6_tclass(fl6->flowlabel))
                return 0;
 
        return 1;
index e7a440dd5c0d75405a5faf083c8f634583d7eb16..f3ffb43f59c08634187f939db338413dd9a5514f 100644 (file)
@@ -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)
 
index 1e5e2404f1af51c4d230ac91817bb5805f62b856..5db8d310f9c07adc656dff9e3e909f611dbc1b1b 100644 (file)
@@ -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)
 
index af0ecb94b3b44cefe2d1575ebec2e46b3d2d1979..2855b00ed49d94ee5fdbca67af9249a54e349035 100644 (file)
@@ -1019,7 +1019,8 @@ 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 = (int)ip6_tclass(np->rcv_flowinfo);
+
                                put_cmsg(&msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass);
                        }
                        if (np->rxopt.bits.rxoinfo) {