aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Kleikamp <shaggy@austin.ibm.com>2005-07-26 10:55:10 -0400
committerDave Kleikamp <shaggy@austin.ibm.com>2005-07-26 10:55:10 -0400
commitde8fd087b280797977b012a4275ee53ff2999f3f (patch)
tree5cd65289983ad65812a6a4335fe657eeb125a7f0
parent18190cc08d70a6ec8ef69f0f6ede021f7cb3f9b8 (diff)
parent6b6a93c6876ea1c530d5d3f68e3678093a27fab0 (diff)
Merge with /home/shaggy/git/linus-clean/
Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
-rw-r--r--arch/arm/boot/compressed/head-shark.S42
-rw-r--r--arch/arm/configs/bast_defconfig1
-rw-r--r--arch/arm/configs/s3c2410_defconfig1
-rw-r--r--arch/arm/kernel/smp.c6
-rw-r--r--arch/arm/mach-integrator/platsmp.c8
-rw-r--r--arch/arm/mach-s3c2410/dma.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-bast.c37
-rw-r--r--arch/arm/nwfpe/fpa11.h4
-rw-r--r--arch/arm/nwfpe/fpmodule.c2
-rw-r--r--arch/arm/nwfpe/fpmodule.inl14
-rw-r--r--arch/i386/kernel/i387.c11
-rw-r--r--arch/i386/kernel/process.c20
-rw-r--r--arch/i386/kernel/setup.c14
-rw-r--r--arch/sparc64/kernel/entry.S17
-rw-r--r--arch/sparc64/kernel/irq.c20
-rw-r--r--arch/sparc64/kernel/process.c2
-rw-r--r--arch/sparc64/kernel/smp.c2
-rw-r--r--arch/sparc64/kernel/traps.c2
-rw-r--r--crypto/cipher.c6
-rw-r--r--crypto/internal.h2
-rw-r--r--drivers/acpi/ec.c17
-rw-r--r--drivers/atm/ambassador.c4
-rw-r--r--drivers/atm/firestream.c6
-rw-r--r--drivers/atm/he.c1
-rw-r--r--drivers/atm/idt77252.c3
-rw-r--r--drivers/atm/zatm.c107
-rw-r--r--drivers/atm/zatm.h1
-rw-r--r--drivers/net/Kconfig18
-rw-r--r--drivers/net/eql.c16
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c3
-rw-r--r--drivers/net/wan/sdla_fr.c7
-rw-r--r--drivers/net/wan/sdla_ft1.c3
-rw-r--r--drivers/net/wan/sdla_ppp.c3
-rw-r--r--drivers/net/wan/sdla_x25.c3
-rw-r--r--drivers/net/wan/wanpipe_multppp.c9
-rw-r--r--drivers/sbus/char/Kconfig14
-rw-r--r--drivers/sbus/char/aurora.c6
-rw-r--r--drivers/sbus/char/bbc_envctrl.c3
-rw-r--r--drivers/sbus/char/envctrl.c10
-rw-r--r--drivers/sbus/char/vfc_i2c.c8
-rw-r--r--drivers/serial/8250_pci.c51
-rw-r--r--drivers/serial/Kconfig7
-rw-r--r--drivers/serial/Makefile1
-rw-r--r--drivers/serial/bast_sio.c80
-rw-r--r--drivers/usb/atm/speedtch.c12
-rw-r--r--drivers/video/imxfb.c14
-rw-r--r--drivers/video/imxfb.h1
-rw-r--r--drivers/w1/w1_int.c2
-rw-r--r--include/asm-arm/arch-imx/imxfb.h1
-rw-r--r--include/asm-arm/locks.h4
-rw-r--r--include/asm-arm/spinlock.h35
-rw-r--r--include/asm-i386/i387.h26
-rw-r--r--include/asm-sparc64/bitops.h56
-rw-r--r--include/asm-sparc64/ptrace.h5
-rw-r--r--include/asm-sparc64/rwsem.h48
-rw-r--r--include/asm-sparc64/spitfire.h130
-rw-r--r--include/asm-sparc64/system.h11
-rw-r--r--include/asm-sparc64/thread_info.h12
-rw-r--r--include/asm-sparc64/timer.h41
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack.h3
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_helper.h7
-rw-r--r--include/linux/netlink.h2
-rw-r--r--include/linux/pci_ids.h2
-rw-r--r--include/linux/skbuff.h3
-rw-r--r--include/linux/tc_ematch/tc_em_meta.h5
-rw-r--r--include/net/sctp/sctp.h7
-rw-r--r--include/net/xfrm.h2
-rw-r--r--net/Kconfig16
-rw-r--r--net/atm/Kconfig4
-rw-r--r--net/atm/svc.c4
-rw-r--r--net/bridge/netfilter/Kconfig2
-rw-r--r--net/core/Makefile3
-rw-r--r--net/core/skbuff.c4
-rw-r--r--net/ipv4/Kconfig12
-rw-r--r--net/ipv4/af_inet.c2
-rw-r--r--net/ipv4/fib_trie.c772
-rw-r--r--net/ipv4/ipip.c36
-rw-r--r--net/ipv4/netfilter/ip_conntrack_amanda.c8
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c43
-rw-r--r--net/ipv4/netfilter/ip_conntrack_ftp.c14
-rw-r--r--net/ipv4/netfilter/ip_conntrack_irc.c8
-rw-r--r--net/ipv4/netfilter/ip_conntrack_standalone.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_tftp.c8
-rw-r--r--net/ipv4/netfilter/ip_nat_amanda.c4
-rw-r--r--net/ipv4/netfilter/ip_nat_ftp.c4
-rw-r--r--net/ipv4/netfilter/ip_nat_irc.c4
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_icmp.c7
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_tcp.c3
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_udp.c3
-rw-r--r--net/ipv4/netfilter/ip_nat_tftp.c4
-rw-r--r--net/ipv4/xfrm4_tunnel.c3
-rw-r--r--net/ipv6/Kconfig1
-rw-r--r--net/ipv6/ip6_tunnel.c38
-rw-r--r--net/ipv6/netfilter/ip6_queue.c2
-rw-r--r--net/ipv6/netfilter/ip6t_LOG.c11
-rw-r--r--net/netlink/af_netlink.c5
-rw-r--r--net/sched/em_meta.c62
-rw-r--r--net/sched/em_text.c3
-rw-r--r--net/sched/sch_generic.c7
-rw-r--r--net/sctp/input.c45
-rw-r--r--net/sctp/ipv6.c7
-rw-r--r--net/sctp/objcnt.c6
102 files changed, 960 insertions, 1220 deletions
diff --git a/arch/arm/boot/compressed/head-shark.S b/arch/arm/boot/compressed/head-shark.S
index 848f60e5429b..089c560e07f1 100644
--- a/arch/arm/boot/compressed/head-shark.S
+++ b/arch/arm/boot/compressed/head-shark.S
@@ -63,8 +63,8 @@ __beginning: mov r4, r0 @ save the entry to the firmware
63 63
64 mov pc, r2 64 mov pc, r2
65 65
66__copy_target: .long 0x08508000 66__copy_target: .long 0x08507FFC
67__copy_end: .long 0x08608000 67__copy_end: .long 0x08607FFC
68 68
69 .word _start 69 .word _start
70 .word __bss_start 70 .word __bss_start
@@ -73,9 +73,10 @@ __copy_end: .long 0x08608000
73__temp_stack: .space 128 73__temp_stack: .space 128
74 74
75__mmu_off: 75__mmu_off:
76 adr r0, __ofw_data 76 adr r0, __ofw_data @ read the 1. entry of the memory map
77 ldr r0, [r0, #4] 77 ldr r0, [r0, #4]
78 orr r0, r0, #0x00600000 78 orr r0, r0, #0x00600000
79 sub r0, r0, #4
79 80
80 ldr r1, __copy_end 81 ldr r1, __copy_end
81 ldr r3, __copy_target 82 ldr r3, __copy_target
@@ -89,20 +90,43 @@ __mmu_off:
89 * from 0x08500000 to 0x08508000 if we have only 8MB 90 * from 0x08500000 to 0x08508000 if we have only 8MB
90 */ 91 */
91 92
93/* As we get more 2.6-kernels it gets more and more
94 * uncomfortable to be bound to kernel images of 1MB only.
95 * So we add a loop here, to be able to copy some more.
96 * Alexander Schulz 2005-07-17
97 */
98
99 mov r4, #3 @ How many megabytes to copy
100
101
102__MoveCode: sub r4, r4, #1
92 103
93__Copy: ldr r2, [r0], #-4 104__Copy: ldr r2, [r0], #-4
94 str r2, [r1], #-4 105 str r2, [r1], #-4
95 teq r1, r3 106 teq r1, r3
96 bne __Copy 107 bne __Copy
108
109 /* The firmware maps us in blocks of 1 MB, the next block is
110 _below_ the last one. So our decrementing source pointer
111 ist right here, but the destination pointer must be increased
112 by 2 MB */
113 add r1, r1, #0x00200000
114 add r3, r3, #0x00100000
115
116 teq r4, #0
117 bne __MoveCode
118
119
97 /* and jump to it */ 120 /* and jump to it */
98 adr r2, __go_on 121 adr r2, __go_on @ where we want to jump
99 adr r0, __ofw_data 122 adr r0, __ofw_data @ read the 1. entry of the memory map
100 ldr r0, [r0, #4] 123 ldr r0, [r0, #4]
101 sub r2, r2, r0 124 sub r2, r2, r0 @ we are mapped add 0e50 now, sub that (-0e00)
102 sub r2, r2, #0x00500000 125 sub r2, r2, #0x00500000 @ -0050
103 ldr r0, __copy_target 126 ldr r0, __copy_target @ and add 0850 8000 instead
127 add r0, r0, #4
104 add r2, r2, r0 128 add r2, r2, r0
105 mov pc, r2 129 mov pc, r2 @ and jump there
106 130
107__go_on: 131__go_on:
108 adr sp, __temp_stack 132 adr sp, __temp_stack
diff --git a/arch/arm/configs/bast_defconfig b/arch/arm/configs/bast_defconfig
index 2d985e9611cd..35e3a99bcbb6 100644
--- a/arch/arm/configs/bast_defconfig
+++ b/arch/arm/configs/bast_defconfig
@@ -561,7 +561,6 @@ CONFIG_SERIAL_8250_SHARE_IRQ=y
561# 561#
562CONFIG_SERIAL_S3C2410=y 562CONFIG_SERIAL_S3C2410=y
563CONFIG_SERIAL_S3C2410_CONSOLE=y 563CONFIG_SERIAL_S3C2410_CONSOLE=y
564CONFIG_SERIAL_BAST_SIO=y
565CONFIG_SERIAL_CORE=y 564CONFIG_SERIAL_CORE=y
566CONFIG_SERIAL_CORE_CONSOLE=y 565CONFIG_SERIAL_CORE_CONSOLE=y
567CONFIG_UNIX98_PTYS=y 566CONFIG_UNIX98_PTYS=y
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index 98b72ff38832..96a794d8de84 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -570,7 +570,6 @@ CONFIG_SERIAL_8250_SHARE_IRQ=y
570# 570#
571CONFIG_SERIAL_S3C2410=y 571CONFIG_SERIAL_S3C2410=y
572CONFIG_SERIAL_S3C2410_CONSOLE=y 572CONFIG_SERIAL_S3C2410_CONSOLE=y
573CONFIG_SERIAL_BAST_SIO=y
574CONFIG_SERIAL_CORE=y 573CONFIG_SERIAL_CORE=y
575CONFIG_SERIAL_CORE_CONSOLE=y 574CONFIG_SERIAL_CORE_CONSOLE=y
576CONFIG_UNIX98_PTYS=y 575CONFIG_UNIX98_PTYS=y
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 7ae45c3fc834..295e0a8379cf 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -78,7 +78,7 @@ struct smp_call_struct {
78static struct smp_call_struct * volatile smp_call_function_data; 78static struct smp_call_struct * volatile smp_call_function_data;
79static DEFINE_SPINLOCK(smp_call_function_lock); 79static DEFINE_SPINLOCK(smp_call_function_lock);
80 80
81int __init __cpu_up(unsigned int cpu) 81int __cpuinit __cpu_up(unsigned int cpu)
82{ 82{
83 struct task_struct *idle; 83 struct task_struct *idle;
84 pgd_t *pgd; 84 pgd_t *pgd;
@@ -159,7 +159,7 @@ int __init __cpu_up(unsigned int cpu)
159 * This is the secondary CPU boot entry. We're using this CPUs 159 * This is the secondary CPU boot entry. We're using this CPUs
160 * idle thread stack, but a set of temporary page tables. 160 * idle thread stack, but a set of temporary page tables.
161 */ 161 */
162asmlinkage void __init secondary_start_kernel(void) 162asmlinkage void __cpuinit secondary_start_kernel(void)
163{ 163{
164 struct mm_struct *mm = &init_mm; 164 struct mm_struct *mm = &init_mm;
165 unsigned int cpu = smp_processor_id(); 165 unsigned int cpu = smp_processor_id();
@@ -209,7 +209,7 @@ asmlinkage void __init secondary_start_kernel(void)
209 * Called by both boot and secondaries to move global data into 209 * Called by both boot and secondaries to move global data into
210 * per-processor storage. 210 * per-processor storage.
211 */ 211 */
212void __init smp_store_cpu_info(unsigned int cpuid) 212void __cpuinit smp_store_cpu_info(unsigned int cpuid)
213{ 213{
214 struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid); 214 struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid);
215 215
diff --git a/arch/arm/mach-integrator/platsmp.c b/arch/arm/mach-integrator/platsmp.c
index 2ba025777098..aecf47ba033a 100644
--- a/arch/arm/mach-integrator/platsmp.c
+++ b/arch/arm/mach-integrator/platsmp.c
@@ -27,12 +27,12 @@ extern void integrator_secondary_startup(void);
27 * control for which core is the next to come out of the secondary 27 * control for which core is the next to come out of the secondary
28 * boot "holding pen" 28 * boot "holding pen"
29 */ 29 */
30volatile int __initdata pen_release = -1; 30volatile int __cpuinitdata pen_release = -1;
31unsigned long __initdata phys_pen_release = 0; 31unsigned long __cpuinitdata phys_pen_release = 0;
32 32
33static DEFINE_SPINLOCK(boot_lock); 33static DEFINE_SPINLOCK(boot_lock);
34 34
35void __init platform_secondary_init(unsigned int cpu) 35void __cpuinit platform_secondary_init(unsigned int cpu)
36{ 36{
37 /* 37 /*
38 * the primary core may have used a "cross call" soft interrupt 38 * the primary core may have used a "cross call" soft interrupt
@@ -61,7 +61,7 @@ void __init platform_secondary_init(unsigned int cpu)
61 spin_unlock(&boot_lock); 61 spin_unlock(&boot_lock);
62} 62}
63 63
64int __init boot_secondary(unsigned int cpu, struct task_struct *idle) 64int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
65{ 65{
66 unsigned long timeout; 66 unsigned long timeout;
67 67
diff --git a/arch/arm/mach-s3c2410/dma.c b/arch/arm/mach-s3c2410/dma.c
index c7c28890d406..65feaf20d23e 100644
--- a/arch/arm/mach-s3c2410/dma.c
+++ b/arch/arm/mach-s3c2410/dma.c
@@ -436,7 +436,7 @@ int s3c2410_dma_enqueue(unsigned int channel, void *id,
436 436
437 buf = kmem_cache_alloc(dma_kmem, GFP_ATOMIC); 437 buf = kmem_cache_alloc(dma_kmem, GFP_ATOMIC);
438 if (buf == NULL) { 438 if (buf == NULL) {
439 pr_debug("%s: out of memory (%d alloc)\n", 439 pr_debug("%s: out of memory (%ld alloc)\n",
440 __FUNCTION__, sizeof(*buf)); 440 __FUNCTION__, sizeof(*buf));
441 return -ENOMEM; 441 return -ENOMEM;
442 } 442 }
diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c
index ccb6bcefa46c..206778ebfce7 100644
--- a/arch/arm/mach-s3c2410/mach-bast.c
+++ b/arch/arm/mach-s3c2410/mach-bast.c
@@ -28,6 +28,7 @@
28 * 14-Mar-2006 BJD Updated for __iomem changes 28 * 14-Mar-2006 BJD Updated for __iomem changes
29 * 22-Jun-2006 BJD Added DM9000 platform information 29 * 22-Jun-2006 BJD Added DM9000 platform information
30 * 28-Jun-2006 BJD Moved pm functionality out to common code 30 * 28-Jun-2006 BJD Moved pm functionality out to common code
31 * 17-Jul-2006 BJD Changed to platform device for SuperIO 16550s
31*/ 32*/
32 33
33#include <linux/kernel.h> 34#include <linux/kernel.h>
@@ -64,6 +65,8 @@
64#include <linux/mtd/nand_ecc.h> 65#include <linux/mtd/nand_ecc.h>
65#include <linux/mtd/partitions.h> 66#include <linux/mtd/partitions.h>
66 67
68#include <linux/serial_8250.h>
69
67#include "clock.h" 70#include "clock.h"
68#include "devs.h" 71#include "devs.h"
69#include "cpu.h" 72#include "cpu.h"
@@ -351,6 +354,39 @@ static struct platform_device bast_device_dm9k = {
351 } 354 }
352}; 355};
353 356
357/* serial devices */
358
359#define SERIAL_BASE (S3C2410_CS2 + BAST_PA_SUPERIO)
360#define SERIAL_FLAGS (UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ)
361#define SERIAL_CLK (1843200)
362
363static struct plat_serial8250_port bast_sio_data[] = {
364 [0] = {
365 .mapbase = SERIAL_BASE + 0x2f8,
366 .irq = IRQ_PCSERIAL1,
367 .flags = SERIAL_FLAGS,
368 .iotype = UPIO_MEM,
369 .regshift = 0,
370 .uartclk = SERIAL_CLK,
371 },
372 [1] = {
373 .mapbase = SERIAL_BASE + 0x3f8,
374 .irq = IRQ_PCSERIAL2,
375 .flags = SERIAL_FLAGS,
376 .iotype = UPIO_MEM,
377 .regshift = 0,
378 .uartclk = SERIAL_CLK,
379 },
380 { }
381};
382
383static struct platform_device bast_sio = {
384 .name = "serial8250",
385 .id = 0,
386 .dev = {
387 .platform_data = &bast_sio_data,
388 },
389};
354 390
355/* Standard BAST devices */ 391/* Standard BAST devices */
356 392
@@ -364,6 +400,7 @@ static struct platform_device *bast_devices[] __initdata = {
364 &s3c_device_nand, 400 &s3c_device_nand,
365 &bast_device_nor, 401 &bast_device_nor,
366 &bast_device_dm9k, 402 &bast_device_dm9k,
403 &bast_sio,
367}; 404};
368 405
369static struct clk *bast_clocks[] = { 406static struct clk *bast_clocks[] = {
diff --git a/arch/arm/nwfpe/fpa11.h b/arch/arm/nwfpe/fpa11.h
index 45cc65426a22..e4a61aea534b 100644
--- a/arch/arm/nwfpe/fpa11.h
+++ b/arch/arm/nwfpe/fpa11.h
@@ -29,9 +29,7 @@
29 * stack+task struct. Use the same method as 'current' uses to 29 * stack+task struct. Use the same method as 'current' uses to
30 * reach them. 30 * reach them.
31 */ 31 */
32register unsigned long *user_registers asm("sl"); 32#define GET_USERREG() ((struct pt_regs *)(THREAD_START_SP + (unsigned long)current_thread_info()) - 1)
33
34#define GET_USERREG() (user_registers)
35 33
36#include <linux/config.h> 34#include <linux/config.h>
37#include <linux/thread_info.h> 35#include <linux/thread_info.h>
diff --git a/arch/arm/nwfpe/fpmodule.c b/arch/arm/nwfpe/fpmodule.c
index a8efcf34888e..12885f31d347 100644
--- a/arch/arm/nwfpe/fpmodule.c
+++ b/arch/arm/nwfpe/fpmodule.c
@@ -132,7 +132,7 @@ void float_raise(signed char flags)
132 printk(KERN_DEBUG 132 printk(KERN_DEBUG
133 "NWFPE: %s[%d] takes exception %08x at %p from %08lx\n", 133 "NWFPE: %s[%d] takes exception %08x at %p from %08lx\n",
134 current->comm, current->pid, flags, 134 current->comm, current->pid, flags,
135 __builtin_return_address(0), GET_USERREG()[15]); 135 __builtin_return_address(0), GET_USERREG()->ARM_pc);
136#endif 136#endif
137 137
138 /* Keep SoftFloat exception flags up to date. */ 138 /* Keep SoftFloat exception flags up to date. */
diff --git a/arch/arm/nwfpe/fpmodule.inl b/arch/arm/nwfpe/fpmodule.inl
index e5f59e9a3022..2c39ad408f22 100644
--- a/arch/arm/nwfpe/fpmodule.inl
+++ b/arch/arm/nwfpe/fpmodule.inl
@@ -28,8 +28,8 @@ static inline unsigned long readRegister(const unsigned int nReg)
28 for this in this routine. LDF/STF instructions with Rn = PC 28 for this in this routine. LDF/STF instructions with Rn = PC
29 depend on the PC being correct, as they use PC+8 in their 29 depend on the PC being correct, as they use PC+8 in their
30 address calculations. */ 30 address calculations. */
31 unsigned long *userRegisters = GET_USERREG(); 31 struct pt_regs *regs = GET_USERREG();
32 unsigned int val = userRegisters[nReg]; 32 unsigned int val = regs->uregs[nReg];
33 if (REG_PC == nReg) 33 if (REG_PC == nReg)
34 val -= 4; 34 val -= 4;
35 return val; 35 return val;
@@ -38,8 +38,8 @@ static inline unsigned long readRegister(const unsigned int nReg)
38static inline void 38static inline void
39writeRegister(const unsigned int nReg, const unsigned long val) 39writeRegister(const unsigned int nReg, const unsigned long val)
40{ 40{
41 unsigned long *userRegisters = GET_USERREG(); 41 struct pt_regs *regs = GET_USERREG();
42 userRegisters[nReg] = val; 42 regs->uregs[nReg] = val;
43} 43}
44 44
45static inline unsigned long readCPSR(void) 45static inline unsigned long readCPSR(void)
@@ -63,12 +63,12 @@ static inline unsigned long readConditionCodes(void)
63 63
64static inline void writeConditionCodes(const unsigned long val) 64static inline void writeConditionCodes(const unsigned long val)
65{ 65{
66 unsigned long *userRegisters = GET_USERREG(); 66 struct pt_regs *regs = GET_USERREG();
67 unsigned long rval; 67 unsigned long rval;
68 /* 68 /*
69 * Operate directly on userRegisters since 69 * Operate directly on userRegisters since
70 * the CPSR may be the PC register itself. 70 * the CPSR may be the PC register itself.
71 */ 71 */
72 rval = userRegisters[REG_CPSR] & ~CC_MASK; 72 rval = regs->ARM_cpsr & ~CC_MASK;
73 userRegisters[REG_CPSR] = rval | (val & CC_MASK); 73 regs->ARM_cpsr = rval | (val & CC_MASK);
74} 74}
diff --git a/arch/i386/kernel/i387.c b/arch/i386/kernel/i387.c
index b817168d9c62..d75524758daf 100644
--- a/arch/i386/kernel/i387.c
+++ b/arch/i386/kernel/i387.c
@@ -82,17 +82,6 @@ void kernel_fpu_begin(void)
82} 82}
83EXPORT_SYMBOL_GPL(kernel_fpu_begin); 83EXPORT_SYMBOL_GPL(kernel_fpu_begin);
84 84
85void restore_fpu( struct task_struct *tsk )
86{
87 if ( cpu_has_fxsr ) {
88 asm volatile( "fxrstor %0"
89 : : "m" (tsk->thread.i387.fxsave) );
90 } else {
91 asm volatile( "frstor %0"
92 : : "m" (tsk->thread.i387.fsave) );
93 }
94}
95
96/* 85/*
97 * FPU tag word conversions. 86 * FPU tag word conversions.
98 */ 87 */
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index ba243a4cc119..d9492058aaf3 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -700,23 +700,27 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
700 700
701 /* 701 /*
702 * Restore %fs and %gs if needed. 702 * Restore %fs and %gs if needed.
703 *
704 * Glibc normally makes %fs be zero, and %gs is one of
705 * the TLS segments.
703 */ 706 */
704 if (unlikely(prev->fs | prev->gs | next->fs | next->gs)) { 707 if (unlikely(prev->fs | next->fs))
705 loadsegment(fs, next->fs); 708 loadsegment(fs, next->fs);
709
710 if (prev->gs | next->gs)
706 loadsegment(gs, next->gs); 711 loadsegment(gs, next->gs);
707 }
708 712
709 /* 713 /*
710 * Now maybe reload the debug registers 714 * Now maybe reload the debug registers
711 */ 715 */
712 if (unlikely(next->debugreg[7])) { 716 if (unlikely(next->debugreg[7])) {
713 set_debugreg(current->thread.debugreg[0], 0); 717 set_debugreg(next->debugreg[0], 0);
714 set_debugreg(current->thread.debugreg[1], 1); 718 set_debugreg(next->debugreg[1], 1);
715 set_debugreg(current->thread.debugreg[2], 2); 719 set_debugreg(next->debugreg[2], 2);
716 set_debugreg(current->thread.debugreg[3], 3); 720 set_debugreg(next->debugreg[3], 3);
717 /* no 4 and 5 */ 721 /* no 4 and 5 */
718 set_debugreg(current->thread.debugreg[6], 6); 722 set_debugreg(next->debugreg[6], 6);
719 set_debugreg(current->thread.debugreg[7], 7); 723 set_debugreg(next->debugreg[7], 7);
720 } 724 }
721 725
722 if (unlikely(prev->io_bitmap_ptr || next->io_bitmap_ptr)) 726 if (unlikely(prev->io_bitmap_ptr || next->io_bitmap_ptr))
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 7306353c520e..af4de58cab54 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -1414,7 +1414,7 @@ static struct nop {
1414 This runs before SMP is initialized to avoid SMP problems with 1414 This runs before SMP is initialized to avoid SMP problems with
1415 self modifying code. This implies that assymetric systems where 1415 self modifying code. This implies that assymetric systems where
1416 APs have less capabilities than the boot processor are not handled. 1416 APs have less capabilities than the boot processor are not handled.
1417 In this case boot with "noreplacement". */ 1417 Tough. Make sure you disable such features by hand. */
1418void apply_alternatives(void *start, void *end) 1418void apply_alternatives(void *start, void *end)
1419{ 1419{
1420 struct alt_instr *a; 1420 struct alt_instr *a;
@@ -1442,24 +1442,12 @@ void apply_alternatives(void *start, void *end)
1442 } 1442 }
1443} 1443}
1444 1444
1445static int no_replacement __initdata = 0;
1446
1447void __init alternative_instructions(void) 1445void __init alternative_instructions(void)
1448{ 1446{
1449 extern struct alt_instr __alt_instructions[], __alt_instructions_end[]; 1447 extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
1450 if (no_replacement)
1451 return;
1452 apply_alternatives(__alt_instructions, __alt_instructions_end); 1448 apply_alternatives(__alt_instructions, __alt_instructions_end);
1453} 1449}
1454 1450
1455static int __init noreplacement_setup(char *s)
1456{
1457 no_replacement = 1;
1458 return 0;
1459}
1460
1461__setup("noreplacement", noreplacement_setup);
1462
1463static char * __init machine_specific_memory_setup(void); 1451static char * __init machine_specific_memory_setup(void);
1464 1452
1465#ifdef CONFIG_MCA 1453#ifdef CONFIG_MCA
diff --git a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
index d781f10adc52..88332f00094a 100644
--- a/arch/sparc64/kernel/entry.S
+++ b/arch/sparc64/kernel/entry.S
@@ -1600,11 +1600,11 @@ sys_clone: flushw
1600 ba,pt %xcc, sparc_do_fork 1600 ba,pt %xcc, sparc_do_fork
1601 add %sp, PTREGS_OFF, %o2 1601 add %sp, PTREGS_OFF, %o2
1602ret_from_syscall: 1602ret_from_syscall:
1603 /* Clear SPARC_FLAG_NEWCHILD, switch_to leaves thread.flags in 1603 /* Clear current_thread_info()->new_child, and
1604 * %o7 for us. Check performance counter stuff too. 1604 * check performance counter stuff too.
1605 */ 1605 */
1606 andn %o7, _TIF_NEWCHILD, %l0 1606 stb %g0, [%g6 + TI_NEW_CHILD]
1607 stx %l0, [%g6 + TI_FLAGS] 1607 ldx [%g6 + TI_FLAGS], %l0
1608 call schedule_tail 1608 call schedule_tail
1609 mov %g7, %o0 1609 mov %g7, %o0
1610 andcc %l0, _TIF_PERFCTR, %g0 1610 andcc %l0, _TIF_PERFCTR, %g0
@@ -1720,12 +1720,11 @@ ret_sys_call:
1720 /* Check if force_successful_syscall_return() 1720 /* Check if force_successful_syscall_return()
1721 * was invoked. 1721 * was invoked.
1722 */ 1722 */
1723 ldx [%curptr + TI_FLAGS], %l0 1723 ldub [%curptr + TI_SYS_NOERROR], %l0
1724 andcc %l0, _TIF_SYSCALL_SUCCESS, %g0 1724 brz,pt %l0, 1f
1725 be,pt %icc, 1f 1725 nop
1726 andn %l0, _TIF_SYSCALL_SUCCESS, %l0
1727 ba,pt %xcc, 80f 1726 ba,pt %xcc, 80f
1728 stx %l0, [%curptr + TI_FLAGS] 1727 stb %g0, [%curptr + TI_SYS_NOERROR]
1729 1728
17301: 17291:
1731 cmp %o0, -ERESTART_RESTARTBLOCK 1730 cmp %o0, -ERESTART_RESTARTBLOCK
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
index daa2fb93052c..c9b69167632a 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -782,8 +782,14 @@ static void distribute_irqs(void)
782} 782}
783#endif 783#endif
784 784
785struct sun5_timer {
786 u64 count0;
787 u64 limit0;
788 u64 count1;
789 u64 limit1;
790};
785 791
786struct sun5_timer *prom_timers; 792static struct sun5_timer *prom_timers;
787static u64 prom_limit0, prom_limit1; 793static u64 prom_limit0, prom_limit1;
788 794
789static void map_prom_timers(void) 795static void map_prom_timers(void)
@@ -839,18 +845,6 @@ static void kill_prom_timer(void)
839 : "g1", "g2"); 845 : "g1", "g2");
840} 846}
841 847
842void enable_prom_timer(void)
843{
844 if (!prom_timers)
845 return;
846
847 /* Set it to whatever was there before. */
848 prom_timers->limit1 = prom_limit1;
849 prom_timers->count1 = 0;
850 prom_timers->limit0 = prom_limit0;
851 prom_timers->count0 = 0;
852}
853
854void init_irqwork_curcpu(void) 848void init_irqwork_curcpu(void)
855{ 849{
856 register struct irq_work_struct *workp asm("o2"); 850 register struct irq_work_struct *workp asm("o2");
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c
index a0cd2b2494d6..cffb1c8ab4fc 100644
--- a/arch/sparc64/kernel/process.c
+++ b/arch/sparc64/kernel/process.c
@@ -621,8 +621,8 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
621 memcpy(child_trap_frame, (((struct sparc_stackf *)regs)-1), (TRACEREG_SZ+STACKFRAME_SZ)); 621 memcpy(child_trap_frame, (((struct sparc_stackf *)regs)-1), (TRACEREG_SZ+STACKFRAME_SZ));
622 622
623 t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) | (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) | 623 t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) | (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) |
624 _TIF_NEWCHILD |
625 (((regs->tstate + 1) & TSTATE_CWP) << TI_FLAG_CWP_SHIFT); 624 (((regs->tstate + 1) & TSTATE_CWP) << TI_FLAG_CWP_SHIFT);
625 t->new_child = 1;
626 t->ksp = ((unsigned long) child_trap_frame) - STACK_BIAS; 626 t->ksp = ((unsigned long) child_trap_frame) - STACK_BIAS;
627 t->kregs = (struct pt_regs *)(child_trap_frame+sizeof(struct sparc_stackf)); 627 t->kregs = (struct pt_regs *)(child_trap_frame+sizeof(struct sparc_stackf));
628 t->fpsaved[0] = 0; 628 t->fpsaved[0] = 0;
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 7e8e2919e186..b9b42491e118 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -137,7 +137,7 @@ void __init smp_callin(void)
137 /* Clear this or we will die instantly when we 137 /* Clear this or we will die instantly when we
138 * schedule back to this idler... 138 * schedule back to this idler...
139 */ 139 */
140 clear_thread_flag(TIF_NEWCHILD); 140 current_thread_info()->new_child = 0;
141 141
142 /* Attach to the address space of init_task. */ 142 /* Attach to the address space of init_task. */
143 atomic_inc(&init_mm.mm_count); 143 atomic_inc(&init_mm.mm_count);
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index a9f4596d7c2b..100b0107c4be 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -2125,6 +2125,8 @@ void __init trap_init(void)
2125 TI_PCR != offsetof(struct thread_info, pcr_reg) || 2125 TI_PCR != offsetof(struct thread_info, pcr_reg) ||
2126 TI_CEE_STUFF != offsetof(struct thread_info, cee_stuff) || 2126 TI_CEE_STUFF != offsetof(struct thread_info, cee_stuff) ||
2127 TI_PRE_COUNT != offsetof(struct thread_info, preempt_count) || 2127 TI_PRE_COUNT != offsetof(struct thread_info, preempt_count) ||
2128 TI_NEW_CHILD != offsetof(struct thread_info, new_child) ||
2129 TI_SYS_NOERROR != offsetof(struct thread_info, syscall_noerror) ||
2128 TI_FPREGS != offsetof(struct thread_info, fpregs) || 2130 TI_FPREGS != offsetof(struct thread_info, fpregs) ||
2129 (TI_FPREGS & (64 - 1))) 2131 (TI_FPREGS & (64 - 1)))
2130 thread_info_offsets_are_bolixed_dave(); 2132 thread_info_offsets_are_bolixed_dave();
diff --git a/crypto/cipher.c b/crypto/cipher.c
index 1c92c6bb138b..8da644364cb4 100644
--- a/crypto/cipher.c
+++ b/crypto/cipher.c
@@ -41,7 +41,7 @@ static unsigned int crypt_slow(const struct cipher_desc *desc,
41 struct scatter_walk *in, 41 struct scatter_walk *in,
42 struct scatter_walk *out, unsigned int bsize) 42 struct scatter_walk *out, unsigned int bsize)
43{ 43{
44 unsigned int alignmask = crypto_tfm_alg_alignmask(desc->tfm); 44 unsigned long alignmask = crypto_tfm_alg_alignmask(desc->tfm);
45 u8 buffer[bsize * 2 + alignmask]; 45 u8 buffer[bsize * 2 + alignmask];
46 u8 *src = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1); 46 u8 *src = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);
47 u8 *dst = src + bsize; 47 u8 *dst = src + bsize;
@@ -160,7 +160,7 @@ static int crypt_iv_unaligned(struct cipher_desc *desc,
160 unsigned int nbytes) 160 unsigned int nbytes)
161{ 161{
162 struct crypto_tfm *tfm = desc->tfm; 162 struct crypto_tfm *tfm = desc->tfm;
163 unsigned int alignmask = crypto_tfm_alg_alignmask(tfm); 163 unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
164 u8 *iv = desc->info; 164 u8 *iv = desc->info;
165 165
166 if (unlikely(((unsigned long)iv & alignmask))) { 166 if (unlikely(((unsigned long)iv & alignmask))) {
@@ -424,7 +424,7 @@ int crypto_init_cipher_ops(struct crypto_tfm *tfm)
424 } 424 }
425 425
426 if (ops->cit_mode == CRYPTO_TFM_MODE_CBC) { 426 if (ops->cit_mode == CRYPTO_TFM_MODE_CBC) {
427 unsigned int align; 427 unsigned long align;
428 unsigned long addr; 428 unsigned long addr;
429 429
430 switch (crypto_tfm_alg_blocksize(tfm)) { 430 switch (crypto_tfm_alg_blocksize(tfm)) {
diff --git a/crypto/internal.h b/crypto/internal.h
index 68612874b5fd..37515beafc8c 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -75,7 +75,7 @@ static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg,
75 75
76 switch (flags & CRYPTO_TFM_MODE_MASK) { 76 switch (flags & CRYPTO_TFM_MODE_MASK) {
77 case CRYPTO_TFM_MODE_CBC: 77 case CRYPTO_TFM_MODE_CBC:
78 len = ALIGN(len, alg->cra_alignmask + 1); 78 len = ALIGN(len, (unsigned long)alg->cra_alignmask + 1);
79 len += alg->cra_blocksize; 79 len += alg->cra_blocksize;
80 break; 80 break;
81 } 81 }
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 8e665f2e3138..fca4140a50a9 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -170,22 +170,19 @@ acpi_ec_enter_burst_mode (
170 status = acpi_ec_read_status(ec); 170 status = acpi_ec_read_status(ec);
171 if (status != -EINVAL && 171 if (status != -EINVAL &&
172 !(status & ACPI_EC_FLAG_BURST)){ 172 !(status & ACPI_EC_FLAG_BURST)){
173 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"entering burst mode \n"));
174 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr); 173 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr);
175 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 174 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
176 if (status){ 175 if (status){
177 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 176 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
178 ACPI_DEBUG_PRINT((ACPI_DB_ERROR," status = %d\n", status));
179 return_VALUE(-EINVAL); 177 return_VALUE(-EINVAL);
180 } 178 }
181 acpi_hw_low_level_read(8, &tmp, &ec->data_addr); 179 acpi_hw_low_level_read(8, &tmp, &ec->data_addr);
182 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 180 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
183 if(tmp != 0x90 ) {/* Burst ACK byte*/ 181 if(tmp != 0x90 ) {/* Burst ACK byte*/
184 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Ack failed \n"));
185 return_VALUE(-EINVAL); 182 return_VALUE(-EINVAL);
186 } 183 }
187 } else 184 }
188 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in burst mode \n")); 185
189 atomic_set(&ec->leaving_burst , 0); 186 atomic_set(&ec->leaving_burst , 0);
190 return_VALUE(0); 187 return_VALUE(0);
191} 188}
@@ -202,7 +199,6 @@ acpi_ec_leave_burst_mode (
202 status = acpi_ec_read_status(ec); 199 status = acpi_ec_read_status(ec);
203 if (status != -EINVAL && 200 if (status != -EINVAL &&
204 (status & ACPI_EC_FLAG_BURST)){ 201 (status & ACPI_EC_FLAG_BURST)){
205 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n"));
206 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->command_addr); 202 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->command_addr);
207 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); 203 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
208 if (status){ 204 if (status){
@@ -212,14 +208,7 @@ acpi_ec_leave_burst_mode (
212 } 208 }
213 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 209 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
214 status = acpi_ec_read_status(ec); 210 status = acpi_ec_read_status(ec);
215 if (status != -EINVAL && 211 }
216 (status & ACPI_EC_FLAG_BURST)) {
217 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->status fail\n"));
218 return_VALUE(-EINVAL);
219 }
220 }else
221 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in Non-burst mode \n"));
222 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n"));
223 212
224 return_VALUE(0); 213 return_VALUE(0);
225} 214}
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index c46d9520c5a7..73c6b85299c1 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -794,7 +794,9 @@ static void drain_rx_pools (amb_dev * dev) {
794 drain_rx_pool (dev, pool); 794 drain_rx_pool (dev, pool);
795} 795}
796 796
797static inline void fill_rx_pool (amb_dev * dev, unsigned char pool, int priority) { 797static inline void fill_rx_pool (amb_dev * dev, unsigned char pool,
798 unsigned int __nocast priority)
799{
798 rx_in rx; 800 rx_in rx;
799 amb_rxq * rxq; 801 amb_rxq * rxq;
800 802
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 101f0cc33d10..b078fa548ebf 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1374,7 +1374,8 @@ static void reset_chip (struct fs_dev *dev)
1374 } 1374 }
1375} 1375}
1376 1376
1377static void __devinit *aligned_kmalloc (int size, int flags, int alignment) 1377static void __devinit *aligned_kmalloc (int size, unsigned int __nocast flags,
1378 int alignment)
1378{ 1379{
1379 void *t; 1380 void *t;
1380 1381
@@ -1464,7 +1465,8 @@ static inline int nr_buffers_in_freepool (struct fs_dev *dev, struct freepool *f
1464 does. I've seen "receive abort: no buffers" and things started 1465 does. I've seen "receive abort: no buffers" and things started
1465 working again after that... -- REW */ 1466 working again after that... -- REW */
1466 1467
1467static void top_off_fp (struct fs_dev *dev, struct freepool *fp, int gfp_flags) 1468static void top_off_fp (struct fs_dev *dev, struct freepool *fp,
1469 unsigned int __nocast gfp_flags)
1468{ 1470{
1469 struct FS_BPENTRY *qe, *ne; 1471 struct FS_BPENTRY *qe, *ne;
1470 struct sk_buff *skb; 1472 struct sk_buff *skb;
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index df2c83fd5496..28250c9b32d6 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -57,7 +57,6 @@
57 57
58#include <linux/config.h> 58#include <linux/config.h>
59#include <linux/module.h> 59#include <linux/module.h>
60#include <linux/version.h>
61#include <linux/kernel.h> 60#include <linux/kernel.h>
62#include <linux/skbuff.h> 61#include <linux/skbuff.h>
63#include <linux/pci.h> 62#include <linux/pci.h>
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index baaf1a3d2242..30b7e990ed0b 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -46,6 +46,7 @@ static char const rcsid[] =
46#include <linux/init.h> 46#include <linux/init.h>
47#include <linux/bitops.h> 47#include <linux/bitops.h>
48#include <linux/wait.h> 48#include <linux/wait.h>
49#include <linux/jiffies.h>
49#include <asm/semaphore.h> 50#include <asm/semaphore.h>
50#include <asm/io.h> 51#include <asm/io.h>
51#include <asm/uaccess.h> 52#include <asm/uaccess.h>
@@ -780,7 +781,7 @@ push_on_scq(struct idt77252_dev *card, struct vc_map *vc, struct sk_buff *skb)
780 return 0; 781 return 0;
781 782
782out: 783out:
783 if (jiffies - scq->trans_start > HZ) { 784 if (time_after(jiffies, scq->trans_start + HZ)) {
784 printk("%s: Error pushing TBD for %d.%d\n", 785 printk("%s: Error pushing TBD for %d.%d\n",
785 card->name, vc->tx_vcc->vpi, vc->tx_vcc->vci); 786 card->name, vc->tx_vcc->vpi, vc->tx_vcc->vci);
786#ifdef CONFIG_ATM_IDT77252_DEBUG 787#ifdef CONFIG_ATM_IDT77252_DEBUG
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 8d5e65cb9755..a2b236a966e0 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -16,9 +16,9 @@
16#include <linux/skbuff.h> 16#include <linux/skbuff.h>
17#include <linux/netdevice.h> 17#include <linux/netdevice.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/ioport.h> /* for request_region */
20#include <linux/uio.h> 19#include <linux/uio.h>
21#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/dma-mapping.h>
22#include <linux/atm_zatm.h> 22#include <linux/atm_zatm.h>
23#include <linux/capability.h> 23#include <linux/capability.h>
24#include <linux/bitops.h> 24#include <linux/bitops.h>
@@ -1257,22 +1257,22 @@ static int __init zatm_init(struct atm_dev *dev)
1257 1257
1258static int __init zatm_start(struct atm_dev *dev) 1258static int __init zatm_start(struct atm_dev *dev)
1259{ 1259{
1260 struct zatm_dev *zatm_dev; 1260 struct zatm_dev *zatm_dev = ZATM_DEV(dev);
1261 struct pci_dev *pdev = zatm_dev->pci_dev;
1261 unsigned long curr; 1262 unsigned long curr;
1262 int pools,vccs,rx; 1263 int pools,vccs,rx;
1263 int error,i,ld; 1264 int error, i, ld;
1264 1265
1265 DPRINTK("zatm_start\n"); 1266 DPRINTK("zatm_start\n");
1266 zatm_dev = ZATM_DEV(dev);
1267 zatm_dev->rx_map = zatm_dev->tx_map = NULL; 1267 zatm_dev->rx_map = zatm_dev->tx_map = NULL;
1268 for (i = 0; i < NR_MBX; i++) 1268 for (i = 0; i < NR_MBX; i++)
1269 zatm_dev->mbx_start[i] = 0; 1269 zatm_dev->mbx_start[i] = 0;
1270 if (request_irq(zatm_dev->irq,&zatm_int,SA_SHIRQ,DEV_LABEL,dev)) { 1270 error = request_irq(zatm_dev->irq, zatm_int, SA_SHIRQ, DEV_LABEL, dev);
1271 printk(KERN_ERR DEV_LABEL "(itf %d): IRQ%d is already in use\n", 1271 if (error < 0) {
1272 dev->number,zatm_dev->irq); 1272 printk(KERN_ERR DEV_LABEL "(itf %d): IRQ%d is already in use\n",
1273 return -EAGAIN; 1273 dev->number,zatm_dev->irq);
1274 goto done;
1274 } 1275 }
1275 request_region(zatm_dev->base,uPD98401_PORTS,DEV_LABEL);
1276 /* define memory regions */ 1276 /* define memory regions */
1277 pools = NR_POOLS; 1277 pools = NR_POOLS;
1278 if (NR_SHAPERS*SHAPER_SIZE > pools*POOL_SIZE) 1278 if (NR_SHAPERS*SHAPER_SIZE > pools*POOL_SIZE)
@@ -1299,51 +1299,66 @@ static int __init zatm_start(struct atm_dev *dev)
1299 "%ld VCs\n",dev->number,NR_SHAPERS,pools,rx, 1299 "%ld VCs\n",dev->number,NR_SHAPERS,pools,rx,
1300 (zatm_dev->mem-curr*4)/VC_SIZE); 1300 (zatm_dev->mem-curr*4)/VC_SIZE);
1301 /* create mailboxes */ 1301 /* create mailboxes */
1302 for (i = 0; i < NR_MBX; i++) 1302 for (i = 0; i < NR_MBX; i++) {
1303 if (mbx_entries[i]) { 1303 void *mbx;
1304 unsigned long here; 1304 dma_addr_t mbx_dma;
1305 1305
1306 here = (unsigned long) kmalloc(2*MBX_SIZE(i), 1306 if (!mbx_entries[i])
1307 GFP_KERNEL); 1307 continue;
1308 if (!here) { 1308 mbx = pci_alloc_consistent(pdev, 2*MBX_SIZE(i), &mbx_dma);
1309 error = -ENOMEM; 1309 if (!mbx) {
1310 goto out; 1310 error = -ENOMEM;
1311 } 1311 goto out;
1312 if ((here^(here+MBX_SIZE(i))) & ~0xffffUL)/* paranoia */
1313 here = (here & ~0xffffUL)+0x10000;
1314 zatm_dev->mbx_start[i] = here;
1315 if ((here^virt_to_bus((void *) here)) & 0xffff) {
1316 printk(KERN_ERR DEV_LABEL "(itf %d): system "
1317 "bus incompatible with driver\n",
1318 dev->number);
1319 error = -ENODEV;
1320 goto out;
1321 }
1322 DPRINTK("mbx@0x%08lx-0x%08lx\n",here,here+MBX_SIZE(i));
1323 zatm_dev->mbx_end[i] = (here+MBX_SIZE(i)) & 0xffff;
1324 zout(virt_to_bus((void *) here) >> 16,MSH(i));
1325 zout(virt_to_bus((void *) here),MSL(i));
1326 zout((here+MBX_SIZE(i)) & 0xffff,MBA(i));
1327 zout(here & 0xffff,MTA(i));
1328 zout(here & 0xffff,MWA(i));
1329 } 1312 }
1313 /*
1314 * Alignment provided by pci_alloc_consistent() isn't enough
1315 * for this device.
1316 */
1317 if (((unsigned long)mbx ^ mbx_dma) & 0xffff) {
1318 printk(KERN_ERR DEV_LABEL "(itf %d): system "
1319 "bus incompatible with driver\n", dev->number);
1320 pci_free_consistent(pdev, 2*MBX_SIZE(i), mbx, mbx_dma);
1321 error = -ENODEV;
1322 goto out;
1323 }
1324 DPRINTK("mbx@0x%08lx-0x%08lx\n", mbx, mbx + MBX_SIZE(i));
1325 zatm_dev->mbx_start[i] = (unsigned long)mbx;
1326 zatm_dev->mbx_dma[i] = mbx_dma;
1327 zatm_dev->mbx_end[i] = (zatm_dev->mbx_start[i] + MBX_SIZE(i)) &
1328 0xffff;
1329 zout(mbx_dma >> 16, MSH(i));
1330 zout(mbx_dma, MSL(i));
1331 zout(zatm_dev->mbx_end[i], MBA(i));
1332 zout((unsigned long)mbx & 0xffff, MTA(i));
1333 zout((unsigned long)mbx & 0xffff, MWA(i));
1334 }
1330 error = start_tx(dev); 1335 error = start_tx(dev);
1331 if (error) goto out; 1336 if (error)
1337 goto out;
1332 error = start_rx(dev); 1338 error = start_rx(dev);
1333 if (error) goto out; 1339 if (error)
1340 goto out_tx;
1334 error = dev->phy->start(dev); 1341 error = dev->phy->start(dev);
1335 if (error) goto out; 1342 if (error)
1343 goto out_rx;
1336 zout(0xffffffff,IMR); /* enable interrupts */ 1344 zout(0xffffffff,IMR); /* enable interrupts */
1337 /* enable TX & RX */ 1345 /* enable TX & RX */
1338 zout(zin(GMR) | uPD98401_GMR_SE | uPD98401_GMR_RE,GMR); 1346 zout(zin(GMR) | uPD98401_GMR_SE | uPD98401_GMR_RE,GMR);
1339 return 0; 1347done:
1340 out: 1348 return error;
1341 for (i = 0; i < NR_MBX; i++) 1349
1342 kfree(zatm_dev->mbx_start[i]); 1350out_rx:
1343 kfree(zatm_dev->rx_map); 1351 kfree(zatm_dev->rx_map);
1352out_tx:
1344 kfree(zatm_dev->tx_map); 1353 kfree(zatm_dev->tx_map);
1354out:
1355 while (i-- > 0) {
1356 pci_free_consistent(pdev, 2*MBX_SIZE(i),
1357 (void *)zatm_dev->mbx_start[i],
1358 zatm_dev->mbx_dma[i]);
1359 }
1345 free_irq(zatm_dev->irq, dev); 1360 free_irq(zatm_dev->irq, dev);
1346 return error; 1361 goto done;
1347} 1362}
1348 1363
1349 1364
diff --git a/drivers/atm/zatm.h b/drivers/atm/zatm.h
index 34a0480f63d6..416fe0fda60c 100644
--- a/drivers/atm/zatm.h
+++ b/drivers/atm/zatm.h
@@ -73,6 +73,7 @@ struct zatm_dev {
73 int chans; /* map size, must be 2^n */ 73 int chans; /* map size, must be 2^n */
74 /*-------------------------------- mailboxes */ 74 /*-------------------------------- mailboxes */
75 unsigned long mbx_start[NR_MBX];/* start addresses */ 75 unsigned long mbx_start[NR_MBX];/* start addresses */
76 dma_addr_t mbx_dma[NR_MBX];
76 u16 mbx_end[NR_MBX]; /* end offset (in bytes) */ 77 u16 mbx_end[NR_MBX]; /* end offset (in bytes) */
77 /*-------------------------------- other pointers */ 78 /*-------------------------------- other pointers */
78 u32 pool_base; /* Free buffer pool dsc (word addr) */ 79 u32 pool_base; /* Free buffer pool dsc (word addr) */
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 9a07ff7a7777..534b598866b3 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2544,9 +2544,25 @@ config SHAPER
2544 2544
2545config NETCONSOLE 2545config NETCONSOLE
2546 tristate "Network console logging support (EXPERIMENTAL)" 2546 tristate "Network console logging support (EXPERIMENTAL)"
2547 depends on NETDEVICES && EXPERIMENTAL 2547 depends on NETDEVICES && INET && EXPERIMENTAL
2548 ---help--- 2548 ---help---
2549 If you want to log kernel messages over the network, enable this. 2549 If you want to log kernel messages over the network, enable this.
2550 See <file:Documentation/networking/netconsole.txt> for details. 2550 See <file:Documentation/networking/netconsole.txt> for details.
2551 2551
2552config NETPOLL
2553 def_bool NETCONSOLE
2554
2555config NETPOLL_RX
2556 bool "Netpoll support for trapping incoming packets"
2557 default n
2558 depends on NETPOLL
2559
2560config NETPOLL_TRAP
2561 bool "Netpoll traffic trapping"
2562 default n
2563 depends on NETPOLL
2564
2565config NET_POLL_CONTROLLER
2566 def_bool NETPOLL
2567
2552endmenu 2568endmenu
diff --git a/drivers/net/eql.c b/drivers/net/eql.c
index dd6865820372..aa1569182fd6 100644
--- a/drivers/net/eql.c
+++ b/drivers/net/eql.c
@@ -132,7 +132,7 @@ static struct net_device_stats *eql_get_stats(struct net_device *dev);
132#define eql_is_slave(dev) ((dev->flags & IFF_SLAVE) == IFF_SLAVE) 132#define eql_is_slave(dev) ((dev->flags & IFF_SLAVE) == IFF_SLAVE)
133#define eql_is_master(dev) ((dev->flags & IFF_MASTER) == IFF_MASTER) 133#define eql_is_master(dev) ((dev->flags & IFF_MASTER) == IFF_MASTER)
134 134
135static void eql_kill_one_slave(slave_t *slave); 135static void eql_kill_one_slave(slave_queue_t *queue, slave_t *slave);
136 136
137static void eql_timer(unsigned long param) 137static void eql_timer(unsigned long param)
138{ 138{
@@ -149,7 +149,7 @@ static void eql_timer(unsigned long param)
149 if (slave->bytes_queued < 0) 149 if (slave->bytes_queued < 0)
150 slave->bytes_queued = 0; 150 slave->bytes_queued = 0;
151 } else { 151 } else {
152 eql_kill_one_slave(slave); 152 eql_kill_one_slave(&eql->queue, slave);
153 } 153 }
154 154
155 } 155 }
@@ -214,9 +214,10 @@ static int eql_open(struct net_device *dev)
214 return 0; 214 return 0;
215} 215}
216 216
217static void eql_kill_one_slave(slave_t *slave) 217static void eql_kill_one_slave(slave_queue_t *queue, slave_t *slave)
218{ 218{
219 list_del(&slave->list); 219 list_del(&slave->list);
220 queue->num_slaves--;
220 slave->dev->flags &= ~IFF_SLAVE; 221 slave->dev->flags &= ~IFF_SLAVE;
221 dev_put(slave->dev); 222 dev_put(slave->dev);
222 kfree(slave); 223 kfree(slave);
@@ -232,8 +233,7 @@ static void eql_kill_slave_queue(slave_queue_t *queue)
232 list_for_each_safe(this, tmp, head) { 233 list_for_each_safe(this, tmp, head) {
233 slave_t *s = list_entry(this, slave_t, list); 234 slave_t *s = list_entry(this, slave_t, list);
234 235
235 eql_kill_one_slave(s); 236 eql_kill_one_slave(queue, s);
236 queue->num_slaves--;
237 } 237 }
238 238
239 spin_unlock_bh(&queue->lock); 239 spin_unlock_bh(&queue->lock);
@@ -318,7 +318,7 @@ static slave_t *__eql_schedule_slaves(slave_queue_t *queue)
318 } 318 }
319 } else { 319 } else {
320 /* We found a dead slave, kill it. */ 320 /* We found a dead slave, kill it. */
321 eql_kill_one_slave(slave); 321 eql_kill_one_slave(queue, slave);
322 } 322 }
323 } 323 }
324 return best_slave; 324 return best_slave;
@@ -393,7 +393,7 @@ static int __eql_insert_slave(slave_queue_t *queue, slave_t *slave)
393 393
394 duplicate_slave = __eql_find_slave_dev(queue, slave->dev); 394 duplicate_slave = __eql_find_slave_dev(queue, slave->dev);
395 if (duplicate_slave != 0) 395 if (duplicate_slave != 0)
396 eql_kill_one_slave(duplicate_slave); 396 eql_kill_one_slave(queue, duplicate_slave);
397 397
398 list_add(&slave->list, &queue->all_slaves); 398 list_add(&slave->list, &queue->all_slaves);
399 queue->num_slaves++; 399 queue->num_slaves++;
@@ -471,7 +471,7 @@ static int eql_emancipate(struct net_device *master_dev, slaving_request_t __use
471 slave_dev); 471 slave_dev);
472 472
473 if (slave) { 473 if (slave) {
474 eql_kill_one_slave(slave); 474 eql_kill_one_slave(&eql->queue, slave);
475 ret = 0; 475 ret = 0;
476 } 476 }
477 } 477 }
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index fbc2f58ff688..0d8bb4cccbb7 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -41,6 +41,7 @@
41#include <linux/ioport.h> 41#include <linux/ioport.h>
42#include <linux/ethtool.h> 42#include <linux/ethtool.h>
43#include <linux/mii.h> 43#include <linux/mii.h>
44#include <linux/jiffies.h>
44 45
45#include <pcmcia/cs_types.h> 46#include <pcmcia/cs_types.h>
46#include <pcmcia/cs.h> 47#include <pcmcia/cs.h>
@@ -2092,7 +2093,7 @@ static void media_check(u_long arg)
2092 } 2093 }
2093 2094
2094 /* Ignore collisions unless we've had no rx's recently */ 2095 /* Ignore collisions unless we've had no rx's recently */
2095 if (jiffies - dev->last_rx > HZ) { 2096 if (time_after(jiffies, dev->last_rx + HZ)) {
2096 if (smc->tx_err || (smc->media_status & EPH_16COL)) 2097 if (smc->tx_err || (smc->media_status & EPH_16COL))
2097 media |= EPH_16COL; 2098 media |= EPH_16COL;
2098 } 2099 }
diff --git a/drivers/net/wan/sdla_fr.c b/drivers/net/wan/sdla_fr.c
index 2efccb0554c0..c5f5e62aab8b 100644
--- a/drivers/net/wan/sdla_fr.c
+++ b/drivers/net/wan/sdla_fr.c
@@ -152,6 +152,7 @@
152#include <asm/io.h> /* for inb(), outb(), etc. */ 152#include <asm/io.h> /* for inb(), outb(), etc. */
153#include <linux/time.h> /* for do_gettimeofday */ 153#include <linux/time.h> /* for do_gettimeofday */
154#include <linux/in.h> /* sockaddr_in */ 154#include <linux/in.h> /* sockaddr_in */
155#include <linux/jiffies.h> /* time_after() macro */
155#include <asm/errno.h> 156#include <asm/errno.h>
156 157
157#include <linux/ip.h> 158#include <linux/ip.h>
@@ -773,7 +774,7 @@ static int update(struct wan_device* wandev)
773 for(;;) { 774 for(;;) {
774 if(card->u.f.update_comms_stats == 0) 775 if(card->u.f.update_comms_stats == 0)
775 break; 776 break;
776 if ((jiffies - timeout) > (1 * HZ)){ 777 if (time_after(jiffies, timeout + 1 * HZ)){
777 card->u.f.update_comms_stats = 0; 778 card->u.f.update_comms_stats = 0;
778 return -EAGAIN; 779 return -EAGAIN;
779 } 780 }
@@ -4799,7 +4800,7 @@ static void trigger_unconfig_fr(struct net_device *dev)
4799{ 4800{
4800 fr_channel_t *chan = dev->priv; 4801 fr_channel_t *chan = dev->priv;
4801 volatile sdla_t *card = chan->card; 4802 volatile sdla_t *card = chan->card;
4802 u32 timeout; 4803 unsigned long timeout;
4803 fr508_flags_t* flags = card->flags; 4804 fr508_flags_t* flags = card->flags;
4804 int reset_critical=0; 4805 int reset_critical=0;
4805 4806
@@ -4821,7 +4822,7 @@ static void trigger_unconfig_fr(struct net_device *dev)
4821 if(!(card->u.f.timer_int_enabled & TMR_INT_ENABLED_UNCONFIG)) 4822 if(!(card->u.f.timer_int_enabled & TMR_INT_ENABLED_UNCONFIG))
4822 break; 4823 break;
4823 4824
4824 if ((jiffies - timeout) > (1 * HZ)){ 4825 if (time_after(jiffies, timeout + 1 * HZ)){
4825 card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_UNCONFIG; 4826 card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_UNCONFIG;
4826 printk(KERN_INFO "%s: Failed to delete DLCI %i\n", 4827 printk(KERN_INFO "%s: Failed to delete DLCI %i\n",
4827 card->devname,chan->dlci); 4828 card->devname,chan->dlci);
diff --git a/drivers/net/wan/sdla_ft1.c b/drivers/net/wan/sdla_ft1.c
index 5e3124856eb0..9d6528a50f7b 100644
--- a/drivers/net/wan/sdla_ft1.c
+++ b/drivers/net/wan/sdla_ft1.c
@@ -29,6 +29,7 @@
29#include <linux/wanrouter.h> /* WAN router definitions */ 29#include <linux/wanrouter.h> /* WAN router definitions */
30#include <linux/wanpipe.h> /* WANPIPE common user API definitions */ 30#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
31#include <linux/if_arp.h> /* ARPHRD_* defines */ 31#include <linux/if_arp.h> /* ARPHRD_* defines */
32#include <linux/jiffies.h> /* time_after() macro */
32 33
33#include <linux/inetdevice.h> 34#include <linux/inetdevice.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
@@ -164,7 +165,7 @@ int wpft1_init (sdla_t* card, wandev_conf_t* conf)
164 165
165 timeout = jiffies; 166 timeout = jiffies;
166 while (mb->return_code != 'I') /* Wait 1s for board to initialize */ 167 while (mb->return_code != 'I') /* Wait 1s for board to initialize */
167 if ((jiffies - timeout) > 1*HZ) break; 168 if (time_after(jiffies, timeout + 1*HZ)) break;
168 169
169 if (mb->return_code != 'I') { 170 if (mb->return_code != 'I') {
170 printk(KERN_INFO 171 printk(KERN_INFO
diff --git a/drivers/net/wan/sdla_ppp.c b/drivers/net/wan/sdla_ppp.c
index 1761cb68ab48..a4b489cccbbf 100644
--- a/drivers/net/wan/sdla_ppp.c
+++ b/drivers/net/wan/sdla_ppp.c
@@ -101,6 +101,7 @@
101#include <linux/if_arp.h> /* ARPHRD_* defines */ 101#include <linux/if_arp.h> /* ARPHRD_* defines */
102#include <asm/byteorder.h> /* htons(), etc. */ 102#include <asm/byteorder.h> /* htons(), etc. */
103#include <linux/in.h> /* sockaddr_in */ 103#include <linux/in.h> /* sockaddr_in */
104#include <linux/jiffies.h> /* time_after() macro */
104 105
105 106
106#include <asm/uaccess.h> 107#include <asm/uaccess.h>
@@ -482,7 +483,7 @@ static int update(struct wan_device *wandev)
482 if(ppp_priv_area->update_comms_stats == 0){ 483 if(ppp_priv_area->update_comms_stats == 0){
483 break; 484 break;
484 } 485 }
485 if ((jiffies - timeout) > (1 * HZ)){ 486 if (time_after(jiffies, timeout + 1 * HZ)){
486 ppp_priv_area->update_comms_stats = 0; 487 ppp_priv_area->update_comms_stats = 0;
487 ppp_priv_area->timer_int_enabled &= 488 ppp_priv_area->timer_int_enabled &=
488 ~TMR_INT_ENABLED_UPDATE; 489 ~TMR_INT_ENABLED_UPDATE;
diff --git a/drivers/net/wan/sdla_x25.c b/drivers/net/wan/sdla_x25.c
index 3a93d2fd4fbf..8a95d61a2f8f 100644
--- a/drivers/net/wan/sdla_x25.c
+++ b/drivers/net/wan/sdla_x25.c
@@ -91,6 +91,7 @@
91#include <linux/wanrouter.h> /* WAN router definitions */ 91#include <linux/wanrouter.h> /* WAN router definitions */
92#include <linux/wanpipe.h> /* WANPIPE common user API definitions */ 92#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
93#include <linux/workqueue.h> 93#include <linux/workqueue.h>
94#include <linux/jiffies.h> /* time_after() macro */
94#include <asm/byteorder.h> /* htons(), etc. */ 95#include <asm/byteorder.h> /* htons(), etc. */
95#include <asm/atomic.h> 96#include <asm/atomic.h>
96#include <linux/delay.h> /* Experimental delay */ 97#include <linux/delay.h> /* Experimental delay */
@@ -867,7 +868,7 @@ static int update(struct wan_device* wandev)
867 if (!(card->u.x.timer_int_enabled & TMR_INT_ENABLED_UPDATE)){ 868 if (!(card->u.x.timer_int_enabled & TMR_INT_ENABLED_UPDATE)){
868 break; 869 break;
869 } 870 }
870 if ((jiffies-timeout) > 1*HZ){ 871 if (time_after(jiffies, timeout + 1*HZ)){
871 card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE; 872 card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE;
872 return -EAGAIN; 873 return -EAGAIN;
873 } 874 }
diff --git a/drivers/net/wan/wanpipe_multppp.c b/drivers/net/wan/wanpipe_multppp.c
index 6aa6987d96cb..812a1183c502 100644
--- a/drivers/net/wan/wanpipe_multppp.c
+++ b/drivers/net/wan/wanpipe_multppp.c
@@ -26,6 +26,7 @@
26#include <linux/wanrouter.h> /* WAN router definitions */ 26#include <linux/wanrouter.h> /* WAN router definitions */
27#include <linux/wanpipe.h> /* WANPIPE common user API definitions */ 27#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
28#include <linux/if_arp.h> /* ARPHRD_* defines */ 28#include <linux/if_arp.h> /* ARPHRD_* defines */
29#include <linux/jiffies.h> /* time_after() macro */
29 30
30#include <linux/in.h> /* sockaddr_in */ 31#include <linux/in.h> /* sockaddr_in */
31#include <linux/inet.h> 32#include <linux/inet.h>
@@ -270,9 +271,9 @@ int wsppp_init (sdla_t* card, wandev_conf_t* conf)
270 ready to accept commands. We expect this to be completed in less 271 ready to accept commands. We expect this to be completed in less
271 than 1 second. */ 272 than 1 second. */
272 273
273 timeout = jiffies; 274 timeout = jiffies + 1 * HZ;
274 while (mb->return_code != 'I') /* Wait 1s for board to initialize */ 275 while (mb->return_code != 'I') /* Wait 1s for board to initialize */
275 if ((jiffies - timeout) > 1*HZ) break; 276 if (time_after(jiffies, timeout)) break;
276 277
277 if (mb->return_code != 'I') { 278 if (mb->return_code != 'I') {
278 printk(KERN_INFO 279 printk(KERN_INFO
@@ -493,11 +494,11 @@ static int update(struct wan_device* wandev)
493 chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UPDATE; 494 chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UPDATE;
494 495
495 /* wait a maximum of 1 second for the statistics to be updated */ 496 /* wait a maximum of 1 second for the statistics to be updated */
496 timeout = jiffies; 497 timeout = jiffies + 1 * HZ;
497 for(;;) { 498 for(;;) {
498 if(chdlc_priv_area->update_comms_stats == 0) 499 if(chdlc_priv_area->update_comms_stats == 0)
499 break; 500 break;
500 if ((jiffies - timeout) > (1 * HZ)){ 501 if (time_after(jiffies, timeout)){
501 chdlc_priv_area->update_comms_stats = 0; 502 chdlc_priv_area->update_comms_stats = 0;
502 chdlc_priv_area->timer_int_enabled &= 503 chdlc_priv_area->timer_int_enabled &=
503 ~TMR_INT_ENABLED_UPDATE; 504 ~TMR_INT_ENABLED_UPDATE;
diff --git a/drivers/sbus/char/Kconfig b/drivers/sbus/char/Kconfig
index 90d8ef1f0bcc..a41778a490d6 100644
--- a/drivers/sbus/char/Kconfig
+++ b/drivers/sbus/char/Kconfig
@@ -71,20 +71,6 @@ config SUN_JSFLASH
71 71
72# XXX Why don't we do "source drivers/char/Config.in" somewhere? 72# XXX Why don't we do "source drivers/char/Config.in" somewhere?
73# no shit 73# no shit
74config APM_RTC_IS_GMT
75 bool
76 depends on EXPERIMENTAL && SPARC32 && PCI
77 default y
78 help
79 Say Y here if your RTC (Real Time Clock a.k.a. hardware clock)
80 stores the time in GMT (Greenwich Mean Time). Say N if your RTC
81 stores localtime.
82
83 It is in fact recommended to store GMT in your RTC, because then you
84 don't have to worry about daylight savings time changes. The only
85 reason not to use GMT in your RTC is if you also run a broken OS
86 that doesn't understand GMT.
87
88config RTC 74config RTC
89 tristate "PC-style Real Time Clock Support" 75 tristate "PC-style Real Time Clock Support"
90 depends on PCI && EXPERIMENTAL && SPARC32 76 depends on PCI && EXPERIMENTAL && SPARC32
diff --git a/drivers/sbus/char/aurora.c b/drivers/sbus/char/aurora.c
index 650d5e924f47..d96cc47de566 100644
--- a/drivers/sbus/char/aurora.c
+++ b/drivers/sbus/char/aurora.c
@@ -1515,8 +1515,7 @@ static void aurora_close(struct tty_struct * tty, struct file * filp)
1515 */ 1515 */
1516 timeout = jiffies+HZ; 1516 timeout = jiffies+HZ;
1517 while(port->SRER & SRER_TXEMPTY) { 1517 while(port->SRER & SRER_TXEMPTY) {
1518 current->state = TASK_INTERRUPTIBLE; 1518 msleep_interruptible(jiffies_to_msecs(port->timeout));
1519 schedule_timeout(port->timeout);
1520 if (time_after(jiffies, timeout)) 1519 if (time_after(jiffies, timeout))
1521 break; 1520 break;
1522 } 1521 }
@@ -1533,8 +1532,7 @@ static void aurora_close(struct tty_struct * tty, struct file * filp)
1533 port->tty = 0; 1532 port->tty = 0;
1534 if (port->blocked_open) { 1533 if (port->blocked_open) {
1535 if (port->close_delay) { 1534 if (port->close_delay) {
1536 current->state = TASK_INTERRUPTIBLE; 1535 msleep_interruptible(jiffies_to_msecs(port->close_delay));
1537 schedule_timeout(port->close_delay);
1538 } 1536 }
1539 wake_up_interruptible(&port->open_wait); 1537 wake_up_interruptible(&port->open_wait);
1540 } 1538 }
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
index d5259f7fee6d..b8a2c7353b0a 100644
--- a/drivers/sbus/char/bbc_envctrl.c
+++ b/drivers/sbus/char/bbc_envctrl.c
@@ -4,13 +4,14 @@
4 * Copyright (C) 2001 David S. Miller (davem@redhat.com) 4 * Copyright (C) 2001 David S. Miller (davem@redhat.com)
5 */ 5 */
6 6
7#define __KERNEL_SYSCALLS__
8
7#include <linux/kernel.h> 9#include <linux/kernel.h>
8#include <linux/sched.h> 10#include <linux/sched.h>
9#include <linux/slab.h> 11#include <linux/slab.h>
10#include <linux/delay.h> 12#include <linux/delay.h>
11#include <asm/oplib.h> 13#include <asm/oplib.h>
12#include <asm/ebus.h> 14#include <asm/ebus.h>
13#define __KERNEL_SYSCALLS__
14static int errno; 15static int errno;
15#include <asm/unistd.h> 16#include <asm/unistd.h>
16 17
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index f6ed35b24f43..9a8c572554f5 100644
--- a/drivers/sbus/char/envctrl.c
+++ b/drivers/sbus/char/envctrl.c
@@ -19,6 +19,8 @@
19 * Daniele Bellucci <bellucda@tiscali.it> 19 * Daniele Bellucci <bellucda@tiscali.it>
20 */ 20 */
21 21
22#define __KERNEL_SYSCALLS__
23
22#include <linux/config.h> 24#include <linux/config.h>
23#include <linux/module.h> 25#include <linux/module.h>
24#include <linux/sched.h> 26#include <linux/sched.h>
@@ -35,7 +37,6 @@
35#include <asm/uaccess.h> 37#include <asm/uaccess.h>
36#include <asm/envctrl.h> 38#include <asm/envctrl.h>
37 39
38#define __KERNEL_SYSCALLS__
39static int errno; 40static int errno;
40#include <asm/unistd.h> 41#include <asm/unistd.h>
41 42
@@ -1007,7 +1008,7 @@ static int kenvctrld(void *__unused)
1007 return -ENODEV; 1008 return -ENODEV;
1008 } 1009 }
1009 1010
1010 poll_interval = 5 * HZ; /* TODO env_mon_interval */ 1011 poll_interval = 5000; /* TODO env_mon_interval */
1011 1012
1012 daemonize("kenvctrld"); 1013 daemonize("kenvctrld");
1013 allow_signal(SIGKILL); 1014 allow_signal(SIGKILL);
@@ -1016,10 +1017,7 @@ static int kenvctrld(void *__unused)
1016 1017
1017 printk(KERN_INFO "envctrl: %s starting...\n", current->comm); 1018 printk(KERN_INFO "envctrl: %s starting...\n", current->comm);
1018 for (;;) { 1019 for (;;) {
1019 current->state = TASK_INTERRUPTIBLE; 1020 if(msleep_interruptible(poll_interval))
1020 schedule_timeout(poll_interval);
1021
1022 if(signal_pending(current))
1023 break; 1021 break;
1024 1022
1025 for (whichcpu = 0; whichcpu < ENVCTRL_MAX_CPU; ++whichcpu) { 1023 for (whichcpu = 0; whichcpu < ENVCTRL_MAX_CPU; ++whichcpu) {
diff --git a/drivers/sbus/char/vfc_i2c.c b/drivers/sbus/char/vfc_i2c.c
index 95e3cebf792c..1faf1e75f71f 100644
--- a/drivers/sbus/char/vfc_i2c.c
+++ b/drivers/sbus/char/vfc_i2c.c
@@ -88,14 +88,16 @@ void vfc_i2c_delay_wakeup(struct vfc_dev *dev)
88 88
89void vfc_i2c_delay_no_busy(struct vfc_dev *dev, unsigned long usecs) 89void vfc_i2c_delay_no_busy(struct vfc_dev *dev, unsigned long usecs)
90{ 90{
91 DEFINE_WAIT(wait);
91 init_timer(&dev->poll_timer); 92 init_timer(&dev->poll_timer);
92 dev->poll_timer.expires = jiffies + 93 dev->poll_timer.expires = jiffies + usecs_to_jiffies(usecs);
93 ((unsigned long)usecs*(HZ))/1000000;
94 dev->poll_timer.data=(unsigned long)dev; 94 dev->poll_timer.data=(unsigned long)dev;
95 dev->poll_timer.function=(void *)(unsigned long)vfc_i2c_delay_wakeup; 95 dev->poll_timer.function=(void *)(unsigned long)vfc_i2c_delay_wakeup;
96 add_timer(&dev->poll_timer); 96 add_timer(&dev->poll_timer);
97 sleep_on(&dev->poll_wait); 97 prepare_to_wait(&dev->poll_wait, &wait, TASK_UNINTERRUPTIBLE);
98 schedule();
98 del_timer(&dev->poll_timer); 99 del_timer(&dev->poll_timer);
100 finish_wait(&dev->poll_wait, &wait);
99} 101}
100 102
101void inline vfc_i2c_delay(struct vfc_dev *dev) 103void inline vfc_i2c_delay(struct vfc_dev *dev)
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index de54bdc5398b..356f5556759a 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -389,6 +389,9 @@ static void __devexit sbs_exit(struct pci_dev *dev)
389 * - 10x cards have control registers in IO and/or memory space; 389 * - 10x cards have control registers in IO and/or memory space;
390 * - 20x cards have control registers in standard PCI configuration space. 390 * - 20x cards have control registers in standard PCI configuration space.
391 * 391 *
392 * There are also Quartet Serial cards which use Oxford Semiconductor
393 * 16954 quad UART PCI chip clocked by 18.432 MHz quartz.
394 *
392 * Note: some SIIG cards are probed by the parport_serial object. 395 * Note: some SIIG cards are probed by the parport_serial object.
393 */ 396 */
394 397
@@ -1026,6 +1029,8 @@ enum pci_board_num_t {
1026 pbn_b0_2_921600, 1029 pbn_b0_2_921600,
1027 pbn_b0_4_921600, 1030 pbn_b0_4_921600,
1028 1031
1032 pbn_b0_4_1152000,
1033
1029 pbn_b0_bt_1_115200, 1034 pbn_b0_bt_1_115200,
1030 pbn_b0_bt_2_115200, 1035 pbn_b0_bt_2_115200,
1031 pbn_b0_bt_8_115200, 1036 pbn_b0_bt_8_115200,
@@ -1158,6 +1163,12 @@ static struct pci_board pci_boards[] __devinitdata = {
1158 .base_baud = 921600, 1163 .base_baud = 921600,
1159 .uart_offset = 8, 1164 .uart_offset = 8,
1160 }, 1165 },
1166 [pbn_b0_4_1152000] = {
1167 .flags = FL_BASE0,
1168 .num_ports = 4,
1169 .base_baud = 1152000,
1170 .uart_offset = 8,
1171 },
1161 1172
1162 [pbn_b0_bt_1_115200] = { 1173 [pbn_b0_bt_1_115200] = {
1163 .flags = FL_BASE0|FL_BASE_BARS, 1174 .flags = FL_BASE0|FL_BASE_BARS,
@@ -1755,33 +1766,30 @@ pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
1755static void __devexit pciserial_remove_one(struct pci_dev *dev) 1766static void __devexit pciserial_remove_one(struct pci_dev *dev)
1756{ 1767{
1757 struct serial_private *priv = pci_get_drvdata(dev); 1768 struct serial_private *priv = pci_get_drvdata(dev);
1769 struct pci_serial_quirk *quirk;
1770 int i;
1758 1771
1759 pci_set_drvdata(dev, NULL); 1772 pci_set_drvdata(dev, NULL);
1760 1773
1761 if (priv) { 1774 for (i = 0; i < priv->nr; i++)
1762 struct pci_serial_quirk *quirk; 1775 serial8250_unregister_port(priv->line[i]);
1763 int i;
1764
1765 for (i = 0; i < priv->nr; i++)
1766 serial8250_unregister_port(priv->line[i]);
1767 1776
1768 for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) { 1777 for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) {
1769 if (priv->remapped_bar[i]) 1778 if (priv->remapped_bar[i])
1770 iounmap(priv->remapped_bar[i]); 1779 iounmap(priv->remapped_bar[i]);
1771 priv->remapped_bar[i] = NULL; 1780 priv->remapped_bar[i] = NULL;
1772 } 1781 }
1773 1782
1774 /* 1783 /*
1775 * Find the exit quirks. 1784 * Find the exit quirks.
1776 */ 1785 */
1777 quirk = find_quirk(dev); 1786 quirk = find_quirk(dev);
1778 if (quirk->exit) 1787 if (quirk->exit)
1779 quirk->exit(dev); 1788 quirk->exit(dev);
1780 1789
1781 pci_disable_device(dev); 1790 pci_disable_device(dev);
1782 1791
1783 kfree(priv); 1792 kfree(priv);
1784 }
1785} 1793}
1786 1794
1787static int pciserial_suspend_one(struct pci_dev *dev, pm_message_t state) 1795static int pciserial_suspend_one(struct pci_dev *dev, pm_message_t state)
@@ -1978,6 +1986,9 @@ static struct pci_device_id serial_pci_tbl[] = {
1978 PCI_VENDOR_ID_SPECIALIX, PCI_SUBDEVICE_ID_SPECIALIX_SPEED4, 0, 0, 1986 PCI_VENDOR_ID_SPECIALIX, PCI_SUBDEVICE_ID_SPECIALIX_SPEED4, 0, 0,
1979 pbn_b0_4_921600 }, 1987 pbn_b0_4_921600 },
1980 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954, 1988 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954,
1989 PCI_SUBVENDOR_ID_SIIG, PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL, 0, 0,
1990 pbn_b0_4_1152000 },
1991 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954,
1981 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1992 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1982 pbn_b0_4_115200 }, 1993 pbn_b0_4_115200 },
1983 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI952, 1994 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI952,
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index e0d0a470ddfc..97034d3937fd 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -306,13 +306,6 @@ config SERIAL_S3C2410_CONSOLE
306 your boot loader about how to pass options to the kernel at 306 your boot loader about how to pass options to the kernel at
307 boot time.) 307 boot time.)
308 308
309config SERIAL_BAST_SIO
310 bool "Support for BAST SuperIO serial ports"
311 depends on ARCH_BAST && SERIAL_8250=y
312 help
313 Support for registerin the SuperIO chip on BAST board with
314 the 8250/16550 uart code.
315
316config SERIAL_DZ 309config SERIAL_DZ
317 bool "DECstation DZ serial driver" 310 bool "DECstation DZ serial driver"
318 depends on MACH_DECSTATION && MIPS32 311 depends on MACH_DECSTATION && MIPS32
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 65bd4381685e..11c7dc483f93 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -44,7 +44,6 @@ obj-$(CONFIG_SERIAL_LH7A40X) += serial_lh7a40x.o
44obj-$(CONFIG_SERIAL_AU1X00) += au1x00_uart.o 44obj-$(CONFIG_SERIAL_AU1X00) += au1x00_uart.o
45obj-$(CONFIG_SERIAL_DZ) += dz.o 45obj-$(CONFIG_SERIAL_DZ) += dz.o
46obj-$(CONFIG_SERIAL_SH_SCI) += sh-sci.o 46obj-$(CONFIG_SERIAL_SH_SCI) += sh-sci.o
47obj-$(CONFIG_SERIAL_BAST_SIO) += bast_sio.o
48obj-$(CONFIG_SERIAL_SGI_L1_CONSOLE) += sn_console.o 47obj-$(CONFIG_SERIAL_SGI_L1_CONSOLE) += sn_console.o
49obj-$(CONFIG_SERIAL_CPM) += cpm_uart/ 48obj-$(CONFIG_SERIAL_CPM) += cpm_uart/
50obj-$(CONFIG_SERIAL_IMX) += imx.o 49obj-$(CONFIG_SERIAL_IMX) += imx.o
diff --git a/drivers/serial/bast_sio.c b/drivers/serial/bast_sio.c
deleted file mode 100644
index 2b48fab6f0c6..000000000000
--- a/drivers/serial/bast_sio.c
+++ /dev/null
@@ -1,80 +0,0 @@
1/* linux/drivers/serial/bast_sio.c
2 *
3 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * http://www.simtec.co.uk/products/EB2410ITX/
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * Modifications:
13 * 23-Sep-2004 BJD Added copyright header
14 * 23-Sep-2004 BJD Added serial port remove code
15*/
16
17#include <linux/module.h>
18#include <linux/config.h>
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/tty.h>
22#include <linux/serial.h>
23#include <linux/serial_core.h>
24#include <linux/types.h>
25
26#include <asm/io.h>
27#include <asm/serial.h>
28#include <asm/mach-types.h>
29
30#include <asm/arch/map.h>
31#include <asm/arch/irqs.h>
32#include <asm/arch/bast-map.h>
33#include <asm/arch/bast-irq.h>
34
35static int __init serial_bast_register(unsigned long port, unsigned int irq)
36{
37 struct serial_struct serial_req;
38
39 serial_req.flags = UPF_AUTOPROBE | UPF_SHARE_IRQ;
40 serial_req.baud_base = BASE_BAUD;
41 serial_req.irq = irq;
42 serial_req.io_type = UPIO_MEM;
43 serial_req.iomap_base = port;
44 serial_req.iomem_base = ioremap(port, 0x10);
45 serial_req.iomem_reg_shift = 0;
46
47 return register_serial(&serial_req);
48}
49
50#define SERIAL_BASE (S3C2410_CS2 + BAST_PA_SUPERIO)
51
52static int port[2] = { -1, -1 };
53
54static int __init serial_bast_init(void)
55{
56 if (machine_is_bast()) {
57 port[0] = serial_bast_register(SERIAL_BASE + 0x2f8, IRQ_PCSERIAL1);
58 port[1] = serial_bast_register(SERIAL_BASE + 0x3f8, IRQ_PCSERIAL2);
59 }
60
61 return 0;
62}
63
64static void __exit serial_bast_exit(void)
65{
66 if (port[0] != -1)
67 unregister_serial(port[0]);
68 if (port[1] != -1)
69 unregister_serial(port[1]);
70}
71
72
73module_init(serial_bast_init);
74module_exit(serial_bast_exit);
75
76MODULE_LICENSE("GPL");
77MODULE_AUTHOR("Ben Dooks, ben@simtec.co.uk");
78MODULE_DESCRIPTION("BAST Onboard Serial setup");
79
80
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index d0cbbb7f0385..6bd581e69afd 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -448,19 +448,19 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
448 case 0: 448 case 0:
449 atm_dev->signal = ATM_PHY_SIG_LOST; 449 atm_dev->signal = ATM_PHY_SIG_LOST;
450 if (instance->last_status) 450 if (instance->last_status)
451 atm_info(usbatm, "ADSL line is down\n"); 451 atm_info(usbatm, "%s\n", "ADSL line is down");
452 /* It may never resync again unless we ask it to... */ 452 /* It may never resync again unless we ask it to... */
453 ret = speedtch_start_synchro(instance); 453 ret = speedtch_start_synchro(instance);
454 break; 454 break;
455 455
456 case 0x08: 456 case 0x08:
457 atm_dev->signal = ATM_PHY_SIG_UNKNOWN; 457 atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
458 atm_info(usbatm, "ADSL line is blocked?\n"); 458 atm_info(usbatm, "%s\n", "ADSL line is blocked?");
459 break; 459 break;
460 460
461 case 0x10: 461 case 0x10:
462 atm_dev->signal = ATM_PHY_SIG_LOST; 462 atm_dev->signal = ATM_PHY_SIG_LOST;
463 atm_info(usbatm, "ADSL line is synchronising\n"); 463 atm_info(usbatm, "%s\n", "ADSL line is synchronising");
464 break; 464 break;
465 465
466 case 0x20: 466 case 0x20:
@@ -502,7 +502,7 @@ static void speedtch_status_poll(unsigned long data)
502 if (instance->poll_delay < MAX_POLL_DELAY) 502 if (instance->poll_delay < MAX_POLL_DELAY)
503 mod_timer(&instance->status_checker.timer, jiffies + msecs_to_jiffies(instance->poll_delay)); 503 mod_timer(&instance->status_checker.timer, jiffies + msecs_to_jiffies(instance->poll_delay));
504 else 504 else
505 atm_warn(instance->usbatm, "Too many failures - disabling line status polling\n"); 505 atm_warn(instance->usbatm, "%s\n", "Too many failures - disabling line status polling");
506} 506}
507 507
508static void speedtch_resubmit_int(unsigned long data) 508static void speedtch_resubmit_int(unsigned long data)
@@ -545,9 +545,9 @@ static void speedtch_handle_int(struct urb *int_urb, struct pt_regs *regs)
545 545
546 if ((count == 6) && !memcmp(up_int, instance->int_data, 6)) { 546 if ((count == 6) && !memcmp(up_int, instance->int_data, 6)) {
547 del_timer(&instance->status_checker.timer); 547 del_timer(&instance->status_checker.timer);
548 atm_info(usbatm, "DSL line goes up\n"); 548 atm_info(usbatm, "%s\n", "DSL line goes up");
549 } else if ((count == 6) && !memcmp(down_int, instance->int_data, 6)) { 549 } else if ((count == 6) && !memcmp(down_int, instance->int_data, 6)) {
550 atm_info(usbatm, "DSL line goes down\n"); 550 atm_info(usbatm, "%s\n", "DSL line goes down");
551 } else { 551 } else {
552 int i; 552 int i;
553 553
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index 8fe1c12a17bd..cabd53cec991 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -249,9 +249,6 @@ static void imxfb_enable_controller(struct imxfb_info *fbi)
249 /* disable hardware cursor */ 249 /* disable hardware cursor */
250 LCDC_CPOS &= ~(CPOS_CC0 | CPOS_CC1); 250 LCDC_CPOS &= ~(CPOS_CC0 | CPOS_CC1);
251 251
252 /* fixed burst length (see erratum 11) */
253 LCDC_DMACR = DMACR_BURST | DMACR_HM(8) | DMACR_TM(2);
254
255 LCDC_RMCR = RMCR_LCDC_EN; 252 LCDC_RMCR = RMCR_LCDC_EN;
256 253
257 if(fbi->backlight_power) 254 if(fbi->backlight_power)
@@ -359,6 +356,7 @@ static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *inf
359 LCDC_PCR = fbi->pcr; 356 LCDC_PCR = fbi->pcr;
360 LCDC_PWMR = fbi->pwmr; 357 LCDC_PWMR = fbi->pwmr;
361 LCDC_LSCR1 = fbi->lscr1; 358 LCDC_LSCR1 = fbi->lscr1;
359 LCDC_DMACR = fbi->dmacr;
362 360
363 return 0; 361 return 0;
364} 362}
@@ -509,6 +507,7 @@ static int __init imxfb_init_fbinfo(struct device *dev)
509 fbi->cmap_inverse = inf->cmap_inverse; 507 fbi->cmap_inverse = inf->cmap_inverse;
510 fbi->pcr = inf->pcr; 508 fbi->pcr = inf->pcr;
511 fbi->lscr1 = inf->lscr1; 509 fbi->lscr1 = inf->lscr1;
510 fbi->dmacr = inf->dmacr;
512 fbi->pwmr = inf->pwmr; 511 fbi->pwmr = inf->pwmr;
513 fbi->lcd_power = inf->lcd_power; 512 fbi->lcd_power = inf->lcd_power;
514 fbi->backlight_power = inf->backlight_power; 513 fbi->backlight_power = inf->backlight_power;
@@ -642,12 +641,12 @@ static int imxfb_remove(struct device *dev)
642{ 641{
643 struct platform_device *pdev = to_platform_device(dev); 642 struct platform_device *pdev = to_platform_device(dev);
644 struct fb_info *info = dev_get_drvdata(dev); 643 struct fb_info *info = dev_get_drvdata(dev);
644 struct imxfb_info *fbi = info->par;
645 struct resource *res; 645 struct resource *res;
646 646
647 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 647 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
648 648
649 /* disable LCD controller */ 649 imxfb_disable_controller(fbi);
650 LCDC_RMCR &= ~RMCR_LCDC_EN;
651 650
652 unregister_framebuffer(info); 651 unregister_framebuffer(info);
653 652
@@ -663,8 +662,9 @@ static int imxfb_remove(struct device *dev)
663 662
664void imxfb_shutdown(struct device * dev) 663void imxfb_shutdown(struct device * dev)
665{ 664{
666 /* disable LCD Controller */ 665 struct fb_info *info = dev_get_drvdata(dev);
667 LCDC_RMCR &= ~RMCR_LCDC_EN; 666 struct imxfb_info *fbi = info->par;
667 imxfb_disable_controller(fbi);
668} 668}
669 669
670static struct device_driver imxfb_driver = { 670static struct device_driver imxfb_driver = {
diff --git a/drivers/video/imxfb.h b/drivers/video/imxfb.h
index 128c3ee515c7..e837a8b48eb8 100644
--- a/drivers/video/imxfb.h
+++ b/drivers/video/imxfb.h
@@ -54,6 +54,7 @@ struct imxfb_info {
54 u_int pcr; 54 u_int pcr;
55 u_int pwmr; 55 u_int pwmr;
56 u_int lscr1; 56 u_int lscr1;
57 u_int dmacr;
57 u_int cmap_inverse:1, 58 u_int cmap_inverse:1,
58 cmap_static:1, 59 cmap_static:1,
59 unused:30; 60 unused:30;
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 35e85d961702..b5a5e04b6d37 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -88,7 +88,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
88 88
89 dev->groups = 23; 89 dev->groups = 23;
90 dev->seq = 1; 90 dev->seq = 1;
91 dev->nls = netlink_kernel_create(NETLINK_NFLOG, NULL); 91 dev->nls = netlink_kernel_create(NETLINK_W1, NULL);
92 if (!dev->nls) { 92 if (!dev->nls) {
93 printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n", 93 printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n",
94 NETLINK_NFLOG, dev->dev.bus_id); 94 NETLINK_NFLOG, dev->dev.bus_id);
diff --git a/include/asm-arm/arch-imx/imxfb.h b/include/asm-arm/arch-imx/imxfb.h
index 2346d454ab9c..7dbc7bbba65d 100644
--- a/include/asm-arm/arch-imx/imxfb.h
+++ b/include/asm-arm/arch-imx/imxfb.h
@@ -25,6 +25,7 @@ struct imxfb_mach_info {
25 u_int pcr; 25 u_int pcr;
26 u_int pwmr; 26 u_int pwmr;
27 u_int lscr1; 27 u_int lscr1;
28 u_int dmacr;
28 29
29 u_char * fixed_screen_cpu; 30 u_char * fixed_screen_cpu;
30 dma_addr_t fixed_screen_dma; 31 dma_addr_t fixed_screen_dma;
diff --git a/include/asm-arm/locks.h b/include/asm-arm/locks.h
index c26298f3891f..9cb33fcc06c1 100644
--- a/include/asm-arm/locks.h
+++ b/include/asm-arm/locks.h
@@ -61,7 +61,7 @@
61" strex ip, lr, [%0]\n" \ 61" strex ip, lr, [%0]\n" \
62" teq ip, #0\n" \ 62" teq ip, #0\n" \
63" bne 1b\n" \ 63" bne 1b\n" \
64" teq lr, #0\n" \ 64" cmp lr, #0\n" \
65" movle ip, %0\n" \ 65" movle ip, %0\n" \
66" blle " #wake \ 66" blle " #wake \
67 : \ 67 : \
@@ -100,7 +100,7 @@
100 __asm__ __volatile__( \ 100 __asm__ __volatile__( \
101 "@ up_op_read\n" \ 101 "@ up_op_read\n" \
102"1: ldrex lr, [%0]\n" \ 102"1: ldrex lr, [%0]\n" \
103" add lr, lr, %1\n" \ 103" adds lr, lr, %1\n" \
104" strex ip, lr, [%0]\n" \ 104" strex ip, lr, [%0]\n" \
105" teq ip, #0\n" \ 105" teq ip, #0\n" \
106" bne 1b\n" \ 106" bne 1b\n" \
diff --git a/include/asm-arm/spinlock.h b/include/asm-arm/spinlock.h
index 182323619caa..9705d5eec94c 100644
--- a/include/asm-arm/spinlock.h
+++ b/include/asm-arm/spinlock.h
@@ -79,7 +79,8 @@ typedef struct {
79} rwlock_t; 79} rwlock_t;
80 80
81#define RW_LOCK_UNLOCKED (rwlock_t) { 0 } 81#define RW_LOCK_UNLOCKED (rwlock_t) { 0 }
82#define rwlock_init(x) do { *(x) + RW_LOCK_UNLOCKED; } while (0) 82#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while (0)
83#define rwlock_is_locked(x) (*((volatile unsigned int *)(x)) != 0)
83 84
84/* 85/*
85 * Write locks are easy - we just set bit 31. When unlocking, we can 86 * Write locks are easy - we just set bit 31. When unlocking, we can
@@ -100,6 +101,21 @@ static inline void _raw_write_lock(rwlock_t *rw)
100 : "cc", "memory"); 101 : "cc", "memory");
101} 102}
102 103
104static inline int _raw_write_trylock(rwlock_t *rw)
105{
106 unsigned long tmp;
107
108 __asm__ __volatile__(
109"1: ldrex %0, [%1]\n"
110" teq %0, #0\n"
111" strexeq %0, %2, [%1]"
112 : "=&r" (tmp)
113 : "r" (&rw->lock), "r" (0x80000000)
114 : "cc", "memory");
115
116 return tmp == 0;
117}
118
103static inline void _raw_write_unlock(rwlock_t *rw) 119static inline void _raw_write_unlock(rwlock_t *rw)
104{ 120{
105 __asm__ __volatile__( 121 __asm__ __volatile__(
@@ -138,6 +154,8 @@ static inline void _raw_read_lock(rwlock_t *rw)
138 154
139static inline void _raw_read_unlock(rwlock_t *rw) 155static inline void _raw_read_unlock(rwlock_t *rw)
140{ 156{
157 unsigned long tmp, tmp2;
158
141 __asm__ __volatile__( 159 __asm__ __volatile__(
142"1: ldrex %0, [%2]\n" 160"1: ldrex %0, [%2]\n"
143" sub %0, %0, #1\n" 161" sub %0, %0, #1\n"
@@ -151,19 +169,4 @@ static inline void _raw_read_unlock(rwlock_t *rw)
151 169
152#define _raw_read_trylock(lock) generic_raw_read_trylock(lock) 170#define _raw_read_trylock(lock) generic_raw_read_trylock(lock)
153 171
154static inline int _raw_write_trylock(rwlock_t *rw)
155{
156 unsigned long tmp;
157
158 __asm__ __volatile__(
159"1: ldrex %0, [%1]\n"
160" teq %0, #0\n"
161" strexeq %0, %2, [%1]"
162 : "=&r" (tmp)
163 : "r" (&rw->lock), "r" (0x80000000)
164 : "cc", "memory");
165
166 return tmp == 0;
167}
168
169#endif /* __ASM_SPINLOCK_H */ 172#endif /* __ASM_SPINLOCK_H */
diff --git a/include/asm-i386/i387.h b/include/asm-i386/i387.h
index f6feb98a9397..6747006743f9 100644
--- a/include/asm-i386/i387.h
+++ b/include/asm-i386/i387.h
@@ -19,10 +19,21 @@
19 19
20extern void mxcsr_feature_mask_init(void); 20extern void mxcsr_feature_mask_init(void);
21extern void init_fpu(struct task_struct *); 21extern void init_fpu(struct task_struct *);
22
22/* 23/*
23 * FPU lazy state save handling... 24 * FPU lazy state save handling...
24 */ 25 */
25extern void restore_fpu( struct task_struct *tsk ); 26
27/*
28 * The "nop" is needed to make the instructions the same
29 * length.
30 */
31#define restore_fpu(tsk) \
32 alternative_input( \
33 "nop ; frstor %1", \
34 "fxrstor %1", \
35 X86_FEATURE_FXSR, \
36 "m" ((tsk)->thread.i387.fxsave))
26 37
27extern void kernel_fpu_begin(void); 38extern void kernel_fpu_begin(void);
28#define kernel_fpu_end() do { stts(); preempt_enable(); } while(0) 39#define kernel_fpu_end() do { stts(); preempt_enable(); } while(0)
@@ -32,13 +43,12 @@ extern void kernel_fpu_begin(void);
32 */ 43 */
33static inline void __save_init_fpu( struct task_struct *tsk ) 44static inline void __save_init_fpu( struct task_struct *tsk )
34{ 45{
35 if ( cpu_has_fxsr ) { 46 alternative_input(
36 asm volatile( "fxsave %0 ; fnclex" 47 "fnsave %1 ; fwait ;" GENERIC_NOP2,
37 : "=m" (tsk->thread.i387.fxsave) ); 48 "fxsave %1 ; fnclex",
38 } else { 49 X86_FEATURE_FXSR,
39 asm volatile( "fnsave %0 ; fwait" 50 "m" (tsk->thread.i387.fxsave)
40 : "=m" (tsk->thread.i387.fsave) ); 51 :"memory");
41 }
42 tsk->thread_info->status &= ~TS_USEDFPU; 52 tsk->thread_info->status &= ~TS_USEDFPU;
43} 53}
44 54
diff --git a/include/asm-sparc64/bitops.h b/include/asm-sparc64/bitops.h
index 9d722dc8cca3..9c5e71970287 100644
--- a/include/asm-sparc64/bitops.h
+++ b/include/asm-sparc64/bitops.h
@@ -20,52 +20,52 @@ extern void change_bit(unsigned long nr, volatile unsigned long *addr);
20 20
21/* "non-atomic" versions... */ 21/* "non-atomic" versions... */
22 22
23static __inline__ void __set_bit(int nr, volatile unsigned long *addr) 23static inline void __set_bit(int nr, volatile unsigned long *addr)
24{ 24{
25 volatile unsigned long *m = addr + (nr >> 6); 25 unsigned long *m = ((unsigned long *)addr) + (nr >> 6);
26 26
27 *m |= (1UL << (nr & 63)); 27 *m |= (1UL << (nr & 63));
28} 28}
29 29
30static __inline__ void __clear_bit(int nr, volatile unsigned long *addr) 30static inline void __clear_bit(int nr, volatile unsigned long *addr)
31{ 31{
32 volatile unsigned long *m = addr + (nr >> 6); 32 unsigned long *m = ((unsigned long *)addr) + (nr >> 6);
33 33
34 *m &= ~(1UL << (nr & 63)); 34 *m &= ~(1UL << (nr & 63));
35} 35}
36 36
37static __inline__ void __change_bit(int nr, volatile unsigned long *addr) 37static inline void __change_bit(int nr, volatile unsigned long *addr)
38{ 38{
39 volatile unsigned long *m = addr + (nr >> 6); 39 unsigned long *m = ((unsigned long *)addr) + (nr >> 6);
40 40
41 *m ^= (1UL << (nr & 63)); 41 *m ^= (1UL << (nr & 63));
42} 42}
43 43
44static __inline__ int __test_and_set_bit(int nr, volatile unsigned long *addr) 44static inline int __test_and_set_bit(int nr, volatile unsigned long *addr)
45{ 45{
46 volatile unsigned long *m = addr + (nr >> 6); 46 unsigned long *m = ((unsigned long *)addr) + (nr >> 6);
47 long old = *m; 47 unsigned long old = *m;
48 long mask = (1UL << (nr & 63)); 48 unsigned long mask = (1UL << (nr & 63));
49 49
50 *m = (old | mask); 50 *m = (old | mask);
51 return ((old & mask) != 0); 51 return ((old & mask) != 0);
52} 52}
53 53
54static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long *addr) 54static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)
55{ 55{
56 volatile unsigned long *m = addr + (nr >> 6); 56 unsigned long *m = ((unsigned long *)addr) + (nr >> 6);
57 long old = *m; 57 unsigned long old = *m;
58 long mask = (1UL << (nr & 63)); 58 unsigned long mask = (1UL << (nr & 63));
59 59
60 *m = (old & ~mask); 60 *m = (old & ~mask);
61 return ((old & mask) != 0); 61 return ((old & mask) != 0);
62} 62}
63 63
64static __inline__ int __test_and_change_bit(int nr, volatile unsigned long *addr) 64static inline int __test_and_change_bit(int nr, volatile unsigned long *addr)
65{ 65{
66 volatile unsigned long *m = addr + (nr >> 6); 66 unsigned long *m = ((unsigned long *)addr) + (nr >> 6);
67 long old = *m; 67 unsigned long old = *m;
68 long mask = (1UL << (nr & 63)); 68 unsigned long mask = (1UL << (nr & 63));
69 69
70 *m = (old ^ mask); 70 *m = (old ^ mask);
71 return ((old & mask) != 0); 71 return ((old & mask) != 0);
@@ -79,13 +79,13 @@ static __inline__ int __test_and_change_bit(int nr, volatile unsigned long *addr
79#define smp_mb__after_clear_bit() barrier() 79#define smp_mb__after_clear_bit() barrier()
80#endif 80#endif
81 81
82static __inline__ int test_bit(int nr, __const__ volatile unsigned long *addr) 82static inline int test_bit(int nr, __const__ volatile unsigned long *addr)
83{ 83{
84 return (1UL & ((addr)[nr >> 6] >> (nr & 63))) != 0UL; 84 return (1UL & (addr[nr >> 6] >> (nr & 63))) != 0UL;
85} 85}
86 86
87/* The easy/cheese version for now. */ 87/* The easy/cheese version for now. */
88static __inline__ unsigned long ffz(unsigned long word) 88static inline unsigned long ffz(unsigned long word)
89{ 89{
90 unsigned long result; 90 unsigned long result;
91 91
@@ -103,7 +103,7 @@ static __inline__ unsigned long ffz(unsigned long word)
103 * 103 *
104 * Undefined if no bit exists, so code should check against 0 first. 104 * Undefined if no bit exists, so code should check against 0 first.
105 */ 105 */
106static __inline__ unsigned long __ffs(unsigned long word) 106static inline unsigned long __ffs(unsigned long word)
107{ 107{
108 unsigned long result = 0; 108 unsigned long result = 0;
109 109
@@ -144,7 +144,7 @@ static inline int sched_find_first_bit(unsigned long *b)
144 * the libc and compiler builtin ffs routines, therefore 144 * the libc and compiler builtin ffs routines, therefore
145 * differs in spirit from the above ffz (man ffs). 145 * differs in spirit from the above ffz (man ffs).
146 */ 146 */
147static __inline__ int ffs(int x) 147static inline int ffs(int x)
148{ 148{
149 if (!x) 149 if (!x)
150 return 0; 150 return 0;
@@ -158,7 +158,7 @@ static __inline__ int ffs(int x)
158 158
159#ifdef ULTRA_HAS_POPULATION_COUNT 159#ifdef ULTRA_HAS_POPULATION_COUNT
160 160
161static __inline__ unsigned int hweight64(unsigned long w) 161static inline unsigned int hweight64(unsigned long w)
162{ 162{
163 unsigned int res; 163 unsigned int res;
164 164
@@ -166,7 +166,7 @@ static __inline__ unsigned int hweight64(unsigned long w)
166 return res; 166 return res;
167} 167}
168 168
169static __inline__ unsigned int hweight32(unsigned int w) 169static inline unsigned int hweight32(unsigned int w)
170{ 170{
171 unsigned int res; 171 unsigned int res;
172 172
@@ -174,7 +174,7 @@ static __inline__ unsigned int hweight32(unsigned int w)
174 return res; 174 return res;
175} 175}
176 176
177static __inline__ unsigned int hweight16(unsigned int w) 177static inline unsigned int hweight16(unsigned int w)
178{ 178{
179 unsigned int res; 179 unsigned int res;
180 180
@@ -182,7 +182,7 @@ static __inline__ unsigned int hweight16(unsigned int w)
182 return res; 182 return res;
183} 183}
184 184
185static __inline__ unsigned int hweight8(unsigned int w) 185static inline unsigned int hweight8(unsigned int w)
186{ 186{
187 unsigned int res; 187 unsigned int res;
188 188
@@ -236,7 +236,7 @@ extern unsigned long find_next_zero_bit(const unsigned long *,
236#define test_and_clear_le_bit(nr,addr) \ 236#define test_and_clear_le_bit(nr,addr) \
237 test_and_clear_bit((nr) ^ 0x38, (addr)) 237 test_and_clear_bit((nr) ^ 0x38, (addr))
238 238
239static __inline__ int test_le_bit(int nr, __const__ unsigned long * addr) 239static inline int test_le_bit(int nr, __const__ unsigned long * addr)
240{ 240{
241 int mask; 241 int mask;
242 __const__ unsigned char *ADDR = (__const__ unsigned char *) addr; 242 __const__ unsigned char *ADDR = (__const__ unsigned char *) addr;
diff --git a/include/asm-sparc64/ptrace.h b/include/asm-sparc64/ptrace.h
index 2d2b5a113d24..6194f771e9fc 100644
--- a/include/asm-sparc64/ptrace.h
+++ b/include/asm-sparc64/ptrace.h
@@ -94,8 +94,9 @@ struct sparc_trapf {
94#define STACKFRAME32_SZ sizeof(struct sparc_stackf32) 94#define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
95 95
96#ifdef __KERNEL__ 96#ifdef __KERNEL__
97#define force_successful_syscall_return() \ 97#define force_successful_syscall_return() \
98 set_thread_flag(TIF_SYSCALL_SUCCESS) 98do { current_thread_info()->syscall_noerror = 1; \
99} while (0)
99#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV)) 100#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
100#define instruction_pointer(regs) ((regs)->tpc) 101#define instruction_pointer(regs) ((regs)->tpc)
101#ifdef CONFIG_SMP 102#ifdef CONFIG_SMP
diff --git a/include/asm-sparc64/rwsem.h b/include/asm-sparc64/rwsem.h
index a1cc94f95984..4568ee4022df 100644
--- a/include/asm-sparc64/rwsem.h
+++ b/include/asm-sparc64/rwsem.h
@@ -46,54 +46,14 @@ extern void __up_read(struct rw_semaphore *sem);
46extern void __up_write(struct rw_semaphore *sem); 46extern void __up_write(struct rw_semaphore *sem);
47extern void __downgrade_write(struct rw_semaphore *sem); 47extern void __downgrade_write(struct rw_semaphore *sem);
48 48
49static __inline__ int rwsem_atomic_update(int delta, struct rw_semaphore *sem) 49static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem)
50{ 50{
51 int tmp = delta; 51 return atomic_add_return(delta, (atomic_t *)(&sem->count));
52
53 __asm__ __volatile__(
54 "1:\tlduw [%2], %%g1\n\t"
55 "add %%g1, %1, %%g7\n\t"
56 "cas [%2], %%g1, %%g7\n\t"
57 "cmp %%g1, %%g7\n\t"
58 "membar #StoreLoad | #StoreStore\n\t"
59 "bne,pn %%icc, 1b\n\t"
60 " nop\n\t"
61 "mov %%g7, %0\n\t"
62 : "=&r" (tmp)
63 : "0" (tmp), "r" (sem)
64 : "g1", "g7", "memory", "cc");
65
66 return tmp + delta;
67}
68
69#define rwsem_atomic_add rwsem_atomic_update
70
71static __inline__ __u16 rwsem_cmpxchgw(struct rw_semaphore *sem, __u16 __old, __u16 __new)
72{
73 u32 old = (sem->count & 0xffff0000) | (u32) __old;
74 u32 new = (old & 0xffff0000) | (u32) __new;
75 u32 prev;
76
77again:
78 __asm__ __volatile__("cas [%2], %3, %0\n\t"
79 "membar #StoreLoad | #StoreStore"
80 : "=&r" (prev)
81 : "0" (new), "r" (sem), "r" (old)
82 : "memory");
83
84 /* To give the same semantics as x86 cmpxchgw, keep trying
85 * if only the upper 16-bits changed.
86 */
87 if (prev != old &&
88 ((prev & 0xffff) == (old & 0xffff)))
89 goto again;
90
91 return prev & 0xffff;
92} 52}
93 53
94static __inline__ signed long rwsem_cmpxchg(struct rw_semaphore *sem, signed long old, signed long new) 54static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
95{ 55{
96 return cmpxchg(&sem->count,old,new); 56 atomic_add(delta, (atomic_t *)(&sem->count));
97} 57}
98 58
99#endif /* __KERNEL__ */ 59#endif /* __KERNEL__ */
diff --git a/include/asm-sparc64/spitfire.h b/include/asm-sparc64/spitfire.h
index 1aa932773af8..962638c9d122 100644
--- a/include/asm-sparc64/spitfire.h
+++ b/include/asm-sparc64/spitfire.h
@@ -56,52 +56,6 @@ extern void cheetah_enable_pcache(void);
56 SPITFIRE_HIGHEST_LOCKED_TLBENT : \ 56 SPITFIRE_HIGHEST_LOCKED_TLBENT : \
57 CHEETAH_HIGHEST_LOCKED_TLBENT) 57 CHEETAH_HIGHEST_LOCKED_TLBENT)
58 58
59static __inline__ unsigned long spitfire_get_isfsr(void)
60{
61 unsigned long ret;
62
63 __asm__ __volatile__("ldxa [%1] %2, %0"
64 : "=r" (ret)
65 : "r" (TLB_SFSR), "i" (ASI_IMMU));
66 return ret;
67}
68
69static __inline__ unsigned long spitfire_get_dsfsr(void)
70{
71 unsigned long ret;
72
73 __asm__ __volatile__("ldxa [%1] %2, %0"
74 : "=r" (ret)
75 : "r" (TLB_SFSR), "i" (ASI_DMMU));
76 return ret;
77}
78
79static __inline__ unsigned long spitfire_get_sfar(void)
80{
81 unsigned long ret;
82
83 __asm__ __volatile__("ldxa [%1] %2, %0"
84 : "=r" (ret)
85 : "r" (DMMU_SFAR), "i" (ASI_DMMU));
86 return ret;
87}
88
89static __inline__ void spitfire_put_isfsr(unsigned long sfsr)
90{
91 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
92 "membar #Sync"
93 : /* no outputs */
94 : "r" (sfsr), "r" (TLB_SFSR), "i" (ASI_IMMU));
95}
96
97static __inline__ void spitfire_put_dsfsr(unsigned long sfsr)
98{
99 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
100 "membar #Sync"
101 : /* no outputs */
102 : "r" (sfsr), "r" (TLB_SFSR), "i" (ASI_DMMU));
103}
104
105/* The data cache is write through, so this just invalidates the 59/* The data cache is write through, so this just invalidates the
106 * specified line. 60 * specified line.
107 */ 61 */
@@ -193,90 +147,6 @@ static __inline__ void spitfire_put_itlb_data(int entry, unsigned long data)
193 "i" (ASI_ITLB_DATA_ACCESS)); 147 "i" (ASI_ITLB_DATA_ACCESS));
194} 148}
195 149
196/* Spitfire hardware assisted TLB flushes. */
197
198/* Context level flushes. */
199static __inline__ void spitfire_flush_dtlb_primary_context(void)
200{
201 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
202 "membar #Sync"
203 : /* No outputs */
204 : "r" (0x40), "i" (ASI_DMMU_DEMAP));
205}
206
207static __inline__ void spitfire_flush_itlb_primary_context(void)
208{
209 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
210 "membar #Sync"
211 : /* No outputs */
212 : "r" (0x40), "i" (ASI_IMMU_DEMAP));
213}
214
215static __inline__ void spitfire_flush_dtlb_secondary_context(void)
216{
217 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
218 "membar #Sync"
219 : /* No outputs */
220 : "r" (0x50), "i" (ASI_DMMU_DEMAP));
221}
222
223static __inline__ void spitfire_flush_itlb_secondary_context(void)
224{
225 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
226 "membar #Sync"
227 : /* No outputs */
228 : "r" (0x50), "i" (ASI_IMMU_DEMAP));
229}
230
231static __inline__ void spitfire_flush_dtlb_nucleus_context(void)
232{
233 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
234 "membar #Sync"
235 : /* No outputs */
236 : "r" (0x60), "i" (ASI_DMMU_DEMAP));
237}
238
239static __inline__ void spitfire_flush_itlb_nucleus_context(void)
240{
241 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
242 "membar #Sync"
243 : /* No outputs */
244 : "r" (0x60), "i" (ASI_IMMU_DEMAP));
245}
246
247/* Page level flushes. */
248static __inline__ void spitfire_flush_dtlb_primary_page(unsigned long page)
249{
250 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
251 "membar #Sync"
252 : /* No outputs */
253 : "r" (page), "i" (ASI_DMMU_DEMAP));
254}
255
256static __inline__ void spitfire_flush_itlb_primary_page(unsigned long page)
257{
258 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
259 "membar #Sync"
260 : /* No outputs */
261 : "r" (page), "i" (ASI_IMMU_DEMAP));
262}
263
264static __inline__ void spitfire_flush_dtlb_secondary_page(unsigned long page)
265{
266 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
267 "membar #Sync"
268 : /* No outputs */
269 : "r" (page | 0x10), "i" (ASI_DMMU_DEMAP));
270}
271
272static __inline__ void spitfire_flush_itlb_secondary_page(unsigned long page)
273{
274 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
275 "membar #Sync"
276 : /* No outputs */
277 : "r" (page | 0x10), "i" (ASI_IMMU_DEMAP));
278}
279
280static __inline__ void spitfire_flush_dtlb_nucleus_page(unsigned long page) 150static __inline__ void spitfire_flush_dtlb_nucleus_page(unsigned long page)
281{ 151{
282 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" 152 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
diff --git a/include/asm-sparc64/system.h b/include/asm-sparc64/system.h
index f9be2c5b4dc9..ee4bdfc6b88f 100644
--- a/include/asm-sparc64/system.h
+++ b/include/asm-sparc64/system.h
@@ -190,24 +190,23 @@ do { if (test_thread_flag(TIF_PERFCTR)) { \
190 "wrpr %%g1, %%cwp\n\t" \ 190 "wrpr %%g1, %%cwp\n\t" \
191 "ldx [%%g6 + %3], %%o6\n\t" \ 191 "ldx [%%g6 + %3], %%o6\n\t" \
192 "ldub [%%g6 + %2], %%o5\n\t" \ 192 "ldub [%%g6 + %2], %%o5\n\t" \
193 "ldx [%%g6 + %4], %%o7\n\t" \ 193 "ldub [%%g6 + %4], %%o7\n\t" \
194 "mov %%g6, %%l2\n\t" \ 194 "mov %%g6, %%l2\n\t" \
195 "wrpr %%o5, 0x0, %%wstate\n\t" \ 195 "wrpr %%o5, 0x0, %%wstate\n\t" \
196 "ldx [%%sp + 2047 + 0x70], %%i6\n\t" \ 196 "ldx [%%sp + 2047 + 0x70], %%i6\n\t" \
197 "ldx [%%sp + 2047 + 0x78], %%i7\n\t" \ 197 "ldx [%%sp + 2047 + 0x78], %%i7\n\t" \
198 "wrpr %%g0, 0x94, %%pstate\n\t" \ 198 "wrpr %%g0, 0x94, %%pstate\n\t" \
199 "mov %%l2, %%g6\n\t" \ 199 "mov %%l2, %%g6\n\t" \
200 "ldx [%%g6 + %7], %%g4\n\t" \ 200 "ldx [%%g6 + %6], %%g4\n\t" \
201 "wrpr %%g0, 0x96, %%pstate\n\t" \ 201 "wrpr %%g0, 0x96, %%pstate\n\t" \
202 "andcc %%o7, %6, %%g0\n\t" \ 202 "brz,pt %%o7, 1f\n\t" \
203 "beq,pt %%icc, 1f\n\t" \
204 " mov %%g7, %0\n\t" \ 203 " mov %%g7, %0\n\t" \
205 "b,a ret_from_syscall\n\t" \ 204 "b,a ret_from_syscall\n\t" \
206 "1:\n\t" \ 205 "1:\n\t" \
207 : "=&r" (last) \ 206 : "=&r" (last) \
208 : "0" (next->thread_info), \ 207 : "0" (next->thread_info), \
209 "i" (TI_WSTATE), "i" (TI_KSP), "i" (TI_FLAGS), "i" (TI_CWP), \ 208 "i" (TI_WSTATE), "i" (TI_KSP), "i" (TI_NEW_CHILD), \
210 "i" (_TIF_NEWCHILD), "i" (TI_TASK) \ 209 "i" (TI_CWP), "i" (TI_TASK) \
211 : "cc", \ 210 : "cc", \
212 "g1", "g2", "g3", "g7", \ 211 "g1", "g2", "g3", "g7", \
213 "l2", "l3", "l4", "l5", "l6", "l7", \ 212 "l2", "l3", "l4", "l5", "l6", "l7", \
diff --git a/include/asm-sparc64/thread_info.h b/include/asm-sparc64/thread_info.h
index a1d25c06f92a..352d9943661a 100644
--- a/include/asm-sparc64/thread_info.h
+++ b/include/asm-sparc64/thread_info.h
@@ -47,7 +47,9 @@ struct thread_info {
47 struct pt_regs *kregs; 47 struct pt_regs *kregs;
48 struct exec_domain *exec_domain; 48 struct exec_domain *exec_domain;
49 int preempt_count; /* 0 => preemptable, <0 => BUG */ 49 int preempt_count; /* 0 => preemptable, <0 => BUG */
50 int __pad; 50 __u8 new_child;
51 __u8 syscall_noerror;
52 __u16 __pad;
51 53
52 unsigned long *utraps; 54 unsigned long *utraps;
53 55
@@ -87,6 +89,8 @@ struct thread_info {
87#define TI_KREGS 0x00000028 89#define TI_KREGS 0x00000028
88#define TI_EXEC_DOMAIN 0x00000030 90#define TI_EXEC_DOMAIN 0x00000030
89#define TI_PRE_COUNT 0x00000038 91#define TI_PRE_COUNT 0x00000038
92#define TI_NEW_CHILD 0x0000003c
93#define TI_SYS_NOERROR 0x0000003d
90#define TI_UTRAPS 0x00000040 94#define TI_UTRAPS 0x00000040
91#define TI_REG_WINDOW 0x00000048 95#define TI_REG_WINDOW 0x00000048
92#define TI_RWIN_SPTRS 0x000003c8 96#define TI_RWIN_SPTRS 0x000003c8
@@ -219,10 +223,10 @@ register struct thread_info *current_thread_info_reg asm("g6");
219#define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */ 223#define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
220#define TIF_NEWSIGNALS 6 /* wants new-style signals */ 224#define TIF_NEWSIGNALS 6 /* wants new-style signals */
221#define TIF_32BIT 7 /* 32-bit binary */ 225#define TIF_32BIT 7 /* 32-bit binary */
222#define TIF_NEWCHILD 8 /* just-spawned child process */ 226/* flag bit 8 is available */
223#define TIF_SECCOMP 9 /* secure computing */ 227#define TIF_SECCOMP 9 /* secure computing */
224#define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */ 228#define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
225#define TIF_SYSCALL_SUCCESS 11 229/* flag bit 11 is available */
226/* NOTE: Thread flags >= 12 should be ones we have no interest 230/* NOTE: Thread flags >= 12 should be ones we have no interest
227 * in using in assembly, else we can't use the mask as 231 * in using in assembly, else we can't use the mask as
228 * an immediate value in instructions such as andcc. 232 * an immediate value in instructions such as andcc.
@@ -239,10 +243,8 @@ register struct thread_info *current_thread_info_reg asm("g6");
239#define _TIF_UNALIGNED (1<<TIF_UNALIGNED) 243#define _TIF_UNALIGNED (1<<TIF_UNALIGNED)
240#define _TIF_NEWSIGNALS (1<<TIF_NEWSIGNALS) 244#define _TIF_NEWSIGNALS (1<<TIF_NEWSIGNALS)
241#define _TIF_32BIT (1<<TIF_32BIT) 245#define _TIF_32BIT (1<<TIF_32BIT)
242#define _TIF_NEWCHILD (1<<TIF_NEWCHILD)
243#define _TIF_SECCOMP (1<<TIF_SECCOMP) 246#define _TIF_SECCOMP (1<<TIF_SECCOMP)
244#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 247#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
245#define _TIF_SYSCALL_SUCCESS (1<<TIF_SYSCALL_SUCCESS)
246#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 248#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
247#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 249#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
248 250
diff --git a/include/asm-sparc64/timer.h b/include/asm-sparc64/timer.h
index ba33a2b6b7bd..edc8e08c3a39 100644
--- a/include/asm-sparc64/timer.h
+++ b/include/asm-sparc64/timer.h
@@ -9,49 +9,8 @@
9 9
10#include <linux/types.h> 10#include <linux/types.h>
11 11
12/* How timers work:
13 *
14 * On uniprocessors we just use counter zero for the system wide
15 * ticker, this performs thread scheduling, clock book keeping,
16 * and runs timer based events. Previously we used the Ultra
17 * %tick interrupt for this purpose.
18 *
19 * On multiprocessors we pick one cpu as the master level 10 tick
20 * processor. Here this counter zero tick handles clock book
21 * keeping and timer events only. Each Ultra has it's level
22 * 14 %tick interrupt set to fire off as well, even the master
23 * tick cpu runs this locally. This ticker performs thread
24 * scheduling, system/user tick counting for the current thread,
25 * and also profiling if enabled.
26 */
27
28#include <linux/config.h> 12#include <linux/config.h>
29 13
30/* Two timers, traditionally steered to PIL's 10 and 14 respectively.
31 * But since INO packets are used on sun5, we could use any PIL level
32 * we like, however for now we use the normal ones.
33 *
34 * The 'reg' and 'interrupts' properties for these live in nodes named
35 * 'counter-timer'. The first of three 'reg' properties describe where
36 * the sun5_timer registers are. The other two I have no idea. (XXX)
37 */
38struct sun5_timer {
39 u64 count0;
40 u64 limit0;
41 u64 count1;
42 u64 limit1;
43};
44
45#define SUN5_LIMIT_ENABLE 0x80000000
46#define SUN5_LIMIT_TOZERO 0x40000000
47#define SUN5_LIMIT_ZRESTART 0x20000000
48#define SUN5_LIMIT_CMASK 0x1fffffff
49
50/* Given a HZ value, set the limit register to so that the timer IRQ
51 * gets delivered that often.
52 */
53#define SUN5_HZ_TO_LIMIT(__hz) (1000000/(__hz))
54
55struct sparc64_tick_ops { 14struct sparc64_tick_ops {
56 void (*init_tick)(unsigned long); 15 void (*init_tick)(unsigned long);
57 unsigned long (*get_tick)(void); 16 unsigned long (*get_tick)(void);
diff --git a/include/linux/netfilter_ipv4/ip_conntrack.h b/include/linux/netfilter_ipv4/ip_conntrack.h
index 3781192ce159..f8da7ddeff3a 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack.h
@@ -197,6 +197,9 @@ struct ip_conntrack_expect
197 /* Timer function; deletes the expectation. */ 197 /* Timer function; deletes the expectation. */
198 struct timer_list timeout; 198 struct timer_list timeout;
199 199
200 /* Usage count. */
201 atomic_t use;
202
200#ifdef CONFIG_IP_NF_NAT_NEEDED 203#ifdef CONFIG_IP_NF_NAT_NEEDED
201 /* This is the original per-proto part, used to map the 204 /* This is the original per-proto part, used to map the
202 * expected connection the way the recipient expects. */ 205 * expected connection the way the recipient expects. */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_helper.h b/include/linux/netfilter_ipv4/ip_conntrack_helper.h
index b1bbba0a12cb..3692daa93dec 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_helper.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_helper.h
@@ -30,9 +30,10 @@ extern int ip_conntrack_helper_register(struct ip_conntrack_helper *);
30extern void ip_conntrack_helper_unregister(struct ip_conntrack_helper *); 30extern void ip_conntrack_helper_unregister(struct ip_conntrack_helper *);
31 31
32/* Allocate space for an expectation: this is mandatory before calling 32/* Allocate space for an expectation: this is mandatory before calling
33 ip_conntrack_expect_related. */ 33 ip_conntrack_expect_related. You will have to call put afterwards. */
34extern struct ip_conntrack_expect *ip_conntrack_expect_alloc(void); 34extern struct ip_conntrack_expect *
35extern void ip_conntrack_expect_free(struct ip_conntrack_expect *exp); 35ip_conntrack_expect_alloc(struct ip_conntrack *master);
36extern void ip_conntrack_expect_put(struct ip_conntrack_expect *exp);
36 37
37/* Add an expected connection: can have more than one per connection */ 38/* Add an expected connection: can have more than one per connection */
38extern int ip_conntrack_expect_related(struct ip_conntrack_expect *exp); 39extern int ip_conntrack_expect_related(struct ip_conntrack_expect *exp);
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 2f0c085f2c7d..70c2a9dc4b2b 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -5,7 +5,7 @@
5#include <linux/types.h> 5#include <linux/types.h>
6 6
7#define NETLINK_ROUTE 0 /* Routing/device hook */ 7#define NETLINK_ROUTE 0 /* Routing/device hook */
8#define NETLINK_SKIP 1 /* Reserved for ENskip */ 8#define NETLINK_W1 1 /* 1-wire subsystem */
9#define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */ 9#define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */
10#define NETLINK_FIREWALL 3 /* Firewalling hook */ 10#define NETLINK_FIREWALL 3 /* Firewalling hook */
11#define NETLINK_TCPDIAG 4 /* TCP socket monitoring */ 11#define NETLINK_TCPDIAG 4 /* TCP socket monitoring */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 27348c22dacb..9a28b312eeb4 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1872,6 +1872,7 @@
1872#define PCI_DEVICE_ID_CBOARDS_DAS1602_16 0x0001 1872#define PCI_DEVICE_ID_CBOARDS_DAS1602_16 0x0001
1873 1873
1874#define PCI_VENDOR_ID_SIIG 0x131f 1874#define PCI_VENDOR_ID_SIIG 0x131f
1875#define PCI_SUBVENDOR_ID_SIIG 0x131f
1875#define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000 1876#define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000
1876#define PCI_DEVICE_ID_SIIG_1S_10x_650 0x1001 1877#define PCI_DEVICE_ID_SIIG_1S_10x_650 0x1001
1877#define PCI_DEVICE_ID_SIIG_1S_10x_850 0x1002 1878#define PCI_DEVICE_ID_SIIG_1S_10x_850 0x1002
@@ -1909,6 +1910,7 @@
1909#define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060 1910#define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060
1910#define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061 1911#define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061
1911#define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062 1912#define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062
1913#define PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL 0x2050
1912 1914
1913#define PCI_VENDOR_ID_RADISYS 0x1331 1915#define PCI_VENDOR_ID_RADISYS 0x1331
1914#define PCI_DEVICE_ID_RADISYS_ENP2611 0x0030 1916#define PCI_DEVICE_ID_RADISYS_ENP2611 0x0030
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 5d4a990d5577..0061c9470482 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -502,7 +502,8 @@ static inline struct sk_buff *skb_share_check(struct sk_buff *skb,
502 * 502 *
503 * %NULL is returned on a memory allocation failure. 503 * %NULL is returned on a memory allocation failure.
504 */ 504 */
505static inline struct sk_buff *skb_unshare(struct sk_buff *skb, int pri) 505static inline struct sk_buff *skb_unshare(struct sk_buff *skb,
506 unsigned int __nocast pri)
506{ 507{
507 might_sleep_if(pri & __GFP_WAIT); 508 might_sleep_if(pri & __GFP_WAIT);
508 if (skb_cloned(skb)) { 509 if (skb_cloned(skb)) {
diff --git a/include/linux/tc_ematch/tc_em_meta.h b/include/linux/tc_ematch/tc_em_meta.h
index bcb762d93123..081b1ee8516e 100644
--- a/include/linux/tc_ematch/tc_em_meta.h
+++ b/include/linux/tc_ematch/tc_em_meta.h
@@ -41,19 +41,14 @@ enum
41 TCF_META_ID_LOADAVG_1, 41 TCF_META_ID_LOADAVG_1,
42 TCF_META_ID_LOADAVG_2, 42 TCF_META_ID_LOADAVG_2,
43 TCF_META_ID_DEV, 43 TCF_META_ID_DEV,
44 TCF_META_ID_INDEV,
45 TCF_META_ID_REALDEV,
46 TCF_META_ID_PRIORITY, 44 TCF_META_ID_PRIORITY,
47 TCF_META_ID_PROTOCOL, 45 TCF_META_ID_PROTOCOL,
48 TCF_META_ID_SECURITY, /* obsolete */
49 TCF_META_ID_PKTTYPE, 46 TCF_META_ID_PKTTYPE,
50 TCF_META_ID_PKTLEN, 47 TCF_META_ID_PKTLEN,
51 TCF_META_ID_DATALEN, 48 TCF_META_ID_DATALEN,
52 TCF_META_ID_MACLEN, 49 TCF_META_ID_MACLEN,
53 TCF_META_ID_NFMARK, 50 TCF_META_ID_NFMARK,
54 TCF_META_ID_TCINDEX, 51 TCF_META_ID_TCINDEX,
55 TCF_META_ID_TCVERDICT,
56 TCF_META_ID_TCCLASSID,
57 TCF_META_ID_RTCLASSID, 52 TCF_META_ID_RTCLASSID,
58 TCF_META_ID_RTIIF, 53 TCF_META_ID_RTIIF,
59 TCF_META_ID_SK_FAMILY, 54 TCF_META_ID_SK_FAMILY,
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 4a26adfaed71..e1d5ec1c23c0 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -167,15 +167,12 @@ void sctp_unhash_established(struct sctp_association *);
167void sctp_hash_endpoint(struct sctp_endpoint *); 167void sctp_hash_endpoint(struct sctp_endpoint *);
168void sctp_unhash_endpoint(struct sctp_endpoint *); 168void sctp_unhash_endpoint(struct sctp_endpoint *);
169struct sock *sctp_err_lookup(int family, struct sk_buff *, 169struct sock *sctp_err_lookup(int family, struct sk_buff *,
170 struct sctphdr *, struct sctp_endpoint **, 170 struct sctphdr *, struct sctp_association **,
171 struct sctp_association **,
172 struct sctp_transport **); 171 struct sctp_transport **);
173void sctp_err_finish(struct sock *, struct sctp_endpoint *, 172void sctp_err_finish(struct sock *, struct sctp_association *);
174 struct sctp_association *);
175void sctp_icmp_frag_needed(struct sock *, struct sctp_association *, 173void sctp_icmp_frag_needed(struct sock *, struct sctp_association *,
176 struct sctp_transport *t, __u32 pmtu); 174 struct sctp_transport *t, __u32 pmtu);
177void sctp_icmp_proto_unreachable(struct sock *sk, 175void sctp_icmp_proto_unreachable(struct sock *sk,
178 struct sctp_endpoint *ep,
179 struct sctp_association *asoc, 176 struct sctp_association *asoc,
180 struct sctp_transport *t); 177 struct sctp_transport *t);
181 178
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 029522a4ceda..868ef88ef971 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -803,7 +803,7 @@ struct xfrm_algo_desc {
803/* XFRM tunnel handlers. */ 803/* XFRM tunnel handlers. */
804struct xfrm_tunnel { 804struct xfrm_tunnel {
805 int (*handler)(struct sk_buff *skb); 805 int (*handler)(struct sk_buff *skb);
806 void (*err_handler)(struct sk_buff *skb, void *info); 806 void (*err_handler)(struct sk_buff *skb, __u32 info);
807}; 807};
808 808
809struct xfrm6_tunnel { 809struct xfrm6_tunnel {
diff --git a/net/Kconfig b/net/Kconfig
index 2684e809a649..40a31ba86d2c 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -209,22 +209,6 @@ endmenu
209 209
210endmenu 210endmenu
211 211
212config NETPOLL
213 def_bool NETCONSOLE
214
215config NETPOLL_RX
216 bool "Netpoll support for trapping incoming packets"
217 default n
218 depends on NETPOLL
219
220config NETPOLL_TRAP
221 bool "Netpoll traffic trapping"
222 default n
223 depends on NETPOLL
224
225config NET_POLL_CONTROLLER
226 def_bool NETPOLL
227
228source "net/ax25/Kconfig" 212source "net/ax25/Kconfig"
229source "net/irda/Kconfig" 213source "net/irda/Kconfig"
230source "net/bluetooth/Kconfig" 214source "net/bluetooth/Kconfig"
diff --git a/net/atm/Kconfig b/net/atm/Kconfig
index bea2426229b1..21ff276b2d80 100644
--- a/net/atm/Kconfig
+++ b/net/atm/Kconfig
@@ -60,7 +60,7 @@ config ATM_BR2684
60 tristate "RFC1483/2684 Bridged protocols" 60 tristate "RFC1483/2684 Bridged protocols"
61 depends on ATM && INET 61 depends on ATM && INET
62 help 62 help
63 ATM PVCs can carry ethernet PDUs according to rfc2684 (formerly 1483) 63 ATM PVCs can carry ethernet PDUs according to RFC2684 (formerly 1483)
64 This device will act like an ethernet from the kernels point of view, 64 This device will act like an ethernet from the kernels point of view,
65 with the traffic being carried by ATM PVCs (currently 1 PVC/device). 65 with the traffic being carried by ATM PVCs (currently 1 PVC/device).
66 This is sometimes used over DSL lines. If in doubt, say N. 66 This is sometimes used over DSL lines. If in doubt, say N.
@@ -69,6 +69,6 @@ config ATM_BR2684_IPFILTER
69 bool "Per-VC IP filter kludge" 69 bool "Per-VC IP filter kludge"
70 depends on ATM_BR2684 70 depends on ATM_BR2684
71 help 71 help
72 This is an experimental mechanism for users who need to terminating a 72 This is an experimental mechanism for users who need to terminate a
73 large number of IP-only vcc's. Do not enable this unless you are sure 73 large number of IP-only vcc's. Do not enable this unless you are sure
74 you know what you are doing. 74 you know what you are doing.
diff --git a/net/atm/svc.c b/net/atm/svc.c
index 02f5374a51f2..08e46052a3e4 100644
--- a/net/atm/svc.c
+++ b/net/atm/svc.c
@@ -118,10 +118,6 @@ static int svc_bind(struct socket *sock,struct sockaddr *sockaddr,
118 goto out; 118 goto out;
119 } 119 }
120 vcc = ATM_SD(sock); 120 vcc = ATM_SD(sock);
121 if (test_bit(ATM_VF_SESSION, &vcc->flags)) {
122 error = -EINVAL;
123 goto out;
124 }
125 addr = (struct sockaddr_atmsvc *) sockaddr; 121 addr = (struct sockaddr_atmsvc *) sockaddr;
126 if (addr->sas_family != AF_ATMSVC) { 122 if (addr->sas_family != AF_ATMSVC) {
127 error = -EAFNOSUPPORT; 123 error = -EAFNOSUPPORT;
diff --git a/net/bridge/netfilter/Kconfig b/net/bridge/netfilter/Kconfig
index 68ccef507b49..c70b3be23026 100644
--- a/net/bridge/netfilter/Kconfig
+++ b/net/bridge/netfilter/Kconfig
@@ -138,7 +138,7 @@ config BRIDGE_EBT_VLAN
138# 138#
139config BRIDGE_EBT_ARPREPLY 139config BRIDGE_EBT_ARPREPLY
140 tristate "ebt: arp reply target support" 140 tristate "ebt: arp reply target support"
141 depends on BRIDGE_NF_EBTABLES 141 depends on BRIDGE_NF_EBTABLES && INET
142 help 142 help
143 This option adds the arp reply target, which allows 143 This option adds the arp reply target, which allows
144 automatically sending arp replies to arp requests. 144 automatically sending arp replies to arp requests.
diff --git a/net/core/Makefile b/net/core/Makefile
index 5e0c56b7f607..f5f5e58943e8 100644
--- a/net/core/Makefile
+++ b/net/core/Makefile
@@ -7,9 +7,10 @@ obj-y := sock.o request_sock.o skbuff.o iovec.o datagram.o stream.o scm.o \
7 7
8obj-$(CONFIG_SYSCTL) += sysctl_net_core.o 8obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
9 9
10obj-y += flow.o dev.o ethtool.o dev_mcast.o dst.o \ 10obj-y += dev.o ethtool.o dev_mcast.o dst.o \
11 neighbour.o rtnetlink.o utils.o link_watch.o filter.o 11 neighbour.o rtnetlink.o utils.o link_watch.o filter.o
12 12
13obj-$(CONFIG_XFRM) += flow.o
13obj-$(CONFIG_SYSFS) += net-sysfs.o 14obj-$(CONFIG_SYSFS) += net-sysfs.o
14obj-$(CONFIG_NETFILTER) += netfilter.o 15obj-$(CONFIG_NETFILTER) += netfilter.o
15obj-$(CONFIG_NET_DIVERT) += dv.o 16obj-$(CONFIG_NET_DIVERT) += dv.o
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index d9f7b06fe886..7eab867ede59 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -377,8 +377,8 @@ struct sk_buff *skb_clone(struct sk_buff *skb, unsigned int __nocast gfp_mask)
377 C(tc_index); 377 C(tc_index);
378#ifdef CONFIG_NET_CLS_ACT 378#ifdef CONFIG_NET_CLS_ACT
379 n->tc_verd = SET_TC_VERD(skb->tc_verd,0); 379 n->tc_verd = SET_TC_VERD(skb->tc_verd,0);
380 n->tc_verd = CLR_TC_OK2MUNGE(skb->tc_verd); 380 n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd);
381 n->tc_verd = CLR_TC_MUNGED(skb->tc_verd); 381 n->tc_verd = CLR_TC_MUNGED(n->tc_verd);
382 C(input_dev); 382 C(input_dev);
383 C(tc_classid); 383 C(tc_classid);
384#endif 384#endif
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index df5386885a90..fc561c0ae8e2 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -54,9 +54,9 @@ config IP_ADVANCED_ROUTER
54choice 54choice
55 prompt "Choose IP: FIB lookup algorithm (choose FIB_HASH if unsure)" 55 prompt "Choose IP: FIB lookup algorithm (choose FIB_HASH if unsure)"
56 depends on IP_ADVANCED_ROUTER 56 depends on IP_ADVANCED_ROUTER
57 default IP_FIB_HASH 57 default ASK_IP_FIB_HASH
58 58
59config IP_FIB_HASH 59config ASK_IP_FIB_HASH
60 bool "FIB_HASH" 60 bool "FIB_HASH"
61 ---help--- 61 ---help---
62 Current FIB is very proven and good enough for most users. 62 Current FIB is very proven and good enough for most users.
@@ -82,12 +82,8 @@ config IP_FIB_TRIE
82 82
83endchoice 83endchoice
84 84
85# If the user does not enable advanced routing, he gets the safe
86# default of the fib-hash algorithm.
87config IP_FIB_HASH 85config IP_FIB_HASH
88 bool 86 def_bool ASK_IP_FIB_HASH || !IP_ADVANCED_ROUTER
89 depends on !IP_ADVANCED_ROUTER
90 default y
91 87
92config IP_MULTIPLE_TABLES 88config IP_MULTIPLE_TABLES
93 bool "IP: policy routing" 89 bool "IP: policy routing"
@@ -239,7 +235,6 @@ config IP_PNP_RARP
239# bool ' IP: ARP support' CONFIG_IP_PNP_ARP 235# bool ' IP: ARP support' CONFIG_IP_PNP_ARP
240config NET_IPIP 236config NET_IPIP
241 tristate "IP: tunneling" 237 tristate "IP: tunneling"
242 select INET_TUNNEL
243 ---help--- 238 ---help---
244 Tunneling means encapsulating data of one protocol type within 239 Tunneling means encapsulating data of one protocol type within
245 another protocol and sending it over a channel that understands the 240 another protocol and sending it over a channel that understands the
@@ -256,7 +251,6 @@ config NET_IPIP
256 251
257config NET_IPGRE 252config NET_IPGRE
258 tristate "IP: GRE tunnels over IP" 253 tristate "IP: GRE tunnels over IP"
259 select XFRM
260 help 254 help
261 Tunneling means encapsulating data of one protocol type within 255 Tunneling means encapsulating data of one protocol type within
262 another protocol and sending it over a channel that understands the 256 another protocol and sending it over a channel that understands the
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index ef7468376ae6..163ae4068b5f 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1157,7 +1157,7 @@ static int __init ipv4_proc_init(void)
1157#ifdef CONFIG_IP_FIB_TRIE 1157#ifdef CONFIG_IP_FIB_TRIE
1158 if (fib_stat_proc_init()) 1158 if (fib_stat_proc_init())
1159 goto out_fib_stat; 1159 goto out_fib_stat;
1160 #endif 1160#endif
1161 if (ip_misc_proc_init()) 1161 if (ip_misc_proc_init())
1162 goto out_misc; 1162 goto out_misc;
1163out: 1163out:
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 4be234c7d8c3..a701405fab0b 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -90,14 +90,14 @@ typedef unsigned int t_key;
90#define T_LEAF 1 90#define T_LEAF 1
91#define NODE_TYPE_MASK 0x1UL 91#define NODE_TYPE_MASK 0x1UL
92#define NODE_PARENT(_node) \ 92#define NODE_PARENT(_node) \
93((struct tnode *)((_node)->_parent & ~NODE_TYPE_MASK)) 93 ((struct tnode *)((_node)->_parent & ~NODE_TYPE_MASK))
94#define NODE_SET_PARENT(_node, _ptr) \ 94#define NODE_SET_PARENT(_node, _ptr) \
95((_node)->_parent = (((unsigned long)(_ptr)) | \ 95 ((_node)->_parent = (((unsigned long)(_ptr)) | \
96 ((_node)->_parent & NODE_TYPE_MASK))) 96 ((_node)->_parent & NODE_TYPE_MASK)))
97#define NODE_INIT_PARENT(_node, _type) \ 97#define NODE_INIT_PARENT(_node, _type) \
98((_node)->_parent = (_type)) 98 ((_node)->_parent = (_type))
99#define NODE_TYPE(_node) \ 99#define NODE_TYPE(_node) \
100((_node)->_parent & NODE_TYPE_MASK) 100 ((_node)->_parent & NODE_TYPE_MASK)
101 101
102#define IS_TNODE(n) (!(n->_parent & T_LEAF)) 102#define IS_TNODE(n) (!(n->_parent & T_LEAF))
103#define IS_LEAF(n) (n->_parent & T_LEAF) 103#define IS_LEAF(n) (n->_parent & T_LEAF)
@@ -147,7 +147,7 @@ struct trie_stat {
147 unsigned int leaves; 147 unsigned int leaves;
148 unsigned int nullpointers; 148 unsigned int nullpointers;
149 unsigned int nodesizes[MAX_CHILDS]; 149 unsigned int nodesizes[MAX_CHILDS];
150}; 150};
151 151
152struct trie { 152struct trie {
153 struct node *trie; 153 struct node *trie;
@@ -185,9 +185,9 @@ static void trie_bug(char *err)
185 BUG(); 185 BUG();
186} 186}
187 187
188static inline struct node *tnode_get_child(struct tnode *tn, int i) 188static inline struct node *tnode_get_child(struct tnode *tn, int i)
189{ 189{
190 if (i >= 1<<tn->bits) 190 if (i >= 1<<tn->bits)
191 trie_bug("tnode_get_child"); 191 trie_bug("tnode_get_child");
192 192
193 return tn->child[i]; 193 return tn->child[i];
@@ -202,7 +202,7 @@ static inline int tnode_child_length(struct tnode *tn)
202 _________________________________________________________________ 202 _________________________________________________________________
203 | i | i | i | i | i | i | i | N | N | N | S | S | S | S | S | C | 203 | i | i | i | i | i | i | i | N | N | N | S | S | S | S | S | C |
204 ---------------------------------------------------------------- 204 ----------------------------------------------------------------
205 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 205 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
206 206
207 _________________________________________________________________ 207 _________________________________________________________________
208 | C | C | C | u | u | u | u | u | u | u | u | u | u | u | u | u | 208 | C | C | C | u | u | u | u | u | u | u | u | u | u | u | u | u |
@@ -226,25 +226,25 @@ static inline t_key tkey_extract_bits(t_key a, int offset, int bits)
226 226
227static inline int tkey_equals(t_key a, t_key b) 227static inline int tkey_equals(t_key a, t_key b)
228{ 228{
229 return a == b; 229 return a == b;
230} 230}
231 231
232static inline int tkey_sub_equals(t_key a, int offset, int bits, t_key b) 232static inline int tkey_sub_equals(t_key a, int offset, int bits, t_key b)
233{ 233{
234 if (bits == 0 || offset >= KEYLENGTH) 234 if (bits == 0 || offset >= KEYLENGTH)
235 return 1; 235 return 1;
236 bits = bits > KEYLENGTH ? KEYLENGTH : bits; 236 bits = bits > KEYLENGTH ? KEYLENGTH : bits;
237 return ((a ^ b) << offset) >> (KEYLENGTH - bits) == 0; 237 return ((a ^ b) << offset) >> (KEYLENGTH - bits) == 0;
238} 238}
239 239
240static inline int tkey_mismatch(t_key a, int offset, t_key b) 240static inline int tkey_mismatch(t_key a, int offset, t_key b)
241{ 241{
242 t_key diff = a ^ b; 242 t_key diff = a ^ b;
243 int i = offset; 243 int i = offset;
244 244
245 if(!diff) 245 if (!diff)
246 return 0; 246 return 0;
247 while((diff << i) >> (KEYLENGTH-1) == 0) 247 while ((diff << i) >> (KEYLENGTH-1) == 0)
248 i++; 248 i++;
249 return i; 249 return i;
250} 250}
@@ -314,6 +314,7 @@ static void fn_free_alias(struct fib_alias *fa)
314 The bits from (n->pos) to (n->pos + n->bits - 1) - "C" - are the index into 314 The bits from (n->pos) to (n->pos + n->bits - 1) - "C" - are the index into
315 n's child array, and will of course be different for each child. 315 n's child array, and will of course be different for each child.
316 316
317
317 The rest of the bits, from (n->pos + n->bits) onward, are completely unknown 318 The rest of the bits, from (n->pos + n->bits) onward, are completely unknown
318 at this point. 319 at this point.
319 320
@@ -321,7 +322,7 @@ static void fn_free_alias(struct fib_alias *fa)
321 322
322static void check_tnode(struct tnode *tn) 323static void check_tnode(struct tnode *tn)
323{ 324{
324 if(tn && tn->pos+tn->bits > 32) { 325 if (tn && tn->pos+tn->bits > 32) {
325 printk("TNODE ERROR tn=%p, pos=%d, bits=%d\n", tn, tn->pos, tn->bits); 326 printk("TNODE ERROR tn=%p, pos=%d, bits=%d\n", tn, tn->pos, tn->bits);
326 } 327 }
327} 328}
@@ -332,7 +333,7 @@ static int inflate_threshold = 50;
332static struct leaf *leaf_new(void) 333static struct leaf *leaf_new(void)
333{ 334{
334 struct leaf *l = kmalloc(sizeof(struct leaf), GFP_KERNEL); 335 struct leaf *l = kmalloc(sizeof(struct leaf), GFP_KERNEL);
335 if(l) { 336 if (l) {
336 NODE_INIT_PARENT(l, T_LEAF); 337 NODE_INIT_PARENT(l, T_LEAF);
337 INIT_HLIST_HEAD(&l->list); 338 INIT_HLIST_HEAD(&l->list);
338 } 339 }
@@ -342,7 +343,7 @@ static struct leaf *leaf_new(void)
342static struct leaf_info *leaf_info_new(int plen) 343static struct leaf_info *leaf_info_new(int plen)
343{ 344{
344 struct leaf_info *li = kmalloc(sizeof(struct leaf_info), GFP_KERNEL); 345 struct leaf_info *li = kmalloc(sizeof(struct leaf_info), GFP_KERNEL);
345 if(li) { 346 if (li) {
346 li->plen = plen; 347 li->plen = plen;
347 INIT_LIST_HEAD(&li->falh); 348 INIT_LIST_HEAD(&li->falh);
348 } 349 }
@@ -365,7 +366,7 @@ static struct tnode *tnode_alloc(unsigned int size)
365 return kmalloc(size, GFP_KERNEL); 366 return kmalloc(size, GFP_KERNEL);
366 } else { 367 } else {
367 return (struct tnode *) 368 return (struct tnode *)
368 __get_free_pages(GFP_KERNEL, get_order(size)); 369 __get_free_pages(GFP_KERNEL, get_order(size));
369 } 370 }
370} 371}
371 372
@@ -386,7 +387,7 @@ static struct tnode* tnode_new(t_key key, int pos, int bits)
386 int sz = sizeof(struct tnode) + nchildren * sizeof(struct node *); 387 int sz = sizeof(struct tnode) + nchildren * sizeof(struct node *);
387 struct tnode *tn = tnode_alloc(sz); 388 struct tnode *tn = tnode_alloc(sz);
388 389
389 if(tn) { 390 if (tn) {
390 memset(tn, 0, sz); 391 memset(tn, 0, sz);
391 NODE_INIT_PARENT(tn, T_TNODE); 392 NODE_INIT_PARENT(tn, T_TNODE);
392 tn->pos = pos; 393 tn->pos = pos;
@@ -395,7 +396,8 @@ static struct tnode* tnode_new(t_key key, int pos, int bits)
395 tn->full_children = 0; 396 tn->full_children = 0;
396 tn->empty_children = 1<<bits; 397 tn->empty_children = 1<<bits;
397 } 398 }
398 if(trie_debug > 0) 399
400 if (trie_debug > 0)
399 printk("AT %p s=%u %u\n", tn, (unsigned int) sizeof(struct tnode), 401 printk("AT %p s=%u %u\n", tn, (unsigned int) sizeof(struct tnode),
400 (unsigned int) (sizeof(struct node) * 1<<bits)); 402 (unsigned int) (sizeof(struct node) * 1<<bits));
401 return tn; 403 return tn;
@@ -403,17 +405,17 @@ static struct tnode* tnode_new(t_key key, int pos, int bits)
403 405
404static void tnode_free(struct tnode *tn) 406static void tnode_free(struct tnode *tn)
405{ 407{
406 if(!tn) { 408 if (!tn) {
407 trie_bug("tnode_free\n"); 409 trie_bug("tnode_free\n");
408 } 410 }
409 if(IS_LEAF(tn)) { 411 if (IS_LEAF(tn)) {
410 free_leaf((struct leaf *)tn); 412 free_leaf((struct leaf *)tn);
411 if(trie_debug > 0 ) 413 if (trie_debug > 0 )
412 printk("FL %p \n", tn); 414 printk("FL %p \n", tn);
413 } 415 }
414 else if(IS_TNODE(tn)) { 416 else if (IS_TNODE(tn)) {
415 __tnode_free(tn); 417 __tnode_free(tn);
416 if(trie_debug > 0 ) 418 if (trie_debug > 0 )
417 printk("FT %p \n", tn); 419 printk("FT %p \n", tn);
418 } 420 }
419 else { 421 else {
@@ -428,58 +430,58 @@ static void tnode_free(struct tnode *tn)
428 430
429static inline int tnode_full(struct tnode *tn, struct node *n) 431static inline int tnode_full(struct tnode *tn, struct node *n)
430{ 432{
431 if(n == NULL || IS_LEAF(n)) 433 if (n == NULL || IS_LEAF(n))
432 return 0; 434 return 0;
433 435
434 return ((struct tnode *) n)->pos == tn->pos + tn->bits; 436 return ((struct tnode *) n)->pos == tn->pos + tn->bits;
435} 437}
436 438
437static inline void put_child(struct trie *t, struct tnode *tn, int i, struct node *n) 439static inline void put_child(struct trie *t, struct tnode *tn, int i, struct node *n)
438{ 440{
439 tnode_put_child_reorg(tn, i, n, -1); 441 tnode_put_child_reorg(tn, i, n, -1);
440} 442}
441 443
442 /* 444 /*
443 * Add a child at position i overwriting the old value. 445 * Add a child at position i overwriting the old value.
444 * Update the value of full_children and empty_children. 446 * Update the value of full_children and empty_children.
445 */ 447 */
446 448
447static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int wasfull) 449static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int wasfull)
448{ 450{
449 struct node *chi; 451 struct node *chi;
450 int isfull; 452 int isfull;
451 453
452 if(i >= 1<<tn->bits) { 454 if (i >= 1<<tn->bits) {
453 printk("bits=%d, i=%d\n", tn->bits, i); 455 printk("bits=%d, i=%d\n", tn->bits, i);
454 trie_bug("tnode_put_child_reorg bits"); 456 trie_bug("tnode_put_child_reorg bits");
455 } 457 }
456 write_lock_bh(&fib_lock); 458 write_lock_bh(&fib_lock);
457 chi = tn->child[i]; 459 chi = tn->child[i];
458 460
459 /* update emptyChildren */ 461 /* update emptyChildren */
460 if (n == NULL && chi != NULL) 462 if (n == NULL && chi != NULL)
461 tn->empty_children++; 463 tn->empty_children++;
462 else if (n != NULL && chi == NULL) 464 else if (n != NULL && chi == NULL)
463 tn->empty_children--; 465 tn->empty_children--;
464 466
465 /* update fullChildren */ 467 /* update fullChildren */
466 if (wasfull == -1) 468 if (wasfull == -1)
467 wasfull = tnode_full(tn, chi); 469 wasfull = tnode_full(tn, chi);
468 470
469 isfull = tnode_full(tn, n); 471 isfull = tnode_full(tn, n);
470 if (wasfull && !isfull) 472 if (wasfull && !isfull)
471 tn->full_children--; 473 tn->full_children--;
472 474
473 else if (!wasfull && isfull) 475 else if (!wasfull && isfull)
474 tn->full_children++; 476 tn->full_children++;
475 if(n) 477 if (n)
476 NODE_SET_PARENT(n, tn); 478 NODE_SET_PARENT(n, tn);
477 479
478 tn->child[i] = n; 480 tn->child[i] = n;
479 write_unlock_bh(&fib_lock); 481 write_unlock_bh(&fib_lock);
480} 482}
481 483
482static struct node *resize(struct trie *t, struct tnode *tn) 484static struct node *resize(struct trie *t, struct tnode *tn)
483{ 485{
484 int i; 486 int i;
485 int err = 0; 487 int err = 0;
@@ -487,8 +489,8 @@ static struct node *resize(struct trie *t, struct tnode *tn)
487 if (!tn) 489 if (!tn)
488 return NULL; 490 return NULL;
489 491
490 if(trie_debug) 492 if (trie_debug)
491 printk("In tnode_resize %p inflate_threshold=%d threshold=%d\n", 493 printk("In tnode_resize %p inflate_threshold=%d threshold=%d\n",
492 tn, inflate_threshold, halve_threshold); 494 tn, inflate_threshold, halve_threshold);
493 495
494 /* No children */ 496 /* No children */
@@ -505,7 +507,7 @@ static struct node *resize(struct trie *t, struct tnode *tn)
505 507
506 /* compress one level */ 508 /* compress one level */
507 struct node *n = tn->child[i]; 509 struct node *n = tn->child[i];
508 if(n) 510 if (n)
509 NODE_INIT_PARENT(n, NODE_TYPE(n)); 511 NODE_INIT_PARENT(n, NODE_TYPE(n));
510 512
511 write_unlock_bh(&fib_lock); 513 write_unlock_bh(&fib_lock);
@@ -514,72 +516,72 @@ static struct node *resize(struct trie *t, struct tnode *tn)
514 } 516 }
515 write_unlock_bh(&fib_lock); 517 write_unlock_bh(&fib_lock);
516 } 518 }
517 /* 519 /*
518 * Double as long as the resulting node has a number of 520 * Double as long as the resulting node has a number of
519 * nonempty nodes that are above the threshold. 521 * nonempty nodes that are above the threshold.
520 */ 522 */
521 523
522 /* 524 /*
523 * From "Implementing a dynamic compressed trie" by Stefan Nilsson of 525 * From "Implementing a dynamic compressed trie" by Stefan Nilsson of
524 * the Helsinki University of Technology and Matti Tikkanen of Nokia 526 * the Helsinki University of Technology and Matti Tikkanen of Nokia
525 * Telecommunications, page 6: 527 * Telecommunications, page 6:
526 * "A node is doubled if the ratio of non-empty children to all 528 * "A node is doubled if the ratio of non-empty children to all
527 * children in the *doubled* node is at least 'high'." 529 * children in the *doubled* node is at least 'high'."
528 * 530 *
529 * 'high' in this instance is the variable 'inflate_threshold'. It 531 * 'high' in this instance is the variable 'inflate_threshold'. It
530 * is expressed as a percentage, so we multiply it with 532 * is expressed as a percentage, so we multiply it with
531 * tnode_child_length() and instead of multiplying by 2 (since the 533 * tnode_child_length() and instead of multiplying by 2 (since the
532 * child array will be doubled by inflate()) and multiplying 534 * child array will be doubled by inflate()) and multiplying
533 * the left-hand side by 100 (to handle the percentage thing) we 535 * the left-hand side by 100 (to handle the percentage thing) we
534 * multiply the left-hand side by 50. 536 * multiply the left-hand side by 50.
535 * 537 *
536 * The left-hand side may look a bit weird: tnode_child_length(tn) 538 * The left-hand side may look a bit weird: tnode_child_length(tn)
537 * - tn->empty_children is of course the number of non-null children 539 * - tn->empty_children is of course the number of non-null children
538 * in the current node. tn->full_children is the number of "full" 540 * in the current node. tn->full_children is the number of "full"
539 * children, that is non-null tnodes with a skip value of 0. 541 * children, that is non-null tnodes with a skip value of 0.
540 * All of those will be doubled in the resulting inflated tnode, so 542 * All of those will be doubled in the resulting inflated tnode, so
541 * we just count them one extra time here. 543 * we just count them one extra time here.
542 * 544 *
543 * A clearer way to write this would be: 545 * A clearer way to write this would be:
544 * 546 *
545 * to_be_doubled = tn->full_children; 547 * to_be_doubled = tn->full_children;
546 * not_to_be_doubled = tnode_child_length(tn) - tn->empty_children - 548 * not_to_be_doubled = tnode_child_length(tn) - tn->empty_children -
547 * tn->full_children; 549 * tn->full_children;
548 * 550 *
549 * new_child_length = tnode_child_length(tn) * 2; 551 * new_child_length = tnode_child_length(tn) * 2;
550 * 552 *
551 * new_fill_factor = 100 * (not_to_be_doubled + 2*to_be_doubled) / 553 * new_fill_factor = 100 * (not_to_be_doubled + 2*to_be_doubled) /
552 * new_child_length; 554 * new_child_length;
553 * if (new_fill_factor >= inflate_threshold) 555 * if (new_fill_factor >= inflate_threshold)
554 * 556 *
555 * ...and so on, tho it would mess up the while() loop. 557 * ...and so on, tho it would mess up the while () loop.
556 * 558 *
557 * anyway, 559 * anyway,
558 * 100 * (not_to_be_doubled + 2*to_be_doubled) / new_child_length >= 560 * 100 * (not_to_be_doubled + 2*to_be_doubled) / new_child_length >=
559 * inflate_threshold 561 * inflate_threshold
560 * 562 *
561 * avoid a division: 563 * avoid a division:
562 * 100 * (not_to_be_doubled + 2*to_be_doubled) >= 564 * 100 * (not_to_be_doubled + 2*to_be_doubled) >=
563 * inflate_threshold * new_child_length 565 * inflate_threshold * new_child_length
564 * 566 *
565 * expand not_to_be_doubled and to_be_doubled, and shorten: 567 * expand not_to_be_doubled and to_be_doubled, and shorten:
566 * 100 * (tnode_child_length(tn) - tn->empty_children + 568 * 100 * (tnode_child_length(tn) - tn->empty_children +
567 * tn->full_children ) >= inflate_threshold * new_child_length 569 * tn->full_children ) >= inflate_threshold * new_child_length
568 * 570 *
569 * expand new_child_length: 571 * expand new_child_length:
570 * 100 * (tnode_child_length(tn) - tn->empty_children + 572 * 100 * (tnode_child_length(tn) - tn->empty_children +
571 * tn->full_children ) >= 573 * tn->full_children ) >=
572 * inflate_threshold * tnode_child_length(tn) * 2 574 * inflate_threshold * tnode_child_length(tn) * 2
573 * 575 *
574 * shorten again: 576 * shorten again:
575 * 50 * (tn->full_children + tnode_child_length(tn) - 577 * 50 * (tn->full_children + tnode_child_length(tn) -
576 * tn->empty_children ) >= inflate_threshold * 578 * tn->empty_children ) >= inflate_threshold *
577 * tnode_child_length(tn) 579 * tnode_child_length(tn)
578 * 580 *
579 */ 581 */
580 582
581 check_tnode(tn); 583 check_tnode(tn);
582 584
583 err = 0; 585 err = 0;
584 while ((tn->full_children > 0 && 586 while ((tn->full_children > 0 &&
585 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >= 587 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >=
@@ -587,7 +589,7 @@ static struct node *resize(struct trie *t, struct tnode *tn)
587 589
588 tn = inflate(t, tn, &err); 590 tn = inflate(t, tn, &err);
589 591
590 if(err) { 592 if (err) {
591#ifdef CONFIG_IP_FIB_TRIE_STATS 593#ifdef CONFIG_IP_FIB_TRIE_STATS
592 t->stats.resize_node_skipped++; 594 t->stats.resize_node_skipped++;
593#endif 595#endif
@@ -609,7 +611,7 @@ static struct node *resize(struct trie *t, struct tnode *tn)
609 611
610 tn = halve(t, tn, &err); 612 tn = halve(t, tn, &err);
611 613
612 if(err) { 614 if (err) {
613#ifdef CONFIG_IP_FIB_TRIE_STATS 615#ifdef CONFIG_IP_FIB_TRIE_STATS
614 t->stats.resize_node_skipped++; 616 t->stats.resize_node_skipped++;
615#endif 617#endif
@@ -617,18 +619,18 @@ static struct node *resize(struct trie *t, struct tnode *tn)
617 } 619 }
618 } 620 }
619 621
620 622
621 /* Only one child remains */ 623 /* Only one child remains */
622 624
623 if (tn->empty_children == tnode_child_length(tn) - 1) 625 if (tn->empty_children == tnode_child_length(tn) - 1)
624 for (i = 0; i < tnode_child_length(tn); i++) { 626 for (i = 0; i < tnode_child_length(tn); i++) {
625 627
626 write_lock_bh(&fib_lock); 628 write_lock_bh(&fib_lock);
627 if (tn->child[i] != NULL) { 629 if (tn->child[i] != NULL) {
628 /* compress one level */ 630 /* compress one level */
629 struct node *n = tn->child[i]; 631 struct node *n = tn->child[i];
630 632
631 if(n) 633 if (n)
632 NODE_INIT_PARENT(n, NODE_TYPE(n)); 634 NODE_INIT_PARENT(n, NODE_TYPE(n));
633 635
634 write_unlock_bh(&fib_lock); 636 write_unlock_bh(&fib_lock);
@@ -648,7 +650,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
648 int olen = tnode_child_length(tn); 650 int olen = tnode_child_length(tn);
649 int i; 651 int i;
650 652
651 if(trie_debug) 653 if (trie_debug)
652 printk("In inflate\n"); 654 printk("In inflate\n");
653 655
654 tn = tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits + 1); 656 tn = tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits + 1);
@@ -659,12 +661,12 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
659 } 661 }
660 662
661 /* 663 /*
662 * Preallocate and store tnodes before the actual work so we 664 * Preallocate and store tnodes before the actual work so we
663 * don't get into an inconsistent state if memory allocation 665 * don't get into an inconsistent state if memory allocation
664 * fails. In case of failure we return the oldnode and inflate 666 * fails. In case of failure we return the oldnode and inflate
665 * of tnode is ignored. 667 * of tnode is ignored.
666 */ 668 */
667 669
668 for(i = 0; i < olen; i++) { 670 for(i = 0; i < olen; i++) {
669 struct tnode *inode = (struct tnode *) tnode_get_child(oldtnode, i); 671 struct tnode *inode = (struct tnode *) tnode_get_child(oldtnode, i);
670 672
@@ -675,20 +677,20 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
675 struct tnode *left, *right; 677 struct tnode *left, *right;
676 678
677 t_key m = TKEY_GET_MASK(inode->pos, 1); 679 t_key m = TKEY_GET_MASK(inode->pos, 1);
678 680
679 left = tnode_new(inode->key&(~m), inode->pos + 1, 681 left = tnode_new(inode->key&(~m), inode->pos + 1,
680 inode->bits - 1); 682 inode->bits - 1);
681 683
682 if(!left) { 684 if (!left) {
683 *err = -ENOMEM; 685 *err = -ENOMEM;
684 break; 686 break;
685 } 687 }
686 688
687 right = tnode_new(inode->key|m, inode->pos + 1, 689 right = tnode_new(inode->key|m, inode->pos + 1,
688 inode->bits - 1); 690 inode->bits - 1);
689 691
690 if(!right) { 692 if (!right) {
691 *err = -ENOMEM; 693 *err = -ENOMEM;
692 break; 694 break;
693 } 695 }
694 696
@@ -697,32 +699,32 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
697 } 699 }
698 } 700 }
699 701
700 if(*err) { 702 if (*err) {
701 int size = tnode_child_length(tn); 703 int size = tnode_child_length(tn);
702 int j; 704 int j;
703 705
704 for(j = 0; j < size; j++) 706 for(j = 0; j < size; j++)
705 if( tn->child[j]) 707 if (tn->child[j])
706 tnode_free((struct tnode *)tn->child[j]); 708 tnode_free((struct tnode *)tn->child[j]);
707 709
708 tnode_free(tn); 710 tnode_free(tn);
709 711
710 *err = -ENOMEM; 712 *err = -ENOMEM;
711 return oldtnode; 713 return oldtnode;
712 } 714 }
713 715
714 for(i = 0; i < olen; i++) { 716 for(i = 0; i < olen; i++) {
715 struct node *node = tnode_get_child(oldtnode, i); 717 struct node *node = tnode_get_child(oldtnode, i);
716 718
717 /* An empty child */ 719 /* An empty child */
718 if (node == NULL) 720 if (node == NULL)
719 continue; 721 continue;
720 722
721 /* A leaf or an internal node with skipped bits */ 723 /* A leaf or an internal node with skipped bits */
722 724
723 if(IS_LEAF(node) || ((struct tnode *) node)->pos > 725 if (IS_LEAF(node) || ((struct tnode *) node)->pos >
724 tn->pos + tn->bits - 1) { 726 tn->pos + tn->bits - 1) {
725 if(tkey_extract_bits(node->key, oldtnode->pos + oldtnode->bits, 727 if (tkey_extract_bits(node->key, oldtnode->pos + oldtnode->bits,
726 1) == 0) 728 1) == 0)
727 put_child(t, tn, 2*i, node); 729 put_child(t, tn, 2*i, node);
728 else 730 else
@@ -745,37 +747,37 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
745 struct tnode *left, *right; 747 struct tnode *left, *right;
746 int size, j; 748 int size, j;
747 749
748 /* We will replace this node 'inode' with two new 750 /* We will replace this node 'inode' with two new
749 * ones, 'left' and 'right', each with half of the 751 * ones, 'left' and 'right', each with half of the
750 * original children. The two new nodes will have 752 * original children. The two new nodes will have
751 * a position one bit further down the key and this 753 * a position one bit further down the key and this
752 * means that the "significant" part of their keys 754 * means that the "significant" part of their keys
753 * (see the discussion near the top of this file) 755 * (see the discussion near the top of this file)
754 * will differ by one bit, which will be "0" in 756 * will differ by one bit, which will be "0" in
755 * left's key and "1" in right's key. Since we are 757 * left's key and "1" in right's key. Since we are
756 * moving the key position by one step, the bit that 758 * moving the key position by one step, the bit that
757 * we are moving away from - the bit at position 759 * we are moving away from - the bit at position
758 * (inode->pos) - is the one that will differ between 760 * (inode->pos) - is the one that will differ between
759 * left and right. So... we synthesize that bit in the 761 * left and right. So... we synthesize that bit in the
760 * two new keys. 762 * two new keys.
761 * The mask 'm' below will be a single "one" bit at 763 * The mask 'm' below will be a single "one" bit at
762 * the position (inode->pos) 764 * the position (inode->pos)
763 */ 765 */
764 766
765 /* Use the old key, but set the new significant 767 /* Use the old key, but set the new significant
766 * bit to zero. 768 * bit to zero.
767 */ 769 */
768 770
769 left = (struct tnode *) tnode_get_child(tn, 2*i); 771 left = (struct tnode *) tnode_get_child(tn, 2*i);
770 put_child(t, tn, 2*i, NULL); 772 put_child(t, tn, 2*i, NULL);
771 773
772 if(!left) 774 if (!left)
773 BUG(); 775 BUG();
774 776
775 right = (struct tnode *) tnode_get_child(tn, 2*i+1); 777 right = (struct tnode *) tnode_get_child(tn, 2*i+1);
776 put_child(t, tn, 2*i+1, NULL); 778 put_child(t, tn, 2*i+1, NULL);
777 779
778 if(!right) 780 if (!right)
779 BUG(); 781 BUG();
780 782
781 size = tnode_child_length(left); 783 size = tnode_child_length(left);
@@ -800,9 +802,9 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err)
800 int i; 802 int i;
801 int olen = tnode_child_length(tn); 803 int olen = tnode_child_length(tn);
802 804
803 if(trie_debug) printk("In halve\n"); 805 if (trie_debug) printk("In halve\n");
804 806
805 tn=tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits - 1); 807 tn = tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits - 1);
806 808
807 if (!tn) { 809 if (!tn) {
808 *err = -ENOMEM; 810 *err = -ENOMEM;
@@ -810,39 +812,39 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err)
810 } 812 }
811 813
812 /* 814 /*
813 * Preallocate and store tnodes before the actual work so we 815 * Preallocate and store tnodes before the actual work so we
814 * don't get into an inconsistent state if memory allocation 816 * don't get into an inconsistent state if memory allocation
815 * fails. In case of failure we return the oldnode and halve 817 * fails. In case of failure we return the oldnode and halve
816 * of tnode is ignored. 818 * of tnode is ignored.
817 */ 819 */
818 820
819 for(i = 0; i < olen; i += 2) { 821 for(i = 0; i < olen; i += 2) {
820 left = tnode_get_child(oldtnode, i); 822 left = tnode_get_child(oldtnode, i);
821 right = tnode_get_child(oldtnode, i+1); 823 right = tnode_get_child(oldtnode, i+1);
822 824
823 /* Two nonempty children */ 825 /* Two nonempty children */
824 if( left && right) { 826 if (left && right) {
825 struct tnode *newBinNode = 827 struct tnode *newBinNode =
826 tnode_new(left->key, tn->pos + tn->bits, 1); 828 tnode_new(left->key, tn->pos + tn->bits, 1);
827 829
828 if(!newBinNode) { 830 if (!newBinNode) {
829 *err = -ENOMEM; 831 *err = -ENOMEM;
830 break; 832 break;
831 } 833 }
832 put_child(t, tn, i/2, (struct node *)newBinNode); 834 put_child(t, tn, i/2, (struct node *)newBinNode);
833 } 835 }
834 } 836 }
835 837
836 if(*err) { 838 if (*err) {
837 int size = tnode_child_length(tn); 839 int size = tnode_child_length(tn);
838 int j; 840 int j;
839 841
840 for(j = 0; j < size; j++) 842 for(j = 0; j < size; j++)
841 if( tn->child[j]) 843 if (tn->child[j])
842 tnode_free((struct tnode *)tn->child[j]); 844 tnode_free((struct tnode *)tn->child[j]);
843 845
844 tnode_free(tn); 846 tnode_free(tn);
845 847
846 *err = -ENOMEM; 848 *err = -ENOMEM;
847 return oldtnode; 849 return oldtnode;
848 } 850 }
@@ -850,7 +852,7 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err)
850 for(i = 0; i < olen; i += 2) { 852 for(i = 0; i < olen; i += 2) {
851 left = tnode_get_child(oldtnode, i); 853 left = tnode_get_child(oldtnode, i);
852 right = tnode_get_child(oldtnode, i+1); 854 right = tnode_get_child(oldtnode, i+1);
853 855
854 /* At least one of the children is empty */ 856 /* At least one of the children is empty */
855 if (left == NULL) { 857 if (left == NULL) {
856 if (right == NULL) /* Both are empty */ 858 if (right == NULL) /* Both are empty */
@@ -858,14 +860,14 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err)
858 put_child(t, tn, i/2, right); 860 put_child(t, tn, i/2, right);
859 } else if (right == NULL) 861 } else if (right == NULL)
860 put_child(t, tn, i/2, left); 862 put_child(t, tn, i/2, left);
861 863
862 /* Two nonempty children */ 864 /* Two nonempty children */
863 else { 865 else {
864 struct tnode *newBinNode = 866 struct tnode *newBinNode =
865 (struct tnode *) tnode_get_child(tn, i/2); 867 (struct tnode *) tnode_get_child(tn, i/2);
866 put_child(t, tn, i/2, NULL); 868 put_child(t, tn, i/2, NULL);
867 869
868 if(!newBinNode) 870 if (!newBinNode)
869 BUG(); 871 BUG();
870 872
871 put_child(t, newBinNode, 0, left); 873 put_child(t, newBinNode, 0, left);
@@ -879,7 +881,7 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err)
879 881
880static void *trie_init(struct trie *t) 882static void *trie_init(struct trie *t)
881{ 883{
882 if(t) { 884 if (t) {
883 t->size = 0; 885 t->size = 0;
884 t->trie = NULL; 886 t->trie = NULL;
885 t->revision = 0; 887 t->revision = 0;
@@ -896,8 +898,7 @@ static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen)
896 struct leaf_info *li; 898 struct leaf_info *li;
897 899
898 hlist_for_each_entry(li, node, head, hlist) { 900 hlist_for_each_entry(li, node, head, hlist) {
899 901 if (li->plen == plen)
900 if ( li->plen == plen )
901 return li; 902 return li;
902 } 903 }
903 return NULL; 904 return NULL;
@@ -905,35 +906,35 @@ static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen)
905 906
906static inline struct list_head * get_fa_head(struct leaf *l, int plen) 907static inline struct list_head * get_fa_head(struct leaf *l, int plen)
907{ 908{
908 struct list_head *fa_head=NULL; 909 struct list_head *fa_head = NULL;
909 struct leaf_info *li = find_leaf_info(&l->list, plen); 910 struct leaf_info *li = find_leaf_info(&l->list, plen);
910 911
911 if(li) 912 if (li)
912 fa_head = &li->falh; 913 fa_head = &li->falh;
913 914
914 return fa_head; 915 return fa_head;
915} 916}
916 917
917static void insert_leaf_info(struct hlist_head *head, struct leaf_info *new) 918static void insert_leaf_info(struct hlist_head *head, struct leaf_info *new)
918{ 919{
919 struct leaf_info *li=NULL, *last=NULL; 920 struct leaf_info *li = NULL, *last = NULL;
920 struct hlist_node *node, *tmp; 921 struct hlist_node *node, *tmp;
921 922
922 write_lock_bh(&fib_lock); 923 write_lock_bh(&fib_lock);
923 924
924 if(hlist_empty(head)) 925 if (hlist_empty(head))
925 hlist_add_head(&new->hlist, head); 926 hlist_add_head(&new->hlist, head);
926 else { 927 else {
927 hlist_for_each_entry_safe(li, node, tmp, head, hlist) { 928 hlist_for_each_entry_safe(li, node, tmp, head, hlist) {
928 929
929 if (new->plen > li->plen) 930 if (new->plen > li->plen)
930 break; 931 break;
931 932
932 last = li; 933 last = li;
933 } 934 }
934 if(last) 935 if (last)
935 hlist_add_after(&last->hlist, &new->hlist); 936 hlist_add_after(&last->hlist, &new->hlist);
936 else 937 else
937 hlist_add_before(&new->hlist, &li->hlist); 938 hlist_add_before(&new->hlist, &li->hlist);
938 } 939 }
939 write_unlock_bh(&fib_lock); 940 write_unlock_bh(&fib_lock);
@@ -947,14 +948,14 @@ fib_find_node(struct trie *t, u32 key)
947 struct node *n; 948 struct node *n;
948 949
949 pos = 0; 950 pos = 0;
950 n=t->trie; 951 n = t->trie;
951 952
952 while (n != NULL && NODE_TYPE(n) == T_TNODE) { 953 while (n != NULL && NODE_TYPE(n) == T_TNODE) {
953 tn = (struct tnode *) n; 954 tn = (struct tnode *) n;
954 955
955 check_tnode(tn); 956 check_tnode(tn);
956 957
957 if(tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) { 958 if (tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) {
958 pos=tn->pos + tn->bits; 959 pos=tn->pos + tn->bits;
959 n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits)); 960 n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits));
960 } 961 }
@@ -977,23 +978,23 @@ static struct node *trie_rebalance(struct trie *t, struct tnode *tn)
977 t_key cindex, key; 978 t_key cindex, key;
978 struct tnode *tp = NULL; 979 struct tnode *tp = NULL;
979 980
980 if(!tn) 981 if (!tn)
981 BUG(); 982 BUG();
982 983
983 key = tn->key; 984 key = tn->key;
984 i = 0; 985 i = 0;
985 986
986 while (tn != NULL && NODE_PARENT(tn) != NULL) { 987 while (tn != NULL && NODE_PARENT(tn) != NULL) {
987 988
988 if( i > 10 ) { 989 if (i > 10) {
989 printk("Rebalance tn=%p \n", tn); 990 printk("Rebalance tn=%p \n", tn);
990 if(tn) printk("tn->parent=%p \n", NODE_PARENT(tn)); 991 if (tn) printk("tn->parent=%p \n", NODE_PARENT(tn));
991 992
992 printk("Rebalance tp=%p \n", tp); 993 printk("Rebalance tp=%p \n", tp);
993 if(tp) printk("tp->parent=%p \n", NODE_PARENT(tp)); 994 if (tp) printk("tp->parent=%p \n", NODE_PARENT(tp));
994 } 995 }
995 996
996 if( i > 12 ) BUG(); 997 if (i > 12) BUG();
997 i++; 998 i++;
998 999
999 tp = NODE_PARENT(tn); 1000 tp = NODE_PARENT(tn);
@@ -1001,14 +1002,14 @@ static struct node *trie_rebalance(struct trie *t, struct tnode *tn)
1001 wasfull = tnode_full(tp, tnode_get_child(tp, cindex)); 1002 wasfull = tnode_full(tp, tnode_get_child(tp, cindex));
1002 tn = (struct tnode *) resize (t, (struct tnode *)tn); 1003 tn = (struct tnode *) resize (t, (struct tnode *)tn);
1003 tnode_put_child_reorg((struct tnode *)tp, cindex,(struct node*)tn, wasfull); 1004 tnode_put_child_reorg((struct tnode *)tp, cindex,(struct node*)tn, wasfull);
1004 1005
1005 if(!NODE_PARENT(tn)) 1006 if (!NODE_PARENT(tn))
1006 break; 1007 break;
1007 1008
1008 tn = NODE_PARENT(tn); 1009 tn = NODE_PARENT(tn);
1009 } 1010 }
1010 /* Handle last (top) tnode */ 1011 /* Handle last (top) tnode */
1011 if (IS_TNODE(tn)) 1012 if (IS_TNODE(tn))
1012 tn = (struct tnode*) resize(t, (struct tnode *)tn); 1013 tn = (struct tnode*) resize(t, (struct tnode *)tn);
1013 1014
1014 return (struct node*) tn; 1015 return (struct node*) tn;
@@ -1022,42 +1023,42 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
1022 struct node *n; 1023 struct node *n;
1023 struct leaf *l; 1024 struct leaf *l;
1024 int missbit; 1025 int missbit;
1025 struct list_head *fa_head=NULL; 1026 struct list_head *fa_head = NULL;
1026 struct leaf_info *li; 1027 struct leaf_info *li;
1027 t_key cindex; 1028 t_key cindex;
1028 1029
1029 pos = 0; 1030 pos = 0;
1030 n=t->trie; 1031 n = t->trie;
1031 1032
1032 /* If we point to NULL, stop. Either the tree is empty and we should 1033 /* If we point to NULL, stop. Either the tree is empty and we should
1033 * just put a new leaf in if, or we have reached an empty child slot, 1034 * just put a new leaf in if, or we have reached an empty child slot,
1034 * and we should just put our new leaf in that. 1035 * and we should just put our new leaf in that.
1035 * If we point to a T_TNODE, check if it matches our key. Note that 1036 * If we point to a T_TNODE, check if it matches our key. Note that
1036 * a T_TNODE might be skipping any number of bits - its 'pos' need 1037 * a T_TNODE might be skipping any number of bits - its 'pos' need
1037 * not be the parent's 'pos'+'bits'! 1038 * not be the parent's 'pos'+'bits'!
1038 * 1039 *
1039 * If it does match the current key, get pos/bits from it, extract 1040 * If it does match the current key, get pos/bits from it, extract
1040 * the index from our key, push the T_TNODE and walk the tree. 1041 * the index from our key, push the T_TNODE and walk the tree.
1041 * 1042 *
1042 * If it doesn't, we have to replace it with a new T_TNODE. 1043 * If it doesn't, we have to replace it with a new T_TNODE.
1043 * 1044 *
1044 * If we point to a T_LEAF, it might or might not have the same key 1045 * If we point to a T_LEAF, it might or might not have the same key
1045 * as we do. If it does, just change the value, update the T_LEAF's 1046 * as we do. If it does, just change the value, update the T_LEAF's
1046 * value, and return it. 1047 * value, and return it.
1047 * If it doesn't, we need to replace it with a T_TNODE. 1048 * If it doesn't, we need to replace it with a T_TNODE.
1048 */ 1049 */
1049 1050
1050 while (n != NULL && NODE_TYPE(n) == T_TNODE) { 1051 while (n != NULL && NODE_TYPE(n) == T_TNODE) {
1051 tn = (struct tnode *) n; 1052 tn = (struct tnode *) n;
1052
1053 check_tnode(tn);
1054 1053
1055 if(tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) { 1054 check_tnode(tn);
1055
1056 if (tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) {
1056 tp = tn; 1057 tp = tn;
1057 pos=tn->pos + tn->bits; 1058 pos=tn->pos + tn->bits;
1058 n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits)); 1059 n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits));
1059 1060
1060 if(n && NODE_PARENT(n) != tn) { 1061 if (n && NODE_PARENT(n) != tn) {
1061 printk("BUG tn=%p, n->parent=%p\n", tn, NODE_PARENT(n)); 1062 printk("BUG tn=%p, n->parent=%p\n", tn, NODE_PARENT(n));
1062 BUG(); 1063 BUG();
1063 } 1064 }
@@ -1069,21 +1070,21 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
1069 /* 1070 /*
1070 * n ----> NULL, LEAF or TNODE 1071 * n ----> NULL, LEAF or TNODE
1071 * 1072 *
1072 * tp is n's (parent) ----> NULL or TNODE 1073 * tp is n's (parent) ----> NULL or TNODE
1073 */ 1074 */
1074 1075
1075 if(tp && IS_LEAF(tp)) 1076 if (tp && IS_LEAF(tp))
1076 BUG(); 1077 BUG();
1077 1078
1078 1079
1079 /* Case 1: n is a leaf. Compare prefixes */ 1080 /* Case 1: n is a leaf. Compare prefixes */
1080 1081
1081 if (n != NULL && IS_LEAF(n) && tkey_equals(key, n->key)) { 1082 if (n != NULL && IS_LEAF(n) && tkey_equals(key, n->key)) {
1082 struct leaf *l = ( struct leaf *) n; 1083 struct leaf *l = ( struct leaf *) n;
1083 1084
1084 li = leaf_info_new(plen); 1085 li = leaf_info_new(plen);
1085 1086
1086 if(! li) { 1087 if (!li) {
1087 *err = -ENOMEM; 1088 *err = -ENOMEM;
1088 goto err; 1089 goto err;
1089 } 1090 }
@@ -1095,7 +1096,7 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
1095 t->size++; 1096 t->size++;
1096 l = leaf_new(); 1097 l = leaf_new();
1097 1098
1098 if(! l) { 1099 if (!l) {
1099 *err = -ENOMEM; 1100 *err = -ENOMEM;
1100 goto err; 1101 goto err;
1101 } 1102 }
@@ -1103,7 +1104,7 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
1103 l->key = key; 1104 l->key = key;
1104 li = leaf_info_new(plen); 1105 li = leaf_info_new(plen);
1105 1106
1106 if(! li) { 1107 if (!li) {
1107 tnode_free((struct tnode *) l); 1108 tnode_free((struct tnode *) l);
1108 *err = -ENOMEM; 1109 *err = -ENOMEM;
1109 goto err; 1110 goto err;
@@ -1116,8 +1117,8 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
1116 if (t->trie && n == NULL) { 1117 if (t->trie && n == NULL) {
1117 1118
1118 NODE_SET_PARENT(l, tp); 1119 NODE_SET_PARENT(l, tp);
1119 1120
1120 if (!tp) 1121 if (!tp)
1121 BUG(); 1122 BUG();
1122 1123
1123 else { 1124 else {
@@ -1127,8 +1128,8 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
1127 } 1128 }
1128 /* Case 3: n is a LEAF or a TNODE and the key doesn't match. */ 1129 /* Case 3: n is a LEAF or a TNODE and the key doesn't match. */
1129 else { 1130 else {
1130 /* 1131 /*
1131 * Add a new tnode here 1132 * Add a new tnode here
1132 * first tnode need some special handling 1133 * first tnode need some special handling
1133 */ 1134 */
1134 1135
@@ -1136,39 +1137,39 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
1136 pos=tp->pos+tp->bits; 1137 pos=tp->pos+tp->bits;
1137 else 1138 else
1138 pos=0; 1139 pos=0;
1139 if(n) { 1140 if (n) {
1140 newpos = tkey_mismatch(key, pos, n->key); 1141 newpos = tkey_mismatch(key, pos, n->key);
1141 tn = tnode_new(n->key, newpos, 1); 1142 tn = tnode_new(n->key, newpos, 1);
1142 } 1143 }
1143 else { 1144 else {
1144 newpos = 0; 1145 newpos = 0;
1145 tn = tnode_new(key, newpos, 1); /* First tnode */ 1146 tn = tnode_new(key, newpos, 1); /* First tnode */
1146 } 1147 }
1147 1148
1148 if(!tn) { 1149 if (!tn) {
1149 free_leaf_info(li); 1150 free_leaf_info(li);
1150 tnode_free((struct tnode *) l); 1151 tnode_free((struct tnode *) l);
1151 *err = -ENOMEM; 1152 *err = -ENOMEM;
1152 goto err; 1153 goto err;
1153 } 1154 }
1154 1155
1155 NODE_SET_PARENT(tn, tp); 1156 NODE_SET_PARENT(tn, tp);
1156 1157
1157 missbit=tkey_extract_bits(key, newpos, 1); 1158 missbit=tkey_extract_bits(key, newpos, 1);
1158 put_child(t, tn, missbit, (struct node *)l); 1159 put_child(t, tn, missbit, (struct node *)l);
1159 put_child(t, tn, 1-missbit, n); 1160 put_child(t, tn, 1-missbit, n);
1160 1161
1161 if(tp) { 1162 if (tp) {
1162 cindex = tkey_extract_bits(key, tp->pos, tp->bits); 1163 cindex = tkey_extract_bits(key, tp->pos, tp->bits);
1163 put_child(t, (struct tnode *)tp, cindex, (struct node *)tn); 1164 put_child(t, (struct tnode *)tp, cindex, (struct node *)tn);
1164 } 1165 }
1165 else { 1166 else {
1166 t->trie = (struct node*) tn; /* First tnode */ 1167 t->trie = (struct node*) tn; /* First tnode */
1167 tp = tn; 1168 tp = tn;
1168 } 1169 }
1169 } 1170 }
1170 if(tp && tp->pos+tp->bits > 32) { 1171 if (tp && tp->pos+tp->bits > 32) {
1171 printk("ERROR tp=%p pos=%d, bits=%d, key=%0x plen=%d\n", 1172 printk("ERROR tp=%p pos=%d, bits=%d, key=%0x plen=%d\n",
1172 tp, tp->pos, tp->bits, key, plen); 1173 tp, tp->pos, tp->bits, key, plen);
1173 } 1174 }
1174 /* Rebalance the trie */ 1175 /* Rebalance the trie */
@@ -1185,7 +1186,7 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
1185{ 1186{
1186 struct trie *t = (struct trie *) tb->tb_data; 1187 struct trie *t = (struct trie *) tb->tb_data;
1187 struct fib_alias *fa, *new_fa; 1188 struct fib_alias *fa, *new_fa;
1188 struct list_head *fa_head=NULL; 1189 struct list_head *fa_head = NULL;
1189 struct fib_info *fi; 1190 struct fib_info *fi;
1190 int plen = r->rtm_dst_len; 1191 int plen = r->rtm_dst_len;
1191 int type = r->rtm_type; 1192 int type = r->rtm_type;
@@ -1198,17 +1199,17 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
1198 return -EINVAL; 1199 return -EINVAL;
1199 1200
1200 key = 0; 1201 key = 0;
1201 if (rta->rta_dst) 1202 if (rta->rta_dst)
1202 memcpy(&key, rta->rta_dst, 4); 1203 memcpy(&key, rta->rta_dst, 4);
1203 1204
1204 key = ntohl(key); 1205 key = ntohl(key);
1205 1206
1206 if(trie_debug) 1207 if (trie_debug)
1207 printk("Insert table=%d %08x/%d\n", tb->tb_id, key, plen); 1208 printk("Insert table=%d %08x/%d\n", tb->tb_id, key, plen);
1208 1209
1209 mask = ntohl( inet_make_mask(plen) ); 1210 mask = ntohl( inet_make_mask(plen) );
1210 1211
1211 if(key & ~mask) 1212 if (key & ~mask)
1212 return -EINVAL; 1213 return -EINVAL;
1213 1214
1214 key = key & mask; 1215 key = key & mask;
@@ -1217,9 +1218,9 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
1217 goto err; 1218 goto err;
1218 1219
1219 l = fib_find_node(t, key); 1220 l = fib_find_node(t, key);
1220 fa = NULL; 1221 fa = NULL;
1221 1222
1222 if(l) { 1223 if (l) {
1223 fa_head = get_fa_head(l, plen); 1224 fa_head = get_fa_head(l, plen);
1224 fa = fib_find_alias(fa_head, tos, fi->fib_priority); 1225 fa = fib_find_alias(fa_head, tos, fi->fib_priority);
1225 } 1226 }
@@ -1298,16 +1299,16 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
1298 new_fa->fa_scope = r->rtm_scope; 1299 new_fa->fa_scope = r->rtm_scope;
1299 new_fa->fa_state = 0; 1300 new_fa->fa_state = 0;
1300#if 0 1301#if 0
1301 new_fa->dst = NULL; 1302 new_fa->dst = NULL;
1302#endif 1303#endif
1303 /* 1304 /*
1304 * Insert new entry to the list. 1305 * Insert new entry to the list.
1305 */ 1306 */
1306 1307
1307 if(!fa_head) { 1308 if (!fa_head) {
1308 fa_head = fib_insert_node(t, &err, key, plen); 1309 fa_head = fib_insert_node(t, &err, key, plen);
1309 err = 0; 1310 err = 0;
1310 if(err) 1311 if (err)
1311 goto out_free_new_fa; 1312 goto out_free_new_fa;
1312 } 1313 }
1313 1314
@@ -1327,11 +1328,11 @@ out_free_new_fa:
1327 kmem_cache_free(fn_alias_kmem, new_fa); 1328 kmem_cache_free(fn_alias_kmem, new_fa);
1328out: 1329out:
1329 fib_release_info(fi); 1330 fib_release_info(fi);
1330err:; 1331err:;
1331 return err; 1332 return err;
1332} 1333}
1333 1334
1334static inline int check_leaf(struct trie *t, struct leaf *l, t_key key, int *plen, const struct flowi *flp, 1335static inline int check_leaf(struct trie *t, struct leaf *l, t_key key, int *plen, const struct flowi *flp,
1335 struct fib_result *res, int *err) 1336 struct fib_result *res, int *err)
1336{ 1337{
1337 int i; 1338 int i;
@@ -1339,12 +1340,12 @@ static inline int check_leaf(struct trie *t, struct leaf *l, t_key key, int *pl
1339 struct leaf_info *li; 1340 struct leaf_info *li;
1340 struct hlist_head *hhead = &l->list; 1341 struct hlist_head *hhead = &l->list;
1341 struct hlist_node *node; 1342 struct hlist_node *node;
1342 1343
1343 hlist_for_each_entry(li, node, hhead, hlist) { 1344 hlist_for_each_entry(li, node, hhead, hlist) {
1344 1345
1345 i = li->plen; 1346 i = li->plen;
1346 mask = ntohl(inet_make_mask(i)); 1347 mask = ntohl(inet_make_mask(i));
1347 if (l->key != (key & mask)) 1348 if (l->key != (key & mask))
1348 continue; 1349 continue;
1349 1350
1350 if (((*err) = fib_semantic_match(&li->falh, flp, res, l->key, mask, i)) == 0) { 1351 if (((*err) = fib_semantic_match(&li->falh, flp, res, l->key, mask, i)) == 0) {
@@ -1376,7 +1377,7 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
1376 n = t->trie; 1377 n = t->trie;
1377 1378
1378 read_lock(&fib_lock); 1379 read_lock(&fib_lock);
1379 if(!n) 1380 if (!n)
1380 goto failed; 1381 goto failed;
1381 1382
1382#ifdef CONFIG_IP_FIB_TRIE_STATS 1383#ifdef CONFIG_IP_FIB_TRIE_STATS
@@ -1385,19 +1386,19 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
1385 1386
1386 /* Just a leaf? */ 1387 /* Just a leaf? */
1387 if (IS_LEAF(n)) { 1388 if (IS_LEAF(n)) {
1388 if( check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret) ) 1389 if (check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret))
1389 goto found; 1390 goto found;
1390 goto failed; 1391 goto failed;
1391 } 1392 }
1392 pn = (struct tnode *) n; 1393 pn = (struct tnode *) n;
1393 chopped_off = 0; 1394 chopped_off = 0;
1394 1395
1395 while (pn) { 1396 while (pn) {
1396 1397
1397 pos = pn->pos; 1398 pos = pn->pos;
1398 bits = pn->bits; 1399 bits = pn->bits;
1399 1400
1400 if(!chopped_off) 1401 if (!chopped_off)
1401 cindex = tkey_extract_bits(MASK_PFX(key, current_prefix_length), pos, bits); 1402 cindex = tkey_extract_bits(MASK_PFX(key, current_prefix_length), pos, bits);
1402 1403
1403 n = tnode_get_child(pn, cindex); 1404 n = tnode_get_child(pn, cindex);
@@ -1417,33 +1418,33 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
1417 int mp; 1418 int mp;
1418 1419
1419 /* 1420 /*
1420 * It's a tnode, and we can do some extra checks here if we 1421 * It's a tnode, and we can do some extra checks here if we
1421 * like, to avoid descending into a dead-end branch. 1422 * like, to avoid descending into a dead-end branch.
1422 * This tnode is in the parent's child array at index 1423 * This tnode is in the parent's child array at index
1423 * key[p_pos..p_pos+p_bits] but potentially with some bits 1424 * key[p_pos..p_pos+p_bits] but potentially with some bits
1424 * chopped off, so in reality the index may be just a 1425 * chopped off, so in reality the index may be just a
1425 * subprefix, padded with zero at the end. 1426 * subprefix, padded with zero at the end.
1426 * We can also take a look at any skipped bits in this 1427 * We can also take a look at any skipped bits in this
1427 * tnode - everything up to p_pos is supposed to be ok, 1428 * tnode - everything up to p_pos is supposed to be ok,
1428 * and the non-chopped bits of the index (se previous 1429 * and the non-chopped bits of the index (se previous
1429 * paragraph) are also guaranteed ok, but the rest is 1430 * paragraph) are also guaranteed ok, but the rest is
1430 * considered unknown. 1431 * considered unknown.
1431 * 1432 *
1432 * The skipped bits are key[pos+bits..cn->pos]. 1433 * The skipped bits are key[pos+bits..cn->pos].
1433 */ 1434 */
1434 1435
1435 /* If current_prefix_length < pos+bits, we are already doing 1436 /* If current_prefix_length < pos+bits, we are already doing
1436 * actual prefix matching, which means everything from 1437 * actual prefix matching, which means everything from
1437 * pos+(bits-chopped_off) onward must be zero along some 1438 * pos+(bits-chopped_off) onward must be zero along some
1438 * branch of this subtree - otherwise there is *no* valid 1439 * branch of this subtree - otherwise there is *no* valid
1439 * prefix present. Here we can only check the skipped 1440 * prefix present. Here we can only check the skipped
1440 * bits. Remember, since we have already indexed into the 1441 * bits. Remember, since we have already indexed into the
1441 * parent's child array, we know that the bits we chopped of 1442 * parent's child array, we know that the bits we chopped of
1442 * *are* zero. 1443 * *are* zero.
1443 */ 1444 */
1444 1445
1445 /* NOTA BENE: CHECKING ONLY SKIPPED BITS FOR THE NEW NODE HERE */ 1446 /* NOTA BENE: CHECKING ONLY SKIPPED BITS FOR THE NEW NODE HERE */
1446 1447
1447 if (current_prefix_length < pos+bits) { 1448 if (current_prefix_length < pos+bits) {
1448 if (tkey_extract_bits(cn->key, current_prefix_length, 1449 if (tkey_extract_bits(cn->key, current_prefix_length,
1449 cn->pos - current_prefix_length) != 0 || 1450 cn->pos - current_prefix_length) != 0 ||
@@ -1452,13 +1453,13 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
1452 } 1453 }
1453 1454
1454 /* 1455 /*
1455 * If chopped_off=0, the index is fully validated and we 1456 * If chopped_off=0, the index is fully validated and we
1456 * only need to look at the skipped bits for this, the new, 1457 * only need to look at the skipped bits for this, the new,
1457 * tnode. What we actually want to do is to find out if 1458 * tnode. What we actually want to do is to find out if
1458 * these skipped bits match our key perfectly, or if we will 1459 * these skipped bits match our key perfectly, or if we will
1459 * have to count on finding a matching prefix further down, 1460 * have to count on finding a matching prefix further down,
1460 * because if we do, we would like to have some way of 1461 * because if we do, we would like to have some way of
1461 * verifying the existence of such a prefix at this point. 1462 * verifying the existence of such a prefix at this point.
1462 */ 1463 */
1463 1464
1464 /* The only thing we can do at this point is to verify that 1465 /* The only thing we can do at this point is to verify that
@@ -1470,22 +1471,22 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
1470 * new tnode's key. 1471 * new tnode's key.
1471 */ 1472 */
1472 1473
1473 /* Note: We aren't very concerned about the piece of the key 1474 /* Note: We aren't very concerned about the piece of the key
1474 * that precede pn->pos+pn->bits, since these have already been 1475 * that precede pn->pos+pn->bits, since these have already been
1475 * checked. The bits after cn->pos aren't checked since these are 1476 * checked. The bits after cn->pos aren't checked since these are
1476 * by definition "unknown" at this point. Thus, what we want to 1477 * by definition "unknown" at this point. Thus, what we want to
1477 * see is if we are about to enter the "prefix matching" state, 1478 * see is if we are about to enter the "prefix matching" state,
1478 * and in that case verify that the skipped bits that will prevail 1479 * and in that case verify that the skipped bits that will prevail
1479 * throughout this subtree are zero, as they have to be if we are 1480 * throughout this subtree are zero, as they have to be if we are
1480 * to find a matching prefix. 1481 * to find a matching prefix.
1481 */ 1482 */
1482 1483
1483 node_prefix = MASK_PFX(cn->key, cn->pos); 1484 node_prefix = MASK_PFX(cn->key, cn->pos);
1484 key_prefix = MASK_PFX(key, cn->pos); 1485 key_prefix = MASK_PFX(key, cn->pos);
1485 pref_mismatch = key_prefix^node_prefix; 1486 pref_mismatch = key_prefix^node_prefix;
1486 mp = 0; 1487 mp = 0;
1487 1488
1488 /* In short: If skipped bits in this node do not match the search 1489 /* In short: If skipped bits in this node do not match the search
1489 * key, enter the "prefix matching" state.directly. 1490 * key, enter the "prefix matching" state.directly.
1490 */ 1491 */
1491 if (pref_mismatch) { 1492 if (pref_mismatch) {
@@ -1494,7 +1495,7 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
1494 pref_mismatch = pref_mismatch <<1; 1495 pref_mismatch = pref_mismatch <<1;
1495 } 1496 }
1496 key_prefix = tkey_extract_bits(cn->key, mp, cn->pos-mp); 1497 key_prefix = tkey_extract_bits(cn->key, mp, cn->pos-mp);
1497 1498
1498 if (key_prefix != 0) 1499 if (key_prefix != 0)
1499 goto backtrace; 1500 goto backtrace;
1500 1501
@@ -1505,9 +1506,9 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
1505 pn = (struct tnode *)n; /* Descend */ 1506 pn = (struct tnode *)n; /* Descend */
1506 chopped_off = 0; 1507 chopped_off = 0;
1507 continue; 1508 continue;
1508 } 1509 }
1509 if (IS_LEAF(n)) { 1510 if (IS_LEAF(n)) {
1510 if( check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret)) 1511 if (check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret))
1511 goto found; 1512 goto found;
1512 } 1513 }
1513backtrace: 1514backtrace:
@@ -1521,18 +1522,18 @@ backtrace:
1521 /* Decrease current_... with bits chopped off */ 1522 /* Decrease current_... with bits chopped off */
1522 if (current_prefix_length > pn->pos + pn->bits - chopped_off) 1523 if (current_prefix_length > pn->pos + pn->bits - chopped_off)
1523 current_prefix_length = pn->pos + pn->bits - chopped_off; 1524 current_prefix_length = pn->pos + pn->bits - chopped_off;
1524 1525
1525 /* 1526 /*
1526 * Either we do the actual chop off according or if we have 1527 * Either we do the actual chop off according or if we have
1527 * chopped off all bits in this tnode walk up to our parent. 1528 * chopped off all bits in this tnode walk up to our parent.
1528 */ 1529 */
1529 1530
1530 if(chopped_off <= pn->bits) 1531 if (chopped_off <= pn->bits)
1531 cindex &= ~(1 << (chopped_off-1)); 1532 cindex &= ~(1 << (chopped_off-1));
1532 else { 1533 else {
1533 if( NODE_PARENT(pn) == NULL) 1534 if (NODE_PARENT(pn) == NULL)
1534 goto failed; 1535 goto failed;
1535 1536
1536 /* Get Child's index */ 1537 /* Get Child's index */
1537 cindex = tkey_extract_bits(pn->key, NODE_PARENT(pn)->pos, NODE_PARENT(pn)->bits); 1538 cindex = tkey_extract_bits(pn->key, NODE_PARENT(pn)->pos, NODE_PARENT(pn)->bits);
1538 pn = NODE_PARENT(pn); 1539 pn = NODE_PARENT(pn);
@@ -1542,10 +1543,10 @@ backtrace:
1542 t->stats.backtrack++; 1543 t->stats.backtrack++;
1543#endif 1544#endif
1544 goto backtrace; 1545 goto backtrace;
1545 } 1546 }
1546 } 1547 }
1547failed: 1548failed:
1548 ret = 1; 1549 ret = 1;
1549found: 1550found:
1550 read_unlock(&fib_lock); 1551 read_unlock(&fib_lock);
1551 return ret; 1552 return ret;
@@ -1558,11 +1559,11 @@ static int trie_leaf_remove(struct trie *t, t_key key)
1558 struct node *n = t->trie; 1559 struct node *n = t->trie;
1559 struct leaf *l; 1560 struct leaf *l;
1560 1561
1561 if(trie_debug) 1562 if (trie_debug)
1562 printk("entering trie_leaf_remove(%p)\n", n); 1563 printk("entering trie_leaf_remove(%p)\n", n);
1563 1564
1564 /* Note that in the case skipped bits, those bits are *not* checked! 1565 /* Note that in the case skipped bits, those bits are *not* checked!
1565 * When we finish this, we will have NULL or a T_LEAF, and the 1566 * When we finish this, we will have NULL or a T_LEAF, and the
1566 * T_LEAF may or may not match our key. 1567 * T_LEAF may or may not match our key.
1567 */ 1568 */
1568 1569
@@ -1571,19 +1572,19 @@ static int trie_leaf_remove(struct trie *t, t_key key)
1571 check_tnode(tn); 1572 check_tnode(tn);
1572 n = tnode_get_child(tn ,tkey_extract_bits(key, tn->pos, tn->bits)); 1573 n = tnode_get_child(tn ,tkey_extract_bits(key, tn->pos, tn->bits));
1573 1574
1574 if(n && NODE_PARENT(n) != tn) { 1575 if (n && NODE_PARENT(n) != tn) {
1575 printk("BUG tn=%p, n->parent=%p\n", tn, NODE_PARENT(n)); 1576 printk("BUG tn=%p, n->parent=%p\n", tn, NODE_PARENT(n));
1576 BUG(); 1577 BUG();
1577 } 1578 }
1578 } 1579 }
1579 l = (struct leaf *) n; 1580 l = (struct leaf *) n;
1580 1581
1581 if(!n || !tkey_equals(l->key, key)) 1582 if (!n || !tkey_equals(l->key, key))
1582 return 0; 1583 return 0;
1583 1584
1584 /* 1585 /*
1585 * Key found. 1586 * Key found.
1586 * Remove the leaf and rebalance the tree 1587 * Remove the leaf and rebalance the tree
1587 */ 1588 */
1588 1589
1589 t->revision++; 1590 t->revision++;
@@ -1592,7 +1593,7 @@ static int trie_leaf_remove(struct trie *t, t_key key)
1592 tp = NODE_PARENT(n); 1593 tp = NODE_PARENT(n);
1593 tnode_free((struct tnode *) n); 1594 tnode_free((struct tnode *) n);
1594 1595
1595 if(tp) { 1596 if (tp) {
1596 cindex = tkey_extract_bits(key, tp->pos, tp->bits); 1597 cindex = tkey_extract_bits(key, tp->pos, tp->bits);
1597 put_child(t, (struct tnode *)tp, cindex, NULL); 1598 put_child(t, (struct tnode *)tp, cindex, NULL);
1598 t->trie = trie_rebalance(t, tp); 1599 t->trie = trie_rebalance(t, tp);
@@ -1615,23 +1616,23 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
1615 struct list_head *fa_head; 1616 struct list_head *fa_head;
1616 struct leaf *l; 1617 struct leaf *l;
1617 1618
1618 if (plen > 32) 1619 if (plen > 32)
1619 return -EINVAL; 1620 return -EINVAL;
1620 1621
1621 key = 0; 1622 key = 0;
1622 if (rta->rta_dst) 1623 if (rta->rta_dst)
1623 memcpy(&key, rta->rta_dst, 4); 1624 memcpy(&key, rta->rta_dst, 4);
1624 1625
1625 key = ntohl(key); 1626 key = ntohl(key);
1626 mask = ntohl( inet_make_mask(plen) ); 1627 mask = ntohl( inet_make_mask(plen) );
1627 1628
1628 if(key & ~mask) 1629 if (key & ~mask)
1629 return -EINVAL; 1630 return -EINVAL;
1630 1631
1631 key = key & mask; 1632 key = key & mask;
1632 l = fib_find_node(t, key); 1633 l = fib_find_node(t, key);
1633 1634
1634 if(!l) 1635 if (!l)
1635 return -ESRCH; 1636 return -ESRCH;
1636 1637
1637 fa_head = get_fa_head(l, plen); 1638 fa_head = get_fa_head(l, plen);
@@ -1677,16 +1678,16 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
1677 1678
1678 list_del(&fa->fa_list); 1679 list_del(&fa->fa_list);
1679 1680
1680 if(list_empty(fa_head)) { 1681 if (list_empty(fa_head)) {
1681 hlist_del(&li->hlist); 1682 hlist_del(&li->hlist);
1682 kill_li = 1; 1683 kill_li = 1;
1683 } 1684 }
1684 write_unlock_bh(&fib_lock); 1685 write_unlock_bh(&fib_lock);
1685 1686
1686 if(kill_li) 1687 if (kill_li)
1687 free_leaf_info(li); 1688 free_leaf_info(li);
1688 1689
1689 if(hlist_empty(&l->list)) 1690 if (hlist_empty(&l->list))
1690 trie_leaf_remove(t, key); 1691 trie_leaf_remove(t, key);
1691 1692
1692 if (fa->fa_state & FA_S_ACCESSED) 1693 if (fa->fa_state & FA_S_ACCESSED)
@@ -1705,12 +1706,12 @@ static int trie_flush_list(struct trie *t, struct list_head *head)
1705 1706
1706 list_for_each_entry_safe(fa, fa_node, head, fa_list) { 1707 list_for_each_entry_safe(fa, fa_node, head, fa_list) {
1707 struct fib_info *fi = fa->fa_info; 1708 struct fib_info *fi = fa->fa_info;
1708 1709
1709 if (fi && (fi->fib_flags&RTNH_F_DEAD)) { 1710 if (fi && (fi->fib_flags&RTNH_F_DEAD)) {
1710 1711
1711 write_lock_bh(&fib_lock); 1712 write_lock_bh(&fib_lock);
1712 list_del(&fa->fa_list); 1713 list_del(&fa->fa_list);
1713 write_unlock_bh(&fib_lock); 1714 write_unlock_bh(&fib_lock);
1714 1715
1715 fn_free_alias(fa); 1716 fn_free_alias(fa);
1716 found++; 1717 found++;
@@ -1727,14 +1728,14 @@ static int trie_flush_leaf(struct trie *t, struct leaf *l)
1727 struct leaf_info *li = NULL; 1728 struct leaf_info *li = NULL;
1728 1729
1729 hlist_for_each_entry_safe(li, node, tmp, lih, hlist) { 1730 hlist_for_each_entry_safe(li, node, tmp, lih, hlist) {
1730 1731
1731 found += trie_flush_list(t, &li->falh); 1732 found += trie_flush_list(t, &li->falh);
1732 1733
1733 if (list_empty(&li->falh)) { 1734 if (list_empty(&li->falh)) {
1734 1735
1735 write_lock_bh(&fib_lock); 1736 write_lock_bh(&fib_lock);
1736 hlist_del(&li->hlist); 1737 hlist_del(&li->hlist);
1737 write_unlock_bh(&fib_lock); 1738 write_unlock_bh(&fib_lock);
1738 1739
1739 free_leaf_info(li); 1740 free_leaf_info(li);
1740 } 1741 }
@@ -1748,8 +1749,8 @@ static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf)
1748 struct tnode *p; 1749 struct tnode *p;
1749 int idx; 1750 int idx;
1750 1751
1751 if(c == NULL) { 1752 if (c == NULL) {
1752 if(t->trie == NULL) 1753 if (t->trie == NULL)
1753 return NULL; 1754 return NULL;
1754 1755
1755 if (IS_LEAF(t->trie)) /* trie w. just a leaf */ 1756 if (IS_LEAF(t->trie)) /* trie w. just a leaf */
@@ -1757,33 +1758,34 @@ static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf)
1757 1758
1758 p = (struct tnode*) t->trie; /* Start */ 1759 p = (struct tnode*) t->trie; /* Start */
1759 } 1760 }
1760 else 1761 else
1761 p = (struct tnode *) NODE_PARENT(c); 1762 p = (struct tnode *) NODE_PARENT(c);
1763
1762 while (p) { 1764 while (p) {
1763 int pos, last; 1765 int pos, last;
1764 1766
1765 /* Find the next child of the parent */ 1767 /* Find the next child of the parent */
1766 if(c) 1768 if (c)
1767 pos = 1 + tkey_extract_bits(c->key, p->pos, p->bits); 1769 pos = 1 + tkey_extract_bits(c->key, p->pos, p->bits);
1768 else 1770 else
1769 pos = 0; 1771 pos = 0;
1770 1772
1771 last = 1 << p->bits; 1773 last = 1 << p->bits;
1772 for(idx = pos; idx < last ; idx++) { 1774 for(idx = pos; idx < last ; idx++) {
1773 if( p->child[idx]) { 1775 if (p->child[idx]) {
1774 1776
1775 /* Decend if tnode */ 1777 /* Decend if tnode */
1776 1778
1777 while (IS_TNODE(p->child[idx])) { 1779 while (IS_TNODE(p->child[idx])) {
1778 p = (struct tnode*) p->child[idx]; 1780 p = (struct tnode*) p->child[idx];
1779 idx = 0; 1781 idx = 0;
1780 1782
1781 /* Rightmost non-NULL branch */ 1783 /* Rightmost non-NULL branch */
1782 if( p && IS_TNODE(p) ) 1784 if (p && IS_TNODE(p))
1783 while ( p->child[idx] == NULL && idx < (1 << p->bits) ) idx++; 1785 while (p->child[idx] == NULL && idx < (1 << p->bits)) idx++;
1784 1786
1785 /* Done with this tnode? */ 1787 /* Done with this tnode? */
1786 if( idx >= (1 << p->bits) || p->child[idx] == NULL ) 1788 if (idx >= (1 << p->bits) || p->child[idx] == NULL )
1787 goto up; 1789 goto up;
1788 } 1790 }
1789 return (struct leaf*) p->child[idx]; 1791 return (struct leaf*) p->child[idx];
@@ -1816,7 +1818,7 @@ static int fn_trie_flush(struct fib_table *tb)
1816 if (ll && hlist_empty(&ll->list)) 1818 if (ll && hlist_empty(&ll->list))
1817 trie_leaf_remove(t, ll->key); 1819 trie_leaf_remove(t, ll->key);
1818 1820
1819 if(trie_debug) 1821 if (trie_debug)
1820 printk("trie_flush found=%d\n", found); 1822 printk("trie_flush found=%d\n", found);
1821 return found; 1823 return found;
1822} 1824}
@@ -1839,32 +1841,32 @@ fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib
1839 order = -1; 1841 order = -1;
1840 1842
1841 read_lock(&fib_lock); 1843 read_lock(&fib_lock);
1842 1844
1843 l = fib_find_node(t, 0); 1845 l = fib_find_node(t, 0);
1844 if(!l) 1846 if (!l)
1845 goto out; 1847 goto out;
1846 1848
1847 fa_head = get_fa_head(l, 0); 1849 fa_head = get_fa_head(l, 0);
1848 if(!fa_head) 1850 if (!fa_head)
1849 goto out; 1851 goto out;
1850 1852
1851 if (list_empty(fa_head)) 1853 if (list_empty(fa_head))
1852 goto out; 1854 goto out;
1853 1855
1854 list_for_each_entry(fa, fa_head, fa_list) { 1856 list_for_each_entry(fa, fa_head, fa_list) {
1855 struct fib_info *next_fi = fa->fa_info; 1857 struct fib_info *next_fi = fa->fa_info;
1856 1858
1857 if (fa->fa_scope != res->scope || 1859 if (fa->fa_scope != res->scope ||
1858 fa->fa_type != RTN_UNICAST) 1860 fa->fa_type != RTN_UNICAST)
1859 continue; 1861 continue;
1860 1862
1861 if (next_fi->fib_priority > res->fi->fib_priority) 1863 if (next_fi->fib_priority > res->fi->fib_priority)
1862 break; 1864 break;
1863 if (!next_fi->fib_nh[0].nh_gw || 1865 if (!next_fi->fib_nh[0].nh_gw ||
1864 next_fi->fib_nh[0].nh_scope != RT_SCOPE_LINK) 1866 next_fi->fib_nh[0].nh_scope != RT_SCOPE_LINK)
1865 continue; 1867 continue;
1866 fa->fa_state |= FA_S_ACCESSED; 1868 fa->fa_state |= FA_S_ACCESSED;
1867 1869
1868 if (fi == NULL) { 1870 if (fi == NULL) {
1869 if (next_fi != res->fi) 1871 if (next_fi != res->fi)
1870 break; 1872 break;
@@ -1902,10 +1904,10 @@ fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib
1902 } 1904 }
1903 trie_last_dflt = last_idx; 1905 trie_last_dflt = last_idx;
1904 out:; 1906 out:;
1905 read_unlock(&fib_lock); 1907 read_unlock(&fib_lock);
1906} 1908}
1907 1909
1908static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fib_table *tb, 1910static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fib_table *tb,
1909 struct sk_buff *skb, struct netlink_callback *cb) 1911 struct sk_buff *skb, struct netlink_callback *cb)
1910{ 1912{
1911 int i, s_i; 1913 int i, s_i;
@@ -1951,7 +1953,7 @@ static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fi
1951 return skb->len; 1953 return skb->len;
1952} 1954}
1953 1955
1954static int fn_trie_dump_plen(struct trie *t, int plen, struct fib_table *tb, struct sk_buff *skb, 1956static int fn_trie_dump_plen(struct trie *t, int plen, struct fib_table *tb, struct sk_buff *skb,
1955 struct netlink_callback *cb) 1957 struct netlink_callback *cb)
1956{ 1958{
1957 int h, s_h; 1959 int h, s_h;
@@ -1968,11 +1970,11 @@ static int fn_trie_dump_plen(struct trie *t, int plen, struct fib_table *tb, str
1968 sizeof(cb->args) - 3*sizeof(cb->args[0])); 1970 sizeof(cb->args) - 3*sizeof(cb->args[0]));
1969 1971
1970 fa_head = get_fa_head(l, plen); 1972 fa_head = get_fa_head(l, plen);
1971 1973
1972 if(!fa_head) 1974 if (!fa_head)
1973 continue; 1975 continue;
1974 1976
1975 if(list_empty(fa_head)) 1977 if (list_empty(fa_head))
1976 continue; 1978 continue;
1977 1979
1978 if (fn_trie_dump_fa(l->key, plen, fa_head, tb, skb, cb)<0) { 1980 if (fn_trie_dump_fa(l->key, plen, fa_head, tb, skb, cb)<0) {
@@ -2048,10 +2050,10 @@ struct fib_table * __init fib_hash_init(int id)
2048 2050
2049 trie_init(t); 2051 trie_init(t);
2050 2052
2051 if (id == RT_TABLE_LOCAL) 2053 if (id == RT_TABLE_LOCAL)
2052 trie_local=t; 2054 trie_local = t;
2053 else if (id == RT_TABLE_MAIN) 2055 else if (id == RT_TABLE_MAIN)
2054 trie_main=t; 2056 trie_main = t;
2055 2057
2056 if (id == RT_TABLE_LOCAL) 2058 if (id == RT_TABLE_LOCAL)
2057 printk("IPv4 FIB: Using LC-trie version %s\n", VERSION); 2059 printk("IPv4 FIB: Using LC-trie version %s\n", VERSION);
@@ -2072,7 +2074,7 @@ static void printbin_seq(struct seq_file *seq, unsigned int v, int bits)
2072 seq_printf(seq, "%s", (v & (1<<bits))?"1":"0"); 2074 seq_printf(seq, "%s", (v & (1<<bits))?"1":"0");
2073} 2075}
2074 2076
2075static void printnode_seq(struct seq_file *seq, int indent, struct node *n, 2077static void printnode_seq(struct seq_file *seq, int indent, struct node *n,
2076 int pend, int cindex, int bits) 2078 int pend, int cindex, int bits)
2077{ 2079{
2078 putspace_seq(seq, indent); 2080 putspace_seq(seq, indent);
@@ -2090,12 +2092,12 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n,
2090 seq_printf(seq, "%s:%p ", IS_LEAF(n)?"Leaf":"Internal node", n); 2092 seq_printf(seq, "%s:%p ", IS_LEAF(n)?"Leaf":"Internal node", n);
2091 2093
2092 if (IS_LEAF(n)) 2094 if (IS_LEAF(n))
2093 seq_printf(seq, "key=%d.%d.%d.%d\n", 2095 seq_printf(seq, "key=%d.%d.%d.%d\n",
2094 n->key >> 24, (n->key >> 16) % 256, (n->key >> 8) % 256, n->key % 256); 2096 n->key >> 24, (n->key >> 16) % 256, (n->key >> 8) % 256, n->key % 256);
2095 else { 2097 else {
2096 int plen=((struct tnode *)n)->pos; 2098 int plen = ((struct tnode *)n)->pos;
2097 t_key prf=MASK_PFX(n->key, plen); 2099 t_key prf=MASK_PFX(n->key, plen);
2098 seq_printf(seq, "key=%d.%d.%d.%d/%d\n", 2100 seq_printf(seq, "key=%d.%d.%d.%d/%d\n",
2099 prf >> 24, (prf >> 16) % 256, (prf >> 8) % 256, prf % 256, plen); 2101 prf >> 24, (prf >> 16) % 256, (prf >> 8) % 256, prf % 256, plen);
2100 } 2102 }
2101 if (IS_LEAF(n)) { 2103 if (IS_LEAF(n)) {
@@ -2103,14 +2105,14 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n,
2103 struct fib_alias *fa; 2105 struct fib_alias *fa;
2104 int i; 2106 int i;
2105 for (i=32; i>=0; i--) 2107 for (i=32; i>=0; i--)
2106 if(find_leaf_info(&l->list, i)) { 2108 if (find_leaf_info(&l->list, i)) {
2107 2109
2108 struct list_head *fa_head = get_fa_head(l, i); 2110 struct list_head *fa_head = get_fa_head(l, i);
2109 2111
2110 if(!fa_head) 2112 if (!fa_head)
2111 continue; 2113 continue;
2112 2114
2113 if(list_empty(fa_head)) 2115 if (list_empty(fa_head))
2114 continue; 2116 continue;
2115 2117
2116 putspace_seq(seq, indent+2); 2118 putspace_seq(seq, indent+2);
@@ -2136,7 +2138,7 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n,
2136 } 2138 }
2137 } 2139 }
2138 else if (IS_TNODE(n)) { 2140 else if (IS_TNODE(n)) {
2139 struct tnode *tn=(struct tnode *)n; 2141 struct tnode *tn = (struct tnode *)n;
2140 putspace_seq(seq, indent); seq_printf(seq, "| "); 2142 putspace_seq(seq, indent); seq_printf(seq, "| ");
2141 seq_printf(seq, "{key prefix=%08x/", tn->key&TKEY_GET_MASK(0, tn->pos)); 2143 seq_printf(seq, "{key prefix=%08x/", tn->key&TKEY_GET_MASK(0, tn->pos));
2142 printbin_seq(seq, tkey_extract_bits(tn->key, 0, tn->pos), tn->pos); 2144 printbin_seq(seq, tkey_extract_bits(tn->key, 0, tn->pos), tn->pos);
@@ -2152,7 +2154,7 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n,
2152 2154
2153static void trie_dump_seq(struct seq_file *seq, struct trie *t) 2155static void trie_dump_seq(struct seq_file *seq, struct trie *t)
2154{ 2156{
2155 struct node *n=t->trie; 2157 struct node *n = t->trie;
2156 int cindex=0; 2158 int cindex=0;
2157 int indent=1; 2159 int indent=1;
2158 int pend=0; 2160 int pend=0;
@@ -2164,7 +2166,7 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t)
2164 if (n) { 2166 if (n) {
2165 printnode_seq(seq, indent, n, pend, cindex, 0); 2167 printnode_seq(seq, indent, n, pend, cindex, 0);
2166 if (IS_TNODE(n)) { 2168 if (IS_TNODE(n)) {
2167 struct tnode *tn=(struct tnode *)n; 2169 struct tnode *tn = (struct tnode *)n;
2168 pend = tn->pos+tn->bits; 2170 pend = tn->pos+tn->bits;
2169 putspace_seq(seq, indent); seq_printf(seq, "\\--\n"); 2171 putspace_seq(seq, indent); seq_printf(seq, "\\--\n");
2170 indent += 3; 2172 indent += 3;
@@ -2172,42 +2174,42 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t)
2172 2174
2173 while (tn && cindex < (1 << tn->bits)) { 2175 while (tn && cindex < (1 << tn->bits)) {
2174 if (tn->child[cindex]) { 2176 if (tn->child[cindex]) {
2175 2177
2176 /* Got a child */ 2178 /* Got a child */
2177 2179
2178 printnode_seq(seq, indent, tn->child[cindex], pend, cindex, tn->bits); 2180 printnode_seq(seq, indent, tn->child[cindex], pend, cindex, tn->bits);
2179 if (IS_LEAF(tn->child[cindex])) { 2181 if (IS_LEAF(tn->child[cindex])) {
2180 cindex++; 2182 cindex++;
2181 2183
2182 } 2184 }
2183 else { 2185 else {
2184 /* 2186 /*
2185 * New tnode. Decend one level 2187 * New tnode. Decend one level
2186 */ 2188 */
2187 2189
2188 depth++; 2190 depth++;
2189 n=tn->child[cindex]; 2191 n = tn->child[cindex];
2190 tn=(struct tnode *)n; 2192 tn = (struct tnode *)n;
2191 pend=tn->pos+tn->bits; 2193 pend = tn->pos+tn->bits;
2192 putspace_seq(seq, indent); seq_printf(seq, "\\--\n"); 2194 putspace_seq(seq, indent); seq_printf(seq, "\\--\n");
2193 indent+=3; 2195 indent+=3;
2194 cindex=0; 2196 cindex=0;
2195 } 2197 }
2196 } 2198 }
2197 else 2199 else
2198 cindex++; 2200 cindex++;
2199 2201
2200 /* 2202 /*
2201 * Test if we are done 2203 * Test if we are done
2202 */ 2204 */
2203 2205
2204 while (cindex >= (1 << tn->bits)) { 2206 while (cindex >= (1 << tn->bits)) {
2205 2207
2206 /* 2208 /*
2207 * Move upwards and test for root 2209 * Move upwards and test for root
2208 * pop off all traversed nodes 2210 * pop off all traversed nodes
2209 */ 2211 */
2210 2212
2211 if (NODE_PARENT(tn) == NULL) { 2213 if (NODE_PARENT(tn) == NULL) {
2212 tn = NULL; 2214 tn = NULL;
2213 n = NULL; 2215 n = NULL;
@@ -2217,8 +2219,8 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t)
2217 cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); 2219 cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits);
2218 tn = NODE_PARENT(tn); 2220 tn = NODE_PARENT(tn);
2219 cindex++; 2221 cindex++;
2220 n=(struct node *)tn; 2222 n = (struct node *)tn;
2221 pend=tn->pos+tn->bits; 2223 pend = tn->pos+tn->bits;
2222 indent-=3; 2224 indent-=3;
2223 depth--; 2225 depth--;
2224 } 2226 }
@@ -2236,36 +2238,36 @@ static struct trie_stat *trie_stat_new(void)
2236{ 2238{
2237 struct trie_stat *s = kmalloc(sizeof(struct trie_stat), GFP_KERNEL); 2239 struct trie_stat *s = kmalloc(sizeof(struct trie_stat), GFP_KERNEL);
2238 int i; 2240 int i;
2239 2241
2240 if(s) { 2242 if (s) {
2241 s->totdepth = 0; 2243 s->totdepth = 0;
2242 s->maxdepth = 0; 2244 s->maxdepth = 0;
2243 s->tnodes = 0; 2245 s->tnodes = 0;
2244 s->leaves = 0; 2246 s->leaves = 0;
2245 s->nullpointers = 0; 2247 s->nullpointers = 0;
2246 2248
2247 for(i=0; i< MAX_CHILDS; i++) 2249 for(i=0; i< MAX_CHILDS; i++)
2248 s->nodesizes[i] = 0; 2250 s->nodesizes[i] = 0;
2249 } 2251 }
2250 return s; 2252 return s;
2251} 2253}
2252 2254
2253static struct trie_stat *trie_collect_stats(struct trie *t) 2255static struct trie_stat *trie_collect_stats(struct trie *t)
2254{ 2256{
2255 struct node *n=t->trie; 2257 struct node *n = t->trie;
2256 struct trie_stat *s = trie_stat_new(); 2258 struct trie_stat *s = trie_stat_new();
2257 int cindex = 0; 2259 int cindex = 0;
2258 int indent = 1; 2260 int indent = 1;
2259 int pend = 0; 2261 int pend = 0;
2260 int depth = 0; 2262 int depth = 0;
2261 2263
2262 read_lock(&fib_lock); 2264 read_lock(&fib_lock);
2263 2265
2264 if (s) { 2266 if (s) {
2265 if (n) { 2267 if (n) {
2266 if (IS_TNODE(n)) { 2268 if (IS_TNODE(n)) {
2267 struct tnode *tn = (struct tnode *)n; 2269 struct tnode *tn = (struct tnode *)n;
2268 pend=tn->pos+tn->bits; 2270 pend = tn->pos+tn->bits;
2269 indent += 3; 2271 indent += 3;
2270 s->nodesizes[tn->bits]++; 2272 s->nodesizes[tn->bits]++;
2271 depth++; 2273 depth++;
@@ -2273,26 +2275,26 @@ static struct trie_stat *trie_collect_stats(struct trie *t)
2273 while (tn && cindex < (1 << tn->bits)) { 2275 while (tn && cindex < (1 << tn->bits)) {
2274 if (tn->child[cindex]) { 2276 if (tn->child[cindex]) {
2275 /* Got a child */ 2277 /* Got a child */
2276 2278
2277 if (IS_LEAF(tn->child[cindex])) { 2279 if (IS_LEAF(tn->child[cindex])) {
2278 cindex++; 2280 cindex++;
2279 2281
2280 /* stats */ 2282 /* stats */
2281 if (depth > s->maxdepth) 2283 if (depth > s->maxdepth)
2282 s->maxdepth = depth; 2284 s->maxdepth = depth;
2283 s->totdepth += depth; 2285 s->totdepth += depth;
2284 s->leaves++; 2286 s->leaves++;
2285 } 2287 }
2286 2288
2287 else { 2289 else {
2288 /* 2290 /*
2289 * New tnode. Decend one level 2291 * New tnode. Decend one level
2290 */ 2292 */
2291 2293
2292 s->tnodes++; 2294 s->tnodes++;
2293 s->nodesizes[tn->bits]++; 2295 s->nodesizes[tn->bits]++;
2294 depth++; 2296 depth++;
2295 2297
2296 n = tn->child[cindex]; 2298 n = tn->child[cindex];
2297 tn = (struct tnode *)n; 2299 tn = (struct tnode *)n;
2298 pend = tn->pos+tn->bits; 2300 pend = tn->pos+tn->bits;
@@ -2303,13 +2305,13 @@ static struct trie_stat *trie_collect_stats(struct trie *t)
2303 } 2305 }
2304 else { 2306 else {
2305 cindex++; 2307 cindex++;
2306 s->nullpointers++; 2308 s->nullpointers++;
2307 } 2309 }
2308 2310
2309 /* 2311 /*
2310 * Test if we are done 2312 * Test if we are done
2311 */ 2313 */
2312 2314
2313 while (cindex >= (1 << tn->bits)) { 2315 while (cindex >= (1 << tn->bits)) {
2314 2316
2315 /* 2317 /*
@@ -2317,7 +2319,7 @@ static struct trie_stat *trie_collect_stats(struct trie *t)
2317 * pop off all traversed nodes 2319 * pop off all traversed nodes
2318 */ 2320 */
2319 2321
2320 2322
2321 if (NODE_PARENT(tn) == NULL) { 2323 if (NODE_PARENT(tn) == NULL) {
2322 tn = NULL; 2324 tn = NULL;
2323 n = NULL; 2325 n = NULL;
@@ -2326,9 +2328,9 @@ static struct trie_stat *trie_collect_stats(struct trie *t)
2326 else { 2328 else {
2327 cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); 2329 cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits);
2328 tn = NODE_PARENT(tn); 2330 tn = NODE_PARENT(tn);
2329 cindex++; 2331 cindex++;
2330 n = (struct node *)tn; 2332 n = (struct node *)tn;
2331 pend=tn->pos+tn->bits; 2333 pend = tn->pos+tn->bits;
2332 indent -= 3; 2334 indent -= 3;
2333 depth--; 2335 depth--;
2334 } 2336 }
@@ -2339,7 +2341,7 @@ static struct trie_stat *trie_collect_stats(struct trie *t)
2339 } 2341 }
2340 } 2342 }
2341 2343
2342 read_unlock(&fib_lock); 2344 read_unlock(&fib_lock);
2343 return s; 2345 return s;
2344} 2346}
2345 2347
@@ -2375,7 +2377,7 @@ static void fib_triestat_seq_stop(struct seq_file *seq, void *v)
2375 2377
2376} 2378}
2377 2379
2378/* 2380/*
2379 * This outputs /proc/net/fib_triestats 2381 * This outputs /proc/net/fib_triestats
2380 * 2382 *
2381 * It always works in backward compatibility mode. 2383 * It always works in backward compatibility mode.
@@ -2401,7 +2403,7 @@ static void collect_and_show(struct trie *t, struct seq_file *seq)
2401 avdepth=0; 2403 avdepth=0;
2402 seq_printf(seq, "Aver depth: %d.%02d\n", avdepth / 100, avdepth % 100 ); 2404 seq_printf(seq, "Aver depth: %d.%02d\n", avdepth / 100, avdepth % 100 );
2403 seq_printf(seq, "Max depth: %4d\n", stat->maxdepth); 2405 seq_printf(seq, "Max depth: %4d\n", stat->maxdepth);
2404 2406
2405 seq_printf(seq, "Leaves: %d\n", stat->leaves); 2407 seq_printf(seq, "Leaves: %d\n", stat->leaves);
2406 bytes += sizeof(struct leaf) * stat->leaves; 2408 bytes += sizeof(struct leaf) * stat->leaves;
2407 seq_printf(seq, "Internal nodes: %d\n", stat->tnodes); 2409 seq_printf(seq, "Internal nodes: %d\n", stat->tnodes);
@@ -2413,7 +2415,7 @@ static void collect_and_show(struct trie *t, struct seq_file *seq)
2413 max--; 2415 max--;
2414 pointers = 0; 2416 pointers = 0;
2415 2417
2416 for (i = 1; i <= max; i++) 2418 for (i = 1; i <= max; i++)
2417 if (stat->nodesizes[i] != 0) { 2419 if (stat->nodesizes[i] != 0) {
2418 seq_printf(seq, " %d: %d", i, stat->nodesizes[i]); 2420 seq_printf(seq, " %d: %d", i, stat->nodesizes[i]);
2419 pointers += (1<<i) * stat->nodesizes[i]; 2421 pointers += (1<<i) * stat->nodesizes[i];
@@ -2444,30 +2446,30 @@ static void collect_and_show(struct trie *t, struct seq_file *seq)
2444static int fib_triestat_seq_show(struct seq_file *seq, void *v) 2446static int fib_triestat_seq_show(struct seq_file *seq, void *v)
2445{ 2447{
2446 char bf[128]; 2448 char bf[128];
2447 2449
2448 if (v == SEQ_START_TOKEN) { 2450 if (v == SEQ_START_TOKEN) {
2449 seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", 2451 seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n",
2450 sizeof(struct leaf), sizeof(struct tnode)); 2452 sizeof(struct leaf), sizeof(struct tnode));
2451 if (trie_local) 2453 if (trie_local)
2452 collect_and_show(trie_local, seq); 2454 collect_and_show(trie_local, seq);
2453 2455
2454 if (trie_main) 2456 if (trie_main)
2455 collect_and_show(trie_main, seq); 2457 collect_and_show(trie_main, seq);
2456 } 2458 }
2457 else { 2459 else {
2458 snprintf(bf, sizeof(bf), 2460 snprintf(bf, sizeof(bf),
2459 "*\t%08X\t%08X", 200, 400); 2461 "*\t%08X\t%08X", 200, 400);
2460 2462
2461 seq_printf(seq, "%-127s\n", bf); 2463 seq_printf(seq, "%-127s\n", bf);
2462 } 2464 }
2463 return 0; 2465 return 0;
2464} 2466}
2465 2467
2466static struct seq_operations fib_triestat_seq_ops = { 2468static struct seq_operations fib_triestat_seq_ops = {
2467 .start = fib_triestat_seq_start, 2469 .start = fib_triestat_seq_start,
2468 .next = fib_triestat_seq_next, 2470 .next = fib_triestat_seq_next,
2469 .stop = fib_triestat_seq_stop, 2471 .stop = fib_triestat_seq_stop,
2470 .show = fib_triestat_seq_show, 2472 .show = fib_triestat_seq_show,
2471}; 2473};
2472 2474
2473static int fib_triestat_seq_open(struct inode *inode, struct file *file) 2475static int fib_triestat_seq_open(struct inode *inode, struct file *file)
@@ -2479,7 +2481,7 @@ static int fib_triestat_seq_open(struct inode *inode, struct file *file)
2479 if (rc) 2481 if (rc)
2480 goto out_kfree; 2482 goto out_kfree;
2481 2483
2482 seq = file->private_data; 2484 seq = file->private_data;
2483out: 2485out:
2484 return rc; 2486 return rc;
2485out_kfree: 2487out_kfree:
@@ -2487,11 +2489,11 @@ out_kfree:
2487} 2489}
2488 2490
2489static struct file_operations fib_triestat_seq_fops = { 2491static struct file_operations fib_triestat_seq_fops = {
2490 .owner = THIS_MODULE, 2492 .owner = THIS_MODULE,
2491 .open = fib_triestat_seq_open, 2493 .open = fib_triestat_seq_open,
2492 .read = seq_read, 2494 .read = seq_read,
2493 .llseek = seq_lseek, 2495 .llseek = seq_lseek,
2494 .release = seq_release_private, 2496 .release = seq_release_private,
2495}; 2497};
2496 2498
2497int __init fib_stat_proc_init(void) 2499int __init fib_stat_proc_init(void)
@@ -2536,7 +2538,7 @@ static void fib_trie_seq_stop(struct seq_file *seq, void *v)
2536 2538
2537} 2539}
2538 2540
2539/* 2541/*
2540 * This outputs /proc/net/fib_trie. 2542 * This outputs /proc/net/fib_trie.
2541 * 2543 *
2542 * It always works in backward compatibility mode. 2544 * It always works in backward compatibility mode.
@@ -2548,10 +2550,10 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
2548 char bf[128]; 2550 char bf[128];
2549 2551
2550 if (v == SEQ_START_TOKEN) { 2552 if (v == SEQ_START_TOKEN) {
2551 if (trie_local) 2553 if (trie_local)
2552 trie_dump_seq(seq, trie_local); 2554 trie_dump_seq(seq, trie_local);
2553 2555
2554 if (trie_main) 2556 if (trie_main)
2555 trie_dump_seq(seq, trie_main); 2557 trie_dump_seq(seq, trie_main);
2556 } 2558 }
2557 2559
@@ -2565,10 +2567,10 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
2565} 2567}
2566 2568
2567static struct seq_operations fib_trie_seq_ops = { 2569static struct seq_operations fib_trie_seq_ops = {
2568 .start = fib_trie_seq_start, 2570 .start = fib_trie_seq_start,
2569 .next = fib_trie_seq_next, 2571 .next = fib_trie_seq_next,
2570 .stop = fib_trie_seq_stop, 2572 .stop = fib_trie_seq_stop,
2571 .show = fib_trie_seq_show, 2573 .show = fib_trie_seq_show,
2572}; 2574};
2573 2575
2574static int fib_trie_seq_open(struct inode *inode, struct file *file) 2576static int fib_trie_seq_open(struct inode *inode, struct file *file)
@@ -2580,7 +2582,7 @@ static int fib_trie_seq_open(struct inode *inode, struct file *file)
2580 if (rc) 2582 if (rc)
2581 goto out_kfree; 2583 goto out_kfree;
2582 2584
2583 seq = file->private_data; 2585 seq = file->private_data;
2584out: 2586out:
2585 return rc; 2587 return rc;
2586out_kfree: 2588out_kfree:
@@ -2588,11 +2590,11 @@ out_kfree:
2588} 2590}
2589 2591
2590static struct file_operations fib_trie_seq_fops = { 2592static struct file_operations fib_trie_seq_fops = {
2591 .owner = THIS_MODULE, 2593 .owner = THIS_MODULE,
2592 .open = fib_trie_seq_open, 2594 .open = fib_trie_seq_open,
2593 .read = seq_read, 2595 .read = seq_read,
2594 .llseek = seq_lseek, 2596 .llseek = seq_lseek,
2595 .release = seq_release_private, 2597 .release= seq_release_private,
2596}; 2598};
2597 2599
2598int __init fib_proc_init(void) 2600int __init fib_proc_init(void)
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 68a78731f722..c3947cd566b7 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -273,7 +273,7 @@ static void ipip_tunnel_uninit(struct net_device *dev)
273 dev_put(dev); 273 dev_put(dev);
274} 274}
275 275
276static void ipip_err(struct sk_buff *skb, void *__unused) 276static void ipip_err(struct sk_buff *skb, u32 info)
277{ 277{
278#ifndef I_WISH_WORLD_WERE_PERFECT 278#ifndef I_WISH_WORLD_WERE_PERFECT
279 279
@@ -852,11 +852,39 @@ static int __init ipip_fb_tunnel_init(struct net_device *dev)
852 return 0; 852 return 0;
853} 853}
854 854
855#ifdef CONFIG_INET_TUNNEL
855static struct xfrm_tunnel ipip_handler = { 856static struct xfrm_tunnel ipip_handler = {
856 .handler = ipip_rcv, 857 .handler = ipip_rcv,
857 .err_handler = ipip_err, 858 .err_handler = ipip_err,
858}; 859};
859 860
861static inline int ipip_register(void)
862{
863 return xfrm4_tunnel_register(&ipip_handler);
864}
865
866static inline int ipip_unregister(void)
867{
868 return xfrm4_tunnel_deregister(&ipip_handler);
869}
870#else
871static struct net_protocol ipip_protocol = {
872 .handler = ipip_rcv,
873 .err_handler = ipip_err,
874 .no_policy = 1,
875};
876
877static inline int ipip_register(void)
878{
879 return inet_add_protocol(&ipip_protocol, IPPROTO_IPIP);
880}
881
882static inline int ipip_unregister(void)
883{
884 return inet_del_protocol(&ipip_protocol, IPPROTO_IPIP);
885}
886#endif
887
860static char banner[] __initdata = 888static char banner[] __initdata =
861 KERN_INFO "IPv4 over IPv4 tunneling driver\n"; 889 KERN_INFO "IPv4 over IPv4 tunneling driver\n";
862 890
@@ -866,7 +894,7 @@ static int __init ipip_init(void)
866 894
867 printk(banner); 895 printk(banner);
868 896
869 if (xfrm4_tunnel_register(&ipip_handler) < 0) { 897 if (ipip_register() < 0) {
870 printk(KERN_INFO "ipip init: can't register tunnel\n"); 898 printk(KERN_INFO "ipip init: can't register tunnel\n");
871 return -EAGAIN; 899 return -EAGAIN;
872 } 900 }
@@ -888,13 +916,13 @@ static int __init ipip_init(void)
888 err2: 916 err2:
889 free_netdev(ipip_fb_tunnel_dev); 917 free_netdev(ipip_fb_tunnel_dev);
890 err1: 918 err1:
891 xfrm4_tunnel_deregister(&ipip_handler); 919 ipip_unregister();
892 goto out; 920 goto out;
893} 921}
894 922
895static void __exit ipip_fini(void) 923static void __exit ipip_fini(void)
896{ 924{
897 if (xfrm4_tunnel_deregister(&ipip_handler) < 0) 925 if (ipip_unregister() < 0)
898 printk(KERN_INFO "ipip close: can't deregister tunnel\n"); 926 printk(KERN_INFO "ipip close: can't deregister tunnel\n");
899 927
900 unregister_netdev(ipip_fb_tunnel_dev); 928 unregister_netdev(ipip_fb_tunnel_dev);
diff --git a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c
index a78a320eee08..01e1b58322a9 100644
--- a/net/ipv4/netfilter/ip_conntrack_amanda.c
+++ b/net/ipv4/netfilter/ip_conntrack_amanda.c
@@ -101,14 +101,13 @@ static int help(struct sk_buff **pskb,
101 if (port == 0 || len > 5) 101 if (port == 0 || len > 5)
102 break; 102 break;
103 103
104 exp = ip_conntrack_expect_alloc(); 104 exp = ip_conntrack_expect_alloc(ct);
105 if (exp == NULL) { 105 if (exp == NULL) {
106 ret = NF_DROP; 106 ret = NF_DROP;
107 goto out; 107 goto out;
108 } 108 }
109 109
110 exp->expectfn = NULL; 110 exp->expectfn = NULL;
111 exp->master = ct;
112 111
113 exp->tuple.src.ip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; 112 exp->tuple.src.ip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip;
114 exp->tuple.src.u.tcp.port = 0; 113 exp->tuple.src.u.tcp.port = 0;
@@ -126,10 +125,9 @@ static int help(struct sk_buff **pskb,
126 ret = ip_nat_amanda_hook(pskb, ctinfo, 125 ret = ip_nat_amanda_hook(pskb, ctinfo,
127 tmp - amanda_buffer, 126 tmp - amanda_buffer,
128 len, exp); 127 len, exp);
129 else if (ip_conntrack_expect_related(exp) != 0) { 128 else if (ip_conntrack_expect_related(exp) != 0)
130 ip_conntrack_expect_free(exp);
131 ret = NF_DROP; 129 ret = NF_DROP;
132 } 130 ip_conntrack_expect_put(exp);
133 } 131 }
134 132
135out: 133out:
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 4b78ebeb6635..63bf88264980 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -137,19 +137,12 @@ ip_ct_invert_tuple(struct ip_conntrack_tuple *inverse,
137 137
138 138
139/* ip_conntrack_expect helper functions */ 139/* ip_conntrack_expect helper functions */
140static void destroy_expect(struct ip_conntrack_expect *exp)
141{
142 ip_conntrack_put(exp->master);
143 IP_NF_ASSERT(!timer_pending(&exp->timeout));
144 kmem_cache_free(ip_conntrack_expect_cachep, exp);
145 CONNTRACK_STAT_INC(expect_delete);
146}
147
148static void unlink_expect(struct ip_conntrack_expect *exp) 140static void unlink_expect(struct ip_conntrack_expect *exp)
149{ 141{
150 ASSERT_WRITE_LOCK(&ip_conntrack_lock); 142 ASSERT_WRITE_LOCK(&ip_conntrack_lock);
143 IP_NF_ASSERT(!timer_pending(&exp->timeout));
151 list_del(&exp->list); 144 list_del(&exp->list);
152 /* Logically in destroy_expect, but we hold the lock here. */ 145 CONNTRACK_STAT_INC(expect_delete);
153 exp->master->expecting--; 146 exp->master->expecting--;
154} 147}
155 148
@@ -160,7 +153,7 @@ static void expectation_timed_out(unsigned long ul_expect)
160 write_lock_bh(&ip_conntrack_lock); 153 write_lock_bh(&ip_conntrack_lock);
161 unlink_expect(exp); 154 unlink_expect(exp);
162 write_unlock_bh(&ip_conntrack_lock); 155 write_unlock_bh(&ip_conntrack_lock);
163 destroy_expect(exp); 156 ip_conntrack_expect_put(exp);
164} 157}
165 158
166/* If an expectation for this connection is found, it gets delete from 159/* If an expectation for this connection is found, it gets delete from
@@ -198,7 +191,7 @@ static void remove_expectations(struct ip_conntrack *ct)
198 list_for_each_entry_safe(i, tmp, &ip_conntrack_expect_list, list) { 191 list_for_each_entry_safe(i, tmp, &ip_conntrack_expect_list, list) {
199 if (i->master == ct && del_timer(&i->timeout)) { 192 if (i->master == ct && del_timer(&i->timeout)) {
200 unlink_expect(i); 193 unlink_expect(i);
201 destroy_expect(i); 194 ip_conntrack_expect_put(i);
202 } 195 }
203 } 196 }
204} 197}
@@ -537,7 +530,7 @@ init_conntrack(const struct ip_conntrack_tuple *tuple,
537 if (exp) { 530 if (exp) {
538 if (exp->expectfn) 531 if (exp->expectfn)
539 exp->expectfn(conntrack, exp); 532 exp->expectfn(conntrack, exp);
540 destroy_expect(exp); 533 ip_conntrack_expect_put(exp);
541 } 534 }
542 535
543 return &conntrack->tuplehash[IP_CT_DIR_ORIGINAL]; 536 return &conntrack->tuplehash[IP_CT_DIR_ORIGINAL];
@@ -729,14 +722,14 @@ void ip_conntrack_unexpect_related(struct ip_conntrack_expect *exp)
729 if (expect_matches(i, exp) && del_timer(&i->timeout)) { 722 if (expect_matches(i, exp) && del_timer(&i->timeout)) {
730 unlink_expect(i); 723 unlink_expect(i);
731 write_unlock_bh(&ip_conntrack_lock); 724 write_unlock_bh(&ip_conntrack_lock);
732 destroy_expect(i); 725 ip_conntrack_expect_put(i);
733 return; 726 return;
734 } 727 }
735 } 728 }
736 write_unlock_bh(&ip_conntrack_lock); 729 write_unlock_bh(&ip_conntrack_lock);
737} 730}
738 731
739struct ip_conntrack_expect *ip_conntrack_expect_alloc(void) 732struct ip_conntrack_expect *ip_conntrack_expect_alloc(struct ip_conntrack *me)
740{ 733{
741 struct ip_conntrack_expect *new; 734 struct ip_conntrack_expect *new;
742 735
@@ -745,18 +738,23 @@ struct ip_conntrack_expect *ip_conntrack_expect_alloc(void)
745 DEBUGP("expect_related: OOM allocating expect\n"); 738 DEBUGP("expect_related: OOM allocating expect\n");
746 return NULL; 739 return NULL;
747 } 740 }
748 new->master = NULL; 741 new->master = me;
742 atomic_inc(&new->master->ct_general.use);
743 atomic_set(&new->use, 1);
749 return new; 744 return new;
750} 745}
751 746
752void ip_conntrack_expect_free(struct ip_conntrack_expect *expect) 747void ip_conntrack_expect_put(struct ip_conntrack_expect *exp)
753{ 748{
754 kmem_cache_free(ip_conntrack_expect_cachep, expect); 749 if (atomic_dec_and_test(&exp->use)) {
750 ip_conntrack_put(exp->master);
751 kmem_cache_free(ip_conntrack_expect_cachep, exp);
752 }
755} 753}
756 754
757static void ip_conntrack_expect_insert(struct ip_conntrack_expect *exp) 755static void ip_conntrack_expect_insert(struct ip_conntrack_expect *exp)
758{ 756{
759 atomic_inc(&exp->master->ct_general.use); 757 atomic_inc(&exp->use);
760 exp->master->expecting++; 758 exp->master->expecting++;
761 list_add(&exp->list, &ip_conntrack_expect_list); 759 list_add(&exp->list, &ip_conntrack_expect_list);
762 760
@@ -778,7 +776,7 @@ static void evict_oldest_expect(struct ip_conntrack *master)
778 if (i->master == master) { 776 if (i->master == master) {
779 if (del_timer(&i->timeout)) { 777 if (del_timer(&i->timeout)) {
780 unlink_expect(i); 778 unlink_expect(i);
781 destroy_expect(i); 779 ip_conntrack_expect_put(i);
782 } 780 }
783 break; 781 break;
784 } 782 }
@@ -810,8 +808,6 @@ int ip_conntrack_expect_related(struct ip_conntrack_expect *expect)
810 /* Refresh timer: if it's dying, ignore.. */ 808 /* Refresh timer: if it's dying, ignore.. */
811 if (refresh_timer(i)) { 809 if (refresh_timer(i)) {
812 ret = 0; 810 ret = 0;
813 /* We don't need the one they've given us. */
814 ip_conntrack_expect_free(expect);
815 goto out; 811 goto out;
816 } 812 }
817 } else if (expect_clash(i, expect)) { 813 } else if (expect_clash(i, expect)) {
@@ -881,7 +877,7 @@ void ip_conntrack_helper_unregister(struct ip_conntrack_helper *me)
881 list_for_each_entry_safe(exp, tmp, &ip_conntrack_expect_list, list) { 877 list_for_each_entry_safe(exp, tmp, &ip_conntrack_expect_list, list) {
882 if (exp->master->helper == me && del_timer(&exp->timeout)) { 878 if (exp->master->helper == me && del_timer(&exp->timeout)) {
883 unlink_expect(exp); 879 unlink_expect(exp);
884 destroy_expect(exp); 880 ip_conntrack_expect_put(exp);
885 } 881 }
886 } 882 }
887 /* Get rid of expecteds, set helpers to NULL. */ 883 /* Get rid of expecteds, set helpers to NULL. */
@@ -1111,6 +1107,9 @@ void ip_conntrack_cleanup(void)
1111 schedule(); 1107 schedule();
1112 goto i_see_dead_people; 1108 goto i_see_dead_people;
1113 } 1109 }
1110 /* wait until all references to ip_conntrack_untracked are dropped */
1111 while (atomic_read(&ip_conntrack_untracked.ct_general.use) > 1)
1112 schedule();
1114 1113
1115 kmem_cache_destroy(ip_conntrack_cachep); 1114 kmem_cache_destroy(ip_conntrack_cachep);
1116 kmem_cache_destroy(ip_conntrack_expect_cachep); 1115 kmem_cache_destroy(ip_conntrack_expect_cachep);
diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
index fea6dd2a00b6..7a3b773be3f9 100644
--- a/net/ipv4/netfilter/ip_conntrack_ftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_ftp.c
@@ -376,7 +376,7 @@ static int help(struct sk_buff **pskb,
376 fb_ptr + matchoff, matchlen, ntohl(th->seq) + matchoff); 376 fb_ptr + matchoff, matchlen, ntohl(th->seq) + matchoff);
377 377
378 /* Allocate expectation which will be inserted */ 378 /* Allocate expectation which will be inserted */
379 exp = ip_conntrack_expect_alloc(); 379 exp = ip_conntrack_expect_alloc(ct);
380 if (exp == NULL) { 380 if (exp == NULL) {
381 ret = NF_DROP; 381 ret = NF_DROP;
382 goto out; 382 goto out;
@@ -403,8 +403,7 @@ static int help(struct sk_buff **pskb,
403 networks, or the packet filter itself). */ 403 networks, or the packet filter itself). */
404 if (!loose) { 404 if (!loose) {
405 ret = NF_ACCEPT; 405 ret = NF_ACCEPT;
406 ip_conntrack_expect_free(exp); 406 goto out_put_expect;
407 goto out_update_nl;
408 } 407 }
409 exp->tuple.dst.ip = htonl((array[0] << 24) | (array[1] << 16) 408 exp->tuple.dst.ip = htonl((array[0] << 24) | (array[1] << 16)
410 | (array[2] << 8) | array[3]); 409 | (array[2] << 8) | array[3]);
@@ -419,7 +418,6 @@ static int help(struct sk_buff **pskb,
419 { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); 418 { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }});
420 419
421 exp->expectfn = NULL; 420 exp->expectfn = NULL;
422 exp->master = ct;
423 421
424 /* Now, NAT might want to mangle the packet, and register the 422 /* Now, NAT might want to mangle the packet, and register the
425 * (possibly changed) expectation itself. */ 423 * (possibly changed) expectation itself. */
@@ -428,13 +426,15 @@ static int help(struct sk_buff **pskb,
428 matchoff, matchlen, exp, &seq); 426 matchoff, matchlen, exp, &seq);
429 else { 427 else {
430 /* Can't expect this? Best to drop packet now. */ 428 /* Can't expect this? Best to drop packet now. */
431 if (ip_conntrack_expect_related(exp) != 0) { 429 if (ip_conntrack_expect_related(exp) != 0)
432 ip_conntrack_expect_free(exp);
433 ret = NF_DROP; 430 ret = NF_DROP;
434 } else 431 else
435 ret = NF_ACCEPT; 432 ret = NF_ACCEPT;
436 } 433 }
437 434
435out_put_expect:
436 ip_conntrack_expect_put(exp);
437
438out_update_nl: 438out_update_nl:
439 /* Now if this ends in \n, update ftp info. Seq may have been 439 /* Now if this ends in \n, update ftp info. Seq may have been
440 * adjusted by NAT code. */ 440 * adjusted by NAT code. */
diff --git a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c
index cd98772cc332..4a28f297d502 100644
--- a/net/ipv4/netfilter/ip_conntrack_irc.c
+++ b/net/ipv4/netfilter/ip_conntrack_irc.c
@@ -197,7 +197,7 @@ static int help(struct sk_buff **pskb,
197 continue; 197 continue;
198 } 198 }
199 199
200 exp = ip_conntrack_expect_alloc(); 200 exp = ip_conntrack_expect_alloc(ct);
201 if (exp == NULL) { 201 if (exp == NULL) {
202 ret = NF_DROP; 202 ret = NF_DROP;
203 goto out; 203 goto out;
@@ -221,16 +221,14 @@ static int help(struct sk_buff **pskb,
221 { { 0, { 0 } }, 221 { { 0, { 0 } },
222 { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); 222 { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }});
223 exp->expectfn = NULL; 223 exp->expectfn = NULL;
224 exp->master = ct;
225 if (ip_nat_irc_hook) 224 if (ip_nat_irc_hook)
226 ret = ip_nat_irc_hook(pskb, ctinfo, 225 ret = ip_nat_irc_hook(pskb, ctinfo,
227 addr_beg_p - ib_ptr, 226 addr_beg_p - ib_ptr,
228 addr_end_p - addr_beg_p, 227 addr_end_p - addr_beg_p,
229 exp); 228 exp);
230 else if (ip_conntrack_expect_related(exp) != 0) { 229 else if (ip_conntrack_expect_related(exp) != 0)
231 ip_conntrack_expect_free(exp);
232 ret = NF_DROP; 230 ret = NF_DROP;
233 } 231 ip_conntrack_expect_put(exp);
234 goto out; 232 goto out;
235 } /* for .. NUM_DCCPROTO */ 233 } /* for .. NUM_DCCPROTO */
236 } /* while data < ... */ 234 } /* while data < ... */
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
index 1dd824f3cf0a..61798c46e91d 100644
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -985,7 +985,7 @@ EXPORT_SYMBOL(ip_ct_refresh_acct);
985EXPORT_SYMBOL(ip_ct_protos); 985EXPORT_SYMBOL(ip_ct_protos);
986EXPORT_SYMBOL(ip_ct_find_proto); 986EXPORT_SYMBOL(ip_ct_find_proto);
987EXPORT_SYMBOL(ip_conntrack_expect_alloc); 987EXPORT_SYMBOL(ip_conntrack_expect_alloc);
988EXPORT_SYMBOL(ip_conntrack_expect_free); 988EXPORT_SYMBOL(ip_conntrack_expect_put);
989EXPORT_SYMBOL(ip_conntrack_expect_related); 989EXPORT_SYMBOL(ip_conntrack_expect_related);
990EXPORT_SYMBOL(ip_conntrack_unexpect_related); 990EXPORT_SYMBOL(ip_conntrack_unexpect_related);
991EXPORT_SYMBOL(ip_conntrack_tuple_taken); 991EXPORT_SYMBOL(ip_conntrack_tuple_taken);
diff --git a/net/ipv4/netfilter/ip_conntrack_tftp.c b/net/ipv4/netfilter/ip_conntrack_tftp.c
index 992fac3e36ee..f8ff170f390a 100644
--- a/net/ipv4/netfilter/ip_conntrack_tftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_tftp.c
@@ -65,7 +65,7 @@ static int tftp_help(struct sk_buff **pskb,
65 DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); 65 DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
66 DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_REPLY].tuple); 66 DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
67 67
68 exp = ip_conntrack_expect_alloc(); 68 exp = ip_conntrack_expect_alloc(ct);
69 if (exp == NULL) 69 if (exp == NULL)
70 return NF_DROP; 70 return NF_DROP;
71 71
@@ -75,17 +75,15 @@ static int tftp_help(struct sk_buff **pskb,
75 exp->mask.dst.u.udp.port = 0xffff; 75 exp->mask.dst.u.udp.port = 0xffff;
76 exp->mask.dst.protonum = 0xff; 76 exp->mask.dst.protonum = 0xff;
77 exp->expectfn = NULL; 77 exp->expectfn = NULL;
78 exp->master = ct;
79 78
80 DEBUGP("expect: "); 79 DEBUGP("expect: ");
81 DUMP_TUPLE(&exp->tuple); 80 DUMP_TUPLE(&exp->tuple);
82 DUMP_TUPLE(&exp->mask); 81 DUMP_TUPLE(&exp->mask);
83 if (ip_nat_tftp_hook) 82 if (ip_nat_tftp_hook)
84 ret = ip_nat_tftp_hook(pskb, ctinfo, exp); 83 ret = ip_nat_tftp_hook(pskb, ctinfo, exp);
85 else if (ip_conntrack_expect_related(exp) != 0) { 84 else if (ip_conntrack_expect_related(exp) != 0)
86 ip_conntrack_expect_free(exp);
87 ret = NF_DROP; 85 ret = NF_DROP;
88 } 86 ip_conntrack_expect_put(exp);
89 break; 87 break;
90 case TFTP_OPCODE_DATA: 88 case TFTP_OPCODE_DATA:
91 case TFTP_OPCODE_ACK: 89 case TFTP_OPCODE_ACK:
diff --git a/net/ipv4/netfilter/ip_nat_amanda.c b/net/ipv4/netfilter/ip_nat_amanda.c
index da1f412583ed..706c8074f422 100644
--- a/net/ipv4/netfilter/ip_nat_amanda.c
+++ b/net/ipv4/netfilter/ip_nat_amanda.c
@@ -56,10 +56,8 @@ static unsigned int help(struct sk_buff **pskb,
56 break; 56 break;
57 } 57 }
58 58
59 if (port == 0) { 59 if (port == 0)
60 ip_conntrack_expect_free(exp);
61 return NF_DROP; 60 return NF_DROP;
62 }
63 61
64 sprintf(buffer, "%u", port); 62 sprintf(buffer, "%u", port);
65 ret = ip_nat_mangle_udp_packet(pskb, exp->master, ctinfo, 63 ret = ip_nat_mangle_udp_packet(pskb, exp->master, ctinfo,
diff --git a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp.c
index c6000e794ad6..d83757a70d9f 100644
--- a/net/ipv4/netfilter/ip_nat_ftp.c
+++ b/net/ipv4/netfilter/ip_nat_ftp.c
@@ -143,10 +143,8 @@ static unsigned int ip_nat_ftp(struct sk_buff **pskb,
143 break; 143 break;
144 } 144 }
145 145
146 if (port == 0) { 146 if (port == 0)
147 ip_conntrack_expect_free(exp);
148 return NF_DROP; 147 return NF_DROP;
149 }
150 148
151 if (!mangle[type](pskb, newip, port, matchoff, matchlen, ct, ctinfo, 149 if (!mangle[type](pskb, newip, port, matchoff, matchlen, ct, ctinfo,
152 seq)) { 150 seq)) {
diff --git a/net/ipv4/netfilter/ip_nat_irc.c b/net/ipv4/netfilter/ip_nat_irc.c
index 9c1ca3381d56..de31942babe3 100644
--- a/net/ipv4/netfilter/ip_nat_irc.c
+++ b/net/ipv4/netfilter/ip_nat_irc.c
@@ -65,10 +65,8 @@ static unsigned int help(struct sk_buff **pskb,
65 break; 65 break;
66 } 66 }
67 67
68 if (port == 0) { 68 if (port == 0)
69 ip_conntrack_expect_free(exp);
70 return NF_DROP; 69 return NF_DROP;
71 }
72 70
73 /* strlen("\1DCC CHAT chat AAAAAAAA P\1\n")=27 71 /* strlen("\1DCC CHAT chat AAAAAAAA P\1\n")=27
74 * strlen("\1DCC SCHAT chat AAAAAAAA P\1\n")=28 72 * strlen("\1DCC SCHAT chat AAAAAAAA P\1\n")=28
diff --git a/net/ipv4/netfilter/ip_nat_proto_icmp.c b/net/ipv4/netfilter/ip_nat_proto_icmp.c
index a558cf0eee8a..6596c9ee1655 100644
--- a/net/ipv4/netfilter/ip_nat_proto_icmp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_icmp.c
@@ -35,16 +35,17 @@ icmp_unique_tuple(struct ip_conntrack_tuple *tuple,
35 const struct ip_conntrack *conntrack) 35 const struct ip_conntrack *conntrack)
36{ 36{
37 static u_int16_t id; 37 static u_int16_t id;
38 unsigned int range_size 38 unsigned int range_size;
39 = (unsigned int)range->max.icmp.id - range->min.icmp.id + 1;
40 unsigned int i; 39 unsigned int i;
41 40
41 range_size = ntohs(range->max.icmp.id) - ntohs(range->min.icmp.id) + 1;
42 /* If no range specified... */ 42 /* If no range specified... */
43 if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) 43 if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED))
44 range_size = 0xFFFF; 44 range_size = 0xFFFF;
45 45
46 for (i = 0; i < range_size; i++, id++) { 46 for (i = 0; i < range_size; i++, id++) {
47 tuple->src.u.icmp.id = range->min.icmp.id + (id % range_size); 47 tuple->src.u.icmp.id = htons(ntohs(range->min.icmp.id) +
48 (id % range_size));
48 if (!ip_nat_used_tuple(tuple, conntrack)) 49 if (!ip_nat_used_tuple(tuple, conntrack))
49 return 1; 50 return 1;
50 } 51 }
diff --git a/net/ipv4/netfilter/ip_nat_proto_tcp.c b/net/ipv4/netfilter/ip_nat_proto_tcp.c
index a91cfceff272..a98e36d2b3c6 100644
--- a/net/ipv4/netfilter/ip_nat_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_tcp.c
@@ -40,7 +40,8 @@ tcp_unique_tuple(struct ip_conntrack_tuple *tuple,
40 enum ip_nat_manip_type maniptype, 40 enum ip_nat_manip_type maniptype,
41 const struct ip_conntrack *conntrack) 41 const struct ip_conntrack *conntrack)
42{ 42{
43 static u_int16_t port, *portptr; 43 static u_int16_t port;
44 u_int16_t *portptr;
44 unsigned int range_size, min, i; 45 unsigned int range_size, min, i;
45 46
46 if (maniptype == IP_NAT_MANIP_SRC) 47 if (maniptype == IP_NAT_MANIP_SRC)
diff --git a/net/ipv4/netfilter/ip_nat_proto_udp.c b/net/ipv4/netfilter/ip_nat_proto_udp.c
index c669e3b5f5d0..9f66e5625664 100644
--- a/net/ipv4/netfilter/ip_nat_proto_udp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_udp.c
@@ -41,7 +41,8 @@ udp_unique_tuple(struct ip_conntrack_tuple *tuple,
41 enum ip_nat_manip_type maniptype, 41 enum ip_nat_manip_type maniptype,
42 const struct ip_conntrack *conntrack) 42 const struct ip_conntrack *conntrack)
43{ 43{
44 static u_int16_t port, *portptr; 44 static u_int16_t port;
45 u_int16_t *portptr;
45 unsigned int range_size, min, i; 46 unsigned int range_size, min, i;
46 47
47 if (maniptype == IP_NAT_MANIP_SRC) 48 if (maniptype == IP_NAT_MANIP_SRC)
diff --git a/net/ipv4/netfilter/ip_nat_tftp.c b/net/ipv4/netfilter/ip_nat_tftp.c
index 0343e0d64674..2215317c76b7 100644
--- a/net/ipv4/netfilter/ip_nat_tftp.c
+++ b/net/ipv4/netfilter/ip_nat_tftp.c
@@ -45,10 +45,8 @@ static unsigned int help(struct sk_buff **pskb,
45 exp->saved_proto.udp.port = exp->tuple.dst.u.tcp.port; 45 exp->saved_proto.udp.port = exp->tuple.dst.u.tcp.port;
46 exp->dir = IP_CT_DIR_REPLY; 46 exp->dir = IP_CT_DIR_REPLY;
47 exp->expectfn = ip_nat_follow_master; 47 exp->expectfn = ip_nat_follow_master;
48 if (ip_conntrack_expect_related(exp) != 0) { 48 if (ip_conntrack_expect_related(exp) != 0)
49 ip_conntrack_expect_free(exp);
50 return NF_DROP; 49 return NF_DROP;
51 }
52 return NF_ACCEPT; 50 return NF_ACCEPT;
53} 51}
54 52
diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c
index e1fe360ed27a..afbb0d4cc305 100644
--- a/net/ipv4/xfrm4_tunnel.c
+++ b/net/ipv4/xfrm4_tunnel.c
@@ -78,10 +78,9 @@ static int ipip_rcv(struct sk_buff *skb)
78static void ipip_err(struct sk_buff *skb, u32 info) 78static void ipip_err(struct sk_buff *skb, u32 info)
79{ 79{
80 struct xfrm_tunnel *handler = ipip_handler; 80 struct xfrm_tunnel *handler = ipip_handler;
81 u32 arg = info;
82 81
83 if (handler) 82 if (handler)
84 handler->err_handler(skb, &arg); 83 handler->err_handler(skb, info);
85} 84}
86 85
87static int ipip_init_state(struct xfrm_state *x) 86static int ipip_init_state(struct xfrm_state *x)
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index 95163cd52ae0..ab7a9124f985 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -91,7 +91,6 @@ config INET6_TUNNEL
91config IPV6_TUNNEL 91config IPV6_TUNNEL
92 tristate "IPv6: IPv6-in-IPv6 tunnel" 92 tristate "IPv6: IPv6-in-IPv6 tunnel"
93 depends on IPV6 93 depends on IPV6
94 select INET6_TUNNEL
95 ---help--- 94 ---help---
96 Support for IPv6-in-IPv6 tunnels described in RFC 2473. 95 Support for IPv6-in-IPv6 tunnels described in RFC 2473.
97 96
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index ba3b0c267f75..09613729404c 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1110,11 +1110,39 @@ ip6ip6_fb_tnl_dev_init(struct net_device *dev)
1110 return 0; 1110 return 0;
1111} 1111}
1112 1112
1113#ifdef CONFIG_INET6_TUNNEL
1113static struct xfrm6_tunnel ip6ip6_handler = { 1114static struct xfrm6_tunnel ip6ip6_handler = {
1114 .handler = ip6ip6_rcv, 1115 .handler = ip6ip6_rcv,
1115 .err_handler = ip6ip6_err, 1116 .err_handler = ip6ip6_err,
1116}; 1117};
1117 1118
1119static inline int ip6ip6_register(void)
1120{
1121 return xfrm6_tunnel_register(&ip6ip6_handler);
1122}
1123
1124static inline int ip6ip6_unregister(void)
1125{
1126 return xfrm6_tunnel_deregister(&ip6ip6_handler);
1127}
1128#else
1129static struct inet6_protocol xfrm6_tunnel_protocol = {
1130 .handler = ip6ip6_rcv,
1131 .err_handler = ip6ip6_err,
1132 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
1133};
1134
1135static inline int ip6ip6_register(void)
1136{
1137 return inet6_add_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6);
1138}
1139
1140static inline int ip6ip6_unregister(void)
1141{
1142 return inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6);
1143}
1144#endif
1145
1118/** 1146/**
1119 * ip6_tunnel_init - register protocol and reserve needed resources 1147 * ip6_tunnel_init - register protocol and reserve needed resources
1120 * 1148 *
@@ -1125,7 +1153,7 @@ static int __init ip6_tunnel_init(void)
1125{ 1153{
1126 int err; 1154 int err;
1127 1155
1128 if (xfrm6_tunnel_register(&ip6ip6_handler) < 0) { 1156 if (ip6ip6_register() < 0) {
1129 printk(KERN_ERR "ip6ip6 init: can't register tunnel\n"); 1157 printk(KERN_ERR "ip6ip6 init: can't register tunnel\n");
1130 return -EAGAIN; 1158 return -EAGAIN;
1131 } 1159 }
@@ -1144,7 +1172,7 @@ static int __init ip6_tunnel_init(void)
1144 } 1172 }
1145 return 0; 1173 return 0;
1146fail: 1174fail:
1147 xfrm6_tunnel_deregister(&ip6ip6_handler); 1175 ip6ip6_unregister();
1148 return err; 1176 return err;
1149} 1177}
1150 1178
@@ -1154,7 +1182,7 @@ fail:
1154 1182
1155static void __exit ip6_tunnel_cleanup(void) 1183static void __exit ip6_tunnel_cleanup(void)
1156{ 1184{
1157 if (xfrm6_tunnel_deregister(&ip6ip6_handler) < 0) 1185 if (ip6ip6_unregister() < 0)
1158 printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n"); 1186 printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n");
1159 1187
1160 unregister_netdev(ip6ip6_fb_tnl_dev); 1188 unregister_netdev(ip6ip6_fb_tnl_dev);
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index 750943e2d34e..5493180f0d44 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -76,7 +76,9 @@ static DECLARE_MUTEX(ipqnl_sem);
76static void 76static void
77ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict) 77ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict)
78{ 78{
79 local_bh_disable();
79 nf_reinject(entry->skb, entry->info, verdict); 80 nf_reinject(entry->skb, entry->info, verdict);
81 local_bh_enable();
80 kfree(entry); 82 kfree(entry);
81} 83}
82 84
diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c
index c44685e391b7..a692e26a4fa3 100644
--- a/net/ipv6/netfilter/ip6t_LOG.c
+++ b/net/ipv6/netfilter/ip6t_LOG.c
@@ -373,9 +373,10 @@ ip6t_log_packet(unsigned int hooknum,
373 in ? in->name : "", 373 in ? in->name : "",
374 out ? out->name : ""); 374 out ? out->name : "");
375 if (in && !out) { 375 if (in && !out) {
376 unsigned int len;
376 /* MAC logging for input chain only. */ 377 /* MAC logging for input chain only. */
377 printk("MAC="); 378 printk("MAC=");
378 if (skb->dev && skb->dev->hard_header_len && 379 if (skb->dev && (len = skb->dev->hard_header_len) &&
379 skb->mac.raw != skb->nh.raw) { 380 skb->mac.raw != skb->nh.raw) {
380 unsigned char *p = skb->mac.raw; 381 unsigned char *p = skb->mac.raw;
381 int i; 382 int i;
@@ -384,9 +385,11 @@ ip6t_log_packet(unsigned int hooknum,
384 (p -= ETH_HLEN) < skb->head) 385 (p -= ETH_HLEN) < skb->head)
385 p = NULL; 386 p = NULL;
386 387
387 if (p != NULL) 388 if (p != NULL) {
388 for (i = 0; i < skb->dev->hard_header_len; i++) 389 for (i = 0; i < len; i++)
389 printk("%02x", p[i]); 390 printk("%02x%s", p[i],
391 i == len - 1 ? "" : ":");
392 }
390 printk(" "); 393 printk(" ");
391 394
392 if (skb->dev->type == ARPHRD_SIT) { 395 if (skb->dev->type == ARPHRD_SIT) {
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 3405fdf41b93..ff774a06c89d 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -648,7 +648,8 @@ void netlink_detachskb(struct sock *sk, struct sk_buff *skb)
648 sock_put(sk); 648 sock_put(sk);
649} 649}
650 650
651static inline struct sk_buff *netlink_trim(struct sk_buff *skb, int allocation) 651static inline struct sk_buff *netlink_trim(struct sk_buff *skb,
652 unsigned int __nocast allocation)
652{ 653{
653 int delta; 654 int delta;
654 655
@@ -717,7 +718,7 @@ struct netlink_broadcast_data {
717 int failure; 718 int failure;
718 int congested; 719 int congested;
719 int delivered; 720 int delivered;
720 int allocation; 721 unsigned int allocation;
721 struct sk_buff *skb, *skb2; 722 struct sk_buff *skb, *skb2;
722}; 723};
723 724
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
index 53d98f8d3d80..00eae5f9a01a 100644
--- a/net/sched/em_meta.c
+++ b/net/sched/em_meta.c
@@ -27,17 +27,17 @@
27 * lvalue rvalue 27 * lvalue rvalue
28 * +-----------+ +-----------+ 28 * +-----------+ +-----------+
29 * | type: INT | | type: INT | 29 * | type: INT | | type: INT |
30 * def | id: INDEV | | id: VALUE | 30 * def | id: DEV | | id: VALUE |
31 * | data: | | data: 3 | 31 * | data: | | data: 3 |
32 * +-----------+ +-----------+ 32 * +-----------+ +-----------+
33 * | | 33 * | |
34 * ---> meta_ops[INT][INDEV](...) | 34 * ---> meta_ops[INT][DEV](...) |
35 * | | 35 * | |
36 * ----------- | 36 * ----------- |
37 * V V 37 * V V
38 * +-----------+ +-----------+ 38 * +-----------+ +-----------+
39 * | type: INT | | type: INT | 39 * | type: INT | | type: INT |
40 * obj | id: INDEV | | id: VALUE | 40 * obj | id: DEV | | id: VALUE |
41 * | data: 2 |<--data got filled out | data: 3 | 41 * | data: 2 |<--data got filled out | data: 3 |
42 * +-----------+ +-----------+ 42 * +-----------+ +-----------+
43 * | | 43 * | |
@@ -170,26 +170,6 @@ META_COLLECTOR(var_dev)
170 *err = var_dev(skb->dev, dst); 170 *err = var_dev(skb->dev, dst);
171} 171}
172 172
173META_COLLECTOR(int_indev)
174{
175 *err = int_dev(skb->input_dev, dst);
176}
177
178META_COLLECTOR(var_indev)
179{
180 *err = var_dev(skb->input_dev, dst);
181}
182
183META_COLLECTOR(int_realdev)
184{
185 *err = int_dev(skb->real_dev, dst);
186}
187
188META_COLLECTOR(var_realdev)
189{
190 *err = var_dev(skb->real_dev, dst);
191}
192
193/************************************************************************** 173/**************************************************************************
194 * skb attributes 174 * skb attributes
195 **************************************************************************/ 175 **************************************************************************/
@@ -229,12 +209,14 @@ META_COLLECTOR(int_maclen)
229 * Netfilter 209 * Netfilter
230 **************************************************************************/ 210 **************************************************************************/
231 211
232#ifdef CONFIG_NETFILTER
233META_COLLECTOR(int_nfmark) 212META_COLLECTOR(int_nfmark)
234{ 213{
214#ifdef CONFIG_NETFILTER
235 dst->value = skb->nfmark; 215 dst->value = skb->nfmark;
236} 216#else
217 dst->value = 0;
237#endif 218#endif
219}
238 220
239/************************************************************************** 221/**************************************************************************
240 * Traffic Control 222 * Traffic Control
@@ -245,31 +227,21 @@ META_COLLECTOR(int_tcindex)
245 dst->value = skb->tc_index; 227 dst->value = skb->tc_index;
246} 228}
247 229
248#ifdef CONFIG_NET_CLS_ACT
249META_COLLECTOR(int_tcverd)
250{
251 dst->value = skb->tc_verd;
252}
253
254META_COLLECTOR(int_tcclassid)
255{
256 dst->value = skb->tc_classid;
257}
258#endif
259
260/************************************************************************** 230/**************************************************************************
261 * Routing 231 * Routing
262 **************************************************************************/ 232 **************************************************************************/
263 233
264#ifdef CONFIG_NET_CLS_ROUTE
265META_COLLECTOR(int_rtclassid) 234META_COLLECTOR(int_rtclassid)
266{ 235{
267 if (unlikely(skb->dst == NULL)) 236 if (unlikely(skb->dst == NULL))
268 *err = -1; 237 *err = -1;
269 else 238 else
239#ifdef CONFIG_NET_CLS_ROUTE
270 dst->value = skb->dst->tclassid; 240 dst->value = skb->dst->tclassid;
271} 241#else
242 dst->value = 0;
272#endif 243#endif
244}
273 245
274META_COLLECTOR(int_rtiif) 246META_COLLECTOR(int_rtiif)
275{ 247{
@@ -505,8 +477,6 @@ struct meta_ops
505static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = { 477static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = {
506 [TCF_META_TYPE_VAR] = { 478 [TCF_META_TYPE_VAR] = {
507 [META_ID(DEV)] = META_FUNC(var_dev), 479 [META_ID(DEV)] = META_FUNC(var_dev),
508 [META_ID(INDEV)] = META_FUNC(var_indev),
509 [META_ID(REALDEV)] = META_FUNC(var_realdev),
510 [META_ID(SK_BOUND_IF)] = META_FUNC(var_sk_bound_if), 480 [META_ID(SK_BOUND_IF)] = META_FUNC(var_sk_bound_if),
511 }, 481 },
512 [TCF_META_TYPE_INT] = { 482 [TCF_META_TYPE_INT] = {
@@ -515,25 +485,15 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = {
515 [META_ID(LOADAVG_1)] = META_FUNC(int_loadavg_1), 485 [META_ID(LOADAVG_1)] = META_FUNC(int_loadavg_1),
516 [META_ID(LOADAVG_2)] = META_FUNC(int_loadavg_2), 486 [META_ID(LOADAVG_2)] = META_FUNC(int_loadavg_2),
517 [META_ID(DEV)] = META_FUNC(int_dev), 487 [META_ID(DEV)] = META_FUNC(int_dev),
518 [META_ID(INDEV)] = META_FUNC(int_indev),
519 [META_ID(REALDEV)] = META_FUNC(int_realdev),
520 [META_ID(PRIORITY)] = META_FUNC(int_priority), 488 [META_ID(PRIORITY)] = META_FUNC(int_priority),
521 [META_ID(PROTOCOL)] = META_FUNC(int_protocol), 489 [META_ID(PROTOCOL)] = META_FUNC(int_protocol),
522 [META_ID(PKTTYPE)] = META_FUNC(int_pkttype), 490 [META_ID(PKTTYPE)] = META_FUNC(int_pkttype),
523 [META_ID(PKTLEN)] = META_FUNC(int_pktlen), 491 [META_ID(PKTLEN)] = META_FUNC(int_pktlen),
524 [META_ID(DATALEN)] = META_FUNC(int_datalen), 492 [META_ID(DATALEN)] = META_FUNC(int_datalen),
525 [META_ID(MACLEN)] = META_FUNC(int_maclen), 493 [META_ID(MACLEN)] = META_FUNC(int_maclen),
526#ifdef CONFIG_NETFILTER
527 [META_ID(NFMARK)] = META_FUNC(int_nfmark), 494 [META_ID(NFMARK)] = META_FUNC(int_nfmark),
528#endif
529 [META_ID(TCINDEX)] = META_FUNC(int_tcindex), 495 [META_ID(TCINDEX)] = META_FUNC(int_tcindex),
530#ifdef CONFIG_NET_CLS_ACT
531 [META_ID(TCVERDICT)] = META_FUNC(int_tcverd),
532 [META_ID(TCCLASSID)] = META_FUNC(int_tcclassid),
533#endif
534#ifdef CONFIG_NET_CLS_ROUTE
535 [META_ID(RTCLASSID)] = META_FUNC(int_rtclassid), 496 [META_ID(RTCLASSID)] = META_FUNC(int_rtclassid),
536#endif
537 [META_ID(RTIIF)] = META_FUNC(int_rtiif), 497 [META_ID(RTIIF)] = META_FUNC(int_rtiif),
538 [META_ID(SK_FAMILY)] = META_FUNC(int_sk_family), 498 [META_ID(SK_FAMILY)] = META_FUNC(int_sk_family),
539 [META_ID(SK_STATE)] = META_FUNC(int_sk_state), 499 [META_ID(SK_STATE)] = META_FUNC(int_sk_state),
diff --git a/net/sched/em_text.c b/net/sched/em_text.c
index 873840d8d072..77beabc91fa3 100644
--- a/net/sched/em_text.c
+++ b/net/sched/em_text.c
@@ -55,9 +55,6 @@ static int em_text_change(struct tcf_proto *tp, void *data, int len,
55 struct ts_config *ts_conf; 55 struct ts_config *ts_conf;
56 int flags = 0; 56 int flags = 0;
57 57
58 printk("Configuring text: %s from %d:%d to %d:%d len %d\n", conf->algo, conf->from_offset,
59 conf->from_layer, conf->to_offset, conf->to_layer, conf->pattern_len);
60
61 if (len < sizeof(*conf) || len < (sizeof(*conf) + conf->pattern_len)) 58 if (len < sizeof(*conf) || len < (sizeof(*conf) + conf->pattern_len))
62 return -EINVAL; 59 return -EINVAL;
63 60
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 73e218e646ac..8edefd5d095d 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -331,11 +331,10 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc)
331 int prio; 331 int prio;
332 struct sk_buff_head *list = qdisc_priv(qdisc); 332 struct sk_buff_head *list = qdisc_priv(qdisc);
333 333
334 for (prio = 0; prio < PFIFO_FAST_BANDS; prio++, list++) { 334 for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
335 struct sk_buff *skb = __qdisc_dequeue_head(qdisc, list); 335 if (!skb_queue_empty(list + prio)) {
336 if (skb) {
337 qdisc->q.qlen--; 336 qdisc->q.qlen--;
338 return skb; 337 return __qdisc_dequeue_head(qdisc, list + prio);
339 } 338 }
340 } 339 }
341 340
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 5e085e041a6e..742be9171b7d 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -351,7 +351,6 @@ void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc,
351 * 351 *
352 */ 352 */
353void sctp_icmp_proto_unreachable(struct sock *sk, 353void sctp_icmp_proto_unreachable(struct sock *sk,
354 struct sctp_endpoint *ep,
355 struct sctp_association *asoc, 354 struct sctp_association *asoc,
356 struct sctp_transport *t) 355 struct sctp_transport *t)
357{ 356{
@@ -367,7 +366,6 @@ void sctp_icmp_proto_unreachable(struct sock *sk,
367/* Common lookup code for icmp/icmpv6 error handler. */ 366/* Common lookup code for icmp/icmpv6 error handler. */
368struct sock *sctp_err_lookup(int family, struct sk_buff *skb, 367struct sock *sctp_err_lookup(int family, struct sk_buff *skb,
369 struct sctphdr *sctphdr, 368 struct sctphdr *sctphdr,
370 struct sctp_endpoint **epp,
371 struct sctp_association **app, 369 struct sctp_association **app,
372 struct sctp_transport **tpp) 370 struct sctp_transport **tpp)
373{ 371{
@@ -375,11 +373,10 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb,
375 union sctp_addr daddr; 373 union sctp_addr daddr;
376 struct sctp_af *af; 374 struct sctp_af *af;
377 struct sock *sk = NULL; 375 struct sock *sk = NULL;
378 struct sctp_endpoint *ep = NULL;
379 struct sctp_association *asoc = NULL; 376 struct sctp_association *asoc = NULL;
380 struct sctp_transport *transport = NULL; 377 struct sctp_transport *transport = NULL;
381 378
382 *app = NULL; *epp = NULL; *tpp = NULL; 379 *app = NULL; *tpp = NULL;
383 380
384 af = sctp_get_af_specific(family); 381 af = sctp_get_af_specific(family);
385 if (unlikely(!af)) { 382 if (unlikely(!af)) {
@@ -394,26 +391,15 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb,
394 * packet. 391 * packet.
395 */ 392 */
396 asoc = __sctp_lookup_association(&saddr, &daddr, &transport); 393 asoc = __sctp_lookup_association(&saddr, &daddr, &transport);
397 if (!asoc) { 394 if (!asoc)
398 /* If there is no matching association, see if it matches any 395 return NULL;
399 * endpoint. This may happen for an ICMP error generated in
400 * response to an INIT_ACK.
401 */
402 ep = __sctp_rcv_lookup_endpoint(&daddr);
403 if (!ep) {
404 return NULL;
405 }
406 }
407 396
408 if (asoc) { 397 sk = asoc->base.sk;
409 sk = asoc->base.sk;
410 398
411 if (ntohl(sctphdr->vtag) != asoc->c.peer_vtag) { 399 if (ntohl(sctphdr->vtag) != asoc->c.peer_vtag) {
412 ICMP_INC_STATS_BH(ICMP_MIB_INERRORS); 400 ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
413 goto out; 401 goto out;
414 } 402 }
415 } else
416 sk = ep->base.sk;
417 403
418 sctp_bh_lock_sock(sk); 404 sctp_bh_lock_sock(sk);
419 405
@@ -423,7 +409,6 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb,
423 if (sock_owned_by_user(sk)) 409 if (sock_owned_by_user(sk))
424 NET_INC_STATS_BH(LINUX_MIB_LOCKDROPPEDICMPS); 410 NET_INC_STATS_BH(LINUX_MIB_LOCKDROPPEDICMPS);
425 411
426 *epp = ep;
427 *app = asoc; 412 *app = asoc;
428 *tpp = transport; 413 *tpp = transport;
429 return sk; 414 return sk;
@@ -432,21 +417,16 @@ out:
432 sock_put(sk); 417 sock_put(sk);
433 if (asoc) 418 if (asoc)
434 sctp_association_put(asoc); 419 sctp_association_put(asoc);
435 if (ep)
436 sctp_endpoint_put(ep);
437 return NULL; 420 return NULL;
438} 421}
439 422
440/* Common cleanup code for icmp/icmpv6 error handler. */ 423/* Common cleanup code for icmp/icmpv6 error handler. */
441void sctp_err_finish(struct sock *sk, struct sctp_endpoint *ep, 424void sctp_err_finish(struct sock *sk, struct sctp_association *asoc)
442 struct sctp_association *asoc)
443{ 425{
444 sctp_bh_unlock_sock(sk); 426 sctp_bh_unlock_sock(sk);
445 sock_put(sk); 427 sock_put(sk);
446 if (asoc) 428 if (asoc)
447 sctp_association_put(asoc); 429 sctp_association_put(asoc);
448 if (ep)
449 sctp_endpoint_put(ep);
450} 430}
451 431
452/* 432/*
@@ -471,7 +451,6 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
471 int type = skb->h.icmph->type; 451 int type = skb->h.icmph->type;
472 int code = skb->h.icmph->code; 452 int code = skb->h.icmph->code;
473 struct sock *sk; 453 struct sock *sk;
474 struct sctp_endpoint *ep;
475 struct sctp_association *asoc; 454 struct sctp_association *asoc;
476 struct sctp_transport *transport; 455 struct sctp_transport *transport;
477 struct inet_sock *inet; 456 struct inet_sock *inet;
@@ -488,7 +467,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
488 savesctp = skb->h.raw; 467 savesctp = skb->h.raw;
489 skb->nh.iph = iph; 468 skb->nh.iph = iph;
490 skb->h.raw = (char *)sh; 469 skb->h.raw = (char *)sh;
491 sk = sctp_err_lookup(AF_INET, skb, sh, &ep, &asoc, &transport); 470 sk = sctp_err_lookup(AF_INET, skb, sh, &asoc, &transport);
492 /* Put back, the original pointers. */ 471 /* Put back, the original pointers. */
493 skb->nh.raw = saveip; 472 skb->nh.raw = saveip;
494 skb->h.raw = savesctp; 473 skb->h.raw = savesctp;
@@ -515,7 +494,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
515 } 494 }
516 else { 495 else {
517 if (ICMP_PROT_UNREACH == code) { 496 if (ICMP_PROT_UNREACH == code) {
518 sctp_icmp_proto_unreachable(sk, ep, asoc, 497 sctp_icmp_proto_unreachable(sk, asoc,
519 transport); 498 transport);
520 goto out_unlock; 499 goto out_unlock;
521 } 500 }
@@ -544,7 +523,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
544 } 523 }
545 524
546out_unlock: 525out_unlock:
547 sctp_err_finish(sk, ep, asoc); 526 sctp_err_finish(sk, asoc);
548} 527}
549 528
550/* 529/*
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index c7e42d125b9c..e9b2fd480d61 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -91,7 +91,6 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
91 struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; 91 struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
92 struct sctphdr *sh = (struct sctphdr *)(skb->data + offset); 92 struct sctphdr *sh = (struct sctphdr *)(skb->data + offset);
93 struct sock *sk; 93 struct sock *sk;
94 struct sctp_endpoint *ep;
95 struct sctp_association *asoc; 94 struct sctp_association *asoc;
96 struct sctp_transport *transport; 95 struct sctp_transport *transport;
97 struct ipv6_pinfo *np; 96 struct ipv6_pinfo *np;
@@ -105,7 +104,7 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
105 savesctp = skb->h.raw; 104 savesctp = skb->h.raw;
106 skb->nh.ipv6h = iph; 105 skb->nh.ipv6h = iph;
107 skb->h.raw = (char *)sh; 106 skb->h.raw = (char *)sh;
108 sk = sctp_err_lookup(AF_INET6, skb, sh, &ep, &asoc, &transport); 107 sk = sctp_err_lookup(AF_INET6, skb, sh, &asoc, &transport);
109 /* Put back, the original pointers. */ 108 /* Put back, the original pointers. */
110 skb->nh.raw = saveip; 109 skb->nh.raw = saveip;
111 skb->h.raw = savesctp; 110 skb->h.raw = savesctp;
@@ -124,7 +123,7 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
124 goto out_unlock; 123 goto out_unlock;
125 case ICMPV6_PARAMPROB: 124 case ICMPV6_PARAMPROB:
126 if (ICMPV6_UNK_NEXTHDR == code) { 125 if (ICMPV6_UNK_NEXTHDR == code) {
127 sctp_icmp_proto_unreachable(sk, ep, asoc, transport); 126 sctp_icmp_proto_unreachable(sk, asoc, transport);
128 goto out_unlock; 127 goto out_unlock;
129 } 128 }
130 break; 129 break;
@@ -142,7 +141,7 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
142 } 141 }
143 142
144out_unlock: 143out_unlock:
145 sctp_err_finish(sk, ep, asoc); 144 sctp_err_finish(sk, asoc);
146out: 145out:
147 if (likely(idev != NULL)) 146 if (likely(idev != NULL))
148 in6_dev_put(idev); 147 in6_dev_put(idev);
diff --git a/net/sctp/objcnt.c b/net/sctp/objcnt.c
index 0781e5d509fd..8ff588f0d76a 100644
--- a/net/sctp/objcnt.c
+++ b/net/sctp/objcnt.c
@@ -127,8 +127,12 @@ done:
127/* Initialize the objcount in the proc filesystem. */ 127/* Initialize the objcount in the proc filesystem. */
128void sctp_dbg_objcnt_init(void) 128void sctp_dbg_objcnt_init(void)
129{ 129{
130 create_proc_read_entry("sctp_dbg_objcnt", 0, proc_net_sctp, 130 struct proc_dir_entry *ent;
131 ent = create_proc_read_entry("sctp_dbg_objcnt", 0, proc_net_sctp,
131 sctp_dbg_objcnt_read, NULL); 132 sctp_dbg_objcnt_read, NULL);
133 if (!ent)
134 printk(KERN_WARNING
135 "sctp_dbg_objcnt: Unable to create /proc entry.\n");
132} 136}
133 137
134/* Cleanup the objcount entry in the proc filesystem. */ 138/* Cleanup the objcount entry in the proc filesystem. */