xref: /openbmc/linux/include/net/ipv6_stubs.h (revision b96f500d)
13616d08bSDavid Ahern /* SPDX-License-Identifier: GPL-2.0 */
23616d08bSDavid Ahern #ifndef _IPV6_STUBS_H
33616d08bSDavid Ahern #define _IPV6_STUBS_H
43616d08bSDavid Ahern 
53616d08bSDavid Ahern #include <linux/in6.h>
63616d08bSDavid Ahern #include <linux/netdevice.h>
73616d08bSDavid Ahern #include <linux/skbuff.h>
83616d08bSDavid Ahern #include <net/dst.h>
93616d08bSDavid Ahern #include <net/flow.h>
103616d08bSDavid Ahern #include <net/neighbour.h>
113616d08bSDavid Ahern #include <net/sock.h>
123616d08bSDavid Ahern 
133616d08bSDavid Ahern /* structs from net/ip6_fib.h */
143616d08bSDavid Ahern struct fib6_info;
151aefd3deSDavid Ahern struct fib6_nh;
161aefd3deSDavid Ahern struct fib6_config;
17b1d40991SDavid Ahern struct fib6_result;
183616d08bSDavid Ahern 
193616d08bSDavid Ahern /* This is ugly, ideally these symbols should be built
203616d08bSDavid Ahern  * into the core kernel.
213616d08bSDavid Ahern  */
223616d08bSDavid Ahern struct ipv6_stub {
233616d08bSDavid Ahern 	int (*ipv6_sock_mc_join)(struct sock *sk, int ifindex,
243616d08bSDavid Ahern 				 const struct in6_addr *addr);
253616d08bSDavid Ahern 	int (*ipv6_sock_mc_drop)(struct sock *sk, int ifindex,
263616d08bSDavid Ahern 				 const struct in6_addr *addr);
276c8991f4SSabrina Dubroca 	struct dst_entry *(*ipv6_dst_lookup_flow)(struct net *net,
286c8991f4SSabrina Dubroca 						  const struct sock *sk,
296c8991f4SSabrina Dubroca 						  struct flowi6 *fl6,
306c8991f4SSabrina Dubroca 						  const struct in6_addr *final_dst);
313616d08bSDavid Ahern 	int (*ipv6_route_input)(struct sk_buff *skb);
323616d08bSDavid Ahern 
333616d08bSDavid Ahern 	struct fib6_table *(*fib6_get_table)(struct net *net, u32 id);
34effda4ddSDavid Ahern 	int (*fib6_lookup)(struct net *net, int oif, struct flowi6 *fl6,
35effda4ddSDavid Ahern 			   struct fib6_result *res, int flags);
36effda4ddSDavid Ahern 	int (*fib6_table_lookup)(struct net *net, struct fib6_table *table,
373616d08bSDavid Ahern 				 int oif, struct flowi6 *fl6,
38effda4ddSDavid Ahern 				 struct fib6_result *res, int flags);
39b1d40991SDavid Ahern 	void (*fib6_select_path)(const struct net *net, struct fib6_result *res,
40b1d40991SDavid Ahern 				 struct flowi6 *fl6, int oif, bool oif_match,
41b1d40991SDavid Ahern 				 const struct sk_buff *skb, int strict);
42b748f260SDavid Ahern 	u32 (*ip6_mtu_from_fib6)(const struct fib6_result *res,
43b748f260SDavid Ahern 				 const struct in6_addr *daddr,
44b748f260SDavid Ahern 				 const struct in6_addr *saddr);
453616d08bSDavid Ahern 
461aefd3deSDavid Ahern 	int (*fib6_nh_init)(struct net *net, struct fib6_nh *fib6_nh,
471aefd3deSDavid Ahern 			    struct fib6_config *cfg, gfp_t gfp_flags,
481aefd3deSDavid Ahern 			    struct netlink_ext_ack *extack);
491aefd3deSDavid Ahern 	void (*fib6_nh_release)(struct fib6_nh *fib6_nh);
508837cbbfSNikolay Aleksandrov 	void (*fib6_nh_release_dsts)(struct fib6_nh *fib6_nh);
51cdaa16a4SDavid Ahern 	void (*fib6_update_sernum)(struct net *net, struct fib6_info *rt);
5211dd74b3SRoopa Prabhu 	int (*ip6_del_rt)(struct net *net, struct fib6_info *rt, bool skip_notify);
5319a3b7eeSDavid Ahern 	void (*fib6_rt_update)(struct net *net, struct fib6_info *rt,
5419a3b7eeSDavid Ahern 			       struct nl_info *info);
5519a3b7eeSDavid Ahern 
563616d08bSDavid Ahern 	void (*udpv6_encap_enable)(void);
573616d08bSDavid Ahern 	void (*ndisc_send_na)(struct net_device *dev, const struct in6_addr *daddr,
583616d08bSDavid Ahern 			      const struct in6_addr *solicited_addr,
593616d08bSDavid Ahern 			      bool router, bool solicited, bool override, bool inc_opt);
600146dca7SSabrina Dubroca #if IS_ENABLED(CONFIG_XFRM)
613e50ddd8SFlorian Westphal 	void (*xfrm6_local_rxpmtu)(struct sk_buff *skb, u32 mtu);
620146dca7SSabrina Dubroca 	int (*xfrm6_udp_encap_rcv)(struct sock *sk, struct sk_buff *skb);
6326333c37SSabrina Dubroca 	int (*xfrm6_rcv_encap)(struct sk_buff *skb, int nexthdr, __be32 spi,
6426333c37SSabrina Dubroca 			       int encap_type);
650146dca7SSabrina Dubroca #endif
663616d08bSDavid Ahern 	struct neigh_table *nd_tbl;
671d97898bSwenxu 
681d97898bSwenxu 	int (*ipv6_fragment)(struct net *net, struct sock *sk, struct sk_buff *skb,
691d97898bSwenxu 			     int (*output)(struct net *, struct sock *, struct sk_buff *));
70504a4011SAndreas Roeseler 	struct net_device *(*ipv6_dev_find)(struct net *net, const struct in6_addr *addr,
71504a4011SAndreas Roeseler 					    struct net_device *dev);
723616d08bSDavid Ahern };
733616d08bSDavid Ahern extern const struct ipv6_stub *ipv6_stub __read_mostly;
743616d08bSDavid Ahern 
753616d08bSDavid Ahern /* A stub used by bpf helpers. Similarly ugly as ipv6_stub */
763616d08bSDavid Ahern struct ipv6_bpf_stub {
773616d08bSDavid Ahern 	int (*inet6_bind)(struct sock *sk, struct sockaddr *uaddr, int addr_len,
78cb0721c7SStanislav Fomichev 			  u32 flags);
793616d08bSDavid Ahern 	struct sock *(*udp6_lib_lookup)(struct net *net,
803616d08bSDavid Ahern 				     const struct in6_addr *saddr, __be16 sport,
813616d08bSDavid Ahern 				     const struct in6_addr *daddr, __be16 dport,
823616d08bSDavid Ahern 				     int dif, int sdif, struct udp_table *tbl,
833616d08bSDavid Ahern 				     struct sk_buff *skb);
8475b64b68SMartin KaFai Lau 	int (*ipv6_setsockopt)(struct sock *sk, int level, int optname,
8575b64b68SMartin KaFai Lau 			       sockptr_t optval, unsigned int optlen);
8638566ec0SMartin KaFai Lau 	int (*ipv6_getsockopt)(struct sock *sk, int level, int optname,
8738566ec0SMartin KaFai Lau 			       sockptr_t optval, sockptr_t optlen);
88*b96f500dSMartynas Pumputis 	int (*ipv6_dev_get_saddr)(struct net *net,
89*b96f500dSMartynas Pumputis 				  const struct net_device *dst_dev,
90*b96f500dSMartynas Pumputis 				  const struct in6_addr *daddr,
91*b96f500dSMartynas Pumputis 				  unsigned int prefs,
92*b96f500dSMartynas Pumputis 				  struct in6_addr *saddr);
933616d08bSDavid Ahern };
943616d08bSDavid Ahern extern const struct ipv6_bpf_stub *ipv6_bpf_stub __read_mostly;
953616d08bSDavid Ahern 
963616d08bSDavid Ahern #endif
97