.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * include/net/l3mdev.h - L3 master device API |
---|
3 | 4 | * Copyright (c) 2015 Cumulus Networks |
---|
4 | 5 | * Copyright (c) 2015 David Ahern <dsa@cumulusnetworks.com> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
9 | | - * (at your option) any later version. |
---|
10 | 6 | */ |
---|
11 | 7 | #ifndef _NET_L3MDEV_H_ |
---|
12 | 8 | #define _NET_L3MDEV_H_ |
---|
13 | 9 | |
---|
14 | 10 | #include <net/dst.h> |
---|
15 | 11 | #include <net/fib_rules.h> |
---|
| 12 | + |
---|
| 13 | +enum l3mdev_type { |
---|
| 14 | + L3MDEV_TYPE_UNSPEC, |
---|
| 15 | + L3MDEV_TYPE_VRF, |
---|
| 16 | + __L3MDEV_TYPE_MAX |
---|
| 17 | +}; |
---|
| 18 | + |
---|
| 19 | +#define L3MDEV_TYPE_MAX (__L3MDEV_TYPE_MAX - 1) |
---|
| 20 | + |
---|
| 21 | +typedef int (*lookup_by_table_id_t)(struct net *net, u32 table_d); |
---|
16 | 22 | |
---|
17 | 23 | /** |
---|
18 | 24 | * struct l3mdev_ops - l3mdev operations |
---|
.. | .. |
---|
40 | 46 | }; |
---|
41 | 47 | |
---|
42 | 48 | #ifdef CONFIG_NET_L3_MASTER_DEV |
---|
| 49 | + |
---|
| 50 | +int l3mdev_table_lookup_register(enum l3mdev_type l3type, |
---|
| 51 | + lookup_by_table_id_t fn); |
---|
| 52 | + |
---|
| 53 | +void l3mdev_table_lookup_unregister(enum l3mdev_type l3type, |
---|
| 54 | + lookup_by_table_id_t fn); |
---|
| 55 | + |
---|
| 56 | +int l3mdev_ifindex_lookup_by_table_id(enum l3mdev_type l3type, struct net *net, |
---|
| 57 | + u32 table_id); |
---|
43 | 58 | |
---|
44 | 59 | int l3mdev_fib_rule_match(struct net *net, struct flowi *fl, |
---|
45 | 60 | struct fib_lookup_arg *arg); |
---|
.. | .. |
---|
99 | 114 | master = NULL; |
---|
100 | 115 | |
---|
101 | 116 | return master; |
---|
| 117 | +} |
---|
| 118 | + |
---|
| 119 | +int l3mdev_master_upper_ifindex_by_index_rcu(struct net *net, int ifindex); |
---|
| 120 | +static inline |
---|
| 121 | +int l3mdev_master_upper_ifindex_by_index(struct net *net, int ifindex) |
---|
| 122 | +{ |
---|
| 123 | + rcu_read_lock(); |
---|
| 124 | + ifindex = l3mdev_master_upper_ifindex_by_index_rcu(net, ifindex); |
---|
| 125 | + rcu_read_unlock(); |
---|
| 126 | + |
---|
| 127 | + return ifindex; |
---|
102 | 128 | } |
---|
103 | 129 | |
---|
104 | 130 | u32 l3mdev_fib_table_rcu(const struct net_device *dev); |
---|
.. | .. |
---|
209 | 235 | } |
---|
210 | 236 | |
---|
211 | 237 | static inline |
---|
| 238 | +int l3mdev_master_upper_ifindex_by_index_rcu(struct net *net, int ifindex) |
---|
| 239 | +{ |
---|
| 240 | + return 0; |
---|
| 241 | +} |
---|
| 242 | +static inline |
---|
| 243 | +int l3mdev_master_upper_ifindex_by_index(struct net *net, int ifindex) |
---|
| 244 | +{ |
---|
| 245 | + return 0; |
---|
| 246 | +} |
---|
| 247 | + |
---|
| 248 | +static inline |
---|
212 | 249 | struct net_device *l3mdev_master_dev_rcu(const struct net_device *dev) |
---|
213 | 250 | { |
---|
214 | 251 | return NULL; |
---|
.. | .. |
---|
263 | 300 | } |
---|
264 | 301 | |
---|
265 | 302 | static inline |
---|
| 303 | +int l3mdev_table_lookup_register(enum l3mdev_type l3type, |
---|
| 304 | + lookup_by_table_id_t fn) |
---|
| 305 | +{ |
---|
| 306 | + return -EOPNOTSUPP; |
---|
| 307 | +} |
---|
| 308 | + |
---|
| 309 | +static inline |
---|
| 310 | +void l3mdev_table_lookup_unregister(enum l3mdev_type l3type, |
---|
| 311 | + lookup_by_table_id_t fn) |
---|
| 312 | +{ |
---|
| 313 | +} |
---|
| 314 | + |
---|
| 315 | +static inline |
---|
| 316 | +int l3mdev_ifindex_lookup_by_table_id(enum l3mdev_type l3type, struct net *net, |
---|
| 317 | + u32 table_id) |
---|
| 318 | +{ |
---|
| 319 | + return -ENODEV; |
---|
| 320 | +} |
---|
| 321 | + |
---|
| 322 | +static inline |
---|
266 | 323 | int l3mdev_fib_rule_match(struct net *net, struct flowi *fl, |
---|
267 | 324 | struct fib_lookup_arg *arg) |
---|
268 | 325 | { |
---|