xref: /linux/net/ipv4/fib_lookup.h (revision 085547891de548491d8b9af22c8fbc9487c79055)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds #ifndef _FIB_LOOKUP_H
31da177e4SLinus Torvalds #define _FIB_LOOKUP_H
41da177e4SLinus Torvalds 
51da177e4SLinus Torvalds #include <linux/types.h>
61da177e4SLinus Torvalds #include <linux/list.h>
71da177e4SLinus Torvalds #include <net/ip_fib.h>
85481d73fSDavid Ahern #include <net/nexthop.h>
91da177e4SLinus Torvalds 
101da177e4SLinus Torvalds struct fib_alias {
1156315f9eSAlexander Duyck 	struct hlist_node	fa_list;
121da177e4SLinus Torvalds 	struct fib_info		*fa_info;
131da177e4SLinus Torvalds 	u8			fa_tos;
141da177e4SLinus Torvalds 	u8			fa_type;
151da177e4SLinus Torvalds 	u8			fa_state;
169b6ebad5SAlexander Duyck 	u8			fa_slen;
170ddcf43dSAlexander Duyck 	u32			tb_id;
182392debcSJulian Anastasov 	s16			fa_default;
1990b93f1bSIdo Schimmel 	u8			offload:1,
2090b93f1bSIdo Schimmel 				trap:1,
2190b93f1bSIdo Schimmel 				unused:6;
22a6501e08SEric Dumazet 	struct rcu_head		rcu;
231da177e4SLinus Torvalds };
241da177e4SLinus Torvalds 
251da177e4SLinus Torvalds #define FA_S_ACCESSED	0x01
261da177e4SLinus Torvalds 
279b0c290eSEric Dumazet /* Dont write on fa_state unless needed, to keep it shared on all cpus */
289b0c290eSEric Dumazet static inline void fib_alias_accessed(struct fib_alias *fa)
299b0c290eSEric Dumazet {
309b0c290eSEric Dumazet 	if (!(fa->fa_state & FA_S_ACCESSED))
319b0c290eSEric Dumazet 		fa->fa_state |= FA_S_ACCESSED;
329b0c290eSEric Dumazet }
339b0c290eSEric Dumazet 
341da177e4SLinus Torvalds /* Exported by fib_semantics.c */
357e58487bSJoe Perches void fib_release_info(struct fib_info *);
366d8422a1SDavid Ahern struct fib_info *fib_create_info(struct fib_config *cfg,
376d8422a1SDavid Ahern 				 struct netlink_ext_ack *extack);
38faee6769SAlexander Aring int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,
399ae28727SDavid Ahern 		 struct netlink_ext_ack *extack);
405f9ae3d9SXin Long bool fib_metrics_match(struct fib_config *cfg, struct fib_info *fi);
411e301fd0SIdo Schimmel int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
42*08554789SAmit Cohen 		  const struct fib_rt_info *fri, unsigned int flags);
437e58487bSJoe Perches void rtmsg_fib(int event, __be32 key, struct fib_alias *fa, int dst_len,
447e58487bSJoe Perches 	       u32 tb_id, const struct nl_info *info, unsigned int nlm_flags);
451da177e4SLinus Torvalds 
46a2bbe682SDenis V. Lunev static inline void fib_result_assign(struct fib_result *res,
47a2bbe682SDenis V. Lunev 				     struct fib_info *fi)
48a2bbe682SDenis V. Lunev {
491f1b9c99SEric Dumazet 	/* we used to play games with refcounts, but we now use RCU */
50a2bbe682SDenis V. Lunev 	res->fi = fi;
51eba618abSDavid Ahern 	res->nhc = fib_info_nhc(fi, 0);
52a2bbe682SDenis V. Lunev }
53a2bbe682SDenis V. Lunev 
543be0686bSDavid S. Miller struct fib_prop {
553be0686bSDavid S. Miller 	int	error;
563be0686bSDavid S. Miller 	u8	scope;
573be0686bSDavid S. Miller };
583be0686bSDavid S. Miller 
593be0686bSDavid S. Miller extern const struct fib_prop fib_props[RTN_MAX + 1];
603be0686bSDavid S. Miller 
611da177e4SLinus Torvalds #endif /* _FIB_LOOKUP_H */
62