2006-08-04 12:38:38 +02:00
|
|
|
#ifndef __NET_FIB_RULES_H
|
|
|
|
#define __NET_FIB_RULES_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
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>
2010-03-24 09:04:11 +01:00
|
|
|
#include <linux/slab.h>
|
2006-08-04 12:38:38 +02:00
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/fib_rules.h>
|
|
|
|
#include <net/flow.h>
|
2007-03-26 08:20:05 +02:00
|
|
|
#include <net/rtnetlink.h>
|
2006-08-04 12:38:38 +02:00
|
|
|
|
2009-11-03 04:26:03 +01:00
|
|
|
struct fib_rule {
|
2006-08-04 12:38:38 +02:00
|
|
|
struct list_head list;
|
|
|
|
atomic_t refcnt;
|
2009-12-03 02:25:54 +01:00
|
|
|
int iifindex;
|
2009-12-03 02:25:56 +01:00
|
|
|
int oifindex;
|
2006-11-10 00:22:18 +01:00
|
|
|
u32 mark;
|
|
|
|
u32 mark_mask;
|
2006-08-04 12:38:38 +02:00
|
|
|
u32 pref;
|
|
|
|
u32 flags;
|
|
|
|
u32 table;
|
|
|
|
u8 action;
|
2007-03-27 02:14:15 +02:00
|
|
|
u32 target;
|
2010-10-26 11:24:55 +02:00
|
|
|
struct fib_rule __rcu *ctarget;
|
2009-12-03 02:25:54 +01:00
|
|
|
char iifname[IFNAMSIZ];
|
2009-12-03 02:25:56 +01:00
|
|
|
char oifname[IFNAMSIZ];
|
2006-08-04 12:38:38 +02:00
|
|
|
struct rcu_head rcu;
|
2008-01-21 01:47:09 +01:00
|
|
|
struct net * fr_net;
|
2006-08-04 12:38:38 +02:00
|
|
|
};
|
|
|
|
|
2009-11-03 04:26:03 +01:00
|
|
|
struct fib_lookup_arg {
|
2006-08-04 12:38:38 +02:00
|
|
|
void *lookup_ptr;
|
|
|
|
void *result;
|
|
|
|
struct fib_rule *rule;
|
2010-10-05 12:41:36 +02:00
|
|
|
int flags;
|
|
|
|
#define FIB_LOOKUP_NOREF 1
|
2006-08-04 12:38:38 +02:00
|
|
|
};
|
|
|
|
|
2009-11-03 04:26:03 +01:00
|
|
|
struct fib_rules_ops {
|
2006-08-04 12:38:38 +02:00
|
|
|
int family;
|
|
|
|
struct list_head list;
|
|
|
|
int rule_size;
|
2007-03-24 20:46:02 +01:00
|
|
|
int addr_size;
|
2007-03-27 02:14:15 +02:00
|
|
|
int unresolved_rules;
|
|
|
|
int nr_goto_rules;
|
2006-08-04 12:38:38 +02:00
|
|
|
|
|
|
|
int (*action)(struct fib_rule *,
|
|
|
|
struct flowi *, int,
|
|
|
|
struct fib_lookup_arg *);
|
|
|
|
int (*match)(struct fib_rule *,
|
|
|
|
struct flowi *, int);
|
|
|
|
int (*configure)(struct fib_rule *,
|
|
|
|
struct sk_buff *,
|
|
|
|
struct fib_rule_hdr *,
|
|
|
|
struct nlattr **);
|
2012-06-29 10:32:45 +02:00
|
|
|
void (*delete)(struct fib_rule *);
|
2006-08-04 12:38:38 +02:00
|
|
|
int (*compare)(struct fib_rule *,
|
|
|
|
struct fib_rule_hdr *,
|
|
|
|
struct nlattr **);
|
|
|
|
int (*fill)(struct fib_rule *, struct sk_buff *,
|
|
|
|
struct fib_rule_hdr *);
|
2008-01-10 12:18:25 +01:00
|
|
|
u32 (*default_pref)(struct fib_rules_ops *ops);
|
2006-11-10 23:10:15 +01:00
|
|
|
size_t (*nlmsg_payload)(struct fib_rule *);
|
2006-08-04 12:38:38 +02:00
|
|
|
|
2007-03-27 22:56:52 +02:00
|
|
|
/* Called after modifications to the rules set, must flush
|
|
|
|
* the route cache if one exists. */
|
2008-07-06 04:01:28 +02:00
|
|
|
void (*flush_cache)(struct fib_rules_ops *ops);
|
2007-03-27 22:56:52 +02:00
|
|
|
|
2006-08-04 12:38:38 +02:00
|
|
|
int nlgroup;
|
2007-06-05 21:38:30 +02:00
|
|
|
const struct nla_policy *policy;
|
2007-09-17 00:44:27 +02:00
|
|
|
struct list_head rules_list;
|
2006-08-04 12:38:38 +02:00
|
|
|
struct module *owner;
|
2008-01-21 01:46:01 +01:00
|
|
|
struct net *fro_net;
|
2009-12-03 21:22:55 +01:00
|
|
|
struct rcu_head rcu;
|
2006-08-04 12:38:38 +02:00
|
|
|
};
|
|
|
|
|
2006-11-10 00:22:48 +01:00
|
|
|
#define FRA_GENERIC_POLICY \
|
2009-12-03 02:25:54 +01:00
|
|
|
[FRA_IIFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, \
|
2009-12-03 02:25:56 +01:00
|
|
|
[FRA_OIFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, \
|
2006-11-10 00:22:48 +01:00
|
|
|
[FRA_PRIORITY] = { .type = NLA_U32 }, \
|
|
|
|
[FRA_FWMARK] = { .type = NLA_U32 }, \
|
|
|
|
[FRA_FWMASK] = { .type = NLA_U32 }, \
|
2007-03-27 02:14:15 +02:00
|
|
|
[FRA_TABLE] = { .type = NLA_U32 }, \
|
|
|
|
[FRA_GOTO] = { .type = NLA_U32 }
|
2006-11-10 00:22:48 +01:00
|
|
|
|
2006-08-04 12:38:38 +02:00
|
|
|
static inline void fib_rule_get(struct fib_rule *rule)
|
|
|
|
{
|
|
|
|
atomic_inc(&rule->refcnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void fib_rule_put_rcu(struct rcu_head *head)
|
|
|
|
{
|
|
|
|
struct fib_rule *rule = container_of(head, struct fib_rule, rcu);
|
2008-04-16 11:01:56 +02:00
|
|
|
release_net(rule->fr_net);
|
2006-08-04 12:38:38 +02:00
|
|
|
kfree(rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void fib_rule_put(struct fib_rule *rule)
|
|
|
|
{
|
|
|
|
if (atomic_dec_and_test(&rule->refcnt))
|
|
|
|
call_rcu(&rule->rcu, fib_rule_put_rcu);
|
|
|
|
}
|
|
|
|
|
2006-08-11 08:09:48 +02:00
|
|
|
static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
|
|
|
|
{
|
|
|
|
if (nla[FRA_TABLE])
|
|
|
|
return nla_get_u32(nla[FRA_TABLE]);
|
|
|
|
return frh->table;
|
|
|
|
}
|
|
|
|
|
2010-04-26 16:02:04 +02:00
|
|
|
extern struct fib_rules_ops *fib_rules_register(const struct fib_rules_ops *, struct net *);
|
2008-01-21 01:46:41 +01:00
|
|
|
extern void fib_rules_unregister(struct fib_rules_ops *);
|
2006-08-04 12:38:38 +02:00
|
|
|
|
|
|
|
extern int fib_rules_lookup(struct fib_rules_ops *,
|
|
|
|
struct flowi *, int flags,
|
|
|
|
struct fib_lookup_arg *);
|
2007-11-11 07:12:03 +01:00
|
|
|
extern int fib_default_rule_add(struct fib_rules_ops *,
|
|
|
|
u32 pref, u32 table,
|
|
|
|
u32 flags);
|
2010-04-13 07:03:15 +02:00
|
|
|
extern u32 fib_default_rule_pref(struct fib_rules_ops *ops);
|
2006-08-04 12:38:38 +02:00
|
|
|
#endif
|