Commit e35a3e9a authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://linux-pnp.bkbits.net/pnp-2.5

into home.transmeta.com:/home/torvalds/v2.5/linux
parents e315468f da334d91
...@@ -186,3 +186,9 @@ oprofile_arch_init(struct oprofile_operations **ops) ...@@ -186,3 +186,9 @@ oprofile_arch_init(struct oprofile_operations **ops)
return 0; return 0;
} }
void __exit
oprofile_arch_exit(void)
{
}
...@@ -84,7 +84,7 @@ core-y += arch/i386/kernel/ \ ...@@ -84,7 +84,7 @@ core-y += arch/i386/kernel/ \
arch/i386/$(mcore-y)/ arch/i386/$(mcore-y)/
drivers-$(CONFIG_MATH_EMULATION) += arch/i386/math-emu/ drivers-$(CONFIG_MATH_EMULATION) += arch/i386/math-emu/
drivers-$(CONFIG_PCI) += arch/i386/pci/ drivers-$(CONFIG_PCI) += arch/i386/pci/
# FIXME: is drivers- right ? # must be linked after kernel/
drivers-$(CONFIG_OPROFILE) += arch/i386/oprofile/ drivers-$(CONFIG_OPROFILE) += arch/i386/oprofile/
CFLAGS += $(mflags-y) CFLAGS += $(mflags-y)
......
...@@ -522,7 +522,8 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic, ...@@ -522,7 +522,8 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
spin_lock(&call_lock); spin_lock(&call_lock);
call_data = &data; call_data = &data;
wmb(); mb();
/* Send a message to all other CPUs and wait for them to respond */ /* Send a message to all other CPUs and wait for them to respond */
send_IPI_allbutself(CALL_FUNCTION_VECTOR); send_IPI_allbutself(CALL_FUNCTION_VECTOR);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
extern int nmi_init(struct oprofile_operations ** ops); extern int nmi_init(struct oprofile_operations ** ops);
extern void nmi_exit(void);
extern void timer_init(struct oprofile_operations ** ops); extern void timer_init(struct oprofile_operations ** ops);
int __init oprofile_arch_init(struct oprofile_operations ** ops) int __init oprofile_arch_init(struct oprofile_operations ** ops)
...@@ -27,3 +28,11 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops) ...@@ -27,3 +28,11 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
timer_init(ops); timer_init(ops);
return 0; return 0;
} }
void __exit oprofile_arch_exit(void)
{
#ifdef CONFIG_X86_LOCAL_APIC
nmi_exit();
#endif
}
...@@ -67,15 +67,22 @@ static struct device device_nmi = { ...@@ -67,15 +67,22 @@ static struct device device_nmi = {
}; };
static int __init init_nmi_driverfs(void) static int __init init_driverfs(void)
{ {
driver_register(&nmi_driver); driver_register(&nmi_driver);
return device_register(&device_nmi); return device_register(&device_nmi);
} }
late_initcall(init_nmi_driverfs); static void __exit exit_driverfs(void)
{
device_unregister(&device_nmi);
driver_unregister(&nmi_driver);
}
#else
#define init_driverfs() do { } while (0)
#define exit_driverfs() do { } while (0)
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
...@@ -297,6 +304,10 @@ static int __init ppro_init(void) ...@@ -297,6 +304,10 @@ static int __init ppro_init(void)
#endif /* !CONFIG_X86_64 */ #endif /* !CONFIG_X86_64 */
/* in order to get driverfs right */
static int using_nmi;
int __init nmi_init(struct oprofile_operations ** ops) int __init nmi_init(struct oprofile_operations ** ops)
{ {
__u8 vendor = current_cpu_data.x86_vendor; __u8 vendor = current_cpu_data.x86_vendor;
...@@ -339,7 +350,16 @@ int __init nmi_init(struct oprofile_operations ** ops) ...@@ -339,7 +350,16 @@ int __init nmi_init(struct oprofile_operations ** ops)
return 0; return 0;
} }
init_driverfs();
using_nmi = 1;
*ops = &nmi_ops; *ops = &nmi_ops;
printk(KERN_INFO "oprofile: using NMI interrupt.\n"); printk(KERN_INFO "oprofile: using NMI interrupt.\n");
return 1; return 1;
} }
void __exit nmi_exit(void)
{
if (using_nmi)
exit_driverfs();
}
...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops) ...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
timer_init(ops); timer_init(ops);
return 0; return 0;
} }
void __exit oprofile_arch_exit()
{
}
...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops) ...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
timer_init(ops); timer_init(ops);
return 0; return 0;
} }
void __exit oprofile_arch_exit(void)
{
}
...@@ -36,12 +36,31 @@ void module_free(struct module *mod, void *module_region) ...@@ -36,12 +36,31 @@ void module_free(struct module *mod, void *module_region)
table entries. */ table entries. */
} }
/* We don't need anything special. */ /* Make generic code ignore STT_REGISTER dummy undefined symbols. */
int module_frob_arch_sections(Elf_Ehdr *hdr, int module_frob_arch_sections(Elf_Ehdr *hdr,
Elf_Shdr *sechdrs, Elf_Shdr *sechdrs,
char *secstrings, char *secstrings,
struct module *mod) struct module *mod)
{ {
unsigned int symidx;
Elf32_Sym *sym;
const char *strtab;
int i;
for (symidx = 0; sechdrs[symidx].sh_type != SHT_SYMTAB; symidx++) {
if (symidx == hdr->e_shnum-1) {
printk("%s: no symtab found.\n", mod->name);
return -ENOEXEC;
}
}
sym = (Elf32_Sym *)sechdrs[symidx].sh_addr;
strtab = (char *)sechdrs[sechdrs[symidx].sh_link].sh_addr;
for (i = 1; i < sechdrs[symidx].sh_size / sizeof(Elf_Sym); i++) {
if (sym[i].st_shndx == SHN_UNDEF &&
ELF32_ST_TYPE(sym[i].st_info) == STT_REGISTER)
sym[i].st_shndx = SHN_ABS;
}
return 0; return 0;
} }
......
...@@ -143,12 +143,31 @@ void module_free(struct module *mod, void *module_region) ...@@ -143,12 +143,31 @@ void module_free(struct module *mod, void *module_region)
table entries. */ table entries. */
} }
/* We don't need anything special. */ /* Make generic code ignore STT_REGISTER dummy undefined symbols. */
int module_frob_arch_sections(Elf_Ehdr *hdr, int module_frob_arch_sections(Elf_Ehdr *hdr,
Elf_Shdr *sechdrs, Elf_Shdr *sechdrs,
char *secstrings, char *secstrings,
struct module *mod) struct module *mod)
{ {
unsigned int symidx;
Elf64_Sym *sym;
const char *strtab;
int i;
for (symidx = 0; sechdrs[symidx].sh_type != SHT_SYMTAB; symidx++) {
if (symidx == hdr->e_shnum-1) {
printk("%s: no symtab found.\n", mod->name);
return -ENOEXEC;
}
}
sym = (Elf64_Sym *)sechdrs[symidx].sh_addr;
strtab = (char *)sechdrs[sechdrs[symidx].sh_link].sh_addr;
for (i = 1; i < sechdrs[symidx].sh_size / sizeof(Elf_Sym); i++) {
if (sym[i].st_shndx == SHN_UNDEF &&
ELF64_ST_TYPE(sym[i].st_info) == STT_REGISTER)
sym[i].st_shndx = SHN_ABS;
}
return 0; return 0;
} }
......
...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops) ...@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
timer_init(ops); timer_init(ops);
return 0; return 0;
} }
void __exit oprofile_arch_exit(void)
{
}
...@@ -736,7 +736,7 @@ acpi_os_acquire_lock ( ...@@ -736,7 +736,7 @@ acpi_os_acquire_lock (
if (flags & ACPI_NOT_ISR) if (flags & ACPI_NOT_ISR)
ACPI_DISABLE_IRQS(); ACPI_DISABLE_IRQS();
spin_lock(handle); spin_lock((spinlock_t *)handle);
return_VOID; return_VOID;
} }
...@@ -755,7 +755,7 @@ acpi_os_release_lock ( ...@@ -755,7 +755,7 @@ acpi_os_release_lock (
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Releasing spinlock[%p] from %s level\n", handle, ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Releasing spinlock[%p] from %s level\n", handle,
((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt"))); ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt")));
spin_unlock(handle); spin_unlock((spinlock_t *)handle);
if (flags & ACPI_NOT_ISR) if (flags & ACPI_NOT_ISR)
ACPI_ENABLE_IRQS(); ACPI_ENABLE_IRQS();
......
...@@ -61,6 +61,14 @@ ...@@ -61,6 +61,14 @@
/* Measure times between events in the driver. */ /* Measure times between events in the driver. */
#undef DEBUG_TIMING #undef DEBUG_TIMING
/* Timing parameters. Call every 10 ms when not doing anything,
otherwise call every KCS_SHORT_TIMEOUT_USEC microseconds. */
#define KCS_TIMEOUT_TIME_USEC 10000
#define KCS_USEC_PER_JIFFY (1000000/HZ)
#define KCS_TIMEOUT_JIFFIES (KCS_TIMEOUT_TIME_USEC/KCS_USEC_PER_JIFFY)
#define KCS_SHORT_TIMEOUT_USEC 250 /* .25ms when the SM request a
short timeout */
#ifdef CONFIG_IPMI_KCS #ifdef CONFIG_IPMI_KCS
/* This forces a dependency to the config file for this option. */ /* This forces a dependency to the config file for this option. */
#endif #endif
...@@ -132,6 +140,8 @@ struct kcs_info ...@@ -132,6 +140,8 @@ struct kcs_info
int interrupt_disabled; int interrupt_disabled;
}; };
static void kcs_restart_short_timer(struct kcs_info *kcs_info);
static void deliver_recv_msg(struct kcs_info *kcs_info, struct ipmi_smi_msg *msg) static void deliver_recv_msg(struct kcs_info *kcs_info, struct ipmi_smi_msg *msg)
{ {
/* Deliver the message to the upper layer with the lock /* Deliver the message to the upper layer with the lock
...@@ -309,6 +319,9 @@ static void handle_transaction_done(struct kcs_info *kcs_info) ...@@ -309,6 +319,9 @@ static void handle_transaction_done(struct kcs_info *kcs_info)
#endif #endif
switch (kcs_info->kcs_state) { switch (kcs_info->kcs_state) {
case KCS_NORMAL: case KCS_NORMAL:
if (!kcs_info->curr_msg)
break;
kcs_info->curr_msg->rsp_size kcs_info->curr_msg->rsp_size
= kcs_get_result(kcs_info->kcs_sm, = kcs_get_result(kcs_info->kcs_sm,
kcs_info->curr_msg->rsp, kcs_info->curr_msg->rsp,
...@@ -563,8 +576,9 @@ static void sender(void *send_info, ...@@ -563,8 +576,9 @@ static void sender(void *send_info,
spin_lock_irqsave(&(kcs_info->kcs_lock), flags); spin_lock_irqsave(&(kcs_info->kcs_lock), flags);
result = kcs_event_handler(kcs_info, 0); result = kcs_event_handler(kcs_info, 0);
while (result != KCS_SM_IDLE) { while (result != KCS_SM_IDLE) {
udelay(500); udelay(KCS_SHORT_TIMEOUT_USEC);
result = kcs_event_handler(kcs_info, 500); result = kcs_event_handler(kcs_info,
KCS_SHORT_TIMEOUT_USEC);
} }
spin_unlock_irqrestore(&(kcs_info->kcs_lock), flags); spin_unlock_irqrestore(&(kcs_info->kcs_lock), flags);
return; return;
...@@ -582,6 +596,7 @@ static void sender(void *send_info, ...@@ -582,6 +596,7 @@ static void sender(void *send_info,
&& (kcs_info->curr_msg == NULL)) && (kcs_info->curr_msg == NULL))
{ {
start_next_msg(kcs_info); start_next_msg(kcs_info);
kcs_restart_short_timer(kcs_info);
} }
spin_unlock_irqrestore(&(kcs_info->kcs_lock), flags); spin_unlock_irqrestore(&(kcs_info->kcs_lock), flags);
} }
...@@ -598,8 +613,9 @@ static void set_run_to_completion(void *send_info, int i_run_to_completion) ...@@ -598,8 +613,9 @@ static void set_run_to_completion(void *send_info, int i_run_to_completion)
if (i_run_to_completion) { if (i_run_to_completion) {
result = kcs_event_handler(kcs_info, 0); result = kcs_event_handler(kcs_info, 0);
while (result != KCS_SM_IDLE) { while (result != KCS_SM_IDLE) {
udelay(500); udelay(KCS_SHORT_TIMEOUT_USEC);
result = kcs_event_handler(kcs_info, 500); result = kcs_event_handler(kcs_info,
KCS_SHORT_TIMEOUT_USEC);
} }
} }
...@@ -613,14 +629,42 @@ static void request_events(void *send_info) ...@@ -613,14 +629,42 @@ static void request_events(void *send_info)
atomic_set(&kcs_info->req_events, 1); atomic_set(&kcs_info->req_events, 1);
} }
/* Call every 10 ms. */
#define KCS_TIMEOUT_TIME_USEC 10000
#define KCS_USEC_PER_JIFFY (1000000/HZ)
#define KCS_TIMEOUT_JIFFIES (KCS_TIMEOUT_TIME_USEC/KCS_USEC_PER_JIFFY)
#define KCS_SHORT_TIMEOUT_USEC 500 /* .5ms when the SM request a
short timeout */
static int initialized = 0; static int initialized = 0;
/* Must be called with interrupts off and with the kcs_lock held. */
static void kcs_restart_short_timer(struct kcs_info *kcs_info)
{
if (del_timer(&(kcs_info->kcs_timer))) {
#ifdef CONFIG_HIGH_RES_TIMERS
unsigned long jiffies_now;
/* If we don't delete the timer, then it will go off
immediately, anyway. So we only process if we
actually delete the timer. */
/* We already have irqsave on, so no need for it
here. */
read_lock(&xtime_lock);
jiffies_now = jiffies;
kcs_info->kcs_timer.expires = jiffies_now;
kcs_info->kcs_timer.sub_expires
= quick_update_jiffies_sub(jiffies_now);
read_unlock(&xtime_lock);
kcs_info->kcs_timer.sub_expires
+= usec_to_arch_cycles(KCS_SHORT_TIMEOUT_USEC);
while (kcs_info->kcs_timer.sub_expires >= cycles_per_jiffies) {
kcs_info->kcs_timer.expires++;
kcs_info->kcs_timer.sub_expires -= cycles_per_jiffies;
}
#else
kcs_info->kcs_timer.expires = jiffies + 1;
#endif
add_timer(&(kcs_info->kcs_timer));
}
}
static void kcs_timeout(unsigned long data) static void kcs_timeout(unsigned long data)
{ {
struct kcs_info *kcs_info = (struct kcs_info *) data; struct kcs_info *kcs_info = (struct kcs_info *) data;
...@@ -643,12 +687,11 @@ static void kcs_timeout(unsigned long data) ...@@ -643,12 +687,11 @@ static void kcs_timeout(unsigned long data)
printk("**Timer: %d.%9.9d\n", t.tv_sec, t.tv_usec); printk("**Timer: %d.%9.9d\n", t.tv_sec, t.tv_usec);
#endif #endif
jiffies_now = jiffies; jiffies_now = jiffies;
time_diff = ((jiffies_now - kcs_info->last_timeout_jiffies) time_diff = ((jiffies_now - kcs_info->last_timeout_jiffies)
* KCS_USEC_PER_JIFFY); * KCS_USEC_PER_JIFFY);
kcs_result = kcs_event_handler(kcs_info, time_diff); kcs_result = kcs_event_handler(kcs_info, time_diff);
spin_unlock_irqrestore(&(kcs_info->kcs_lock), flags);
kcs_info->last_timeout_jiffies = jiffies_now; kcs_info->last_timeout_jiffies = jiffies_now;
if ((kcs_info->irq) && (! kcs_info->interrupt_disabled)) { if ((kcs_info->irq) && (! kcs_info->interrupt_disabled)) {
...@@ -669,6 +712,7 @@ static void kcs_timeout(unsigned long data) ...@@ -669,6 +712,7 @@ static void kcs_timeout(unsigned long data)
} }
} else { } else {
kcs_info->kcs_timer.expires = jiffies + KCS_TIMEOUT_JIFFIES; kcs_info->kcs_timer.expires = jiffies + KCS_TIMEOUT_JIFFIES;
kcs_info->kcs_timer.sub_expires = 0;
} }
#else #else
/* If requested, take the shortest delay possible */ /* If requested, take the shortest delay possible */
...@@ -681,6 +725,7 @@ static void kcs_timeout(unsigned long data) ...@@ -681,6 +725,7 @@ static void kcs_timeout(unsigned long data)
do_add_timer: do_add_timer:
add_timer(&(kcs_info->kcs_timer)); add_timer(&(kcs_info->kcs_timer));
spin_unlock_irqrestore(&(kcs_info->kcs_lock), flags);
} }
static void kcs_irq_handler(int irq, void *data, struct pt_regs *regs) static void kcs_irq_handler(int irq, void *data, struct pt_regs *regs)
......
...@@ -1765,9 +1765,13 @@ static void ipmi_timeout(unsigned long data) ...@@ -1765,9 +1765,13 @@ static void ipmi_timeout(unsigned long data)
} }
static atomic_t smi_msg_inuse_count = ATOMIC_INIT(0);
static atomic_t recv_msg_inuse_count = ATOMIC_INIT(0);
/* FIXME - convert these to slabs. */ /* FIXME - convert these to slabs. */
static void free_smi_msg(struct ipmi_smi_msg *msg) static void free_smi_msg(struct ipmi_smi_msg *msg)
{ {
atomic_dec(&smi_msg_inuse_count);
kfree(msg); kfree(msg);
} }
...@@ -1775,13 +1779,16 @@ struct ipmi_smi_msg *ipmi_alloc_smi_msg(void) ...@@ -1775,13 +1779,16 @@ struct ipmi_smi_msg *ipmi_alloc_smi_msg(void)
{ {
struct ipmi_smi_msg *rv; struct ipmi_smi_msg *rv;
rv = kmalloc(sizeof(struct ipmi_smi_msg), GFP_ATOMIC); rv = kmalloc(sizeof(struct ipmi_smi_msg), GFP_ATOMIC);
if (rv) if (rv) {
rv->done = free_smi_msg; rv->done = free_smi_msg;
atomic_inc(&smi_msg_inuse_count);
}
return rv; return rv;
} }
static void free_recv_msg(struct ipmi_recv_msg *msg) static void free_recv_msg(struct ipmi_recv_msg *msg)
{ {
atomic_dec(&recv_msg_inuse_count);
kfree(msg); kfree(msg);
} }
...@@ -1790,8 +1797,10 @@ struct ipmi_recv_msg *ipmi_alloc_recv_msg(void) ...@@ -1790,8 +1797,10 @@ struct ipmi_recv_msg *ipmi_alloc_recv_msg(void)
struct ipmi_recv_msg *rv; struct ipmi_recv_msg *rv;
rv = kmalloc(sizeof(struct ipmi_recv_msg), GFP_ATOMIC); rv = kmalloc(sizeof(struct ipmi_recv_msg), GFP_ATOMIC);
if (rv) if (rv) {
rv->done = free_recv_msg; rv->done = free_recv_msg;
atomic_inc(&recv_msg_inuse_count);
}
return rv; return rv;
} }
...@@ -1924,6 +1933,8 @@ static __init int ipmi_init_msghandler(void) ...@@ -1924,6 +1933,8 @@ static __init int ipmi_init_msghandler(void)
static __exit void cleanup_ipmi(void) static __exit void cleanup_ipmi(void)
{ {
int count;
if (!initialized) if (!initialized)
return; return;
...@@ -1940,6 +1951,16 @@ static __exit void cleanup_ipmi(void) ...@@ -1940,6 +1951,16 @@ static __exit void cleanup_ipmi(void)
} }
initialized = 0; initialized = 0;
/* Check for buffer leaks. */
count = atomic_read(&smi_msg_inuse_count);
if (count != 0)
printk("ipmi_msghandler: SMI message count %d at exit\n",
count);
count = atomic_read(&recv_msg_inuse_count);
if (count != 0)
printk("ipmi_msghandler: recv message count %d at exit\n",
count);
} }
module_exit(cleanup_ipmi); module_exit(cleanup_ipmi);
......
...@@ -506,8 +506,8 @@ void do_tty_hangup(void *data) ...@@ -506,8 +506,8 @@ void do_tty_hangup(void *data)
p->tty = NULL; p->tty = NULL;
if (!p->leader) if (!p->leader)
continue; continue;
send_sig(SIGHUP, p, 1); send_group_sig_info(SIGHUP, SEND_SIG_PRIV, p);
send_sig(SIGCONT, p, 1); send_group_sig_info(SIGCONT, SEND_SIG_PRIV, p);
if (tty->pgrp > 0) if (tty->pgrp > 0)
p->tty_old_pgrp = tty->pgrp; p->tty_old_pgrp = tty->pgrp;
} }
......
...@@ -2036,7 +2036,7 @@ modem_write_profile(atemu * m) ...@@ -2036,7 +2036,7 @@ modem_write_profile(atemu * m)
memcpy(m->pmsn, m->msn, ISDN_MSNLEN); memcpy(m->pmsn, m->msn, ISDN_MSNLEN);
memcpy(m->plmsn, m->lmsn, ISDN_LMSNLEN); memcpy(m->plmsn, m->lmsn, ISDN_LMSNLEN);
if (dev->profd) if (dev->profd)
send_sig(SIGIO, dev->profd, 1); group_send_sig_info(SIGIO, SEND_SIG_PRIV, dev->profd);
} }
int int
......
...@@ -148,6 +148,7 @@ static int __init oprofile_init(void) ...@@ -148,6 +148,7 @@ static int __init oprofile_init(void)
static void __exit oprofile_exit(void) static void __exit oprofile_exit(void)
{ {
oprofilefs_unregister(); oprofilefs_unregister();
oprofile_arch_exit();
} }
......
...@@ -465,7 +465,7 @@ static void send_sigio_to_task(struct task_struct *p, ...@@ -465,7 +465,7 @@ static void send_sigio_to_task(struct task_struct *p,
break; break;
/* fall-through: fall back on the old plain SIGIO signal */ /* fall-through: fall back on the old plain SIGIO signal */
case 0: case 0:
send_sig(SIGIO, p, 1); send_group_sig_info(SIGIO, SEND_SIG_PRIV, p);
} }
} }
...@@ -501,7 +501,7 @@ static void send_sigurg_to_task(struct task_struct *p, ...@@ -501,7 +501,7 @@ static void send_sigurg_to_task(struct task_struct *p,
struct fown_struct *fown) struct fown_struct *fown)
{ {
if (sigio_perm(p, fown)) if (sigio_perm(p, fown))
send_sig(SIGURG, p, 1); send_group_sig_info(SIGURG, SEND_SIG_PRIV, p);
} }
int send_sigurg(struct fown_struct *fown) int send_sigurg(struct fown_struct *fown)
......
...@@ -45,6 +45,11 @@ struct oprofile_operations { ...@@ -45,6 +45,11 @@ struct oprofile_operations {
*/ */
int oprofile_arch_init(struct oprofile_operations ** ops); int oprofile_arch_init(struct oprofile_operations ** ops);
/**
* One-time exit/cleanup for the arch.
*/
void oprofile_arch_exit(void);
/** /**
* Add a sample. This may be called from any context. Pass * Add a sample. This may be called from any context. Pass
* smp_processor_id() as cpu. * smp_processor_id() as cpu.
......
...@@ -541,6 +541,7 @@ extern void block_all_signals(int (*notifier)(void *priv), void *priv, ...@@ -541,6 +541,7 @@ extern void block_all_signals(int (*notifier)(void *priv), void *priv,
extern void unblock_all_signals(void); extern void unblock_all_signals(void);
extern void release_task(struct task_struct * p); extern void release_task(struct task_struct * p);
extern int send_sig_info(int, struct siginfo *, struct task_struct *); extern int send_sig_info(int, struct siginfo *, struct task_struct *);
extern int send_group_sig_info(int, struct siginfo *, struct task_struct *);
extern int force_sig_info(int, struct siginfo *, struct task_struct *); extern int force_sig_info(int, struct siginfo *, struct task_struct *);
extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp); extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
extern int kill_pg_info(int, struct siginfo *, pid_t); extern int kill_pg_info(int, struct siginfo *, pid_t);
...@@ -558,6 +559,11 @@ extern int kill_proc(pid_t, int, int); ...@@ -558,6 +559,11 @@ extern int kill_proc(pid_t, int, int);
extern int do_sigaction(int, const struct k_sigaction *, struct k_sigaction *); extern int do_sigaction(int, const struct k_sigaction *, struct k_sigaction *);
extern int do_sigaltstack(const stack_t *, stack_t *, unsigned long); extern int do_sigaltstack(const stack_t *, stack_t *, unsigned long);
/* These can be the second arg to send_sig_info/send_group_sig_info. */
#define SEND_SIG_NOINFO ((struct siginfo *) 0)
#define SEND_SIG_PRIV ((struct siginfo *) 1)
#define SEND_SIG_FORCED ((struct siginfo *) 2)
/* True if we are on the alternate signal stack. */ /* True if we are on the alternate signal stack. */
static inline int on_sig_stack(unsigned long sp) static inline int on_sig_stack(unsigned long sp)
......
...@@ -138,12 +138,10 @@ typedef enum { ...@@ -138,12 +138,10 @@ typedef enum {
*/ */
typedef union { typedef union {
sctp_cid_t chunk; sctp_cid_t chunk;
sctp_event_timeout_t timeout; sctp_event_timeout_t timeout;
sctp_event_other_t other; sctp_event_other_t other;
sctp_event_primitive_t primitive; sctp_event_primitive_t primitive;
} sctp_subtype_t; } sctp_subtype_t;
#define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \ #define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \
...@@ -421,9 +419,9 @@ typedef enum { ...@@ -421,9 +419,9 @@ typedef enum {
/* Reasons to retransmit. */ /* Reasons to retransmit. */
typedef enum { typedef enum {
SCTP_RETRANSMIT_T3_RTX, SCTP_RTXR_T3_RTX,
SCTP_RETRANSMIT_FAST_RTX, SCTP_RTXR_FAST_RTX,
SCTP_RETRANSMIT_PMTU_DISCOVERY, SCTP_RTXR_PMTUD,
} sctp_retransmit_reason_t; } sctp_retransmit_reason_t;
/* Reasons to lower cwnd. */ /* Reasons to lower cwnd. */
......
...@@ -123,14 +123,14 @@ ...@@ -123,14 +123,14 @@
*/ */
extern struct sctp_protocol sctp_proto; extern struct sctp_protocol sctp_proto;
extern struct sock *sctp_get_ctl_sock(void); extern struct sock *sctp_get_ctl_sock(void);
extern int sctp_copy_local_addr_list(struct sctp_protocol *, extern int sctp_copy_local_addr_list(struct sctp_protocol *,
struct sctp_bind_addr *, struct sctp_bind_addr *,
sctp_scope_t, int priority, int flags); sctp_scope_t, int priority, int flags);
extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family); extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family);
extern int sctp_register_pf(struct sctp_pf *, sa_family_t); extern int sctp_register_pf(struct sctp_pf *, sa_family_t);
/* /*
* sctp_socket.c * sctp/socket.c
*/ */
extern int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb); extern int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
extern int sctp_inet_listen(struct socket *sock, int backlog); extern int sctp_inet_listen(struct socket *sock, int backlog);
...@@ -139,7 +139,7 @@ extern unsigned int sctp_poll(struct file *file, struct socket *sock, ...@@ -139,7 +139,7 @@ extern unsigned int sctp_poll(struct file *file, struct socket *sock,
poll_table *wait); poll_table *wait);
/* /*
* sctp_primitive.c * sctp/primitive.c
*/ */
extern int sctp_primitive_ASSOCIATE(sctp_association_t *, void *arg); extern int sctp_primitive_ASSOCIATE(sctp_association_t *, void *arg);
extern int sctp_primitive_SHUTDOWN(sctp_association_t *, void *arg); extern int sctp_primitive_SHUTDOWN(sctp_association_t *, void *arg);
...@@ -148,14 +148,14 @@ extern int sctp_primitive_SEND(sctp_association_t *, void *arg); ...@@ -148,14 +148,14 @@ extern int sctp_primitive_SEND(sctp_association_t *, void *arg);
extern int sctp_primitive_REQUESTHEARTBEAT(sctp_association_t *, void *arg); extern int sctp_primitive_REQUESTHEARTBEAT(sctp_association_t *, void *arg);
/* /*
* sctp_crc32c.c * sctp/crc32c.c
*/ */
extern __u32 sctp_start_cksum(__u8 *ptr, __u16 count); extern __u32 sctp_start_cksum(__u8 *ptr, __u16 count);
extern __u32 sctp_update_cksum(__u8 *ptr, __u16 count, __u32 cksum); extern __u32 sctp_update_cksum(__u8 *ptr, __u16 count, __u32 cksum);
extern __u32 sctp_end_cksum(__u32 cksum); extern __u32 sctp_end_cksum(__u32 cksum);
/* /*
* sctp_input.c * sctp/input.c
*/ */
extern int sctp_rcv(struct sk_buff *skb); extern int sctp_rcv(struct sk_buff *skb);
extern void sctp_v4_err(struct sk_buff *skb, u32 info); extern void sctp_v4_err(struct sk_buff *skb, u32 info);
...@@ -170,9 +170,16 @@ extern void __sctp_unhash_endpoint(sctp_endpoint_t *); ...@@ -170,9 +170,16 @@ extern void __sctp_unhash_endpoint(sctp_endpoint_t *);
extern sctp_association_t *__sctp_lookup_association(const union sctp_addr *, extern sctp_association_t *__sctp_lookup_association(const union sctp_addr *,
const union sctp_addr *, const union sctp_addr *,
struct sctp_transport **); struct sctp_transport **);
extern struct sock *sctp_err_lookup(int family, struct sk_buff *,
struct sctphdr *, struct sctp_endpoint **,
struct sctp_association **,
struct sctp_transport **);
extern void sctp_err_finish(struct sock *, struct sctp_endpoint *,
struct sctp_association *);
extern void sctp_icmp_frag_needed(struct sock *, struct sctp_association *,
struct sctp_transport *t, __u32 pmtu);
/* /*
* sctp_hashdriver.c * sctp/hashdriver.c
*/ */
extern void sctp_hash_digest(const char *secret, const int secret_len, extern void sctp_hash_digest(const char *secret, const int secret_len,
const char *text, const int text_len, const char *text, const int text_len,
...@@ -184,9 +191,7 @@ extern void sctp_hash_digest(const char *secret, const int secret_len, ...@@ -184,9 +191,7 @@ extern void sctp_hash_digest(const char *secret, const int secret_len,
#ifdef TEST_FRAME #ifdef TEST_FRAME
#include <test_frame.h> #include <test_frame.h>
#else #else
/* spin lock wrappers. */ /* spin lock wrappers. */
...@@ -194,28 +199,28 @@ extern void sctp_hash_digest(const char *secret, const int secret_len, ...@@ -194,28 +199,28 @@ extern void sctp_hash_digest(const char *secret, const int secret_len,
#define sctp_spin_unlock_irqrestore(lock, flags) \ #define sctp_spin_unlock_irqrestore(lock, flags) \
spin_unlock_irqrestore(lock, flags) spin_unlock_irqrestore(lock, flags)
#define sctp_local_bh_disable() local_bh_disable() #define sctp_local_bh_disable() local_bh_disable()
#define sctp_local_bh_enable() local_bh_enable() #define sctp_local_bh_enable() local_bh_enable()
#define sctp_spin_lock(lock) spin_lock(lock) #define sctp_spin_lock(lock) spin_lock(lock)
#define sctp_spin_unlock(lock) spin_unlock(lock) #define sctp_spin_unlock(lock) spin_unlock(lock)
#define sctp_write_lock(lock) write_lock(lock) #define sctp_write_lock(lock) write_lock(lock)
#define sctp_write_unlock(lock) write_unlock(lock) #define sctp_write_unlock(lock) write_unlock(lock)
#define sctp_read_lock(lock) read_lock(lock) #define sctp_read_lock(lock) read_lock(lock)
#define sctp_read_unlock(lock) read_unlock(lock) #define sctp_read_unlock(lock) read_unlock(lock)
/* sock lock wrappers. */ /* sock lock wrappers. */
#define sctp_lock_sock(sk) lock_sock(sk) #define sctp_lock_sock(sk) lock_sock(sk)
#define sctp_release_sock(sk) release_sock(sk) #define sctp_release_sock(sk) release_sock(sk)
#define sctp_bh_lock_sock(sk) bh_lock_sock(sk) #define sctp_bh_lock_sock(sk) bh_lock_sock(sk)
#define sctp_bh_unlock_sock(sk) bh_unlock_sock(sk) #define sctp_bh_unlock_sock(sk) bh_unlock_sock(sk)
#define SCTP_SOCK_SLEEP_PRE(sk) SOCK_SLEEP_PRE(sk) #define SCTP_SOCK_SLEEP_PRE(sk) SOCK_SLEEP_PRE(sk)
#define SCTP_SOCK_SLEEP_POST(sk) SOCK_SLEEP_POST(sk) #define SCTP_SOCK_SLEEP_POST(sk) SOCK_SLEEP_POST(sk)
/* SCTP SNMP MIB stats handlers */ /* SCTP SNMP MIB stats handlers */
DECLARE_SNMP_STAT(struct sctp_mib, sctp_statistics); DECLARE_SNMP_STAT(struct sctp_mib, sctp_statistics);
#define SCTP_INC_STATS(field) SNMP_INC_STATS(sctp_statistics, field) #define SCTP_INC_STATS(field) SNMP_INC_STATS(sctp_statistics, field)
#define SCTP_INC_STATS_BH(field) SNMP_INC_STATS_BH(sctp_statistics, field) #define SCTP_INC_STATS_BH(field) SNMP_INC_STATS_BH(sctp_statistics, field)
#define SCTP_INC_STATS_USER(field) SNMP_INC_STATS_USER(sctp_statistics, field) #define SCTP_INC_STATS_USER(field) SNMP_INC_STATS_USER(sctp_statistics, field)
#define SCTP_DEC_STATS(field) SNMP_DEC_STATS(sctp_statistics, field) #define SCTP_DEC_STATS(field) SNMP_DEC_STATS(sctp_statistics, field)
/* Determine if this is a valid kernel address. */ /* Determine if this is a valid kernel address. */
static inline int sctp_is_valid_kaddr(unsigned long addr) static inline int sctp_is_valid_kaddr(unsigned long addr)
...@@ -312,7 +317,6 @@ static inline void sctp_sysctl_register(void) { return; } ...@@ -312,7 +317,6 @@ static inline void sctp_sysctl_register(void) { return; }
static inline void sctp_sysctl_unregister(void) { return; } static inline void sctp_sysctl_unregister(void) { return; }
#endif #endif
/* Size of Supported Address Parameter for 'x' address types. */ /* Size of Supported Address Parameter for 'x' address types. */
#define SCTP_SAT_LEN(x) (sizeof(struct sctp_paramhdr) + (x) * sizeof(__u16)) #define SCTP_SAT_LEN(x) (sizeof(struct sctp_paramhdr) + (x) * sizeof(__u16))
...@@ -320,19 +324,15 @@ static inline void sctp_sysctl_unregister(void) { return; } ...@@ -320,19 +324,15 @@ static inline void sctp_sysctl_unregister(void) { return; }
extern int sctp_v6_init(void); extern int sctp_v6_init(void);
extern void sctp_v6_exit(void); extern void sctp_v6_exit(void);
static inline int sctp_ipv6_addr_type(const struct in6_addr *addr) extern void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
{ int type, int code, int offset, __u32 info);
return ipv6_addr_type((struct in6_addr*) addr);
}
#else /* #ifdef defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ #else /* #ifdef defined(CONFIG_IPV6) */
#define sctp_ipv6_addr_type(a) 0
static inline int sctp_v6_init(void) { return 0; } static inline int sctp_v6_init(void) { return 0; }
static inline void sctp_v6_exit(void) { return; } static inline void sctp_v6_exit(void) { return; }
#endif /* #ifdef defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ #endif /* #if defined(CONFIG_IPV6) */
/* Map an association to an assoc_id. */ /* Map an association to an assoc_id. */
static inline sctp_assoc_t sctp_assoc2id(const sctp_association_t *asoc) static inline sctp_assoc_t sctp_assoc2id(const sctp_association_t *asoc)
...@@ -414,13 +414,22 @@ static inline __s32 sctp_jitter(__u32 rto) ...@@ -414,13 +414,22 @@ static inline __s32 sctp_jitter(__u32 rto)
sctp_rand ^= (sctp_rand << 12); sctp_rand ^= (sctp_rand << 12);
sctp_rand ^= (sctp_rand >> 20); sctp_rand ^= (sctp_rand >> 20);
/* Choose random number from 0 to rto, then move to -50% ~ +50% /* Choose random number from 0 to rto, then move to -50% ~ +50%
* of rto. * of rto.
*/ */
ret = sctp_rand % rto - (rto >> 1); ret = sctp_rand % rto - (rto >> 1);
return ret; return ret;
} }
/* Break down data chunks at this point. */
static inline int sctp_frag_point(int pmtu)
{
pmtu -= SCTP_IP_OVERHEAD + sizeof(struct sctp_data_chunk);
pmtu -= sizeof(struct sctp_sack_chunk);
return pmtu;
}
/* Walk through a list of TLV parameters. Don't trust the /* Walk through a list of TLV parameters. Don't trust the
* individual parameter lengths and instead depend on * individual parameter lengths and instead depend on
* the chunk length to indicate when to stop. Make sure * the chunk length to indicate when to stop. Make sure
...@@ -479,21 +488,24 @@ static inline struct sctp_protocol *sctp_get_protocol(void) ...@@ -479,21 +488,24 @@ static inline struct sctp_protocol *sctp_get_protocol(void)
/* Convert from an IP version number to an Address Family symbol. */ /* Convert from an IP version number to an Address Family symbol. */
static inline int ipver2af(__u8 ipver) static inline int ipver2af(__u8 ipver)
{ {
int family;
switch (ipver) { switch (ipver) {
case 4: case 4:
family = AF_INET; return AF_INET;
break;
case 6: case 6:
family = AF_INET6; return AF_INET6;
break;
default: default:
family = 0; return 0;
break;
}; };
}
return family; /* Perform some sanity checks. */
static inline int sctp_sanity_check(void)
{
SCTP_ASSERT(sizeof(struct sctp_ulpevent) <=
sizeof(((struct sk_buff *)0)->cb),
"SCTP: ulpevent does not fit in skb!\n", return 0);
return 1;
} }
/* Warning: The following hash functions assume a power of two 'size'. */ /* Warning: The following hash functions assume a power of two 'size'. */
...@@ -537,7 +549,7 @@ struct sctp_sock { ...@@ -537,7 +549,7 @@ struct sctp_sock {
struct sock sk; struct sock sk;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
struct ipv6_pinfo *pinet6; struct ipv6_pinfo *pinet6;
#endif /* CONFIG_IPV6 || CONFIG_IPV6_MODULE */ #endif /* CONFIG_IPV6 */
struct inet_opt inet; struct inet_opt inet;
struct sctp_opt sctp; struct sctp_opt sctp;
}; };
...@@ -550,7 +562,7 @@ struct sctp6_sock { ...@@ -550,7 +562,7 @@ struct sctp6_sock {
struct sctp_opt sctp; struct sctp_opt sctp;
struct ipv6_pinfo inet6; struct ipv6_pinfo inet6;
}; };
#endif /* CONFIG_IPV6 || CONFIG_IPV6_MODULE */ #endif /* CONFIG_IPV6 */
#define sctp_sk(__sk) (&((struct sctp_sock *)__sk)->sctp) #define sctp_sk(__sk) (&((struct sctp_sock *)__sk)->sctp)
......
...@@ -197,15 +197,14 @@ sctp_state_fn_t sctp_addip_do_asconf; ...@@ -197,15 +197,14 @@ sctp_state_fn_t sctp_addip_do_asconf;
sctp_state_fn_t sctp_addip_do_asconf_ack; sctp_state_fn_t sctp_addip_do_asconf_ack;
/* Prototypes for utility support functions. */ /* Prototypes for utility support functions. */
__u8 sctp_get_chunk_type(sctp_chunk_t *chunk); __u8 sctp_get_chunk_type(struct sctp_chunk *chunk);
sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t event_type, sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t event_type,
sctp_state_t state, sctp_state_t state,
sctp_subtype_t event_subtype); sctp_subtype_t event_subtype);
int sctp_chunk_iif(const struct sctp_chunk *);
time_t timeval_sub(struct timeval *, struct timeval *); struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *,
sctp_association_t *sctp_make_temp_asoc(const sctp_endpoint_t *, struct sctp_chunk *,
sctp_chunk_t *, int gfp);
const int priority);
__u32 sctp_generate_verification_tag(void); __u32 sctp_generate_verification_tag(void);
void sctp_populate_tie_tags(__u8 *cookie, __u32 curTag, __u32 hisTag); void sctp_populate_tie_tags(__u8 *cookie, __u32 curTag, __u32 hisTag);
...@@ -344,7 +343,7 @@ __u32 sctp_generate_tsn(const sctp_endpoint_t *); ...@@ -344,7 +343,7 @@ __u32 sctp_generate_tsn(const sctp_endpoint_t *);
/* 4th level prototypes */ /* 4th level prototypes */
void sctp_param2sockaddr(union sctp_addr *addr, sctp_addr_param_t *, void sctp_param2sockaddr(union sctp_addr *addr, sctp_addr_param_t *,
__u16 port); __u16 port, int iif);
int sctp_addr2sockaddr(const union sctp_params, union sctp_addr *); int sctp_addr2sockaddr(const union sctp_params, union sctp_addr *);
int sockaddr2sctp_addr(const union sctp_addr *, sctp_addr_param_t *); int sockaddr2sctp_addr(const union sctp_addr *, sctp_addr_param_t *);
......
This diff is collapsed.
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
* be incorporated into the next SCTP release. * be incorporated into the next SCTP release.
*/ */
#ifndef __sctp_ulpevent_h__ #ifndef __sctp_ulpevent_h__
#define __sctp_ulpevent_h__ #define __sctp_ulpevent_h__
...@@ -50,6 +49,7 @@ struct sctp_ulpevent { ...@@ -50,6 +49,7 @@ struct sctp_ulpevent {
struct sctp_association *asoc; struct sctp_association *asoc;
struct sctp_sndrcvinfo sndrcvinfo; struct sctp_sndrcvinfo sndrcvinfo;
int msg_flags; int msg_flags;
int iif;
}; };
/* Retrieve the skb this event sits inside of. */ /* Retrieve the skb this event sits inside of. */
...@@ -61,9 +61,9 @@ static inline struct sk_buff *sctp_event2skb(struct sctp_ulpevent *ev) ...@@ -61,9 +61,9 @@ static inline struct sk_buff *sctp_event2skb(struct sctp_ulpevent *ev)
/* Retrieve & cast the event sitting inside the skb. */ /* Retrieve & cast the event sitting inside the skb. */
static inline struct sctp_ulpevent *sctp_skb2event(struct sk_buff *skb) static inline struct sctp_ulpevent *sctp_skb2event(struct sk_buff *skb)
{ {
return (struct sctp_ulpevent *)skb->cb; return (struct sctp_ulpevent *)skb->cb;
} }
struct sctp_ulpevent *sctp_ulpevent_new(int size, int flags, int priority); struct sctp_ulpevent *sctp_ulpevent_new(int size, int flags, int priority);
struct sctp_ulpevent *sctp_ulpevent_init(struct sctp_ulpevent *, int flags); struct sctp_ulpevent *sctp_ulpevent_init(struct sctp_ulpevent *, int flags);
void sctp_ulpevent_free(struct sctp_ulpevent *); void sctp_ulpevent_free(struct sctp_ulpevent *);
......
...@@ -488,7 +488,7 @@ static inline void reparent_thread(task_t *p, task_t *father, int traced) ...@@ -488,7 +488,7 @@ static inline void reparent_thread(task_t *p, task_t *father, int traced)
p->self_exec_id++; p->self_exec_id++;
if (p->pdeath_signal) if (p->pdeath_signal)
send_sig(p->pdeath_signal, p, 0); send_group_sig_info(p->pdeath_signal, 0, p);
/* Move the child from its dying parent to the new one. */ /* Move the child from its dying parent to the new one. */
if (unlikely(traced)) { if (unlikely(traced)) {
......
...@@ -67,7 +67,7 @@ void it_real_fn(unsigned long __data) ...@@ -67,7 +67,7 @@ void it_real_fn(unsigned long __data)
struct task_struct * p = (struct task_struct *) __data; struct task_struct * p = (struct task_struct *) __data;
unsigned long interval; unsigned long interval;
send_sig(SIGALRM, p, 1); send_group_sig_info(SIGALRM, SEND_SIG_PRIV, p);
interval = p->it_real_incr; interval = p->it_real_incr;
if (interval) { if (interval) {
if (interval > (unsigned long) LONG_MAX) if (interval > (unsigned long) LONG_MAX)
......
...@@ -974,11 +974,6 @@ static int simplify_symbols(Elf_Shdr *sechdrs, ...@@ -974,11 +974,6 @@ static int simplify_symbols(Elf_Shdr *sechdrs,
/* Ok if weak. */ /* Ok if weak. */
if (ELF_ST_BIND(sym[i].st_info) == STB_WEAK) if (ELF_ST_BIND(sym[i].st_info) == STB_WEAK)
break; break;
#if defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64)
/* Ok if Sparc register directive. */
if (ELF_ST_TYPE(sym[i].st_info) == STT_REGISTER)
break;
#endif
printk(KERN_WARNING "%s: Unknown symbol %s\n", printk(KERN_WARNING "%s: Unknown symbol %s\n",
mod->name, strtab + sym[i].st_name); mod->name, strtab + sym[i].st_name);
......
...@@ -33,64 +33,79 @@ static kmem_cache_t *sigqueue_cachep; ...@@ -33,64 +33,79 @@ static kmem_cache_t *sigqueue_cachep;
atomic_t nr_queued_signals; atomic_t nr_queued_signals;
int max_queued_signals = 1024; int max_queued_signals = 1024;
/********************************************************* /*
* In POSIX a signal is sent either to a specific thread (Linux task)
POSIX thread group signal behavior: * or to the process as a whole (Linux thread group). How the signal
* is sent determines whether it's to one thread or the whole group,
---------------------------------------------------------- * which determines which signal mask(s) are involved in blocking it
| | userspace | kernel | * from being delivered until later. When the signal is delivered,
---------------------------------------------------------- * either it's caught or ignored by a user handler or it has a default
| SIGHUP | load-balance | kill-all | * effect that applies to the whole thread group (POSIX process).
| SIGINT | load-balance | kill-all | *
| SIGQUIT | load-balance | kill-all+core | * The possible effects an unblocked signal set to SIG_DFL can have are:
| SIGILL | specific | kill-all+core | * ignore - Nothing Happens
| SIGTRAP | specific | kill-all+core | * terminate - kill the process, i.e. all threads in the group,
| SIGABRT/SIGIOT | specific | kill-all+core | * similar to exit_group. The group leader (only) reports
| SIGBUS | specific | kill-all+core | * WIFSIGNALED status to its parent.
| SIGFPE | specific | kill-all+core | * coredump - write a core dump file describing all threads using
| SIGKILL | n/a | kill-all | * the same mm and then kill all those threads
| SIGUSR1 | load-balance | kill-all | * stop - stop all the threads in the group, i.e. TASK_STOPPED state
| SIGSEGV | specific | kill-all+core | *
| SIGUSR2 | load-balance | kill-all | * SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.
| SIGPIPE | specific | kill-all | * Other signals when not blocked and set to SIG_DFL behaves as follows.
| SIGALRM | load-balance | kill-all | * The job control signals also have other special effects.
| SIGTERM | load-balance | kill-all | *
| SIGCHLD | load-balance | ignore | * +--------------------+------------------+
| SIGCONT | load-balance | ignore | * | POSIX signal | default action |
| SIGSTOP | n/a | stop-all | * +--------------------+------------------+
| SIGTSTP | load-balance | stop-all | * | SIGHUP | terminate |
| SIGTTIN | load-balance | stop-all | * | SIGINT | terminate |
| SIGTTOU | load-balance | stop-all | * | SIGQUIT | coredump |
| SIGURG | load-balance | ignore | * | SIGILL | coredump |
| SIGXCPU | specific | kill-all+core | * | SIGTRAP | coredump |
| SIGXFSZ | specific | kill-all+core | * | SIGABRT/SIGIOT | coredump |
| SIGVTALRM | load-balance | kill-all | * | SIGBUS | coredump |
| SIGPROF | specific | kill-all | * | SIGFPE | coredump |
| SIGPOLL/SIGIO | load-balance | kill-all | * | SIGKILL | terminate(+) |
| SIGSYS/SIGUNUSED | specific | kill-all+core | * | SIGUSR1 | terminate |
| SIGSTKFLT | specific | kill-all | * | SIGSEGV | coredump |
| SIGWINCH | load-balance | ignore | * | SIGUSR2 | terminate |
| SIGPWR | load-balance | kill-all | * | SIGPIPE | terminate |
| SIGRTMIN-SIGRTMAX | load-balance | kill-all | * | SIGALRM | terminate |
---------------------------------------------------------- * | SIGTERM | terminate |
* | SIGCHLD | ignore |
non-POSIX signal thread group behavior: * | SIGCONT | ignore(*) |
* | SIGSTOP | stop(*)(+) |
---------------------------------------------------------- * | SIGTSTP | stop(*) |
| | userspace | kernel | * | SIGTTIN | stop(*) |
---------------------------------------------------------- * | SIGTTOU | stop(*) |
| SIGEMT | specific | kill-all+core | * | SIGURG | ignore |
---------------------------------------------------------- * | SIGXCPU | coredump |
*/ * | SIGXFSZ | coredump |
* | SIGVTALRM | terminate |
/* Some systems do not have a SIGSTKFLT and the kernel never * | SIGPROF | terminate |
* generates such signals anyways. * | SIGPOLL/SIGIO | terminate |
* | SIGSYS/SIGUNUSED | coredump |
* | SIGSTKFLT | terminate |
* | SIGWINCH | ignore |
* | SIGPWR | terminate |
* | SIGRTMIN-SIGRTMAX | terminate |
* +--------------------+------------------+
* | non-POSIX signal | default action |
* +--------------------+------------------+
* | SIGEMT | coredump |
* +--------------------+------------------+
*
* (+) For SIGKILL and SIGSTOP the action is "always", not just "default".
* (*) Special job control effects:
* When SIGCONT is sent, it resumes the process (all threads in the group)
* from TASK_STOPPED state and also clears any pending/queued stop signals
* (any of those marked with "stop(*)"). This happens regardless of blocking,
* catching, or ignoring SIGCONT. When any stop signal is sent, it clears
* any pending/queued SIGCONT signals; this happens regardless of blocking,
* catching, or ignored the stop signal, though (except for SIGSTOP) the
* default action of stopping the process may happen later or never.
*/ */
#ifdef SIGSTKFLT
#define M_SIGSTKFLT M(SIGSTKFLT)
#else
#define M_SIGSTKFLT 0
#endif
#ifdef SIGEMT #ifdef SIGEMT
#define M_SIGEMT M(SIGEMT) #define M_SIGEMT M(SIGEMT)
...@@ -105,16 +120,6 @@ int max_queued_signals = 1024; ...@@ -105,16 +120,6 @@ int max_queued_signals = 1024;
#endif #endif
#define T(sig, mask) (M(sig) & (mask)) #define T(sig, mask) (M(sig) & (mask))
#define SIG_KERNEL_BROADCAST_MASK (\
M(SIGHUP) | M(SIGINT) | M(SIGQUIT) | M(SIGILL) | \
M(SIGTRAP) | M(SIGABRT) | M(SIGBUS) | M(SIGFPE) | \
M(SIGKILL) | M(SIGUSR1) | M(SIGSEGV) | M(SIGUSR2) | \
M(SIGPIPE) | M(SIGALRM) | M(SIGTERM) | M(SIGXCPU) | \
M(SIGXFSZ) | M(SIGVTALRM) | M(SIGPROF) | M(SIGPOLL) | \
M(SIGSYS) | M_SIGSTKFLT | M(SIGPWR) | M(SIGCONT) | \
M(SIGSTOP) | M(SIGTSTP) | M(SIGTTIN) | M(SIGTTOU) | \
M_SIGEMT )
#define SIG_KERNEL_ONLY_MASK (\ #define SIG_KERNEL_ONLY_MASK (\
M(SIGKILL) | M(SIGSTOP) ) M(SIGKILL) | M(SIGSTOP) )
...@@ -599,7 +604,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, ...@@ -599,7 +604,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk,
struct task_struct *parent); struct task_struct *parent);
/* /*
* Handle magic process-wide effects of stop/continue signals, and SIGKILL. * Handle magic process-wide effects of stop/continue signals.
* Unlike the signal actions, these happen immediately at signal-generation * Unlike the signal actions, these happen immediately at signal-generation
* time regardless of blocking, ignoring, or handling. This does the * time regardless of blocking, ignoring, or handling. This does the
* actual continuing for SIGCONT, but not the actual stopping for stop * actual continuing for SIGCONT, but not the actual stopping for stop
...@@ -1134,9 +1139,8 @@ static int kill_something_info(int sig, struct siginfo *info, int pid) ...@@ -1134,9 +1139,8 @@ static int kill_something_info(int sig, struct siginfo *info, int pid)
*/ */
/* /*
* XXX should probably nix these interfaces and update the kernel * These two are the most common entry points. They send a signal
* to specify explicitly whether the signal is a group signal or * just to the specific thread.
* specific to a thread.
*/ */
int int
send_sig_info(int sig, struct siginfo *info, struct task_struct *p) send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
...@@ -1150,13 +1154,9 @@ send_sig_info(int sig, struct siginfo *info, struct task_struct *p) ...@@ -1150,13 +1154,9 @@ send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
* going away or changing from under us. * going away or changing from under us.
*/ */
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
if (T(sig, SIG_KERNEL_BROADCAST_MASK)) { spin_lock_irq(&p->sighand->siglock);
ret = group_send_sig_info(sig, info, p); ret = specific_send_sig_info(sig, info, p);
} else { spin_unlock_irq(&p->sighand->siglock);
spin_lock_irq(&p->sighand->siglock);
ret = specific_send_sig_info(sig, info, p);
spin_unlock_irq(&p->sighand->siglock);
}
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
return ret; return ret;
} }
...@@ -1167,6 +1167,20 @@ send_sig(int sig, struct task_struct *p, int priv) ...@@ -1167,6 +1167,20 @@ send_sig(int sig, struct task_struct *p, int priv)
return send_sig_info(sig, (void*)(long)(priv != 0), p); return send_sig_info(sig, (void*)(long)(priv != 0), p);
} }
/*
* This is the entry point for "process-wide" signals.
* They will go to an appropriate thread in the thread group.
*/
int
send_group_sig_info(int sig, struct siginfo *info, struct task_struct *p)
{
int ret;
read_lock(&tasklist_lock);
ret = group_send_sig_info(sig, info, p);
read_unlock(&tasklist_lock);
return ret;
}
void void
force_sig(int sig, struct task_struct *p) force_sig(int sig, struct task_struct *p)
{ {
...@@ -1642,6 +1656,7 @@ EXPORT_SYMBOL(kill_sl_info); ...@@ -1642,6 +1656,7 @@ EXPORT_SYMBOL(kill_sl_info);
EXPORT_SYMBOL(notify_parent); EXPORT_SYMBOL(notify_parent);
EXPORT_SYMBOL(send_sig); EXPORT_SYMBOL(send_sig);
EXPORT_SYMBOL(send_sig_info); EXPORT_SYMBOL(send_sig_info);
EXPORT_SYMBOL(send_group_sig_info);
EXPORT_SYMBOL(sigprocmask); EXPORT_SYMBOL(sigprocmask);
EXPORT_SYMBOL(block_all_signals); EXPORT_SYMBOL(block_all_signals);
EXPORT_SYMBOL(unblock_all_signals); EXPORT_SYMBOL(unblock_all_signals);
......
...@@ -1293,11 +1293,10 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar ...@@ -1293,11 +1293,10 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
static struct packet_type ip_packet_type = static struct packet_type ip_packet_type =
{ {
__constant_htons(ETH_P_IP), .type = __constant_htons(ETH_P_IP),
NULL, /* All devices */ .dev = NULL, /* All devices */
ip_rcv, .func = ip_rcv,
(void*)1, .data = (void*)1,
NULL,
}; };
/* /*
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv4.h>
#include <linux/brlock.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <net/checksum.h> #include <net/checksum.h>
#include <net/icmp.h> #include <net/icmp.h>
......
...@@ -55,20 +55,18 @@ DEFINE_SNMP_STAT(struct ipv6_mib, ipv6_statistics); ...@@ -55,20 +55,18 @@ DEFINE_SNMP_STAT(struct ipv6_mib, ipv6_statistics);
static struct packet_type ipv6_packet_type = static struct packet_type ipv6_packet_type =
{ {
__constant_htons(ETH_P_IPV6), .type = __constant_htons(ETH_P_IPV6),
NULL, /* All devices */ .dev = NULL, /* All devices */
ipv6_rcv, .func = ipv6_rcv,
(void*)1, .data = (void*)1,
NULL
}; };
/* /*
* addrconf module should be notifyed of a device going up * addrconf module should be notified of a device going up
*/ */
static struct notifier_block ipv6_dev_notf = { static struct notifier_block ipv6_dev_notf = {
addrconf_notify, .notifier_call = addrconf_notify,
NULL, .priority = 0
0
}; };
struct ip6_ra_chain *ip6_ra_chain; struct ip6_ra_chain *ip6_ra_chain;
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <linux/netfilter.h> #include <linux/netfilter.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/brlock.h>
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <net/sock.h> #include <net/sock.h>
...@@ -682,8 +681,7 @@ init_or_cleanup(int init) ...@@ -682,8 +681,7 @@ init_or_cleanup(int init)
cleanup: cleanup:
nf_unregister_queue_handler(PF_INET6); nf_unregister_queue_handler(PF_INET6);
br_write_lock_bh(BR_NETPROTO_LOCK); synchronize_net();
br_write_unlock_bh(BR_NETPROTO_LOCK);
ipq_flush(NF_DROP); ipq_flush(NF_DROP);
cleanup_sysctl: cleanup_sysctl:
......
...@@ -156,7 +156,7 @@ static int snmp6_seq_show(struct seq_file *seq, void *v) ...@@ -156,7 +156,7 @@ static int snmp6_seq_show(struct seq_file *seq, void *v)
int i; int i;
for (i=0; i<sizeof(snmp6_list)/sizeof(snmp6_list[0]); i++) for (i=0; i<sizeof(snmp6_list)/sizeof(snmp6_list[0]); i++)
seq_printf(seq, "%-32s\t%ld\n", snmp6_list[i].name, seq_printf(seq, "%-32s\t%lu\n", snmp6_list[i].name,
fold_field(snmp6_list[i].mib, snmp6_list[i].offset)); fold_field(snmp6_list[i].mib, snmp6_list[i].offset));
return 0; return 0;
......
...@@ -290,14 +290,18 @@ sctp_association_t *sctp_association_init(sctp_association_t *asoc, ...@@ -290,14 +290,18 @@ sctp_association_t *sctp_association_init(sctp_association_t *asoc,
*/ */
void sctp_association_free(sctp_association_t *asoc) void sctp_association_free(sctp_association_t *asoc)
{ {
struct sock *sk = asoc->base.sk;
struct sctp_transport *transport; struct sctp_transport *transport;
sctp_endpoint_t *ep;
struct list_head *pos, *temp; struct list_head *pos, *temp;
int i; int i;
ep = asoc->ep;
list_del(&asoc->asocs); list_del(&asoc->asocs);
/* Decrement the backlog value for a TCP-style listening socket. */
if ((SCTP_SOCKET_TCP == sctp_sk(sk)->type) &&
(SCTP_SS_LISTENING == sk->state))
sk->ack_backlog--;
/* Mark as dead, so other users can know this structure is /* Mark as dead, so other users can know this structure is
* going away. * going away.
*/ */
...@@ -421,8 +425,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, ...@@ -421,8 +425,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
SCTP_DEBUG_PRINTK("sctp_assoc_add_peer:association %p PMTU set to " SCTP_DEBUG_PRINTK("sctp_assoc_add_peer:association %p PMTU set to "
"%d\n", asoc, asoc->pmtu); "%d\n", asoc, asoc->pmtu);
asoc->frag_point = asoc->pmtu; asoc->frag_point = sctp_frag_point(asoc->pmtu);
asoc->frag_point -= SCTP_IP_OVERHEAD + sizeof(struct sctp_data_chunk);
/* The asoc->peer.port might not be meaningful yet, but /* The asoc->peer.port might not be meaningful yet, but
* initialize the packet structure anyway. * initialize the packet structure anyway.
...@@ -642,8 +645,6 @@ __u32 sctp_association_get_tsn_block(sctp_association_t *asoc, int num) ...@@ -642,8 +645,6 @@ __u32 sctp_association_get_tsn_block(sctp_association_t *asoc, int num)
/* Compare two addresses to see if they match. Wildcard addresses /* Compare two addresses to see if they match. Wildcard addresses
* only match themselves. * only match themselves.
*
* FIXME: We do not match address scopes correctly.
*/ */
int sctp_cmp_addr_exact(const union sctp_addr *ss1, int sctp_cmp_addr_exact(const union sctp_addr *ss1,
const union sctp_addr *ss2) const union sctp_addr *ss2)
...@@ -651,38 +652,27 @@ int sctp_cmp_addr_exact(const union sctp_addr *ss1, ...@@ -651,38 +652,27 @@ int sctp_cmp_addr_exact(const union sctp_addr *ss1,
struct sctp_af *af; struct sctp_af *af;
af = sctp_get_af_specific(ss1->sa.sa_family); af = sctp_get_af_specific(ss1->sa.sa_family);
if (!af) if (unlikely(!af))
return 0; return 0;
return af->cmp_addr(ss1, ss2); return af->cmp_addr(ss1, ss2);
} }
/* Return an ecne chunk to get prepended to a packet. /* Return an ecne chunk to get prepended to a packet.
* Note: We are sly and return a shared, prealloced chunk. * Note: We are sly and return a shared, prealloced chunk. FIXME:
* No we don't, but we could/should.
*/ */
sctp_chunk_t *sctp_get_ecne_prepend(sctp_association_t *asoc) sctp_chunk_t *sctp_get_ecne_prepend(struct sctp_association *asoc)
{ {
sctp_chunk_t *chunk; struct sctp_chunk *chunk;
int need_ecne;
__u32 lowest_tsn;
/* Can be called from task or bh. Both need_ecne and /* Send ECNE if needed.
* last_ecne_tsn are written during bh. * Not being able to allocate a chunk here is not deadly.
*/ */
need_ecne = asoc->need_ecne; if (asoc->need_ecne)
lowest_tsn = asoc->last_ecne_tsn; chunk = sctp_make_ecne(asoc, asoc->last_ecne_tsn);
else
if (need_ecne) {
chunk = sctp_make_ecne(asoc, lowest_tsn);
/* ECNE is not mandatory to the flow. Being unable to
* alloc mem is not deadly. We are just unable to help
* out the network. If we run out of memory, just return
* NULL.
*/
} else {
chunk = NULL; chunk = NULL;
}
return chunk; return chunk;
} }
...@@ -832,12 +822,17 @@ static void sctp_assoc_bh_rcv(sctp_association_t *asoc) ...@@ -832,12 +822,17 @@ static void sctp_assoc_bh_rcv(sctp_association_t *asoc)
void sctp_assoc_migrate(sctp_association_t *assoc, struct sock *newsk) void sctp_assoc_migrate(sctp_association_t *assoc, struct sock *newsk)
{ {
struct sctp_opt *newsp = sctp_sk(newsk); struct sctp_opt *newsp = sctp_sk(newsk);
struct sock *oldsk = assoc->base.sk;
/* Delete the association from the old endpoint's list of /* Delete the association from the old endpoint's list of
* associations. * associations.
*/ */
list_del(&assoc->asocs); list_del(&assoc->asocs);
/* Decrement the backlog value for a TCP-style socket. */
if (SCTP_SOCKET_TCP == sctp_sk(oldsk)->type)
oldsk->ack_backlog--;
/* Release references to the old endpoint and the sock. */ /* Release references to the old endpoint and the sock. */
sctp_endpoint_put(assoc->ep); sctp_endpoint_put(assoc->ep);
sock_put(assoc->base.sk); sock_put(assoc->base.sk);
...@@ -986,8 +981,7 @@ void sctp_assoc_sync_pmtu(sctp_association_t *asoc) ...@@ -986,8 +981,7 @@ void sctp_assoc_sync_pmtu(sctp_association_t *asoc)
if (pmtu) { if (pmtu) {
asoc->pmtu = pmtu; asoc->pmtu = pmtu;
asoc->frag_point = pmtu - (SCTP_IP_OVERHEAD + asoc->frag_point = sctp_frag_point(pmtu);
sizeof(sctp_data_chunk_t));
} }
SCTP_DEBUG_PRINTK("%s: asoc:%p, pmtu:%d, frag_point:%d\n", SCTP_DEBUG_PRINTK("%s: asoc:%p, pmtu:%d, frag_point:%d\n",
...@@ -1001,9 +995,9 @@ static inline int sctp_peer_needs_update(struct sctp_association *asoc) ...@@ -1001,9 +995,9 @@ static inline int sctp_peer_needs_update(struct sctp_association *asoc)
case SCTP_STATE_ESTABLISHED: case SCTP_STATE_ESTABLISHED:
case SCTP_STATE_SHUTDOWN_PENDING: case SCTP_STATE_SHUTDOWN_PENDING:
case SCTP_STATE_SHUTDOWN_RECEIVED: case SCTP_STATE_SHUTDOWN_RECEIVED:
if ((asoc->rwnd > asoc->a_rwnd) && if ((asoc->rwnd > asoc->a_rwnd) &&
((asoc->rwnd - asoc->a_rwnd) >= ((asoc->rwnd - asoc->a_rwnd) >=
min_t(__u32, (asoc->base.sk->rcvbuf >> 1), asoc->pmtu))) min_t(__u32, (asoc->base.sk->rcvbuf >> 1), asoc->pmtu)))
return 1; return 1;
break; break;
default: default:
...@@ -1070,14 +1064,14 @@ void sctp_assoc_rwnd_decrease(sctp_association_t *asoc, int len) ...@@ -1070,14 +1064,14 @@ void sctp_assoc_rwnd_decrease(sctp_association_t *asoc, int len)
asoc->rwnd = 0; asoc->rwnd = 0;
} }
SCTP_DEBUG_PRINTK("%s: asoc %p rwnd decreased by %d to (%u, %u)\n", SCTP_DEBUG_PRINTK("%s: asoc %p rwnd decreased by %d to (%u, %u)\n",
__FUNCTION__, asoc, len, asoc->rwnd, __FUNCTION__, asoc, len, asoc->rwnd,
asoc->rwnd_over); asoc->rwnd_over);
} }
/* Build the bind address list for the association based on info from the /* Build the bind address list for the association based on info from the
* local endpoint and the remote peer. * local endpoint and the remote peer.
*/ */
int sctp_assoc_set_bind_addr_from_ep(sctp_association_t *asoc, int priority) int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, int gfp)
{ {
sctp_scope_t scope; sctp_scope_t scope;
int flags; int flags;
...@@ -1094,19 +1088,17 @@ int sctp_assoc_set_bind_addr_from_ep(sctp_association_t *asoc, int priority) ...@@ -1094,19 +1088,17 @@ int sctp_assoc_set_bind_addr_from_ep(sctp_association_t *asoc, int priority)
return sctp_bind_addr_copy(&asoc->base.bind_addr, return sctp_bind_addr_copy(&asoc->base.bind_addr,
&asoc->ep->base.bind_addr, &asoc->ep->base.bind_addr,
scope, priority, flags); scope, gfp, flags);
} }
/* Build the association's bind address list from the cookie. */ /* Build the association's bind address list from the cookie. */
int sctp_assoc_set_bind_addr_from_cookie(sctp_association_t *asoc, int sctp_assoc_set_bind_addr_from_cookie(sctp_association_t *asoc,
sctp_cookie_t *cookie, int priority) sctp_cookie_t *cookie, int gfp)
{ {
int var_size2 = ntohs(cookie->peer_init->chunk_hdr.length); int var_size2 = ntohs(cookie->peer_init->chunk_hdr.length);
int var_size3 = cookie->raw_addr_list_len; int var_size3 = cookie->raw_addr_list_len;
__u8 *raw_addr_list = (__u8 *)cookie + sizeof(sctp_cookie_t) + __u8 *raw = (__u8 *)cookie + sizeof(sctp_cookie_t) + var_size2;
var_size2;
return sctp_raw_to_bind_addrs(&asoc->base.bind_addr, raw_addr_list, return sctp_raw_to_bind_addrs(&asoc->base.bind_addr, raw, var_size3,
var_size3, asoc->ep->base.bind_addr.port, asoc->ep->base.bind_addr.port, gfp);
priority);
} }
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
/* Forward declarations for internal helpers. */ /* Forward declarations for internal helpers. */
static int sctp_copy_one_addr(sctp_bind_addr_t *, union sctp_addr *, static int sctp_copy_one_addr(sctp_bind_addr_t *, union sctp_addr *,
sctp_scope_t scope, int priority, int flags); sctp_scope_t scope, int gfp, int flags);
static void sctp_bind_addr_clean(sctp_bind_addr_t *); static void sctp_bind_addr_clean(sctp_bind_addr_t *);
/* First Level Abstractions. */ /* First Level Abstractions. */
...@@ -62,7 +62,7 @@ static void sctp_bind_addr_clean(sctp_bind_addr_t *); ...@@ -62,7 +62,7 @@ static void sctp_bind_addr_clean(sctp_bind_addr_t *);
* in 'src' which have a broader scope than 'scope'. * in 'src' which have a broader scope than 'scope'.
*/ */
int sctp_bind_addr_copy(sctp_bind_addr_t *dest, const sctp_bind_addr_t *src, int sctp_bind_addr_copy(sctp_bind_addr_t *dest, const sctp_bind_addr_t *src,
sctp_scope_t scope, int priority, int flags) sctp_scope_t scope, int gfp, int flags)
{ {
struct sockaddr_storage_list *addr; struct sockaddr_storage_list *addr;
struct list_head *pos; struct list_head *pos;
...@@ -75,7 +75,7 @@ int sctp_bind_addr_copy(sctp_bind_addr_t *dest, const sctp_bind_addr_t *src, ...@@ -75,7 +75,7 @@ int sctp_bind_addr_copy(sctp_bind_addr_t *dest, const sctp_bind_addr_t *src,
list_for_each(pos, &src->address_list) { list_for_each(pos, &src->address_list) {
addr = list_entry(pos, struct sockaddr_storage_list, list); addr = list_entry(pos, struct sockaddr_storage_list, list);
error = sctp_copy_one_addr(dest, &addr->a, scope, error = sctp_copy_one_addr(dest, &addr->a, scope,
priority, flags); gfp, flags);
if (error < 0) if (error < 0)
goto out; goto out;
} }
...@@ -88,11 +88,11 @@ int sctp_bind_addr_copy(sctp_bind_addr_t *dest, const sctp_bind_addr_t *src, ...@@ -88,11 +88,11 @@ int sctp_bind_addr_copy(sctp_bind_addr_t *dest, const sctp_bind_addr_t *src,
} }
/* Create a new SCTP_bind_addr from nothing. */ /* Create a new SCTP_bind_addr from nothing. */
sctp_bind_addr_t *sctp_bind_addr_new(int priority) sctp_bind_addr_t *sctp_bind_addr_new(int gfp)
{ {
sctp_bind_addr_t *retval; sctp_bind_addr_t *retval;
retval = t_new(sctp_bind_addr_t, priority); retval = t_new(sctp_bind_addr_t, gfp);
if (!retval) if (!retval)
goto nomem; goto nomem;
...@@ -144,12 +144,12 @@ void sctp_bind_addr_free(sctp_bind_addr_t *bp) ...@@ -144,12 +144,12 @@ void sctp_bind_addr_free(sctp_bind_addr_t *bp)
/* Add an address to the bind address list in the SCTP_bind_addr structure. */ /* Add an address to the bind address list in the SCTP_bind_addr structure. */
int sctp_add_bind_addr(sctp_bind_addr_t *bp, union sctp_addr *new, int sctp_add_bind_addr(sctp_bind_addr_t *bp, union sctp_addr *new,
int priority) int gfp)
{ {
struct sockaddr_storage_list *addr; struct sockaddr_storage_list *addr;
/* Add the address to the bind address list. */ /* Add the address to the bind address list. */
addr = t_new(struct sockaddr_storage_list, priority); addr = t_new(struct sockaddr_storage_list, gfp);
if (!addr) if (!addr)
return -ENOMEM; return -ENOMEM;
...@@ -197,7 +197,7 @@ int sctp_del_bind_addr(sctp_bind_addr_t *bp, union sctp_addr *del_addr) ...@@ -197,7 +197,7 @@ int sctp_del_bind_addr(sctp_bind_addr_t *bp, union sctp_addr *del_addr)
* The second argument is the return value for the length. * The second argument is the return value for the length.
*/ */
union sctp_params sctp_bind_addrs_to_raw(const sctp_bind_addr_t *bp, union sctp_params sctp_bind_addrs_to_raw(const sctp_bind_addr_t *bp,
int *addrs_len, int priority) int *addrs_len, int gfp)
{ {
union sctp_params addrparms; union sctp_params addrparms;
union sctp_params retval; union sctp_params retval;
...@@ -214,7 +214,7 @@ union sctp_params sctp_bind_addrs_to_raw(const sctp_bind_addr_t *bp, ...@@ -214,7 +214,7 @@ union sctp_params sctp_bind_addrs_to_raw(const sctp_bind_addr_t *bp,
len += sizeof(sctp_addr_param_t); len += sizeof(sctp_addr_param_t);
} }
retval.v = kmalloc(len, priority); retval.v = kmalloc(len, gfp);
if (!retval.v) if (!retval.v)
goto end_raw; goto end_raw;
...@@ -238,7 +238,7 @@ union sctp_params sctp_bind_addrs_to_raw(const sctp_bind_addr_t *bp, ...@@ -238,7 +238,7 @@ union sctp_params sctp_bind_addrs_to_raw(const sctp_bind_addr_t *bp,
* address parameters). * address parameters).
*/ */
int sctp_raw_to_bind_addrs(sctp_bind_addr_t *bp, __u8 *raw_addr_list, int sctp_raw_to_bind_addrs(sctp_bind_addr_t *bp, __u8 *raw_addr_list,
int addrs_len, __u16 port, int priority) int addrs_len, __u16 port, int gfp)
{ {
sctp_addr_param_t *rawaddr; sctp_addr_param_t *rawaddr;
sctp_paramhdr_t *param; sctp_paramhdr_t *param;
...@@ -254,8 +254,8 @@ int sctp_raw_to_bind_addrs(sctp_bind_addr_t *bp, __u8 *raw_addr_list, ...@@ -254,8 +254,8 @@ int sctp_raw_to_bind_addrs(sctp_bind_addr_t *bp, __u8 *raw_addr_list,
switch (param->type) { switch (param->type) {
case SCTP_PARAM_IPV4_ADDRESS: case SCTP_PARAM_IPV4_ADDRESS:
case SCTP_PARAM_IPV6_ADDRESS: case SCTP_PARAM_IPV6_ADDRESS:
sctp_param2sockaddr(&addr, rawaddr, port); sctp_param2sockaddr(&addr, rawaddr, port, 0);
retval = sctp_add_bind_addr(bp, &addr, priority); retval = sctp_add_bind_addr(bp, &addr, gfp);
if (retval) { if (retval) {
/* Can't finish building the list, clean up. */ /* Can't finish building the list, clean up. */
sctp_bind_addr_clean(bp); sctp_bind_addr_clean(bp);
...@@ -300,14 +300,14 @@ int sctp_bind_addr_match(sctp_bind_addr_t *bp, const union sctp_addr *addr, ...@@ -300,14 +300,14 @@ int sctp_bind_addr_match(sctp_bind_addr_t *bp, const union sctp_addr *addr,
/* Copy out addresses from the global local address list. */ /* Copy out addresses from the global local address list. */
static int sctp_copy_one_addr(sctp_bind_addr_t *dest, union sctp_addr *addr, static int sctp_copy_one_addr(sctp_bind_addr_t *dest, union sctp_addr *addr,
sctp_scope_t scope, int priority, int flags) sctp_scope_t scope, int gfp, int flags)
{ {
struct sctp_protocol *proto = sctp_get_protocol(); struct sctp_protocol *proto = sctp_get_protocol();
int error = 0; int error = 0;
if (sctp_is_any(addr)) { if (sctp_is_any(addr)) {
error = sctp_copy_local_addr_list(proto, dest, scope, error = sctp_copy_local_addr_list(proto, dest, scope,
priority, flags); gfp, flags);
} else if (sctp_in_scope(addr, scope)) { } else if (sctp_in_scope(addr, scope)) {
/* Now that the address is in scope, check to see if /* Now that the address is in scope, check to see if
* the address type is supported by local sock as * the address type is supported by local sock as
...@@ -318,7 +318,7 @@ static int sctp_copy_one_addr(sctp_bind_addr_t *dest, union sctp_addr *addr, ...@@ -318,7 +318,7 @@ static int sctp_copy_one_addr(sctp_bind_addr_t *dest, union sctp_addr *addr,
(((AF_INET6 == addr->sa.sa_family) && (((AF_INET6 == addr->sa.sa_family) &&
(flags & SCTP_ADDR6_ALLOWED) && (flags & SCTP_ADDR6_ALLOWED) &&
(flags & SCTP_ADDR6_PEERSUPP)))) (flags & SCTP_ADDR6_PEERSUPP))))
error = sctp_add_bind_addr(dest, addr, priority); error = sctp_add_bind_addr(dest, addr, gfp);
} }
return error; return error;
......
...@@ -177,8 +177,15 @@ sctp_endpoint_t *sctp_endpoint_init(sctp_endpoint_t *ep, ...@@ -177,8 +177,15 @@ sctp_endpoint_t *sctp_endpoint_init(sctp_endpoint_t *ep,
/* Add an association to an endpoint. */ /* Add an association to an endpoint. */
void sctp_endpoint_add_asoc(sctp_endpoint_t *ep, sctp_association_t *asoc) void sctp_endpoint_add_asoc(sctp_endpoint_t *ep, sctp_association_t *asoc)
{ {
struct sock *sk = ep->base.sk;
/* Now just add it to our list of asocs */ /* Now just add it to our list of asocs */
list_add_tail(&asoc->asocs, &ep->asocs); list_add_tail(&asoc->asocs, &ep->asocs);
/* Increment the backlog value for a TCP-style listening socket. */
if ((SCTP_SOCKET_TCP == sctp_sk(sk)->type) &&
(SCTP_SS_LISTENING == sk->state))
sk->ack_backlog++;
} }
/* Free the endpoint structure. Delay cleanup until /* Free the endpoint structure. Delay cleanup until
......
...@@ -207,21 +207,19 @@ int sctp_rcv(struct sk_buff *skb) ...@@ -207,21 +207,19 @@ int sctp_rcv(struct sk_buff *skb)
*/ */
sctp_bh_lock_sock(sk); sctp_bh_lock_sock(sk);
if (sock_owned_by_user(sk)) { if (sock_owned_by_user(sk))
sk_add_backlog(sk, (struct sk_buff *) chunk); sk_add_backlog(sk, (struct sk_buff *) chunk);
} else { else
sctp_backlog_rcv(sk, (struct sk_buff *) chunk); sctp_backlog_rcv(sk, (struct sk_buff *) chunk);
}
/* Release the sock and any reference counts we took in the /* Release the sock and any reference counts we took in the
* lookup calls. * lookup calls.
*/ */
sctp_bh_unlock_sock(sk); sctp_bh_unlock_sock(sk);
if (asoc) { if (asoc)
sctp_association_put(asoc); sctp_association_put(asoc);
} else { else
sctp_endpoint_put(ep); sctp_endpoint_put(ep);
}
sock_put(sk); sock_put(sk);
return ret; return ret;
...@@ -268,10 +266,8 @@ int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -268,10 +266,8 @@ int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
} }
/* Handle icmp frag needed error. */ /* Handle icmp frag needed error. */
static inline void sctp_icmp_frag_needed(struct sock *sk, void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc,
sctp_association_t *asoc, struct sctp_transport *t, __u32 pmtu)
struct sctp_transport *transport,
__u32 pmtu)
{ {
if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) { if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) {
printk(KERN_WARNING "%s: Reported pmtu %d too low, " printk(KERN_WARNING "%s: Reported pmtu %d too low, "
...@@ -280,54 +276,38 @@ static inline void sctp_icmp_frag_needed(struct sock *sk, ...@@ -280,54 +276,38 @@ static inline void sctp_icmp_frag_needed(struct sock *sk,
pmtu = SCTP_DEFAULT_MINSEGMENT; pmtu = SCTP_DEFAULT_MINSEGMENT;
} }
if (!sock_owned_by_user(sk) && transport && (transport->pmtu != pmtu)) { if (!sock_owned_by_user(sk) && t && (t->pmtu != pmtu)) {
transport->pmtu = pmtu; t->pmtu = pmtu;
sctp_assoc_sync_pmtu(asoc); sctp_assoc_sync_pmtu(asoc);
sctp_retransmit(&asoc->outqueue, transport, sctp_retransmit(&asoc->outqueue, t, SCTP_RTXR_PMTUD);
SCTP_RETRANSMIT_PMTU_DISCOVERY );
} }
} }
/* /* Common lookup code for icmp/icmpv6 error handler. */
* This routine is called by the ICMP module when it gets some struct sock *sctp_err_lookup(int family, struct sk_buff *skb,
* sort of error condition. If err < 0 then the socket should struct sctphdr *sctphdr,
* be closed and the error returned to the user. If err > 0 struct sctp_endpoint **epp,
* it's just the icmp type << 8 | icmp code. After adjustment struct sctp_association **app,
* header points to the first 8 bytes of the sctp header. We need struct sctp_transport **tpp)
* to find the appropriate port.
*
* The locking strategy used here is very "optimistic". When
* someone else accesses the socket the ICMP is just dropped
* and for some paths there is no check at all.
* A more general error queue to queue errors for later handling
* is probably better.
*
*/
void sctp_v4_err(struct sk_buff *skb, __u32 info)
{ {
struct iphdr *iph = (struct iphdr *)skb->data; union sctp_addr saddr;
struct sctphdr *sh = (struct sctphdr *)(skb->data + (iph->ihl <<2)); union sctp_addr daddr;
int type = skb->h.icmph->type; struct sctp_af *af;
int code = skb->h.icmph->code;
union sctp_addr saddr, daddr;
struct inet_opt *inet;
struct sock *sk = NULL; struct sock *sk = NULL;
sctp_endpoint_t *ep = NULL; struct sctp_endpoint *ep = NULL;
sctp_association_t *asoc = NULL; struct sctp_association *asoc = NULL;
struct sctp_transport *transport; struct sctp_transport *transport = NULL;
int err;
if (skb->len < ((iph->ihl << 2) + 8)) { *app = NULL; *epp = NULL; *tpp = NULL;
ICMP_INC_STATS_BH(IcmpInErrors);
return; af = sctp_get_af_specific(family);
if (unlikely(!af)) {
return NULL;
} }
saddr.v4.sin_family = AF_INET; /* Initialize local addresses for lookups. */
saddr.v4.sin_port = ntohs(sh->source); af->from_skb(&saddr, skb, 1);
memcpy(&saddr.v4.sin_addr.s_addr, &iph->saddr, sizeof(struct in_addr)); af->from_skb(&daddr, skb, 0);
daddr.v4.sin_family = AF_INET;
daddr.v4.sin_port = ntohs(sh->dest);
memcpy(&daddr.v4.sin_addr.s_addr, &iph->daddr, sizeof(struct in_addr));
/* Look for an association that matches the incoming ICMP error /* Look for an association that matches the incoming ICMP error
* packet. * packet.
...@@ -340,13 +320,12 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) ...@@ -340,13 +320,12 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
*/ */
ep = __sctp_rcv_lookup_endpoint(&daddr); ep = __sctp_rcv_lookup_endpoint(&daddr);
if (!ep) { if (!ep) {
ICMP_INC_STATS_BH(IcmpInErrors); return NULL;
return;
} }
} }
if (asoc) { if (asoc) {
if (ntohl(sh->vtag) != asoc->c.peer_vtag) { if (ntohl(sctphdr->vtag) != asoc->c.peer_vtag) {
ICMP_INC_STATS_BH(IcmpInErrors); ICMP_INC_STATS_BH(IcmpInErrors);
goto out; goto out;
} }
...@@ -355,12 +334,90 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) ...@@ -355,12 +334,90 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
sk = ep->base.sk; sk = ep->base.sk;
sctp_bh_lock_sock(sk); sctp_bh_lock_sock(sk);
/* If too many ICMPs get dropped on busy /* If too many ICMPs get dropped on busy
* servers this needs to be solved differently. * servers this needs to be solved differently.
*/ */
if (sock_owned_by_user(sk)) if (sock_owned_by_user(sk))
NET_INC_STATS_BH(LockDroppedIcmps); NET_INC_STATS_BH(LockDroppedIcmps);
*epp = ep;
*app = asoc;
*tpp = transport;
return sk;
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)
{
sctp_bh_unlock_sock(sk);
sock_put(sk);
if (asoc)
sctp_association_put(asoc);
if (ep)
sctp_endpoint_put(ep);
}
/*
* This routine is called by the ICMP module when it gets some
* sort of error condition. If err < 0 then the socket should
* be closed and the error returned to the user. If err > 0
* it's just the icmp type << 8 | icmp code. After adjustment
* header points to the first 8 bytes of the sctp header. We need
* to find the appropriate port.
*
* The locking strategy used here is very "optimistic". When
* someone else accesses the socket the ICMP is just dropped
* and for some paths there is no check at all.
* A more general error queue to queue errors for later handling
* is probably better.
*
*/
void sctp_v4_err(struct sk_buff *skb, __u32 info)
{
struct iphdr *iph = (struct iphdr *)skb->data;
struct sctphdr *sh = (struct sctphdr *)(skb->data + (iph->ihl <<2));
int type = skb->h.icmph->type;
int code = skb->h.icmph->code;
struct sock *sk;
sctp_endpoint_t *ep;
sctp_association_t *asoc;
struct sctp_transport *transport;
struct inet_opt *inet;
char *saveip, *savesctp;
int err;
if (skb->len < ((iph->ihl << 2) + 8)) {
ICMP_INC_STATS_BH(IcmpInErrors);
return;
}
/* Fix up skb to look at the embedded net header. */
saveip = skb->nh.raw;
savesctp = skb->h.raw;
skb->nh.iph = iph;
skb->h.raw = (char *)sh;
sk = sctp_err_lookup(AF_INET, skb, sh, &ep, &asoc, &transport);
/* Put back, the original pointers. */
skb->nh.raw = saveip;
skb->h.raw = savesctp;
if (!sk) {
ICMP_INC_STATS_BH(IcmpInErrors);
return;
}
/* Warning: The sock lock is held. Remember to call
* sctp_err_finish!
*/
switch (type) { switch (type) {
case ICMP_PARAMETERPROB: case ICMP_PARAMETERPROB:
err = EPROTO; err = EPROTO;
...@@ -399,13 +456,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) ...@@ -399,13 +456,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
} }
out_unlock: out_unlock:
sctp_bh_unlock_sock(sk); sctp_err_finish(sk, ep, asoc);
out:
sock_put(sk);
if (asoc)
sctp_association_put(asoc);
if (ep)
sctp_endpoint_put(ep);
} }
/* /*
...@@ -623,9 +674,9 @@ void __sctp_unhash_established(sctp_association_t *asoc) ...@@ -623,9 +674,9 @@ void __sctp_unhash_established(sctp_association_t *asoc)
} }
/* Look up an association. */ /* Look up an association. */
sctp_association_t *__sctp_lookup_association(const union sctp_addr *laddr, sctp_association_t *__sctp_lookup_association(const union sctp_addr *local,
const union sctp_addr *paddr, const union sctp_addr *peer,
struct sctp_transport **transportp) struct sctp_transport **pt)
{ {
sctp_hashbucket_t *head; sctp_hashbucket_t *head;
sctp_endpoint_common_t *epb; sctp_endpoint_common_t *epb;
...@@ -636,12 +687,12 @@ sctp_association_t *__sctp_lookup_association(const union sctp_addr *laddr, ...@@ -636,12 +687,12 @@ sctp_association_t *__sctp_lookup_association(const union sctp_addr *laddr,
/* Optimize here for direct hit, only listening connections can /* Optimize here for direct hit, only listening connections can
* have wildcards anyways. * have wildcards anyways.
*/ */
hash = sctp_assoc_hashfn(laddr->v4.sin_port, paddr->v4.sin_port); hash = sctp_assoc_hashfn(local->v4.sin_port, peer->v4.sin_port);
head = &sctp_proto.assoc_hashbucket[hash]; head = &sctp_proto.assoc_hashbucket[hash];
read_lock(&head->lock); read_lock(&head->lock);
for (epb = head->chain; epb; epb = epb->next) { for (epb = head->chain; epb; epb = epb->next) {
asoc = sctp_assoc(epb); asoc = sctp_assoc(epb);
transport = sctp_assoc_is_match(asoc, laddr, paddr); transport = sctp_assoc_is_match(asoc, local, peer);
if (transport) if (transport)
goto hit; goto hit;
} }
...@@ -651,7 +702,7 @@ sctp_association_t *__sctp_lookup_association(const union sctp_addr *laddr, ...@@ -651,7 +702,7 @@ sctp_association_t *__sctp_lookup_association(const union sctp_addr *laddr,
return NULL; return NULL;
hit: hit:
*transportp = transport; *pt = transport;
sctp_association_hold(asoc); sctp_association_hold(asoc);
sock_hold(epb->sk); sock_hold(epb->sk);
read_unlock(&head->lock); read_unlock(&head->lock);
...@@ -754,7 +805,7 @@ static sctp_association_t *__sctp_rcv_init_lookup(struct sk_buff *skb, ...@@ -754,7 +805,7 @@ static sctp_association_t *__sctp_rcv_init_lookup(struct sk_buff *skb,
(SCTP_PARAM_IPV6_ADDRESS != params.p->type)) (SCTP_PARAM_IPV6_ADDRESS != params.p->type))
continue; continue;
sctp_param2sockaddr(paddr, params.addr, ntohs(sh->source)); sctp_param2sockaddr(paddr, params.addr, ntohs(sh->source), 0);
asoc = __sctp_lookup_association(laddr, paddr, transportp); asoc = __sctp_lookup_association(laddr, paddr, transportp);
if (asoc) if (asoc)
return asoc; return asoc;
...@@ -782,8 +833,3 @@ sctp_association_t *__sctp_rcv_lookup(struct sk_buff *skb, ...@@ -782,8 +833,3 @@ sctp_association_t *__sctp_rcv_lookup(struct sk_buff *skb,
return asoc; return asoc;
} }
This diff is collapsed.
...@@ -79,6 +79,7 @@ struct sctp_packet *sctp_packet_config(struct sctp_packet *packet, ...@@ -79,6 +79,7 @@ struct sctp_packet *sctp_packet_config(struct sctp_packet *packet,
packet->ecn_capable = ecn_capable; packet->ecn_capable = ecn_capable;
packet->get_prepend_chunk = prepend_handler; packet->get_prepend_chunk = prepend_handler;
packet->has_cookie_echo = 0; packet->has_cookie_echo = 0;
packet->has_sack = 0;
packet->ipfragok = 0; packet->ipfragok = 0;
/* We might need to call the prepend_handler right away. */ /* We might need to call the prepend_handler right away. */
...@@ -100,6 +101,7 @@ struct sctp_packet *sctp_packet_init(struct sctp_packet *packet, ...@@ -100,6 +101,7 @@ struct sctp_packet *sctp_packet_init(struct sctp_packet *packet,
packet->ecn_capable = 0; packet->ecn_capable = 0;
packet->get_prepend_chunk = NULL; packet->get_prepend_chunk = NULL;
packet->has_cookie_echo = 0; packet->has_cookie_echo = 0;
packet->has_sack = 0;
packet->ipfragok = 0; packet->ipfragok = 0;
packet->malloced = 0; packet->malloced = 0;
sctp_packet_reset(packet); sctp_packet_reset(packet);
...@@ -155,6 +157,37 @@ sctp_xmit_t sctp_packet_transmit_chunk(struct sctp_packet *packet, ...@@ -155,6 +157,37 @@ sctp_xmit_t sctp_packet_transmit_chunk(struct sctp_packet *packet,
return retval; return retval;
} }
/* Try to bundle a SACK with the packet. */
static sctp_xmit_t sctp_packet_bundle_sack(struct sctp_packet *pkt,
struct sctp_chunk *chunk)
{
sctp_xmit_t retval = SCTP_XMIT_OK;
/* If sending DATA and haven't aleady bundled a SACK, try to
* bundle one in to the packet.
*/
if (sctp_chunk_is_data(chunk) && !pkt->has_sack &&
!pkt->has_cookie_echo) {
struct sctp_association *asoc;
asoc = pkt->transport->asoc;
if (asoc->a_rwnd > asoc->rwnd) {
struct sctp_chunk *sack;
asoc->a_rwnd = asoc->rwnd;
sack = sctp_make_sack(asoc);
if (sack) {
struct timer_list *timer;
retval = sctp_packet_append_chunk(pkt, sack);
asoc->peer.sack_needed = 0;
timer = &asoc->timers[SCTP_EVENT_TIMEOUT_SACK];
if (timer_pending(timer) && del_timer(timer))
sctp_association_put(asoc);
}
}
}
return retval;
}
/* Append a chunk to the offered packet reporting back any inability to do /* Append a chunk to the offered packet reporting back any inability to do
* so. * so.
*/ */
...@@ -163,10 +196,16 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet, ...@@ -163,10 +196,16 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
{ {
sctp_xmit_t retval = SCTP_XMIT_OK; sctp_xmit_t retval = SCTP_XMIT_OK;
__u16 chunk_len = WORD_ROUND(ntohs(chunk->chunk_hdr->length)); __u16 chunk_len = WORD_ROUND(ntohs(chunk->chunk_hdr->length));
size_t psize = packet->size; size_t psize;
size_t pmtu; size_t pmtu;
int too_big; int too_big;
retval = sctp_packet_bundle_sack(packet, chunk);
psize = packet->size;
if (retval != SCTP_XMIT_OK)
goto finish;
pmtu = ((packet->transport->asoc) ? pmtu = ((packet->transport->asoc) ?
(packet->transport->asoc->pmtu) : (packet->transport->asoc->pmtu) :
(packet->transport->pmtu)); (packet->transport->pmtu));
...@@ -214,11 +253,14 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet, ...@@ -214,11 +253,14 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
*/ */
if (sctp_chunk_is_data(chunk)) { if (sctp_chunk_is_data(chunk)) {
retval = sctp_packet_append_data(packet, chunk); retval = sctp_packet_append_data(packet, chunk);
/* Disallow SACK bundling after DATA. */
packet->has_sack = 1;
if (SCTP_XMIT_OK != retval) if (SCTP_XMIT_OK != retval)
goto finish; goto finish;
} else if (SCTP_CID_COOKIE_ECHO == chunk->chunk_hdr->type) { } else if (SCTP_CID_COOKIE_ECHO == chunk->chunk_hdr->type)
packet->has_cookie_echo = 1; packet->has_cookie_echo = 1;
} else if (SCTP_CID_SACK == chunk->chunk_hdr->type)
packet->has_sack = 1;
/* It is OK to send this chunk. */ /* It is OK to send this chunk. */
__skb_queue_tail(&packet->chunks, (struct sk_buff *)chunk); __skb_queue_tail(&packet->chunks, (struct sk_buff *)chunk);
......
...@@ -138,13 +138,13 @@ void sctp_outq_init(sctp_association_t *asoc, struct sctp_outq *q) ...@@ -138,13 +138,13 @@ void sctp_outq_init(sctp_association_t *asoc, struct sctp_outq *q)
} }
/* Free the outqueue structure and any related pending chunks. /* Free the outqueue structure and any related pending chunks.
* FIXME: Add SEND_FAILED support.
*/ */
void sctp_outq_teardown(struct sctp_outq *q) void sctp_outq_teardown(struct sctp_outq *q)
{ {
struct sctp_transport *transport; struct sctp_transport *transport;
struct list_head *lchunk, *pos, *temp; struct list_head *lchunk, *pos, *temp;
sctp_chunk_t *chunk; sctp_chunk_t *chunk;
struct sctp_ulpevent *ev;
/* Throw away unacknowledged chunks. */ /* Throw away unacknowledged chunks. */
list_for_each(pos, &q->asoc->peer.transport_addr_list) { list_for_each(pos, &q->asoc->peer.transport_addr_list) {
...@@ -152,6 +152,14 @@ void sctp_outq_teardown(struct sctp_outq *q) ...@@ -152,6 +152,14 @@ void sctp_outq_teardown(struct sctp_outq *q)
while ((lchunk = sctp_list_dequeue(&transport->transmitted))) { while ((lchunk = sctp_list_dequeue(&transport->transmitted))) {
chunk = list_entry(lchunk, sctp_chunk_t, chunk = list_entry(lchunk, sctp_chunk_t,
transmitted_list); transmitted_list);
/* Generate a SEND FAILED event. */
ev = sctp_ulpevent_make_send_failed(q->asoc,
chunk, SCTP_DATA_SENT,
q->error, GFP_ATOMIC);
if (ev)
sctp_ulpq_tail_event(&q->asoc->ulpq, ev);
sctp_free_chunk(chunk); sctp_free_chunk(chunk);
} }
} }
...@@ -171,8 +179,19 @@ void sctp_outq_teardown(struct sctp_outq *q) ...@@ -171,8 +179,19 @@ void sctp_outq_teardown(struct sctp_outq *q)
} }
/* Throw away any leftover data chunks. */ /* Throw away any leftover data chunks. */
while ((chunk = sctp_outq_dequeue_data(q))) while ((chunk = sctp_outq_dequeue_data(q))) {
/* Generate a SEND FAILED event. */
ev = sctp_ulpevent_make_send_failed(q->asoc,
chunk, SCTP_DATA_UNSENT,
q->error, GFP_ATOMIC);
if (ev)
sctp_ulpq_tail_event(&q->asoc->ulpq, ev);
sctp_free_chunk(chunk); sctp_free_chunk(chunk);
}
q->error = 0;
/* Throw away any leftover control chunks. */ /* Throw away any leftover control chunks. */
while ((chunk = (sctp_chunk_t *) skb_dequeue(&q->control))) while ((chunk = (sctp_chunk_t *) skb_dequeue(&q->control)))
...@@ -357,7 +376,7 @@ void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport, ...@@ -357,7 +376,7 @@ void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
__u8 fast_retransmit = 0; __u8 fast_retransmit = 0;
switch(reason) { switch(reason) {
case SCTP_RETRANSMIT_T3_RTX: case SCTP_RTXR_T3_RTX:
sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_T3_RTX); sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_T3_RTX);
/* Update the retran path if the T3-rtx timer has expired for /* Update the retran path if the T3-rtx timer has expired for
* the current retran path. * the current retran path.
...@@ -365,10 +384,11 @@ void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport, ...@@ -365,10 +384,11 @@ void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
if (transport == transport->asoc->peer.retran_path) if (transport == transport->asoc->peer.retran_path)
sctp_assoc_update_retran_path(transport->asoc); sctp_assoc_update_retran_path(transport->asoc);
break; break;
case SCTP_RETRANSMIT_FAST_RTX: case SCTP_RTXR_FAST_RTX:
sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_FAST_RTX); sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_FAST_RTX);
fast_retransmit = 1; fast_retransmit = 1;
break; break;
case SCTP_RTXR_PMTUD:
default: default:
break; break;
} }
...@@ -876,7 +896,7 @@ int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout) ...@@ -876,7 +896,7 @@ int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
start_timer = 0; start_timer = 0;
queue = &q->out; queue = &q->out;
while (NULL != (chunk = sctp_outq_dequeue_data(q))) { while ((chunk = sctp_outq_dequeue_data(q))) {
/* RFC 2960 6.5 Every DATA chunk MUST carry a valid /* RFC 2960 6.5 Every DATA chunk MUST carry a valid
* stream identifier. * stream identifier.
*/ */
...@@ -891,9 +911,7 @@ int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout) ...@@ -891,9 +911,7 @@ int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
if (ev) if (ev)
sctp_ulpq_tail_event(&asoc->ulpq, ev); sctp_ulpq_tail_event(&asoc->ulpq, ev);
/* Free the chunk. This chunk is not on any /* Free the chunk. */
* list yet, just free it.
*/
sctp_free_chunk(chunk); sctp_free_chunk(chunk);
continue; continue;
} }
...@@ -1572,7 +1590,7 @@ static void sctp_check_transmitted(struct sctp_outq *q, ...@@ -1572,7 +1590,7 @@ static void sctp_check_transmitted(struct sctp_outq *q,
if (transport) { if (transport) {
if (do_fast_retransmit) if (do_fast_retransmit)
sctp_retransmit(q, transport, SCTP_RETRANSMIT_FAST_RTX); sctp_retransmit(q, transport, SCTP_RTXR_FAST_RTX);
SCTP_DEBUG_PRINTK("%s: transport: %p, cwnd: %d, " SCTP_DEBUG_PRINTK("%s: transport: %p, cwnd: %d, "
"ssthresh: %d, flight_size: %d, pba: %d\n", "ssthresh: %d, flight_size: %d, pba: %d\n",
......
...@@ -170,7 +170,7 @@ static void __sctp_get_local_addr_list(struct sctp_protocol *proto) ...@@ -170,7 +170,7 @@ static void __sctp_get_local_addr_list(struct sctp_protocol *proto)
static void sctp_get_local_addr_list(struct sctp_protocol *proto) static void sctp_get_local_addr_list(struct sctp_protocol *proto)
{ {
long flags __attribute__ ((unused)); unsigned long flags;
sctp_spin_lock_irqsave(&sctp_proto.local_addr_lock, flags); sctp_spin_lock_irqsave(&sctp_proto.local_addr_lock, flags);
__sctp_get_local_addr_list(&sctp_proto); __sctp_get_local_addr_list(&sctp_proto);
...@@ -193,7 +193,7 @@ static void __sctp_free_local_addr_list(struct sctp_protocol *proto) ...@@ -193,7 +193,7 @@ static void __sctp_free_local_addr_list(struct sctp_protocol *proto)
/* Free the existing local addresses. */ /* Free the existing local addresses. */
static void sctp_free_local_addr_list(struct sctp_protocol *proto) static void sctp_free_local_addr_list(struct sctp_protocol *proto)
{ {
long flags __attribute__ ((unused)); unsigned long flags;
sctp_spin_lock_irqsave(&proto->local_addr_lock, flags); sctp_spin_lock_irqsave(&proto->local_addr_lock, flags);
__sctp_free_local_addr_list(proto); __sctp_free_local_addr_list(proto);
...@@ -208,7 +208,7 @@ int sctp_copy_local_addr_list(struct sctp_protocol *proto, ...@@ -208,7 +208,7 @@ int sctp_copy_local_addr_list(struct sctp_protocol *proto,
struct sockaddr_storage_list *addr; struct sockaddr_storage_list *addr;
int error = 0; int error = 0;
struct list_head *pos; struct list_head *pos;
long flags __attribute__ ((unused)); unsigned long flags;
sctp_spin_lock_irqsave(&proto->local_addr_lock, flags); sctp_spin_lock_irqsave(&proto->local_addr_lock, flags);
list_for_each(pos, &proto->local_addr_list) { list_for_each(pos, &proto->local_addr_list) {
...@@ -233,7 +233,6 @@ int sctp_copy_local_addr_list(struct sctp_protocol *proto, ...@@ -233,7 +233,6 @@ int sctp_copy_local_addr_list(struct sctp_protocol *proto,
end_copy: end_copy:
sctp_spin_unlock_irqrestore(&proto->local_addr_lock, flags); sctp_spin_unlock_irqrestore(&proto->local_addr_lock, flags);
return error; return error;
} }
...@@ -383,7 +382,7 @@ static sctp_scope_t sctp_v4_scope(union sctp_addr *addr) ...@@ -383,7 +382,7 @@ static sctp_scope_t sctp_v4_scope(union sctp_addr *addr)
* addresses. If an association is passed, trys to get a dst entry with a * addresses. If an association is passed, trys to get a dst entry with a
* source adddress that matches an address in the bind address list. * source adddress that matches an address in the bind address list.
*/ */
struct dst_entry *sctp_v4_get_dst(sctp_association_t *asoc, struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc,
union sctp_addr *daddr, union sctp_addr *daddr,
union sctp_addr *saddr) union sctp_addr *saddr)
{ {
...@@ -480,6 +479,12 @@ void sctp_v4_get_saddr(sctp_association_t *asoc, ...@@ -480,6 +479,12 @@ void sctp_v4_get_saddr(sctp_association_t *asoc,
} }
/* What interface did this skb arrive on? */
int sctp_v4_skb_iif(const struct sk_buff *skb)
{
return ((struct rtable *)skb->dst)->rt_iif;
}
/* Create and initialize a new sk for the socket returned by accept(). */ /* Create and initialize a new sk for the socket returned by accept(). */
struct sock *sctp_v4_create_accept_sk(struct sock *sk, struct sock *sctp_v4_create_accept_sk(struct sock *sk,
struct sctp_association *asoc) struct sctp_association *asoc)
...@@ -538,10 +543,10 @@ struct sock *sctp_v4_create_accept_sk(struct sock *sk, ...@@ -538,10 +543,10 @@ struct sock *sctp_v4_create_accept_sk(struct sock *sk,
/* Event handler for inet address addition/deletion events. /* Event handler for inet address addition/deletion events.
* Basically, whenever there is an event, we re-build our local address list. * Basically, whenever there is an event, we re-build our local address list.
*/ */
static int sctp_inetaddr_event(struct notifier_block *this, unsigned long event, static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
void *ptr) void *ptr)
{ {
long flags __attribute__ ((unused)); unsigned long flags;
sctp_spin_lock_irqsave(&sctp_proto.local_addr_lock, flags); sctp_spin_lock_irqsave(&sctp_proto.local_addr_lock, flags);
__sctp_free_local_addr_list(&sctp_proto); __sctp_free_local_addr_list(&sctp_proto);
...@@ -689,6 +694,14 @@ static int sctp_inet_bind_verify(struct sctp_opt *opt, union sctp_addr *addr) ...@@ -689,6 +694,14 @@ static int sctp_inet_bind_verify(struct sctp_opt *opt, union sctp_addr *addr)
return sctp_v4_available(addr); return sctp_v4_available(addr);
} }
/* Verify that sockaddr looks sendable. Common verification has already
* been taken care of.
*/
static int sctp_inet_send_verify(struct sctp_opt *opt, union sctp_addr *addr)
{
return 1;
}
/* Fill in Supported Address Type information for INIT and INIT-ACK /* Fill in Supported Address Type information for INIT and INIT-ACK
* chunks. Returns number of addresses supported. * chunks. Returns number of addresses supported.
*/ */
...@@ -721,6 +734,7 @@ static struct sctp_pf sctp_pf_inet = { ...@@ -721,6 +734,7 @@ static struct sctp_pf sctp_pf_inet = {
.af_supported = sctp_inet_af_supported, .af_supported = sctp_inet_af_supported,
.cmp_addr = sctp_inet_cmp_addr, .cmp_addr = sctp_inet_cmp_addr,
.bind_verify = sctp_inet_bind_verify, .bind_verify = sctp_inet_bind_verify,
.send_verify = sctp_inet_send_verify,
.supported_addrs = sctp_inet_supported_addrs, .supported_addrs = sctp_inet_supported_addrs,
.create_accept_sk = sctp_v4_create_accept_sk, .create_accept_sk = sctp_v4_create_accept_sk,
.af = &sctp_ipv4_specific, .af = &sctp_ipv4_specific,
...@@ -797,6 +811,7 @@ struct sctp_af sctp_ipv4_specific = { ...@@ -797,6 +811,7 @@ struct sctp_af sctp_ipv4_specific = {
.is_any = sctp_v4_is_any, .is_any = sctp_v4_is_any,
.available = sctp_v4_available, .available = sctp_v4_available,
.scope = sctp_v4_scope, .scope = sctp_v4_scope,
.skb_iif = sctp_v4_skb_iif,
.net_header_len = sizeof(struct iphdr), .net_header_len = sizeof(struct iphdr),
.sockaddr_len = sizeof(struct sockaddr_in), .sockaddr_len = sizeof(struct sockaddr_in),
.sa_family = AF_INET, .sa_family = AF_INET,
...@@ -874,6 +889,10 @@ __init int sctp_init(void) ...@@ -874,6 +889,10 @@ __init int sctp_init(void)
int i; int i;
int status = 0; int status = 0;
/* SCTP_DEBUG sanity check. */
if (!sctp_sanity_check())
return -EINVAL;
/* Add SCTP to inet_protos hash table. */ /* Add SCTP to inet_protos hash table. */
if (inet_add_protocol(&sctp_protocol, IPPROTO_SCTP) < 0) if (inet_add_protocol(&sctp_protocol, IPPROTO_SCTP) < 0)
return -EAGAIN; return -EAGAIN;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -244,9 +244,6 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len) ...@@ -244,9 +244,6 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
if (!snum) if (!snum)
snum = inet_sk(sk)->num; snum = inet_sk(sk)->num;
/* Add the address to the bind address list. */ /* Add the address to the bind address list. */
sctp_local_bh_disable(); sctp_local_bh_disable();
sctp_write_lock(&ep->base.addr_lock); sctp_write_lock(&ep->base.addr_lock);
...@@ -257,7 +254,6 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len) ...@@ -257,7 +254,6 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
addr->v4.sin_port = htons(addr->v4.sin_port); addr->v4.sin_port = htons(addr->v4.sin_port);
if (!ret && !bp->port) if (!ret && !bp->port)
bp->port = snum; bp->port = snum;
sctp_write_unlock(&ep->base.addr_lock); sctp_write_unlock(&ep->base.addr_lock);
sctp_local_bh_enable(); sctp_local_bh_enable();
...@@ -2750,6 +2746,9 @@ int sctp_inet_listen(struct socket *sock, int backlog) ...@@ -2750,6 +2746,9 @@ int sctp_inet_listen(struct socket *sock, int backlog)
err = -EINVAL; err = -EINVAL;
if (sock->state != SS_UNCONNECTED) if (sock->state != SS_UNCONNECTED)
goto out; goto out;
if (unlikely(backlog < 0))
goto out;
switch (sock->type) { switch (sock->type) {
case SOCK_SEQPACKET: case SOCK_SEQPACKET:
err = sctp_seqpacket_listen(sk, backlog); err = sctp_seqpacket_listen(sk, backlog);
...@@ -3152,7 +3151,10 @@ static inline int sctp_verify_addr(struct sock *sk, union sctp_addr *addr, ...@@ -3152,7 +3151,10 @@ static inline int sctp_verify_addr(struct sock *sk, union sctp_addr *addr,
return -EINVAL; return -EINVAL;
/* Is this a valid SCTP address? */ /* Is this a valid SCTP address? */
if (!af->addr_valid((union sctp_addr *)addr)) if (!af->addr_valid(addr))
return -EINVAL;
if (!sctp_sk(sk)->pf->send_verify(sctp_sk(sk), (addr)))
return -EINVAL; return -EINVAL;
return 0; return 0;
......
...@@ -628,6 +628,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(sctp_association_t *asoc, ...@@ -628,6 +628,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(sctp_association_t *asoc,
if (!event) if (!event)
goto fail_init; goto fail_init;
event->iif = sctp_chunk_iif(chunk);
/* Note: Not clearing the entire event struct as /* Note: Not clearing the entire event struct as
* this is just a fragment of the real event. However, * this is just a fragment of the real event. However,
* we still need to do rwnd accounting. * we still need to do rwnd accounting.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment