From 9d853c3757ef74ded5ae564d68370f22208fb88b Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 15 Jul 2005 07:41:31 -0700 Subject: [PATCH 01/66] [CRYPTO]: Fix zero-extension bug on 64-bit architectures. Noticed by Ken-ichirou MATSUZAWA. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- crypto/cipher.c | 6 +++--- crypto/internal.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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, struct scatter_walk *in, struct scatter_walk *out, unsigned int bsize) { - unsigned int alignmask = crypto_tfm_alg_alignmask(desc->tfm); + unsigned long alignmask = crypto_tfm_alg_alignmask(desc->tfm); u8 buffer[bsize * 2 + alignmask]; u8 *src = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1); u8 *dst = src + bsize; @@ -160,7 +160,7 @@ static int crypt_iv_unaligned(struct cipher_desc *desc, unsigned int nbytes) { struct crypto_tfm *tfm = desc->tfm; - unsigned int alignmask = crypto_tfm_alg_alignmask(tfm); + unsigned long alignmask = crypto_tfm_alg_alignmask(tfm); u8 *iv = desc->info; if (unlikely(((unsigned long)iv & alignmask))) { @@ -424,7 +424,7 @@ int crypto_init_cipher_ops(struct crypto_tfm *tfm) } if (ops->cit_mode == CRYPTO_TFM_MODE_CBC) { - unsigned int align; + unsigned long align; unsigned long addr; 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, switch (flags & CRYPTO_TFM_MODE_MASK) { case CRYPTO_TFM_MODE_CBC: - len = ALIGN(len, alg->cra_alignmask + 1); + len = ALIGN(len, (unsigned long)alg->cra_alignmask + 1); len += alg->cra_blocksize; break; } From a8178345c4f12f4413e5620fc86a6b0381c41bc9 Mon Sep 17 00:00:00 2001 From: Marcelo Feitoza Parisi Date: Fri, 15 Jul 2005 09:59:26 -0700 Subject: [PATCH 02/66] [WAN]: drivers/net/wan/: use of time_after macro From: Marcelo Feitoza Parisi Use of the time_after() macro, defined at linux/jiffies.h, which deal with wrapping correctly and are nicer to read. Signed-off-by: Marcelo Feitoza Parisi Signed-off-by: Domen Puncer Signed-off-by: David S. Miller --- drivers/net/wan/sdla_fr.c | 7 ++++--- drivers/net/wan/sdla_ft1.c | 3 ++- drivers/net/wan/sdla_ppp.c | 3 ++- drivers/net/wan/sdla_x25.c | 3 ++- drivers/net/wan/wanpipe_multppp.c | 9 +++++---- 5 files changed, 15 insertions(+), 10 deletions(-) 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 @@ #include /* for inb(), outb(), etc. */ #include /* for do_gettimeofday */ #include /* sockaddr_in */ +#include /* time_after() macro */ #include #include @@ -773,7 +774,7 @@ static int update(struct wan_device* wandev) for(;;) { if(card->u.f.update_comms_stats == 0) break; - if ((jiffies - timeout) > (1 * HZ)){ + if (time_after(jiffies, timeout + 1 * HZ)){ card->u.f.update_comms_stats = 0; return -EAGAIN; } @@ -4799,7 +4800,7 @@ static void trigger_unconfig_fr(struct net_device *dev) { fr_channel_t *chan = dev->priv; volatile sdla_t *card = chan->card; - u32 timeout; + unsigned long timeout; fr508_flags_t* flags = card->flags; int reset_critical=0; @@ -4821,7 +4822,7 @@ static void trigger_unconfig_fr(struct net_device *dev) if(!(card->u.f.timer_int_enabled & TMR_INT_ENABLED_UNCONFIG)) break; - if ((jiffies - timeout) > (1 * HZ)){ + if (time_after(jiffies, timeout + 1 * HZ)){ card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_UNCONFIG; printk(KERN_INFO "%s: Failed to delete DLCI %i\n", 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 @@ #include /* WAN router definitions */ #include /* WANPIPE common user API definitions */ #include /* ARPHRD_* defines */ +#include /* time_after() macro */ #include #include @@ -164,7 +165,7 @@ int wpft1_init (sdla_t* card, wandev_conf_t* conf) timeout = jiffies; while (mb->return_code != 'I') /* Wait 1s for board to initialize */ - if ((jiffies - timeout) > 1*HZ) break; + if (time_after(jiffies, timeout + 1*HZ)) break; if (mb->return_code != 'I') { 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 @@ #include /* ARPHRD_* defines */ #include /* htons(), etc. */ #include /* sockaddr_in */ +#include /* time_after() macro */ #include @@ -482,7 +483,7 @@ static int update(struct wan_device *wandev) if(ppp_priv_area->update_comms_stats == 0){ break; } - if ((jiffies - timeout) > (1 * HZ)){ + if (time_after(jiffies, timeout + 1 * HZ)){ ppp_priv_area->update_comms_stats = 0; ppp_priv_area->timer_int_enabled &= ~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 @@ #include /* WAN router definitions */ #include /* WANPIPE common user API definitions */ #include +#include /* time_after() macro */ #include /* htons(), etc. */ #include #include /* Experimental delay */ @@ -867,7 +868,7 @@ static int update(struct wan_device* wandev) if (!(card->u.x.timer_int_enabled & TMR_INT_ENABLED_UPDATE)){ break; } - if ((jiffies-timeout) > 1*HZ){ + if (time_after(jiffies, timeout + 1*HZ)){ card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE; return -EAGAIN; } 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 @@ #include /* WAN router definitions */ #include /* WANPIPE common user API definitions */ #include /* ARPHRD_* defines */ +#include /* time_after() macro */ #include /* sockaddr_in */ #include @@ -270,9 +271,9 @@ int wsppp_init (sdla_t* card, wandev_conf_t* conf) ready to accept commands. We expect this to be completed in less than 1 second. */ - timeout = jiffies; + timeout = jiffies + 1 * HZ; while (mb->return_code != 'I') /* Wait 1s for board to initialize */ - if ((jiffies - timeout) > 1*HZ) break; + if (time_after(jiffies, timeout)) break; if (mb->return_code != 'I') { printk(KERN_INFO @@ -493,11 +494,11 @@ static int update(struct wan_device* wandev) chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UPDATE; /* wait a maximum of 1 second for the statistics to be updated */ - timeout = jiffies; + timeout = jiffies + 1 * HZ; for(;;) { if(chdlc_priv_area->update_comms_stats == 0) break; - if ((jiffies - timeout) > (1 * HZ)){ + if (time_after(jiffies, timeout)){ chdlc_priv_area->update_comms_stats = 0; chdlc_priv_area->timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE; From 4851d3aaa550b7b62553dd19fcadc7b586da4f17 Mon Sep 17 00:00:00 2001 From: Marcelo Feitoza Parisi Date: Fri, 15 Jul 2005 10:00:41 -0700 Subject: [PATCH 03/66] [NET PCMCIA]: drivers/net/pcmcia/smc91c92_cs.c : Use of time_after macro From: Marcelo Feitoza Parisi Use of the time_after() macro, defined at linux/jiffies.h, which deal with wrapping correctly and are nicer to read. Signed-off-by: Marcelo Feitoza Parisi Signed-off-by: Domen Puncer Signed-off-by: David S. Miller --- drivers/net/pcmcia/smc91c92_cs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 @@ #include #include #include +#include #include #include @@ -2092,7 +2093,7 @@ static void media_check(u_long arg) } /* Ignore collisions unless we've had no rx's recently */ - if (jiffies - dev->last_rx > HZ) { + if (time_after(jiffies, dev->last_rx + HZ)) { if (smc->tx_err || (smc->media_status & EPH_16COL)) media |= EPH_16COL; } From b66da4a4859b0be3f12575863bf1d873116d1947 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 17 Jul 2005 10:54:50 +0100 Subject: [PATCH 04/66] [PATCH] ARM: Remove global nwfpe register variable Recent changes to nwfpe broke the build with some gcc versions: In file included from arch/arm/nwfpe/softfloat.c:33: arch/arm/nwfpe/fpa11.h:32: global register variable follows a function definition make[1]: *** [arch/arm/nwfpe/softfloat.o] Error 1 Since we now ensure that the kernel stack is empty when returning to user space, we can now access the userspace registers with reference to the kernel stack using current_thread_info(), rather than remembering the stack pointer at the time nwfpe was called. Signed-off-by: Russell King --- arch/arm/nwfpe/fpa11.h | 4 +--- arch/arm/nwfpe/fpmodule.c | 2 +- arch/arm/nwfpe/fpmodule.inl | 14 +++++++------- 3 files changed, 9 insertions(+), 11 deletions(-) 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 @@ * stack+task struct. Use the same method as 'current' uses to * reach them. */ -register unsigned long *user_registers asm("sl"); - -#define GET_USERREG() (user_registers) +#define GET_USERREG() ((struct pt_regs *)(THREAD_START_SP + (unsigned long)current_thread_info()) - 1) #include #include 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) printk(KERN_DEBUG "NWFPE: %s[%d] takes exception %08x at %p from %08lx\n", current->comm, current->pid, flags, - __builtin_return_address(0), GET_USERREG()[15]); + __builtin_return_address(0), GET_USERREG()->ARM_pc); #endif /* 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) for this in this routine. LDF/STF instructions with Rn = PC depend on the PC being correct, as they use PC+8 in their address calculations. */ - unsigned long *userRegisters = GET_USERREG(); - unsigned int val = userRegisters[nReg]; + struct pt_regs *regs = GET_USERREG(); + unsigned int val = regs->uregs[nReg]; if (REG_PC == nReg) val -= 4; return val; @@ -38,8 +38,8 @@ static inline unsigned long readRegister(const unsigned int nReg) static inline void writeRegister(const unsigned int nReg, const unsigned long val) { - unsigned long *userRegisters = GET_USERREG(); - userRegisters[nReg] = val; + struct pt_regs *regs = GET_USERREG(); + regs->uregs[nReg] = val; } static inline unsigned long readCPSR(void) @@ -63,12 +63,12 @@ static inline unsigned long readConditionCodes(void) static inline void writeConditionCodes(const unsigned long val) { - unsigned long *userRegisters = GET_USERREG(); + struct pt_regs *regs = GET_USERREG(); unsigned long rval; /* * Operate directly on userRegisters since * the CPSR may be the PC register itself. */ - rval = userRegisters[REG_CPSR] & ~CC_MASK; - userRegisters[REG_CPSR] = rval | (val & CC_MASK); + rval = regs->ARM_cpsr & ~CC_MASK; + regs->ARM_cpsr = rval | (val & CC_MASK); } From 246b49768bc96d942ab0e2a17aab6fc3d2e011da Mon Sep 17 00:00:00 2001 From: Alexander Schulz Date: Sun, 17 Jul 2005 20:12:08 +0100 Subject: [PATCH 05/66] [PATCH] ARM: 2816/1: Shark: boot kernel images bigger than 1 MB Patch from Alexander Schulz Up to now, shark kernels were limited to one megabyte compressed size. As the kernels get bigger, this becomes more and more uncomfortable. So I added a loop to copy 3 MB instead of one and added some comments. Signed-off-by: Alexander Schulz Signed-off-by: Russell King --- arch/arm/boot/compressed/head-shark.S | 42 +++++++++++++++++++++------ 1 file changed, 33 insertions(+), 9 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 mov pc, r2 -__copy_target: .long 0x08508000 -__copy_end: .long 0x08608000 +__copy_target: .long 0x08507FFC +__copy_end: .long 0x08607FFC .word _start .word __bss_start @@ -73,9 +73,10 @@ __copy_end: .long 0x08608000 __temp_stack: .space 128 __mmu_off: - adr r0, __ofw_data + adr r0, __ofw_data @ read the 1. entry of the memory map ldr r0, [r0, #4] orr r0, r0, #0x00600000 + sub r0, r0, #4 ldr r1, __copy_end ldr r3, __copy_target @@ -89,20 +90,43 @@ __mmu_off: * from 0x08500000 to 0x08508000 if we have only 8MB */ +/* As we get more 2.6-kernels it gets more and more + * uncomfortable to be bound to kernel images of 1MB only. + * So we add a loop here, to be able to copy some more. + * Alexander Schulz 2005-07-17 + */ + + mov r4, #3 @ How many megabytes to copy + + +__MoveCode: sub r4, r4, #1 __Copy: ldr r2, [r0], #-4 str r2, [r1], #-4 teq r1, r3 bne __Copy + + /* The firmware maps us in blocks of 1 MB, the next block is + _below_ the last one. So our decrementing source pointer + ist right here, but the destination pointer must be increased + by 2 MB */ + add r1, r1, #0x00200000 + add r3, r3, #0x00100000 + + teq r4, #0 + bne __MoveCode + + /* and jump to it */ - adr r2, __go_on - adr r0, __ofw_data + adr r2, __go_on @ where we want to jump + adr r0, __ofw_data @ read the 1. entry of the memory map ldr r0, [r0, #4] - sub r2, r2, r0 - sub r2, r2, #0x00500000 - ldr r0, __copy_target + sub r2, r2, r0 @ we are mapped add 0e50 now, sub that (-0e00) + sub r2, r2, #0x00500000 @ -0050 + ldr r0, __copy_target @ and add 0850 8000 instead + add r0, r0, #4 add r2, r2, r0 - mov pc, r2 + mov pc, r2 @ and jump there __go_on: adr sp, __temp_stack From 772a9e631ccad0423ed6d08acb3a4b1084ae2613 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Sun, 17 Jul 2005 20:15:36 +0100 Subject: [PATCH 06/66] [PATCH] ARM: 2687/1: i.MX framebuffer: make dmacr register platform configurable Patch from Sascha Hauer The dmacr needs different settings on some boards. This patch makes the register configurable by the platform part. Also we have imxfb_disable_controller(), so lets use it. Signed-off-by: Steven Scholz Signed-off-by: Sascha Hauer Signed-off-by: Russell King --- drivers/video/imxfb.c | 14 +++++++------- drivers/video/imxfb.h | 1 + include/asm-arm/arch-imx/imxfb.h | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) 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) /* disable hardware cursor */ LCDC_CPOS &= ~(CPOS_CC0 | CPOS_CC1); - /* fixed burst length (see erratum 11) */ - LCDC_DMACR = DMACR_BURST | DMACR_HM(8) | DMACR_TM(2); - LCDC_RMCR = RMCR_LCDC_EN; if(fbi->backlight_power) @@ -359,6 +356,7 @@ static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *inf LCDC_PCR = fbi->pcr; LCDC_PWMR = fbi->pwmr; LCDC_LSCR1 = fbi->lscr1; + LCDC_DMACR = fbi->dmacr; return 0; } @@ -509,6 +507,7 @@ static int __init imxfb_init_fbinfo(struct device *dev) fbi->cmap_inverse = inf->cmap_inverse; fbi->pcr = inf->pcr; fbi->lscr1 = inf->lscr1; + fbi->dmacr = inf->dmacr; fbi->pwmr = inf->pwmr; fbi->lcd_power = inf->lcd_power; fbi->backlight_power = inf->backlight_power; @@ -642,12 +641,12 @@ static int imxfb_remove(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct fb_info *info = dev_get_drvdata(dev); + struct imxfb_info *fbi = info->par; struct resource *res; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - /* disable LCD controller */ - LCDC_RMCR &= ~RMCR_LCDC_EN; + imxfb_disable_controller(fbi); unregister_framebuffer(info); @@ -663,8 +662,9 @@ static int imxfb_remove(struct device *dev) void imxfb_shutdown(struct device * dev) { - /* disable LCD Controller */ - LCDC_RMCR &= ~RMCR_LCDC_EN; + struct fb_info *info = dev_get_drvdata(dev); + struct imxfb_info *fbi = info->par; + imxfb_disable_controller(fbi); } static 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 { u_int pcr; u_int pwmr; u_int lscr1; + u_int dmacr; u_int cmap_inverse:1, cmap_static:1, unused:30; 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 { u_int pcr; u_int pwmr; u_int lscr1; + u_int dmacr; u_char * fixed_screen_cpu; dma_addr_t fixed_screen_dma; From bd6f68af298cab4e059f8489b56e46ae36243fcc Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 17 Jul 2005 21:35:41 +0100 Subject: [PATCH 07/66] [PATCH] ARM SMP: Mark CPU init functions/data with __cpuinit/...data Signed-off-by: Russell King --- arch/arm/kernel/smp.c | 6 +++--- arch/arm/mach-integrator/platsmp.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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 { static struct smp_call_struct * volatile smp_call_function_data; static DEFINE_SPINLOCK(smp_call_function_lock); -int __init __cpu_up(unsigned int cpu) +int __cpuinit __cpu_up(unsigned int cpu) { struct task_struct *idle; pgd_t *pgd; @@ -159,7 +159,7 @@ int __init __cpu_up(unsigned int cpu) * This is the secondary CPU boot entry. We're using this CPUs * idle thread stack, but a set of temporary page tables. */ -asmlinkage void __init secondary_start_kernel(void) +asmlinkage void __cpuinit secondary_start_kernel(void) { struct mm_struct *mm = &init_mm; unsigned int cpu = smp_processor_id(); @@ -209,7 +209,7 @@ asmlinkage void __init secondary_start_kernel(void) * Called by both boot and secondaries to move global data into * per-processor storage. */ -void __init smp_store_cpu_info(unsigned int cpuid) +void __cpuinit smp_store_cpu_info(unsigned int cpuid) { struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid); diff --git a/arch/arm/mach-integrator/platsmp.c b/arch/arm/mach-integrator/platsmp.c index 2ba025777098..c8eef97d0c16 100644 --- a/arch/arm/mach-integrator/platsmp.c +++ b/arch/arm/mach-integrator/platsmp.c @@ -32,7 +32,7 @@ unsigned long __initdata phys_pen_release = 0; static DEFINE_SPINLOCK(boot_lock); -void __init platform_secondary_init(unsigned int cpu) +void __cpuinit platform_secondary_init(unsigned int cpu) { /* * the primary core may have used a "cross call" soft interrupt @@ -61,7 +61,7 @@ void __init platform_secondary_init(unsigned int cpu) spin_unlock(&boot_lock); } -int __init boot_secondary(unsigned int cpu, struct task_struct *idle) +int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned long timeout; From 65cc3370ef3fb56b9b423f282a8204f8cce66e32 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Mon, 18 Jul 2005 10:24:32 +0100 Subject: [PATCH 08/66] [PATCH] ARM: 2818/1: BAST - Use platform device for SuperIO 16550s Patch from Ben Dooks Use platform device for the 16500 UARTs in the onboard SuperIO controller. Signed-off-by: Ben Dooks Signed-off-by: Russell King --- arch/arm/configs/bast_defconfig | 1 - arch/arm/configs/s3c2410_defconfig | 1 - arch/arm/mach-s3c2410/mach-bast.c | 37 ++++++++++++++ drivers/serial/Kconfig | 7 --- drivers/serial/Makefile | 1 - drivers/serial/bast_sio.c | 80 ------------------------------ 6 files changed, 37 insertions(+), 90 deletions(-) delete mode 100644 drivers/serial/bast_sio.c 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 # CONFIG_SERIAL_S3C2410=y CONFIG_SERIAL_S3C2410_CONSOLE=y -CONFIG_SERIAL_BAST_SIO=y CONFIG_SERIAL_CORE=y CONFIG_SERIAL_CORE_CONSOLE=y CONFIG_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 # CONFIG_SERIAL_S3C2410=y CONFIG_SERIAL_S3C2410_CONSOLE=y -CONFIG_SERIAL_BAST_SIO=y CONFIG_SERIAL_CORE=y CONFIG_SERIAL_CORE_CONSOLE=y CONFIG_UNIX98_PTYS=y 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 @@ * 14-Mar-2006 BJD Updated for __iomem changes * 22-Jun-2006 BJD Added DM9000 platform information * 28-Jun-2006 BJD Moved pm functionality out to common code + * 17-Jul-2006 BJD Changed to platform device for SuperIO 16550s */ #include @@ -64,6 +65,8 @@ #include #include +#include + #include "clock.h" #include "devs.h" #include "cpu.h" @@ -351,6 +354,39 @@ static struct platform_device bast_device_dm9k = { } }; +/* serial devices */ + +#define SERIAL_BASE (S3C2410_CS2 + BAST_PA_SUPERIO) +#define SERIAL_FLAGS (UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ) +#define SERIAL_CLK (1843200) + +static struct plat_serial8250_port bast_sio_data[] = { + [0] = { + .mapbase = SERIAL_BASE + 0x2f8, + .irq = IRQ_PCSERIAL1, + .flags = SERIAL_FLAGS, + .iotype = UPIO_MEM, + .regshift = 0, + .uartclk = SERIAL_CLK, + }, + [1] = { + .mapbase = SERIAL_BASE + 0x3f8, + .irq = IRQ_PCSERIAL2, + .flags = SERIAL_FLAGS, + .iotype = UPIO_MEM, + .regshift = 0, + .uartclk = SERIAL_CLK, + }, + { } +}; + +static struct platform_device bast_sio = { + .name = "serial8250", + .id = 0, + .dev = { + .platform_data = &bast_sio_data, + }, +}; /* Standard BAST devices */ @@ -364,6 +400,7 @@ static struct platform_device *bast_devices[] __initdata = { &s3c_device_nand, &bast_device_nor, &bast_device_dm9k, + &bast_sio, }; static struct clk *bast_clocks[] = { 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 your boot loader about how to pass options to the kernel at boot time.) -config SERIAL_BAST_SIO - bool "Support for BAST SuperIO serial ports" - depends on ARCH_BAST && SERIAL_8250=y - help - Support for registerin the SuperIO chip on BAST board with - the 8250/16550 uart code. - config SERIAL_DZ bool "DECstation DZ serial driver" 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 obj-$(CONFIG_SERIAL_AU1X00) += au1x00_uart.o obj-$(CONFIG_SERIAL_DZ) += dz.o obj-$(CONFIG_SERIAL_SH_SCI) += sh-sci.o -obj-$(CONFIG_SERIAL_BAST_SIO) += bast_sio.o obj-$(CONFIG_SERIAL_SGI_L1_CONSOLE) += sn_console.o obj-$(CONFIG_SERIAL_CPM) += cpm_uart/ obj-$(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 @@ -/* linux/drivers/serial/bast_sio.c - * - * Copyright (c) 2004 Simtec Electronics - * Ben Dooks - * - * http://www.simtec.co.uk/products/EB2410ITX/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * Modifications: - * 23-Sep-2004 BJD Added copyright header - * 23-Sep-2004 BJD Added serial port remove code -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -static int __init serial_bast_register(unsigned long port, unsigned int irq) -{ - struct serial_struct serial_req; - - serial_req.flags = UPF_AUTOPROBE | UPF_SHARE_IRQ; - serial_req.baud_base = BASE_BAUD; - serial_req.irq = irq; - serial_req.io_type = UPIO_MEM; - serial_req.iomap_base = port; - serial_req.iomem_base = ioremap(port, 0x10); - serial_req.iomem_reg_shift = 0; - - return register_serial(&serial_req); -} - -#define SERIAL_BASE (S3C2410_CS2 + BAST_PA_SUPERIO) - -static int port[2] = { -1, -1 }; - -static int __init serial_bast_init(void) -{ - if (machine_is_bast()) { - port[0] = serial_bast_register(SERIAL_BASE + 0x2f8, IRQ_PCSERIAL1); - port[1] = serial_bast_register(SERIAL_BASE + 0x3f8, IRQ_PCSERIAL2); - } - - return 0; -} - -static void __exit serial_bast_exit(void) -{ - if (port[0] != -1) - unregister_serial(port[0]); - if (port[1] != -1) - unregister_serial(port[1]); -} - - -module_init(serial_bast_init); -module_exit(serial_bast_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Ben Dooks, ben@simtec.co.uk"); -MODULE_DESCRIPTION("BAST Onboard Serial setup"); - - From fbc0dc0df54be06586d712ebf6958816e3b1b2b7 Mon Sep 17 00:00:00 2001 From: Andrey Panin Date: Mon, 18 Jul 2005 11:38:09 +0100 Subject: [PATCH 09/66] [PATCH] Serial: Add support for SIIG Quartet serial card Add support for SIIG Quartet Serial card. This card has Oxford Semiconducor 16954 quad UART which is clocked by 10x faster (18.432 MHz) quartz. Signed-off-by: Andrey Panin Signed-off-by: Andrew Morton Signed-off-by: Russell King --- drivers/serial/8250_pci.c | 14 ++++++++++++++ include/linux/pci_ids.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index de54bdc5398b..c3f55f5a38de 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) * - 10x cards have control registers in IO and/or memory space; * - 20x cards have control registers in standard PCI configuration space. * + * There are also Quartet Serial cards which use Oxford Semiconductor + * 16954 quad UART PCI chip clocked by 18.432 MHz quartz. + * * Note: some SIIG cards are probed by the parport_serial object. */ @@ -1026,6 +1029,8 @@ enum pci_board_num_t { pbn_b0_2_921600, pbn_b0_4_921600, + pbn_b0_4_1152000, + pbn_b0_bt_1_115200, pbn_b0_bt_2_115200, pbn_b0_bt_8_115200, @@ -1158,6 +1163,12 @@ static struct pci_board pci_boards[] __devinitdata = { .base_baud = 921600, .uart_offset = 8, }, + [pbn_b0_4_1152000] = { + .flags = FL_BASE0, + .num_ports = 4, + .base_baud = 1152000, + .uart_offset = 8, + }, [pbn_b0_bt_1_115200] = { .flags = FL_BASE0|FL_BASE_BARS, @@ -1977,6 +1988,9 @@ static struct pci_device_id serial_pci_tbl[] = { { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_OXSEMI_16PCI954, PCI_VENDOR_ID_SPECIALIX, PCI_SUBDEVICE_ID_SPECIALIX_SPEED4, 0, 0, pbn_b0_4_921600 }, + { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954, + PCI_SUBVENDOR_ID_SIIG, PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL, 0, 0, + pbn_b0_4_1152000 }, { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954, PCI_ANY_ID, PCI_ANY_ID, 0, 0, pbn_b0_4_115200 }, 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 @@ #define PCI_DEVICE_ID_CBOARDS_DAS1602_16 0x0001 #define PCI_VENDOR_ID_SIIG 0x131f +#define PCI_SUBVENDOR_ID_SIIG 0x131f #define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000 #define PCI_DEVICE_ID_SIIG_1S_10x_650 0x1001 #define PCI_DEVICE_ID_SIIG_1S_10x_850 0x1002 @@ -1909,6 +1910,7 @@ #define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060 #define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061 #define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062 +#define PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL 0x2050 #define PCI_VENDOR_ID_RADISYS 0x1331 #define PCI_DEVICE_ID_RADISYS_ENP2611 0x0030 From d7c7ed4dbc66c5f4dfa5615cdfc5009af3b3b137 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Mon, 18 Jul 2005 13:29:49 -0700 Subject: [PATCH 10/66] [PKT_SCHED]: Remove debugging leftover from textsearch ematch Signed-off-by: Thomas Graf Signed-off-by: David S. Miller --- net/sched/em_text.c | 3 --- 1 file changed, 3 deletions(-) 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, struct ts_config *ts_conf; int flags = 0; - printk("Configuring text: %s from %d:%d to %d:%d len %d\n", conf->algo, conf->from_offset, - conf->from_layer, conf->to_offset, conf->to_layer, conf->pattern_len); - if (len < sizeof(*conf) || len < (sizeof(*conf) + conf->pattern_len)) return -EINVAL; From 452f299da3253f65020143f743c2e207b752547b Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Mon, 18 Jul 2005 13:30:53 -0700 Subject: [PATCH 11/66] [PKT_SCHED]: Reduce branch mispredictions in pfifo_fast_dequeue The current call to __qdisc_dequeue_head leads to a branch misprediction for every loop iteration, the fact that the most common priority is 2 makes this even worse. This issue has been brought up by Eric Dumazet but unlike his solution which was to manually unroll the loop, this approach preserves the possibility to increase the number of bands at compile time. Signed-off-by: Thomas Graf Signed-off-by: David S. Miller --- net/sched/sch_generic.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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) int prio; struct sk_buff_head *list = qdisc_priv(qdisc); - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++, list++) { - struct sk_buff *skb = __qdisc_dequeue_head(qdisc, list); - if (skb) { + for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) { + if (!skb_queue_empty(list + prio)) { qdisc->q.qlen--; - return skb; + return __qdisc_dequeue_head(qdisc, list + prio); } } From 23af27eb8fa9ea8614138c4cded7a16cb4197a55 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Mon, 18 Jul 2005 13:34:35 -0700 Subject: [PATCH 12/66] [PKT_SCHED]: Kill TCF_META_ID_TCCLASSID. Thomas Graf states: > I used to mark such ids as obsolete in the header but since > skb is on diet anyway and there has been no official > iproute2 release with the ematch bits included it might be > a better idea to remove the ids from the header completely. > Those that have picked up my patch on netdev shouldn't care > about a ABI breakage, actually I doubt that someone is using > it already. So here's the patch to remove it. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- include/linux/tc_ematch/tc_em_meta.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/tc_ematch/tc_em_meta.h b/include/linux/tc_ematch/tc_em_meta.h index bcb762d93123..90ab9f95d43d 100644 --- a/include/linux/tc_ematch/tc_em_meta.h +++ b/include/linux/tc_ematch/tc_em_meta.h @@ -53,7 +53,6 @@ enum TCF_META_ID_NFMARK, TCF_META_ID_TCINDEX, TCF_META_ID_TCVERDICT, - TCF_META_ID_TCCLASSID, TCF_META_ID_RTCLASSID, TCF_META_ID_RTIIF, TCF_META_ID_SK_FAMILY, From 37da647d994cdac7e0bc8d2a365fbda403939a2b Mon Sep 17 00:00:00 2001 From: Victor Fusco Date: Mon, 18 Jul 2005 13:35:43 -0700 Subject: [PATCH 13/66] [NETLINK]: Fix "nocast type" warnings From: Victor Fusco Fix the sparse warning "implicit cast to nocast type" Signed-off-by: Victor Fusco Signed-off-by: Domen Puncer Signed-off-by: David S. Miller --- net/netlink/af_netlink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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) sock_put(sk); } -static inline struct sk_buff *netlink_trim(struct sk_buff *skb, int allocation) +static inline struct sk_buff *netlink_trim(struct sk_buff *skb, + unsigned int __nocast allocation) { int delta; @@ -717,7 +718,7 @@ struct netlink_broadcast_data { int failure; int congested; int delivered; - int allocation; + unsigned int allocation; struct sk_buff *skb, *skb2; }; From e2bf521d9728bfae9b6c3d484614e5962d0b5afd Mon Sep 17 00:00:00 2001 From: Victor Fusco Date: Mon, 18 Jul 2005 13:36:38 -0700 Subject: [PATCH 14/66] [NET]: Fix "nocast type" warnings in skbuff.h From: Victor Fusco Fix the sparse warning "implicit cast to nocast type" Signed-off-by: Victor Fusco Signed-off-by: Domen Puncer Signed-off-by: David S. Miller --- include/linux/skbuff.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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, * * %NULL is returned on a memory allocation failure. */ -static inline struct sk_buff *skb_unshare(struct sk_buff *skb, int pri) +static inline struct sk_buff *skb_unshare(struct sk_buff *skb, + unsigned int __nocast pri) { might_sleep_if(pri & __GFP_WAIT); if (skb_cloned(skb)) { From ee71a29eb5e341fe977c5ad7a43782c29bd9cb9e Mon Sep 17 00:00:00 2001 From: Christophe Lucas Date: Mon, 18 Jul 2005 13:38:07 -0700 Subject: [PATCH 15/66] [SCTP]: Audit return code of create_proc_* From: Christophe Lucas Audit return of create_proc_* functions. Signed-off-by: Christophe Lucas Signed-off-by: Domen Puncer Signed-off-by: David S. Miller --- net/sctp/objcnt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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: /* Initialize the objcount in the proc filesystem. */ void sctp_dbg_objcnt_init(void) { - create_proc_read_entry("sctp_dbg_objcnt", 0, proc_net_sctp, + struct proc_dir_entry *ent; + ent = create_proc_read_entry("sctp_dbg_objcnt", 0, proc_net_sctp, sctp_dbg_objcnt_read, NULL); + if (!ent) + printk(KERN_WARNING + "sctp_dbg_objcnt: Unable to create /proc entry.\n"); } /* Cleanup the objcount entry in the proc filesystem. */ From d1ad1ff299dd908d07c5e5f27f88bbdb235eb7a5 Mon Sep 17 00:00:00 2001 From: Sridhar Samudrala Date: Mon, 18 Jul 2005 13:44:10 -0700 Subject: [PATCH 16/66] [SCTP]: Fix potential null pointer dereference while handling an icmp error Signed-off-by: Sridhar Samudrala Signed-off-by: David S. Miller --- include/net/sctp/sctp.h | 7 ++---- net/sctp/input.c | 47 ++++++++++++----------------------------- net/sctp/ipv6.c | 7 +++--- 3 files changed, 18 insertions(+), 43 deletions(-) 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 *); void sctp_hash_endpoint(struct sctp_endpoint *); void sctp_unhash_endpoint(struct sctp_endpoint *); struct sock *sctp_err_lookup(int family, struct sk_buff *, - struct sctphdr *, struct sctp_endpoint **, - struct sctp_association **, + struct sctphdr *, struct sctp_association **, struct sctp_transport **); -void sctp_err_finish(struct sock *, struct sctp_endpoint *, - struct sctp_association *); +void sctp_err_finish(struct sock *, struct sctp_association *); void sctp_icmp_frag_needed(struct sock *, struct sctp_association *, struct sctp_transport *t, __u32 pmtu); void sctp_icmp_proto_unreachable(struct sock *sk, - struct sctp_endpoint *ep, struct sctp_association *asoc, struct sctp_transport *t); 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, * */ void sctp_icmp_proto_unreachable(struct sock *sk, - struct sctp_endpoint *ep, struct sctp_association *asoc, struct sctp_transport *t) { @@ -367,7 +366,6 @@ void sctp_icmp_proto_unreachable(struct sock *sk, /* Common lookup code for icmp/icmpv6 error handler. */ struct sock *sctp_err_lookup(int family, struct sk_buff *skb, struct sctphdr *sctphdr, - struct sctp_endpoint **epp, struct sctp_association **app, struct sctp_transport **tpp) { @@ -375,11 +373,10 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb, union sctp_addr daddr; struct sctp_af *af; struct sock *sk = NULL; - struct sctp_endpoint *ep = NULL; struct sctp_association *asoc = NULL; struct sctp_transport *transport = NULL; - *app = NULL; *epp = NULL; *tpp = NULL; + *app = NULL; *tpp = NULL; af = sctp_get_af_specific(family); if (unlikely(!af)) { @@ -394,27 +391,16 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb, * packet. */ asoc = __sctp_lookup_association(&saddr, &daddr, &transport); - if (!asoc) { - /* If there is no matching association, see if it matches any - * endpoint. This may happen for an ICMP error generated in - * response to an INIT_ACK. - */ - ep = __sctp_rcv_lookup_endpoint(&daddr); - if (!ep) { - return NULL; - } + if (!asoc) + return NULL; + + sk = asoc->base.sk; + + if (ntohl(sctphdr->vtag) != asoc->c.peer_vtag) { + ICMP_INC_STATS_BH(ICMP_MIB_INERRORS); + goto out; } - if (asoc) { - sk = asoc->base.sk; - - if (ntohl(sctphdr->vtag) != asoc->c.peer_vtag) { - ICMP_INC_STATS_BH(ICMP_MIB_INERRORS); - goto out; - } - } else - sk = ep->base.sk; - sctp_bh_lock_sock(sk); /* If too many ICMPs get dropped on busy @@ -423,7 +409,6 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb, if (sock_owned_by_user(sk)) NET_INC_STATS_BH(LINUX_MIB_LOCKDROPPEDICMPS); - *epp = ep; *app = asoc; *tpp = transport; return sk; @@ -432,21 +417,16 @@ out: sock_put(sk); if (asoc) sctp_association_put(asoc); - if (ep) - sctp_endpoint_put(ep); return NULL; } /* Common cleanup code for icmp/icmpv6 error handler. */ -void sctp_err_finish(struct sock *sk, struct sctp_endpoint *ep, - struct sctp_association *asoc) +void sctp_err_finish(struct sock *sk, struct sctp_association *asoc) { sctp_bh_unlock_sock(sk); sock_put(sk); if (asoc) sctp_association_put(asoc); - if (ep) - sctp_endpoint_put(ep); } /* @@ -471,7 +451,6 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) int type = skb->h.icmph->type; int code = skb->h.icmph->code; struct sock *sk; - struct sctp_endpoint *ep; struct sctp_association *asoc; struct sctp_transport *transport; struct inet_sock *inet; @@ -488,7 +467,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) savesctp = skb->h.raw; skb->nh.iph = iph; skb->h.raw = (char *)sh; - sk = sctp_err_lookup(AF_INET, skb, sh, &ep, &asoc, &transport); + sk = sctp_err_lookup(AF_INET, skb, sh, &asoc, &transport); /* Put back, the original pointers. */ skb->nh.raw = saveip; skb->h.raw = savesctp; @@ -515,7 +494,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) } else { if (ICMP_PROT_UNREACH == code) { - sctp_icmp_proto_unreachable(sk, ep, asoc, + sctp_icmp_proto_unreachable(sk, asoc, transport); goto out_unlock; } @@ -544,7 +523,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) } out_unlock: - sctp_err_finish(sk, ep, asoc); + sctp_err_finish(sk, asoc); } /* 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, struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; struct sctphdr *sh = (struct sctphdr *)(skb->data + offset); struct sock *sk; - struct sctp_endpoint *ep; struct sctp_association *asoc; struct sctp_transport *transport; struct ipv6_pinfo *np; @@ -105,7 +104,7 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, savesctp = skb->h.raw; skb->nh.ipv6h = iph; skb->h.raw = (char *)sh; - sk = sctp_err_lookup(AF_INET6, skb, sh, &ep, &asoc, &transport); + sk = sctp_err_lookup(AF_INET6, skb, sh, &asoc, &transport); /* Put back, the original pointers. */ skb->nh.raw = saveip; skb->h.raw = savesctp; @@ -124,7 +123,7 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, goto out_unlock; case ICMPV6_PARAMPROB: if (ICMPV6_UNK_NEXTHDR == code) { - sctp_icmp_proto_unreachable(sk, ep, asoc, transport); + sctp_icmp_proto_unreachable(sk, asoc, transport); goto out_unlock; } break; @@ -142,7 +141,7 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, } out_unlock: - sctp_err_finish(sk, ep, asoc); + sctp_err_finish(sk, asoc); out: if (likely(idev != NULL)) in6_dev_put(idev); From 54208991e15fa00e37a9d172ac0d87191a832165 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 18 Jul 2005 13:45:12 -0700 Subject: [PATCH 17/66] [NET]: Kconfig: NETCONSOLE and NETPOLL together Put NETCONSOLE and NETPOLL options together since they are related. This cuts down on the hassle of flipping back and forth between the Networking menu and the Network drivers menu to change their config settings. Tested with menuconfig, gconfig, and xconfig. gconfig has a small problem with this. I think that it's a bug in gconfig and I will take it up with Romain Lievin. Signed-off-by: Randy Dunlap Signed-off-by: David S. Miller --- drivers/net/Kconfig | 16 ++++++++++++++++ net/Kconfig | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 9a07ff7a7777..f827f0a1e1a6 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -2549,4 +2549,20 @@ config NETCONSOLE If you want to log kernel messages over the network, enable this. See for details. +config NETPOLL + def_bool NETCONSOLE + +config NETPOLL_RX + bool "Netpoll support for trapping incoming packets" + default n + depends on NETPOLL + +config NETPOLL_TRAP + bool "Netpoll traffic trapping" + default n + depends on NETPOLL + +config NET_POLL_CONTROLLER + def_bool NETPOLL + endmenu diff --git a/net/Kconfig b/net/Kconfig index 2684e809a649..40a31ba86d2c 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -209,22 +209,6 @@ endmenu endmenu -config NETPOLL - def_bool NETCONSOLE - -config NETPOLL_RX - bool "Netpoll support for trapping incoming packets" - default n - depends on NETPOLL - -config NETPOLL_TRAP - bool "Netpoll traffic trapping" - default n - depends on NETPOLL - -config NET_POLL_CONTROLLER - def_bool NETPOLL - source "net/ax25/Kconfig" source "net/irda/Kconfig" source "net/bluetooth/Kconfig" From 6876f95f201ce2d62367d85dd793c1fee351d7a6 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Mon, 18 Jul 2005 13:55:19 -0700 Subject: [PATCH 18/66] [IPV4]: fix IP_FIB_HASH kconfig warning This patch fixes the following kconfig warning: net/ipv4/Kconfig:92:warning: defaults for choice values not supported Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: David S. Miller --- net/ipv4/Kconfig | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index df5386885a90..ecea2bc8229f 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig @@ -54,9 +54,9 @@ config IP_ADVANCED_ROUTER choice prompt "Choose IP: FIB lookup algorithm (choose FIB_HASH if unsure)" depends on IP_ADVANCED_ROUTER - default IP_FIB_HASH + default ASK_IP_FIB_HASH -config IP_FIB_HASH +config ASK_IP_FIB_HASH bool "FIB_HASH" ---help--- Current FIB is very proven and good enough for most users. @@ -82,12 +82,8 @@ config IP_FIB_TRIE endchoice -# If the user does not enable advanced routing, he gets the safe -# default of the fib-hash algorithm. config IP_FIB_HASH - bool - depends on !IP_ADVANCED_ROUTER - default y + def_bool ASK_IP_FIB_HASH || !IP_ADVANCED_ROUTER config IP_MULTIPLE_TABLES bool "IP: policy routing" From 3f1c81ff10187396e6d0fd01df82ab0cec256c96 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Mon, 18 Jul 2005 17:10:55 -0700 Subject: [PATCH 19/66] [EMATCH]: Kill TCF_META_ID_TCCLASSID reference from meta ematch as well. Signed-off-by: David S. Miller --- net/sched/em_meta.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index 53d98f8d3d80..feefcbfd03d0 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c @@ -250,11 +250,6 @@ META_COLLECTOR(int_tcverd) { dst->value = skb->tc_verd; } - -META_COLLECTOR(int_tcclassid) -{ - dst->value = skb->tc_classid; -} #endif /************************************************************************** @@ -529,7 +524,6 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = { [META_ID(TCINDEX)] = META_FUNC(int_tcindex), #ifdef CONFIG_NET_CLS_ACT [META_ID(TCVERDICT)] = META_FUNC(int_tcverd), - [META_ID(TCCLASSID)] = META_FUNC(int_tcclassid), #endif #ifdef CONFIG_NET_CLS_ROUTE [META_ID(RTCLASSID)] = META_FUNC(int_rtclassid), From 43f51fce0a637e6cdf1285b0fa09b8398ff14834 Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Tue, 19 Jul 2005 13:54:19 -0700 Subject: [PATCH 20/66] [ATM]: [zatm] eliminate kfree warning (from Tobias Hirning ) Signed-off-by: Chas Williams Signed-off-by: David S. Miller --- drivers/atm/zatm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c index 8d5e65cb9755..afcf1ada5547 100644 --- a/drivers/atm/zatm.c +++ b/drivers/atm/zatm.c @@ -1339,7 +1339,7 @@ static int __init zatm_start(struct atm_dev *dev) return 0; out: for (i = 0; i < NR_MBX; i++) - kfree(zatm_dev->mbx_start[i]); + kfree(&zatm_dev->mbx_start[i]); kfree(zatm_dev->rx_map); kfree(zatm_dev->tx_map); free_irq(zatm_dev->irq, dev); From 322361b3712af97c19ab730b410f9ae5d9aad4c3 Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Tue, 19 Jul 2005 13:54:44 -0700 Subject: [PATCH 21/66] [ATM]: allow bind() on point-to-multpoint svcs (from Martin Whitaker ) Signed-off-by: Chas Williams Signed-off-by: David S. Miller --- net/atm/svc.c | 4 ---- 1 file changed, 4 deletions(-) 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, goto out; } vcc = ATM_SD(sock); - if (test_bit(ATM_VF_SESSION, &vcc->flags)) { - error = -EINVAL; - goto out; - } addr = (struct sockaddr_atmsvc *) sockaddr; if (addr->sas_family != AF_ATMSVC) { error = -EAFNOSUPPORT; From e1bd232b641a0d0ef184a5154409ef38aebb3155 Mon Sep 17 00:00:00 2001 From: Marcelo Feitoza Parisi Date: Tue, 19 Jul 2005 13:55:14 -0700 Subject: [PATCH 22/66] [ATM]: [idt77252] use time_after() macro Signed-off-by: Marcelo Feitoza Parisi Signed-off-by: Domen Puncer Signed-off-by: Chas Williams Signed-off-by: David S. Miller --- drivers/atm/idt77252.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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[] = #include #include #include +#include #include #include #include @@ -780,7 +781,7 @@ push_on_scq(struct idt77252_dev *card, struct vc_map *vc, struct sk_buff *skb) return 0; out: - if (jiffies - scq->trans_start > HZ) { + if (time_after(jiffies, scq->trans_start + HZ)) { printk("%s: Error pushing TBD for %d.%d\n", card->name, vc->tx_vcc->vpi, vc->tx_vcc->vci); #ifdef CONFIG_ATM_IDT77252_DEBUG From 5e8676d113a097e19d18492e85215f0f3cc86e43 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Tue, 19 Jul 2005 13:55:38 -0700 Subject: [PATCH 23/66] [ATM]: [he] remove linux/version.h include Signed-off-by: Olaf Hering Signed-off-by: Chas Williams Signed-off-by: David S. Miller --- drivers/atm/he.c | 1 - 1 file changed, 1 deletion(-) 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 @@ #include #include -#include #include #include #include From c9e42614585dddd544a56907ff5fd5ca55411967 Mon Sep 17 00:00:00 2001 From: Victor Fusco Date: Tue, 19 Jul 2005 13:56:01 -0700 Subject: [PATCH 24/66] [ATM]: [firestream] fix the sparse warning "implicit cast to nocast type" Signed-off-by: Victor Fusco Signed-off-by: Domen Puncer Signed-off-by: Chas Williams Signed-off-by: David S. Miller --- drivers/atm/firestream.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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) } } -static void __devinit *aligned_kmalloc (int size, int flags, int alignment) +static void __devinit *aligned_kmalloc (int size, unsigned int __nocast flags, + int alignment) { void *t; @@ -1464,7 +1465,8 @@ static inline int nr_buffers_in_freepool (struct fs_dev *dev, struct freepool *f does. I've seen "receive abort: no buffers" and things started working again after that... -- REW */ -static void top_off_fp (struct fs_dev *dev, struct freepool *fp, int gfp_flags) +static void top_off_fp (struct fs_dev *dev, struct freepool *fp, + unsigned int __nocast gfp_flags) { struct FS_BPENTRY *qe, *ne; struct sk_buff *skb; From 5938a7b580bb7a738ee349048565ac76e6f3f5d7 Mon Sep 17 00:00:00 2001 From: Victor Fusco Date: Tue, 19 Jul 2005 13:56:29 -0700 Subject: [PATCH 25/66] [ATM]: [ambassador] Fix the sparse warning "implicit cast to nocast type" Signed-off-by: Victor Fusco Signed-off-by: Domen Puncer Signed-off-by: Chas Williams Signed-off-by: David S. Miller --- drivers/atm/ambassador.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) { drain_rx_pool (dev, pool); } -static inline void fill_rx_pool (amb_dev * dev, unsigned char pool, int priority) { +static inline void fill_rx_pool (amb_dev * dev, unsigned char pool, + unsigned int __nocast priority) +{ rx_in rx; amb_rxq * rxq; From 88e9fa8a54cf4d66ee8fc1d855e82de827233d74 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Tue, 19 Jul 2005 13:56:53 -0700 Subject: [PATCH 26/66] [ATM]: Trivial spelling fix patch for net/Kconfig Signed-off-by: Jesper Juhl Signed-off-by: Adrian Bunk Signed-off-by: Chas Williams Signed-off-by: David S. Miller --- net/atm/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 tristate "RFC1483/2684 Bridged protocols" depends on ATM && INET help - ATM PVCs can carry ethernet PDUs according to rfc2684 (formerly 1483) + ATM PVCs can carry ethernet PDUs according to RFC2684 (formerly 1483) This device will act like an ethernet from the kernels point of view, with the traffic being carried by ATM PVCs (currently 1 PVC/device). This is sometimes used over DSL lines. If in doubt, say N. @@ -69,6 +69,6 @@ config ATM_BR2684_IPFILTER bool "Per-VC IP filter kludge" depends on ATM_BR2684 help - This is an experimental mechanism for users who need to terminating a + This is an experimental mechanism for users who need to terminate a large number of IP-only vcc's. Do not enable this unless you are sure you know what you are doing. From 86cf42e4e029b83110cf98692420239103363dbf Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Tue, 19 Jul 2005 13:57:17 -0700 Subject: [PATCH 27/66] [ATM]: [speedtch] cure atm_printk() macro gcc-2.95 compile error Signed-off-by: Duncan Sands Signed-off-by: Chas Williams Signed-off-by: David S. Miller --- drivers/usb/atm/speedtch.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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) case 0: atm_dev->signal = ATM_PHY_SIG_LOST; if (instance->last_status) - atm_info(usbatm, "ADSL line is down\n"); + atm_info(usbatm, "%s\n", "ADSL line is down"); /* It may never resync again unless we ask it to... */ ret = speedtch_start_synchro(instance); break; case 0x08: atm_dev->signal = ATM_PHY_SIG_UNKNOWN; - atm_info(usbatm, "ADSL line is blocked?\n"); + atm_info(usbatm, "%s\n", "ADSL line is blocked?"); break; case 0x10: atm_dev->signal = ATM_PHY_SIG_LOST; - atm_info(usbatm, "ADSL line is synchronising\n"); + atm_info(usbatm, "%s\n", "ADSL line is synchronising"); break; case 0x20: @@ -502,7 +502,7 @@ static void speedtch_status_poll(unsigned long data) if (instance->poll_delay < MAX_POLL_DELAY) mod_timer(&instance->status_checker.timer, jiffies + msecs_to_jiffies(instance->poll_delay)); else - atm_warn(instance->usbatm, "Too many failures - disabling line status polling\n"); + atm_warn(instance->usbatm, "%s\n", "Too many failures - disabling line status polling"); } static void speedtch_resubmit_int(unsigned long data) @@ -545,9 +545,9 @@ static void speedtch_handle_int(struct urb *int_urb, struct pt_regs *regs) if ((count == 6) && !memcmp(up_int, instance->int_data, 6)) { del_timer(&instance->status_checker.timer); - atm_info(usbatm, "DSL line goes up\n"); + atm_info(usbatm, "%s\n", "DSL line goes up"); } else if ((count == 6) && !memcmp(down_int, instance->int_data, 6)) { - atm_info(usbatm, "DSL line goes down\n"); + atm_info(usbatm, "%s\n", "DSL line goes down"); } else { int i; From 6aef4fdfeaec5f2c66415f2cafa98a3ff927501f Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Tue, 19 Jul 2005 13:58:40 -0700 Subject: [PATCH 28/66] [NET]: Only build flow.o if CONFIG_XFRM=y Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/core/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 \ obj-$(CONFIG_SYSCTL) += sysctl_net_core.o -obj-y += flow.o dev.o ethtool.o dev_mcast.o dst.o \ +obj-y += dev.o ethtool.o dev_mcast.o dst.o \ neighbour.o rtnetlink.o utils.o link_watch.o filter.o +obj-$(CONFIG_XFRM) += flow.o obj-$(CONFIG_SYSFS) += net-sysfs.o obj-$(CONFIG_NETFILTER) += netfilter.o obj-$(CONFIG_NET_DIVERT) += dv.o From abaacad9bcb3f118cc802f527ab5d7c41b63f83a Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Tue, 19 Jul 2005 13:59:17 -0700 Subject: [PATCH 29/66] [IPV4]: Don't select XFRM for ip_gre Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index ecea2bc8229f..c7f1f9245bc9 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig @@ -252,7 +252,6 @@ config NET_IPIP config NET_IPGRE tristate "IP: GRE tunnels over IP" - select XFRM help Tunneling means encapsulating data of one protocol type within another protocol and sending it over a channel that understands the From eb3f8f5e22cdee8138e654963e371ad337830efb Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 19 Jul 2005 14:00:13 -0700 Subject: [PATCH 30/66] [NET]: BRIDGE_EBT_ARPREPLY must depend on INET BRIDGE_EBT_ARPREPLY=y and INET=n results in the following compile error: net/built-in.o: In function `ebt_target_reply': ebt_arpreply.c:(.text+0x68fb9): undefined reference to `arp_send' make: *** [.tmp_vmlinux1] Error 1 Signed-off-by: Adrian Bunk Signed-off-by: David S. Miller --- net/bridge/netfilter/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 # config BRIDGE_EBT_ARPREPLY tristate "ebt: arp reply target support" - depends on BRIDGE_NF_EBTABLES + depends on BRIDGE_NF_EBTABLES && INET help This option adds the arp reply target, which allows automatically sending arp replies to arp requests. From 23a534e7b1ad2650002bbc236493791ac23440ee Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 19 Jul 2005 14:00:53 -0700 Subject: [PATCH 31/66] [NET]: NETCONSOLE must depend on INET NETCONSOLE=y and INET=n results in the following compile error: net/built-in.o: In function `netpoll_parse_options': : undefined reference to `in_aton' net/built-in.o: In function `netpoll_parse_options': : undefined reference to `in_aton' Signed-off-by: Adrian Bunk Signed-off-by: David S. Miller --- drivers/net/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index f827f0a1e1a6..534b598866b3 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -2544,7 +2544,7 @@ config SHAPER config NETCONSOLE tristate "Network console logging support (EXPERIMENTAL)" - depends on NETDEVICES && EXPERIMENTAL + depends on NETDEVICES && INET && EXPERIMENTAL ---help--- If you want to log kernel messages over the network, enable this. See for details. From c877efb207bf4629cfa97ac13412f7392a873485 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 19 Jul 2005 14:01:51 -0700 Subject: [PATCH 32/66] [IPV4]: Fix up lots of little whitespace indentation stuff in fib_trie. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/ipv4/af_inet.c | 2 +- net/ipv4/fib_trie.c | 772 ++++++++++++++++++++++---------------------- 2 files changed, 388 insertions(+), 386 deletions(-) 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) #ifdef CONFIG_IP_FIB_TRIE if (fib_stat_proc_init()) goto out_fib_stat; - #endif +#endif if (ip_misc_proc_init()) goto out_misc; out: 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; #define T_LEAF 1 #define NODE_TYPE_MASK 0x1UL #define NODE_PARENT(_node) \ -((struct tnode *)((_node)->_parent & ~NODE_TYPE_MASK)) + ((struct tnode *)((_node)->_parent & ~NODE_TYPE_MASK)) #define NODE_SET_PARENT(_node, _ptr) \ -((_node)->_parent = (((unsigned long)(_ptr)) | \ + ((_node)->_parent = (((unsigned long)(_ptr)) | \ ((_node)->_parent & NODE_TYPE_MASK))) #define NODE_INIT_PARENT(_node, _type) \ -((_node)->_parent = (_type)) + ((_node)->_parent = (_type)) #define NODE_TYPE(_node) \ -((_node)->_parent & NODE_TYPE_MASK) + ((_node)->_parent & NODE_TYPE_MASK) #define IS_TNODE(n) (!(n->_parent & T_LEAF)) #define IS_LEAF(n) (n->_parent & T_LEAF) @@ -147,7 +147,7 @@ struct trie_stat { unsigned int leaves; unsigned int nullpointers; unsigned int nodesizes[MAX_CHILDS]; -}; +}; struct trie { struct node *trie; @@ -185,9 +185,9 @@ static void trie_bug(char *err) BUG(); } -static inline struct node *tnode_get_child(struct tnode *tn, int i) +static inline struct node *tnode_get_child(struct tnode *tn, int i) { - if (i >= 1<bits) + if (i >= 1<bits) trie_bug("tnode_get_child"); return tn->child[i]; @@ -202,7 +202,7 @@ static inline int tnode_child_length(struct tnode *tn) _________________________________________________________________ | i | i | i | i | i | i | i | N | N | N | S | S | S | S | S | C | ---------------------------------------------------------------- - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 _________________________________________________________________ | 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) static inline int tkey_equals(t_key a, t_key b) { - return a == b; + return a == b; } static inline int tkey_sub_equals(t_key a, int offset, int bits, t_key b) { - if (bits == 0 || offset >= KEYLENGTH) - return 1; + if (bits == 0 || offset >= KEYLENGTH) + return 1; bits = bits > KEYLENGTH ? KEYLENGTH : bits; return ((a ^ b) << offset) >> (KEYLENGTH - bits) == 0; -} +} static inline int tkey_mismatch(t_key a, int offset, t_key b) { t_key diff = a ^ b; int i = offset; - if(!diff) - return 0; - while((diff << i) >> (KEYLENGTH-1) == 0) + if (!diff) + return 0; + while ((diff << i) >> (KEYLENGTH-1) == 0) i++; return i; } @@ -314,6 +314,7 @@ static void fn_free_alias(struct fib_alias *fa) The bits from (n->pos) to (n->pos + n->bits - 1) - "C" - are the index into n's child array, and will of course be different for each child. + The rest of the bits, from (n->pos + n->bits) onward, are completely unknown at this point. @@ -321,7 +322,7 @@ static void fn_free_alias(struct fib_alias *fa) static void check_tnode(struct tnode *tn) { - if(tn && tn->pos+tn->bits > 32) { + if (tn && tn->pos+tn->bits > 32) { printk("TNODE ERROR tn=%p, pos=%d, bits=%d\n", tn, tn->pos, tn->bits); } } @@ -332,7 +333,7 @@ static int inflate_threshold = 50; static struct leaf *leaf_new(void) { struct leaf *l = kmalloc(sizeof(struct leaf), GFP_KERNEL); - if(l) { + if (l) { NODE_INIT_PARENT(l, T_LEAF); INIT_HLIST_HEAD(&l->list); } @@ -342,7 +343,7 @@ static struct leaf *leaf_new(void) static struct leaf_info *leaf_info_new(int plen) { struct leaf_info *li = kmalloc(sizeof(struct leaf_info), GFP_KERNEL); - if(li) { + if (li) { li->plen = plen; INIT_LIST_HEAD(&li->falh); } @@ -365,7 +366,7 @@ static struct tnode *tnode_alloc(unsigned int size) return kmalloc(size, GFP_KERNEL); } else { return (struct tnode *) - __get_free_pages(GFP_KERNEL, get_order(size)); + __get_free_pages(GFP_KERNEL, get_order(size)); } } @@ -386,7 +387,7 @@ static struct tnode* tnode_new(t_key key, int pos, int bits) int sz = sizeof(struct tnode) + nchildren * sizeof(struct node *); struct tnode *tn = tnode_alloc(sz); - if(tn) { + if (tn) { memset(tn, 0, sz); NODE_INIT_PARENT(tn, T_TNODE); tn->pos = pos; @@ -395,7 +396,8 @@ static struct tnode* tnode_new(t_key key, int pos, int bits) tn->full_children = 0; tn->empty_children = 1< 0) + + if (trie_debug > 0) printk("AT %p s=%u %u\n", tn, (unsigned int) sizeof(struct tnode), (unsigned int) (sizeof(struct node) * 1< 0 ) + if (trie_debug > 0 ) printk("FL %p \n", tn); } - else if(IS_TNODE(tn)) { + else if (IS_TNODE(tn)) { __tnode_free(tn); - if(trie_debug > 0 ) + if (trie_debug > 0 ) printk("FT %p \n", tn); } else { @@ -428,58 +430,58 @@ static void tnode_free(struct tnode *tn) static inline int tnode_full(struct tnode *tn, struct node *n) { - if(n == NULL || IS_LEAF(n)) + if (n == NULL || IS_LEAF(n)) return 0; return ((struct tnode *) n)->pos == tn->pos + tn->bits; } -static inline void put_child(struct trie *t, struct tnode *tn, int i, struct node *n) +static inline void put_child(struct trie *t, struct tnode *tn, int i, struct node *n) { tnode_put_child_reorg(tn, i, n, -1); } - /* + /* * Add a child at position i overwriting the old value. * Update the value of full_children and empty_children. */ -static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int wasfull) +static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int wasfull) { struct node *chi; int isfull; - if(i >= 1<bits) { + if (i >= 1<bits) { printk("bits=%d, i=%d\n", tn->bits, i); trie_bug("tnode_put_child_reorg bits"); } write_lock_bh(&fib_lock); - chi = tn->child[i]; + chi = tn->child[i]; /* update emptyChildren */ if (n == NULL && chi != NULL) tn->empty_children++; else if (n != NULL && chi == NULL) tn->empty_children--; - + /* update fullChildren */ if (wasfull == -1) wasfull = tnode_full(tn, chi); isfull = tnode_full(tn, n); - if (wasfull && !isfull) + if (wasfull && !isfull) tn->full_children--; - - else if (!wasfull && isfull) + + else if (!wasfull && isfull) tn->full_children++; - if(n) - NODE_SET_PARENT(n, tn); + if (n) + NODE_SET_PARENT(n, tn); tn->child[i] = n; write_unlock_bh(&fib_lock); } -static struct node *resize(struct trie *t, struct tnode *tn) +static struct node *resize(struct trie *t, struct tnode *tn) { int i; int err = 0; @@ -487,8 +489,8 @@ static struct node *resize(struct trie *t, struct tnode *tn) if (!tn) return NULL; - if(trie_debug) - printk("In tnode_resize %p inflate_threshold=%d threshold=%d\n", + if (trie_debug) + printk("In tnode_resize %p inflate_threshold=%d threshold=%d\n", tn, inflate_threshold, halve_threshold); /* No children */ @@ -505,7 +507,7 @@ static struct node *resize(struct trie *t, struct tnode *tn) /* compress one level */ struct node *n = tn->child[i]; - if(n) + if (n) NODE_INIT_PARENT(n, NODE_TYPE(n)); write_unlock_bh(&fib_lock); @@ -514,72 +516,72 @@ static struct node *resize(struct trie *t, struct tnode *tn) } write_unlock_bh(&fib_lock); } - /* + /* * Double as long as the resulting node has a number of * nonempty nodes that are above the threshold. */ /* - * From "Implementing a dynamic compressed trie" by Stefan Nilsson of - * the Helsinki University of Technology and Matti Tikkanen of Nokia + * From "Implementing a dynamic compressed trie" by Stefan Nilsson of + * the Helsinki University of Technology and Matti Tikkanen of Nokia * Telecommunications, page 6: - * "A node is doubled if the ratio of non-empty children to all + * "A node is doubled if the ratio of non-empty children to all * children in the *doubled* node is at least 'high'." * - * 'high' in this instance is the variable 'inflate_threshold'. It - * is expressed as a percentage, so we multiply it with - * tnode_child_length() and instead of multiplying by 2 (since the - * child array will be doubled by inflate()) and multiplying - * the left-hand side by 100 (to handle the percentage thing) we + * 'high' in this instance is the variable 'inflate_threshold'. It + * is expressed as a percentage, so we multiply it with + * tnode_child_length() and instead of multiplying by 2 (since the + * child array will be doubled by inflate()) and multiplying + * the left-hand side by 100 (to handle the percentage thing) we * multiply the left-hand side by 50. - * - * The left-hand side may look a bit weird: tnode_child_length(tn) - * - tn->empty_children is of course the number of non-null children - * in the current node. tn->full_children is the number of "full" + * + * The left-hand side may look a bit weird: tnode_child_length(tn) + * - tn->empty_children is of course the number of non-null children + * in the current node. tn->full_children is the number of "full" * children, that is non-null tnodes with a skip value of 0. - * All of those will be doubled in the resulting inflated tnode, so + * All of those will be doubled in the resulting inflated tnode, so * we just count them one extra time here. - * + * * A clearer way to write this would be: - * + * * to_be_doubled = tn->full_children; - * not_to_be_doubled = tnode_child_length(tn) - tn->empty_children - + * not_to_be_doubled = tnode_child_length(tn) - tn->empty_children - * tn->full_children; * * new_child_length = tnode_child_length(tn) * 2; * - * new_fill_factor = 100 * (not_to_be_doubled + 2*to_be_doubled) / + * new_fill_factor = 100 * (not_to_be_doubled + 2*to_be_doubled) / * new_child_length; * if (new_fill_factor >= inflate_threshold) - * - * ...and so on, tho it would mess up the while() loop. - * + * + * ...and so on, tho it would mess up the while () loop. + * * anyway, * 100 * (not_to_be_doubled + 2*to_be_doubled) / new_child_length >= * inflate_threshold - * + * * avoid a division: * 100 * (not_to_be_doubled + 2*to_be_doubled) >= * inflate_threshold * new_child_length - * + * * expand not_to_be_doubled and to_be_doubled, and shorten: - * 100 * (tnode_child_length(tn) - tn->empty_children + + * 100 * (tnode_child_length(tn) - tn->empty_children + * tn->full_children ) >= inflate_threshold * new_child_length - * + * * expand new_child_length: - * 100 * (tnode_child_length(tn) - tn->empty_children + + * 100 * (tnode_child_length(tn) - tn->empty_children + * tn->full_children ) >= * inflate_threshold * tnode_child_length(tn) * 2 - * + * * shorten again: - * 50 * (tn->full_children + tnode_child_length(tn) - - * tn->empty_children ) >= inflate_threshold * + * 50 * (tn->full_children + tnode_child_length(tn) - + * tn->empty_children ) >= inflate_threshold * * tnode_child_length(tn) - * + * */ check_tnode(tn); - + err = 0; while ((tn->full_children > 0 && 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) tn = inflate(t, tn, &err); - if(err) { + if (err) { #ifdef CONFIG_IP_FIB_TRIE_STATS t->stats.resize_node_skipped++; #endif @@ -609,7 +611,7 @@ static struct node *resize(struct trie *t, struct tnode *tn) tn = halve(t, tn, &err); - if(err) { + if (err) { #ifdef CONFIG_IP_FIB_TRIE_STATS t->stats.resize_node_skipped++; #endif @@ -617,18 +619,18 @@ static struct node *resize(struct trie *t, struct tnode *tn) } } - + /* Only one child remains */ if (tn->empty_children == tnode_child_length(tn) - 1) for (i = 0; i < tnode_child_length(tn); i++) { - + write_lock_bh(&fib_lock); if (tn->child[i] != NULL) { /* compress one level */ struct node *n = tn->child[i]; - if(n) + if (n) NODE_INIT_PARENT(n, NODE_TYPE(n)); write_unlock_bh(&fib_lock); @@ -648,7 +650,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) int olen = tnode_child_length(tn); int i; - if(trie_debug) + if (trie_debug) printk("In inflate\n"); 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) } /* - * Preallocate and store tnodes before the actual work so we - * don't get into an inconsistent state if memory allocation - * fails. In case of failure we return the oldnode and inflate + * Preallocate and store tnodes before the actual work so we + * don't get into an inconsistent state if memory allocation + * fails. In case of failure we return the oldnode and inflate * of tnode is ignored. */ - + for(i = 0; i < olen; i++) { struct tnode *inode = (struct tnode *) tnode_get_child(oldtnode, i); @@ -675,20 +677,20 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) struct tnode *left, *right; t_key m = TKEY_GET_MASK(inode->pos, 1); - + left = tnode_new(inode->key&(~m), inode->pos + 1, inode->bits - 1); - if(!left) { - *err = -ENOMEM; + if (!left) { + *err = -ENOMEM; break; } - + right = tnode_new(inode->key|m, inode->pos + 1, inode->bits - 1); - if(!right) { - *err = -ENOMEM; + if (!right) { + *err = -ENOMEM; break; } @@ -697,32 +699,32 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) } } - if(*err) { + if (*err) { int size = tnode_child_length(tn); int j; - for(j = 0; j < size; j++) - if( tn->child[j]) + for(j = 0; j < size; j++) + if (tn->child[j]) tnode_free((struct tnode *)tn->child[j]); tnode_free(tn); - + *err = -ENOMEM; return oldtnode; } for(i = 0; i < olen; i++) { struct node *node = tnode_get_child(oldtnode, i); - + /* An empty child */ if (node == NULL) continue; /* A leaf or an internal node with skipped bits */ - if(IS_LEAF(node) || ((struct tnode *) node)->pos > + if (IS_LEAF(node) || ((struct tnode *) node)->pos > tn->pos + tn->bits - 1) { - if(tkey_extract_bits(node->key, oldtnode->pos + oldtnode->bits, + if (tkey_extract_bits(node->key, oldtnode->pos + oldtnode->bits, 1) == 0) put_child(t, tn, 2*i, node); else @@ -745,37 +747,37 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) struct tnode *left, *right; int size, j; - /* We will replace this node 'inode' with two new - * ones, 'left' and 'right', each with half of the - * original children. The two new nodes will have - * a position one bit further down the key and this - * means that the "significant" part of their keys - * (see the discussion near the top of this file) - * will differ by one bit, which will be "0" in - * left's key and "1" in right's key. Since we are - * moving the key position by one step, the bit that - * we are moving away from - the bit at position - * (inode->pos) - is the one that will differ between + /* We will replace this node 'inode' with two new + * ones, 'left' and 'right', each with half of the + * original children. The two new nodes will have + * a position one bit further down the key and this + * means that the "significant" part of their keys + * (see the discussion near the top of this file) + * will differ by one bit, which will be "0" in + * left's key and "1" in right's key. Since we are + * moving the key position by one step, the bit that + * we are moving away from - the bit at position + * (inode->pos) - is the one that will differ between * left and right. So... we synthesize that bit in the * two new keys. - * The mask 'm' below will be a single "one" bit at + * The mask 'm' below will be a single "one" bit at * the position (inode->pos) */ - /* Use the old key, but set the new significant - * bit to zero. + /* Use the old key, but set the new significant + * bit to zero. */ left = (struct tnode *) tnode_get_child(tn, 2*i); put_child(t, tn, 2*i, NULL); - if(!left) + if (!left) BUG(); right = (struct tnode *) tnode_get_child(tn, 2*i+1); put_child(t, tn, 2*i+1, NULL); - if(!right) + if (!right) BUG(); size = tnode_child_length(left); @@ -800,9 +802,9 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err) int i; int olen = tnode_child_length(tn); - if(trie_debug) printk("In halve\n"); - - tn=tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits - 1); + if (trie_debug) printk("In halve\n"); + + tn = tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits - 1); if (!tn) { *err = -ENOMEM; @@ -810,39 +812,39 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err) } /* - * Preallocate and store tnodes before the actual work so we - * don't get into an inconsistent state if memory allocation - * fails. In case of failure we return the oldnode and halve + * Preallocate and store tnodes before the actual work so we + * don't get into an inconsistent state if memory allocation + * fails. In case of failure we return the oldnode and halve * of tnode is ignored. */ for(i = 0; i < olen; i += 2) { left = tnode_get_child(oldtnode, i); right = tnode_get_child(oldtnode, i+1); - + /* Two nonempty children */ - if( left && right) { + if (left && right) { struct tnode *newBinNode = tnode_new(left->key, tn->pos + tn->bits, 1); - if(!newBinNode) { - *err = -ENOMEM; + if (!newBinNode) { + *err = -ENOMEM; break; } put_child(t, tn, i/2, (struct node *)newBinNode); } } - if(*err) { + if (*err) { int size = tnode_child_length(tn); int j; - for(j = 0; j < size; j++) - if( tn->child[j]) + for(j = 0; j < size; j++) + if (tn->child[j]) tnode_free((struct tnode *)tn->child[j]); tnode_free(tn); - + *err = -ENOMEM; return oldtnode; } @@ -850,7 +852,7 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err) for(i = 0; i < olen; i += 2) { left = tnode_get_child(oldtnode, i); right = tnode_get_child(oldtnode, i+1); - + /* At least one of the children is empty */ if (left == NULL) { if (right == NULL) /* Both are empty */ @@ -858,14 +860,14 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err) put_child(t, tn, i/2, right); } else if (right == NULL) put_child(t, tn, i/2, left); - + /* Two nonempty children */ else { struct tnode *newBinNode = (struct tnode *) tnode_get_child(tn, i/2); put_child(t, tn, i/2, NULL); - if(!newBinNode) + if (!newBinNode) BUG(); put_child(t, newBinNode, 0, left); @@ -879,7 +881,7 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err) static void *trie_init(struct trie *t) { - if(t) { + if (t) { t->size = 0; t->trie = NULL; t->revision = 0; @@ -896,8 +898,7 @@ static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen) struct leaf_info *li; hlist_for_each_entry(li, node, head, hlist) { - - if ( li->plen == plen ) + if (li->plen == plen) return li; } return NULL; @@ -905,35 +906,35 @@ static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen) static inline struct list_head * get_fa_head(struct leaf *l, int plen) { - struct list_head *fa_head=NULL; + struct list_head *fa_head = NULL; struct leaf_info *li = find_leaf_info(&l->list, plen); - - if(li) + + if (li) fa_head = &li->falh; - + return fa_head; } static void insert_leaf_info(struct hlist_head *head, struct leaf_info *new) { - struct leaf_info *li=NULL, *last=NULL; + struct leaf_info *li = NULL, *last = NULL; struct hlist_node *node, *tmp; write_lock_bh(&fib_lock); - - if(hlist_empty(head)) + + if (hlist_empty(head)) hlist_add_head(&new->hlist, head); else { hlist_for_each_entry_safe(li, node, tmp, head, hlist) { - - if (new->plen > li->plen) + + if (new->plen > li->plen) break; - + last = li; } - if(last) + if (last) hlist_add_after(&last->hlist, &new->hlist); - else + else hlist_add_before(&new->hlist, &li->hlist); } write_unlock_bh(&fib_lock); @@ -947,14 +948,14 @@ fib_find_node(struct trie *t, u32 key) struct node *n; pos = 0; - n=t->trie; + n = t->trie; while (n != NULL && NODE_TYPE(n) == T_TNODE) { tn = (struct tnode *) n; - + check_tnode(tn); - - if(tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) { + + if (tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) { pos=tn->pos + tn->bits; n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits)); } @@ -977,23 +978,23 @@ static struct node *trie_rebalance(struct trie *t, struct tnode *tn) t_key cindex, key; struct tnode *tp = NULL; - if(!tn) + if (!tn) BUG(); - + key = tn->key; i = 0; while (tn != NULL && NODE_PARENT(tn) != NULL) { - if( i > 10 ) { + if (i > 10) { printk("Rebalance tn=%p \n", tn); - if(tn) printk("tn->parent=%p \n", NODE_PARENT(tn)); - + if (tn) printk("tn->parent=%p \n", NODE_PARENT(tn)); + printk("Rebalance tp=%p \n", tp); - if(tp) printk("tp->parent=%p \n", NODE_PARENT(tp)); + if (tp) printk("tp->parent=%p \n", NODE_PARENT(tp)); } - if( i > 12 ) BUG(); + if (i > 12) BUG(); i++; tp = NODE_PARENT(tn); @@ -1001,14 +1002,14 @@ static struct node *trie_rebalance(struct trie *t, struct tnode *tn) wasfull = tnode_full(tp, tnode_get_child(tp, cindex)); tn = (struct tnode *) resize (t, (struct tnode *)tn); tnode_put_child_reorg((struct tnode *)tp, cindex,(struct node*)tn, wasfull); - - if(!NODE_PARENT(tn)) + + if (!NODE_PARENT(tn)) break; tn = NODE_PARENT(tn); } /* Handle last (top) tnode */ - if (IS_TNODE(tn)) + if (IS_TNODE(tn)) tn = (struct tnode*) resize(t, (struct tnode *)tn); return (struct node*) tn; @@ -1022,42 +1023,42 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen) struct node *n; struct leaf *l; int missbit; - struct list_head *fa_head=NULL; + struct list_head *fa_head = NULL; struct leaf_info *li; t_key cindex; pos = 0; - n=t->trie; + n = t->trie; - /* If we point to NULL, stop. Either the tree is empty and we should - * just put a new leaf in if, or we have reached an empty child slot, + /* If we point to NULL, stop. Either the tree is empty and we should + * just put a new leaf in if, or we have reached an empty child slot, * and we should just put our new leaf in that. - * If we point to a T_TNODE, check if it matches our key. Note that - * a T_TNODE might be skipping any number of bits - its 'pos' need + * If we point to a T_TNODE, check if it matches our key. Note that + * a T_TNODE might be skipping any number of bits - its 'pos' need * not be the parent's 'pos'+'bits'! * - * If it does match the current key, get pos/bits from it, extract + * If it does match the current key, get pos/bits from it, extract * the index from our key, push the T_TNODE and walk the tree. * * If it doesn't, we have to replace it with a new T_TNODE. * - * If we point to a T_LEAF, it might or might not have the same key - * as we do. If it does, just change the value, update the T_LEAF's - * value, and return it. + * If we point to a T_LEAF, it might or might not have the same key + * as we do. If it does, just change the value, update the T_LEAF's + * value, and return it. * If it doesn't, we need to replace it with a T_TNODE. */ while (n != NULL && NODE_TYPE(n) == T_TNODE) { tn = (struct tnode *) n; - - check_tnode(tn); - if(tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) { + check_tnode(tn); + + if (tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) { tp = tn; pos=tn->pos + tn->bits; n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits)); - if(n && NODE_PARENT(n) != tn) { + if (n && NODE_PARENT(n) != tn) { printk("BUG tn=%p, n->parent=%p\n", tn, NODE_PARENT(n)); BUG(); } @@ -1069,21 +1070,21 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen) /* * n ----> NULL, LEAF or TNODE * - * tp is n's (parent) ----> NULL or TNODE + * tp is n's (parent) ----> NULL or TNODE */ - if(tp && IS_LEAF(tp)) + if (tp && IS_LEAF(tp)) BUG(); /* Case 1: n is a leaf. Compare prefixes */ - if (n != NULL && IS_LEAF(n) && tkey_equals(key, n->key)) { + if (n != NULL && IS_LEAF(n) && tkey_equals(key, n->key)) { struct leaf *l = ( struct leaf *) n; - + li = leaf_info_new(plen); - - if(! li) { + + if (!li) { *err = -ENOMEM; goto err; } @@ -1095,7 +1096,7 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen) t->size++; l = leaf_new(); - if(! l) { + if (!l) { *err = -ENOMEM; goto err; } @@ -1103,7 +1104,7 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen) l->key = key; li = leaf_info_new(plen); - if(! li) { + if (!li) { tnode_free((struct tnode *) l); *err = -ENOMEM; goto err; @@ -1116,8 +1117,8 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen) if (t->trie && n == NULL) { NODE_SET_PARENT(l, tp); - - if (!tp) + + if (!tp) BUG(); else { @@ -1127,8 +1128,8 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen) } /* Case 3: n is a LEAF or a TNODE and the key doesn't match. */ else { - /* - * Add a new tnode here + /* + * Add a new tnode here * first tnode need some special handling */ @@ -1136,39 +1137,39 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen) pos=tp->pos+tp->bits; else pos=0; - if(n) { + if (n) { newpos = tkey_mismatch(key, pos, n->key); tn = tnode_new(n->key, newpos, 1); } else { newpos = 0; - tn = tnode_new(key, newpos, 1); /* First tnode */ + tn = tnode_new(key, newpos, 1); /* First tnode */ } - if(!tn) { + if (!tn) { free_leaf_info(li); tnode_free((struct tnode *) l); *err = -ENOMEM; goto err; - } - + } + NODE_SET_PARENT(tn, tp); missbit=tkey_extract_bits(key, newpos, 1); put_child(t, tn, missbit, (struct node *)l); put_child(t, tn, 1-missbit, n); - if(tp) { + if (tp) { cindex = tkey_extract_bits(key, tp->pos, tp->bits); put_child(t, (struct tnode *)tp, cindex, (struct node *)tn); } - else { + else { t->trie = (struct node*) tn; /* First tnode */ tp = tn; } } - if(tp && tp->pos+tp->bits > 32) { - printk("ERROR tp=%p pos=%d, bits=%d, key=%0x plen=%d\n", + if (tp && tp->pos+tp->bits > 32) { + printk("ERROR tp=%p pos=%d, bits=%d, key=%0x plen=%d\n", tp, tp->pos, tp->bits, key, plen); } /* Rebalance the trie */ @@ -1185,7 +1186,7 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, { struct trie *t = (struct trie *) tb->tb_data; struct fib_alias *fa, *new_fa; - struct list_head *fa_head=NULL; + struct list_head *fa_head = NULL; struct fib_info *fi; int plen = r->rtm_dst_len; int type = r->rtm_type; @@ -1198,17 +1199,17 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, return -EINVAL; key = 0; - if (rta->rta_dst) + if (rta->rta_dst) memcpy(&key, rta->rta_dst, 4); key = ntohl(key); - if(trie_debug) + if (trie_debug) printk("Insert table=%d %08x/%d\n", tb->tb_id, key, plen); - mask = ntohl( inet_make_mask(plen) ); + mask = ntohl( inet_make_mask(plen) ); - if(key & ~mask) + if (key & ~mask) return -EINVAL; key = key & mask; @@ -1217,9 +1218,9 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, goto err; l = fib_find_node(t, key); - fa = NULL; + fa = NULL; - if(l) { + if (l) { fa_head = get_fa_head(l, plen); fa = fib_find_alias(fa_head, tos, fi->fib_priority); } @@ -1298,16 +1299,16 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, new_fa->fa_scope = r->rtm_scope; new_fa->fa_state = 0; #if 0 - new_fa->dst = NULL; + new_fa->dst = NULL; #endif /* * Insert new entry to the list. */ - if(!fa_head) { + if (!fa_head) { fa_head = fib_insert_node(t, &err, key, plen); err = 0; - if(err) + if (err) goto out_free_new_fa; } @@ -1327,11 +1328,11 @@ out_free_new_fa: kmem_cache_free(fn_alias_kmem, new_fa); out: fib_release_info(fi); -err:; +err:; return err; } -static inline int check_leaf(struct trie *t, struct leaf *l, t_key key, int *plen, const struct flowi *flp, +static inline int check_leaf(struct trie *t, struct leaf *l, t_key key, int *plen, const struct flowi *flp, struct fib_result *res, int *err) { int i; @@ -1339,12 +1340,12 @@ static inline int check_leaf(struct trie *t, struct leaf *l, t_key key, int *pl struct leaf_info *li; struct hlist_head *hhead = &l->list; struct hlist_node *node; - + hlist_for_each_entry(li, node, hhead, hlist) { i = li->plen; mask = ntohl(inet_make_mask(i)); - if (l->key != (key & mask)) + if (l->key != (key & mask)) continue; 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 n = t->trie; read_lock(&fib_lock); - if(!n) + if (!n) goto failed; #ifdef CONFIG_IP_FIB_TRIE_STATS @@ -1385,19 +1386,19 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result /* Just a leaf? */ if (IS_LEAF(n)) { - if( check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret) ) + if (check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret)) goto found; goto failed; } pn = (struct tnode *) n; chopped_off = 0; - + while (pn) { pos = pn->pos; bits = pn->bits; - if(!chopped_off) + if (!chopped_off) cindex = tkey_extract_bits(MASK_PFX(key, current_prefix_length), pos, bits); n = tnode_get_child(pn, cindex); @@ -1417,33 +1418,33 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result int mp; /* - * It's a tnode, and we can do some extra checks here if we + * It's a tnode, and we can do some extra checks here if we * like, to avoid descending into a dead-end branch. - * This tnode is in the parent's child array at index - * key[p_pos..p_pos+p_bits] but potentially with some bits - * chopped off, so in reality the index may be just a + * This tnode is in the parent's child array at index + * key[p_pos..p_pos+p_bits] but potentially with some bits + * chopped off, so in reality the index may be just a * subprefix, padded with zero at the end. - * We can also take a look at any skipped bits in this - * tnode - everything up to p_pos is supposed to be ok, + * We can also take a look at any skipped bits in this + * tnode - everything up to p_pos is supposed to be ok, * and the non-chopped bits of the index (se previous - * paragraph) are also guaranteed ok, but the rest is + * paragraph) are also guaranteed ok, but the rest is * considered unknown. * * The skipped bits are key[pos+bits..cn->pos]. */ - - /* If current_prefix_length < pos+bits, we are already doing - * actual prefix matching, which means everything from - * pos+(bits-chopped_off) onward must be zero along some - * branch of this subtree - otherwise there is *no* valid + + /* If current_prefix_length < pos+bits, we are already doing + * actual prefix matching, which means everything from + * pos+(bits-chopped_off) onward must be zero along some + * branch of this subtree - otherwise there is *no* valid * prefix present. Here we can only check the skipped - * bits. Remember, since we have already indexed into the - * parent's child array, we know that the bits we chopped of + * bits. Remember, since we have already indexed into the + * parent's child array, we know that the bits we chopped of * *are* zero. */ /* NOTA BENE: CHECKING ONLY SKIPPED BITS FOR THE NEW NODE HERE */ - + if (current_prefix_length < pos+bits) { if (tkey_extract_bits(cn->key, current_prefix_length, cn->pos - current_prefix_length) != 0 || @@ -1452,13 +1453,13 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result } /* - * If chopped_off=0, the index is fully validated and we - * only need to look at the skipped bits for this, the new, + * If chopped_off=0, the index is fully validated and we + * only need to look at the skipped bits for this, the new, * tnode. What we actually want to do is to find out if * these skipped bits match our key perfectly, or if we will - * have to count on finding a matching prefix further down, - * because if we do, we would like to have some way of - * verifying the existence of such a prefix at this point. + * have to count on finding a matching prefix further down, + * because if we do, we would like to have some way of + * verifying the existence of such a prefix at this point. */ /* 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 * new tnode's key. */ - /* Note: We aren't very concerned about the piece of the key - * that precede pn->pos+pn->bits, since these have already been - * checked. The bits after cn->pos aren't checked since these are - * by definition "unknown" at this point. Thus, what we want to - * see is if we are about to enter the "prefix matching" state, - * and in that case verify that the skipped bits that will prevail - * throughout this subtree are zero, as they have to be if we are + /* Note: We aren't very concerned about the piece of the key + * that precede pn->pos+pn->bits, since these have already been + * checked. The bits after cn->pos aren't checked since these are + * by definition "unknown" at this point. Thus, what we want to + * see is if we are about to enter the "prefix matching" state, + * and in that case verify that the skipped bits that will prevail + * throughout this subtree are zero, as they have to be if we are * to find a matching prefix. */ node_prefix = MASK_PFX(cn->key, cn->pos); - key_prefix = MASK_PFX(key, cn->pos); + key_prefix = MASK_PFX(key, cn->pos); pref_mismatch = key_prefix^node_prefix; mp = 0; - /* In short: If skipped bits in this node do not match the search + /* In short: If skipped bits in this node do not match the search * key, enter the "prefix matching" state.directly. */ if (pref_mismatch) { @@ -1494,7 +1495,7 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result pref_mismatch = pref_mismatch <<1; } key_prefix = tkey_extract_bits(cn->key, mp, cn->pos-mp); - + if (key_prefix != 0) goto backtrace; @@ -1505,9 +1506,9 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result pn = (struct tnode *)n; /* Descend */ chopped_off = 0; continue; - } - if (IS_LEAF(n)) { - if( check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret)) + } + if (IS_LEAF(n)) { + if (check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret)) goto found; } backtrace: @@ -1521,18 +1522,18 @@ backtrace: /* Decrease current_... with bits chopped off */ if (current_prefix_length > pn->pos + pn->bits - chopped_off) current_prefix_length = pn->pos + pn->bits - chopped_off; - + /* - * Either we do the actual chop off according or if we have + * Either we do the actual chop off according or if we have * chopped off all bits in this tnode walk up to our parent. */ - if(chopped_off <= pn->bits) + if (chopped_off <= pn->bits) cindex &= ~(1 << (chopped_off-1)); else { - if( NODE_PARENT(pn) == NULL) + if (NODE_PARENT(pn) == NULL) goto failed; - + /* Get Child's index */ cindex = tkey_extract_bits(pn->key, NODE_PARENT(pn)->pos, NODE_PARENT(pn)->bits); pn = NODE_PARENT(pn); @@ -1542,10 +1543,10 @@ backtrace: t->stats.backtrack++; #endif goto backtrace; - } + } } failed: - ret = 1; + ret = 1; found: read_unlock(&fib_lock); return ret; @@ -1558,11 +1559,11 @@ static int trie_leaf_remove(struct trie *t, t_key key) struct node *n = t->trie; struct leaf *l; - if(trie_debug) + if (trie_debug) printk("entering trie_leaf_remove(%p)\n", n); /* Note that in the case skipped bits, those bits are *not* checked! - * When we finish this, we will have NULL or a T_LEAF, and the + * When we finish this, we will have NULL or a T_LEAF, and the * T_LEAF may or may not match our key. */ @@ -1571,19 +1572,19 @@ static int trie_leaf_remove(struct trie *t, t_key key) check_tnode(tn); n = tnode_get_child(tn ,tkey_extract_bits(key, tn->pos, tn->bits)); - if(n && NODE_PARENT(n) != tn) { + if (n && NODE_PARENT(n) != tn) { printk("BUG tn=%p, n->parent=%p\n", tn, NODE_PARENT(n)); BUG(); } } l = (struct leaf *) n; - if(!n || !tkey_equals(l->key, key)) + if (!n || !tkey_equals(l->key, key)) return 0; - - /* - * Key found. - * Remove the leaf and rebalance the tree + + /* + * Key found. + * Remove the leaf and rebalance the tree */ t->revision++; @@ -1592,7 +1593,7 @@ static int trie_leaf_remove(struct trie *t, t_key key) tp = NODE_PARENT(n); tnode_free((struct tnode *) n); - if(tp) { + if (tp) { cindex = tkey_extract_bits(key, tp->pos, tp->bits); put_child(t, (struct tnode *)tp, cindex, NULL); t->trie = trie_rebalance(t, tp); @@ -1615,23 +1616,23 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, struct list_head *fa_head; struct leaf *l; - if (plen > 32) + if (plen > 32) return -EINVAL; key = 0; - if (rta->rta_dst) + if (rta->rta_dst) memcpy(&key, rta->rta_dst, 4); key = ntohl(key); - mask = ntohl( inet_make_mask(plen) ); + mask = ntohl( inet_make_mask(plen) ); - if(key & ~mask) + if (key & ~mask) return -EINVAL; key = key & mask; l = fib_find_node(t, key); - if(!l) + if (!l) return -ESRCH; 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, list_del(&fa->fa_list); - if(list_empty(fa_head)) { + if (list_empty(fa_head)) { hlist_del(&li->hlist); kill_li = 1; } write_unlock_bh(&fib_lock); - - if(kill_li) + + if (kill_li) free_leaf_info(li); - if(hlist_empty(&l->list)) + if (hlist_empty(&l->list)) trie_leaf_remove(t, key); if (fa->fa_state & FA_S_ACCESSED) @@ -1705,12 +1706,12 @@ static int trie_flush_list(struct trie *t, struct list_head *head) list_for_each_entry_safe(fa, fa_node, head, fa_list) { struct fib_info *fi = fa->fa_info; - + if (fi && (fi->fib_flags&RTNH_F_DEAD)) { - write_lock_bh(&fib_lock); + write_lock_bh(&fib_lock); list_del(&fa->fa_list); - write_unlock_bh(&fib_lock); + write_unlock_bh(&fib_lock); fn_free_alias(fa); found++; @@ -1727,14 +1728,14 @@ static int trie_flush_leaf(struct trie *t, struct leaf *l) struct leaf_info *li = NULL; hlist_for_each_entry_safe(li, node, tmp, lih, hlist) { - + found += trie_flush_list(t, &li->falh); if (list_empty(&li->falh)) { - write_lock_bh(&fib_lock); + write_lock_bh(&fib_lock); hlist_del(&li->hlist); - write_unlock_bh(&fib_lock); + write_unlock_bh(&fib_lock); free_leaf_info(li); } @@ -1748,8 +1749,8 @@ static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf) struct tnode *p; int idx; - if(c == NULL) { - if(t->trie == NULL) + if (c == NULL) { + if (t->trie == NULL) return NULL; if (IS_LEAF(t->trie)) /* trie w. just a leaf */ @@ -1757,33 +1758,34 @@ static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf) p = (struct tnode*) t->trie; /* Start */ } - else + else p = (struct tnode *) NODE_PARENT(c); + while (p) { int pos, last; /* Find the next child of the parent */ - if(c) - pos = 1 + tkey_extract_bits(c->key, p->pos, p->bits); - else + if (c) + pos = 1 + tkey_extract_bits(c->key, p->pos, p->bits); + else pos = 0; last = 1 << p->bits; for(idx = pos; idx < last ; idx++) { - if( p->child[idx]) { + if (p->child[idx]) { /* Decend if tnode */ while (IS_TNODE(p->child[idx])) { p = (struct tnode*) p->child[idx]; idx = 0; - + /* Rightmost non-NULL branch */ - if( p && IS_TNODE(p) ) - while ( p->child[idx] == NULL && idx < (1 << p->bits) ) idx++; + if (p && IS_TNODE(p)) + while (p->child[idx] == NULL && idx < (1 << p->bits)) idx++; /* Done with this tnode? */ - if( idx >= (1 << p->bits) || p->child[idx] == NULL ) + if (idx >= (1 << p->bits) || p->child[idx] == NULL ) goto up; } return (struct leaf*) p->child[idx]; @@ -1816,7 +1818,7 @@ static int fn_trie_flush(struct fib_table *tb) if (ll && hlist_empty(&ll->list)) trie_leaf_remove(t, ll->key); - if(trie_debug) + if (trie_debug) printk("trie_flush found=%d\n", found); return found; } @@ -1839,32 +1841,32 @@ fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib order = -1; read_lock(&fib_lock); - + l = fib_find_node(t, 0); - if(!l) + if (!l) goto out; fa_head = get_fa_head(l, 0); - if(!fa_head) + if (!fa_head) goto out; - if (list_empty(fa_head)) + if (list_empty(fa_head)) goto out; list_for_each_entry(fa, fa_head, fa_list) { struct fib_info *next_fi = fa->fa_info; - + if (fa->fa_scope != res->scope || fa->fa_type != RTN_UNICAST) continue; - + if (next_fi->fib_priority > res->fi->fib_priority) break; if (!next_fi->fib_nh[0].nh_gw || next_fi->fib_nh[0].nh_scope != RT_SCOPE_LINK) continue; fa->fa_state |= FA_S_ACCESSED; - + if (fi == NULL) { if (next_fi != res->fi) break; @@ -1902,10 +1904,10 @@ fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib } trie_last_dflt = last_idx; out:; - read_unlock(&fib_lock); + read_unlock(&fib_lock); } -static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fib_table *tb, +static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fib_table *tb, struct sk_buff *skb, struct netlink_callback *cb) { 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 return skb->len; } -static int fn_trie_dump_plen(struct trie *t, int plen, struct fib_table *tb, struct sk_buff *skb, +static int fn_trie_dump_plen(struct trie *t, int plen, struct fib_table *tb, struct sk_buff *skb, struct netlink_callback *cb) { int h, s_h; @@ -1968,11 +1970,11 @@ static int fn_trie_dump_plen(struct trie *t, int plen, struct fib_table *tb, str sizeof(cb->args) - 3*sizeof(cb->args[0])); fa_head = get_fa_head(l, plen); - - if(!fa_head) + + if (!fa_head) continue; - if(list_empty(fa_head)) + if (list_empty(fa_head)) continue; 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) trie_init(t); - if (id == RT_TABLE_LOCAL) - trie_local=t; - else if (id == RT_TABLE_MAIN) - trie_main=t; + if (id == RT_TABLE_LOCAL) + trie_local = t; + else if (id == RT_TABLE_MAIN) + trie_main = t; if (id == RT_TABLE_LOCAL) 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) seq_printf(seq, "%s", (v & (1<key >> 24, (n->key >> 16) % 256, (n->key >> 8) % 256, n->key % 256); else { - int plen=((struct tnode *)n)->pos; + int plen = ((struct tnode *)n)->pos; t_key prf=MASK_PFX(n->key, plen); - seq_printf(seq, "key=%d.%d.%d.%d/%d\n", + seq_printf(seq, "key=%d.%d.%d.%d/%d\n", prf >> 24, (prf >> 16) % 256, (prf >> 8) % 256, prf % 256, plen); } if (IS_LEAF(n)) { @@ -2103,14 +2105,14 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n, struct fib_alias *fa; int i; for (i=32; i>=0; i--) - if(find_leaf_info(&l->list, i)) { - + if (find_leaf_info(&l->list, i)) { + struct list_head *fa_head = get_fa_head(l, i); - - if(!fa_head) + + if (!fa_head) continue; - if(list_empty(fa_head)) + if (list_empty(fa_head)) continue; putspace_seq(seq, indent+2); @@ -2136,7 +2138,7 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n, } } else if (IS_TNODE(n)) { - struct tnode *tn=(struct tnode *)n; + struct tnode *tn = (struct tnode *)n; putspace_seq(seq, indent); seq_printf(seq, "| "); seq_printf(seq, "{key prefix=%08x/", tn->key&TKEY_GET_MASK(0, tn->pos)); 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, static void trie_dump_seq(struct seq_file *seq, struct trie *t) { - struct node *n=t->trie; + struct node *n = t->trie; int cindex=0; int indent=1; int pend=0; @@ -2164,7 +2166,7 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t) if (n) { printnode_seq(seq, indent, n, pend, cindex, 0); if (IS_TNODE(n)) { - struct tnode *tn=(struct tnode *)n; + struct tnode *tn = (struct tnode *)n; pend = tn->pos+tn->bits; putspace_seq(seq, indent); seq_printf(seq, "\\--\n"); indent += 3; @@ -2172,42 +2174,42 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t) while (tn && cindex < (1 << tn->bits)) { if (tn->child[cindex]) { - + /* Got a child */ - + printnode_seq(seq, indent, tn->child[cindex], pend, cindex, tn->bits); - if (IS_LEAF(tn->child[cindex])) { + if (IS_LEAF(tn->child[cindex])) { cindex++; - + } else { - /* - * New tnode. Decend one level + /* + * New tnode. Decend one level */ - + depth++; - n=tn->child[cindex]; - tn=(struct tnode *)n; - pend=tn->pos+tn->bits; + n = tn->child[cindex]; + tn = (struct tnode *)n; + pend = tn->pos+tn->bits; putspace_seq(seq, indent); seq_printf(seq, "\\--\n"); indent+=3; cindex=0; } } - else + else cindex++; /* - * Test if we are done + * Test if we are done */ - + while (cindex >= (1 << tn->bits)) { /* * Move upwards and test for root * pop off all traversed nodes */ - + if (NODE_PARENT(tn) == NULL) { tn = NULL; n = NULL; @@ -2217,8 +2219,8 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t) cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); tn = NODE_PARENT(tn); cindex++; - n=(struct node *)tn; - pend=tn->pos+tn->bits; + n = (struct node *)tn; + pend = tn->pos+tn->bits; indent-=3; depth--; } @@ -2236,36 +2238,36 @@ static struct trie_stat *trie_stat_new(void) { struct trie_stat *s = kmalloc(sizeof(struct trie_stat), GFP_KERNEL); int i; - - if(s) { + + if (s) { s->totdepth = 0; s->maxdepth = 0; s->tnodes = 0; s->leaves = 0; s->nullpointers = 0; - + for(i=0; i< MAX_CHILDS; i++) s->nodesizes[i] = 0; } return s; -} +} static struct trie_stat *trie_collect_stats(struct trie *t) { - struct node *n=t->trie; + struct node *n = t->trie; struct trie_stat *s = trie_stat_new(); int cindex = 0; int indent = 1; int pend = 0; int depth = 0; - read_lock(&fib_lock); + read_lock(&fib_lock); if (s) { if (n) { if (IS_TNODE(n)) { struct tnode *tn = (struct tnode *)n; - pend=tn->pos+tn->bits; + pend = tn->pos+tn->bits; indent += 3; s->nodesizes[tn->bits]++; depth++; @@ -2273,26 +2275,26 @@ static struct trie_stat *trie_collect_stats(struct trie *t) while (tn && cindex < (1 << tn->bits)) { if (tn->child[cindex]) { /* Got a child */ - - if (IS_LEAF(tn->child[cindex])) { + + if (IS_LEAF(tn->child[cindex])) { cindex++; - + /* stats */ if (depth > s->maxdepth) s->maxdepth = depth; s->totdepth += depth; s->leaves++; } - + else { - /* - * New tnode. Decend one level + /* + * New tnode. Decend one level */ - + s->tnodes++; s->nodesizes[tn->bits]++; depth++; - + n = tn->child[cindex]; tn = (struct tnode *)n; pend = tn->pos+tn->bits; @@ -2303,13 +2305,13 @@ static struct trie_stat *trie_collect_stats(struct trie *t) } else { cindex++; - s->nullpointers++; + s->nullpointers++; } /* - * Test if we are done + * Test if we are done */ - + while (cindex >= (1 << tn->bits)) { /* @@ -2317,7 +2319,7 @@ static struct trie_stat *trie_collect_stats(struct trie *t) * pop off all traversed nodes */ - + if (NODE_PARENT(tn) == NULL) { tn = NULL; n = NULL; @@ -2326,9 +2328,9 @@ static struct trie_stat *trie_collect_stats(struct trie *t) else { cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); tn = NODE_PARENT(tn); - cindex++; + cindex++; n = (struct node *)tn; - pend=tn->pos+tn->bits; + pend = tn->pos+tn->bits; indent -= 3; depth--; } @@ -2339,7 +2341,7 @@ static struct trie_stat *trie_collect_stats(struct trie *t) } } - read_unlock(&fib_lock); + read_unlock(&fib_lock); return s; } @@ -2375,7 +2377,7 @@ static void fib_triestat_seq_stop(struct seq_file *seq, void *v) } -/* +/* * This outputs /proc/net/fib_triestats * * It always works in backward compatibility mode. @@ -2401,7 +2403,7 @@ static void collect_and_show(struct trie *t, struct seq_file *seq) avdepth=0; seq_printf(seq, "Aver depth: %d.%02d\n", avdepth / 100, avdepth % 100 ); seq_printf(seq, "Max depth: %4d\n", stat->maxdepth); - + seq_printf(seq, "Leaves: %d\n", stat->leaves); bytes += sizeof(struct leaf) * stat->leaves; 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) max--; pointers = 0; - for (i = 1; i <= max; i++) + for (i = 1; i <= max; i++) if (stat->nodesizes[i] != 0) { seq_printf(seq, " %d: %d", i, stat->nodesizes[i]); pointers += (1<nodesizes[i]; @@ -2444,30 +2446,30 @@ static void collect_and_show(struct trie *t, struct seq_file *seq) static int fib_triestat_seq_show(struct seq_file *seq, void *v) { char bf[128]; - + if (v == SEQ_START_TOKEN) { - seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", + seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", sizeof(struct leaf), sizeof(struct tnode)); - if (trie_local) + if (trie_local) collect_and_show(trie_local, seq); - if (trie_main) + if (trie_main) collect_and_show(trie_main, seq); } else { snprintf(bf, sizeof(bf), "*\t%08X\t%08X", 200, 400); - + seq_printf(seq, "%-127s\n", bf); } return 0; } static struct seq_operations fib_triestat_seq_ops = { - .start = fib_triestat_seq_start, - .next = fib_triestat_seq_next, - .stop = fib_triestat_seq_stop, - .show = fib_triestat_seq_show, + .start = fib_triestat_seq_start, + .next = fib_triestat_seq_next, + .stop = fib_triestat_seq_stop, + .show = fib_triestat_seq_show, }; static 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) if (rc) goto out_kfree; - seq = file->private_data; + seq = file->private_data; out: return rc; out_kfree: @@ -2487,11 +2489,11 @@ out_kfree: } static struct file_operations fib_triestat_seq_fops = { - .owner = THIS_MODULE, - .open = fib_triestat_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release_private, + .owner = THIS_MODULE, + .open = fib_triestat_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release_private, }; int __init fib_stat_proc_init(void) @@ -2536,7 +2538,7 @@ static void fib_trie_seq_stop(struct seq_file *seq, void *v) } -/* +/* * This outputs /proc/net/fib_trie. * * It always works in backward compatibility mode. @@ -2548,10 +2550,10 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v) char bf[128]; if (v == SEQ_START_TOKEN) { - if (trie_local) + if (trie_local) trie_dump_seq(seq, trie_local); - if (trie_main) + if (trie_main) trie_dump_seq(seq, trie_main); } @@ -2565,10 +2567,10 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v) } static struct seq_operations fib_trie_seq_ops = { - .start = fib_trie_seq_start, - .next = fib_trie_seq_next, - .stop = fib_trie_seq_stop, - .show = fib_trie_seq_show, + .start = fib_trie_seq_start, + .next = fib_trie_seq_next, + .stop = fib_trie_seq_stop, + .show = fib_trie_seq_show, }; static 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) if (rc) goto out_kfree; - seq = file->private_data; + seq = file->private_data; out: return rc; out_kfree: @@ -2588,11 +2590,11 @@ out_kfree: } static struct file_operations fib_trie_seq_fops = { - .owner = THIS_MODULE, - .open = fib_trie_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release_private, + .owner = THIS_MODULE, + .open = fib_trie_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release= seq_release_private, }; int __init fib_proc_init(void) From 0303770deb834c15ca664a9d741d40f893c92f4e Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Tue, 19 Jul 2005 14:03:34 -0700 Subject: [PATCH 33/66] [NET]: Make ipip/ip6_tunnel independant of XFRM Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- include/net/xfrm.h | 2 +- net/ipv4/Kconfig | 1 - net/ipv4/ipip.c | 36 ++++++++++++++++++++++++++++++++---- net/ipv4/xfrm4_tunnel.c | 3 +-- net/ipv6/Kconfig | 1 - net/ipv6/ip6_tunnel.c | 38 +++++++++++++++++++++++++++++++++----- 6 files changed, 67 insertions(+), 14 deletions(-) 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 { /* XFRM tunnel handlers. */ struct xfrm_tunnel { int (*handler)(struct sk_buff *skb); - void (*err_handler)(struct sk_buff *skb, void *info); + void (*err_handler)(struct sk_buff *skb, __u32 info); }; struct xfrm6_tunnel { diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index c7f1f9245bc9..fc561c0ae8e2 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig @@ -235,7 +235,6 @@ config IP_PNP_RARP # bool ' IP: ARP support' CONFIG_IP_PNP_ARP config NET_IPIP tristate "IP: tunneling" - select INET_TUNNEL ---help--- Tunneling means encapsulating data of one protocol type within another protocol and sending it over a channel that understands the 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) dev_put(dev); } -static void ipip_err(struct sk_buff *skb, void *__unused) +static void ipip_err(struct sk_buff *skb, u32 info) { #ifndef I_WISH_WORLD_WERE_PERFECT @@ -852,11 +852,39 @@ static int __init ipip_fb_tunnel_init(struct net_device *dev) return 0; } +#ifdef CONFIG_INET_TUNNEL static struct xfrm_tunnel ipip_handler = { .handler = ipip_rcv, .err_handler = ipip_err, }; +static inline int ipip_register(void) +{ + return xfrm4_tunnel_register(&ipip_handler); +} + +static inline int ipip_unregister(void) +{ + return xfrm4_tunnel_deregister(&ipip_handler); +} +#else +static struct net_protocol ipip_protocol = { + .handler = ipip_rcv, + .err_handler = ipip_err, + .no_policy = 1, +}; + +static inline int ipip_register(void) +{ + return inet_add_protocol(&ipip_protocol, IPPROTO_IPIP); +} + +static inline int ipip_unregister(void) +{ + return inet_del_protocol(&ipip_protocol, IPPROTO_IPIP); +} +#endif + static char banner[] __initdata = KERN_INFO "IPv4 over IPv4 tunneling driver\n"; @@ -866,7 +894,7 @@ static int __init ipip_init(void) printk(banner); - if (xfrm4_tunnel_register(&ipip_handler) < 0) { + if (ipip_register() < 0) { printk(KERN_INFO "ipip init: can't register tunnel\n"); return -EAGAIN; } @@ -888,13 +916,13 @@ static int __init ipip_init(void) err2: free_netdev(ipip_fb_tunnel_dev); err1: - xfrm4_tunnel_deregister(&ipip_handler); + ipip_unregister(); goto out; } static void __exit ipip_fini(void) { - if (xfrm4_tunnel_deregister(&ipip_handler) < 0) + if (ipip_unregister() < 0) printk(KERN_INFO "ipip close: can't deregister tunnel\n"); unregister_netdev(ipip_fb_tunnel_dev); 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) static void ipip_err(struct sk_buff *skb, u32 info) { struct xfrm_tunnel *handler = ipip_handler; - u32 arg = info; if (handler) - handler->err_handler(skb, &arg); + handler->err_handler(skb, info); } static 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 config IPV6_TUNNEL tristate "IPv6: IPv6-in-IPv6 tunnel" depends on IPV6 - select INET6_TUNNEL ---help--- Support for IPv6-in-IPv6 tunnels described in RFC 2473. diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index ba3b0c267f75..f39ddeae1eef 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) return 0; } +#ifdef CONFIG_INET6_TUNNEL static struct xfrm6_tunnel ip6ip6_handler = { - .handler = ip6ip6_rcv, - .err_handler = ip6ip6_err, + .handler = ip6ip6_rcv, + .err_handler = ip6ip6_err, }; +static inline int ip6ip6_register(void) +{ + return xfrm6_tunnel_register(&ip6ip6_handler); +} + +static inline int ip6ip6_unregister(void) +{ + return xfrm6_tunnel_unregister(&ip6ip6_handler); +} +#else +static struct inet6_protocol xfrm6_tunnel_protocol = { + .handler = ip6ip6_rcv, + .err_handler = ip6ip6_err, + .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, +}; + +static inline int ip6ip6_register(void) +{ + return inet6_add_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6); +} + +static inline int ip6ip6_unregister(void) +{ + return inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6); +} +#endif + /** * ip6_tunnel_init - register protocol and reserve needed resources * @@ -1125,7 +1153,7 @@ static int __init ip6_tunnel_init(void) { int err; - if (xfrm6_tunnel_register(&ip6ip6_handler) < 0) { + if (ip6ip6_register() < 0) { printk(KERN_ERR "ip6ip6 init: can't register tunnel\n"); return -EAGAIN; } @@ -1144,7 +1172,7 @@ static int __init ip6_tunnel_init(void) } return 0; fail: - xfrm6_tunnel_deregister(&ip6ip6_handler); + ip6ip6_unregister(); return err; } @@ -1154,7 +1182,7 @@ fail: static void __exit ip6_tunnel_cleanup(void) { - if (xfrm6_tunnel_deregister(&ip6ip6_handler) < 0) + if (ip6ip6_unregister() < 0) printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n"); unregister_netdev(ip6ip6_fb_tnl_dev); From b72f6eccb0fc516070f2de469f73870cb6cb1149 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 19 Jul 2005 14:13:54 -0700 Subject: [PATCH 34/66] [NET]: Fix tc_verd thinko in skb_clone() It was overwriting the computer n->tc_verd value over and over with skb->tc_verd, by mistake. Signed-off-by: David S. Miller --- net/core/skbuff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) C(tc_index); #ifdef CONFIG_NET_CLS_ACT n->tc_verd = SET_TC_VERD(skb->tc_verd,0); - n->tc_verd = CLR_TC_OK2MUNGE(skb->tc_verd); - n->tc_verd = CLR_TC_MUNGED(skb->tc_verd); + n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd); + n->tc_verd = CLR_TC_MUNGED(n->tc_verd); C(input_dev); C(tc_classid); #endif From 4aa49d130df9209707a97786a55a3f584b7345e9 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Wed, 20 Jul 2005 12:01:46 -0700 Subject: [PATCH 35/66] [ATM]: zatm: mailbox converted to pci_alloc_consistent() mailbox converted to pci_alloc_consistent() - request_region() is not needed: zatm_init_one() issues pci_request_regions(); - the warning related to kfree(zatm_dev->mbx_start) disappears; Compiled with i386 and sparc64 as target. Signed-off-by: Francois Romieu Signed-off-by: David S. Miller --- drivers/atm/zatm.c | 109 ++++++++++++++++++++++++++------------------- drivers/atm/zatm.h | 1 + 2 files changed, 63 insertions(+), 47 deletions(-) diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c index afcf1ada5547..a2b236a966e0 100644 --- a/drivers/atm/zatm.c +++ b/drivers/atm/zatm.c @@ -16,9 +16,9 @@ #include #include #include -#include /* for request_region */ #include #include +#include #include #include #include @@ -1257,22 +1257,22 @@ static int __init zatm_init(struct atm_dev *dev) static int __init zatm_start(struct atm_dev *dev) { - struct zatm_dev *zatm_dev; + struct zatm_dev *zatm_dev = ZATM_DEV(dev); + struct pci_dev *pdev = zatm_dev->pci_dev; unsigned long curr; int pools,vccs,rx; - int error,i,ld; + int error, i, ld; DPRINTK("zatm_start\n"); - zatm_dev = ZATM_DEV(dev); zatm_dev->rx_map = zatm_dev->tx_map = NULL; - for (i = 0; i < NR_MBX; i++) - zatm_dev->mbx_start[i] = 0; - if (request_irq(zatm_dev->irq,&zatm_int,SA_SHIRQ,DEV_LABEL,dev)) { - printk(KERN_ERR DEV_LABEL "(itf %d): IRQ%d is already in use\n", - dev->number,zatm_dev->irq); - return -EAGAIN; + for (i = 0; i < NR_MBX; i++) + zatm_dev->mbx_start[i] = 0; + error = request_irq(zatm_dev->irq, zatm_int, SA_SHIRQ, DEV_LABEL, dev); + if (error < 0) { + printk(KERN_ERR DEV_LABEL "(itf %d): IRQ%d is already in use\n", + dev->number,zatm_dev->irq); + goto done; } - request_region(zatm_dev->base,uPD98401_PORTS,DEV_LABEL); /* define memory regions */ pools = NR_POOLS; if (NR_SHAPERS*SHAPER_SIZE > pools*POOL_SIZE) @@ -1299,51 +1299,66 @@ static int __init zatm_start(struct atm_dev *dev) "%ld VCs\n",dev->number,NR_SHAPERS,pools,rx, (zatm_dev->mem-curr*4)/VC_SIZE); /* create mailboxes */ - for (i = 0; i < NR_MBX; i++) - if (mbx_entries[i]) { - unsigned long here; + for (i = 0; i < NR_MBX; i++) { + void *mbx; + dma_addr_t mbx_dma; - here = (unsigned long) kmalloc(2*MBX_SIZE(i), - GFP_KERNEL); - if (!here) { - error = -ENOMEM; - goto out; - } - if ((here^(here+MBX_SIZE(i))) & ~0xffffUL)/* paranoia */ - here = (here & ~0xffffUL)+0x10000; - zatm_dev->mbx_start[i] = here; - if ((here^virt_to_bus((void *) here)) & 0xffff) { - printk(KERN_ERR DEV_LABEL "(itf %d): system " - "bus incompatible with driver\n", - dev->number); - error = -ENODEV; - goto out; - } - DPRINTK("mbx@0x%08lx-0x%08lx\n",here,here+MBX_SIZE(i)); - zatm_dev->mbx_end[i] = (here+MBX_SIZE(i)) & 0xffff; - zout(virt_to_bus((void *) here) >> 16,MSH(i)); - zout(virt_to_bus((void *) here),MSL(i)); - zout((here+MBX_SIZE(i)) & 0xffff,MBA(i)); - zout(here & 0xffff,MTA(i)); - zout(here & 0xffff,MWA(i)); + if (!mbx_entries[i]) + continue; + mbx = pci_alloc_consistent(pdev, 2*MBX_SIZE(i), &mbx_dma); + if (!mbx) { + error = -ENOMEM; + goto out; } + /* + * Alignment provided by pci_alloc_consistent() isn't enough + * for this device. + */ + if (((unsigned long)mbx ^ mbx_dma) & 0xffff) { + printk(KERN_ERR DEV_LABEL "(itf %d): system " + "bus incompatible with driver\n", dev->number); + pci_free_consistent(pdev, 2*MBX_SIZE(i), mbx, mbx_dma); + error = -ENODEV; + goto out; + } + DPRINTK("mbx@0x%08lx-0x%08lx\n", mbx, mbx + MBX_SIZE(i)); + zatm_dev->mbx_start[i] = (unsigned long)mbx; + zatm_dev->mbx_dma[i] = mbx_dma; + zatm_dev->mbx_end[i] = (zatm_dev->mbx_start[i] + MBX_SIZE(i)) & + 0xffff; + zout(mbx_dma >> 16, MSH(i)); + zout(mbx_dma, MSL(i)); + zout(zatm_dev->mbx_end[i], MBA(i)); + zout((unsigned long)mbx & 0xffff, MTA(i)); + zout((unsigned long)mbx & 0xffff, MWA(i)); + } error = start_tx(dev); - if (error) goto out; + if (error) + goto out; error = start_rx(dev); - if (error) goto out; + if (error) + goto out_tx; error = dev->phy->start(dev); - if (error) goto out; + if (error) + goto out_rx; zout(0xffffffff,IMR); /* enable interrupts */ /* enable TX & RX */ zout(zin(GMR) | uPD98401_GMR_SE | uPD98401_GMR_RE,GMR); - return 0; - out: - for (i = 0; i < NR_MBX; i++) - kfree(&zatm_dev->mbx_start[i]); - kfree(zatm_dev->rx_map); - kfree(zatm_dev->tx_map); - free_irq(zatm_dev->irq, dev); +done: return error; + +out_rx: + kfree(zatm_dev->rx_map); +out_tx: + kfree(zatm_dev->tx_map); +out: + while (i-- > 0) { + pci_free_consistent(pdev, 2*MBX_SIZE(i), + (void *)zatm_dev->mbx_start[i], + zatm_dev->mbx_dma[i]); + } + free_irq(zatm_dev->irq, dev); + goto done; } 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 { int chans; /* map size, must be 2^n */ /*-------------------------------- mailboxes */ unsigned long mbx_start[NR_MBX];/* start addresses */ + dma_addr_t mbx_dma[NR_MBX]; u16 mbx_end[NR_MBX]; /* end offset (in bytes) */ /*-------------------------------- other pointers */ u32 pool_base; /* Free buffer pool dsc (word addr) */ From ab9b6339381d340779e8b5957561aed41155a270 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 20 Jul 2005 21:32:26 +0100 Subject: [PATCH 36/66] [PATCH] ARM SMP: Mark mroe CPU init data with __cpuinitdata Signed-off-by: Russell King --- arch/arm/mach-integrator/platsmp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-integrator/platsmp.c b/arch/arm/mach-integrator/platsmp.c index c8eef97d0c16..aecf47ba033a 100644 --- a/arch/arm/mach-integrator/platsmp.c +++ b/arch/arm/mach-integrator/platsmp.c @@ -27,8 +27,8 @@ extern void integrator_secondary_startup(void); * control for which core is the next to come out of the secondary * boot "holding pen" */ -volatile int __initdata pen_release = -1; -unsigned long __initdata phys_pen_release = 0; +volatile int __cpuinitdata pen_release = -1; +unsigned long __cpuinitdata phys_pen_release = 0; static DEFINE_SPINLOCK(boot_lock); From 4acdbdbe5089c06d5e0c7e96783fcc4414ded00a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 21 Jul 2005 13:14:46 -0700 Subject: [PATCH 37/66] [NETFILTER]: ip_conntrack_expect_related must not free expectation If a connection tracking helper tells us to expect a connection, and we're already expecting that connection, we simply free the one they gave us and return success. The problem is that NAT helpers (eg. FTP) have to allocate the expectation first (to see what port is available) then rewrite the packet. If that rewrite fails, they try to remove the expectation, but it was freed in ip_conntrack_expect_related. This is one example of a larger problem: having registered the expectation, the pointer is no longer ours to use. Reference counting is needed for ctnetlink anyway, so introduce it now. To have a single "put" path, we need to grab the reference to the connection on creation, rather than open-coding it in the caller. Signed-off-by: Rusty Russell Signed-off-by: David S. Miller --- include/linux/netfilter_ipv4/ip_conntrack.h | 3 ++ .../netfilter_ipv4/ip_conntrack_helper.h | 7 ++-- net/ipv4/netfilter/ip_conntrack_amanda.c | 8 ++-- net/ipv4/netfilter/ip_conntrack_core.c | 40 +++++++++---------- net/ipv4/netfilter/ip_conntrack_ftp.c | 14 +++---- net/ipv4/netfilter/ip_conntrack_irc.c | 8 ++-- net/ipv4/netfilter/ip_conntrack_standalone.c | 2 +- net/ipv4/netfilter/ip_conntrack_tftp.c | 8 ++-- net/ipv4/netfilter/ip_nat_amanda.c | 4 +- net/ipv4/netfilter/ip_nat_ftp.c | 4 +- net/ipv4/netfilter/ip_nat_irc.c | 4 +- net/ipv4/netfilter/ip_nat_tftp.c | 4 +- 12 files changed, 46 insertions(+), 60 deletions(-) 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 /* Timer function; deletes the expectation. */ struct timer_list timeout; + /* Usage count. */ + atomic_t use; + #ifdef CONFIG_IP_NF_NAT_NEEDED /* This is the original per-proto part, used to map the * 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 *); extern void ip_conntrack_helper_unregister(struct ip_conntrack_helper *); /* Allocate space for an expectation: this is mandatory before calling - ip_conntrack_expect_related. */ -extern struct ip_conntrack_expect *ip_conntrack_expect_alloc(void); -extern void ip_conntrack_expect_free(struct ip_conntrack_expect *exp); + ip_conntrack_expect_related. You will have to call put afterwards. */ +extern struct ip_conntrack_expect * +ip_conntrack_expect_alloc(struct ip_conntrack *master); +extern void ip_conntrack_expect_put(struct ip_conntrack_expect *exp); /* Add an expected connection: can have more than one per connection */ extern int ip_conntrack_expect_related(struct ip_conntrack_expect *exp); 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, if (port == 0 || len > 5) break; - exp = ip_conntrack_expect_alloc(); + exp = ip_conntrack_expect_alloc(ct); if (exp == NULL) { ret = NF_DROP; goto out; } exp->expectfn = NULL; - exp->master = ct; exp->tuple.src.ip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; exp->tuple.src.u.tcp.port = 0; @@ -126,10 +125,9 @@ static int help(struct sk_buff **pskb, ret = ip_nat_amanda_hook(pskb, ctinfo, tmp - amanda_buffer, len, exp); - else if (ip_conntrack_expect_related(exp) != 0) { - ip_conntrack_expect_free(exp); + else if (ip_conntrack_expect_related(exp) != 0) ret = NF_DROP; - } + ip_conntrack_expect_put(exp); } out: diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c index 4b78ebeb6635..14af55cad5d6 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, /* ip_conntrack_expect helper functions */ -static void destroy_expect(struct ip_conntrack_expect *exp) -{ - ip_conntrack_put(exp->master); - IP_NF_ASSERT(!timer_pending(&exp->timeout)); - kmem_cache_free(ip_conntrack_expect_cachep, exp); - CONNTRACK_STAT_INC(expect_delete); -} - static void unlink_expect(struct ip_conntrack_expect *exp) { ASSERT_WRITE_LOCK(&ip_conntrack_lock); + IP_NF_ASSERT(!timer_pending(&exp->timeout)); list_del(&exp->list); - /* Logically in destroy_expect, but we hold the lock here. */ + CONNTRACK_STAT_INC(expect_delete); exp->master->expecting--; } @@ -160,7 +153,7 @@ static void expectation_timed_out(unsigned long ul_expect) write_lock_bh(&ip_conntrack_lock); unlink_expect(exp); write_unlock_bh(&ip_conntrack_lock); - destroy_expect(exp); + ip_conntrack_expect_put(exp); } /* If an expectation for this connection is found, it gets delete from @@ -198,7 +191,7 @@ static void remove_expectations(struct ip_conntrack *ct) list_for_each_entry_safe(i, tmp, &ip_conntrack_expect_list, list) { if (i->master == ct && del_timer(&i->timeout)) { unlink_expect(i); - destroy_expect(i); + ip_conntrack_expect_put(i); } } } @@ -537,7 +530,7 @@ init_conntrack(const struct ip_conntrack_tuple *tuple, if (exp) { if (exp->expectfn) exp->expectfn(conntrack, exp); - destroy_expect(exp); + ip_conntrack_expect_put(exp); } return &conntrack->tuplehash[IP_CT_DIR_ORIGINAL]; @@ -729,14 +722,14 @@ void ip_conntrack_unexpect_related(struct ip_conntrack_expect *exp) if (expect_matches(i, exp) && del_timer(&i->timeout)) { unlink_expect(i); write_unlock_bh(&ip_conntrack_lock); - destroy_expect(i); + ip_conntrack_expect_put(i); return; } } write_unlock_bh(&ip_conntrack_lock); } -struct ip_conntrack_expect *ip_conntrack_expect_alloc(void) +struct ip_conntrack_expect *ip_conntrack_expect_alloc(struct ip_conntrack *me) { struct ip_conntrack_expect *new; @@ -745,18 +738,23 @@ struct ip_conntrack_expect *ip_conntrack_expect_alloc(void) DEBUGP("expect_related: OOM allocating expect\n"); return NULL; } - new->master = NULL; + new->master = me; + atomic_inc(&new->master->ct_general.use); + atomic_set(&new->use, 1); return new; } -void ip_conntrack_expect_free(struct ip_conntrack_expect *expect) +void ip_conntrack_expect_put(struct ip_conntrack_expect *exp) { - kmem_cache_free(ip_conntrack_expect_cachep, expect); + if (atomic_dec_and_test(&exp->use)) { + ip_conntrack_put(exp->master); + kmem_cache_free(ip_conntrack_expect_cachep, exp); + } } static void ip_conntrack_expect_insert(struct ip_conntrack_expect *exp) { - atomic_inc(&exp->master->ct_general.use); + atomic_inc(&exp->use); exp->master->expecting++; list_add(&exp->list, &ip_conntrack_expect_list); @@ -778,7 +776,7 @@ static void evict_oldest_expect(struct ip_conntrack *master) if (i->master == master) { if (del_timer(&i->timeout)) { unlink_expect(i); - destroy_expect(i); + ip_conntrack_expect_put(i); } break; } @@ -810,8 +808,6 @@ int ip_conntrack_expect_related(struct ip_conntrack_expect *expect) /* Refresh timer: if it's dying, ignore.. */ if (refresh_timer(i)) { ret = 0; - /* We don't need the one they've given us. */ - ip_conntrack_expect_free(expect); goto out; } } else if (expect_clash(i, expect)) { @@ -881,7 +877,7 @@ void ip_conntrack_helper_unregister(struct ip_conntrack_helper *me) list_for_each_entry_safe(exp, tmp, &ip_conntrack_expect_list, list) { if (exp->master->helper == me && del_timer(&exp->timeout)) { unlink_expect(exp); - destroy_expect(exp); + ip_conntrack_expect_put(exp); } } /* Get rid of expecteds, set helpers to NULL. */ 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, fb_ptr + matchoff, matchlen, ntohl(th->seq) + matchoff); /* Allocate expectation which will be inserted */ - exp = ip_conntrack_expect_alloc(); + exp = ip_conntrack_expect_alloc(ct); if (exp == NULL) { ret = NF_DROP; goto out; @@ -403,8 +403,7 @@ static int help(struct sk_buff **pskb, networks, or the packet filter itself). */ if (!loose) { ret = NF_ACCEPT; - ip_conntrack_expect_free(exp); - goto out_update_nl; + goto out_put_expect; } exp->tuple.dst.ip = htonl((array[0] << 24) | (array[1] << 16) | (array[2] << 8) | array[3]); @@ -419,7 +418,6 @@ static int help(struct sk_buff **pskb, { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); exp->expectfn = NULL; - exp->master = ct; /* Now, NAT might want to mangle the packet, and register the * (possibly changed) expectation itself. */ @@ -428,13 +426,15 @@ static int help(struct sk_buff **pskb, matchoff, matchlen, exp, &seq); else { /* Can't expect this? Best to drop packet now. */ - if (ip_conntrack_expect_related(exp) != 0) { - ip_conntrack_expect_free(exp); + if (ip_conntrack_expect_related(exp) != 0) ret = NF_DROP; - } else + else ret = NF_ACCEPT; } +out_put_expect: + ip_conntrack_expect_put(exp); + out_update_nl: /* Now if this ends in \n, update ftp info. Seq may have been * 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, continue; } - exp = ip_conntrack_expect_alloc(); + exp = ip_conntrack_expect_alloc(ct); if (exp == NULL) { ret = NF_DROP; goto out; @@ -221,16 +221,14 @@ static int help(struct sk_buff **pskb, { { 0, { 0 } }, { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); exp->expectfn = NULL; - exp->master = ct; if (ip_nat_irc_hook) ret = ip_nat_irc_hook(pskb, ctinfo, addr_beg_p - ib_ptr, addr_end_p - addr_beg_p, exp); - else if (ip_conntrack_expect_related(exp) != 0) { - ip_conntrack_expect_free(exp); + else if (ip_conntrack_expect_related(exp) != 0) ret = NF_DROP; - } + ip_conntrack_expect_put(exp); goto out; } /* for .. NUM_DCCPROTO */ } /* 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); EXPORT_SYMBOL(ip_ct_protos); EXPORT_SYMBOL(ip_ct_find_proto); EXPORT_SYMBOL(ip_conntrack_expect_alloc); -EXPORT_SYMBOL(ip_conntrack_expect_free); +EXPORT_SYMBOL(ip_conntrack_expect_put); EXPORT_SYMBOL(ip_conntrack_expect_related); EXPORT_SYMBOL(ip_conntrack_unexpect_related); EXPORT_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, DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_REPLY].tuple); - exp = ip_conntrack_expect_alloc(); + exp = ip_conntrack_expect_alloc(ct); if (exp == NULL) return NF_DROP; @@ -75,17 +75,15 @@ static int tftp_help(struct sk_buff **pskb, exp->mask.dst.u.udp.port = 0xffff; exp->mask.dst.protonum = 0xff; exp->expectfn = NULL; - exp->master = ct; DEBUGP("expect: "); DUMP_TUPLE(&exp->tuple); DUMP_TUPLE(&exp->mask); if (ip_nat_tftp_hook) ret = ip_nat_tftp_hook(pskb, ctinfo, exp); - else if (ip_conntrack_expect_related(exp) != 0) { - ip_conntrack_expect_free(exp); + else if (ip_conntrack_expect_related(exp) != 0) ret = NF_DROP; - } + ip_conntrack_expect_put(exp); break; case TFTP_OPCODE_DATA: 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, break; } - if (port == 0) { - ip_conntrack_expect_free(exp); + if (port == 0) return NF_DROP; - } sprintf(buffer, "%u", port); 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, break; } - if (port == 0) { - ip_conntrack_expect_free(exp); + if (port == 0) return NF_DROP; - } if (!mangle[type](pskb, newip, port, matchoff, matchlen, ct, ctinfo, 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, break; } - if (port == 0) { - ip_conntrack_expect_free(exp); + if (port == 0) return NF_DROP; - } /* strlen("\1DCC CHAT chat AAAAAAAA P\1\n")=27 * strlen("\1DCC SCHAT chat AAAAAAAA P\1\n")=28 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, exp->saved_proto.udp.port = exp->tuple.dst.u.tcp.port; exp->dir = IP_CT_DIR_REPLY; exp->expectfn = ip_nat_follow_master; - if (ip_conntrack_expect_related(exp) != 0) { - ip_conntrack_expect_free(exp); + if (ip_conntrack_expect_related(exp) != 0) return NF_DROP; - } return NF_ACCEPT; } From 14a59e1829cd5782ad1a8979e594578f49f3e2c1 Mon Sep 17 00:00:00 2001 From: Loic Le Loarer Date: Thu, 21 Jul 2005 14:16:54 -0700 Subject: [PATCH 38/66] [EQL]: Proper num_slaves decrement Signed-off-by: Loic Le Loarer Signed-off-by: David S. Miller --- drivers/net/eql.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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); #define eql_is_slave(dev) ((dev->flags & IFF_SLAVE) == IFF_SLAVE) #define eql_is_master(dev) ((dev->flags & IFF_MASTER) == IFF_MASTER) -static void eql_kill_one_slave(slave_t *slave); +static void eql_kill_one_slave(slave_queue_t *queue, slave_t *slave); static void eql_timer(unsigned long param) { @@ -149,7 +149,7 @@ static void eql_timer(unsigned long param) if (slave->bytes_queued < 0) slave->bytes_queued = 0; } else { - eql_kill_one_slave(slave); + eql_kill_one_slave(&eql->queue, slave); } } @@ -214,9 +214,10 @@ static int eql_open(struct net_device *dev) return 0; } -static void eql_kill_one_slave(slave_t *slave) +static void eql_kill_one_slave(slave_queue_t *queue, slave_t *slave) { list_del(&slave->list); + queue->num_slaves--; slave->dev->flags &= ~IFF_SLAVE; dev_put(slave->dev); kfree(slave); @@ -232,8 +233,7 @@ static void eql_kill_slave_queue(slave_queue_t *queue) list_for_each_safe(this, tmp, head) { slave_t *s = list_entry(this, slave_t, list); - eql_kill_one_slave(s); - queue->num_slaves--; + eql_kill_one_slave(queue, s); } spin_unlock_bh(&queue->lock); @@ -318,7 +318,7 @@ static slave_t *__eql_schedule_slaves(slave_queue_t *queue) } } else { /* We found a dead slave, kill it. */ - eql_kill_one_slave(slave); + eql_kill_one_slave(queue, slave); } } return best_slave; @@ -393,7 +393,7 @@ static int __eql_insert_slave(slave_queue_t *queue, slave_t *slave) duplicate_slave = __eql_find_slave_dev(queue, slave->dev); if (duplicate_slave != 0) - eql_kill_one_slave(duplicate_slave); + eql_kill_one_slave(queue, duplicate_slave); list_add(&slave->list, &queue->all_slaves); queue->num_slaves++; @@ -471,7 +471,7 @@ static int eql_emancipate(struct net_device *master_dev, slaving_request_t __use slave_dev); if (slave) { - eql_kill_one_slave(slave); + eql_kill_one_slave(&eql->queue, slave); ret = 0; } } From 056a8763fc036639441a6dc49b61e57bc632af6e Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 22 Jul 2005 10:15:04 +0100 Subject: [PATCH 39/66] [PATCH] Serial: No need to check for priv != NULL in remove_one Signed-off-by: Russell King --- drivers/serial/8250_pci.c | 41 ++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index c3f55f5a38de..356f5556759a 100644 --- a/drivers/serial/8250_pci.c +++ b/drivers/serial/8250_pci.c @@ -1766,33 +1766,30 @@ pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent) static void __devexit pciserial_remove_one(struct pci_dev *dev) { struct serial_private *priv = pci_get_drvdata(dev); + struct pci_serial_quirk *quirk; + int i; pci_set_drvdata(dev, NULL); - if (priv) { - struct pci_serial_quirk *quirk; - int i; + for (i = 0; i < priv->nr; i++) + serial8250_unregister_port(priv->line[i]); - for (i = 0; i < priv->nr; i++) - serial8250_unregister_port(priv->line[i]); - - for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) { - if (priv->remapped_bar[i]) - iounmap(priv->remapped_bar[i]); - priv->remapped_bar[i] = NULL; - } - - /* - * Find the exit quirks. - */ - quirk = find_quirk(dev); - if (quirk->exit) - quirk->exit(dev); - - pci_disable_device(dev); - - kfree(priv); + for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) { + if (priv->remapped_bar[i]) + iounmap(priv->remapped_bar[i]); + priv->remapped_bar[i] = NULL; } + + /* + * Find the exit quirks. + */ + quirk = find_quirk(dev); + if (quirk->exit) + quirk->exit(dev); + + pci_disable_device(dev); + + kfree(priv); } static int pciserial_suspend_one(struct pci_dev *dev, pm_message_t state) From 28e212fb360ce2568edd60b93d60683d5ad24146 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 22 Jul 2005 11:47:25 -0700 Subject: [PATCH 40/66] [PKT_SCHED]: Kill TCF_META_ID_REALDEV from meta ematch. It won't exist any longer when we shrink the SKB in 2.6.14, and we should kill this off before anyone in userspace starts using it. Signed-off-by: David S. Miller Acked-by: Thomas Graf --- include/linux/tc_ematch/tc_em_meta.h | 1 - net/sched/em_meta.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/include/linux/tc_ematch/tc_em_meta.h b/include/linux/tc_ematch/tc_em_meta.h index 90ab9f95d43d..150efe07ff6b 100644 --- a/include/linux/tc_ematch/tc_em_meta.h +++ b/include/linux/tc_ematch/tc_em_meta.h @@ -42,7 +42,6 @@ enum TCF_META_ID_LOADAVG_2, TCF_META_ID_DEV, TCF_META_ID_INDEV, - TCF_META_ID_REALDEV, TCF_META_ID_PRIORITY, TCF_META_ID_PROTOCOL, TCF_META_ID_SECURITY, /* obsolete */ diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index feefcbfd03d0..179efb5bc9b3 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c @@ -180,16 +180,6 @@ META_COLLECTOR(var_indev) *err = var_dev(skb->input_dev, dst); } -META_COLLECTOR(int_realdev) -{ - *err = int_dev(skb->real_dev, dst); -} - -META_COLLECTOR(var_realdev) -{ - *err = var_dev(skb->real_dev, dst); -} - /************************************************************************** * skb attributes **************************************************************************/ @@ -501,7 +491,6 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = { [TCF_META_TYPE_VAR] = { [META_ID(DEV)] = META_FUNC(var_dev), [META_ID(INDEV)] = META_FUNC(var_indev), - [META_ID(REALDEV)] = META_FUNC(var_realdev), [META_ID(SK_BOUND_IF)] = META_FUNC(var_sk_bound_if), }, [TCF_META_TYPE_INT] = { @@ -511,7 +500,6 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = { [META_ID(LOADAVG_2)] = META_FUNC(int_loadavg_2), [META_ID(DEV)] = META_FUNC(int_dev), [META_ID(INDEV)] = META_FUNC(int_indev), - [META_ID(REALDEV)] = META_FUNC(int_realdev), [META_ID(PRIORITY)] = META_FUNC(int_priority), [META_ID(PROTOCOL)] = META_FUNC(int_protocol), [META_ID(PKTTYPE)] = META_FUNC(int_pkttype), From b339a18b81a1f6ca1455559594f5df872b9e59f4 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 22 Jul 2005 15:23:47 -0400 Subject: [PATCH 41/66] Fix up incorrect "unlikely()" on %gs reload in x86 __switch_to These days %gs is normally the TLS segment, so it's no longer zero. As a result, we shouldn't just assume that %fs/%gs tend to be zero together, but test them independently instead. Also, fix setting of debug registers to use the "next" pointer instead of "current". It so happens that the scheduler will have set the new current pointer before calling __switch_to(), but that's just an implementation detail. --- arch/i386/kernel/process.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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 /* * Restore %fs and %gs if needed. + * + * Glibc normally makes %fs be zero, and %gs is one of + * the TLS segments. */ - if (unlikely(prev->fs | prev->gs | next->fs | next->gs)) { + if (unlikely(prev->fs | next->fs)) loadsegment(fs, next->fs); + + if (prev->gs | next->gs) loadsegment(gs, next->gs); - } /* * Now maybe reload the debug registers */ if (unlikely(next->debugreg[7])) { - set_debugreg(current->thread.debugreg[0], 0); - set_debugreg(current->thread.debugreg[1], 1); - set_debugreg(current->thread.debugreg[2], 2); - set_debugreg(current->thread.debugreg[3], 3); + set_debugreg(next->debugreg[0], 0); + set_debugreg(next->debugreg[1], 1); + set_debugreg(next->debugreg[2], 2); + set_debugreg(next->debugreg[3], 3); /* no 4 and 5 */ - set_debugreg(current->thread.debugreg[6], 6); - set_debugreg(current->thread.debugreg[7], 7); + set_debugreg(next->debugreg[6], 6); + set_debugreg(next->debugreg[7], 7); } if (unlikely(prev->io_bitmap_ptr || next->io_bitmap_ptr)) From 4c1217deeb148ff8ab838ba4f1875d0f52dea343 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Fri, 22 Jul 2005 12:49:30 -0700 Subject: [PATCH 42/66] [NETFILTER]: Fix deadlock in ip6_queue Already fixed in ip_queue, ip6_queue was missed. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv6/netfilter/ip6_queue.c | 2 ++ 1 file changed, 2 insertions(+) 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); static void ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict) { + local_bh_disable(); nf_reinject(entry->skb, entry->info, verdict); + local_bh_enable(); kfree(entry); } From d04b4f8c1c9766e49fad6a141fc61cb30db69a5c Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Fri, 22 Jul 2005 12:50:29 -0700 Subject: [PATCH 43/66] [NETFILTER]: Fix potential memory corruption in NAT code (aka memory NAT) The portptr pointing to the port in the conntrack tuple is declared static, which could result in memory corruption when two packets of the same protocol are NATed at the same time and one conntrack goes away. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_nat_proto_tcp.c | 3 ++- net/ipv4/netfilter/ip_nat_proto_udp.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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, enum ip_nat_manip_type maniptype, const struct ip_conntrack *conntrack) { - static u_int16_t port, *portptr; + static u_int16_t port; + u_int16_t *portptr; unsigned int range_size, min, i; 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, enum ip_nat_manip_type maniptype, const struct ip_conntrack *conntrack) { - static u_int16_t port, *portptr; + static u_int16_t port; + u_int16_t *portptr; unsigned int range_size, min, i; if (maniptype == IP_NAT_MANIP_SRC) From 21f930e4abdcb9649f26e5b959c14dddee4e600b Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Fri, 22 Jul 2005 12:51:03 -0700 Subject: [PATCH 44/66] [NETFILTER]: Wait until all references to ip_conntrack_untracked are dropped on unload Fixes a crash when unloading ip_conntrack. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_conntrack_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c index 14af55cad5d6..63bf88264980 100644 --- a/net/ipv4/netfilter/ip_conntrack_core.c +++ b/net/ipv4/netfilter/ip_conntrack_core.c @@ -1107,6 +1107,9 @@ void ip_conntrack_cleanup(void) schedule(); goto i_see_dead_people; } + /* wait until all references to ip_conntrack_untracked are dropped */ + while (atomic_read(&ip_conntrack_untracked.ct_general.use) > 1) + schedule(); kmem_cache_destroy(ip_conntrack_cachep); kmem_cache_destroy(ip_conntrack_expect_cachep); From 74bb421da7f39e70ab636ad46ef85ea1178786c5 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Fri, 22 Jul 2005 12:51:38 -0700 Subject: [PATCH 45/66] [NETFILTER]: Use correct byteorder in ICMP NAT Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_nat_proto_icmp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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, const struct ip_conntrack *conntrack) { static u_int16_t id; - unsigned int range_size - = (unsigned int)range->max.icmp.id - range->min.icmp.id + 1; + unsigned int range_size; unsigned int i; + range_size = ntohs(range->max.icmp.id) - ntohs(range->min.icmp.id) + 1; /* If no range specified... */ if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) range_size = 0xFFFF; for (i = 0; i < range_size; i++, id++) { - tuple->src.u.icmp.id = range->min.icmp.id + (id % range_size); + tuple->src.u.icmp.id = htons(ntohs(range->min.icmp.id) + + (id % range_size)); if (!ip_nat_used_tuple(tuple, conntrack)) return 1; } From d3984a6b6abac6203868f0e9095c0ed9e33ece03 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Fri, 22 Jul 2005 12:52:47 -0700 Subject: [PATCH 46/66] [NETFILTER]: Fix ip6t_LOG MAC format I broke this in the patch that consolidated MAC logging. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv6/netfilter/ip6t_LOG.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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, in ? in->name : "", out ? out->name : ""); if (in && !out) { + unsigned int len; /* MAC logging for input chain only. */ printk("MAC="); - if (skb->dev && skb->dev->hard_header_len && + if (skb->dev && (len = skb->dev->hard_header_len) && skb->mac.raw != skb->nh.raw) { unsigned char *p = skb->mac.raw; int i; @@ -384,9 +385,11 @@ ip6t_log_packet(unsigned int hooknum, (p -= ETH_HLEN) < skb->head) p = NULL; - if (p != NULL) - for (i = 0; i < skb->dev->hard_header_len; i++) - printk("%02x", p[i]); + if (p != NULL) { + for (i = 0; i < len; i++) + printk("%02x%s", p[i], + i == len - 1 ? "" : ":"); + } printk(" "); if (skb->dev->type == ARPHRD_SIT) { From 8ed1383fb7b6685968588141d5934e0e6715e954 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 22 Jul 2005 16:06:16 -0400 Subject: [PATCH 47/66] x86: make restore_fpu() use alternative assembler instructions It's really just a single instruction, conditional on whether the CPU supports FXSR or not, so implement it as such instead of making it a function that queries FXSR dynamically. This means that the instruction just gets automatically rewritten to the correct one at boot-time. --- arch/i386/kernel/i387.c | 11 ----------- include/asm-i386/i387.h | 13 ++++++++++++- 2 files changed, 12 insertions(+), 12 deletions(-) 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) } EXPORT_SYMBOL_GPL(kernel_fpu_begin); -void restore_fpu( struct task_struct *tsk ) -{ - if ( cpu_has_fxsr ) { - asm volatile( "fxrstor %0" - : : "m" (tsk->thread.i387.fxsave) ); - } else { - asm volatile( "frstor %0" - : : "m" (tsk->thread.i387.fsave) ); - } -} - /* * FPU tag word conversions. */ diff --git a/include/asm-i386/i387.h b/include/asm-i386/i387.h index f6feb98a9397..e678609bb57e 100644 --- a/include/asm-i386/i387.h +++ b/include/asm-i386/i387.h @@ -19,10 +19,21 @@ extern void mxcsr_feature_mask_init(void); extern void init_fpu(struct task_struct *); + /* * FPU lazy state save handling... */ -extern void restore_fpu( struct task_struct *tsk ); + +/* + * The "nop" is needed to make the instructions the same + * length. + */ +#define restore_fpu(tsk) \ + alternative_input( \ + "nop ; frstor %1", \ + "fxrstor %1", \ + X86_FEATURE_FXSR, \ + "m" ((tsk)->thread.i387.fsave)) extern void kernel_fpu_begin(void); #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0) From 261688d01ec07d3a265b8ace6ec68310fbd96a96 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 22 Jul 2005 14:43:52 -0700 Subject: [PATCH 48/66] [PKT_SCHED]: em_meta: Kill TCF_META_ID_{INDEV,SECURITY,TCVERDICT} More unusable TCF_META_* match types that need to get eliminated before 2.6.13 goes out the door. Signed-off-by: David S. Miller Acked-by: Thomas Graf --- include/linux/tc_ematch/tc_em_meta.h | 3 --- net/sched/em_meta.c | 28 +++------------------------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/include/linux/tc_ematch/tc_em_meta.h b/include/linux/tc_ematch/tc_em_meta.h index 150efe07ff6b..081b1ee8516e 100644 --- a/include/linux/tc_ematch/tc_em_meta.h +++ b/include/linux/tc_ematch/tc_em_meta.h @@ -41,17 +41,14 @@ enum TCF_META_ID_LOADAVG_1, TCF_META_ID_LOADAVG_2, TCF_META_ID_DEV, - TCF_META_ID_INDEV, TCF_META_ID_PRIORITY, TCF_META_ID_PROTOCOL, - TCF_META_ID_SECURITY, /* obsolete */ TCF_META_ID_PKTTYPE, TCF_META_ID_PKTLEN, TCF_META_ID_DATALEN, TCF_META_ID_MACLEN, TCF_META_ID_NFMARK, TCF_META_ID_TCINDEX, - TCF_META_ID_TCVERDICT, TCF_META_ID_RTCLASSID, TCF_META_ID_RTIIF, TCF_META_ID_SK_FAMILY, diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index 179efb5bc9b3..a18b924743d9 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c @@ -27,17 +27,17 @@ * lvalue rvalue * +-----------+ +-----------+ * | type: INT | | type: INT | - * def | id: INDEV | | id: VALUE | + * def | id: DEV | | id: VALUE | * | data: | | data: 3 | * +-----------+ +-----------+ * | | - * ---> meta_ops[INT][INDEV](...) | + * ---> meta_ops[INT][DEV](...) | * | | * ----------- | * V V * +-----------+ +-----------+ * | type: INT | | type: INT | - * obj | id: INDEV | | id: VALUE | + * obj | id: DEV | | id: VALUE | * | data: 2 |<--data got filled out | data: 3 | * +-----------+ +-----------+ * | | @@ -170,16 +170,6 @@ META_COLLECTOR(var_dev) *err = var_dev(skb->dev, dst); } -META_COLLECTOR(int_indev) -{ - *err = int_dev(skb->input_dev, dst); -} - -META_COLLECTOR(var_indev) -{ - *err = var_dev(skb->input_dev, dst); -} - /************************************************************************** * skb attributes **************************************************************************/ @@ -235,13 +225,6 @@ META_COLLECTOR(int_tcindex) dst->value = skb->tc_index; } -#ifdef CONFIG_NET_CLS_ACT -META_COLLECTOR(int_tcverd) -{ - dst->value = skb->tc_verd; -} -#endif - /************************************************************************** * Routing **************************************************************************/ @@ -490,7 +473,6 @@ struct meta_ops static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = { [TCF_META_TYPE_VAR] = { [META_ID(DEV)] = META_FUNC(var_dev), - [META_ID(INDEV)] = META_FUNC(var_indev), [META_ID(SK_BOUND_IF)] = META_FUNC(var_sk_bound_if), }, [TCF_META_TYPE_INT] = { @@ -499,7 +481,6 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = { [META_ID(LOADAVG_1)] = META_FUNC(int_loadavg_1), [META_ID(LOADAVG_2)] = META_FUNC(int_loadavg_2), [META_ID(DEV)] = META_FUNC(int_dev), - [META_ID(INDEV)] = META_FUNC(int_indev), [META_ID(PRIORITY)] = META_FUNC(int_priority), [META_ID(PROTOCOL)] = META_FUNC(int_protocol), [META_ID(PKTTYPE)] = META_FUNC(int_pkttype), @@ -510,9 +491,6 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = { [META_ID(NFMARK)] = META_FUNC(int_nfmark), #endif [META_ID(TCINDEX)] = META_FUNC(int_tcindex), -#ifdef CONFIG_NET_CLS_ACT - [META_ID(TCVERDICT)] = META_FUNC(int_tcverd), -#endif #ifdef CONFIG_NET_CLS_ROUTE [META_ID(RTCLASSID)] = META_FUNC(int_rtclassid), #endif From 2847e3478c3d8119eedc3e0cb85a308b21f681dd Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 22 Jul 2005 18:19:20 -0400 Subject: [PATCH 49/66] x86: use alternative instructions for fnsave/fxsave too This one ends up using an inline asm format that claims to read memory and then clobber it (rather than just write it directly), which made it easier to use the existing "alternative_input()" infrastructure support. Now the fxsave code matches the fxrstor. --- include/asm-i386/i387.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/include/asm-i386/i387.h b/include/asm-i386/i387.h index e678609bb57e..6747006743f9 100644 --- a/include/asm-i386/i387.h +++ b/include/asm-i386/i387.h @@ -33,7 +33,7 @@ extern void init_fpu(struct task_struct *); "nop ; frstor %1", \ "fxrstor %1", \ X86_FEATURE_FXSR, \ - "m" ((tsk)->thread.i387.fsave)) + "m" ((tsk)->thread.i387.fxsave)) extern void kernel_fpu_begin(void); #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0) @@ -43,13 +43,12 @@ extern void kernel_fpu_begin(void); */ static inline void __save_init_fpu( struct task_struct *tsk ) { - if ( cpu_has_fxsr ) { - asm volatile( "fxsave %0 ; fnclex" - : "=m" (tsk->thread.i387.fxsave) ); - } else { - asm volatile( "fnsave %0 ; fwait" - : "=m" (tsk->thread.i387.fsave) ); - } + alternative_input( + "fnsave %1 ; fwait ;" GENERIC_NOP2, + "fxsave %1 ; fnclex", + X86_FEATURE_FXSR, + "m" (tsk->thread.i387.fxsave) + :"memory"); tsk->thread_info->status &= ~TS_USEDFPU; } From 72538d8565b0205240d88591b72db3c7f3f1881a Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 22 Jul 2005 18:29:40 -0400 Subject: [PATCH 50/66] Remove "noreplacement" kernel command line option. It is no longer valid to not replace instructions, since we depend on different behaviour depending on CPU capabilities. If you need to limit the capabilities of the replacements (because the boot CPU has features that non-boot CPU's do not have, for example), you need to explicitly disable those capabilities that are not shared across all CPU's. For example, if your boot CPU has FXSR, but other CPU's in your system do not, you need to use the "nofxsr" kernel command line, not disable instruction replacement per se. --- arch/i386/kernel/setup.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) 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 { This runs before SMP is initialized to avoid SMP problems with self modifying code. This implies that assymetric systems where APs have less capabilities than the boot processor are not handled. - In this case boot with "noreplacement". */ + Tough. Make sure you disable such features by hand. */ void apply_alternatives(void *start, void *end) { struct alt_instr *a; @@ -1442,24 +1442,12 @@ void apply_alternatives(void *start, void *end) } } -static int no_replacement __initdata = 0; - void __init alternative_instructions(void) { extern struct alt_instr __alt_instructions[], __alt_instructions_end[]; - if (no_replacement) - return; apply_alternatives(__alt_instructions, __alt_instructions_end); } -static int __init noreplacement_setup(char *s) -{ - no_replacement = 1; - return 0; -} - -__setup("noreplacement", noreplacement_setup); - static char * __init machine_specific_memory_setup(void); #ifdef CONFIG_MCA From 668d74c04c16bb69de564e25e85dd94eeb0175d9 Mon Sep 17 00:00:00 2001 From: Luming Yu Date: Sat, 23 Jul 2005 00:26:33 -0400 Subject: [PATCH 51/66] ACPI: delete unnecessary EC console messages http://bugzilla.kernel.org/show_bug.cgi?id=4534 Signed-off-by: Luming Yu Signed-off-by: Len Brown --- drivers/acpi/ec.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) 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 ( status = acpi_ec_read_status(ec); if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)){ - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"entering burst mode \n")); acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr); status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); if (status){ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR," status = %d\n", status)); return_VALUE(-EINVAL); } acpi_hw_low_level_read(8, &tmp, &ec->data_addr); acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); if(tmp != 0x90 ) {/* Burst ACK byte*/ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Ack failed \n")); return_VALUE(-EINVAL); } - } else - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in burst mode \n")); + } + atomic_set(&ec->leaving_burst , 0); return_VALUE(0); } @@ -202,7 +199,6 @@ acpi_ec_leave_burst_mode ( status = acpi_ec_read_status(ec); if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n")); acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->command_addr); status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); if (status){ @@ -212,14 +208,7 @@ acpi_ec_leave_burst_mode ( } acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); status = acpi_ec_read_status(ec); - if (status != -EINVAL && - (status & ACPI_EC_FLAG_BURST)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->status fail\n")); - return_VALUE(-EINVAL); - } - }else - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in Non-burst mode \n")); - ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n")); + } return_VALUE(0); } From 53776eb4acdd3ec576d75b61b656ef8d51e430ea Mon Sep 17 00:00:00 2001 From: Lucas Correia Villa Real Date: Sun, 24 Jul 2005 00:15:46 +0100 Subject: [PATCH 52/66] [PATCH] ARM: 2825/1: S3C2410: turns %d into %ld on DMA printk Patch from Lucas Correia Villa Real This patch replaces the sizeof()'s %d specifier by %ld on a S3C2410 DMA printk. Signed-off-by: Lucas Correia Villa Real Signed-off-by: Russell King --- arch/arm/mach-s3c2410/dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, buf = kmem_cache_alloc(dma_kmem, GFP_ATOMIC); if (buf == NULL) { - pr_debug("%s: out of memory (%d alloc)\n", + pr_debug("%s: out of memory (%ld alloc)\n", __FUNCTION__, sizeof(*buf)); return -ENOMEM; } From 4e8fd22bd421d7aa279bcb76189505a1f96bb7bf Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 24 Jul 2005 12:13:40 +0100 Subject: [PATCH 53/66] [PATCH] ARM SMP: Fix ARMv6 spinlock and semaphore implementations Signed-off-by: Russell King --- include/asm-arm/locks.h | 4 ++-- include/asm-arm/spinlock.h | 35 +++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 18 deletions(-) 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 @@ " strex ip, lr, [%0]\n" \ " teq ip, #0\n" \ " bne 1b\n" \ -" teq lr, #0\n" \ +" cmp lr, #0\n" \ " movle ip, %0\n" \ " blle " #wake \ : \ @@ -100,7 +100,7 @@ __asm__ __volatile__( \ "@ up_op_read\n" \ "1: ldrex lr, [%0]\n" \ -" add lr, lr, %1\n" \ +" adds lr, lr, %1\n" \ " strex ip, lr, [%0]\n" \ " teq ip, #0\n" \ " 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 { } rwlock_t; #define RW_LOCK_UNLOCKED (rwlock_t) { 0 } -#define rwlock_init(x) do { *(x) + RW_LOCK_UNLOCKED; } while (0) +#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while (0) +#define rwlock_is_locked(x) (*((volatile unsigned int *)(x)) != 0) /* * 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) : "cc", "memory"); } +static inline int _raw_write_trylock(rwlock_t *rw) +{ + unsigned long tmp; + + __asm__ __volatile__( +"1: ldrex %0, [%1]\n" +" teq %0, #0\n" +" strexeq %0, %2, [%1]" + : "=&r" (tmp) + : "r" (&rw->lock), "r" (0x80000000) + : "cc", "memory"); + + return tmp == 0; +} + static inline void _raw_write_unlock(rwlock_t *rw) { __asm__ __volatile__( @@ -138,6 +154,8 @@ static inline void _raw_read_lock(rwlock_t *rw) static inline void _raw_read_unlock(rwlock_t *rw) { + unsigned long tmp, tmp2; + __asm__ __volatile__( "1: ldrex %0, [%2]\n" " sub %0, %0, #1\n" @@ -151,19 +169,4 @@ static inline void _raw_read_unlock(rwlock_t *rw) #define _raw_read_trylock(lock) generic_raw_read_trylock(lock) -static inline int _raw_write_trylock(rwlock_t *rw) -{ - unsigned long tmp; - - __asm__ __volatile__( -"1: ldrex %0, [%1]\n" -" teq %0, #0\n" -" strexeq %0, %2, [%1]" - : "=&r" (tmp) - : "r" (&rw->lock), "r" (0x80000000) - : "cc", "memory"); - - return tmp == 0; -} - #endif /* __ASM_SPINLOCK_H */ From 227510c7f175c44b12cdff6eab316e53dbf71f92 Mon Sep 17 00:00:00 2001 From: Cal Peake Date: Sun, 24 Jul 2005 19:30:06 -0700 Subject: [PATCH 54/66] [IPV6]: fix implicit declaration of function `xfrm6_tunnel_unregister' Signed-off-by: Cal Peake Signed-off-by: David S. Miller --- net/ipv6/ip6_tunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index f39ddeae1eef..09613729404c 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -1123,7 +1123,7 @@ static inline int ip6ip6_register(void) static inline int ip6ip6_unregister(void) { - return xfrm6_tunnel_unregister(&ip6ip6_handler); + return xfrm6_tunnel_deregister(&ip6ip6_handler); } #else static struct inet6_protocol xfrm6_tunnel_protocol = { From 48647feed9f7a2d839c6ada12147b341833646e8 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sun, 24 Jul 2005 19:30:28 -0700 Subject: [PATCH 55/66] [W1]: Do not use NFLOG netlink number. Use the reserved by never used NETLINK_SKIP value instead. Signed-off-by: David S. Miller --- drivers/w1/w1_int.c | 2 +- include/linux/netlink.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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, dev->groups = 23; dev->seq = 1; - dev->nls = netlink_kernel_create(NETLINK_NFLOG, NULL); + dev->nls = netlink_kernel_create(NETLINK_W1, NULL); if (!dev->nls) { printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n", NETLINK_NFLOG, dev->dev.bus_id); 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 @@ #include #define NETLINK_ROUTE 0 /* Routing/device hook */ -#define NETLINK_SKIP 1 /* Reserved for ENskip */ +#define NETLINK_W1 1 /* 1-wire subsystem */ #define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */ #define NETLINK_FIREWALL 3 /* Firewalling hook */ #define NETLINK_TCPDIAG 4 /* TCP socket monitoring */ From 4564203d76599973da9c5cbcd93057252414ac9e Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sun, 24 Jul 2005 19:33:55 -0700 Subject: [PATCH 56/66] [SPARC]: Remvoe APM_RTC_IS_GMT from config. I can't see any effect of this option outside the i386-specific APM code. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: David S. Miller --- drivers/sbus/char/Kconfig | 14 -------------- 1 file changed, 14 deletions(-) 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 # XXX Why don't we do "source drivers/char/Config.in" somewhere? # no shit -config APM_RTC_IS_GMT - bool - depends on EXPERIMENTAL && SPARC32 && PCI - default y - help - Say Y here if your RTC (Real Time Clock a.k.a. hardware clock) - stores the time in GMT (Greenwich Mean Time). Say N if your RTC - stores localtime. - - It is in fact recommended to store GMT in your RTC, because then you - don't have to worry about daylight savings time changes. The only - reason not to use GMT in your RTC is if you also run a broken OS - that doesn't understand GMT. - config RTC tristate "PC-style Real Time Clock Support" depends on PCI && EXPERIMENTAL && SPARC32 From 70c83375bb47cadd60fdb923ad913d4f4be75aba Mon Sep 17 00:00:00 2001 From: Nishanth Aravamudan Date: Sun, 24 Jul 2005 19:34:19 -0700 Subject: [PATCH 57/66] [SPARC]: sbus/aurora: replace schedule_timeout() with msleep_interruptible() Use msleep_interruptible() instead of schedule_timeout() to guarantee the task delays as expected. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems Signed-off-by: Domen Puncer --- drivers/sbus/char/aurora.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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) */ timeout = jiffies+HZ; while(port->SRER & SRER_TXEMPTY) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(port->timeout); + msleep_interruptible(jiffies_to_msecs(port->timeout)); if (time_after(jiffies, timeout)) break; } @@ -1533,8 +1532,7 @@ static void aurora_close(struct tty_struct * tty, struct file * filp) port->tty = 0; if (port->blocked_open) { if (port->close_delay) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(port->close_delay); + msleep_interruptible(jiffies_to_msecs(port->close_delay)); } wake_up_interruptible(&port->open_wait); } From cb39d263e751f9cca8055bcacfe5ec863dfe2705 Mon Sep 17 00:00:00 2001 From: Nishanth Aravamudan Date: Sun, 24 Jul 2005 19:34:33 -0700 Subject: [PATCH 58/66] [SPARC]: sbus/envctrl: replace schedule_timeout() with msleep_interruptible() Use msleep_interruptible() instead of schedule_timeout() to guarantee the task delays as expected. Change the units of poll_interval to msecs as it is only used in this delay. Signed-off-by: Nishanth Aravamudan Signed-off-by: Domen Puncer Signed-off-by: David S. Miller --- drivers/sbus/char/envctrl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index f6ed35b24f43..0c7cd7e7e2e5 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c @@ -1007,7 +1007,7 @@ static int kenvctrld(void *__unused) return -ENODEV; } - poll_interval = 5 * HZ; /* TODO env_mon_interval */ + poll_interval = 5000; /* TODO env_mon_interval */ daemonize("kenvctrld"); allow_signal(SIGKILL); @@ -1016,10 +1016,7 @@ static int kenvctrld(void *__unused) printk(KERN_INFO "envctrl: %s starting...\n", current->comm); for (;;) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(poll_interval); - - if(signal_pending(current)) + if(msleep_interruptible(poll_interval)) break; for (whichcpu = 0; whichcpu < ENVCTRL_MAX_CPU; ++whichcpu) { From 2d1aea8dd02ad35658864de52a3e0f9f033e63f4 Mon Sep 17 00:00:00 2001 From: Nishanth Aravamudan Date: Sun, 24 Jul 2005 19:34:47 -0700 Subject: [PATCH 59/66] [SPARC]: sbus/vfc_i2c: remove sleep_on() usage Use wait-queue directly instead of the deprecated sleep_on() function. This required adding a local wait-queue. Also use new (added in separate patch to K-J) usecs to jiffies function to convert value. Signed-off-by: Nishanth Aravamudan Signed-off-by: Domen Puncer Signed-off-by: David S. Miller --- drivers/sbus/char/vfc_i2c.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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) void vfc_i2c_delay_no_busy(struct vfc_dev *dev, unsigned long usecs) { + DEFINE_WAIT(wait); init_timer(&dev->poll_timer); - dev->poll_timer.expires = jiffies + - ((unsigned long)usecs*(HZ))/1000000; + dev->poll_timer.expires = jiffies + usecs_to_jiffies(usecs); dev->poll_timer.data=(unsigned long)dev; dev->poll_timer.function=(void *)(unsigned long)vfc_i2c_delay_wakeup; add_timer(&dev->poll_timer); - sleep_on(&dev->poll_wait); + prepare_to_wait(&dev->poll_wait, &wait, TASK_UNINTERRUPTIBLE); + schedule(); del_timer(&dev->poll_timer); + finish_wait(&dev->poll_wait, &wait); } void inline vfc_i2c_delay(struct vfc_dev *dev) From 4b502421aac89c8d4e61ecc89a70065a33305a0b Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sun, 24 Jul 2005 19:35:08 -0700 Subject: [PATCH 60/66] [SPARC]: Fix __KERNEL_SYSCALLS__ defining in envctrl.c and bbc_envctrl.c It needs to happen before any header includes because nowadays some things implicitly include asm/unistd.h which ends up being before the __KERNEL_SYSCALLS__ define gets done. Signed-off-by: David S. Miller --- drivers/sbus/char/bbc_envctrl.c | 3 ++- drivers/sbus/char/envctrl.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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 @@ * Copyright (C) 2001 David S. Miller (davem@redhat.com) */ +#define __KERNEL_SYSCALLS__ + #include #include #include #include #include #include -#define __KERNEL_SYSCALLS__ static int errno; #include diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index 0c7cd7e7e2e5..9a8c572554f5 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c @@ -19,6 +19,8 @@ * Daniele Bellucci */ +#define __KERNEL_SYSCALLS__ + #include #include #include @@ -35,7 +37,6 @@ #include #include -#define __KERNEL_SYSCALLS__ static int errno; #include From 6593eaed814d50214d6056c683d52ac63153730e Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sun, 24 Jul 2005 19:35:28 -0700 Subject: [PATCH 61/66] [SPARC64]: Non-atomic bitops do not need volatile operations Noticed this while comparing sparc64's bitops.h to ppc64's. We can cast the volatile memory argument to be non-volatile. While we're here, __inline__ --> inline. Signed-off-by: David S. Miller --- include/asm-sparc64/bitops.h | 56 ++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) 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); /* "non-atomic" versions... */ -static __inline__ void __set_bit(int nr, volatile unsigned long *addr) +static inline void __set_bit(int nr, volatile unsigned long *addr) { - volatile unsigned long *m = addr + (nr >> 6); + unsigned long *m = ((unsigned long *)addr) + (nr >> 6); *m |= (1UL << (nr & 63)); } -static __inline__ void __clear_bit(int nr, volatile unsigned long *addr) +static inline void __clear_bit(int nr, volatile unsigned long *addr) { - volatile unsigned long *m = addr + (nr >> 6); + unsigned long *m = ((unsigned long *)addr) + (nr >> 6); *m &= ~(1UL << (nr & 63)); } -static __inline__ void __change_bit(int nr, volatile unsigned long *addr) +static inline void __change_bit(int nr, volatile unsigned long *addr) { - volatile unsigned long *m = addr + (nr >> 6); + unsigned long *m = ((unsigned long *)addr) + (nr >> 6); *m ^= (1UL << (nr & 63)); } -static __inline__ int __test_and_set_bit(int nr, volatile unsigned long *addr) +static inline int __test_and_set_bit(int nr, volatile unsigned long *addr) { - volatile unsigned long *m = addr + (nr >> 6); - long old = *m; - long mask = (1UL << (nr & 63)); + unsigned long *m = ((unsigned long *)addr) + (nr >> 6); + unsigned long old = *m; + unsigned long mask = (1UL << (nr & 63)); *m = (old | mask); return ((old & mask) != 0); } -static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long *addr) +static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) { - volatile unsigned long *m = addr + (nr >> 6); - long old = *m; - long mask = (1UL << (nr & 63)); + unsigned long *m = ((unsigned long *)addr) + (nr >> 6); + unsigned long old = *m; + unsigned long mask = (1UL << (nr & 63)); *m = (old & ~mask); return ((old & mask) != 0); } -static __inline__ int __test_and_change_bit(int nr, volatile unsigned long *addr) +static inline int __test_and_change_bit(int nr, volatile unsigned long *addr) { - volatile unsigned long *m = addr + (nr >> 6); - long old = *m; - long mask = (1UL << (nr & 63)); + unsigned long *m = ((unsigned long *)addr) + (nr >> 6); + unsigned long old = *m; + unsigned long mask = (1UL << (nr & 63)); *m = (old ^ mask); return ((old & mask) != 0); @@ -79,13 +79,13 @@ static __inline__ int __test_and_change_bit(int nr, volatile unsigned long *addr #define smp_mb__after_clear_bit() barrier() #endif -static __inline__ int test_bit(int nr, __const__ volatile unsigned long *addr) +static inline int test_bit(int nr, __const__ volatile unsigned long *addr) { - return (1UL & ((addr)[nr >> 6] >> (nr & 63))) != 0UL; + return (1UL & (addr[nr >> 6] >> (nr & 63))) != 0UL; } /* The easy/cheese version for now. */ -static __inline__ unsigned long ffz(unsigned long word) +static inline unsigned long ffz(unsigned long word) { unsigned long result; @@ -103,7 +103,7 @@ static __inline__ unsigned long ffz(unsigned long word) * * Undefined if no bit exists, so code should check against 0 first. */ -static __inline__ unsigned long __ffs(unsigned long word) +static inline unsigned long __ffs(unsigned long word) { unsigned long result = 0; @@ -144,7 +144,7 @@ static inline int sched_find_first_bit(unsigned long *b) * the libc and compiler builtin ffs routines, therefore * differs in spirit from the above ffz (man ffs). */ -static __inline__ int ffs(int x) +static inline int ffs(int x) { if (!x) return 0; @@ -158,7 +158,7 @@ static __inline__ int ffs(int x) #ifdef ULTRA_HAS_POPULATION_COUNT -static __inline__ unsigned int hweight64(unsigned long w) +static inline unsigned int hweight64(unsigned long w) { unsigned int res; @@ -166,7 +166,7 @@ static __inline__ unsigned int hweight64(unsigned long w) return res; } -static __inline__ unsigned int hweight32(unsigned int w) +static inline unsigned int hweight32(unsigned int w) { unsigned int res; @@ -174,7 +174,7 @@ static __inline__ unsigned int hweight32(unsigned int w) return res; } -static __inline__ unsigned int hweight16(unsigned int w) +static inline unsigned int hweight16(unsigned int w) { unsigned int res; @@ -182,7 +182,7 @@ static __inline__ unsigned int hweight16(unsigned int w) return res; } -static __inline__ unsigned int hweight8(unsigned int w) +static inline unsigned int hweight8(unsigned int w) { unsigned int res; @@ -236,7 +236,7 @@ extern unsigned long find_next_zero_bit(const unsigned long *, #define test_and_clear_le_bit(nr,addr) \ test_and_clear_bit((nr) ^ 0x38, (addr)) -static __inline__ int test_le_bit(int nr, __const__ unsigned long * addr) +static inline int test_le_bit(int nr, __const__ unsigned long * addr) { int mask; __const__ unsigned char *ADDR = (__const__ unsigned char *) addr; From 620de54675e76f1369326bbe1fc75aff88917063 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sun, 24 Jul 2005 19:35:42 -0700 Subject: [PATCH 62/66] [SPARC64]: Simplify asm/rwsem.h slightly. rwsem_atomic_update and rwsem_atomic_add can be implemented straightly using atomic_*() routines. Also, rwsem_cmpxchgw() is totally unused, kill it. Signed-off-by: David S. Miller --- include/asm-sparc64/rwsem.h | 48 ++++--------------------------------- 1 file changed, 4 insertions(+), 44 deletions(-) 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); extern void __up_write(struct rw_semaphore *sem); extern void __downgrade_write(struct rw_semaphore *sem); -static __inline__ int rwsem_atomic_update(int delta, struct rw_semaphore *sem) +static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) { - int tmp = delta; - - __asm__ __volatile__( - "1:\tlduw [%2], %%g1\n\t" - "add %%g1, %1, %%g7\n\t" - "cas [%2], %%g1, %%g7\n\t" - "cmp %%g1, %%g7\n\t" - "membar #StoreLoad | #StoreStore\n\t" - "bne,pn %%icc, 1b\n\t" - " nop\n\t" - "mov %%g7, %0\n\t" - : "=&r" (tmp) - : "0" (tmp), "r" (sem) - : "g1", "g7", "memory", "cc"); - - return tmp + delta; + return atomic_add_return(delta, (atomic_t *)(&sem->count)); } -#define rwsem_atomic_add rwsem_atomic_update - -static __inline__ __u16 rwsem_cmpxchgw(struct rw_semaphore *sem, __u16 __old, __u16 __new) +static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem) { - u32 old = (sem->count & 0xffff0000) | (u32) __old; - u32 new = (old & 0xffff0000) | (u32) __new; - u32 prev; - -again: - __asm__ __volatile__("cas [%2], %3, %0\n\t" - "membar #StoreLoad | #StoreStore" - : "=&r" (prev) - : "0" (new), "r" (sem), "r" (old) - : "memory"); - - /* To give the same semantics as x86 cmpxchgw, keep trying - * if only the upper 16-bits changed. - */ - if (prev != old && - ((prev & 0xffff) == (old & 0xffff))) - goto again; - - return prev & 0xffff; -} - -static __inline__ signed long rwsem_cmpxchg(struct rw_semaphore *sem, signed long old, signed long new) -{ - return cmpxchg(&sem->count,old,new); + atomic_add(delta, (atomic_t *)(&sem->count)); } #endif /* __KERNEL__ */ From c5019a578f18cf3a76829626e91e5469dbd4a738 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sun, 24 Jul 2005 19:35:56 -0700 Subject: [PATCH 63/66] [SPARC64]: Kill totally unused inline functions from asm/spitfire.h Signed-off-by: David S. Miller --- include/asm-sparc64/spitfire.h | 130 --------------------------------- 1 file changed, 130 deletions(-) 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); SPITFIRE_HIGHEST_LOCKED_TLBENT : \ CHEETAH_HIGHEST_LOCKED_TLBENT) -static __inline__ unsigned long spitfire_get_isfsr(void) -{ - unsigned long ret; - - __asm__ __volatile__("ldxa [%1] %2, %0" - : "=r" (ret) - : "r" (TLB_SFSR), "i" (ASI_IMMU)); - return ret; -} - -static __inline__ unsigned long spitfire_get_dsfsr(void) -{ - unsigned long ret; - - __asm__ __volatile__("ldxa [%1] %2, %0" - : "=r" (ret) - : "r" (TLB_SFSR), "i" (ASI_DMMU)); - return ret; -} - -static __inline__ unsigned long spitfire_get_sfar(void) -{ - unsigned long ret; - - __asm__ __volatile__("ldxa [%1] %2, %0" - : "=r" (ret) - : "r" (DMMU_SFAR), "i" (ASI_DMMU)); - return ret; -} - -static __inline__ void spitfire_put_isfsr(unsigned long sfsr) -{ - __asm__ __volatile__("stxa %0, [%1] %2\n\t" - "membar #Sync" - : /* no outputs */ - : "r" (sfsr), "r" (TLB_SFSR), "i" (ASI_IMMU)); -} - -static __inline__ void spitfire_put_dsfsr(unsigned long sfsr) -{ - __asm__ __volatile__("stxa %0, [%1] %2\n\t" - "membar #Sync" - : /* no outputs */ - : "r" (sfsr), "r" (TLB_SFSR), "i" (ASI_DMMU)); -} - /* The data cache is write through, so this just invalidates the * specified line. */ @@ -193,90 +147,6 @@ static __inline__ void spitfire_put_itlb_data(int entry, unsigned long data) "i" (ASI_ITLB_DATA_ACCESS)); } -/* Spitfire hardware assisted TLB flushes. */ - -/* Context level flushes. */ -static __inline__ void spitfire_flush_dtlb_primary_context(void) -{ - __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" - "membar #Sync" - : /* No outputs */ - : "r" (0x40), "i" (ASI_DMMU_DEMAP)); -} - -static __inline__ void spitfire_flush_itlb_primary_context(void) -{ - __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" - "membar #Sync" - : /* No outputs */ - : "r" (0x40), "i" (ASI_IMMU_DEMAP)); -} - -static __inline__ void spitfire_flush_dtlb_secondary_context(void) -{ - __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" - "membar #Sync" - : /* No outputs */ - : "r" (0x50), "i" (ASI_DMMU_DEMAP)); -} - -static __inline__ void spitfire_flush_itlb_secondary_context(void) -{ - __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" - "membar #Sync" - : /* No outputs */ - : "r" (0x50), "i" (ASI_IMMU_DEMAP)); -} - -static __inline__ void spitfire_flush_dtlb_nucleus_context(void) -{ - __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" - "membar #Sync" - : /* No outputs */ - : "r" (0x60), "i" (ASI_DMMU_DEMAP)); -} - -static __inline__ void spitfire_flush_itlb_nucleus_context(void) -{ - __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" - "membar #Sync" - : /* No outputs */ - : "r" (0x60), "i" (ASI_IMMU_DEMAP)); -} - -/* Page level flushes. */ -static __inline__ void spitfire_flush_dtlb_primary_page(unsigned long page) -{ - __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" - "membar #Sync" - : /* No outputs */ - : "r" (page), "i" (ASI_DMMU_DEMAP)); -} - -static __inline__ void spitfire_flush_itlb_primary_page(unsigned long page) -{ - __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" - "membar #Sync" - : /* No outputs */ - : "r" (page), "i" (ASI_IMMU_DEMAP)); -} - -static __inline__ void spitfire_flush_dtlb_secondary_page(unsigned long page) -{ - __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" - "membar #Sync" - : /* No outputs */ - : "r" (page | 0x10), "i" (ASI_DMMU_DEMAP)); -} - -static __inline__ void spitfire_flush_itlb_secondary_page(unsigned long page) -{ - __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" - "membar #Sync" - : /* No outputs */ - : "r" (page | 0x10), "i" (ASI_IMMU_DEMAP)); -} - static __inline__ void spitfire_flush_dtlb_nucleus_page(unsigned long page) { __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" From cdd5186f753b23ab51f86679bdc4cc698ab0b893 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sun, 24 Jul 2005 19:36:13 -0700 Subject: [PATCH 64/66] [SPARC64]: Privatize sun5_timer. It is only used by some localized code in irq.c, and also delete enable_prom_timer() as that is totally unused. Signed-off-by: David S. Miller --- arch/sparc64/kernel/irq.c | 20 +++++++----------- include/asm-sparc64/timer.h | 41 ------------------------------------- 2 files changed, 7 insertions(+), 54 deletions(-) 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) } #endif +struct sun5_timer { + u64 count0; + u64 limit0; + u64 count1; + u64 limit1; +}; -struct sun5_timer *prom_timers; +static struct sun5_timer *prom_timers; static u64 prom_limit0, prom_limit1; static void map_prom_timers(void) @@ -839,18 +845,6 @@ static void kill_prom_timer(void) : "g1", "g2"); } -void enable_prom_timer(void) -{ - if (!prom_timers) - return; - - /* Set it to whatever was there before. */ - prom_timers->limit1 = prom_limit1; - prom_timers->count1 = 0; - prom_timers->limit0 = prom_limit0; - prom_timers->count0 = 0; -} - void init_irqwork_curcpu(void) { register struct irq_work_struct *workp asm("o2"); 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 @@ #include -/* How timers work: - * - * On uniprocessors we just use counter zero for the system wide - * ticker, this performs thread scheduling, clock book keeping, - * and runs timer based events. Previously we used the Ultra - * %tick interrupt for this purpose. - * - * On multiprocessors we pick one cpu as the master level 10 tick - * processor. Here this counter zero tick handles clock book - * keeping and timer events only. Each Ultra has it's level - * 14 %tick interrupt set to fire off as well, even the master - * tick cpu runs this locally. This ticker performs thread - * scheduling, system/user tick counting for the current thread, - * and also profiling if enabled. - */ - #include -/* Two timers, traditionally steered to PIL's 10 and 14 respectively. - * But since INO packets are used on sun5, we could use any PIL level - * we like, however for now we use the normal ones. - * - * The 'reg' and 'interrupts' properties for these live in nodes named - * 'counter-timer'. The first of three 'reg' properties describe where - * the sun5_timer registers are. The other two I have no idea. (XXX) - */ -struct sun5_timer { - u64 count0; - u64 limit0; - u64 count1; - u64 limit1; -}; - -#define SUN5_LIMIT_ENABLE 0x80000000 -#define SUN5_LIMIT_TOZERO 0x40000000 -#define SUN5_LIMIT_ZRESTART 0x20000000 -#define SUN5_LIMIT_CMASK 0x1fffffff - -/* Given a HZ value, set the limit register to so that the timer IRQ - * gets delivered that often. - */ -#define SUN5_HZ_TO_LIMIT(__hz) (1000000/(__hz)) - struct sparc64_tick_ops { void (*init_tick)(unsigned long); unsigned long (*get_tick)(void); From db7d9a4eb700be766cc9f29241483dbb1e748832 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sun, 24 Jul 2005 19:36:26 -0700 Subject: [PATCH 65/66] [SPARC64]: Move syscall success and newchild state out of thread flags. These two bits were accesses non-atomically from assembler code. So, in order to eliminate any potential races resulting from that, move these pieces of state into two bytes elsewhere in struct thread_info. Signed-off-by: David S. Miller --- arch/sparc64/kernel/entry.S | 17 ++++++++--------- arch/sparc64/kernel/process.c | 2 +- arch/sparc64/kernel/smp.c | 2 +- arch/sparc64/kernel/traps.c | 2 ++ include/asm-sparc64/ptrace.h | 5 +++-- include/asm-sparc64/system.h | 11 +++++------ include/asm-sparc64/thread_info.h | 12 +++++++----- 7 files changed, 27 insertions(+), 24 deletions(-) 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 ba,pt %xcc, sparc_do_fork add %sp, PTREGS_OFF, %o2 ret_from_syscall: - /* Clear SPARC_FLAG_NEWCHILD, switch_to leaves thread.flags in - * %o7 for us. Check performance counter stuff too. + /* Clear current_thread_info()->new_child, and + * check performance counter stuff too. */ - andn %o7, _TIF_NEWCHILD, %l0 - stx %l0, [%g6 + TI_FLAGS] + stb %g0, [%g6 + TI_NEW_CHILD] + ldx [%g6 + TI_FLAGS], %l0 call schedule_tail mov %g7, %o0 andcc %l0, _TIF_PERFCTR, %g0 @@ -1720,12 +1720,11 @@ ret_sys_call: /* Check if force_successful_syscall_return() * was invoked. */ - ldx [%curptr + TI_FLAGS], %l0 - andcc %l0, _TIF_SYSCALL_SUCCESS, %g0 - be,pt %icc, 1f - andn %l0, _TIF_SYSCALL_SUCCESS, %l0 + ldub [%curptr + TI_SYS_NOERROR], %l0 + brz,pt %l0, 1f + nop ba,pt %xcc, 80f - stx %l0, [%curptr + TI_FLAGS] + stb %g0, [%curptr + TI_SYS_NOERROR] 1: cmp %o0, -ERESTART_RESTARTBLOCK 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, memcpy(child_trap_frame, (((struct sparc_stackf *)regs)-1), (TRACEREG_SZ+STACKFRAME_SZ)); t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) | (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) | - _TIF_NEWCHILD | (((regs->tstate + 1) & TSTATE_CWP) << TI_FLAG_CWP_SHIFT); + t->new_child = 1; t->ksp = ((unsigned long) child_trap_frame) - STACK_BIAS; t->kregs = (struct pt_regs *)(child_trap_frame+sizeof(struct sparc_stackf)); 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) /* Clear this or we will die instantly when we * schedule back to this idler... */ - clear_thread_flag(TIF_NEWCHILD); + current_thread_info()->new_child = 0; /* Attach to the address space of init_task. */ 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) TI_PCR != offsetof(struct thread_info, pcr_reg) || TI_CEE_STUFF != offsetof(struct thread_info, cee_stuff) || TI_PRE_COUNT != offsetof(struct thread_info, preempt_count) || + TI_NEW_CHILD != offsetof(struct thread_info, new_child) || + TI_SYS_NOERROR != offsetof(struct thread_info, syscall_noerror) || TI_FPREGS != offsetof(struct thread_info, fpregs) || (TI_FPREGS & (64 - 1))) thread_info_offsets_are_bolixed_dave(); 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 { #define STACKFRAME32_SZ sizeof(struct sparc_stackf32) #ifdef __KERNEL__ -#define force_successful_syscall_return() \ - set_thread_flag(TIF_SYSCALL_SUCCESS) +#define force_successful_syscall_return() \ +do { current_thread_info()->syscall_noerror = 1; \ +} while (0) #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV)) #define instruction_pointer(regs) ((regs)->tpc) #ifdef CONFIG_SMP 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)) { \ "wrpr %%g1, %%cwp\n\t" \ "ldx [%%g6 + %3], %%o6\n\t" \ "ldub [%%g6 + %2], %%o5\n\t" \ - "ldx [%%g6 + %4], %%o7\n\t" \ + "ldub [%%g6 + %4], %%o7\n\t" \ "mov %%g6, %%l2\n\t" \ "wrpr %%o5, 0x0, %%wstate\n\t" \ "ldx [%%sp + 2047 + 0x70], %%i6\n\t" \ "ldx [%%sp + 2047 + 0x78], %%i7\n\t" \ "wrpr %%g0, 0x94, %%pstate\n\t" \ "mov %%l2, %%g6\n\t" \ - "ldx [%%g6 + %7], %%g4\n\t" \ + "ldx [%%g6 + %6], %%g4\n\t" \ "wrpr %%g0, 0x96, %%pstate\n\t" \ - "andcc %%o7, %6, %%g0\n\t" \ - "beq,pt %%icc, 1f\n\t" \ + "brz,pt %%o7, 1f\n\t" \ " mov %%g7, %0\n\t" \ "b,a ret_from_syscall\n\t" \ "1:\n\t" \ : "=&r" (last) \ : "0" (next->thread_info), \ - "i" (TI_WSTATE), "i" (TI_KSP), "i" (TI_FLAGS), "i" (TI_CWP), \ - "i" (_TIF_NEWCHILD), "i" (TI_TASK) \ + "i" (TI_WSTATE), "i" (TI_KSP), "i" (TI_NEW_CHILD), \ + "i" (TI_CWP), "i" (TI_TASK) \ : "cc", \ "g1", "g2", "g3", "g7", \ "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 { struct pt_regs *kregs; struct exec_domain *exec_domain; int preempt_count; /* 0 => preemptable, <0 => BUG */ - int __pad; + __u8 new_child; + __u8 syscall_noerror; + __u16 __pad; unsigned long *utraps; @@ -87,6 +89,8 @@ struct thread_info { #define TI_KREGS 0x00000028 #define TI_EXEC_DOMAIN 0x00000030 #define TI_PRE_COUNT 0x00000038 +#define TI_NEW_CHILD 0x0000003c +#define TI_SYS_NOERROR 0x0000003d #define TI_UTRAPS 0x00000040 #define TI_REG_WINDOW 0x00000048 #define TI_RWIN_SPTRS 0x000003c8 @@ -219,10 +223,10 @@ register struct thread_info *current_thread_info_reg asm("g6"); #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */ #define TIF_NEWSIGNALS 6 /* wants new-style signals */ #define TIF_32BIT 7 /* 32-bit binary */ -#define TIF_NEWCHILD 8 /* just-spawned child process */ +/* flag bit 8 is available */ #define TIF_SECCOMP 9 /* secure computing */ #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */ -#define TIF_SYSCALL_SUCCESS 11 +/* flag bit 11 is available */ /* NOTE: Thread flags >= 12 should be ones we have no interest * in using in assembly, else we can't use the mask as * an immediate value in instructions such as andcc. @@ -239,10 +243,8 @@ register struct thread_info *current_thread_info_reg asm("g6"); #define _TIF_UNALIGNED (1< Date: Sun, 24 Jul 2005 19:44:23 -0700 Subject: [PATCH 66/66] [EMATCH]: Remove feature ifdefs in meta ematch. Signed-off-by: Patrick McHardy Acked-by: Thomas Graf Signed-off-by: David S. Miller --- net/sched/em_meta.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index a18b924743d9..00eae5f9a01a 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c @@ -209,12 +209,14 @@ META_COLLECTOR(int_maclen) * Netfilter **************************************************************************/ -#ifdef CONFIG_NETFILTER META_COLLECTOR(int_nfmark) { +#ifdef CONFIG_NETFILTER dst->value = skb->nfmark; -} +#else + dst->value = 0; #endif +} /************************************************************************** * Traffic Control @@ -229,15 +231,17 @@ META_COLLECTOR(int_tcindex) * Routing **************************************************************************/ -#ifdef CONFIG_NET_CLS_ROUTE META_COLLECTOR(int_rtclassid) { if (unlikely(skb->dst == NULL)) *err = -1; else +#ifdef CONFIG_NET_CLS_ROUTE dst->value = skb->dst->tclassid; -} +#else + dst->value = 0; #endif +} META_COLLECTOR(int_rtiif) { @@ -487,13 +491,9 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = { [META_ID(PKTLEN)] = META_FUNC(int_pktlen), [META_ID(DATALEN)] = META_FUNC(int_datalen), [META_ID(MACLEN)] = META_FUNC(int_maclen), -#ifdef CONFIG_NETFILTER [META_ID(NFMARK)] = META_FUNC(int_nfmark), -#endif [META_ID(TCINDEX)] = META_FUNC(int_tcindex), -#ifdef CONFIG_NET_CLS_ROUTE [META_ID(RTCLASSID)] = META_FUNC(int_rtclassid), -#endif [META_ID(RTIIF)] = META_FUNC(int_rtiif), [META_ID(SK_FAMILY)] = META_FUNC(int_sk_family), [META_ID(SK_STATE)] = META_FUNC(int_sk_state),