arbitrator9.61 on linux-2.4.30 miniHOWTO
Marcello Pivanti (quakeiggy@hotmail.com)
v1.0, September 20th 2005
These are just the simple steps to backport arbitrator9.61 from linux-2.6.5 to linux-2.4.30
1) Download the arbitrator (arbitrator9.61.tar.gz)
2) Arbitrator9.61 is for kernel 2.6.5 so download linux-2.6.5.tar.bz2
3) Download the new kernel you need to try to install arbitrator,
in this case is kernel 2.4.30 so download linux-2.4.30.tar.bz2
4) Unpack the packages
tar xvzf arbitrator9.61.tar.gz
tar xvjf linux-2.6.5.tar.bz2
tar xvjf linux-2.4.30.tar.bz2
5) Take a look of the Arbitrator structure,
the only files interesting in this case are:
arbitrator9.61/usr/src/linux/include/linux/if_bridge.h
arbitrator9.61/usr/src/linux/include/linux/netfilter_bridge.h
arbitrator9.61/usr/src/linux/net/bridge/br_private.h
arbitrator9.61/usr/src/linux/net/bridge/regexp.h
arbitrator9.61/usr/src/linux/net/bridge/regmagic.h
arbitrator9.61/usr/src/linux/net/bridge/br.c
arbitrator9.61/usr/src/linux/net/bridge/br_device.c
arbitrator9.61/usr/src/linux/net/bridge/br_forward.c
arbitrator9.61/usr/src/linux/net/bridge/br_if.c
arbitrator9.61/usr/src/linux/net/bridge/br_input.c
arbitrator9.61/usr/src/linux/net/bridge/br_ioctl.c
arbitrator9.61/usr/src/linux/net/bridge/linux_BA_hook.c
arbitrator9.61/usr/src/linux/net/bridge/Makefile
6) Try to find the aforesaid files in the kernel 2.6.5:
linux-2.6.5/include/linux/if_bridge.h ...FOUND
linux-2.6.5/include/linux/netfilter_bridge.h ...FOUND
linux-2.6.5/net/bridge/br_private.h ...FOUND
linux-2.6.5/net/bridge/regexp.h ...NOT FOUND
linux-2.6.5/net/bridge/regmagic.h ...NOT FOUND
linux-2.6.5/net/bridge/br.c ...FOUND
linux-2.6.5/net/bridge/br_device.c ...FOUND
linux-2.6.5/net/bridge/br_forward.c ...FOUND
linux-2.6.5/net/bridge/br_if.c ...FOUND
linux-2.6.5/net/bridge/br_input.c ...FOUND
linux-2.6.5/net/bridge/br_ioctl.c ...FOUND
linux-2.6.5/net/bridge/linux_BA_hook.c ...NOT FOUND
linux-2.6.5/net/bridge/Makefile ...FOUND
7) The files
arbitrator9.61/usr/src/linux/net/bridge/regexp.h
arbitrator9.61/usr/src/linux/net/bridge/regmagic.h
arbitrator9.61/usr/src/linux/net/bridge/linux_BA_hook.c
are Arbitrator-specific files so they are not in the kernel 2.6.5
8) List the differences for every file:
diff -u -b -B linux-2.6.5/include/linux/if_bridge.h arbitrator9.61/usr/src/linux/include/linux/if_bridge.h >> differences1.diff
diff -u -b -B linux-2.6.5/include/linux/netfilter_bridge.h arbitrator9.61/usr/src/linux/include/linux/netfilter_bridge.h >> differences1.diff
diff -u -b -B linux-2.6.5/net/bridge/br_private.h arbitrator9.61/usr/src/linux/net/bridge/br_private.h >> differences1.diff
diff -u -b -B linux-2.6.5/net/bridge/br.c arbitrator9.61/usr/src/linux/net/bridge/br.c >> differences1.diff
diff -u -b -B linux-2.6.5/net/bridge/br_device.c arbitrator9.61/usr/src/linux/net/bridge/br_device.c >> differences1.diff
diff -u -b -B linux-2.6.5/net/bridge/br_forward.c arbitrator9.61/usr/src/linux/net/bridge/br_forward.c >> differences1.diff
diff -u -b -B linux-2.6.5/net/bridge/br_if.c arbitrator9.61/usr/src/linux/net/bridge/br_if.c >> differences1.diff
diff -u -b -B linux-2.6.5/net/bridge/br_input.c arbitrator9.61/usr/src/linux/net/bridge/br_input.c >> differences1.diff
diff -u -b -B linux-2.6.5/net/bridge/br_ioctl.c arbitrator9.61/usr/src/linux/net/bridge/br_ioctl.c >> differences1.diff
diff -u -b -B linux-2.6.5/net/bridge/Makefile arbitrator9.61/usr/src/linux/net/bridge/Makefile >> differences1.diff
9) Read the file differences1.diff:
in if_bridge.h there are several #define added
netfilter_bridge.h does not presents modifies
in br_private.h there is the heart of the Arbitrator headers and the extension of the arguments for the bridge functions
in br.c there is the insertion of Arbitrator in the bridge structure
in br_device.c there is the extension of the arguments for the bridge functions
in br_forward.c the kernel hook managment is overrided by the Arbitrator hook management
in br_ioctl.c there is the extension of the arguments for the bridge functions and the control of the insertion of the Arbitrator input/output control
in Makefile is only added the instruction to compile Arbitrator
10) Try to find the files at point (5) in the kernel 2.4.30:
linux-2.4.30/include/linux/if_bridge.h ...FOUND
linux-2.4.30/include/linux/netfilter_bridge.h ...FOUND
linux-2.4.30/net/bridge/br_private.h ...FOUND
linux-2.4.30/net/bridge/regexp.h ...NOT FOUND
linux-2.4.30/net/bridge/regmagic.h ...NOT FOUND
linux-2.4.30/net/bridge/br.c ...FOUND
linux-2.4.30/net/bridge/br_device.c ...FOUND
linux-2.4.30/net/bridge/br_forward.c ...FOUND
linux-2.4.30/net/bridge/br_if.c ...FOUND
linux-2.4.30/net/bridge/br_input.c ...FOUND
linux-2.4.30/net/bridge/br_ioctl.c ...FOUND
linux-2.4.30/net/bridge/linux_BA_hook.c ...NOT FOUND
linux-2.4.30/net/bridge/Makefile ...FOUND
11) Like at point (6) the files
arbitrator9.61/usr/src/linux/net/bridge/regexp.h
arbitrator9.61/usr/src/linux/net/bridge/regmagic.h
arbitrator9.61/usr/src/linux/net/bridge/linux_BA_hook.c
are Arbitrator-specific files so they are not in the kernel 2.4.30
12) List the differeces between the kernels:
diff -u -b -B linux-2.4.30/include/linux/if_bridge.h linux-2.6.5/include/linux/if_bridge.h >> differences2.diff
diff -u -b -B linux-2.4.30/include/linux/netfilter_bridge.h linux-2.6.5/include/linux/netfilter_bridge.h >> differences2.diff
diff -u -b -B linux-2.4.30/net/bridge/br_private.h linux-2.6.5/net/bridge/br_private.h >> differences2.diff
diff -u -b -B linux-2.4.30/net/bridge/br.c linux-2.6.5/net/bridge/br.c >> differences2.diff
diff -u -b -B linux-2.4.30/net/bridge/br_device.c linux-2.6.5/net/bridge/br_device.c >> differences2.diff
diff -u -b -B linux-2.4.30/net/bridge/br_forward.c linux-2.6.5/net/bridge/br_forward.c >> differences2.diff
diff -u -b -B linux-2.4.30/net/bridge/br_if.c linux-2.6.5/net/bridge/br_if.c >> differences2.diff
diff -u -b -B linux-2.4.30/net/bridge/br_input.c linux-2.6.5/net/bridge/br_input.c >> differences2.diff
diff -u -b -B linux-2.4.30/net/bridge/br_ioctl.c linux-2.6.5/net/bridge/br_ioctl.c >> differences2.diff
diff -u -b -B linux-2.4.30/net/bridge/Makefile linux-2.6.5/net/bridge/Makefile >> differences2.diff
13) Read the file differences2.diff:
There are several changes but nothing interesting for our work
14) NOW IT IS TIME TO MAKE THE MAGIC!!!
(YOU HAVE TO APPLY ALL THE CHANGES IN THE FILES OF KERNEL 2.4.30)
Open files differences1.diff and differences2.diff, compare them, as you can see:
a) in section "if_bridge.h" the only difference is in the addition of 26 arbitrator #define
so in file linux-2.4.30/include/linux/if_bridge.h at line 41 add the 26 arbitrator #define
b) in section "br_private.h" there is a large section starting with "/*********************Linux BA ***********************/"
and ending with "/*******************eend linux BA ***********************/"
it is the heart of Arbitrator headers so in file linux-2.4.30/net/bridge/br_private.h add the entire section
at line 27 (between "#define BR_HOLD_TIME (1*HZ)" and "typedef struct bridge_id bridge_id;)",
as you can see
the input output control of the bridge in the normal kernel need just 4 arguments
but the input output control of the bridge in the Arbitrator need 5 arguments
so add at line 437 (in the declaration of the extern function)
"extern int br_ioctl(...)"
insert the fifth argument "unsigned long arg3"
c) in section "br.c" just insert the call for the function "linux_BA_hook_init();" at line 60.
d) in section "br_device.c" apply the modify seen at point (b) so
in function "br_dev_do_ioctl(...)" replace the size of the array (5 instead of 4) at line 24
in the instruction "if (copy_from_user(args, data, 4*sizeof(unsigned long)))" place the number 5 instead of 4 at line 31,
add the fifth argument "args[4]" in the instruction "return br_ioctl(...);" at line 34
e) in section "br_forward.c" Arbitrator must override of the normal kernel HOOK system so
place the instruction "linux_BA_hook(to ,skb);" at line 69
and comment (or delete) the instruction "NF_HOOK(PF_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev, br_forward_finish);" at lines 70-71,
then insert the declaration "int bandwi;" at line 65 (BUT I DO NOT UNDERSTAND WHY!!!)
f) in section "br_ioctl.c", as seen at point (b)
at line 27 add the fifth argument "unsigned long arg3" at function "br_ioctl_device(...)",
at line 31 add "if (linux_BA_ioctl(br,cmd,arg0,arg1,arg2,arg3)) return 0;",
at line 251 add the fifth argument "unsigned long arg3" at function "br_ioctl(...)",
at line 257 add the fifth argument "arg3" at the function call "return br_ioctl_device(br, cmd, arg0, arg1, arg2);"
e) in section "Makefile" just add the instruction "linux_BA_hook.o" at line 15 to compile the Arbitrator HOOK system
15) Remember to copy the files
arbitrator9.61/usr/src/linux/net/bridge/regexp.h
arbitrator9.61/usr/src/linux/net/bridge/regmagic.h
arbitrator9.61/usr/src/linux/net/bridge/linux_BA_hook.c
in linux-2.4.30/net/bridge/
16) Now you have the kernel 2.4.30 ready to be compiled!
17) If you want to prepare a patch just rename the directory linux-2.4.30 in linux-2.4.30ARB
and unpack one more time the file linux-2.4.30.tar.bz2
tar xvjf linux-2.4.30.tar.bz2
then make a diff of the directories
diff -u -r -b -B -N linux-2.4.30 linux-2.4.30ARB > Arbitrator9.61_against_linux-2.4.30.diff
now open the file "Arbitrator9.61_against_linux-2.4.30.diff" and
replace the string "linux-2.4.30ARB" with the string "linux-2.4.30",
save it and your patch is ready!