2006-08-04 03:38:38 -07: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 01:04:11 -07:00
|
|
|
#include <linux/slab.h>
|
2006-08-04 03:38:38 -07:00
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/fib_rules.h>
|
|
|
|
#include <net/flow.h>
|
2007-03-25 23:20:05 -07:00
|
|
|
#include <net/rtnetlink.h>
|
2006-08-04 03:38:38 -07:00
|
|
|
|
2009-11-02 20:26:03 -07:00
|
|
|
struct fib_rule {
|
2006-08-04 03:38:38 -07:00
|
|
|
struct list_head list;
|
|
|
|
atomic_t refcnt;
|
2009-12-02 18:25:54 -07:00
|
|
|
int iifindex;
|
2009-12-02 18:25:56 -07:00
|
|
|
int oifindex;
|
2006-11-09 16:22:18 -07:00
|
|
|
u32 mark;
|
|
|
|
u32 mark_mask;
|
2006-08-04 03:38:38 -07:00
|
|
|
u32 pref;
|
|
|
|
u32 flags;
|
|
|
|
u32 table;
|
|
|
|
u8 action;
|
2007-03-26 17:14:15 -07:00
|
|
|
u32 target;
|
2010-10-26 02:24:55 -07:00
|
|
|
struct fib_rule __rcu *ctarget;
|
2009-12-02 18:25:54 -07:00
|
|
|
char iifname[IFNAMSIZ];
|
2009-12-02 18:25:56 -07:00
|
|
|
char oifname[IFNAMSIZ];
|
2006-08-04 03:38:38 -07:00
|
|
|
struct rcu_head rcu;
|
2008-01-20 17:47:09 -07:00
|
|
|
struct net * fr_net;
|
2006-08-04 03:38:38 -07:00
|
|
|
};
|
|
|
|
|
2009-11-02 20:26:03 -07:00
|
|
|
struct fib_lookup_arg {
|
2006-08-04 03:38:38 -07:00
|
|
|
void *lookup_ptr;
|
|
|
|
void *result;
|
|
|
|
struct fib_rule *rule;
|
2010-10-05 03:41:36 -07:00
|
|
|
int flags;
|
|
|
|
#define FIB_LOOKUP_NOREF 1
|
2006-08-04 03:38:38 -07:00
|
|
|
};
|
|
|
|
|
2009-11-02 20:26:03 -07:00
|
|
|
struct fib_rules_ops {
|
2006-08-04 03:38:38 -07:00
|
|
|
int family;
|
|
|
|
struct list_head list;
|
|
|
|
int rule_size;
|
2007-03-24 12:46:02 -07:00
|
|
|
int addr_size;
|
2007-03-26 17:14:15 -07:00
|
|
|
int unresolved_rules;
|
|
|
|
int nr_goto_rules;
|
2006-08-04 03:38:38 -07: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 **);
|
|
|
|
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 04:18:25 -07:00
|
|
|
u32 (*default_pref)(struct fib_rules_ops *ops);
|
2006-11-10 15:10:15 -07:00
|
|
|
size_t (*nlmsg_payload)(struct fib_rule *);
|
2006-08-04 03:38:38 -07:00
|
|
|
|
2007-03-27 13:56:52 -07:00
|
|
|
/* Called after modifications to the rules set, must flush
|
|
|
|
* the route cache if one exists. */
|
2008-07-05 19:01:28 -07:00
|
|
|
void (*flush_cache)(struct fib_rules_ops *ops);
|
2007-03-27 13:56:52 -07:00
|
|
|
|
2006-08-04 03:38:38 -07:00
|
|
|
int nlgroup;
|
2007-06-05 12:38:30 -07:00
|
|
|
const struct nla_policy *policy;
|
2007-09-16 15:44:27 -07:00
|
|
|
struct list_head rules_list;
|
2006-08-04 03:38:38 -07:00
|
|
|
struct module *owner;
|
2008-01-20 17:46:01 -07:00
|
|
|
struct net *fro_net;
|
2009-12-03 13:22:55 -07:00
|
|
|
struct rcu_head rcu;
|
2006-08-04 03:38:38 -07:00
|
|
|
};
|
|
|
|
|
2006-11-09 16:22:48 -07:00
|
|
|
#define FRA_GENERIC_POLICY \
|
2009-12-02 18:25:54 -07:00
|
|
|
[FRA_IIFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, \
|
2009-12-02 18:25:56 -07:00
|
|
|
[FRA_OIFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, \
|
2006-11-09 16:22:48 -07:00
|
|
|
[FRA_PRIORITY] = { .type = NLA_U32 }, \
|
|
|
|
[FRA_FWMARK] = { .type = NLA_U32 }, \
|
|
|
|
[FRA_FWMASK] = { .type = NLA_U32 }, \
|
2007-03-26 17:14:15 -07:00
|
|
|
[FRA_TABLE] = { .type = NLA_U32 }, \
|
|
|
|
[FRA_GOTO] = { .type = NLA_U32 }
|
2006-11-09 16:22:48 -07:00
|
|
|
|
2006-08-04 03:38:38 -07: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 02:01:56 -07:00
|
|
|
release_net(rule->fr_net);
|
2006-08-04 03:38:38 -07: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-10 23:09:48 -07: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 07:02:04 -07:00
|
|
|
extern struct fib_rules_ops *fib_rules_register(const struct fib_rules_ops *, struct net *);
|
2008-01-20 17:46:41 -07:00
|
|
|
extern void fib_rules_unregister(struct fib_rules_ops *);
|
2006-08-04 03:38:38 -07:00
|
|
|
|
|
|
|
extern int fib_rules_lookup(struct fib_rules_ops *,
|
|
|
|
struct flowi *, int flags,
|
|
|
|
struct fib_lookup_arg *);
|
2007-11-10 23:12:03 -07:00
|
|
|
extern int fib_default_rule_add(struct fib_rules_ops *,
|
|
|
|
u32 pref, u32 table,
|
|
|
|
u32 flags);
|
2010-04-12 22:03:15 -07:00
|
|
|
extern u32 fib_default_rule_pref(struct fib_rules_ops *ops);
|
2006-08-04 03:38:38 -07:00
|
|
|
#endif
|