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