Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
commit 082c888cd7b2d0e6d99b5f4add32d676d5851c2c Author: Sven Eckelmann sven@narfation.org Date: Fri Apr 17 19:40:30 2015 +0200
batman-adv: Automatically create nested kfree_rcu helper functions
The kfree_rcu compat helper for old kernels require a special function that knows how to calculate the offsets to the actual data pointer to call kfree. These can either be manually provided or the GCC extension for nested functions can be used to automatically create a local function using a macro.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Marek Lindner mareklindner@neomailbox.ch
082c888cd7b2d0e6d99b5f4add32d676d5851c2c Makefile | 1 - compat.c | 120 -------------------------------------------------------------- compat.h | 20 ----------- 3 files changed, 141 deletions(-)
diff --git a/Makefile b/Makefile index fd7ae8d..e57fcb3 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,6 @@ NOSTDINC_FLAGS := \ $(CFLAGS)
CONFIG_BATMAN_ADV=m -batman-adv-y += compat.o ifneq ($(REVISION),) ccflags-y += -DBATADV_SOURCE_VERSION="$(REVISION)" endif diff --git a/compat.c b/compat.c deleted file mode 100644 index 516d06c..0000000 --- a/compat.c +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: - * - * Marek Lindner, Simon Wunderlich - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see http://www.gnu.org/licenses/. - * - * This file contains macros for maintaining compatibility with older versions - * of the Linux kernel. - */ - -#include <linux/in.h> -#include <linux/version.h> -#include "main.h" - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) - -void batadv_free_rcu_orig_vlan(struct rcu_head *rcu) -{ - struct batadv_orig_node_vlan *vlan; - - vlan = container_of(rcu, struct batadv_orig_node_vlan, rcu); - - kfree(vlan); -} - -void batadv_free_rcu_softif_vlan(struct rcu_head *rcu) -{ - struct batadv_softif_vlan *vlan; - - vlan = container_of(rcu, struct batadv_softif_vlan, rcu); - - kfree(vlan); -} - -void batadv_free_rcu_vlan(struct rcu_head *rcu) -{ - struct batadv_softif_vlan *vlan; - - vlan = container_of(rcu, struct batadv_softif_vlan, rcu); - - kfree(vlan); -} - -void batadv_free_rcu_tt_global_entry(struct rcu_head *rcu) -{ - struct batadv_tt_global_entry *global; - - global = container_of(rcu, struct batadv_tt_global_entry, common.rcu); - - kfree(global); -} - -void batadv_free_rcu_gw_node(struct rcu_head *rcu) -{ - struct batadv_gw_node *gw_node; - - gw_node = container_of(rcu, struct batadv_gw_node, rcu); - kfree(gw_node); -} - -void batadv_free_rcu_tt_local_entry(struct rcu_head *rcu) -{ - struct batadv_tt_common_entry *tt_common_entry; - struct batadv_tt_local_entry *tt_local_entry; - - tt_common_entry = container_of(rcu, struct batadv_tt_common_entry, rcu); - tt_local_entry = container_of(tt_common_entry, - struct batadv_tt_local_entry, common); - kfree(tt_local_entry); -} - -#ifdef CONFIG_BATMAN_ADV_BLA -void batadv_free_rcu_backbone_gw(struct rcu_head *rcu) -{ - struct batadv_bla_backbone_gw *backbone_gw; - - backbone_gw = container_of(rcu, struct batadv_bla_backbone_gw, rcu); - kfree(backbone_gw); -} -#endif - -#ifdef CONFIG_BATMAN_ADV_DAT -void batadv_free_rcu_dat_entry(struct rcu_head *rcu) -{ - struct batadv_dat_entry *dat_entry; - - dat_entry = container_of(rcu, struct batadv_dat_entry, rcu); - kfree(dat_entry); -} -#endif - -#ifdef CONFIG_BATMAN_ADV_NC -void batadv_free_rcu_nc_path(struct rcu_head *rcu) -{ - struct batadv_nc_path *nc_path; - - nc_path = container_of(rcu, struct batadv_nc_path, rcu); - kfree(nc_path); -} -#endif - -void batadv_free_rcu_tvlv_handler(struct rcu_head *rcu) -{ - struct batadv_tvlv_handler *tvlv_handler; - - tvlv_handler = container_of(rcu, struct batadv_tvlv_handler, rcu); - kfree(tvlv_handler); -} - -#endif /* < KERNEL_VERSION(3, 0, 0) */ diff --git a/compat.h b/compat.h index 35e3dbd..250763e 100644 --- a/compat.h +++ b/compat.h @@ -90,26 +90,6 @@ static const struct { \ #endif /* < KERNEL_VERSION(2, 6, 39) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) - -#define kfree_rcu(ptr, rcu_head) call_rcu(&ptr->rcu_head, batadv_free_rcu_##ptr) - -struct rcu_head; - -void batadv_free_rcu_orig_vlan(struct rcu_head *rcu); -void batadv_free_rcu_softif_vlan(struct rcu_head *rcu); -void batadv_free_rcu_tt_global_entry(struct rcu_head *rcu); -void batadv_free_rcu_gw_node(struct rcu_head *rcu); -void batadv_free_rcu_tt_local_entry(struct rcu_head *rcu); -void batadv_free_rcu_backbone_gw(struct rcu_head *rcu); -void batadv_free_rcu_dat_entry(struct rcu_head *rcu); -void batadv_free_rcu_nc_path(struct rcu_head *rcu); -void batadv_free_rcu_tvlv_handler(struct rcu_head *rcu); -void batadv_free_rcu_vlan(struct rcu_head *rcu); - -#endif /* < KERNEL_VERSION(3, 0, 0) */ - - #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
#define batadv_interface_add_vid(x, y, z) \