From 12485a5989edee5f8cd6d4c5ba1cdb983b0036e3 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 6 Jul 2009 14:34:45 -0700 Subject: [PATCH] Backport genl_register_family_with_ops() and skb_dst_drop() Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.31.c | 46 ++++++++++++++++++++++++++++++++++++++++++ compat/compat-2.6.31.h | 19 +++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/compat/compat-2.6.31.c b/compat/compat-2.6.31.c index c1cf216c36de..5c51bde7cb67 100644 --- a/compat/compat-2.6.31.c +++ b/compat/compat-2.6.31.c @@ -120,5 +120,51 @@ void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, } EXPORT_SYMBOL_GPL(__dev_addr_unsync); +/** + * genl_register_family_with_ops - register a generic netlink family + * @family: generic netlink family + * @ops: operations to be registered + * @n_ops: number of elements to register + * + * Registers the specified family and operations from the specified table. + * Only one family may be registered with the same family name or identifier. + * + * The family id may equal GENL_ID_GENERATE causing an unique id to + * be automatically generated and assigned. + * + * Either a doit or dumpit callback must be specified for every registered + * operation or the function will fail. Only one operation structure per + * command identifier may be registered. + * + * See include/net/genetlink.h for more documenation on the operations + * structure. + * + * This is equivalent to calling genl_register_family() followed by + * genl_register_ops() for every operation entry in the table taking + * care to unregister the family on error path. + * + * Return 0 on success or a negative error code. + */ +int genl_register_family_with_ops(struct genl_family *family, + struct genl_ops *ops, size_t n_ops) +{ + int err, i; + + err = genl_register_family(family); + if (err) + return err; + + for (i = 0; i < n_ops; ++i, ++ops) { + err = genl_register_ops(family, ops); + if (err) + goto err_out; + } + return 0; +err_out: + genl_unregister_family(family); + return err; +} +EXPORT_SYMBOL(genl_register_family_with_ops); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ diff --git a/compat/compat-2.6.31.h b/compat/compat-2.6.31.h index bdfa18d2b2b2..cbe9752e651d 100644 --- a/compat/compat-2.6.31.h +++ b/compat/compat-2.6.31.h @@ -7,6 +7,10 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) +#include +#include +#include + #ifndef SDIO_DEVICE_ID_MARVELL_8688WLAN #define SDIO_DEVICE_ID_MARVELL_8688WLAN 0x9104 #endif @@ -33,6 +37,21 @@ #define NETDEV_PRE_UP 0x000D #endif +/* + * Added via adf30907d63893e4208dfe3f5c88ae12bc2f25d5 + * + * There is no _sk_dst on older kernels, so just set the + * old dst to NULL and release it directly. + */ +static inline void skb_dst_drop(struct sk_buff *skb) +{ + dst_release(skb->dst); + skb->dst = NULL; +} + +extern int genl_register_family_with_ops(struct genl_family *family, + struct genl_ops *ops, size_t n_ops); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ #endif /* LINUX_26_31_COMPAT_H */ -- 2.30.2