]> git.proxmox.com Git - iproute2.git/blob - debian/patches/f_u32
buildsys: update make upload target for stretch
[iproute2.git] / debian / patches / f_u32
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
7 patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
8
9 if [ $# -ne 1 ]; then
10 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
11 exit 1
12 fi
13 case "$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;;
19 esac
20
21 exit 0
22 @DPATCH@
23 diff -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;