hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/include/net/route.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * INET An implementation of the TCP/IP protocol suite for the LINUX
34 * operating system. INET is implemented using the BSD Socket
....@@ -15,11 +16,6 @@
1516 * Alexey Kuznetsov: Major changes for new routing code.
1617 * Mike McLagan : Routing by source
1718 * Robert Olsson : Added rt_cache statistics
18
- *
19
- * This program is free software; you can redistribute it and/or
20
- * modify it under the terms of the GNU General Public License
21
- * as published by the Free Software Foundation; either version
22
- * 2 of the License, or (at your option) any later version.
2319 */
2420 #ifndef _ROUTE_H
2521 #define _ROUTE_H
....@@ -29,6 +25,8 @@
2925 #include <net/flow.h>
3026 #include <net/inet_sock.h>
3127 #include <net/ip_fib.h>
28
+#include <net/arp.h>
29
+#include <net/ndisc.h>
3230 #include <linux/in_route.h>
3331 #include <linux/rtnetlink.h>
3432 #include <linux/rcupdate.h>
....@@ -59,8 +57,12 @@
5957
6058 int rt_iif;
6159
60
+ u8 rt_gw_family;
6261 /* Info on neighbour */
63
- __be32 rt_gateway;
62
+ union {
63
+ __be32 rt_gw4;
64
+ struct in6_addr rt_gw6;
65
+ };
6466
6567 /* Miscellaneous cached information */
6668 u32 rt_mtu_locked:1,
....@@ -82,8 +84,8 @@
8284
8385 static inline __be32 rt_nexthop(const struct rtable *rt, __be32 daddr)
8486 {
85
- if (rt->rt_gateway)
86
- return rt->rt_gateway;
87
+ if (rt->rt_gw_family == AF_INET)
88
+ return rt->rt_gw4;
8789 return daddr;
8890 }
8991
....@@ -126,6 +128,12 @@
126128
127129 struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp,
128130 const struct sock *sk);
131
+struct rtable *ip_route_output_tunnel(struct sk_buff *skb,
132
+ struct net_device *dev,
133
+ struct net *net, __be32 *saddr,
134
+ const struct ip_tunnel_info *info,
135
+ u8 protocol, bool use_cache);
136
+
129137 struct dst_entry *ipv4_blackhole_route(struct net *net,
130138 struct dst_entry *dst_orig);
131139
....@@ -157,7 +165,7 @@
157165 sk ? inet_sk_flowi_flags(sk) : 0,
158166 daddr, saddr, dport, sport, sock_net_uid(net, sk));
159167 if (sk)
160
- security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
168
+ security_sk_classify_flow(sk, flowi4_to_flowi_common(fl4));
161169 return ip_route_output_flow(net, fl4, sk);
162170 }
163171
....@@ -183,6 +191,10 @@
183191 u8 tos, struct net_device *devin,
184192 struct fib_result *res);
185193
194
+int ip_route_use_hint(struct sk_buff *skb, __be32 dst, __be32 src,
195
+ u8 tos, struct net_device *devin,
196
+ const struct sk_buff *hint);
197
+
186198 static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src,
187199 u8 tos, struct net_device *devin)
188200 {
....@@ -201,10 +213,9 @@
201213 }
202214
203215 void ipv4_update_pmtu(struct sk_buff *skb, struct net *net, u32 mtu, int oif,
204
- u32 mark, u8 protocol, int flow_flags);
216
+ u8 protocol);
205217 void ipv4_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, u32 mtu);
206
-void ipv4_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark,
207
- u8 protocol, int flow_flags);
218
+void ipv4_redirect(struct sk_buff *skb, struct net *net, int oif, u8 protocol);
208219 void ipv4_sk_redirect(struct sk_buff *skb, struct sock *sk);
209220 void ip_rt_send_redirect(struct sk_buff *skb);
210221
....@@ -220,7 +231,8 @@
220231 void ip_rt_get_source(u8 *src, struct sk_buff *skb, struct rtable *rt);
221232 struct rtable *rt_dst_alloc(struct net_device *dev,
222233 unsigned int flags, u16 type,
223
- bool nopolicy, bool noxfrm, bool will_cache);
234
+ bool nopolicy, bool noxfrm);
235
+struct rtable *rt_dst_clone(struct net_device *dev, struct rtable *rt);
224236
225237 struct in_ifaddr;
226238 void fib_add_ifaddr(struct in_ifaddr *);
....@@ -229,6 +241,10 @@
229241
230242 void rt_add_uncached_list(struct rtable *rt);
231243 void rt_del_uncached_list(struct rtable *rt);
244
+
245
+int fib_dump_info_fnhe(struct sk_buff *skb, struct netlink_callback *cb,
246
+ u32 table_id, struct fib_info *fi,
247
+ int *fa_index, int fa_start, unsigned int flags);
232248
233249 static inline void ip_rt_put(struct rtable *rt)
234250 {
....@@ -306,7 +322,7 @@
306322 ip_rt_put(rt);
307323 flowi4_update_output(fl4, oif, tos, fl4->daddr, fl4->saddr);
308324 }
309
- security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
325
+ security_sk_classify_flow(sk, flowi4_to_flowi_common(fl4));
310326 return ip_route_output_flow(net, fl4, sk);
311327 }
312328
....@@ -322,7 +338,7 @@
322338 flowi4_update_output(fl4, sk->sk_bound_dev_if,
323339 RT_CONN_FLAGS(sk), fl4->daddr,
324340 fl4->saddr);
325
- security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
341
+ security_sk_classify_flow(sk, flowi4_to_flowi_common(fl4));
326342 return ip_route_output_flow(sock_net(sk), fl4, sk);
327343 }
328344 return rt;
....@@ -348,4 +364,34 @@
348364 return hoplimit;
349365 }
350366
367
+static inline struct neighbour *ip_neigh_gw4(struct net_device *dev,
368
+ __be32 daddr)
369
+{
370
+ struct neighbour *neigh;
371
+
372
+ neigh = __ipv4_neigh_lookup_noref(dev, (__force u32)daddr);
373
+ if (unlikely(!neigh))
374
+ neigh = __neigh_create(&arp_tbl, &daddr, dev, false);
375
+
376
+ return neigh;
377
+}
378
+
379
+static inline struct neighbour *ip_neigh_for_gw(struct rtable *rt,
380
+ struct sk_buff *skb,
381
+ bool *is_v6gw)
382
+{
383
+ struct net_device *dev = rt->dst.dev;
384
+ struct neighbour *neigh;
385
+
386
+ if (likely(rt->rt_gw_family == AF_INET)) {
387
+ neigh = ip_neigh_gw4(dev, rt->rt_gw4);
388
+ } else if (rt->rt_gw_family == AF_INET6) {
389
+ neigh = ip_neigh_gw6(dev, &rt->rt_gw6);
390
+ *is_v6gw = true;
391
+ } else {
392
+ neigh = ip_neigh_gw4(dev, ip_hdr(skb)->daddr);
393
+ }
394
+ return neigh;
395
+}
396
+
351397 #endif /* _ROUTE_H */