diff options
| author | Vojtech Pavlik <vojtech@suse.cz> | 2002-11-15 10:15:29 +0100 |
|---|---|---|
| committer | Vojtech Pavlik <vojtech@suse.cz> | 2002-11-15 10:15:29 +0100 |
| commit | 26c692941cd9362f55a9a0ca71eed2381c593124 (patch) | |
| tree | ae2f274fd89856dee98d35c1d153b8b9544c74cb /include/linux | |
| parent | cdd78a965de150f55dc6bc2836995e5f8bc991a9 (diff) | |
| parent | b11523f3840b25ad8be50e33f8729cd922447dce (diff) | |
Merge suse.cz:/home/vojtech/bk/linus into suse.cz:/home/vojtech/bk/input
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/cpu.h | 3 | ||||
| -rw-r--r-- | include/linux/device.h | 10 | ||||
| -rw-r--r-- | include/linux/elf.h | 45 | ||||
| -rw-r--r-- | include/linux/fs.h | 4 | ||||
| -rw-r--r-- | include/linux/hiddev.h | 1 | ||||
| -rw-r--r-- | include/linux/in.h | 1 | ||||
| -rw-r--r-- | include/linux/init.h | 121 | ||||
| -rw-r--r-- | include/linux/kernel.h | 2 | ||||
| -rw-r--r-- | include/linux/kmod.h | 1 | ||||
| -rw-r--r-- | include/linux/major.h | 1 | ||||
| -rw-r--r-- | include/linux/module.h | 767 | ||||
| -rw-r--r-- | include/linux/netlink.h | 3 | ||||
| -rw-r--r-- | include/linux/poll.h | 17 | ||||
| -rw-r--r-- | include/linux/suspend.h | 4 | ||||
| -rw-r--r-- | include/linux/udp.h | 3 | ||||
| -rw-r--r-- | include/linux/xfrm.h | 215 |
16 files changed, 636 insertions, 562 deletions
diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 4cbab1066761..0cea32df8325 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -21,6 +21,7 @@ #include <linux/device.h> #include <linux/node.h> +#include <asm/semaphore.h> struct cpu { int node_id; /* The node which contains the CPU */ @@ -29,4 +30,6 @@ struct cpu { extern int register_cpu(struct cpu *, int, struct node *); +/* Stop CPUs going up and down. */ +extern struct semaphore cpucontrol; #endif /* _LINUX_CPU_H_ */ diff --git a/include/linux/device.h b/include/linux/device.h index 0bea391871ae..abec1699ab74 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -443,19 +443,19 @@ extern void firmware_uregister(struct subsystem *); #ifdef DEBUG #define dev_dbg(dev, format, arg...) \ printk (KERN_DEBUG "%s %s: " format , \ - dev.driver->name , dev.bus_id , ## arg) + (dev).driver->name , (dev).bus_id , ## arg) #else #define dev_dbg(dev, format, arg...) do {} while (0) #endif #define dev_err(dev, format, arg...) \ printk (KERN_ERR "%s %s: " format , \ - dev.driver->name , dev.bus_id , ## arg) + (dev).driver->name , (dev).bus_id , ## arg) #define dev_info(dev, format, arg...) \ printk (KERN_INFO "%s %s: " format , \ - dev.driver->name , dev.bus_id , ## arg) + (dev).driver->name , (dev).bus_id , ## arg) #define dev_warn(dev, format, arg...) \ - printk (KERN_WARN "%s %s: " format , \ - dev.driver->name , dev.bus_id , ## arg) + printk (KERN_WARNING "%s %s: " format , \ + (dev).driver->name , (dev).bus_id , ## arg) #endif /* _DEVICE_H_ */ diff --git a/include/linux/elf.h b/include/linux/elf.h index c4157f2ba08b..b8aadaa6a661 100644 --- a/include/linux/elf.h +++ b/include/linux/elf.h @@ -198,6 +198,9 @@ typedef struct { #define ELF32_R_SYM(x) ((x) >> 8) #define ELF32_R_TYPE(x) ((x) & 0xff) +#define ELF64_R_SYM(i) ((i) >> 32) +#define ELF64_R_TYPE(i) ((i) & 0xffffffff) + #define R_386_NONE 0 #define R_386_32 1 #define R_386_PC32 2 @@ -295,6 +298,7 @@ typedef struct { #define R_SPARC_PCPLT10 29 #define R_SPARC_10 30 #define R_SPARC_11 31 +#define R_SPARC_64 32 #define R_SPARC_WDISP16 40 #define R_SPARC_WDISP19 41 #define R_SPARC_7 43 @@ -369,6 +373,47 @@ typedef struct { #define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ #define R_ALPHA_RELATIVE 27 /* Adjust by program base */ +/* PowerPC relocations defined by the ABIs */ +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 /* 32bit absolute address */ +#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ +#define R_PPC_ADDR16 3 /* 16bit absolute address */ +#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ +#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ +#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ +#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 /* PC relative 26 bit */ +#define R_PPC_REL14 11 /* PC relative 16 bit */ +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 +/* Keep this the last entry. */ +#define R_PPC_NUM 37 + /* Legal values for e_flags field of Elf64_Ehdr. */ #define EF_ALPHA_32BIT 1 /* All addresses are below 2GB */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 85029ca092cb..c3bc1a4d0c32 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1121,10 +1121,10 @@ extern void blk_run_queues(void); extern int register_chrdev(unsigned int, const char *, struct file_operations *); extern int unregister_chrdev(unsigned int, const char *); extern int chrdev_open(struct inode *, struct file *); -extern const char *__bdevname(kdev_t); +extern const char *__bdevname(dev_t); extern inline const char *bdevname(struct block_device *bdev) { - return __bdevname(to_kdev_t(bdev->bd_dev)); + return __bdevname(bdev->bd_dev); } extern const char * cdevname(kdev_t); extern const char * kdevname(kdev_t); diff --git a/include/linux/hiddev.h b/include/linux/hiddev.h index 0077b58559f5..a2e1c8e09020 100644 --- a/include/linux/hiddev.h +++ b/include/linux/hiddev.h @@ -159,6 +159,7 @@ struct hiddev_usage_ref { #define HIDIOCSFLAG _IOW('H', 0x0F, int) #define HIDIOCGCOLLECTIONINDEX _IOW('H', 0x10, struct hiddev_usage_ref) #define HIDIOCGCOLLECTIONINFO _IOWR('H', 0x11, struct hiddev_collection_info) +#define HIDIOCGPHYS(len) _IOC(_IOC_READ, 'H', 0x12, len) /* * Flags to be used in HIDIOCSFLAG diff --git a/include/linux/in.h b/include/linux/in.h index edea83ecf432..24814adc8643 100644 --- a/include/linux/in.h +++ b/include/linux/in.h @@ -70,6 +70,7 @@ struct in_addr { #define IP_MTU 14 #define IP_FREEBIND 15 #define IP_IPSEC_POLICY 16 +#define IP_XFRM_POLICY 17 /* BSD compatibility */ #define IP_RECVRETOPTS IP_RETOPTS diff --git a/include/linux/init.h b/include/linux/init.h index d9b7f490e66d..52db706d0ed0 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -38,17 +38,30 @@ * Also note, that this data cannot be "const". */ -#ifndef MODULE +/* These are for everybody (although not all archs will actually + discard it in modules) */ +#define __init __attribute__ ((__section__ (".init.text"))) +#define __initdata __attribute__ ((__section__ (".init.data"))) +#define __exit __attribute__ ((__section__(".exit.text"))) +#define __exitdata __attribute__ ((__section__(".exit.data"))) +#define __exit_call __attribute__ ((unused,__section__ (".exitcall.exit"))) -#ifndef __ASSEMBLY__ +/* For assembly routines */ +#define __INIT .section ".init.text","ax" +#define __FINIT .previous +#define __INITDATA .section ".init.data","aw" +#ifndef __ASSEMBLY__ /* * Used for initialization calls.. */ typedef int (*initcall_t)(void); typedef void (*exitcall_t)(void); +#endif -extern initcall_t __initcall_start, __initcall_end; +#ifndef MODULE + +#ifndef __ASSEMBLY__ /* initcalls are now grouped by functionality into separate * subsections. Ordering inside the subsections is determined @@ -70,7 +83,7 @@ extern initcall_t __initcall_start, __initcall_end; #define __initcall(fn) device_initcall(fn) -#define __exitcall(fn) \ +#define __exitcall(fn) \ static exitcall_t __exitcall_##fn __exit_call = fn /* @@ -83,39 +96,21 @@ struct kernel_param { extern struct kernel_param __setup_start, __setup_end; -#define __setup(str, fn) \ - static char __setup_str_##fn[] __initdata = str; \ - static struct kernel_param __setup_##fn __attribute__((unused)) __initsetup = { __setup_str_##fn, fn } +#define __setup(str, fn) \ + static char __setup_str_##fn[] __initdata = str; \ + static struct kernel_param __setup_##fn \ + __attribute__((unused,__section__ (".init.setup"))) \ + = { __setup_str_##fn, fn } #endif /* __ASSEMBLY__ */ -/* - * Mark functions and data as being only used at initialization - * or exit time. - */ -#define __init __attribute__ ((__section__ (".init.text"))) -#define __exit __attribute__ ((unused, __section__(".exit.text"))) -#define __initdata __attribute__ ((__section__ (".init.data"))) -#define __exitdata __attribute__ ((unused, __section__ (".exit.data"))) -#define __initsetup __attribute__ ((unused,__section__ (".init.setup"))) -#define __init_call(level) __attribute__ ((unused,__section__ (".initcall" level ".init"))) -#define __exit_call __attribute__ ((unused,__section__ (".exitcall.exit"))) - -/* For assembly routines */ -#define __INIT .section ".init.text","ax" -#define __FINIT .previous -#define __INITDATA .section ".init.data","aw" - /** * module_init() - driver initialization entry point * @x: function to be run at kernel boot time or module insertion * - * module_init() will add the driver initialization routine in - * the "__initcall.int" code segment if the driver is checked as - * "y" or static, or else it will wrap the driver initialization - * routine with init_module() which is used by insmod and - * modprobe when the driver is used as a module. - */ + * module_init() will either be called during do_initcalls (if + * builtin) or at module insertion time (if a module). There can only + * be one per module. */ #define module_init(x) __initcall(x); /** @@ -126,39 +121,21 @@ extern struct kernel_param __setup_start, __setup_end; * with cleanup_module() when used with rmmod when * the driver is a module. If the driver is statically * compiled into the kernel, module_exit() has no effect. + * There can only be one per module. */ #define module_exit(x) __exitcall(x); -#else - -#define __init -#define __exit -#define __initdata -#define __exitdata -#define __initcall(fn) -/* For assembly routines */ -#define __INIT -#define __FINIT -#define __INITDATA - -/* These macros create a dummy inline: gcc 2.9x does not count alias - as usage, hence the `unused function' warning when __init functions - are declared static. We use the dummy __*_module_inline functions - both to kill the warning and check the type of the init/cleanup - function. */ -typedef int (*__init_module_func_t)(void); -typedef void (*__cleanup_module_func_t)(void); -#define module_init(x) \ - int init_module(void) __attribute__((alias(#x))); \ - static inline __init_module_func_t __init_module_inline(void) \ - { return x; } -#define module_exit(x) \ - void cleanup_module(void) __attribute__((alias(#x))); \ - static inline __cleanup_module_func_t __cleanup_module_inline(void) \ - { return x; } +/** + * no_module_init - code needs no initialization. + * + * The equivalent of declaring an empty init function which returns 0. + * Every module must have exactly one module_init() or no_module_init + * invocation. */ +#define no_module_init -#define __setup(str,func) /* nothing */ +#else /* MODULE */ +/* Don't use these in modules, but some people do... */ #define core_initcall(fn) module_init(fn) #define postcore_initcall(fn) module_init(fn) #define arch_initcall(fn) module_init(fn) @@ -167,6 +144,34 @@ typedef void (*__cleanup_module_func_t)(void); #define device_initcall(fn) module_init(fn) #define late_initcall(fn) module_init(fn) +/* Each module knows its own name. */ +#define __DEFINE_MODULE_NAME \ + char __module_name[] __attribute__((section(".modulename"))) = \ + __stringify(KBUILD_MODNAME) + +/* These macros create a dummy inline: gcc 2.9x does not count alias + as usage, hence the `unused function' warning when __init functions + are declared static. We use the dummy __*_module_inline functions + both to kill the warning and check the type of the init/cleanup + function. */ + +/* Each module must use one module_init(), or one no_module_init */ +#define module_init(initfn) \ + __DEFINE_MODULE_NAME; \ + static inline initcall_t __inittest(void) \ + { return initfn; } \ + int __initfn(void) __attribute__((alias(#initfn))); + +#define no_module_init __DEFINE_MODULE_NAME + +/* This is only required if you want to be unloadable. */ +#define module_exit(exitfn) \ + static inline exitcall_t __exittest(void) \ + { return exitfn; } \ + void __exitfn(void) __attribute__((alias(#exitfn))); + + +#define __setup(str,func) /* nothing */ #endif /* Data marked not to be saved by software_suspend() */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h index afa757a3b0a1..b81053121b20 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -105,7 +105,7 @@ extern const char *print_tainted(void); extern void dump_stack(void); -#if DEBUG +#ifdef DEBUG #define pr_debug(fmt,arg...) \ printk(KERN_DEBUG fmt,##arg) #else diff --git a/include/linux/kmod.h b/include/linux/kmod.h index 44e1ea6526bb..ca24ceb8e2e2 100644 --- a/include/linux/kmod.h +++ b/include/linux/kmod.h @@ -28,6 +28,7 @@ extern int request_module(const char * name); static inline int request_module(const char * name) { return -ENOSYS; } #endif +#define try_then_request_module(x, mod) ((x) ?: request_module(mod), (x)) extern int exec_usermodehelper(char *program_path, char *argv[], char *envp[]); extern int call_usermodehelper(char *path, char *argv[], char *envp[]); diff --git a/include/linux/major.h b/include/linux/major.h index 3358985dcea4..3679c040597d 100644 --- a/include/linux/major.h +++ b/include/linux/major.h @@ -33,6 +33,7 @@ #define MD_MAJOR 9 #define MISC_MAJOR 10 #define SCSI_CDROM_MAJOR 11 +#define MUX_MAJOR 11 /* PA-RISC only */ #define QIC02_TAPE_MAJOR 12 #define XT_DISK_MAJOR 13 #define SOUND_MAJOR 14 diff --git a/include/linux/module.h b/include/linux/module.h index 8e4cac38ba26..bbdf2b49d5b0 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -1,535 +1,338 @@ +#ifndef _LINUX_MODULE_H +#define _LINUX_MODULE_H /* * Dynamic loading of modules into the kernel. * * Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996 + * Rewritten again by Rusty Russell, 2002 */ - -#ifndef _LINUX_MODULE_H -#define _LINUX_MODULE_H - #include <linux/config.h> +#include <linux/sched.h> #include <linux/spinlock.h> #include <linux/list.h> -#include <linux/errno.h> - -#include <asm/atomic.h> - -/* Don't need to bring in all of uaccess.h just for this decl. */ -struct exception_table_entry; +#include <linux/elf.h> +#include <linux/stat.h> +#include <linux/compiler.h> +#include <linux/cache.h> +#include <linux/kmod.h> +#include <asm/module.h> +#include <asm/uaccess.h> /* For struct exception_table_entry */ + +/* Indirect stringification */ +#define __MODULE_STRING_1(x) #x +#define __MODULE_STRING(x) __MODULE_STRING_1(x) -/* Used by get_kernel_syms, which is obsolete. */ -struct kernel_sym -{ - unsigned long value; - char name[60]; /* should have been 64-sizeof(long); oh well */ -}; +/* Not Yet Implemented */ +#define MODULE_LICENSE(name) +#define MODULE_AUTHOR(name) +#define MODULE_DESCRIPTION(desc) +#define MODULE_SUPPORTED_DEVICE(name) +#define MODULE_GENERIC_TABLE(gtype,name) +#define MODULE_DEVICE_TABLE(type,name) +#define MODULE_PARM_DESC(var,desc) +#define print_symbol(format, addr) +#define print_modules() -struct module_symbol +#define MODULE_NAME_LEN (64 - sizeof(unsigned long)) +struct kernel_symbol { unsigned long value; - const char *name; + char name[MODULE_NAME_LEN]; }; -struct module_ref -{ - struct module *dep; /* "parent" pointer */ - struct module *ref; /* "child" pointer */ - struct module_ref *next_ref; -}; +#ifdef MODULE +/* This is magically filled in by the linker, but THIS_MODULE must be + a constant so it works in initializers. */ +extern struct module __this_module; +#define THIS_MODULE (&__this_module) +#else +#define THIS_MODULE ((struct module *)0) +#endif -/* TBD */ -struct module_persist; +#ifdef CONFIG_MODULES +/* Get/put a kernel symbol (calls must be symmetric) */ +void *__symbol_get(const char *symbol); +void *__symbol_get_gpl(const char *symbol); +#define symbol_get(x) ((typeof(&x))(__symbol_get(#x))) -struct module -{ - unsigned long size_of_struct; /* == sizeof(module) */ - struct module *next; - const char *name; - unsigned long size; +/* For every exported symbol, place a struct in the __ksymtab section */ +#define EXPORT_SYMBOL(sym) \ + const struct kernel_symbol __ksymtab_##sym \ + __attribute__((section("__ksymtab"))) \ + = { (unsigned long)&sym, #sym } - union - { - atomic_t usecount; - long pad; - } uc; /* Needs to keep its size - so says rth */ +#define EXPORT_SYMBOL_NOVERS(sym) EXPORT_SYMBOL(sym) +#define EXPORT_SYMBOL_GPL(sym) EXPORT_SYMBOL(sym) - unsigned long flags; /* AUTOCLEAN et al */ +struct kernel_symbol_group +{ + /* Links us into the global symbol list */ + struct list_head list; - unsigned nsyms; - unsigned ndeps; + /* Module which owns it (if any) */ + struct module *owner; - struct module_symbol *syms; - struct module_ref *deps; - struct module_ref *refs; - int (*init)(void); - void (*cleanup)(void); - const struct exception_table_entry *ex_table_start; - const struct exception_table_entry *ex_table_end; -#ifdef __alpha__ - unsigned long gp; -#endif - /* Members past this point are extensions to the basic - module support and are optional. Use mod_member_present() - to examine them. */ - const struct module_persist *persist_start; - const struct module_persist *persist_end; - int (*can_unload)(void); - int runsize; /* In modutils, not currently used */ - const char *kallsyms_start; /* All symbols for kernel debugging */ - const char *kallsyms_end; - const char *archdata_start; /* arch specific data for module */ - const char *archdata_end; - const char *kernel_data; /* Reserved for kernel internal use */ + unsigned int num_syms; + const struct kernel_symbol *syms; }; -struct module_info +struct exception_table { - unsigned long addr; - unsigned long size; - unsigned long flags; - long usecount; -}; - -/* Bits of module.flags. */ - -#define MOD_UNINITIALIZED 0 -#define MOD_RUNNING 1 -#define MOD_DELETED 2 -#define MOD_AUTOCLEAN 4 -#define MOD_VISITED 8 -#define MOD_USED_ONCE 16 -#define MOD_JUST_FREED 32 -#define MOD_INITIALIZING 64 - -/* Values for query_module's which. */ - -#define QM_MODULES 1 -#define QM_DEPS 2 -#define QM_REFS 3 -#define QM_SYMBOLS 4 -#define QM_INFO 5 - -/* Can the module be queried? */ -#define MOD_CAN_QUERY(mod) (((mod)->flags & (MOD_RUNNING | MOD_INITIALIZING)) && !((mod)->flags & MOD_DELETED)) - -/* When struct module is extended, we must test whether the new member - is present in the header received from insmod before we can use it. - This function returns true if the member is present. */ - -#define mod_member_present(mod,member) \ - ((unsigned long)(&((struct module *)0L)->member + 1) \ - <= (mod)->size_of_struct) - -/* - * Ditto for archdata. Assumes mod->archdata_start and mod->archdata_end - * are validated elsewhere. - */ -#define mod_archdata_member_present(mod, type, member) \ - (((unsigned long)(&((type *)0L)->member) + \ - sizeof(((type *)0L)->member)) <= \ - ((mod)->archdata_end - (mod)->archdata_start)) - - -/* Check if an address p with number of entries n is within the body of module m */ -#define mod_bound(p, n, m) ((unsigned long)(p) >= ((unsigned long)(m) + ((m)->size_of_struct)) && \ - (unsigned long)((p)+(n)) <= (unsigned long)(m) + (m)->size) - -/* Backwards compatibility definition. */ - -#define GET_USE_COUNT(module) (atomic_read(&(module)->uc.usecount)) - -/* Poke the use count of a module. */ - -#define __MOD_INC_USE_COUNT(mod) \ - (atomic_inc(&(mod)->uc.usecount), (mod)->flags |= MOD_VISITED|MOD_USED_ONCE) -#define __MOD_DEC_USE_COUNT(mod) \ - (atomic_dec(&(mod)->uc.usecount), (mod)->flags |= MOD_VISITED) -#define __MOD_IN_USE(mod) \ - (mod_member_present((mod), can_unload) && (mod)->can_unload \ - ? (mod)->can_unload() : atomic_read(&(mod)->uc.usecount)) - -/* Indirect stringification. */ + struct list_head list; -#define __MODULE_STRING_1(x) #x -#define __MODULE_STRING(x) __MODULE_STRING_1(x) + unsigned int num_entries; + const struct exception_table_entry *entry; +}; -/* Generic inter module communication. - * - * NOTE: This interface is intended for small amounts of data that are - * passed between two objects and either or both of the objects - * might be compiled as modules. Do not over use this interface. - * - * If more than two objects need to communicate then you probably - * need a specific interface instead of abusing this generic - * interface. If both objects are *always* built into the kernel - * then a global extern variable is good enough, you do not need - * this interface. - * - * Keith Owens <kaos@ocs.com.au> 28 Oct 2000. - */ +struct module_ref +{ + atomic_t count; +} ____cacheline_aligned; -#ifdef __KERNEL__ -#define HAVE_INTER_MODULE -extern void inter_module_register(const char *, struct module *, const void *); -extern void inter_module_unregister(const char *); -extern const void *inter_module_get(const char *); -extern const void *inter_module_get_request(const char *, const char *); -extern void inter_module_put(const char *); +struct module +{ + /* Am I live (yet)? */ + int live; -struct inter_module_entry { + /* Member of list of modules */ struct list_head list; - const char *im_name; - struct module *owner; - const void *userdata; -}; -extern int try_inc_mod_count(struct module *mod); -#endif /* __KERNEL__ */ + /* Unique handle for this module */ + char name[MODULE_NAME_LEN]; -#if defined(MODULE) && !defined(__GENKSYMS__) + /* Exported symbols */ + struct kernel_symbol_group symbols; -/* Embedded module documentation macros. */ + /* Exception tables */ + struct exception_table extable; -/* For documentation purposes only. */ + /* Startup function. */ + int (*init)(void); -#define MODULE_AUTHOR(name) \ -const char __module_author[] __attribute__((section(".modinfo"))) = \ -"author=" name + /* If this is non-NULL, vfree after init() returns */ + void *module_init; -#define MODULE_DESCRIPTION(desc) \ -const char __module_description[] __attribute__((section(".modinfo"))) = \ -"description=" desc + /* Here is the actual code + data, vfree'd on unload. */ + void *module_core; -/* Could potentially be used by kmod... */ + /* Here are the sizes of the init and core sections */ + unsigned long init_size, core_size; -#define MODULE_SUPPORTED_DEVICE(dev) \ -const char __module_device[] __attribute__((section(".modinfo"))) = \ -"device=" dev + /* Arch-specific module values */ + struct mod_arch_specific arch; -/* Used to verify parameters given to the module. The TYPE arg should - be a string in the following format: - [min[-max]]{b,h,i,l,s} - The MIN and MAX specifiers delimit the length of the array. If MAX - is omitted, it defaults to MIN; if both are omitted, the default is 1. - The final character is a type specifier: - b byte - h short - i int - l long - s string -*/ + /* Am I unsafe to unload? */ + int unsafe; -#define MODULE_PARM(var,type) \ -const char __module_parm_##var[] \ -__attribute__((section(".modinfo"))) = \ -"parm_" __MODULE_STRING(var) "=" type +#ifdef CONFIG_MODULE_UNLOAD + /* Reference counts */ + struct module_ref ref[NR_CPUS]; -#define MODULE_PARM_DESC(var,desc) \ -const char __module_parm_desc_##var[] \ -__attribute__((section(".modinfo"))) = \ -"parm_desc_" __MODULE_STRING(var) "=" desc + /* What modules depend on me? */ + struct list_head modules_which_use_me; -/* - * MODULE_DEVICE_TABLE exports information about devices - * currently supported by this module. A device type, such as PCI, - * is a C-like identifier passed as the first arg to this macro. - * The second macro arg is the variable containing the device - * information being made public. - * - * The following is a list of known device types (arg 1), - * and the C types which are to be passed as arg 2. - * pci - struct pci_device_id - List of PCI ids supported by this module - * isapnp - struct isapnp_device_id - List of ISA PnP ids supported by this module - * usb - struct usb_device_id - List of USB ids supported by this module - */ -#define MODULE_GENERIC_TABLE(gtype,name) \ -static const unsigned long __module_##gtype##_size \ - __attribute__ ((unused)) = sizeof(struct gtype##_id); \ -static const struct gtype##_id * __module_##gtype##_table \ - __attribute__ ((unused)) = name + /* Who is waiting for us to be unloaded */ + struct task_struct *waiter; -/* - * The following license idents are currently accepted as indicating free - * software modules - * - * "GPL" [GNU Public License v2 or later] - * "GPL v2" [GNU Public License v2] - * "GPL and additional rights" [GNU Public License v2 rights and more] - * "Dual BSD/GPL" [GNU Public License v2 or BSD license choice] - * "Dual MPL/GPL" [GNU Public License v2 or Mozilla license choice] - * - * The following other idents are available - * - * "Proprietary" [Non free products] - * - * There are dual licensed components, but when running with Linux it is the - * GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL - * is a GPL combined work. - * - * This exists for several reasons - * 1. So modinfo can show license info for users wanting to vet their setup - * is free - * 2. So the community can ignore bug reports including proprietary modules - * 3. So vendors can do likewise based on their own policies - */ - -#define MODULE_LICENSE(license) \ -static const char __module_license[] \ - __attribute__((section(".modinfo"), unused)) = "license=" license - -/* Define the module variable, and usage macros. */ -extern struct module __this_module; - -#define THIS_MODULE (&__this_module) -#define MOD_INC_USE_COUNT __MOD_INC_USE_COUNT(THIS_MODULE) -#define MOD_DEC_USE_COUNT __MOD_DEC_USE_COUNT(THIS_MODULE) -#define MOD_IN_USE __MOD_IN_USE(THIS_MODULE) - -#include <linux/version.h> -static const char __module_kernel_version[] - __attribute__((section(".modinfo"), unused)) = - "kernel_version=" UTS_RELEASE; -#ifdef CONFIG_MODVERSIONS -static const char __module_using_checksums[] - __attribute__((section(".modinfo"), unused)) = - "using_checksums=1"; + /* Destruction function. */ + void (*exit)(void); #endif -#else /* MODULE */ - -#define MODULE_AUTHOR(name) -#define MODULE_LICENSE(license) -#define MODULE_DESCRIPTION(desc) -#define MODULE_SUPPORTED_DEVICE(name) -#define MODULE_PARM(var,type) -#define MODULE_PARM_DESC(var,desc) - -/* Create a dummy reference to the table to suppress gcc unused warnings. Put - * the reference in the .data.exit section which is discarded when code is built - * in, so the reference does not bloat the running kernel. Note: cannot be - * const, other exit data may be writable. - */ -#define MODULE_GENERIC_TABLE(gtype,name) \ -static const struct gtype##_id * __module_##gtype##_table \ - __attribute__ ((unused, __section__(".exit.data"))) = name - -#ifndef __GENKSYMS__ - -#define THIS_MODULE NULL -#define MOD_INC_USE_COUNT do { } while (0) -#define MOD_DEC_USE_COUNT do { } while (0) -#define MOD_IN_USE 1 - -#endif /* !__GENKSYMS__ */ - -#endif /* MODULE */ - -#define MODULE_DEVICE_TABLE(type,name) \ - MODULE_GENERIC_TABLE(type##_device,name) - -/* Export a symbol either from the kernel or a module. - - In the kernel, the symbol is added to the kernel's global symbol table. - - In a module, it controls which variables are exported. If no - variables are explicitly exported, the action is controled by the - insmod -[xX] flags. Otherwise, only the variables listed are exported. - This obviates the need for the old register_symtab() function. */ - -/* So how does the CONFIG_MODVERSIONS magic work? - * - * A module can only be loaded if it's undefined symbols can be resolved - * using symbols the kernel exports for that purpose. The idea behind - * CONFIG_MODVERSIONS is to mangle those symbols depending on their - * definition (see man genksyms) - a change in the definition will thus - * caused the mangled name to change, and the module will refuse to - * load due to unresolved symbols. - * - * Let's start with taking a look how things work when we don't use - * CONFIG_MODVERSIONS. In this case, the only thing which is worth - * mentioning is the EXPORT_SYMBOL() macro. Using EXPORT_SYMBOL(foo) - * will expand into __EXPORT_SYMBOL(foo, "foo"), which then uses - * some ELF section magic to generate a list of pairs - * (address, symbol_name), which is used to resolve undefined - * symbols into addresses when loading a module. - * - * That's easy. Let's get back to CONFIG_MODVERSIONS=y. - * - * The first step is to generate the checksums. This is done at - * "make dep" time, code which exports symbols (using EXPORT_SYMTAB) - * is preprocessed with the additional macro __GENKSYMS__ set and fed - * into genksyms. - * At this stage, for each file that exports symbols an corresponding - * file in include/linux/module is generated, which for each exported - * symbol contains - * - * #define __ver_schedule_task 2d6c3d04 - * #define schedule_task _set_ver(schedule_task) - * - * In addition, include/linux/modversions.h is generated, which - * looks like - * - * #include <linux/modsetver.h> - * #include <linux/modules/kernel__context.ver> - * <<<lists all of the files just described>>> - * - * Let's see what happens for different cases during compilation. - * - * o compile a file into the kernel which does not export symbols: - * - * Since the file is known to not export symbols (it's not listed - * in the export-objs variable in the corresponding Makefile), the - * kernel build system does compile it with no extra flags set. - * The macro EXPORT_SYMTAB is unset, and you can see below that - * files which still try to use EXPORT_SYMBOL() will be trapped. - * Other than that, just regular compilation. - * - * o compile a file into the kernel which does export symbols: - * - * In this case, the file will compiled with the macro - * EXPORT_SYMTAB defined. - * As MODULE is not set, we hit this case from below: - * - * #define _set_ver(sym) sym - * #include <linux/modversions.h> - * - * #define EXPORT_SYMBOL(var) \ - * __EXPORT_SYMBOL(var, __MODULE_STRING(__VERSIONED_SYMBOL(var))) - * - * The first two lines will in essence include - * - * #define __ver_schedule_task 2d6c3d04 - * #define schedule_task schedule_task - * - * for each symbol. The second line really doesn't do much, but the - * first one gives us the checksums we generated before. - * - * So EXPORT_SYMBOL(schedule_task) will expand into - * __EXPORT_SYMBOL(schedule_task, "schedule_task_R2d6c3d04"), - * hence exporting the symbol for schedule_task under the name of - * schedule_task_R2d6c3d04. - * - * o compile a file into a module - * - * In this case, the kernel build system will add - * "-include include/linux/modversions.h" to the command line. So - * modversions.h is prepended to the actual source, turning into - * - * #define __ver_schedule_task 2d6c3d04 - * #define schedule_task schedule_task_R2d6c3d04 - * - * Though the source code says "schedule_task", the compiler will - * see the mangled symbol everywhere. So the module will end up with - * an undefined symbol "schedule_task_R2d6c3d04" - which is exactly - * the symbols which occurs in the kernel's list of symbols, with - * a value of &schedule_task - it all comes together nicely. - * - * One question remains: What happens if a module itself exports - * a symbol - the answer is simple: It's actually handled as the - * CONFIG_MODVERSIONS=n case described first, only that the compiler - * sees the mangled symbol everywhere. So &foo_R12345678 is exported - * with the name "foo_R12345678". Think about it. It all makes sense. - */ - -#if defined(__GENKSYMS__) - -/* We want the EXPORT_SYMBOL tag left intact for recognition. */ - -#elif !defined(CONFIG_MODULES) - -#define __EXPORT_SYMBOL(sym,str) -#define EXPORT_SYMBOL(var) -#define EXPORT_SYMBOL_NOVERS(var) -#define EXPORT_SYMBOL_GPL(var) - -#elif !defined(EXPORT_SYMTAB) - -#define __EXPORT_SYMBOL(sym,str) error this_object_must_be_defined_as_export_objs_in_the_Makefile -#define EXPORT_SYMBOL(var) error this_object_must_be_defined_as_export_objs_in_the_Makefile -#define EXPORT_SYMBOL_NOVERS(var) error this_object_must_be_defined_as_export_objs_in_the_Makefile -#define EXPORT_SYMBOL_GPL(var) error this_object_must_be_defined_as_export_objs_in_the_Makefile - -#else - -#define __EXPORT_SYMBOL(sym, str) \ -const char __kstrtab_##sym[] \ -__attribute__((section(".kstrtab"))) = str; \ -const struct module_symbol __ksymtab_##sym \ -__attribute__((section("__ksymtab"))) = \ -{ (unsigned long)&sym, __kstrtab_##sym } - -#define __EXPORT_SYMBOL_GPL(sym, str) \ -const char __kstrtab_##sym[] \ -__attribute__((section(".kstrtab"))) = "GPLONLY_" str; \ -const struct module_symbol __ksymtab_##sym \ -__attribute__((section("__ksymtab"))) = \ -{ (unsigned long)&sym, __kstrtab_##sym } - -#if defined(CONFIG_MODVERSIONS) && !defined(MODULE) - -#define _set_ver(sym) sym -#include <linux/modversions.h> - -#define EXPORT_SYMBOL(var) __EXPORT_SYMBOL(var, __MODULE_STRING(__VERSIONED_SYMBOL(var))) -#define EXPORT_SYMBOL_GPL(var) __EXPORT_SYMBOL(var, __MODULE_STRING(__VERSIONED_SYMBOL(var))) - -#else /* !defined (CONFIG_MODVERSIONS) || defined(MODULE) */ - -#define EXPORT_SYMBOL(var) __EXPORT_SYMBOL(var, __MODULE_STRING(var)) -#define EXPORT_SYMBOL_GPL(var) __EXPORT_SYMBOL_GPL(var, __MODULE_STRING(var)) - -#endif /* defined(CONFIG_MODVERSIONS) && !defined(MODULE) */ - -#define EXPORT_SYMBOL_NOVERS(var) __EXPORT_SYMBOL(var, __MODULE_STRING(var)) - -#endif /* __GENKSYMS__ */ - -/* - * Force a module to export no symbols. - * EXPORT_NO_SYMBOLS is default now, leave the define around for sources - * which still have it - */ -#define EXPORT_NO_SYMBOLS - -#ifdef CONFIG_MODULES -/* - * Always allocate a section "__ksymtab". If we encounter EXPORT_SYMBOL, - * the exported symbol will be added to it. - * If it remains empty, that tells modutils that we do not want to - * export any symbols (as opposed to it not being present, which means - * "export all symbols" to modutils) - */ -__asm__(".section __ksymtab,\"a\"\n.previous"); -#endif + /* The command line arguments (may be mangled). People like + keeping pointers to this stuff */ + char args[0]; +}; -#ifdef CONFIG_MODULES -#define SET_MODULE_OWNER(some_struct) do { (some_struct)->owner = THIS_MODULE; } while (0) -#else -#define SET_MODULE_OWNER(some_struct) do { } while (0) +/* Helper function for arch-specific module loaders */ +unsigned long find_symbol_internal(Elf_Shdr *sechdrs, + unsigned int symindex, + const char *strtab, + const char *name, + struct module *mod, + struct kernel_symbol_group **group); + +/* These must be implemented by the specific architecture */ + +/* vmalloc AND zero for the non-releasable code; return ERR_PTR() on error. */ +void *module_core_alloc(const Elf_Ehdr *hdr, + const Elf_Shdr *sechdrs, + const char *secstrings, + struct module *mod); + +/* vmalloc and zero (if any) for sections to be freed after init. + Return ERR_PTR() on error. */ +void *module_init_alloc(const Elf_Ehdr *hdr, + const Elf_Shdr *sechdrs, + const char *secstrings, + struct module *mod); + +/* Apply the given relocation to the (simplified) ELF. Return -error + or 0. */ +int apply_relocate(Elf_Shdr *sechdrs, + const char *strtab, + unsigned int symindex, + unsigned int relsec, + struct module *mod); + +/* Apply the given add relocation to the (simplified) ELF. Return + -error or 0 */ +int apply_relocate_add(Elf_Shdr *sechdrs, + const char *strtab, + unsigned int symindex, + unsigned int relsec, + struct module *mod); + +/* Any final processing of module before access. Return -error or 0. */ +int module_finalize(const Elf_Ehdr *hdr, + const Elf_Shdr *sechdrs, + struct module *mod); + +/* Free memory returned from module_core_alloc/module_init_alloc */ +void module_free(struct module *mod, void *module_region); + +#ifdef CONFIG_MODULE_UNLOAD + +void __symbol_put(const char *symbol); +#define symbol_put(x) __symbol_put(#x) +void symbol_put_addr(void *addr); + +/* We only need protection against local interrupts. */ +#ifndef __HAVE_ARCH_LOCAL_INC +#define local_inc(x) atomic_inc(x) +#define local_dec(x) atomic_dec(x) #endif -extern void print_modules(void); - -#if defined(CONFIG_MODULES) || defined(CONFIG_KALLSYMS) - -extern struct module *module_list; - -/* - * print_symbols takes a format string containing one %s. - * If support for resolving symbols is compiled in, the %s will - * be replaced by the closest symbol to the address and the entire - * string is printk()ed. Otherwise, nothing is printed. - */ -extern void print_symbol(const char *fmt, unsigned long address); - -#else +static inline int try_module_get(struct module *module) +{ + int ret = 1; + + if (module) { + unsigned int cpu = get_cpu(); + if (likely(module->live)) + local_inc(&module->ref[cpu].count); + else + ret = 0; + put_cpu(); + } + return ret; +} -static inline int -print_symbol(const char *fmt, unsigned long address) +static inline void module_put(struct module *module) { - return -ESRCH; + if (module) { + unsigned int cpu = get_cpu(); + local_dec(&module->ref[cpu].count); + /* Maybe they're waiting for us to drop reference? */ + if (unlikely(!module->live)) + wake_up_process(module->waiter); + put_cpu(); + } } +#else /*!CONFIG_MODULE_UNLOAD*/ +static inline int try_module_get(struct module *module) +{ + return !module || module->live; +} +static inline void module_put(struct module *module) +{ +} +#define symbol_put(x) do { } while(0) +#define symbol_put_addr(p) do { } while(0) + +#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) \ +do { \ + if (mod && !(mod)->unsafe) { \ + printk(KERN_WARNING \ + "Module %s cannot be unloaded due to unsafe usage in" \ + " %s:%u\n", (mod)->name, __FILE__, __LINE__); \ + (mod)->unsafe = 1; \ + } \ +} while(0) + +#else /* !CONFIG_MODULES... */ +#define EXPORT_SYMBOL(sym) +#define EXPORT_SYMBOL_GPL(sym) +#define EXPORT_SYMBOL_NOVERS(sym) + +/* Get/put a kernel symbol (calls should be symmetric) */ +#define symbol_get(x) (&(x)) +#define symbol_put(x) do { } while(0) +#define symbol_put_addr(x) do { } while(0) + +#define try_module_get(module) 1 +#define module_put(module) do { } while(0) + +#define module_name(mod) "kernel" + +#define __unsafe(mod) +#endif /* CONFIG_MODULES */ + +/* For archs to search exception tables */ +extern struct list_head extables; +extern spinlock_t modlist_lock; + +#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) + +/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ +#define __MOD_INC_USE_COUNT(mod) \ + do { __unsafe(mod); (void)try_module_get(mod); } while(0) +#define __MOD_DEC_USE_COUNT(mod) module_put(mod) +#define SET_MODULE_OWNER(dev) ((dev)->owner = THIS_MODULE) + +/* People do this inside their init routines, when the module isn't + "live" yet. They should no longer be doing that, but + meanwhile... */ +#if defined(CONFIG_MODULE_UNLOAD) && defined(MODULE) +#define MOD_INC_USE_COUNT \ + do { __unsafe(THIS_MODULE); local_inc(&THIS_MODULE->ref[get_cpu()].count); put_cpu(); } while (0) +#else +#define MOD_INC_USE_COUNT \ + do { __unsafe(THIS_MODULE); (void)try_module_get(THIS_MODULE); } while (0) +#endif +#define MOD_DEC_USE_COUNT module_put(THIS_MODULE) +#define try_inc_mod_count(mod) try_module_get(mod) +#define MODULE_PARM(parm,string) +#define EXPORT_NO_SYMBOLS +extern int module_dummy_usage; +#define GET_USE_COUNT(module) (module_dummy_usage) +#define MOD_IN_USE 0 +#define __mod_between(a_start, a_len, b_start, b_len) \ +(((a_start) >= (b_start) && (a_start) <= (b_start)+(b_len)) \ + || ((a_start)+(a_len) >= (b_start) \ + && (a_start)+(a_len) <= (b_start)+(b_len))) +#define mod_bound(p, n, m) \ +(((m)->module_init \ + && __mod_between((p),(n),(m)->module_init,(m)->init_size)) \ + || __mod_between((p),(n),(m)->module_core,(m)->core_size)) + +/* Old-style "I'll just call it init_module and it'll be run at + insert". Use module_init(myroutine) instead. */ +#ifdef MODULE +/* Used as "int init_module(void) { ... }". Get funky to insert modname. */ +#define init_module(voidarg) \ + __initfn(void); \ + char __module_name[] __attribute__((section(".modulename"))) = \ + __stringify(KBUILD_MODNAME); \ + int __initfn(void) +#define cleanup_module(voidarg) __exitfn(void) #endif +/* Use symbol_get and symbol_put instead. You'll thank me. */ +#define HAVE_INTER_MODULE +extern void inter_module_register(const char *, struct module *, const void *); +extern void inter_module_unregister(const char *); +extern const void *inter_module_get(const char *); +extern const void *inter_module_get_request(const char *, const char *); +extern void inter_module_put(const char *); + #endif /* _LINUX_MODULE_H */ diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 446991da8842..6a0e792fb795 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -7,6 +7,7 @@ #define NETLINK_FIREWALL 3 /* Firewalling hook */ #define NETLINK_TCPDIAG 4 /* TCP socket monitoring */ #define NETLINK_NFLOG 5 /* netfilter/iptables ULOG */ +#define NETLINK_XFRM 6 /* ipsec */ #define NETLINK_ARPD 8 #define NETLINK_ROUTE6 11 /* af_inet6 route comm channel */ #define NETLINK_IP6_FW 13 @@ -86,6 +87,8 @@ struct nlmsgerr #ifdef __KERNEL__ +#include <linux/capability.h> + struct netlink_skb_parms { struct ucred creds; /* Skb credentials */ diff --git a/include/linux/poll.h b/include/linux/poll.h index e88468c3b046..416d32e5d8e2 100644 --- a/include/linux/poll.h +++ b/include/linux/poll.h @@ -11,11 +11,12 @@ #include <asm/uaccess.h> struct poll_table_page; +struct poll_table_struct; + +typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *); typedef struct poll_table_struct { - int queue; - void *priv; - void (*qproc)(void *, wait_queue_head_t *); + poll_queue_proc qproc; int error; struct poll_table_page * table; } poll_table; @@ -25,16 +26,12 @@ extern void __pollwait(struct file * filp, wait_queue_head_t * wait_address, pol static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p) { if (p && wait_address) - __pollwait(filp, wait_address, p); + p->qproc(filp, wait_address, p); } -static inline void poll_initwait_ex(poll_table* pt, int queue, - void (*qproc)(void *, wait_queue_head_t *), - void *priv) +static inline void poll_initwait_ex(poll_table* pt, poll_queue_proc qproc) { - pt->queue = queue; pt->qproc = qproc; - pt->priv = priv; pt->error = 0; pt->table = NULL; } @@ -42,7 +39,7 @@ static inline void poll_initwait_ex(poll_table* pt, int queue, static inline void poll_initwait(poll_table* pt) { - poll_initwait_ex(pt, 1, NULL, NULL); + poll_initwait_ex(pt, __pollwait); } extern void poll_freewait(poll_table* pt); diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 3153f1fb17ee..a481f80034fa 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -72,7 +72,9 @@ extern void do_magic_suspend_2(void); extern void do_suspend_lowlevel(int resume); #else -#define software_suspend() do { } while(0) +static inline void software_suspend(void) +{ +} #define software_resume() do { } while(0) #define register_suspend_notifier(a) do { } while(0) #define unregister_suspend_notifier(a) do { } while(0) diff --git a/include/linux/udp.h b/include/linux/udp.h index 23992fbb73ae..5bdb970a1b69 100644 --- a/include/linux/udp.h +++ b/include/linux/udp.h @@ -57,7 +57,4 @@ struct udp_sock { #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 */ diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h new file mode 100644 index 000000000000..bac8b2e3e666 --- /dev/null +++ b/include/linux/xfrm.h @@ -0,0 +1,215 @@ +#ifndef _LINUX_XFRM_H +#define _LINUX_XFRM_H + +#include <linux/types.h> + +/* All of the structures in this file may not change size as they are + * passed into the kernel from userspace via netlink sockets. + */ + +/* Structure to encapsulate addresses. I do not want to use + * "standard" structure. My apologies. + */ +typedef union +{ + struct { + __u32 addr; + __u32 mask; /* Use unused bits to cache mask. */ + } a4; +#define xfrm4_addr a4.addr +#define xfrm4_mask a4.mask + __u32 a6[4]; +} xfrm_address_t; + +/* Ident of a specific xfrm_state. It is used on input to lookup + * the state by (spi,daddr,ah/esp) or to store information about + * spi, protocol and tunnel address on output. + */ +struct xfrm_id +{ + xfrm_address_t daddr; + __u32 spi; + __u8 proto; +}; + +/* Selector, used as selector both on policy rules (SPD) and SAs. */ + +struct xfrm_selector +{ + xfrm_address_t daddr; + xfrm_address_t saddr; + __u16 dport; + __u16 dport_mask; + __u16 sport; + __u16 sport_mask; + __u8 prefixlen_d; + __u8 prefixlen_s; + __u8 proto; + int ifindex; + uid_t user; + void *owner; +}; + +#define XFRM_INF (~(u64)0) + +struct xfrm_lifetime_cfg +{ + __u64 soft_byte_limit; + __u64 hard_byte_limit; + __u64 soft_packet_limit; + __u64 hard_packet_limit; + __u64 soft_add_expires_seconds; + __u64 hard_add_expires_seconds; + __u64 soft_use_expires_seconds; + __u64 hard_use_expires_seconds; +}; + +struct xfrm_lifetime_cur +{ + __u64 bytes; + __u64 packets; + __u64 add_time; + __u64 use_time; +}; + +struct xfrm_replay_state +{ + __u32 oseq; + __u32 seq; + __u32 bitmap; +}; + +struct xfrm_algo { + char alg_name[64]; + int alg_key_len; /* in bits */ + char alg_key[0]; +}; + +struct xfrm_stats { + __u32 replay_window; + __u32 replay; + __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. */ +#define XFRM_MSG_BASE 0x10 + +#define XFRM_MSG_NEWSA (RTM_BASE + 0) +#define XFRM_MSG_DELSA (RTM_BASE + 1) +#define XFRM_MSG_GETSA (RTM_BASE + 2) + +#define XFRM_MSG_NEWPOLICY (RTM_BASE + 3) +#define XFRM_MSG_DELPOLICY (RTM_BASE + 4) +#define XFRM_MSG_GETPOLICY (RTM_BASE + 5) + +#define XFRM_MSG_ALLOCSPI (RTM_BASE + 6) +#define XFRM_MSG_ACQUIRE (RTM_BASE + 7) +#define XFRM_MSG_EXPIRE (RTM_BASE + 8) + +#define XFRM_MSG_MAX (XFRM_MSG_EXPIRE+1) + +struct xfrm_user_tmpl { + struct xfrm_id id; + xfrm_address_t saddr; + __u16 reqid; + __u8 mode; + __u8 share; + __u8 optional; + __u32 aalgos; + __u32 ealgos; + __u32 calgos; +}; + +/* Netlink message attributes. */ +enum xfrm_attr_type_t { + XFRMA_UNSPEC, + XFRMA_ALG_AUTH, /* struct xfrm_algo */ + XFRMA_ALG_CRYPT, /* struct xfrm_algo */ + XFRMA_ALG_COMP, /* struct xfrm_algo */ + XFRMA_TMPL, /* 1 or more struct xfrm_user_tmpl */ + +#define XFRMA_MAX XFRMA_TMPL +}; + +struct xfrm_usersa_info { + struct xfrm_selector sel; + struct xfrm_id id; + struct xfrm_lifetime_cfg lft; + struct xfrm_lifetime_cur curlft; + struct xfrm_stats stats; + __u32 seq; + __u16 family; + __u16 reqid; + __u8 mode; /* 0=transport,1=tunnel */ + __u8 replay_window; +}; + +struct xfrm_usersa_id { + xfrm_address_t saddr; + __u32 spi; + __u8 proto; +}; + +struct xfrm_userspi_info { + struct xfrm_usersa_info info; + u32 min; + u32 max; +}; + +struct xfrm_userpolicy_info { + struct xfrm_selector sel; + struct xfrm_lifetime_cfg lft; + struct xfrm_lifetime_cur curlft; + __u32 priority; + __u32 index; + __u16 family; + __u8 dir; + __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_selector sel; + __u32 index; + __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 */ |
