diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-09-24 01:52:47 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-09-24 01:52:47 -0400 |
commit | 23930fa1cebfea6f79881c588ccd1b0781e49e3f (patch) | |
tree | 36d29e3f83661c4f5f45b6f74ac0d5f9886867a8 /include/net/fib_rules.h | |
parent | 36b35a5be0e4b406acd816e2122d153e875105be (diff) | |
parent | 4f5537de7c1531398e84e18a24f667e49cc94208 (diff) |
Merge branch 'master' into upstream
Diffstat (limited to 'include/net/fib_rules.h')
-rw-r--r-- | include/net/fib_rules.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h new file mode 100644 index 000000000000..8e2f473d3e82 --- /dev/null +++ b/include/net/fib_rules.h | |||
@@ -0,0 +1,97 @@ | |||
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 | |||
10 | struct 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 | |||
23 | struct fib_lookup_arg | ||
24 | { | ||
25 | void *lookup_ptr; | ||
26 | void *result; | ||
27 | struct fib_rule *rule; | ||
28 | }; | ||
29 | |||
30 | struct 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 | |||
60 | static inline void fib_rule_get(struct fib_rule *rule) | ||
61 | { | ||
62 | atomic_inc(&rule->refcnt); | ||
63 | } | ||
64 | |||
65 | static 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 | |||
71 | static 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 | |||
77 | static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla) | ||
78 | { | ||
79 | if (nla[FRA_TABLE]) | ||
80 | return nla_get_u32(nla[FRA_TABLE]); | ||
81 | return frh->table; | ||
82 | } | ||
83 | |||
84 | extern int fib_rules_register(struct fib_rules_ops *); | ||
85 | extern int fib_rules_unregister(struct fib_rules_ops *); | ||
86 | |||
87 | extern int fib_rules_lookup(struct fib_rules_ops *, | ||
88 | struct flowi *, int flags, | ||
89 | struct fib_lookup_arg *); | ||
90 | |||
91 | extern int fib_nl_newrule(struct sk_buff *, | ||
92 | struct nlmsghdr *, void *); | ||
93 | extern int fib_nl_delrule(struct sk_buff *, | ||
94 | struct nlmsghdr *, void *); | ||
95 | extern int fib_rules_dump(struct sk_buff *, | ||
96 | struct netlink_callback *, int); | ||
97 | #endif | ||