21 #include <linux/types.h>
22 #include <linux/kernel.h>
23 #include <linux/netdevice.h>
24 #include <linux/netlink.h>
27 #include <linux/list.h>
29 #include <linux/export.h>
45 #ifdef CONFIG_IP_ROUTE_CLASSID
59 #ifdef CONFIG_IP_ROUTE_CLASSID
105 static int fib4_rule_match(
struct fib_rule *rule,
struct flowi *
fl,
int flags)
116 if (r->
tos && (r->
tos != fl4->flowi4_tos))
127 if (fib_get_table(net,
id) ==
NULL)
128 return fib_new_table(net,
id);
141 struct net *net = sock_net(skb->
sk);
152 table = fib_empty_table(net);
168 #ifdef CONFIG_IP_ROUTE_CLASSID
170 rule4->tclassid = nla_get_u32(tb[FRA_FLOW]);
172 net->
ipv4.fib_num_tclassid_users++;
182 net->
ipv4.fib_has_custom_rules =
true;
188 static void fib4_rule_delete(
struct fib_rule *rule)
190 struct net *net = rule->
fr_net;
191 #ifdef CONFIG_IP_ROUTE_CLASSID
195 net->
ipv4.fib_num_tclassid_users--;
197 net->
ipv4.fib_has_custom_rules =
true;
211 if (frh->
tos && (rule4->
tos != frh->
tos))
214 #ifdef CONFIG_IP_ROUTE_CLASSID
215 if (tb[FRA_FLOW] && (rule4->tclassid != nla_get_u32(tb[FRA_FLOW])))
240 nla_put_be32(skb, FRA_SRC, rule4->
src)))
241 goto nla_put_failure;
242 #ifdef CONFIG_IP_ROUTE_CLASSID
243 if (rule4->tclassid &&
244 nla_put_u32(skb, FRA_FLOW, rule4->tclassid))
245 goto nla_put_failure;
253 static size_t fib4_rule_nlmsg_payload(
struct fib_rule *rule)
255 return nla_total_size(4)
269 .
action = fib4_rule_action,
270 .
match = fib4_rule_match,
271 .configure = fib4_rule_configure,
272 .
delete = fib4_rule_delete,
273 .compare = fib4_rule_compare,
274 .
fill = fib4_rule_fill,
276 .nlmsg_payload = fib4_rule_nlmsg_payload,
279 .policy = fib4_rule_policy,
308 err = fib_default_rules_init(ops);
311 net->
ipv4.rules_ops = ops;
312 net->
ipv4.fib_has_custom_rules =
false;