After Al Viro (finally) succeeded in removing the sched.h #include in module.h recently, it makes sense again to remove other superfluous sched.h includes. There are quite a lot of files which include it but don't actually need anything defined in there. Presumably these includes were once needed for macros that used to live in sched.h, but moved to other header files in the course of cleaning it up. To ease the pain, this time I did not fiddle with any header files and only removed #includes from .c-files, which tend to cause less trouble. Compile tested against 2.6.20-rc2 and 2.6.20-rc2-mm2 (with offsets) on alpha, arm, i386, ia64, mips, powerpc, and x86_64 with allnoconfig, defconfig, allmodconfig, and allyesconfig as well as a few randconfigs on x86_64 and all configs in arch/arm/configs on arm. I also checked that no new warnings were introduced by the patch (actually, some warnings are removed that were emitted by unnecessarily included header files). Signed-off-by: Tim Schmielau <tim@physik3.uni-rostock.de> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
128 lines
3 KiB
C
128 lines
3 KiB
C
/*
|
|
* Random policy for multipath.
|
|
*
|
|
*
|
|
* Version: $Id: multipath_random.c,v 1.1.2.3 2004/09/21 08:42:11 elueck Exp $
|
|
*
|
|
* Authors: Einar Lueck <elueck@de.ibm.com><lkml@einar-lueck.de>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*/
|
|
|
|
#include <asm/system.h>
|
|
#include <asm/uaccess.h>
|
|
#include <linux/types.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/timer.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/fcntl.h>
|
|
#include <linux/stat.h>
|
|
#include <linux/socket.h>
|
|
#include <linux/in.h>
|
|
#include <linux/inet.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/inetdevice.h>
|
|
#include <linux/igmp.h>
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/module.h>
|
|
#include <linux/mroute.h>
|
|
#include <linux/init.h>
|
|
#include <net/ip.h>
|
|
#include <net/protocol.h>
|
|
#include <linux/skbuff.h>
|
|
#include <net/sock.h>
|
|
#include <net/icmp.h>
|
|
#include <net/udp.h>
|
|
#include <net/raw.h>
|
|
#include <linux/notifier.h>
|
|
#include <linux/if_arp.h>
|
|
#include <linux/netfilter_ipv4.h>
|
|
#include <net/ipip.h>
|
|
#include <net/checksum.h>
|
|
#include <net/ip_mp_alg.h>
|
|
|
|
#define MULTIPATH_MAX_CANDIDATES 40
|
|
|
|
/* interface to random number generation */
|
|
static unsigned int RANDOM_SEED = 93186752;
|
|
|
|
static inline unsigned int random(unsigned int ubound)
|
|
{
|
|
static unsigned int a = 1588635695,
|
|
q = 2,
|
|
r = 1117695901;
|
|
|
|
RANDOM_SEED = a*(RANDOM_SEED % q) - r*(RANDOM_SEED / q);
|
|
|
|
return RANDOM_SEED % ubound;
|
|
}
|
|
|
|
|
|
static void random_select_route(const struct flowi *flp,
|
|
struct rtable *first,
|
|
struct rtable **rp)
|
|
{
|
|
struct rtable *rt;
|
|
struct rtable *decision;
|
|
unsigned char candidate_count = 0;
|
|
|
|
/* count all candidate */
|
|
for (rt = rcu_dereference(first); rt;
|
|
rt = rcu_dereference(rt->u.dst.rt_next)) {
|
|
if ((rt->u.dst.flags & DST_BALANCED) != 0 &&
|
|
multipath_comparekeys(&rt->fl, flp))
|
|
++candidate_count;
|
|
}
|
|
|
|
/* choose a random candidate */
|
|
decision = first;
|
|
if (candidate_count > 1) {
|
|
unsigned char i = 0;
|
|
unsigned char candidate_no = (unsigned char)
|
|
random(candidate_count);
|
|
|
|
/* find chosen candidate and adjust GC data for all candidates
|
|
* to ensure they stay in cache
|
|
*/
|
|
for (rt = first; rt; rt = rt->u.dst.rt_next) {
|
|
if ((rt->u.dst.flags & DST_BALANCED) != 0 &&
|
|
multipath_comparekeys(&rt->fl, flp)) {
|
|
rt->u.dst.lastuse = jiffies;
|
|
|
|
if (i == candidate_no)
|
|
decision = rt;
|
|
|
|
if (i >= candidate_count)
|
|
break;
|
|
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
|
|
decision->u.dst.__use++;
|
|
*rp = decision;
|
|
}
|
|
|
|
static struct ip_mp_alg_ops random_ops = {
|
|
.mp_alg_select_route = random_select_route,
|
|
};
|
|
|
|
static int __init random_init(void)
|
|
{
|
|
return multipath_alg_register(&random_ops, IP_MP_ALG_RANDOM);
|
|
}
|
|
|
|
static void __exit random_exit(void)
|
|
{
|
|
multipath_alg_unregister(&random_ops, IP_MP_ALG_RANDOM);
|
|
}
|
|
|
|
module_init(random_init);
|
|
module_exit(random_exit);
|
|
MODULE_LICENSE("GPL");
|