Commit 3f4f4e5c authored by Doug Ledford's avatar Doug Ledford

Merge aladin.rdu.redhat.com:/usr/local/home/dledford/bk/linus-2.5

into aladin.rdu.redhat.com:/usr/src/2.5
parents e05290c8 2c0889e4
...@@ -66,7 +66,9 @@ OLDESP = 0x34 ...@@ -66,7 +66,9 @@ OLDESP = 0x34
OLDSS = 0x38 OLDSS = 0x38
CF_MASK = 0x00000001 CF_MASK = 0x00000001
TF_MASK = 0x00000100
IF_MASK = 0x00000200 IF_MASK = 0x00000200
DF_MASK = 0x00000400
NT_MASK = 0x00004000 NT_MASK = 0x00004000
VM_MASK = 0x00020000 VM_MASK = 0x00020000
...@@ -134,6 +136,17 @@ ENTRY(lcall7) ...@@ -134,6 +136,17 @@ ENTRY(lcall7)
movl %eax,EFLAGS(%esp) # movl %eax,EFLAGS(%esp) #
movl %edx,EIP(%esp) # Now we move them to their "normal" places movl %edx,EIP(%esp) # Now we move them to their "normal" places
movl %ecx,CS(%esp) # movl %ecx,CS(%esp) #
#
# Call gates don't clear TF and NT in eflags like
# traps do, so we need to do it ourselves.
# %eax already contains eflags (but it may have
# DF set, clear that also)
#
andl $~(DF_MASK | TF_MASK | NT_MASK),%eax
pushl %eax
popfl
movl %esp, %ebx movl %esp, %ebx
pushl %ebx pushl %ebx
andl $-8192, %ebx # GET_THREAD_INFO andl $-8192, %ebx # GET_THREAD_INFO
...@@ -156,6 +169,17 @@ ENTRY(lcall27) ...@@ -156,6 +169,17 @@ ENTRY(lcall27)
movl %eax,EFLAGS(%esp) # movl %eax,EFLAGS(%esp) #
movl %edx,EIP(%esp) # Now we move them to their "normal" places movl %edx,EIP(%esp) # Now we move them to their "normal" places
movl %ecx,CS(%esp) # movl %ecx,CS(%esp) #
#
# Call gates don't clear TF and NT in eflags like
# traps do, so we need to do it ourselves.
# %eax already contains eflags (but it may have
# DF set, clear that also)
#
andl $~(DF_MASK | TF_MASK | NT_MASK),%eax
pushl %eax
popfl
movl %esp, %ebx movl %esp, %ebx
pushl %ebx pushl %ebx
andl $-8192, %ebx # GET_THREAD_INFO andl $-8192, %ebx # GET_THREAD_INFO
......
...@@ -90,7 +90,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, ...@@ -90,7 +90,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
me->name, strtab + sym->st_name); me->name, strtab + sym->st_name);
return -ENOENT; return -ENOENT;
} }
v += rel->r_addend; v += rel[i].r_addend;
switch (ELF32_R_TYPE(rel[i].r_info)) { switch (ELF32_R_TYPE(rel[i].r_info)) {
case R_SPARC_32: case R_SPARC_32:
...@@ -126,7 +126,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, ...@@ -126,7 +126,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
me->name, me->name,
(int) (ELF32_R_TYPE(rel[i].r_info) & 0xff)); (int) (ELF32_R_TYPE(rel[i].r_info) & 0xff));
return -ENOEXEC; return -ENOEXEC;
} };
} }
return 0; return 0;
} }
......
...@@ -10,6 +10,113 @@ ...@@ -10,6 +10,113 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
static struct vm_struct * modvmlist = NULL;
static void module_unmap(void * addr)
{
struct vm_struct **p, *tmp;
int i;
if (!addr)
return;
if ((PAGE_SIZE-1) & (unsigned long) addr) {
printk("Trying to unmap module with bad address (%p)\n", addr);
return;
}
for (p = &modvmlist ; (tmp = *p) ; p = &tmp->next) {
if (tmp->addr == addr) {
*p = tmp->next;
goto found;
}
}
printk("Trying to unmap nonexistent module vm area (%p)\n", addr);
return;
found:
unmap_vm_area(tmp);
for (i = 0; i < tmp->nr_pages; i++) {
if (unlikely(!tmp->pages[i]))
BUG();
__free_page(tmp->pages[i]);
}
kfree(tmp->pages);
kfree(tmp);
}
static void *module_map(unsigned long size)
{
struct vm_struct **p, *tmp, *area;
struct page **pages;
void * addr;
unsigned int nr_pages, array_size, i;
size = PAGE_ALIGN(size);
if (!size || size > MODULES_LEN)
return NULL;
addr = (void *) MODULES_VADDR;
for (p = &modvmlist; (tmp = *p) ; p = &tmp->next) {
if (size + (unsigned long) addr < (unsigned long) tmp->addr)
break;
addr = (void *) (tmp->size + (unsigned long) tmp->addr);
}
if ((unsigned long) addr + size >= MODULES_END)
return NULL;
area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL);
if (!area)
return NULL;
area->size = size + PAGE_SIZE;
area->addr = addr;
area->next = *p;
area->pages = NULL;
area->nr_pages = 0;
area->phys_addr = 0;
*p = area;
nr_pages = size >> PAGE_SHIFT;
array_size = (nr_pages * sizeof(struct page *));
area->nr_pages = nr_pages;
area->pages = pages = kmalloc(array_size, GFP_KERNEL);
if (!area->pages)
goto fail;
memset(area->pages, 0, array_size);
for (i = 0; i < area->nr_pages; i++) {
area->pages[i] = alloc_page(GFP_KERNEL);
if (unlikely(!area->pages[i]))
goto fail;
}
if (map_vm_area(area, PAGE_KERNEL, &pages)) {
unmap_vm_area(area);
goto fail;
}
return area->addr;
fail:
if (area->pages) {
for (i = 0; i < area->nr_pages; i++) {
if (area->pages[i])
__free_page(area->pages[i]);
}
kfree(area->pages);
}
kfree(area);
return NULL;
}
static void *alloc_and_zero(unsigned long size) static void *alloc_and_zero(unsigned long size)
{ {
...@@ -19,7 +126,7 @@ static void *alloc_and_zero(unsigned long size) ...@@ -19,7 +126,7 @@ static void *alloc_and_zero(unsigned long size)
if (size == 0) if (size == 0)
return NULL; return NULL;
ret = vmalloc(size); ret = module_map(size);
if (!ret) if (!ret)
ret = ERR_PTR(-ENOMEM); ret = ERR_PTR(-ENOMEM);
else else
...@@ -31,7 +138,7 @@ static void *alloc_and_zero(unsigned long size) ...@@ -31,7 +138,7 @@ static void *alloc_and_zero(unsigned long size)
/* Free memory returned from module_core_alloc/module_init_alloc */ /* Free memory returned from module_core_alloc/module_init_alloc */
void module_free(struct module *mod, void *module_region) void module_free(struct module *mod, void *module_region)
{ {
vfree(module_region); module_unmap(module_region);
/* FIXME: If module_region == mod->init_region, trim exception /* FIXME: If module_region == mod->init_region, trim exception
table entries. */ table entries. */
} }
...@@ -82,6 +189,9 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, ...@@ -82,6 +189,9 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
location = (u8 *)sechdrs[sechdrs[relsec].sh_info].sh_offset location = (u8 *)sechdrs[sechdrs[relsec].sh_info].sh_offset
+ rel[i].r_offset; + rel[i].r_offset;
loc32 = (u32 *) location; loc32 = (u32 *) location;
BUG_ON(((u64)location >> (u64)32) != (u64)0);
/* This is the symbol it is referring to */ /* This is the symbol it is referring to */
sym = (Elf64_Sym *)sechdrs[symindex].sh_offset sym = (Elf64_Sym *)sechdrs[symindex].sh_offset
+ ELF64_R_SYM(rel[i].r_info); + ELF64_R_SYM(rel[i].r_info);
...@@ -90,7 +200,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, ...@@ -90,7 +200,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
me->name, strtab + sym->st_name); me->name, strtab + sym->st_name);
return -ENOENT; return -ENOENT;
} }
v += rel->r_addend; v += rel[i].r_addend;
switch (ELF64_R_TYPE(rel[i].r_info) & 0xff) { switch (ELF64_R_TYPE(rel[i].r_info) & 0xff) {
case R_SPARC_64: case R_SPARC_64:
...@@ -137,7 +247,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, ...@@ -137,7 +247,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
me->name, me->name,
(int) (ELF64_R_TYPE(rel[i].r_info) & 0xff)); (int) (ELF64_R_TYPE(rel[i].r_info) & 0xff));
return -ENOEXEC; return -ENOEXEC;
} };
} }
return 0; return 0;
} }
......
...@@ -3113,24 +3113,18 @@ asmlinkage int sparc32_execve(struct pt_regs *regs) ...@@ -3113,24 +3113,18 @@ asmlinkage int sparc32_execve(struct pt_regs *regs)
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
extern asmlinkage long sys_init_module(const char *name_user, extern asmlinkage long sys_init_module(void *, unsigned long, const char *);
struct module *mod_user);
/* Hey, when you're trying to init module, take time and prepare us a nice asmlinkage int sys32_init_module(void *umod, u32 len, const char *uargs)
* 64bit module structure, even if from 32bit modutils... Why to pollute
* kernel... :))
*/
asmlinkage int sys32_init_module(const char *name_user,
struct module *mod_user)
{ {
return sys_init_module(name_user, mod_user); return sys_init_module(umod, len, uargs);
} }
extern asmlinkage long sys_delete_module(const char *name_user); extern asmlinkage long sys_delete_module(const char *, unsigned int);
asmlinkage int sys32_delete_module(const char *name_user) asmlinkage int sys32_delete_module(const char *name_user, unsigned int flags)
{ {
return sys_delete_module(name_user); return sys_delete_module(name_user, flags);
} }
#else /* CONFIG_MODULES */ #else /* CONFIG_MODULES */
......
...@@ -263,8 +263,7 @@ static int c_show(struct seq_file *m, void *p) ...@@ -263,8 +263,7 @@ static int c_show(struct seq_file *m, void *p)
struct crypto_alg *alg = (struct crypto_alg *)p; struct crypto_alg *alg = (struct crypto_alg *)p;
seq_printf(m, "name : %s\n", alg->cra_name); seq_printf(m, "name : %s\n", alg->cra_name);
seq_printf(m, "module : %s\n", alg->cra_module ? seq_printf(m, "module : %s\n", module_name(alg->cra_module));
alg->cra_module->name : "[static]");
seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
......
...@@ -70,6 +70,7 @@ struct in_addr { ...@@ -70,6 +70,7 @@ struct in_addr {
#define IP_MTU 14 #define IP_MTU 14
#define IP_FREEBIND 15 #define IP_FREEBIND 15
#define IP_IPSEC_POLICY 16 #define IP_IPSEC_POLICY 16
#define IP_XFRM_POLICY 17
/* BSD compatibility */ /* BSD compatibility */
#define IP_RECVRETOPTS IP_RETOPTS #define IP_RECVRETOPTS IP_RETOPTS
......
...@@ -242,6 +242,13 @@ static inline void module_put(struct module *module) ...@@ -242,6 +242,13 @@ static inline void module_put(struct module *module)
#endif /* CONFIG_MODULE_UNLOAD */ #endif /* CONFIG_MODULE_UNLOAD */
/* This is a #define so the string doesn't get put in every .o file */
#define module_name(mod) \
({ \
struct module *__mod = (mod); \
__mod ? __mod->name : "kernel"; \
})
#define __unsafe(mod) \ #define __unsafe(mod) \
do { \ do { \
if (mod && !(mod)->unsafe) { \ if (mod && !(mod)->unsafe) { \
...@@ -265,6 +272,8 @@ do { \ ...@@ -265,6 +272,8 @@ do { \
#define try_module_get(module) 1 #define try_module_get(module) 1
#define module_put(module) do { } while(0) #define module_put(module) do { } while(0)
#define module_name(mod) "kernel"
#define __unsafe(mod) #define __unsafe(mod)
#endif /* CONFIG_MODULES */ #endif /* CONFIG_MODULES */
......
...@@ -57,7 +57,4 @@ struct udp_sock { ...@@ -57,7 +57,4 @@ struct udp_sock {
#define udp_sk(__sk) (&((struct udp_sock *)__sk)->udp) #define udp_sk(__sk) (&((struct udp_sock *)__sk)->udp)
extern int udp_proc_init(void);
extern void udp_proc_exit(void);
#endif /* _LINUX_UDP_H */ #endif /* _LINUX_UDP_H */
...@@ -91,6 +91,22 @@ struct xfrm_stats { ...@@ -91,6 +91,22 @@ struct xfrm_stats {
__u32 integrity_failed; __u32 integrity_failed;
}; };
enum
{
XFRM_POLICY_IN = 0,
XFRM_POLICY_OUT = 1,
XFRM_POLICY_FWD = 2,
XFRM_POLICY_MAX = 3
};
enum
{
XFRM_SHARE_ANY, /* No limitations */
XFRM_SHARE_SESSION, /* For this session only */
XFRM_SHARE_USER, /* For this user only */
XFRM_SHARE_UNIQUE /* Use once */
};
/* Netlink configuration messages. */ /* Netlink configuration messages. */
#define XFRM_MSG_BASE 0x10 #define XFRM_MSG_BASE 0x10
...@@ -104,8 +120,9 @@ struct xfrm_stats { ...@@ -104,8 +120,9 @@ struct xfrm_stats {
#define XFRM_MSG_ALLOCSPI (RTM_BASE + 6) #define XFRM_MSG_ALLOCSPI (RTM_BASE + 6)
#define XFRM_MSG_ACQUIRE (RTM_BASE + 7) #define XFRM_MSG_ACQUIRE (RTM_BASE + 7)
#define XFRM_MSG_EXPIRE (RTM_BASE + 8)
#define XFRM_MSG_MAX (XFRM_MSG_ACQUIRE+1) #define XFRM_MSG_MAX (XFRM_MSG_EXPIRE+1)
struct xfrm_user_tmpl { struct xfrm_user_tmpl {
struct xfrm_id id; struct xfrm_id id;
...@@ -113,6 +130,7 @@ struct xfrm_user_tmpl { ...@@ -113,6 +130,7 @@ struct xfrm_user_tmpl {
__u16 reqid; __u16 reqid;
__u8 mode; __u8 mode;
__u8 share; __u8 share;
__u8 optional;
__u32 aalgos; __u32 aalgos;
__u32 ealgos; __u32 ealgos;
__u32 calgos; __u32 calgos;
...@@ -135,9 +153,9 @@ struct xfrm_usersa_info { ...@@ -135,9 +153,9 @@ struct xfrm_usersa_info {
struct xfrm_lifetime_cfg lft; struct xfrm_lifetime_cfg lft;
struct xfrm_lifetime_cur curlft; struct xfrm_lifetime_cur curlft;
struct xfrm_stats stats; struct xfrm_stats stats;
__u32 seq;
__u16 family; __u16 family;
__u16 reqid; __u16 reqid;
__u8 sa_type;
__u8 mode; /* 0=transport,1=tunnel */ __u8 mode; /* 0=transport,1=tunnel */
__u8 replay_window; __u8 replay_window;
}; };
...@@ -148,15 +166,26 @@ struct xfrm_usersa_id { ...@@ -148,15 +166,26 @@ struct xfrm_usersa_id {
__u8 proto; __u8 proto;
}; };
struct xfrm_userspi_info {
struct xfrm_usersa_info info;
u32 min;
u32 max;
};
struct xfrm_userpolicy_info { struct xfrm_userpolicy_info {
struct xfrm_selector sel; struct xfrm_selector sel;
struct xfrm_id id;
struct xfrm_lifetime_cfg lft; struct xfrm_lifetime_cfg lft;
struct xfrm_lifetime_cur curlft; struct xfrm_lifetime_cur curlft;
__u32 priority;
__u32 index; __u32 index;
__u16 family; __u16 family;
__u8 dir; __u8 dir;
__u8 action; __u8 action;
#define XFRM_POLICY_ALLOW 0
#define XFRM_POLICY_BLOCK 1
__u8 flags;
#define XFRM_POLICY_LOCALOK 1 /* Allow user to override global policy */
__u8 share;
}; };
struct xfrm_userpolicy_id { struct xfrm_userpolicy_id {
...@@ -165,4 +194,22 @@ struct xfrm_userpolicy_id { ...@@ -165,4 +194,22 @@ struct xfrm_userpolicy_id {
__u8 dir; __u8 dir;
}; };
struct xfrm_user_acquire {
struct xfrm_id id;
xfrm_address_t saddr;
struct xfrm_userpolicy_info policy;
__u32 aalgos;
__u32 ealgos;
__u32 calgos;
__u32 seq;
};
struct xfrm_user_expire {
struct xfrm_usersa_info state;
__u8 hard;
};
#define XFRMGRP_ACQUIRE 1
#define XFRMGRP_EXPIRE 2
#endif /* _LINUX_XFRM_H */ #endif /* _LINUX_XFRM_H */
...@@ -276,7 +276,4 @@ static inline void fib_res_put(struct fib_result *res) ...@@ -276,7 +276,4 @@ static inline void fib_res_put(struct fib_result *res)
#endif #endif
} }
extern int fib_proc_init(void);
extern void fib_proc_exit(void);
#endif /* _NET_FIB_H */ #endif /* _NET_FIB_H */
...@@ -76,6 +76,4 @@ extern struct udp_mib udp_statistics[NR_CPUS*2]; ...@@ -76,6 +76,4 @@ extern struct udp_mib udp_statistics[NR_CPUS*2];
#define UDP_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_statistics, field) #define UDP_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_statistics, field)
#define UDP_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_statistics, field) #define UDP_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_statistics, field)
extern int udp_proc_init(void);
#endif /* _UDP_H */ #endif /* _UDP_H */
...@@ -96,6 +96,7 @@ struct xfrm_state ...@@ -96,6 +96,7 @@ struct xfrm_state
u8 replay_window; u8 replay_window;
u8 aalgo, ealgo, calgo; u8 aalgo, ealgo, calgo;
u16 reqid; u16 reqid;
u16 family;
xfrm_address_t saddr; xfrm_address_t saddr;
int header_len; int header_len;
int trailer_len; int trailer_len;
...@@ -187,22 +188,6 @@ struct xfrm_tmpl ...@@ -187,22 +188,6 @@ struct xfrm_tmpl
#define XFRM_MAX_DEPTH 3 #define XFRM_MAX_DEPTH 3
enum
{
XFRM_SHARE_ANY, /* No limitations */
XFRM_SHARE_SESSION, /* For this session only */
XFRM_SHARE_USER, /* For this user only */
XFRM_SHARE_UNIQUE /* Use once */
};
enum
{
XFRM_POLICY_IN = 0,
XFRM_POLICY_OUT = 1,
XFRM_POLICY_FWD = 2,
XFRM_POLICY_MAX = 3
};
struct xfrm_policy struct xfrm_policy
{ {
struct xfrm_policy *next; struct xfrm_policy *next;
...@@ -217,11 +202,9 @@ struct xfrm_policy ...@@ -217,11 +202,9 @@ struct xfrm_policy
struct xfrm_lifetime_cfg lft; struct xfrm_lifetime_cfg lft;
struct xfrm_lifetime_cur curlft; struct xfrm_lifetime_cur curlft;
struct dst_entry *bundles; struct dst_entry *bundles;
__u16 family;
__u8 action; __u8 action;
#define XFRM_POLICY_ALLOW 0
#define XFRM_POLICY_BLOCK 1
__u8 flags; __u8 flags;
#define XFRM_POLICY_LOCALOK 1 /* Allow user to override global policy */
__u8 dead; __u8 dead;
__u8 xfrm_nr; __u8 xfrm_nr;
struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH];
...@@ -390,7 +373,7 @@ struct xfrm_policy *xfrm_policy_delete(int dir, struct xfrm_selector *sel); ...@@ -390,7 +373,7 @@ struct xfrm_policy *xfrm_policy_delete(int dir, struct xfrm_selector *sel);
struct xfrm_policy *xfrm_policy_byid(int dir, u32 id, int delete); struct xfrm_policy *xfrm_policy_byid(int dir, u32 id, int delete);
void xfrm_policy_flush(void); void xfrm_policy_flush(void);
void xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi); void xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi);
struct xfrm_state * xfrm_find_acq(u8 mode, u16 reqid, u8 proto, u32 daddr, u32 saddr); struct xfrm_state * xfrm_find_acq(u8 mode, u16 reqid, u8 proto, u32 daddr, u32 saddr, int create);
extern void xfrm_policy_flush(void); extern void xfrm_policy_flush(void);
extern void xfrm_policy_kill(struct xfrm_policy *); extern void xfrm_policy_kill(struct xfrm_policy *);
extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol);
......
...@@ -210,13 +210,8 @@ get_exec_domain_list(char *page) ...@@ -210,13 +210,8 @@ get_exec_domain_list(char *page)
read_lock(&exec_domains_lock); read_lock(&exec_domains_lock);
for (ep = exec_domains; ep && len < PAGE_SIZE - 80; ep = ep->next) for (ep = exec_domains; ep && len < PAGE_SIZE - 80; ep = ep->next)
len += sprintf(page + len, "%d-%d\t%-16s\t[%s]\n", len += sprintf(page + len, "%d-%d\t%-16s\t[%s]\n",
ep->pers_low, ep->pers_high, ep->name, ep->pers_low, ep->pers_high, ep->name,
#ifdef CONFIG_MODULES module_name(ep->module));
ep->module ? ep->module->name : "kernel"
#else
"kernel"
#endif
);
read_unlock(&exec_domains_lock); read_unlock(&exec_domains_lock);
return (len); return (len);
} }
......
...@@ -541,10 +541,10 @@ static int rif_get_info(char *buffer,char **start, off_t offset, int length) ...@@ -541,10 +541,10 @@ static int rif_get_info(char *buffer,char **start, off_t offset, int length)
static int __init rif_init(void) static int __init rif_init(void)
{ {
init_timer(&rif_timer);
rif_timer.expires = RIF_TIMEOUT; rif_timer.expires = RIF_TIMEOUT;
rif_timer.data = 0L; rif_timer.data = 0L;
rif_timer.function = rif_check_expire; rif_timer.function = rif_check_expire;
init_timer(&rif_timer);
add_timer(&rif_timer); add_timer(&rif_timer);
proc_net_create("tr_rif",0,rif_get_info); proc_net_create("tr_rif",0,rif_get_info);
......
...@@ -104,7 +104,7 @@ extern void mpc_proc_clean(void); ...@@ -104,7 +104,7 @@ extern void mpc_proc_clean(void);
struct mpoa_client *mpcs = NULL; /* FIXME */ struct mpoa_client *mpcs = NULL; /* FIXME */
static struct atm_mpoa_qos *qos_head = NULL; static struct atm_mpoa_qos *qos_head = NULL;
static struct timer_list mpc_timer; static struct timer_list mpc_timer = TIMER_INITIALIZER(NULL, 0, 0);
static struct mpoa_client *find_mpc_by_itfnum(int itf) static struct mpoa_client *find_mpc_by_itfnum(int itf)
......
...@@ -1151,8 +1151,8 @@ void neigh_table_init(struct neigh_table *tbl) ...@@ -1151,8 +1151,8 @@ void neigh_table_init(struct neigh_table *tbl)
tasklet_init(&tbl->gc_task, SMP_TIMER_NAME(neigh_periodic_timer), tasklet_init(&tbl->gc_task, SMP_TIMER_NAME(neigh_periodic_timer),
(unsigned long)tbl); (unsigned long)tbl);
#endif #endif
init_timer(&tbl->gc_timer);
tbl->lock = RW_LOCK_UNLOCKED; tbl->lock = RW_LOCK_UNLOCKED;
init_timer(&tbl->gc_timer);
tbl->gc_timer.data = (unsigned long)tbl; tbl->gc_timer.data = (unsigned long)tbl;
tbl->gc_timer.function = neigh_periodic_timer; tbl->gc_timer.function = neigh_periodic_timer;
tbl->gc_timer.expires = now + tbl->gc_interval + tbl->gc_timer.expires = now + tbl->gc_interval +
......
...@@ -362,5 +362,13 @@ config INET_ESP ...@@ -362,5 +362,13 @@ config INET_ESP
If unsure, say Y. If unsure, say Y.
config XFRM_USER
tristate "IP: IPsec user configuration interface"
---help---
Support for IPsec user configuration interface used
by native Linux tools.
If unsure, say Y.
source "net/ipv4/netfilter/Kconfig" source "net/ipv4/netfilter/Kconfig"
...@@ -20,6 +20,7 @@ obj-$(CONFIG_INET_AH) += ah.o ...@@ -20,6 +20,7 @@ obj-$(CONFIG_INET_AH) += ah.o
obj-$(CONFIG_INET_ESP) += esp.o obj-$(CONFIG_INET_ESP) += esp.o
obj-$(CONFIG_IP_PNP) += ipconfig.o obj-$(CONFIG_IP_PNP) += ipconfig.o
obj-$(CONFIG_NETFILTER) += netfilter/ obj-$(CONFIG_NETFILTER) += netfilter/
obj-$(CONFIG_XFRM_USER) += xfrm_user.o
obj-y += xfrm_policy.o xfrm_state.o xfrm_input.o obj-y += xfrm_policy.o xfrm_state.o xfrm_input.o
......
...@@ -1160,16 +1160,20 @@ module_init(inet_init); ...@@ -1160,16 +1160,20 @@ module_init(inet_init);
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
extern int fib_proc_init(void);
extern int ip_misc_proc_init(void); extern void fib_proc_exit(void);
extern int raw_get_info(char *, char **, off_t, int); extern int ip_misc_proc_init(void);
extern int tcp_get_info(char *, char **, off_t, int); extern int raw_proc_init(void);
extern void raw_proc_exit(void);
extern int tcp_get_info(char *buffer, char **start, off_t offset, int length);
extern int udp_proc_init(void);
extern void udp_proc_exit(void);
int __init ipv4_proc_init(void) int __init ipv4_proc_init(void)
{ {
int rc = 0; int rc = 0;
if (!proc_net_create("raw", 0, raw_get_info)) if (raw_proc_init())
goto out_raw; goto out_raw;
if (!proc_net_create("tcp", 0, tcp_get_info)) if (!proc_net_create("tcp", 0, tcp_get_info))
goto out_tcp; goto out_tcp;
...@@ -1188,7 +1192,7 @@ int __init ipv4_proc_init(void) ...@@ -1188,7 +1192,7 @@ int __init ipv4_proc_init(void)
out_udp: out_udp:
proc_net_remove("tcp"); proc_net_remove("tcp");
out_tcp: out_tcp:
proc_net_remove("raw"); raw_proc_exit();
out_raw: out_raw:
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
......
...@@ -189,7 +189,7 @@ int ah_output(struct sk_buff *skb) ...@@ -189,7 +189,7 @@ int ah_output(struct sk_buff *skb)
top_iph->saddr = x->props.saddr.xfrm4_addr; top_iph->saddr = x->props.saddr.xfrm4_addr;
top_iph->daddr = x->id.daddr.xfrm4_addr; top_iph->daddr = x->id.daddr.xfrm4_addr;
ah = (struct ip_auth_hdr*)(top_iph+1); ah = (struct ip_auth_hdr*)(top_iph+1);
ah->nexthdr = IPPROTO_IP; ah->nexthdr = IPPROTO_IPIP;
} else { } else {
memcpy(&tmp_iph, skb->data, iph->ihl*4); memcpy(&tmp_iph, skb->data, iph->ihl*4);
top_iph = (struct iphdr*)skb_push(skb, x->props.header_len); top_iph = (struct iphdr*)skb_push(skb, x->props.header_len);
......
...@@ -190,11 +190,10 @@ esp_hmac_digest(struct esp_data *esp, struct sk_buff *skb, int offset, ...@@ -190,11 +190,10 @@ esp_hmac_digest(struct esp_data *esp, struct sk_buff *skb, int offset,
struct crypto_tfm *tfm = esp->auth.tfm; struct crypto_tfm *tfm = esp->auth.tfm;
char *digest = esp->auth.work_digest; char *digest = esp->auth.work_digest;
memset(auth_data, 0, esp->auth.authlen);
crypto_hmac_init(tfm, esp->auth.key, &esp->auth.key_len); crypto_hmac_init(tfm, esp->auth.key, &esp->auth.key_len);
skb_digest_walk(skb, tfm, offset, len); skb_digest_walk(skb, tfm, offset, len);
crypto_hmac_final(tfm, esp->auth.key, &esp->auth.key_len, digest); crypto_hmac_final(tfm, esp->auth.key, &esp->auth.key_len, digest);
memcpy(auth_data, digest, crypto_tfm_alg_digestsize(tfm)); memcpy(auth_data, digest, esp->auth.authlen);
} }
/* Check that skb data bits are writable. If they are not, copy data /* Check that skb data bits are writable. If they are not, copy data
...@@ -370,7 +369,7 @@ int esp_output(struct sk_buff *skb) ...@@ -370,7 +369,7 @@ int esp_output(struct sk_buff *skb)
if (x->props.mode) { if (x->props.mode) {
top_iph = (struct iphdr*)skb_push(skb, x->props.header_len); top_iph = (struct iphdr*)skb_push(skb, x->props.header_len);
esph = (struct ip_esp_hdr*)(top_iph+1); esph = (struct ip_esp_hdr*)(top_iph+1);
*(u8*)(trailer->tail - 1) = IPPROTO_IP; *(u8*)(trailer->tail - 1) = IPPROTO_IPIP;
top_iph->ihl = 5; top_iph->ihl = 5;
top_iph->version = 4; top_iph->version = 4;
top_iph->tos = iph->tos; /* DS disclosed */ top_iph->tos = iph->tos; /* DS disclosed */
...@@ -463,16 +462,16 @@ int esp_input(struct xfrm_state *x, struct sk_buff *skb) ...@@ -463,16 +462,16 @@ int esp_input(struct xfrm_state *x, struct sk_buff *skb)
/* If integrity check is required, do this. */ /* If integrity check is required, do this. */
if (esp->auth.authlen) { if (esp->auth.authlen) {
int icvsize = crypto_tfm_alg_digestsize(esp->auth.tfm); u8 sum[esp->auth.authlen];
u8 sum[icvsize]; u8 sum1[esp->auth.authlen];
u8 sum1[icvsize];
esp->auth.digest(esp, skb, 0, skb->len-esp->auth.authlen, sum); esp->auth.digest(esp, skb, 0, skb->len-esp->auth.authlen, sum);
if (skb_copy_bits(skb, skb->len-esp->auth.authlen, sum1, icvsize)) if (skb_copy_bits(skb, skb->len-esp->auth.authlen, sum1,
esp->auth.authlen))
BUG(); BUG();
if (unlikely(memcmp(sum, sum1, icvsize))) { if (unlikely(memcmp(sum, sum1, esp->auth.authlen))) {
x->stats.integrity_failed++; x->stats.integrity_failed++;
goto out; goto out;
} }
...@@ -605,14 +604,20 @@ int esp_init_state(struct xfrm_state *x, void *args) ...@@ -605,14 +604,20 @@ int esp_init_state(struct xfrm_state *x, void *args)
memset(esp, 0, sizeof(*esp)); memset(esp, 0, sizeof(*esp));
if (x->aalg) { if (x->aalg) {
int digestsize;
esp->auth.key = x->aalg->alg_key; esp->auth.key = x->aalg->alg_key;
esp->auth.key_len = (x->aalg->alg_key_len+7)/8; esp->auth.key_len = (x->aalg->alg_key_len+7)/8;
esp->auth.tfm = crypto_alloc_tfm(x->aalg->alg_name, 0); esp->auth.tfm = crypto_alloc_tfm(x->aalg->alg_name, 0);
if (esp->auth.tfm == NULL) if (esp->auth.tfm == NULL)
goto error; goto error;
esp->auth.digest = esp_hmac_digest; esp->auth.digest = esp_hmac_digest;
esp->auth.authlen = crypto_tfm_alg_digestsize(esp->auth.tfm); digestsize = crypto_tfm_alg_digestsize(esp->auth.tfm);
esp->auth.work_digest = kmalloc(esp->auth.authlen, GFP_KERNEL); /* XXX RFC2403 and RFC 2404 truncate auth to 96 bit */
esp->auth.authlen = 12;
if (esp->auth.authlen > digestsize) /* XXX */
BUG();
esp->auth.work_digest = kmalloc(digestsize, GFP_KERNEL);
if (!esp->auth.work_digest) if (!esp->auth.work_digest)
goto error; goto error;
} }
......
...@@ -1092,16 +1092,4 @@ void __init fib_proc_exit(void) ...@@ -1092,16 +1092,4 @@ void __init fib_proc_exit(void)
{ {
remove_proc_entry("route", proc_net); remove_proc_entry("route", proc_net);
} }
#else /* CONFIG_PROC_FS */
int __init fib_proc_init(void)
{
return 0;
}
void __init fib_proc_exit(void)
{
return 0;
}
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
...@@ -626,6 +626,7 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt ...@@ -626,6 +626,7 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt
break; break;
case IP_IPSEC_POLICY: case IP_IPSEC_POLICY:
case IP_XFRM_POLICY:
err = xfrm_user_policy(sk, optname, optval, optlen); err = xfrm_user_policy(sk, optname, optval, optlen);
break; break;
......
...@@ -361,8 +361,6 @@ helper_cmp(const struct ip_nat_helper *helper, ...@@ -361,8 +361,6 @@ helper_cmp(const struct ip_nat_helper *helper,
return ip_ct_tuple_mask_cmp(tuple, &helper->tuple, &helper->mask); return ip_ct_tuple_mask_cmp(tuple, &helper->tuple, &helper->mask);
} }
#define MODULE_MAX_NAMELEN 32
int ip_nat_helper_register(struct ip_nat_helper *me) int ip_nat_helper_register(struct ip_nat_helper *me)
{ {
int ret = 0; int ret = 0;
...@@ -374,14 +372,13 @@ int ip_nat_helper_register(struct ip_nat_helper *me) ...@@ -374,14 +372,13 @@ int ip_nat_helper_register(struct ip_nat_helper *me)
&& ct_helper->me) { && ct_helper->me) {
__MOD_INC_USE_COUNT(ct_helper->me); __MOD_INC_USE_COUNT(ct_helper->me);
} else { } else {
#ifdef CONFIG_MODULES
/* We are a NAT helper for protocol X. If we need /* We are a NAT helper for protocol X. If we need
* respective conntrack helper for protoccol X, compute * respective conntrack helper for protoccol X, compute
* conntrack helper name and try to load module */ * conntrack helper name and try to load module */
char name[MODULE_MAX_NAMELEN]; char name[MODULE_NAME_LEN];
const char *tmp = me->me->name; const char *tmp = module_name(me->me);
if (strlen(tmp) + 6 > MODULE_MAX_NAMELEN) { if (strlen(tmp) + 6 > MODULE_NAME_LEN) {
printk("%s: unable to " printk("%s: unable to "
"compute conntrack helper name " "compute conntrack helper name "
"from %s\n", __FUNCTION__, tmp); "from %s\n", __FUNCTION__, tmp);
...@@ -403,7 +400,6 @@ int ip_nat_helper_register(struct ip_nat_helper *me) ...@@ -403,7 +400,6 @@ int ip_nat_helper_register(struct ip_nat_helper *me)
"because kernel was compiled without kernel " "because kernel was compiled without kernel "
"module loader support\n", name); "module loader support\n", name);
return -EBUSY; return -EBUSY;
#endif
#endif #endif
} }
} }
......
This diff is collapsed.
...@@ -40,31 +40,42 @@ ...@@ -40,31 +40,42 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <asm/system.h> #include <asm/atomic.h>
#include <asm/byteorder.h>
#include <asm/current.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/ioctls.h> #include <asm/ioctls.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/sched.h> #include <linux/stddef.h>
#include <linux/slab.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/timer.h> #include <linux/aio.h>
#include <linux/mm.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/fcntl.h> #include <linux/spinlock.h>
#include <linux/sockios.h>
#include <linux/socket.h> #include <linux/socket.h>
#include <linux/in.h> #include <linux/in.h>
#include <linux/inet.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/mroute.h> #include <linux/in_route.h>
#include <net/tcp.h> #include <linux/route.h>
#include <net/protocol.h> #include <linux/tcp.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <net/dst.h>
#include <net/sock.h> #include <net/sock.h>
#include <linux/gfp.h>
#include <linux/ip.h>
#include <net/ip.h>
#include <net/icmp.h> #include <net/icmp.h>
#include <net/udp.h> #include <net/udp.h>
#include <net/raw.h> #include <net/raw.h>
#include <net/snmp.h>
#include <net/inet_common.h> #include <net/inet_common.h>
#include <net/checksum.h> #include <net/checksum.h>
#include <net/xfrm.h> #include <net/xfrm.h>
#include <linux/rtnetlink.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv4.h>
struct sock *raw_v4_htable[RAWV4_HTABLE_SIZE]; struct sock *raw_v4_htable[RAWV4_HTABLE_SIZE];
...@@ -656,7 +667,95 @@ static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg) ...@@ -656,7 +667,95 @@ static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg)
} }
} }
static void get_raw_sock(struct sock *sp, char *tmpbuf, int i) struct proto raw_prot = {
.name = "RAW",
.close = raw_close,
.connect = udp_connect,
.disconnect = udp_disconnect,
.ioctl = raw_ioctl,
.init = raw_init,
.setsockopt = raw_setsockopt,
.getsockopt = raw_getsockopt,
.sendmsg = raw_sendmsg,
.recvmsg = raw_recvmsg,
.bind = raw_bind,
.backlog_rcv = raw_rcv_skb,
.hash = raw_v4_hash,
.unhash = raw_v4_unhash,
};
#ifdef CONFIG_PROC_FS
struct raw_iter_state {
int bucket;
};
#define raw_seq_private(seq) ((struct raw_iter_state *)&seq->private)
static struct sock *raw_get_first(struct seq_file *seq)
{
struct sock *sk = NULL;
struct raw_iter_state* state = raw_seq_private(seq);
for (state->bucket = 0; state->bucket < RAWV4_HTABLE_SIZE; ++state->bucket) {
sk = raw_v4_htable[state->bucket];
while (sk && sk->family != PF_INET)
sk = sk->next;
if (sk)
break;
}
return sk;
}
static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk)
{
struct raw_iter_state* state = raw_seq_private(seq);
do {
sk = sk->next;
try_again:
} while (sk && sk->family != PF_INET);
if (!sk && ++state->bucket < RAWV4_HTABLE_SIZE) {
sk = raw_v4_htable[state->bucket];
goto try_again;
}
return sk;
}
static struct sock *raw_get_idx(struct seq_file *seq, loff_t pos)
{
struct sock *sk = raw_get_first(seq);
if (sk)
while (pos && (sk = raw_get_next(seq, sk)) != NULL)
--pos;
return pos ? NULL : sk;
}
static void *raw_seq_start(struct seq_file *seq, loff_t *pos)
{
read_lock(&raw_v4_lock);
return *pos ? raw_get_idx(seq, *pos) : (void *)1;
}
static void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct sock *sk;
if (v == (void *)1)
sk = raw_get_first(seq);
else
sk = raw_get_next(seq, v);
++*pos;
return sk;
}
static void raw_seq_stop(struct seq_file *seq, void *v)
{
read_unlock(&raw_v4_lock);
}
static __inline__ char *get_raw_sock(struct sock *sp, char *tmpbuf, int i)
{ {
struct inet_opt *inet = inet_sk(sp); struct inet_opt *inet = inet_sk(sp);
unsigned int dest = inet->daddr, unsigned int dest = inet->daddr,
...@@ -668,65 +767,63 @@ static void get_raw_sock(struct sock *sp, char *tmpbuf, int i) ...@@ -668,65 +767,63 @@ static void get_raw_sock(struct sock *sp, char *tmpbuf, int i)
" %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p", " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
i, src, srcp, dest, destp, sp->state, i, src, srcp, dest, destp, sp->state,
atomic_read(&sp->wmem_alloc), atomic_read(&sp->rmem_alloc), atomic_read(&sp->wmem_alloc), atomic_read(&sp->rmem_alloc),
0, 0L, 0, 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
sock_i_uid(sp), 0,
sock_i_ino(sp),
atomic_read(&sp->refcnt), sp); atomic_read(&sp->refcnt), sp);
return tmpbuf;
} }
int raw_get_info(char *buffer, char **start, off_t offset, int length) static int raw_seq_show(struct seq_file *seq, void *v)
{ {
int len = 0, num = 0, i;
off_t pos = 128;
off_t begin;
char tmpbuf[129]; char tmpbuf[129];
if (offset < 128) if (v == (void *)1)
len += sprintf(buffer, "%-127s\n", seq_printf(seq, "%-127s\n",
" sl local_address rem_address st tx_queue " " sl local_address rem_address st tx_queue "
"rx_queue tr tm->when retrnsmt uid timeout " "rx_queue tr tm->when retrnsmt uid timeout "
"inode"); "inode");
read_lock(&raw_v4_lock); else {
for (i = 0; i < RAWV4_HTABLE_SIZE; i++) { struct raw_iter_state *state = raw_seq_private(seq);
struct sock *sk;
seq_printf(seq, "%-127s\n",
for (sk = raw_v4_htable[i]; sk; sk = sk->next, num++) { get_raw_sock(v, tmpbuf, state->bucket));
if (sk->family != PF_INET)
continue;
pos += 128;
if (pos <= offset)
continue;
get_raw_sock(sk, tmpbuf, i);
len += sprintf(buffer + len, "%-127s\n", tmpbuf);
if (len >= length)
goto out;
}
} }
out: return 0;
read_unlock(&raw_v4_lock);
begin = len - (pos - offset);
*start = buffer + begin;
len -= begin;
if (len > length)
len = length;
if (len < 0)
len = 0;
return len;
} }
struct proto raw_prot = { static struct seq_operations raw_seq_ops = {
.name = "RAW", .start = raw_seq_start,
.close = raw_close, .next = raw_seq_next,
.connect = udp_connect, .stop = raw_seq_stop,
.disconnect = udp_disconnect, .show = raw_seq_show,
.ioctl = raw_ioctl, };
.init = raw_init,
.setsockopt = raw_setsockopt, static int raw_seq_open(struct inode *inode, struct file *file)
.getsockopt = raw_getsockopt, {
.sendmsg = raw_sendmsg, return seq_open(file, &raw_seq_ops);
.recvmsg = raw_recvmsg, }
.bind = raw_bind,
.backlog_rcv = raw_rcv_skb, static struct file_operations raw_seq_fops = {
.hash = raw_v4_hash, .open = raw_seq_open,
.unhash = raw_v4_unhash, .read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
}; };
int __init raw_proc_init(void)
{
struct proc_dir_entry *p;
int rc = 0;
p = create_proc_entry("raw", S_IRUGO, proc_net);
if (p)
p->proc_fops = &raw_seq_fops;
else
rc = -ENOMEM;
return rc;
}
void __init raw_proc_exit(void)
{
remove_proc_entry("raw", proc_net);
}
#endif /* CONFIG_PROC_FS */
...@@ -944,7 +944,7 @@ static int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) ...@@ -944,7 +944,7 @@ static int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
/* /*
* Charge it to the socket, dropping if the queue is full. * Charge it to the socket, dropping if the queue is full.
*/ */
if (!xfrm_policy_check(NULL, XFRM_POLICY_IN, skb)) { if (!xfrm_policy_check(sk, XFRM_POLICY_IN, skb)) {
kfree_skb(skb); kfree_skb(skb);
return -1; return -1;
} }
...@@ -1377,16 +1377,4 @@ void __init udp_proc_exit(void) ...@@ -1377,16 +1377,4 @@ void __init udp_proc_exit(void)
{ {
remove_proc_entry("udp", proc_net); remove_proc_entry("udp", proc_net);
} }
#else /* CONFIG_PROC_FS */
int __init udp_proc_init(void)
{
return 0;
}
void __init udp_proc_exit(void)
{
return 0;
}
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
...@@ -91,7 +91,7 @@ int xfrm4_rcv(struct sk_buff *skb) ...@@ -91,7 +91,7 @@ int xfrm4_rcv(struct sk_buff *skb)
iph = skb->nh.iph; iph = skb->nh.iph;
if (x->props.mode) { if (x->props.mode) {
if (iph->protocol != IPPROTO_IP) if (iph->protocol != IPPROTO_IPIP)
goto drop; goto drop;
skb->nh.raw = skb->data; skb->nh.raw = skb->data;
iph = skb->nh.iph; iph = skb->nh.iph;
......
...@@ -386,7 +386,7 @@ xfrm_state_lookup(u32 daddr, u32 spi, u8 proto) ...@@ -386,7 +386,7 @@ xfrm_state_lookup(u32 daddr, u32 spi, u8 proto)
} }
struct xfrm_state * struct xfrm_state *
xfrm_find_acq(u8 mode, u16 reqid, u8 proto, u32 daddr, u32 saddr) xfrm_find_acq(u8 mode, u16 reqid, u8 proto, u32 daddr, u32 saddr, int create)
{ {
struct xfrm_state *x, *x0; struct xfrm_state *x, *x0;
unsigned h = ntohl(daddr); unsigned h = ntohl(daddr);
...@@ -400,10 +400,11 @@ xfrm_find_acq(u8 mode, u16 reqid, u8 proto, u32 daddr, u32 saddr) ...@@ -400,10 +400,11 @@ xfrm_find_acq(u8 mode, u16 reqid, u8 proto, u32 daddr, u32 saddr)
mode == x->props.mode && mode == x->props.mode &&
proto == x->id.proto && proto == x->id.proto &&
saddr == x->props.saddr.xfrm4_addr && saddr == x->props.saddr.xfrm4_addr &&
reqid == x->props.reqid) { reqid == x->props.reqid &&
x->km.state == XFRM_STATE_ACQ) {
if (!x0) if (!x0)
x0 = x; x0 = x;
if (x->km.state != XFRM_STATE_ACQ) if (x->id.spi)
continue; continue;
x0 = x; x0 = x;
break; break;
...@@ -411,7 +412,7 @@ xfrm_find_acq(u8 mode, u16 reqid, u8 proto, u32 daddr, u32 saddr) ...@@ -411,7 +412,7 @@ xfrm_find_acq(u8 mode, u16 reqid, u8 proto, u32 daddr, u32 saddr)
} }
if (x0) { if (x0) {
atomic_inc(&x0->refcnt); atomic_inc(&x0->refcnt);
} else if ((x0 = xfrm_state_alloc()) != NULL) { } else if (create && (x0 = xfrm_state_alloc()) != NULL) {
x0->sel.daddr.xfrm4_addr = daddr; x0->sel.daddr.xfrm4_addr = daddr;
x0->sel.daddr.xfrm4_mask = ~0; x0->sel.daddr.xfrm4_mask = ~0;
x0->sel.saddr.xfrm4_addr = saddr; x0->sel.saddr.xfrm4_addr = saddr;
......
This diff is collapsed.
...@@ -296,6 +296,7 @@ int ipv6_dev_mc_inc(struct net_device *dev, struct in6_addr *addr) ...@@ -296,6 +296,7 @@ int ipv6_dev_mc_inc(struct net_device *dev, struct in6_addr *addr)
} }
memset(mc, 0, sizeof(struct ifmcaddr6)); memset(mc, 0, sizeof(struct ifmcaddr6));
init_timer(&mc->mca_timer);
mc->mca_timer.function = igmp6_timer_handler; mc->mca_timer.function = igmp6_timer_handler;
mc->mca_timer.data = (unsigned long) mc; mc->mca_timer.data = (unsigned long) mc;
......
...@@ -2364,6 +2364,7 @@ static int irda_getsockopt(struct socket *sock, int level, int optname, ...@@ -2364,6 +2364,7 @@ static int irda_getsockopt(struct socket *sock, int level, int optname,
/* Set watchdog timer to expire in <val> ms. */ /* Set watchdog timer to expire in <val> ms. */
self->errno = 0; self->errno = 0;
init_timer(&self->watchdog);
self->watchdog.function = irda_discovery_timeout; self->watchdog.function = irda_discovery_timeout;
self->watchdog.data = (unsigned long) self; self->watchdog.data = (unsigned long) self;
self->watchdog.expires = jiffies + (val * HZ/1000); self->watchdog.expires = jiffies + (val * HZ/1000);
......
...@@ -528,8 +528,7 @@ static struct xfrm_state *pfkey_xfrm_state_lookup(struct sadb_msg *hdr, void ** ...@@ -528,8 +528,7 @@ static struct xfrm_state *pfkey_xfrm_state_lookup(struct sadb_msg *hdr, void **
switch (((struct sockaddr *)(addr + 1))->sa_family) { switch (((struct sockaddr *)(addr + 1))->sa_family) {
case AF_INET: case AF_INET:
x = xfrm_state_lookup( x = xfrm_state_lookup(((struct sockaddr_in*)(addr + 1))->sin_addr.s_addr,
((struct sockaddr_in*)(addr + 1))->sin_addr.s_addr,
sa->sadb_sa_spi, proto); sa->sadb_sa_spi, proto);
break; break;
case AF_INET6: case AF_INET6:
...@@ -1043,7 +1042,7 @@ static int pfkey_getspi(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h ...@@ -1043,7 +1042,7 @@ static int pfkey_getspi(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
daddr = (struct sockaddr_in*)(addr + 1); daddr = (struct sockaddr_in*)(addr + 1);
x = xfrm_find_acq(mode, reqid, proto, daddr->sin_addr.s_addr, x = xfrm_find_acq(mode, reqid, proto, daddr->sin_addr.s_addr,
saddr->sin_addr.s_addr); saddr->sin_addr.s_addr, 1);
if (x == NULL) if (x == NULL)
return -ENOENT; return -ENOENT;
...@@ -1122,7 +1121,17 @@ static int pfkey_add(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, ...@@ -1122,7 +1121,17 @@ static int pfkey_add(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr,
/* XXX there is race condition */ /* XXX there is race condition */
x1 = pfkey_xfrm_state_lookup(hdr, ext_hdrs); x1 = pfkey_xfrm_state_lookup(hdr, ext_hdrs);
if (x1 && hdr->sadb_msg_type == SADB_ADD) { if (!x1) {
x1 = xfrm_find_acq(x->props.mode, x->props.reqid, x->id.proto,
x->id.daddr.xfrm4_addr,
x->props.saddr.xfrm4_addr, 0);
if (x1 && x1->id.spi != x->id.spi && x1->id.spi) {
xfrm_state_put(x1);
x1 = NULL;
}
}
if (x1 && x1->id.spi && hdr->sadb_msg_type == SADB_ADD) {
x->km.state = XFRM_STATE_DEAD; x->km.state = XFRM_STATE_DEAD;
xfrm_state_put(x); xfrm_state_put(x);
xfrm_state_put(x1); xfrm_state_put(x1);
...@@ -1131,7 +1140,7 @@ static int pfkey_add(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, ...@@ -1131,7 +1140,7 @@ static int pfkey_add(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr,
xfrm_state_insert(x); xfrm_state_insert(x);
if (x1 && hdr->sadb_msg_type != SADB_ADD) { if (x1) {
xfrm_state_delete(x1); xfrm_state_delete(x1);
xfrm_state_put(x1); xfrm_state_put(x1);
} }
...@@ -1225,7 +1234,7 @@ static struct sk_buff *compose_sadb_supported(struct sadb_msg *orig, int allocat ...@@ -1225,7 +1234,7 @@ static struct sk_buff *compose_sadb_supported(struct sadb_msg *orig, int allocat
esp_len += sizeof(struct sadb_supported); esp_len += sizeof(struct sadb_supported);
len = esp_len + ah_len + sizeof(struct sadb_msg); len = esp_len + ah_len + sizeof(struct sadb_msg);
skb = alloc_skb(allocation, len + 16); skb = alloc_skb(len + 16, allocation);
if (!skb) if (!skb)
goto out_put_algs; goto out_put_algs;
...@@ -2156,7 +2165,7 @@ static struct xfrm_policy *pfkey_compile_policy(int opt, u8 *data, int len, int ...@@ -2156,7 +2165,7 @@ static struct xfrm_policy *pfkey_compile_policy(int opt, u8 *data, int len, int
(!pol->sadb_x_policy_dir || pol->sadb_x_policy_dir > IPSEC_DIR_OUTBOUND)) (!pol->sadb_x_policy_dir || pol->sadb_x_policy_dir > IPSEC_DIR_OUTBOUND))
return NULL; return NULL;
xp = xfrm_policy_alloc(GFP_KERNEL); xp = xfrm_policy_alloc(GFP_ATOMIC);
if (xp == NULL) { if (xp == NULL) {
*dir = -ENOBUFS; *dir = -ENOBUFS;
return NULL; return NULL;
......
...@@ -181,18 +181,22 @@ int llc_sk_init(struct sock* sk) ...@@ -181,18 +181,22 @@ int llc_sk_init(struct sock* sk)
llc->inc_cntr = llc->dec_cntr = 2; llc->inc_cntr = llc->dec_cntr = 2;
llc->dec_step = llc->connect_step = 1; llc->dec_step = llc->connect_step = 1;
init_timer(&llc->ack_timer);
llc->ack_timer.expire = LLC_ACK_TIME; llc->ack_timer.expire = LLC_ACK_TIME;
llc->ack_timer.timer.data = (unsigned long)sk; llc->ack_timer.timer.data = (unsigned long)sk;
llc->ack_timer.timer.function = llc_conn_ack_tmr_cb; llc->ack_timer.timer.function = llc_conn_ack_tmr_cb;
init_timer(&llc->pf_cycle_timer);
llc->pf_cycle_timer.expire = LLC_P_TIME; llc->pf_cycle_timer.expire = LLC_P_TIME;
llc->pf_cycle_timer.timer.data = (unsigned long)sk; llc->pf_cycle_timer.timer.data = (unsigned long)sk;
llc->pf_cycle_timer.timer.function = llc_conn_pf_cycle_tmr_cb; llc->pf_cycle_timer.timer.function = llc_conn_pf_cycle_tmr_cb;
init_timer(&llc->rej_sent_timer);
llc->rej_sent_timer.expire = LLC_REJ_TIME; llc->rej_sent_timer.expire = LLC_REJ_TIME;
llc->rej_sent_timer.timer.data = (unsigned long)sk; llc->rej_sent_timer.timer.data = (unsigned long)sk;
llc->rej_sent_timer.timer.function = llc_conn_rej_tmr_cb; llc->rej_sent_timer.timer.function = llc_conn_rej_tmr_cb;
init_timer(&llc->busy_state_timer);
llc->busy_state_timer.expire = LLC_BUSY_TIME; llc->busy_state_timer.expire = LLC_BUSY_TIME;
llc->busy_state_timer.timer.data = (unsigned long)sk; llc->busy_state_timer.timer.data = (unsigned long)sk;
llc->busy_state_timer.timer.function = llc_conn_busy_tmr_cb; llc->busy_state_timer.timer.function = llc_conn_busy_tmr_cb;
...@@ -552,6 +556,7 @@ static int __init llc_init(void) ...@@ -552,6 +556,7 @@ static int __init llc_init(void)
skb_queue_head_init(&llc_main_station.mac_pdu_q); skb_queue_head_init(&llc_main_station.mac_pdu_q);
skb_queue_head_init(&llc_main_station.ev_q.list); skb_queue_head_init(&llc_main_station.ev_q.list);
spin_lock_init(&llc_main_station.ev_q.lock); spin_lock_init(&llc_main_station.ev_q.lock);
init_timer(&llc_main_station.ack_timer);
llc_main_station.ack_timer.data = (unsigned long)&llc_main_station; llc_main_station.ack_timer.data = (unsigned long)&llc_main_station;
llc_main_station.ack_timer.function = llc_station_ack_tmr_cb; llc_main_station.ack_timer.function = llc_station_ack_tmr_cb;
......
...@@ -411,9 +411,9 @@ static int sfq_init(struct Qdisc *sch, struct rtattr *opt) ...@@ -411,9 +411,9 @@ static int sfq_init(struct Qdisc *sch, struct rtattr *opt)
struct sfq_sched_data *q = (struct sfq_sched_data *)sch->data; struct sfq_sched_data *q = (struct sfq_sched_data *)sch->data;
int i; int i;
init_timer(&q->perturb_timer);
q->perturb_timer.data = (unsigned long)sch; q->perturb_timer.data = (unsigned long)sch;
q->perturb_timer.function = sfq_perturbation; q->perturb_timer.function = sfq_perturbation;
init_timer(&q->perturb_timer);
for (i=0; i<SFQ_HASH_DIVISOR; i++) for (i=0; i<SFQ_HASH_DIVISOR; i++)
q->ht[i] = SFQ_DEPTH; q->ht[i] = SFQ_DEPTH;
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/wanrouter.h> #include <linux/wanrouter.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
...@@ -1839,29 +1840,19 @@ void __init sock_init(void) ...@@ -1839,29 +1840,19 @@ void __init sock_init(void)
#endif #endif
} }
int socket_get_info(char *buffer, char **start, off_t offset, int length) #ifdef CONFIG_PROC_FS
void socket_seq_show(struct seq_file *seq)
{ {
int len, cpu; int cpu;
int counter = 0; int counter = 0;
for (cpu=0; cpu<NR_CPUS; cpu++) for (cpu = 0; cpu < NR_CPUS; cpu++)
counter += sockets_in_use[cpu].counter; counter += sockets_in_use[cpu].counter;
/* It can be negative, by the way. 8) */ /* It can be negative, by the way. 8) */
if (counter < 0) if (counter < 0)
counter = 0; counter = 0;
len = sprintf(buffer, "sockets: used %d\n", counter); seq_printf(seq, "sockets: used %d\n", counter);
if (offset >= len)
{
*start = buffer;
return 0;
}
*start = buffer + offset;
len -= offset;
if (len > length)
len = length;
if (len < 0)
len = 0;
return len;
} }
#endif /* CONFIG_PROC_FS */
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