OSDN Git Service

Merge tag 'drivers-3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / net / sched / cls_fw.c
index ed00e8c..63a3ce7 100644 (file)
 #include <net/act_api.h>
 #include <net/pkt_cls.h>
 
-#define HTSIZE (PAGE_SIZE/sizeof(struct fw_filter *))
+#define HTSIZE 256
 
 struct fw_head {
-       struct fw_filter *ht[HTSIZE];
-       u32 mask;
+       u32                     mask;
+       struct fw_filter        *ht[HTSIZE];
 };
 
 struct fw_filter {
@@ -46,30 +46,11 @@ struct fw_filter {
        struct tcf_exts         exts;
 };
 
-static inline int fw_hash(u32 handle)
+static u32 fw_hash(u32 handle)
 {
-       if (HTSIZE == 4096)
-               return ((handle >> 24) & 0xFFF) ^
-                      ((handle >> 12) & 0xFFF) ^
-                      (handle & 0xFFF);
-       else if (HTSIZE == 2048)
-               return ((handle >> 22) & 0x7FF) ^
-                      ((handle >> 11) & 0x7FF) ^
-                      (handle & 0x7FF);
-       else if (HTSIZE == 1024)
-               return ((handle >> 20) & 0x3FF) ^
-                      ((handle >> 10) & 0x3FF) ^
-                      (handle & 0x3FF);
-       else if (HTSIZE == 512)
-               return (handle >> 27) ^
-                      ((handle >> 18) & 0x1FF) ^
-                      ((handle >> 9) & 0x1FF) ^
-                      (handle & 0x1FF);
-       else if (HTSIZE == 256) {
-               u8 *t = (u8 *) &handle;
-               return t[0] ^ t[1] ^ t[2] ^ t[3];
-       } else
-               return handle & (HTSIZE - 1);
+       handle ^= (handle >> 16);
+       handle ^= (handle >> 8);
+       return handle % HTSIZE;
 }
 
 static int fw_classify(struct sk_buff *skb, const struct tcf_proto *tp,
@@ -209,8 +190,10 @@ fw_change_attrs(struct net *net, struct tcf_proto *tp, struct fw_filter *f,
        if (tb[TCA_FW_INDEV]) {
                int ret;
                ret = tcf_change_indev(net, tb[TCA_FW_INDEV]);
-               if (ret < 0)
+               if (ret < 0) {
+                       err = ret;
                        goto errout;
+               }
                f->ifindex = ret;
        }
 #endif /* CONFIG_NET_CLS_IND */