mirror of
https://github.com/torvalds/linux.git
synced 2024-11-14 16:12:02 +00:00
5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
168 lines
3.8 KiB
C
168 lines
3.8 KiB
C
/*
|
|
* This module:
|
|
* This module 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.
|
|
*
|
|
* History
|
|
* 03-01-2007 Added forwarding for x.25 Andrew Hendry
|
|
*/
|
|
#include <linux/if_arp.h>
|
|
#include <linux/init.h>
|
|
#include <linux/slab.h>
|
|
#include <net/x25.h>
|
|
|
|
LIST_HEAD(x25_forward_list);
|
|
DEFINE_RWLOCK(x25_forward_list_lock);
|
|
|
|
int x25_forward_call(struct x25_address *dest_addr, struct x25_neigh *from,
|
|
struct sk_buff *skb, int lci)
|
|
{
|
|
struct x25_route *rt;
|
|
struct x25_neigh *neigh_new = NULL;
|
|
struct list_head *entry;
|
|
struct x25_forward *x25_frwd, *new_frwd;
|
|
struct sk_buff *skbn;
|
|
short same_lci = 0;
|
|
int rc = 0;
|
|
|
|
if ((rt = x25_get_route(dest_addr)) == NULL)
|
|
goto out_no_route;
|
|
|
|
if ((neigh_new = x25_get_neigh(rt->dev)) == NULL) {
|
|
/* This shouldnt happen, if it occurs somehow
|
|
* do something sensible
|
|
*/
|
|
goto out_put_route;
|
|
}
|
|
|
|
/* Avoid a loop. This is the normal exit path for a
|
|
* system with only one x.25 iface and default route
|
|
*/
|
|
if (rt->dev == from->dev) {
|
|
goto out_put_nb;
|
|
}
|
|
|
|
/* Remote end sending a call request on an already
|
|
* established LCI? It shouldnt happen, just in case..
|
|
*/
|
|
read_lock_bh(&x25_forward_list_lock);
|
|
list_for_each(entry, &x25_forward_list) {
|
|
x25_frwd = list_entry(entry, struct x25_forward, node);
|
|
if (x25_frwd->lci == lci) {
|
|
printk(KERN_WARNING "X.25: call request for lci which is already registered!, transmitting but not registering new pair\n");
|
|
same_lci = 1;
|
|
}
|
|
}
|
|
read_unlock_bh(&x25_forward_list_lock);
|
|
|
|
/* Save the forwarding details for future traffic */
|
|
if (!same_lci){
|
|
if ((new_frwd = kmalloc(sizeof(struct x25_forward),
|
|
GFP_ATOMIC)) == NULL){
|
|
rc = -ENOMEM;
|
|
goto out_put_nb;
|
|
}
|
|
new_frwd->lci = lci;
|
|
new_frwd->dev1 = rt->dev;
|
|
new_frwd->dev2 = from->dev;
|
|
write_lock_bh(&x25_forward_list_lock);
|
|
list_add(&new_frwd->node, &x25_forward_list);
|
|
write_unlock_bh(&x25_forward_list_lock);
|
|
}
|
|
|
|
/* Forward the call request */
|
|
if ( (skbn = skb_clone(skb, GFP_ATOMIC)) == NULL){
|
|
goto out_put_nb;
|
|
}
|
|
x25_transmit_link(skbn, neigh_new);
|
|
rc = 1;
|
|
|
|
|
|
out_put_nb:
|
|
x25_neigh_put(neigh_new);
|
|
|
|
out_put_route:
|
|
x25_route_put(rt);
|
|
|
|
out_no_route:
|
|
return rc;
|
|
}
|
|
|
|
|
|
int x25_forward_data(int lci, struct x25_neigh *from, struct sk_buff *skb) {
|
|
|
|
struct x25_forward *frwd;
|
|
struct list_head *entry;
|
|
struct net_device *peer = NULL;
|
|
struct x25_neigh *nb;
|
|
struct sk_buff *skbn;
|
|
int rc = 0;
|
|
|
|
read_lock_bh(&x25_forward_list_lock);
|
|
list_for_each(entry, &x25_forward_list) {
|
|
frwd = list_entry(entry, struct x25_forward, node);
|
|
if (frwd->lci == lci) {
|
|
/* The call is established, either side can send */
|
|
if (from->dev == frwd->dev1) {
|
|
peer = frwd->dev2;
|
|
} else {
|
|
peer = frwd->dev1;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
read_unlock_bh(&x25_forward_list_lock);
|
|
|
|
if ( (nb = x25_get_neigh(peer)) == NULL)
|
|
goto out;
|
|
|
|
if ( (skbn = pskb_copy(skb, GFP_ATOMIC)) == NULL){
|
|
goto output;
|
|
|
|
}
|
|
x25_transmit_link(skbn, nb);
|
|
|
|
rc = 1;
|
|
output:
|
|
x25_neigh_put(nb);
|
|
out:
|
|
return rc;
|
|
}
|
|
|
|
void x25_clear_forward_by_lci(unsigned int lci)
|
|
{
|
|
struct x25_forward *fwd;
|
|
struct list_head *entry, *tmp;
|
|
|
|
write_lock_bh(&x25_forward_list_lock);
|
|
|
|
list_for_each_safe(entry, tmp, &x25_forward_list) {
|
|
fwd = list_entry(entry, struct x25_forward, node);
|
|
if (fwd->lci == lci) {
|
|
list_del(&fwd->node);
|
|
kfree(fwd);
|
|
}
|
|
}
|
|
write_unlock_bh(&x25_forward_list_lock);
|
|
}
|
|
|
|
|
|
void x25_clear_forward_by_dev(struct net_device *dev)
|
|
{
|
|
struct x25_forward *fwd;
|
|
struct list_head *entry, *tmp;
|
|
|
|
write_lock_bh(&x25_forward_list_lock);
|
|
|
|
list_for_each_safe(entry, tmp, &x25_forward_list) {
|
|
fwd = list_entry(entry, struct x25_forward, node);
|
|
if ((fwd->dev1 == dev) || (fwd->dev2 == dev)){
|
|
list_del(&fwd->node);
|
|
kfree(fwd);
|
|
}
|
|
}
|
|
write_unlock_bh(&x25_forward_list_lock);
|
|
}
|