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
];
29 struct fib_rule
*rule
;
35 struct list_head list
;
39 int (*action
)(struct fib_rule
*,
41 struct fib_lookup_arg
*);
42 int (*match
)(struct fib_rule
*,
44 int (*configure
)(struct fib_rule
*,
47 struct fib_rule_hdr
*,
49 int (*compare
)(struct fib_rule
*,
50 struct fib_rule_hdr
*,
52 int (*fill
)(struct fib_rule
*, struct sk_buff
*,
54 struct fib_rule_hdr
*);
55 u32 (*default_pref
)(void);
56 size_t (*nlmsg_payload
)(struct fib_rule
*);
59 struct nla_policy
*policy
;
60 struct list_head
*rules_list
;
64 #define FRA_GENERIC_POLICY \
65 [FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, \
66 [FRA_PRIORITY] = { .type = NLA_U32 }, \
67 [FRA_FWMARK] = { .type = NLA_U32 }, \
68 [FRA_FWMASK] = { .type = NLA_U32 }, \
69 [FRA_TABLE] = { .type = NLA_U32 }
71 static inline void fib_rule_get(struct fib_rule
*rule
)
73 atomic_inc(&rule
->refcnt
);
76 static inline void fib_rule_put_rcu(struct rcu_head
*head
)
78 struct fib_rule
*rule
= container_of(head
, struct fib_rule
, rcu
);
82 static inline void fib_rule_put(struct fib_rule
*rule
)
84 if (atomic_dec_and_test(&rule
->refcnt
))
85 call_rcu(&rule
->rcu
, fib_rule_put_rcu
);
88 static inline u32
frh_get_table(struct fib_rule_hdr
*frh
, struct nlattr
**nla
)
91 return nla_get_u32(nla
[FRA_TABLE
]);
95 extern int fib_rules_register(struct fib_rules_ops
*);
96 extern int fib_rules_unregister(struct fib_rules_ops
*);
98 extern int fib_rules_lookup(struct fib_rules_ops
*,
99 struct flowi
*, int flags
,
100 struct fib_lookup_arg
*);
102 extern int fib_nl_newrule(struct sk_buff
*,
103 struct nlmsghdr
*, void *);
104 extern int fib_nl_delrule(struct sk_buff
*,
105 struct nlmsghdr
*, void *);
106 extern int fib_rules_dump(struct sk_buff
*,
107 struct netlink_callback
*, int);