aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2006-08-04 06:38:38 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 17:53:40 -0400
commit14c0b97ddfc2944982d078b8e33b088840068976 (patch)
tree41109287d7e143da29b4bc8742040582af17d870 /include
parentc71099acce933455123ee505cc75964610a209ad (diff)
[NET]: Protocol Independant Policy Routing Rules Framework
Derived from net/ipv/fib_rules.c Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/fib_rules.h60
-rw-r--r--include/net/fib_rules.h90
2 files changed, 150 insertions, 0 deletions
diff --git a/include/linux/fib_rules.h b/include/linux/fib_rules.h
new file mode 100644
index 000000000000..5e503f0ca6e4
--- /dev/null
+++ b/include/linux/fib_rules.h
@@ -0,0 +1,60 @@
1#ifndef __LINUX_FIB_RULES_H
2#define __LINUX_FIB_RULES_H
3
4#include <linux/types.h>
5#include <linux/rtnetlink.h>
6
7/* rule is permanent, and cannot be deleted */
8#define FIB_RULE_PERMANENT 1
9
10struct fib_rule_hdr
11{
12 __u8 family;
13 __u8 dst_len;
14 __u8 src_len;
15 __u8 tos;
16
17 __u8 table;
18 __u8 res1; /* reserved */
19 __u8 res2; /* reserved */
20 __u8 action;
21
22 __u32 flags;
23};
24
25enum
26{
27 FRA_UNSPEC,
28 FRA_DST, /* destination address */
29 FRA_SRC, /* source address */
30 FRA_IFNAME, /* interface name */
31 FRA_UNUSED1,
32 FRA_UNUSED2,
33 FRA_PRIORITY, /* priority/preference */
34 FRA_UNUSED3,
35 FRA_UNUSED4,
36 FRA_UNUSED5,
37 FRA_FWMARK, /* netfilter mark (IPv4) */
38 FRA_FLOW, /* flow/class id */
39 __FRA_MAX
40};
41
42#define FRA_MAX (__FRA_MAX - 1)
43
44enum
45{
46 FR_ACT_UNSPEC,
47 FR_ACT_TO_TBL, /* Pass to fixed table */
48 FR_ACT_RES1,
49 FR_ACT_RES2,
50 FR_ACT_RES3,
51 FR_ACT_RES4,
52 FR_ACT_BLACKHOLE, /* Drop without notification */
53 FR_ACT_UNREACHABLE, /* Drop with ENETUNREACH */
54 FR_ACT_PROHIBIT, /* Drop with EACCES */
55 __FR_ACT_MAX,
56};
57
58#define FR_ACT_MAX (__FR_ACT_MAX - 1)
59
60#endif
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
new file mode 100644
index 000000000000..61375d9e53f8
--- /dev/null
+++ b/include/net/fib_rules.h
@@ -0,0 +1,90 @@
1#ifndef __NET_FIB_RULES_H
2#define __NET_FIB_RULES_H
3
4#include <linux/types.h>
5#include <linux/netdevice.h>
6#include <linux/fib_rules.h>
7#include <net/flow.h>
8#include <net/netlink.h>
9
10struct fib_rule
11{
12 struct list_head list;
13 atomic_t refcnt;
14 int ifindex;
15 char ifname[IFNAMSIZ];
16 u32 pref;
17 u32 flags;
18 u32 table;
19 u8 action;
20 struct rcu_head rcu;
21};
22
23struct fib_lookup_arg
24{
25 void *lookup_ptr;
26 void *result;
27 struct fib_rule *rule;
28};
29
30struct fib_rules_ops
31{
32 int family;
33 struct list_head list;
34 int rule_size;
35
36 int (*action)(struct fib_rule *,
37 struct flowi *, int,
38 struct fib_lookup_arg *);
39 int (*match)(struct fib_rule *,
40 struct flowi *, int);
41 int (*configure)(struct fib_rule *,
42 struct sk_buff *,
43 struct nlmsghdr *,
44 struct fib_rule_hdr *,
45 struct nlattr **);
46 int (*compare)(struct fib_rule *,
47 struct fib_rule_hdr *,
48 struct nlattr **);
49 int (*fill)(struct fib_rule *, struct sk_buff *,
50 struct nlmsghdr *,
51 struct fib_rule_hdr *);
52 u32 (*default_pref)(void);
53
54 int nlgroup;
55 struct nla_policy *policy;
56 struct list_head *rules_list;
57 struct module *owner;
58};
59
60static inline void fib_rule_get(struct fib_rule *rule)
61{
62 atomic_inc(&rule->refcnt);
63}
64
65static inline void fib_rule_put_rcu(struct rcu_head *head)
66{
67 struct fib_rule *rule = container_of(head, struct fib_rule, rcu);
68 kfree(rule);
69}
70
71static inline void fib_rule_put(struct fib_rule *rule)
72{
73 if (atomic_dec_and_test(&rule->refcnt))
74 call_rcu(&rule->rcu, fib_rule_put_rcu);
75}
76
77extern int fib_rules_register(struct fib_rules_ops *);
78extern int fib_rules_unregister(struct fib_rules_ops *);
79
80extern int fib_rules_lookup(struct fib_rules_ops *,
81 struct flowi *, int flags,
82 struct fib_lookup_arg *);
83
84extern int fib_nl_newrule(struct sk_buff *,
85 struct nlmsghdr *, void *);
86extern int fib_nl_delrule(struct sk_buff *,
87 struct nlmsghdr *, void *);
88extern int fib_rules_dump(struct sk_buff *,
89 struct netlink_callback *, int);
90#endif