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