1 /* multipath.c: IPV4 multipath algorithm support.
3 * Copyright (C) 2004, 2005 Einar Lueck <elueck@de.ibm.com>
4 * Copyright (C) 2005 David S. Miller <davem@davemloft.net>
7 #include <linux/module.h>
8 #include <linux/errno.h>
9 #include <linux/netdevice.h>
10 #include <linux/spinlock.h>
12 #include <net/ip_mp_alg.h>
14 static DEFINE_SPINLOCK(alg_table_lock
);
15 struct ip_mp_alg_ops
*ip_mp_alg_table
[IP_MP_ALG_MAX
+ 1];
17 int multipath_alg_register(struct ip_mp_alg_ops
*ops
, enum ip_mp_alg n
)
19 struct ip_mp_alg_ops
**slot
;
22 if (n
< IP_MP_ALG_NONE
|| n
> IP_MP_ALG_MAX
||
23 !ops
->mp_alg_select_route
)
26 spin_lock(&alg_table_lock
);
27 slot
= &ip_mp_alg_table
[n
];
34 spin_unlock(&alg_table_lock
);
38 EXPORT_SYMBOL(multipath_alg_register
);
40 void multipath_alg_unregister(struct ip_mp_alg_ops
*ops
, enum ip_mp_alg n
)
42 struct ip_mp_alg_ops
**slot
;
44 if (n
< IP_MP_ALG_NONE
|| n
> IP_MP_ALG_MAX
)
47 spin_lock(&alg_table_lock
);
48 slot
= &ip_mp_alg_table
[n
];
51 spin_unlock(&alg_table_lock
);
55 EXPORT_SYMBOL(multipath_alg_unregister
);