From patchwork Tue Dec 7 22:32:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 666 Return-Path: Received: from fmmailgate02.web.de (fmmailgate02.web.de [217.72.192.227]) by open-mesh.org (Postfix) with ESMTP id D7DCB15463C for ; Tue, 7 Dec 2010 23:32:29 +0100 (CET) Received: from smtp04.web.de ( [172.20.0.225]) by fmmailgate02.web.de (Postfix) with ESMTP id EE8D418C57980; Tue, 7 Dec 2010 23:32:28 +0100 (CET) Received: from [46.126.246.98] (helo=localhost) by smtp04.web.de with asmtp (TLSv1:AES128-SHA:128) (WEB.DE 4.110 #24) id 1PQ65E-0002WX-00; Tue, 07 Dec 2010 23:32:28 +0100 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Tue, 7 Dec 2010 23:32:13 +0100 Message-Id: <1291761150-29818-3-git-send-email-linus.luessing@saxnet.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <20101207221351.GA19474@Sellars> References: <20101207221351.GA19474@Sellars> MIME-Version: 1.0 Sender: linus.luessing@web.de X-Sender: linus.luessing@web.de X-Provags-ID: V01U2FsdGVkX19bUpvfHwXxj3LOCfJWnZQBWnRX+HeYz4OfX/TW sAKaju7F8/ZXX7K6y6IYiR4jmu8WxCZ8eV08MlvS8sJ4LPbQrw e1djsuuld7CUhjQjb4Fg== Cc: =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [B.A.T.M.A.N.] [PATCH 03/20] batman-adv: compat macros/defines for local multicast group fetching X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Dec 2010 22:32:30 -0000 The data structures and locking mechanisms for fetching multicast mac addresses from a net_device have changed a little between kernel versions 2.6.21 to 2.6.35. Therefore this commit backports two macros (netdev_mc_count(), netdev_for_each_mc_addr()) for older kernel versions and abstracts the way of locking and accessing the variables with own customized macros. Signed-off-by: Linus Lüssing --- compat.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-) diff --git a/compat.h b/compat.h index b01455f..bbb1dad 100644 --- a/compat.h +++ b/compat.h @@ -264,4 +264,53 @@ int bat_seq_printf(struct seq_file *m, const char *f, ...); #endif /* < KERNEL_VERSION(2, 6, 29) */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) + +#define netdev_mc_count(dev) ((dev)->mc_count) +#define netdev_for_each_mc_addr(mclist, dev) \ + for (mclist = dev->mc_list; mclist; mclist = mclist->next) + +#endif /* < KERNEL_VERSION(2, 6, 34) */ + + +/* + * net_device - multicast list handling + * structures + */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) + +#define MC_LIST struct dev_addr_list +#define MC_LIST_ADDR da_addr + +#endif /* < KERNEL_VERSION(2, 6, 35) */ + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34) + +#define MC_LIST struct netdev_hw_addr_list_mc +#define MC_LIST_ADDR addr + +#endif /* > KERNEL_VERSION(2, 6, 34) */ + +/* + * net_device - multicast list handling + * locking + */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) + +#define MC_LIST_LOCK(soft_iface, flags) \ + spin_lock_irqsave(&soft_iface->_xmit_lock, flags) +#define MC_LIST_UNLOCK(soft_iface, flags) \ + spin_unlock_irqrestore(&soft_iface->_xmit_lock, flags) + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) */ + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 26) + +#define MC_LIST_LOCK(soft_iface, flags) \ + spin_lock_irqsave(&soft_iface->addr_list_lock, flags) +#define MC_LIST_UNLOCK(soft_iface, flags) \ + spin_unlock_irqrestore(&soft_iface->addr_list_lock, flags) + +#endif /* > KERNEL_VERSION(2, 6, 26) */ + #endif /* _NET_BATMAN_ADV_COMPAT_H_ */