From 2d7033d00850c7db34930cff9986c4e4486d2b08 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 14 Mar 2013 11:58:10 -0700 Subject: [PATCH] compat: fix compilation on 2.6.24 based on next-20130312 drivers/net/wireless/iwlwifi/mvm/mac80211.c ends up including include/net/inet_hashtables.h which in 2.6.24 has a routine called __inet_lookup_established() that uses the sk_for_each(1, 2, 3). The patch below by Hauke backported the change that went into the kernel that made sk_for_each(1, 3) use two arguments. It turns out that upstream we realized that the second argument was useless. The header however uses it though so the trick didn't work for 2.6.24 if code used it there. We fix it using a nasty hack by ensuring that when the header file is included we redefine that routine to something else, then we udef it, and then define our new version that only uses the 2 argument form of sk_for_each(). This is a nasty way to solve it but not sure if there is anything cleaner. commit dbc390647a841061954f67ea226221fc7f4b3836 Author: Hauke Mehrtens Date: Sun Feb 10 20:10:10 2013 +0100 compat: backport drop of node parameter from iterators This patch backports the following commit in mainline linux kernel: commit 0bbacca7c3911451cea923b0ad6389d58e3d9ce9 Author: Sasha Levin Date: Thu Feb 7 12:32:18 2013 +1100 hlist: drop the node parameter from iterators Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.25.h | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index 563b65f79b5f..5ca6783eb299 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -20,6 +20,52 @@ #include #include #include +#define __inet_lookup_established __inet_lookup_established_old +#include +#undef __inet_lookup_established +#include +/* + * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so we need + * not check it for lookups anymore, thanks Alexey. -DaveM + * + * Local BH must be disabled here. + */ +static inline struct sock * + __inet_lookup_established(struct inet_hashinfo *hashinfo, + const __be32 saddr, const __be16 sport, + const __be32 daddr, const u16 hnum, + const int dif) +{ + INET_ADDR_COOKIE(acookie, saddr, daddr) + const __portpair ports = INET_COMBINED_PORTS(sport, hnum); + struct sock *sk; + /* Optimize here for direct hit, only listening connections can + * have wildcards anyways. + */ + unsigned int hash = inet_ehashfn(daddr, hnum, saddr, sport); + struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash); + rwlock_t *lock = inet_ehash_lockp(hashinfo, hash); + + prefetch(head->chain.first); + read_lock(lock); + sk_for_each(sk, &head->chain) { + if (INET_MATCH(sk, hash, acookie, saddr, daddr, ports, dif)) + goto hit; /* You sunk my battleship! */ + } + + /* Must check for a TIME_WAIT'er before going to listener hash. */ + sk_for_each(sk, &head->twchain) { + if (INET_TW_MATCH(sk, hash, acookie, saddr, daddr, ports, dif)) + goto hit; + } + sk = NULL; +out: + read_unlock(lock); + return sk; +hit: + sock_hold(sk); + goto out; +} /* Backports b718989da7 */ int __must_check pci_enable_device_mem(struct pci_dev *dev); -- 2.30.2