.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
---|
3 | 4 | * operating system. INET is implemented using the BSD Socket |
---|
.. | .. |
---|
7 | 8 | * |
---|
8 | 9 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
---|
9 | 10 | * Thomas Graf <tgraf@suug.ch> |
---|
10 | | - * |
---|
11 | | - * This program is free software; you can redistribute it and/or |
---|
12 | | - * modify it under the terms of the GNU General Public License |
---|
13 | | - * as published by the Free Software Foundation; either version |
---|
14 | | - * 2 of the License, or (at your option) any later version. |
---|
15 | 11 | * |
---|
16 | 12 | * Fixes: |
---|
17 | 13 | * Rani Assaf : local_rule cannot be deleted |
---|
.. | .. |
---|
31 | 27 | #include <net/route.h> |
---|
32 | 28 | #include <net/tcp.h> |
---|
33 | 29 | #include <net/ip_fib.h> |
---|
| 30 | +#include <net/nexthop.h> |
---|
34 | 31 | #include <net/fib_rules.h> |
---|
| 32 | +#include <linux/indirect_call_wrapper.h> |
---|
35 | 33 | |
---|
36 | 34 | struct fib4_rule { |
---|
37 | 35 | struct fib_rule common; |
---|
.. | .. |
---|
68 | 66 | } |
---|
69 | 67 | EXPORT_SYMBOL_GPL(fib4_rule_default); |
---|
70 | 68 | |
---|
71 | | -int fib4_rules_dump(struct net *net, struct notifier_block *nb) |
---|
| 69 | +int fib4_rules_dump(struct net *net, struct notifier_block *nb, |
---|
| 70 | + struct netlink_ext_ack *extack) |
---|
72 | 71 | { |
---|
73 | | - return fib_rules_dump(net, nb, AF_INET); |
---|
| 72 | + return fib_rules_dump(net, nb, AF_INET, extack); |
---|
74 | 73 | } |
---|
75 | 74 | |
---|
76 | 75 | unsigned int fib4_rules_seq_read(struct net *net) |
---|
.. | .. |
---|
105 | 104 | } |
---|
106 | 105 | EXPORT_SYMBOL_GPL(__fib_lookup); |
---|
107 | 106 | |
---|
108 | | -static int fib4_rule_action(struct fib_rule *rule, struct flowi *flp, |
---|
109 | | - int flags, struct fib_lookup_arg *arg) |
---|
| 107 | +INDIRECT_CALLABLE_SCOPE int fib4_rule_action(struct fib_rule *rule, |
---|
| 108 | + struct flowi *flp, int flags, |
---|
| 109 | + struct fib_lookup_arg *arg) |
---|
110 | 110 | { |
---|
111 | 111 | int err = -EAGAIN; |
---|
112 | 112 | struct fib_table *tbl; |
---|
.. | .. |
---|
140 | 140 | return err; |
---|
141 | 141 | } |
---|
142 | 142 | |
---|
143 | | -static bool fib4_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg) |
---|
| 143 | +INDIRECT_CALLABLE_SCOPE bool fib4_rule_suppress(struct fib_rule *rule, |
---|
| 144 | + int flags, |
---|
| 145 | + struct fib_lookup_arg *arg) |
---|
144 | 146 | { |
---|
145 | 147 | struct fib_result *result = (struct fib_result *) arg->result; |
---|
146 | 148 | struct net_device *dev = NULL; |
---|
147 | 149 | |
---|
148 | | - if (result->fi) |
---|
149 | | - dev = result->fi->fib_dev; |
---|
| 150 | + if (result->fi) { |
---|
| 151 | + struct fib_nh_common *nhc = fib_info_nhc(result->fi, 0); |
---|
| 152 | + |
---|
| 153 | + dev = nhc->nhc_dev; |
---|
| 154 | + } |
---|
150 | 155 | |
---|
151 | 156 | /* do not accept result if the route does |
---|
152 | 157 | * not meet the required prefix length |
---|
.. | .. |
---|
168 | 173 | return true; |
---|
169 | 174 | } |
---|
170 | 175 | |
---|
171 | | -static int fib4_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) |
---|
| 176 | +INDIRECT_CALLABLE_SCOPE int fib4_rule_match(struct fib_rule *rule, |
---|
| 177 | + struct flowi *fl, int flags) |
---|
172 | 178 | { |
---|
173 | 179 | struct fib4_rule *r = (struct fib4_rule *) rule; |
---|
174 | 180 | struct flowi4 *fl4 = &fl->u.ip4; |
---|
.. | .. |
---|
198 | 204 | |
---|
199 | 205 | static struct fib_table *fib_empty_table(struct net *net) |
---|
200 | 206 | { |
---|
201 | | - u32 id; |
---|
| 207 | + u32 id = 1; |
---|
202 | 208 | |
---|
203 | | - for (id = 1; id <= RT_TABLE_MAX; id++) |
---|
| 209 | + while (1) { |
---|
204 | 210 | if (!fib_get_table(net, id)) |
---|
205 | 211 | return fib_new_table(net, id); |
---|
| 212 | + |
---|
| 213 | + if (id++ == RT_TABLE_MAX) |
---|
| 214 | + break; |
---|
| 215 | + } |
---|
206 | 216 | return NULL; |
---|
207 | 217 | } |
---|
208 | 218 | |
---|
.. | .. |
---|
254 | 264 | if (tb[FRA_FLOW]) { |
---|
255 | 265 | rule4->tclassid = nla_get_u32(tb[FRA_FLOW]); |
---|
256 | 266 | if (rule4->tclassid) |
---|
257 | | - net->ipv4.fib_num_tclassid_users++; |
---|
| 267 | + atomic_inc(&net->ipv4.fib_num_tclassid_users); |
---|
258 | 268 | } |
---|
259 | 269 | #endif |
---|
260 | 270 | |
---|
.. | .. |
---|
286 | 296 | |
---|
287 | 297 | #ifdef CONFIG_IP_ROUTE_CLASSID |
---|
288 | 298 | if (((struct fib4_rule *)rule)->tclassid) |
---|
289 | | - net->ipv4.fib_num_tclassid_users--; |
---|
| 299 | + atomic_dec(&net->ipv4.fib_num_tclassid_users); |
---|
290 | 300 | #endif |
---|
291 | 301 | net->ipv4.fib_has_custom_rules = true; |
---|
292 | 302 | |
---|