2006-08-04 17: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 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2006-08-04 17:38:38 +07:00
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/fib_rules.h>
|
|
|
|
#include <net/flow.h>
|
2007-03-26 13:20:05 +07:00
|
|
|
#include <net/rtnetlink.h>
|
2006-08-04 17:38:38 +07:00
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct fib_rule {
|
2006-08-04 17:38:38 +07:00
|
|
|
struct list_head list;
|
2009-12-03 08:25:54 +07:00
|
|
|
int iifindex;
|
2009-12-03 08:25:56 +07:00
|
|
|
int oifindex;
|
2006-11-10 06:22:18 +07:00
|
|
|
u32 mark;
|
|
|
|
u32 mark_mask;
|
2006-08-04 17:38:38 +07:00
|
|
|
u32 flags;
|
|
|
|
u32 table;
|
|
|
|
u8 action;
|
2013-08-04 01:50:35 +07:00
|
|
|
/* 3 bytes hole, try to use */
|
2007-03-27 07:14:15 +07:00
|
|
|
u32 target;
|
2015-07-21 15:44:01 +07:00
|
|
|
__be64 tun_id;
|
2010-10-26 16:24:55 +07:00
|
|
|
struct fib_rule __rcu *ctarget;
|
2013-08-04 01:50:35 +07:00
|
|
|
struct net *fr_net;
|
|
|
|
|
|
|
|
atomic_t refcnt;
|
|
|
|
u32 pref;
|
|
|
|
int suppress_ifgroup;
|
|
|
|
int suppress_prefixlen;
|
2009-12-03 08:25:54 +07:00
|
|
|
char iifname[IFNAMSIZ];
|
2009-12-03 08:25:56 +07:00
|
|
|
char oifname[IFNAMSIZ];
|
2006-08-04 17:38:38 +07:00
|
|
|
struct rcu_head rcu;
|
|
|
|
};
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct fib_lookup_arg {
|
2006-08-04 17:38:38 +07:00
|
|
|
void *lookup_ptr;
|
|
|
|
void *result;
|
|
|
|
struct fib_rule *rule;
|
2010-10-05 17:41:36 +07:00
|
|
|
int flags;
|
2015-06-24 00:45:37 +07:00
|
|
|
#define FIB_LOOKUP_NOREF 1
|
|
|
|
#define FIB_LOOKUP_IGNORE_LINKSTATE 2
|
2006-08-04 17:38:38 +07:00
|
|
|
};
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct fib_rules_ops {
|
2006-08-04 17:38:38 +07:00
|
|
|
int family;
|
|
|
|
struct list_head list;
|
|
|
|
int rule_size;
|
2007-03-25 02:46:02 +07:00
|
|
|
int addr_size;
|
2007-03-27 07:14:15 +07:00
|
|
|
int unresolved_rules;
|
|
|
|
int nr_goto_rules;
|
2006-08-04 17:38:38 +07:00
|
|
|
|
|
|
|
int (*action)(struct fib_rule *,
|
|
|
|
struct flowi *, int,
|
|
|
|
struct fib_lookup_arg *);
|
2013-08-01 07:17:15 +07:00
|
|
|
bool (*suppress)(struct fib_rule *,
|
|
|
|
struct fib_lookup_arg *);
|
2006-08-04 17:38:38 +07:00
|
|
|
int (*match)(struct fib_rule *,
|
|
|
|
struct flowi *, int);
|
|
|
|
int (*configure)(struct fib_rule *,
|
|
|
|
struct sk_buff *,
|
|
|
|
struct fib_rule_hdr *,
|
|
|
|
struct nlattr **);
|
2015-03-07 04:47:00 +07:00
|
|
|
int (*delete)(struct fib_rule *);
|
2006-08-04 17:38:38 +07:00
|
|
|
int (*compare)(struct fib_rule *,
|
|
|
|
struct fib_rule_hdr *,
|
|
|
|
struct nlattr **);
|
|
|
|
int (*fill)(struct fib_rule *, struct sk_buff *,
|
|
|
|
struct fib_rule_hdr *);
|
2006-11-11 05:10:15 +07:00
|
|
|
size_t (*nlmsg_payload)(struct fib_rule *);
|
2006-08-04 17:38:38 +07:00
|
|
|
|
2007-03-28 03:56:52 +07:00
|
|
|
/* Called after modifications to the rules set, must flush
|
|
|
|
* the route cache if one exists. */
|
2008-07-06 09:01:28 +07:00
|
|
|
void (*flush_cache)(struct fib_rules_ops *ops);
|
2007-03-28 03:56:52 +07:00
|
|
|
|
2006-08-04 17:38:38 +07:00
|
|
|
int nlgroup;
|
2007-06-06 02:38:30 +07:00
|
|
|
const struct nla_policy *policy;
|
2007-09-17 05:44:27 +07:00
|
|
|
struct list_head rules_list;
|
2006-08-04 17:38:38 +07:00
|
|
|
struct module *owner;
|
2008-01-21 07:46:01 +07:00
|
|
|
struct net *fro_net;
|
2009-12-04 03:22:55 +07:00
|
|
|
struct rcu_head rcu;
|
2006-08-04 17:38:38 +07:00
|
|
|
};
|
|
|
|
|
2006-11-10 06:22:48 +07:00
|
|
|
#define FRA_GENERIC_POLICY \
|
2009-12-03 08:25:54 +07:00
|
|
|
[FRA_IIFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, \
|
2009-12-03 08:25:56 +07:00
|
|
|
[FRA_OIFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, \
|
2006-11-10 06:22:48 +07:00
|
|
|
[FRA_PRIORITY] = { .type = NLA_U32 }, \
|
|
|
|
[FRA_FWMARK] = { .type = NLA_U32 }, \
|
|
|
|
[FRA_FWMASK] = { .type = NLA_U32 }, \
|
2007-03-27 07:14:15 +07:00
|
|
|
[FRA_TABLE] = { .type = NLA_U32 }, \
|
2013-08-03 19:14:43 +07:00
|
|
|
[FRA_SUPPRESS_PREFIXLEN] = { .type = NLA_U32 }, \
|
2013-08-02 22:19:56 +07:00
|
|
|
[FRA_SUPPRESS_IFGROUP] = { .type = NLA_U32 }, \
|
2007-03-27 07:14:15 +07:00
|
|
|
[FRA_GOTO] = { .type = NLA_U32 }
|
2006-11-10 06:22:48 +07:00
|
|
|
|
2006-08-04 17:38:38 +07:00
|
|
|
static inline void fib_rule_get(struct fib_rule *rule)
|
|
|
|
{
|
|
|
|
atomic_inc(&rule->refcnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void fib_rule_put(struct fib_rule *rule)
|
|
|
|
{
|
|
|
|
if (atomic_dec_and_test(&rule->refcnt))
|
2015-03-12 11:04:08 +07:00
|
|
|
kfree_rcu(rule, rcu);
|
2006-08-04 17:38:38 +07:00
|
|
|
}
|
|
|
|
|
2006-08-11 13: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;
|
|
|
|
}
|
|
|
|
|
2013-09-21 01:23:23 +07:00
|
|
|
struct fib_rules_ops *fib_rules_register(const struct fib_rules_ops *,
|
|
|
|
struct net *);
|
|
|
|
void fib_rules_unregister(struct fib_rules_ops *);
|
2006-08-04 17:38:38 +07:00
|
|
|
|
2013-09-21 01:23:23 +07:00
|
|
|
int fib_rules_lookup(struct fib_rules_ops *, struct flowi *, int flags,
|
|
|
|
struct fib_lookup_arg *);
|
|
|
|
int fib_default_rule_add(struct fib_rules_ops *, u32 pref, u32 table,
|
|
|
|
u32 flags);
|
2006-08-04 17:38:38 +07:00
|
|
|
#endif
|