162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _IPV6_STUBS_H
362306a36Sopenharmony_ci#define _IPV6_STUBS_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/in6.h>
662306a36Sopenharmony_ci#include <linux/netdevice.h>
762306a36Sopenharmony_ci#include <linux/skbuff.h>
862306a36Sopenharmony_ci#include <net/dst.h>
962306a36Sopenharmony_ci#include <net/flow.h>
1062306a36Sopenharmony_ci#include <net/neighbour.h>
1162306a36Sopenharmony_ci#include <net/sock.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* structs from net/ip6_fib.h */
1462306a36Sopenharmony_cistruct fib6_info;
1562306a36Sopenharmony_cistruct fib6_nh;
1662306a36Sopenharmony_cistruct fib6_config;
1762306a36Sopenharmony_cistruct fib6_result;
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/* This is ugly, ideally these symbols should be built
2062306a36Sopenharmony_ci * into the core kernel.
2162306a36Sopenharmony_ci */
2262306a36Sopenharmony_cistruct ipv6_stub {
2362306a36Sopenharmony_ci	int (*ipv6_sock_mc_join)(struct sock *sk, int ifindex,
2462306a36Sopenharmony_ci				 const struct in6_addr *addr);
2562306a36Sopenharmony_ci	int (*ipv6_sock_mc_drop)(struct sock *sk, int ifindex,
2662306a36Sopenharmony_ci				 const struct in6_addr *addr);
2762306a36Sopenharmony_ci	struct dst_entry *(*ipv6_dst_lookup_flow)(struct net *net,
2862306a36Sopenharmony_ci						  const struct sock *sk,
2962306a36Sopenharmony_ci						  struct flowi6 *fl6,
3062306a36Sopenharmony_ci						  const struct in6_addr *final_dst);
3162306a36Sopenharmony_ci	int (*ipv6_route_input)(struct sk_buff *skb);
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci	struct fib6_table *(*fib6_get_table)(struct net *net, u32 id);
3462306a36Sopenharmony_ci	int (*fib6_lookup)(struct net *net, int oif, struct flowi6 *fl6,
3562306a36Sopenharmony_ci			   struct fib6_result *res, int flags);
3662306a36Sopenharmony_ci	int (*fib6_table_lookup)(struct net *net, struct fib6_table *table,
3762306a36Sopenharmony_ci				 int oif, struct flowi6 *fl6,
3862306a36Sopenharmony_ci				 struct fib6_result *res, int flags);
3962306a36Sopenharmony_ci	void (*fib6_select_path)(const struct net *net, struct fib6_result *res,
4062306a36Sopenharmony_ci				 struct flowi6 *fl6, int oif, bool oif_match,
4162306a36Sopenharmony_ci				 const struct sk_buff *skb, int strict);
4262306a36Sopenharmony_ci	u32 (*ip6_mtu_from_fib6)(const struct fib6_result *res,
4362306a36Sopenharmony_ci				 const struct in6_addr *daddr,
4462306a36Sopenharmony_ci				 const struct in6_addr *saddr);
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci	int (*fib6_nh_init)(struct net *net, struct fib6_nh *fib6_nh,
4762306a36Sopenharmony_ci			    struct fib6_config *cfg, gfp_t gfp_flags,
4862306a36Sopenharmony_ci			    struct netlink_ext_ack *extack);
4962306a36Sopenharmony_ci	void (*fib6_nh_release)(struct fib6_nh *fib6_nh);
5062306a36Sopenharmony_ci	void (*fib6_nh_release_dsts)(struct fib6_nh *fib6_nh);
5162306a36Sopenharmony_ci	void (*fib6_update_sernum)(struct net *net, struct fib6_info *rt);
5262306a36Sopenharmony_ci	int (*ip6_del_rt)(struct net *net, struct fib6_info *rt, bool skip_notify);
5362306a36Sopenharmony_ci	void (*fib6_rt_update)(struct net *net, struct fib6_info *rt,
5462306a36Sopenharmony_ci			       struct nl_info *info);
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci	void (*udpv6_encap_enable)(void);
5762306a36Sopenharmony_ci	void (*ndisc_send_na)(struct net_device *dev, const struct in6_addr *daddr,
5862306a36Sopenharmony_ci			      const struct in6_addr *solicited_addr,
5962306a36Sopenharmony_ci			      bool router, bool solicited, bool override, bool inc_opt);
6062306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_XFRM)
6162306a36Sopenharmony_ci	void (*xfrm6_local_rxpmtu)(struct sk_buff *skb, u32 mtu);
6262306a36Sopenharmony_ci	int (*xfrm6_udp_encap_rcv)(struct sock *sk, struct sk_buff *skb);
6362306a36Sopenharmony_ci	int (*xfrm6_rcv_encap)(struct sk_buff *skb, int nexthdr, __be32 spi,
6462306a36Sopenharmony_ci			       int encap_type);
6562306a36Sopenharmony_ci#endif
6662306a36Sopenharmony_ci	struct neigh_table *nd_tbl;
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci	int (*ipv6_fragment)(struct net *net, struct sock *sk, struct sk_buff *skb,
6962306a36Sopenharmony_ci			     int (*output)(struct net *, struct sock *, struct sk_buff *));
7062306a36Sopenharmony_ci	struct net_device *(*ipv6_dev_find)(struct net *net, const struct in6_addr *addr,
7162306a36Sopenharmony_ci					    struct net_device *dev);
7262306a36Sopenharmony_ci};
7362306a36Sopenharmony_ciextern const struct ipv6_stub *ipv6_stub __read_mostly;
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci/* A stub used by bpf helpers. Similarly ugly as ipv6_stub */
7662306a36Sopenharmony_cistruct ipv6_bpf_stub {
7762306a36Sopenharmony_ci	int (*inet6_bind)(struct sock *sk, struct sockaddr *uaddr, int addr_len,
7862306a36Sopenharmony_ci			  u32 flags);
7962306a36Sopenharmony_ci	struct sock *(*udp6_lib_lookup)(struct net *net,
8062306a36Sopenharmony_ci				     const struct in6_addr *saddr, __be16 sport,
8162306a36Sopenharmony_ci				     const struct in6_addr *daddr, __be16 dport,
8262306a36Sopenharmony_ci				     int dif, int sdif, struct udp_table *tbl,
8362306a36Sopenharmony_ci				     struct sk_buff *skb);
8462306a36Sopenharmony_ci	int (*ipv6_setsockopt)(struct sock *sk, int level, int optname,
8562306a36Sopenharmony_ci			       sockptr_t optval, unsigned int optlen);
8662306a36Sopenharmony_ci	int (*ipv6_getsockopt)(struct sock *sk, int level, int optname,
8762306a36Sopenharmony_ci			       sockptr_t optval, sockptr_t optlen);
8862306a36Sopenharmony_ci	int (*ipv6_dev_get_saddr)(struct net *net,
8962306a36Sopenharmony_ci				  const struct net_device *dst_dev,
9062306a36Sopenharmony_ci				  const struct in6_addr *daddr,
9162306a36Sopenharmony_ci				  unsigned int prefs,
9262306a36Sopenharmony_ci				  struct in6_addr *saddr);
9362306a36Sopenharmony_ci};
9462306a36Sopenharmony_ciextern const struct ipv6_bpf_stub *ipv6_bpf_stub __read_mostly;
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci#endif
97