1 #ifndef __NET_FIB_RULES_H
2 #define __NET_FIB_RULES_H
4 #include <linux/types.h>
5 #include <linux/netdevice.h>
6 #include <linux/fib_rules.h>
8 #include <net/netlink.h>
12 struct list_head list
;
15 char ifname
[IFNAMSIZ
];
27 struct fib_rule
*rule
;
33 struct list_head list
;
36 int (*action
)(struct fib_rule
*,
38 struct fib_lookup_arg
*);
39 int (*match
)(struct fib_rule
*,
41 int (*configure
)(struct fib_rule
*,
44 struct fib_rule_hdr
*,
46 int (*compare
)(struct fib_rule
*,
47 struct fib_rule_hdr
*,
49 int (*fill
)(struct fib_rule
*, struct sk_buff
*,
51 struct fib_rule_hdr
*);
52 u32 (*default_pref
)(void);
55 struct nla_policy
*policy
;
56 struct list_head
*rules_list
;
60 static inline void fib_rule_get(struct fib_rule
*rule
)
62 atomic_inc(&rule
->refcnt
);
65 static inline void fib_rule_put_rcu(struct rcu_head
*head
)
67 struct fib_rule
*rule
= container_of(head
, struct fib_rule
, rcu
);
71 static inline void fib_rule_put(struct fib_rule
*rule
)
73 if (atomic_dec_and_test(&rule
->refcnt
))
74 call_rcu(&rule
->rcu
, fib_rule_put_rcu
);
77 static inline u32
frh_get_table(struct fib_rule_hdr
*frh
, struct nlattr
**nla
)
80 return nla_get_u32(nla
[FRA_TABLE
]);
84 extern int fib_rules_register(struct fib_rules_ops
*);
85 extern int fib_rules_unregister(struct fib_rules_ops
*);
87 extern int fib_rules_lookup(struct fib_rules_ops
*,
88 struct flowi
*, int flags
,
89 struct fib_lookup_arg
*);
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);