xref: /openbmc/linux/net/ipv4/fib_rules.c (revision 81f7bf6cbaca02c034b0393c51fc22b29cba20f7)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * INET		An implementation of the TCP/IP protocol suite for the LINUX
31da177e4SLinus Torvalds  *		operating system.  INET is implemented using the  BSD Socket
41da177e4SLinus Torvalds  *		interface as the means of communication with the user level.
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  *		IPv4 Forwarding Information Base: policy rules.
71da177e4SLinus Torvalds  *
81da177e4SLinus Torvalds  * Authors:	Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
9e1ef4bf2SThomas Graf  * 		Thomas Graf <tgraf@suug.ch>
101da177e4SLinus Torvalds  *
111da177e4SLinus Torvalds  *		This program is free software; you can redistribute it and/or
121da177e4SLinus Torvalds  *		modify it under the terms of the GNU General Public License
131da177e4SLinus Torvalds  *		as published by the Free Software Foundation; either version
141da177e4SLinus Torvalds  *		2 of the License, or (at your option) any later version.
151da177e4SLinus Torvalds  *
161da177e4SLinus Torvalds  * Fixes:
171da177e4SLinus Torvalds  * 		Rani Assaf	:	local_rule cannot be deleted
181da177e4SLinus Torvalds  *		Marc Boucher	:	routing by fwmark
191da177e4SLinus Torvalds  */
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #include <linux/types.h>
221da177e4SLinus Torvalds #include <linux/kernel.h>
231da177e4SLinus Torvalds #include <linux/netdevice.h>
241da177e4SLinus Torvalds #include <linux/netlink.h>
25e1ef4bf2SThomas Graf #include <linux/inetdevice.h>
261da177e4SLinus Torvalds #include <linux/init.h>
277b204afdSRobert Olsson #include <linux/list.h>
287b204afdSRobert Olsson #include <linux/rcupdate.h>
291da177e4SLinus Torvalds #include <net/ip.h>
301da177e4SLinus Torvalds #include <net/route.h>
311da177e4SLinus Torvalds #include <net/tcp.h>
321da177e4SLinus Torvalds #include <net/ip_fib.h>
33e1ef4bf2SThomas Graf #include <net/fib_rules.h>
341da177e4SLinus Torvalds 
35e1ef4bf2SThomas Graf static struct fib_rules_ops fib4_rules_ops;
361da177e4SLinus Torvalds 
37e1ef4bf2SThomas Graf struct fib4_rule
381da177e4SLinus Torvalds {
39e1ef4bf2SThomas Graf 	struct fib_rule		common;
40e1ef4bf2SThomas Graf 	u8			dst_len;
41e1ef4bf2SThomas Graf 	u8			src_len;
42e1ef4bf2SThomas Graf 	u8			tos;
43*81f7bf6cSAl Viro 	__be32			src;
44*81f7bf6cSAl Viro 	__be32			srcmask;
45*81f7bf6cSAl Viro 	__be32			dst;
46*81f7bf6cSAl Viro 	__be32			dstmask;
471da177e4SLinus Torvalds #ifdef CONFIG_IP_ROUTE_FWMARK
48e1ef4bf2SThomas Graf 	u32			fwmark;
49bbfb39cbSPatrick McHardy 	u32			fwmask;
501da177e4SLinus Torvalds #endif
511da177e4SLinus Torvalds #ifdef CONFIG_NET_CLS_ROUTE
52e1ef4bf2SThomas Graf 	u32			tclassid;
531da177e4SLinus Torvalds #endif
541da177e4SLinus Torvalds };
551da177e4SLinus Torvalds 
56e1ef4bf2SThomas Graf static struct fib4_rule default_rule = {
57e1ef4bf2SThomas Graf 	.common = {
58e1ef4bf2SThomas Graf 		.refcnt =	ATOMIC_INIT(2),
59e1ef4bf2SThomas Graf 		.pref =		0x7FFF,
60e1ef4bf2SThomas Graf 		.table =	RT_TABLE_DEFAULT,
61e1ef4bf2SThomas Graf 		.action =	FR_ACT_TO_TBL,
62e1ef4bf2SThomas Graf 	},
631da177e4SLinus Torvalds };
641da177e4SLinus Torvalds 
65e1ef4bf2SThomas Graf static struct fib4_rule main_rule = {
66e1ef4bf2SThomas Graf 	.common = {
67e1ef4bf2SThomas Graf 		.refcnt =	ATOMIC_INIT(2),
68e1ef4bf2SThomas Graf 		.pref =		0x7FFE,
69e1ef4bf2SThomas Graf 		.table =	RT_TABLE_MAIN,
70e1ef4bf2SThomas Graf 		.action =	FR_ACT_TO_TBL,
71e1ef4bf2SThomas Graf 	},
721da177e4SLinus Torvalds };
731da177e4SLinus Torvalds 
74e1ef4bf2SThomas Graf static struct fib4_rule local_rule = {
75e1ef4bf2SThomas Graf 	.common = {
76e1ef4bf2SThomas Graf 		.refcnt =	ATOMIC_INIT(2),
77e1ef4bf2SThomas Graf 		.table =	RT_TABLE_LOCAL,
78e1ef4bf2SThomas Graf 		.action =	FR_ACT_TO_TBL,
79e1ef4bf2SThomas Graf 		.flags =	FIB_RULE_PERMANENT,
80e1ef4bf2SThomas Graf 	},
811da177e4SLinus Torvalds };
821da177e4SLinus Torvalds 
83e1ef4bf2SThomas Graf static LIST_HEAD(fib4_rules);
847b204afdSRobert Olsson 
85e1ef4bf2SThomas Graf #ifdef CONFIG_NET_CLS_ROUTE
86e1ef4bf2SThomas Graf u32 fib_rules_tclass(struct fib_result *res)
871da177e4SLinus Torvalds {
88e1ef4bf2SThomas Graf 	return res->r ? ((struct fib4_rule *) res->r)->tclassid : 0;
89e1ef4bf2SThomas Graf }
901da177e4SLinus Torvalds #endif
911da177e4SLinus Torvalds 
92e1ef4bf2SThomas Graf int fib_lookup(struct flowi *flp, struct fib_result *res)
93e1ef4bf2SThomas Graf {
94e1ef4bf2SThomas Graf 	struct fib_lookup_arg arg = {
95e1ef4bf2SThomas Graf 		.result = res,
96e1ef4bf2SThomas Graf 	};
97e1ef4bf2SThomas Graf 	int err;
98e1ef4bf2SThomas Graf 
99e1ef4bf2SThomas Graf 	err = fib_rules_lookup(&fib4_rules_ops, flp, 0, &arg);
100e1ef4bf2SThomas Graf 	res->r = arg.rule;
101e1ef4bf2SThomas Graf 
1021da177e4SLinus Torvalds 	return err;
1031da177e4SLinus Torvalds }
1041da177e4SLinus Torvalds 
1058ce11e6aSAdrian Bunk static int fib4_rule_action(struct fib_rule *rule, struct flowi *flp,
1068ce11e6aSAdrian Bunk 			    int flags, struct fib_lookup_arg *arg)
107e1ef4bf2SThomas Graf {
108e1ef4bf2SThomas Graf 	int err = -EAGAIN;
109e1ef4bf2SThomas Graf 	struct fib_table *tbl;
110e1ef4bf2SThomas Graf 
111e1ef4bf2SThomas Graf 	switch (rule->action) {
112e1ef4bf2SThomas Graf 	case FR_ACT_TO_TBL:
113e1ef4bf2SThomas Graf 		break;
114e1ef4bf2SThomas Graf 
115e1ef4bf2SThomas Graf 	case FR_ACT_UNREACHABLE:
116e1ef4bf2SThomas Graf 		err = -ENETUNREACH;
117e1ef4bf2SThomas Graf 		goto errout;
118e1ef4bf2SThomas Graf 
119e1ef4bf2SThomas Graf 	case FR_ACT_PROHIBIT:
120e1ef4bf2SThomas Graf 		err = -EACCES;
121e1ef4bf2SThomas Graf 		goto errout;
122e1ef4bf2SThomas Graf 
123e1ef4bf2SThomas Graf 	case FR_ACT_BLACKHOLE:
124e1ef4bf2SThomas Graf 	default:
125e1ef4bf2SThomas Graf 		err = -EINVAL;
126e1ef4bf2SThomas Graf 		goto errout;
127e1ef4bf2SThomas Graf 	}
128e1ef4bf2SThomas Graf 
129e1ef4bf2SThomas Graf 	if ((tbl = fib_get_table(rule->table)) == NULL)
130e1ef4bf2SThomas Graf 		goto errout;
131e1ef4bf2SThomas Graf 
132e1ef4bf2SThomas Graf 	err = tbl->tb_lookup(tbl, flp, (struct fib_result *) arg->result);
133e1ef4bf2SThomas Graf 	if (err > 0)
134e1ef4bf2SThomas Graf 		err = -EAGAIN;
135e1ef4bf2SThomas Graf errout:
136e1ef4bf2SThomas Graf 	return err;
137e1ef4bf2SThomas Graf }
138e1ef4bf2SThomas Graf 
139e1ef4bf2SThomas Graf 
140e1ef4bf2SThomas Graf void fib_select_default(const struct flowi *flp, struct fib_result *res)
141e1ef4bf2SThomas Graf {
142e1ef4bf2SThomas Graf 	if (res->r && res->r->action == FR_ACT_TO_TBL &&
143e1ef4bf2SThomas Graf 	    FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) {
144e1ef4bf2SThomas Graf 		struct fib_table *tb;
145e1ef4bf2SThomas Graf 		if ((tb = fib_get_table(res->r->table)) != NULL)
146e1ef4bf2SThomas Graf 			tb->tb_select_default(tb, flp, res);
147e1ef4bf2SThomas Graf 	}
148e1ef4bf2SThomas Graf }
149e1ef4bf2SThomas Graf 
150e1ef4bf2SThomas Graf static int fib4_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
151e1ef4bf2SThomas Graf {
152e1ef4bf2SThomas Graf 	struct fib4_rule *r = (struct fib4_rule *) rule;
153*81f7bf6cSAl Viro 	__be32 daddr = fl->fl4_dst;
154*81f7bf6cSAl Viro 	__be32 saddr = fl->fl4_src;
155e1ef4bf2SThomas Graf 
156e1ef4bf2SThomas Graf 	if (((saddr ^ r->src) & r->srcmask) ||
157e1ef4bf2SThomas Graf 	    ((daddr ^ r->dst) & r->dstmask))
158e1ef4bf2SThomas Graf 		return 0;
159e1ef4bf2SThomas Graf 
160e1ef4bf2SThomas Graf 	if (r->tos && (r->tos != fl->fl4_tos))
161e1ef4bf2SThomas Graf 		return 0;
162e1ef4bf2SThomas Graf 
163e1ef4bf2SThomas Graf #ifdef CONFIG_IP_ROUTE_FWMARK
164bbfb39cbSPatrick McHardy 	if ((r->fwmark ^ fl->fl4_fwmark) & r->fwmask)
165e1ef4bf2SThomas Graf 		return 0;
166e1ef4bf2SThomas Graf #endif
167e1ef4bf2SThomas Graf 
168e1ef4bf2SThomas Graf 	return 1;
169e1ef4bf2SThomas Graf }
1701da177e4SLinus Torvalds 
1711da177e4SLinus Torvalds static struct fib_table *fib_empty_table(void)
1721da177e4SLinus Torvalds {
1732dfe55b4SPatrick McHardy 	u32 id;
1741da177e4SLinus Torvalds 
1751da177e4SLinus Torvalds 	for (id = 1; id <= RT_TABLE_MAX; id++)
1761af5a8c4SPatrick McHardy 		if (fib_get_table(id) == NULL)
1771af5a8c4SPatrick McHardy 			return fib_new_table(id);
1781da177e4SLinus Torvalds 	return NULL;
1791da177e4SLinus Torvalds }
1801da177e4SLinus Torvalds 
181e1ef4bf2SThomas Graf static struct nla_policy fib4_rule_policy[FRA_MAX+1] __read_mostly = {
1825176f91eSThomas Graf 	[FRA_IFNAME]	= { .type = NLA_STRING, .len = IFNAMSIZ - 1 },
183e1ef4bf2SThomas Graf 	[FRA_PRIORITY]	= { .type = NLA_U32 },
184e1ef4bf2SThomas Graf 	[FRA_SRC]	= { .type = NLA_U32 },
185e1ef4bf2SThomas Graf 	[FRA_DST]	= { .type = NLA_U32 },
186e1ef4bf2SThomas Graf 	[FRA_FWMARK]	= { .type = NLA_U32 },
187bbfb39cbSPatrick McHardy 	[FRA_FWMASK]	= { .type = NLA_U32 },
188e1ef4bf2SThomas Graf 	[FRA_FLOW]	= { .type = NLA_U32 },
1899e762a4aSPatrick McHardy 	[FRA_TABLE]	= { .type = NLA_U32 },
1901da177e4SLinus Torvalds };
1911da177e4SLinus Torvalds 
192e1ef4bf2SThomas Graf static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
193e1ef4bf2SThomas Graf 			       struct nlmsghdr *nlh, struct fib_rule_hdr *frh,
194e1ef4bf2SThomas Graf 			       struct nlattr **tb)
1951da177e4SLinus Torvalds {
196e1ef4bf2SThomas Graf 	int err = -EINVAL;
197e1ef4bf2SThomas Graf 	struct fib4_rule *rule4 = (struct fib4_rule *) rule;
1981da177e4SLinus Torvalds 
199e1ef4bf2SThomas Graf 	if (frh->src_len > 32 || frh->dst_len > 32 ||
200e1ef4bf2SThomas Graf 	    (frh->tos & ~IPTOS_TOS_MASK))
201e1ef4bf2SThomas Graf 		goto errout;
202e1ef4bf2SThomas Graf 
203e1ef4bf2SThomas Graf 	if (rule->table == RT_TABLE_UNSPEC) {
204e1ef4bf2SThomas Graf 		if (rule->action == FR_ACT_TO_TBL) {
205e1ef4bf2SThomas Graf 			struct fib_table *table;
206e1ef4bf2SThomas Graf 
207e1ef4bf2SThomas Graf 			table = fib_empty_table();
208e1ef4bf2SThomas Graf 			if (table == NULL) {
209e1ef4bf2SThomas Graf 				err = -ENOBUFS;
210e1ef4bf2SThomas Graf 				goto errout;
211e1ef4bf2SThomas Graf 			}
212e1ef4bf2SThomas Graf 
213e1ef4bf2SThomas Graf 			rule->table = table->tb_id;
214e1ef4bf2SThomas Graf 		}
215e1ef4bf2SThomas Graf 	}
216e1ef4bf2SThomas Graf 
217e1ef4bf2SThomas Graf 	if (tb[FRA_SRC])
218e1ef4bf2SThomas Graf 		rule4->src = nla_get_u32(tb[FRA_SRC]);
219e1ef4bf2SThomas Graf 
220e1ef4bf2SThomas Graf 	if (tb[FRA_DST])
221e1ef4bf2SThomas Graf 		rule4->dst = nla_get_u32(tb[FRA_DST]);
222e1ef4bf2SThomas Graf 
2231da177e4SLinus Torvalds #ifdef CONFIG_IP_ROUTE_FWMARK
224bbfb39cbSPatrick McHardy 	if (tb[FRA_FWMARK]) {
225e1ef4bf2SThomas Graf 		rule4->fwmark = nla_get_u32(tb[FRA_FWMARK]);
226bbfb39cbSPatrick McHardy 		if (rule4->fwmark)
227bbfb39cbSPatrick McHardy 			/* compatibility: if the mark value is non-zero all bits
228bbfb39cbSPatrick McHardy 			 * are compared unless a mask is explicitly specified.
229bbfb39cbSPatrick McHardy 			 */
230bbfb39cbSPatrick McHardy 			rule4->fwmask = 0xFFFFFFFF;
231bbfb39cbSPatrick McHardy 	}
232bbfb39cbSPatrick McHardy 
233bbfb39cbSPatrick McHardy 	if (tb[FRA_FWMASK])
234bbfb39cbSPatrick McHardy 		rule4->fwmask = nla_get_u32(tb[FRA_FWMASK]);
2351da177e4SLinus Torvalds #endif
2361da177e4SLinus Torvalds 
2371da177e4SLinus Torvalds #ifdef CONFIG_NET_CLS_ROUTE
238e1ef4bf2SThomas Graf 	if (tb[FRA_FLOW])
239e1ef4bf2SThomas Graf 		rule4->tclassid = nla_get_u32(tb[FRA_FLOW]);
2401da177e4SLinus Torvalds #endif
2411da177e4SLinus Torvalds 
242e1ef4bf2SThomas Graf 	rule4->src_len = frh->src_len;
243e1ef4bf2SThomas Graf 	rule4->srcmask = inet_make_mask(rule4->src_len);
244e1ef4bf2SThomas Graf 	rule4->dst_len = frh->dst_len;
245e1ef4bf2SThomas Graf 	rule4->dstmask = inet_make_mask(rule4->dst_len);
246e1ef4bf2SThomas Graf 	rule4->tos = frh->tos;
247e1ef4bf2SThomas Graf 
248e1ef4bf2SThomas Graf 	err = 0;
249e1ef4bf2SThomas Graf errout:
250e1ef4bf2SThomas Graf 	return err;
2511da177e4SLinus Torvalds }
2521da177e4SLinus Torvalds 
253e1ef4bf2SThomas Graf static int fib4_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
254e1ef4bf2SThomas Graf 			     struct nlattr **tb)
255a5cdc030SPatrick McHardy {
256e1ef4bf2SThomas Graf 	struct fib4_rule *rule4 = (struct fib4_rule *) rule;
257a5cdc030SPatrick McHardy 
258e1ef4bf2SThomas Graf 	if (frh->src_len && (rule4->src_len != frh->src_len))
259e1ef4bf2SThomas Graf 		return 0;
260e1ef4bf2SThomas Graf 
261e1ef4bf2SThomas Graf 	if (frh->dst_len && (rule4->dst_len != frh->dst_len))
262e1ef4bf2SThomas Graf 		return 0;
263e1ef4bf2SThomas Graf 
264e1ef4bf2SThomas Graf 	if (frh->tos && (rule4->tos != frh->tos))
265e1ef4bf2SThomas Graf 		return 0;
266e1ef4bf2SThomas Graf 
267e1ef4bf2SThomas Graf #ifdef CONFIG_IP_ROUTE_FWMARK
268e1ef4bf2SThomas Graf 	if (tb[FRA_FWMARK] && (rule4->fwmark != nla_get_u32(tb[FRA_FWMARK])))
269e1ef4bf2SThomas Graf 		return 0;
270bbfb39cbSPatrick McHardy 
271bbfb39cbSPatrick McHardy 	if (tb[FRA_FWMASK] && (rule4->fwmask != nla_get_u32(tb[FRA_FWMASK])))
272bbfb39cbSPatrick McHardy 		return 0;
273e1ef4bf2SThomas Graf #endif
274e1ef4bf2SThomas Graf 
275e1ef4bf2SThomas Graf #ifdef CONFIG_NET_CLS_ROUTE
276e1ef4bf2SThomas Graf 	if (tb[FRA_FLOW] && (rule4->tclassid != nla_get_u32(tb[FRA_FLOW])))
277e1ef4bf2SThomas Graf 		return 0;
278e1ef4bf2SThomas Graf #endif
279e1ef4bf2SThomas Graf 
280e1ef4bf2SThomas Graf 	if (tb[FRA_SRC] && (rule4->src != nla_get_u32(tb[FRA_SRC])))
281e1ef4bf2SThomas Graf 		return 0;
282e1ef4bf2SThomas Graf 
283e1ef4bf2SThomas Graf 	if (tb[FRA_DST] && (rule4->dst != nla_get_u32(tb[FRA_DST])))
284e1ef4bf2SThomas Graf 		return 0;
285e1ef4bf2SThomas Graf 
286e1ef4bf2SThomas Graf 	return 1;
287a5cdc030SPatrick McHardy }
288a5cdc030SPatrick McHardy 
289e1ef4bf2SThomas Graf static int fib4_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
290e1ef4bf2SThomas Graf 			  struct nlmsghdr *nlh, struct fib_rule_hdr *frh)
2911da177e4SLinus Torvalds {
292e1ef4bf2SThomas Graf 	struct fib4_rule *rule4 = (struct fib4_rule *) rule;
2931da177e4SLinus Torvalds 
294e1ef4bf2SThomas Graf 	frh->family = AF_INET;
295e1ef4bf2SThomas Graf 	frh->dst_len = rule4->dst_len;
296e1ef4bf2SThomas Graf 	frh->src_len = rule4->src_len;
297e1ef4bf2SThomas Graf 	frh->tos = rule4->tos;
2981da177e4SLinus Torvalds 
299e1ef4bf2SThomas Graf #ifdef CONFIG_IP_ROUTE_FWMARK
300e1ef4bf2SThomas Graf 	if (rule4->fwmark)
301e1ef4bf2SThomas Graf 		NLA_PUT_U32(skb, FRA_FWMARK, rule4->fwmark);
302bbfb39cbSPatrick McHardy 
303bbfb39cbSPatrick McHardy 	if (rule4->fwmask || rule4->fwmark)
304bbfb39cbSPatrick McHardy 		NLA_PUT_U32(skb, FRA_FWMASK, rule4->fwmask);
305e1ef4bf2SThomas Graf #endif
306e1ef4bf2SThomas Graf 
307e1ef4bf2SThomas Graf 	if (rule4->dst_len)
308e1ef4bf2SThomas Graf 		NLA_PUT_U32(skb, FRA_DST, rule4->dst);
309e1ef4bf2SThomas Graf 
310e1ef4bf2SThomas Graf 	if (rule4->src_len)
311e1ef4bf2SThomas Graf 		NLA_PUT_U32(skb, FRA_SRC, rule4->src);
312e1ef4bf2SThomas Graf 
313e1ef4bf2SThomas Graf #ifdef CONFIG_NET_CLS_ROUTE
314e1ef4bf2SThomas Graf 	if (rule4->tclassid)
315e1ef4bf2SThomas Graf 		NLA_PUT_U32(skb, FRA_FLOW, rule4->tclassid);
316e1ef4bf2SThomas Graf #endif
317e1ef4bf2SThomas Graf 	return 0;
318e1ef4bf2SThomas Graf 
319e1ef4bf2SThomas Graf nla_put_failure:
320e1ef4bf2SThomas Graf 	return -ENOBUFS;
3211da177e4SLinus Torvalds }
3221da177e4SLinus Torvalds 
323e1ef4bf2SThomas Graf int fib4_rules_dump(struct sk_buff *skb, struct netlink_callback *cb)
3241da177e4SLinus Torvalds {
325e1ef4bf2SThomas Graf 	return fib_rules_dump(skb, cb, AF_INET);
326e1ef4bf2SThomas Graf }
327e1ef4bf2SThomas Graf 
328e1ef4bf2SThomas Graf static u32 fib4_rule_default_pref(void)
329e1ef4bf2SThomas Graf {
330e1ef4bf2SThomas Graf 	struct list_head *pos;
331e1ef4bf2SThomas Graf 	struct fib_rule *rule;
332e1ef4bf2SThomas Graf 
333e1ef4bf2SThomas Graf 	if (!list_empty(&fib4_rules)) {
334e1ef4bf2SThomas Graf 		pos = fib4_rules.next;
335e1ef4bf2SThomas Graf 		if (pos->next != &fib4_rules) {
336e1ef4bf2SThomas Graf 			rule = list_entry(pos->next, struct fib_rule, list);
337e1ef4bf2SThomas Graf 			if (rule->pref)
338e1ef4bf2SThomas Graf 				return rule->pref - 1;
339e1ef4bf2SThomas Graf 		}
340e1ef4bf2SThomas Graf 	}
341e1ef4bf2SThomas Graf 
342e1ef4bf2SThomas Graf 	return 0;
343e1ef4bf2SThomas Graf }
344e1ef4bf2SThomas Graf 
345e1ef4bf2SThomas Graf static struct fib_rules_ops fib4_rules_ops = {
346e1ef4bf2SThomas Graf 	.family		= AF_INET,
347e1ef4bf2SThomas Graf 	.rule_size	= sizeof(struct fib4_rule),
348e1ef4bf2SThomas Graf 	.action		= fib4_rule_action,
349e1ef4bf2SThomas Graf 	.match		= fib4_rule_match,
350e1ef4bf2SThomas Graf 	.configure	= fib4_rule_configure,
351e1ef4bf2SThomas Graf 	.compare	= fib4_rule_compare,
352e1ef4bf2SThomas Graf 	.fill		= fib4_rule_fill,
353e1ef4bf2SThomas Graf 	.default_pref	= fib4_rule_default_pref,
354e1ef4bf2SThomas Graf 	.nlgroup	= RTNLGRP_IPV4_RULE,
355e1ef4bf2SThomas Graf 	.policy		= fib4_rule_policy,
356e1ef4bf2SThomas Graf 	.rules_list	= &fib4_rules,
357e1ef4bf2SThomas Graf 	.owner		= THIS_MODULE,
358e1ef4bf2SThomas Graf };
359e1ef4bf2SThomas Graf 
360e1ef4bf2SThomas Graf void __init fib4_rules_init(void)
361e1ef4bf2SThomas Graf {
362e1ef4bf2SThomas Graf 	list_add_tail(&local_rule.common.list, &fib4_rules);
363e1ef4bf2SThomas Graf 	list_add_tail(&main_rule.common.list, &fib4_rules);
364e1ef4bf2SThomas Graf 	list_add_tail(&default_rule.common.list, &fib4_rules);
365e1ef4bf2SThomas Graf 
366e1ef4bf2SThomas Graf 	fib_rules_register(&fib4_rules_ops);
367e1ef4bf2SThomas Graf }
368