]> git.proxmox.com Git - iproute2.git/blame - debian/patches/f_u32
buildsys: update make upload target for stretch
[iproute2.git] / debian / patches / f_u32
CommitLineData
3cf71090
DM
1#! /bin/sh -e
2##
3## All lines beginning with `## DP:' are a description of the patch.
4## DP: Fixes the u32 calculation for 2.6 kernel - by Russell Stuart <russell-debian@stuart.id.au>
5
6[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
7patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
8
9if [ $# -ne 1 ]; then
10 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
11 exit 1
12fi
13case "$1" in
14 -patch) patch $patch_opts -p1 < $0;;
15 -unpatch) patch $patch_opts -p1 -R < $0;;
16 *)
17 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
18 exit 1;;
19esac
20
21exit 0
22@DPATCH@
23diff -Nur iproute-20051007.keep/tc/f_u32.c iproute-20051007/tc/f_u32.c
24--- iproute-20051007.keep/tc/f_u32.c 2006-01-12 17:34:37.000000000 +1000
25+++ iproute-20051007/tc/f_u32.c 2006-02-07 17:10:29.000000000 +1000
26@@ -17,6 +17,7 @@
27 #include <syslog.h>
28 #include <fcntl.h>
29 #include <sys/socket.h>
30+#include <sys/utsname.h>
31 #include <netinet/in.h>
32 #include <arpa/inet.h>
33 #include <string.h>
34@@ -874,6 +875,7 @@
35 htid = (handle&0xFFFFF000);
36 } else if (strcmp(*argv, "sample") == 0) {
37 __u32 hash;
38+ struct utsname utsname;
39 struct {
40 struct tc_u32_sel sel;
41 struct tc_u32_key keys[4];
42@@ -889,8 +891,19 @@
43 return -1;
44 }
45 hash = sel2.sel.keys[0].val&sel2.sel.keys[0].mask;
46- hash ^= hash>>16;
47- hash ^= hash>>8;
48+ uname(&utsname);
49+ if (strncmp(utsname.release, "2.4.", 4) == 0) {
50+ hash ^= hash>>16;
51+ hash ^= hash>>8;
52+ }
53+ else {
54+ __u32 mask = sel2.sel.keys[0].mask;
55+ while (mask && !(mask & 1)) {
56+ mask >>= 1;
57+ hash >>= 1;
58+ }
59+ hash &= 0xFF;
60+ }
61 htid = ((hash<<12)&0xFF000)|(htid&0xFFF00000);
62 sample_ok = 1;
63 continue;