hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/net/l3mdev.h
....@@ -1,18 +1,24 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * include/net/l3mdev.h - L3 master device API
34 * Copyright (c) 2015 Cumulus Networks
45 * 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.
106 */
117 #ifndef _NET_L3MDEV_H_
128 #define _NET_L3MDEV_H_
139
1410 #include <net/dst.h>
1511 #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);
1622
1723 /**
1824 * struct l3mdev_ops - l3mdev operations
....@@ -40,6 +46,15 @@
4046 };
4147
4248 #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);
4358
4459 int l3mdev_fib_rule_match(struct net *net, struct flowi *fl,
4560 struct fib_lookup_arg *arg);
....@@ -99,6 +114,17 @@
99114 master = NULL;
100115
101116 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;
102128 }
103129
104130 u32 l3mdev_fib_table_rcu(const struct net_device *dev);
....@@ -209,6 +235,17 @@
209235 }
210236
211237 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
212249 struct net_device *l3mdev_master_dev_rcu(const struct net_device *dev)
213250 {
214251 return NULL;
....@@ -263,6 +300,26 @@
263300 }
264301
265302 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
266323 int l3mdev_fib_rule_match(struct net *net, struct flowi *fl,
267324 struct fib_lookup_arg *arg)
268325 {