• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Based on net/ipv4/fib_rules.c
4  * Authors:	Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
5  *		Thomas Graf <tgraf@suug.ch>
6  *
7  * Fixes:
8  *		Rani Assaf	:	local_rule cannot be deleted
9  *		Marc Boucher	:	routing by fwmark
10  *
11  * Based on net/ipv6/fib6_rules.c
12  * Copyright (C)2003-2006 Helsinki University of Technology
13  * Copyright (C)2003-2006 USAGI/WIDE Project
14  *
15  * Authors
16  *	Thomas Graf		<tgraf@suug.ch>
17  *	Ville Nuorvala		<vnuorval@tcs.hut.fi>
18  *
19  * NewIP Routing Policy Rules
20  */
21 #define pr_fmt(fmt) KBUILD_MODNAME ": [%s:%d] " fmt, __func__, __LINE__
22 
23 #include <net/nip_fib.h>
24 #include <linux/netdevice.h>
25 #include <linux/notifier.h>
26 #include <linux/export.h>
27 #include "tcp_nip_parameter.h"
28 
nip_fib_rule_lookup(struct net * net,struct flow_nip * fln,int flags,int * tbl_type,nip_pol_lookup_t lookup)29 struct dst_entry *nip_fib_rule_lookup(struct net *net, struct flow_nip *fln,
30 				      int flags, int *tbl_type, nip_pol_lookup_t lookup)
31 {
32 	struct nip_rt_info *rt;
33 
34 	rt = lookup(net, net->newip.nip_fib_local_tbl, fln, flags);
35 	if (rt != net->newip.nip_null_entry) {
36 		*tbl_type = (int)RT_TABLE_LOCAL;
37 		return &rt->dst;
38 	}
39 	nip_rt_put(rt);
40 	rt = lookup(net, net->newip.nip_fib_main_tbl, fln, flags);
41 	if (rt != net->newip.nip_null_entry) {
42 		*tbl_type = (int)RT_TABLE_MAIN;
43 		return &rt->dst;
44 	}
45 	nip_rt_put(rt);
46 
47 	dst_hold(&net->newip.nip_null_entry->dst);
48 	*tbl_type = (int)RT_TABLE_MAX;
49 	return &net->newip.nip_null_entry->dst;
50 }
51