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>
732ccf110SGuillaume Nault #include <net/inet_dscp.h>
81da177e4SLinus Torvalds #include <net/ip_fib.h>
95481d73fSDavid Ahern #include <net/nexthop.h>
101da177e4SLinus Torvalds
111da177e4SLinus Torvalds struct fib_alias {
1256315f9eSAlexander Duyck struct hlist_node fa_list;
131da177e4SLinus Torvalds struct fib_info *fa_info;
1432ccf110SGuillaume Nault dscp_t fa_dscp;
151da177e4SLinus Torvalds u8 fa_type;
161da177e4SLinus Torvalds u8 fa_state;
179b6ebad5SAlexander Duyck u8 fa_slen;
180ddcf43dSAlexander Duyck u32 tb_id;
192392debcSJulian Anastasov s16 fa_default;
20*9fcf986cSEric Dumazet u8 offload;
21*9fcf986cSEric Dumazet u8 trap;
22*9fcf986cSEric Dumazet u8 offload_failed;
23a6501e08SEric Dumazet struct rcu_head rcu;
241da177e4SLinus Torvalds };
251da177e4SLinus Torvalds
261da177e4SLinus Torvalds #define FA_S_ACCESSED 0x01
271da177e4SLinus Torvalds
28974d8f86SZheng Yongjun /* Don't write on fa_state unless needed, to keep it shared on all cpus */
fib_alias_accessed(struct fib_alias * fa)299b0c290eSEric Dumazet static inline void fib_alias_accessed(struct fib_alias *fa)
309b0c290eSEric Dumazet {
319b0c290eSEric Dumazet if (!(fa->fa_state & FA_S_ACCESSED))
329b0c290eSEric Dumazet fa->fa_state |= FA_S_ACCESSED;
339b0c290eSEric Dumazet }
349b0c290eSEric Dumazet
351da177e4SLinus Torvalds /* Exported by fib_semantics.c */
367e58487bSJoe Perches void fib_release_info(struct fib_info *);
376d8422a1SDavid Ahern struct fib_info *fib_create_info(struct fib_config *cfg,
386d8422a1SDavid Ahern struct netlink_ext_ack *extack);
39faee6769SAlexander Aring int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,
409ae28727SDavid Ahern struct netlink_ext_ack *extack);
415f9ae3d9SXin Long bool fib_metrics_match(struct fib_config *cfg, struct fib_info *fi);
421e301fd0SIdo Schimmel int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
4308554789SAmit Cohen const struct fib_rt_info *fri, unsigned int flags);
447e58487bSJoe Perches void rtmsg_fib(int event, __be32 key, struct fib_alias *fa, int dst_len,
457e58487bSJoe Perches u32 tb_id, const struct nl_info *info, unsigned int nlm_flags);
461e7bdec6SAmit Cohen size_t fib_nlmsg_size(struct fib_info *fi);
471da177e4SLinus Torvalds
fib_result_assign(struct fib_result * res,struct fib_info * fi)48a2bbe682SDenis V. Lunev static inline void fib_result_assign(struct fib_result *res,
49a2bbe682SDenis V. Lunev struct fib_info *fi)
50a2bbe682SDenis V. Lunev {
511f1b9c99SEric Dumazet /* we used to play games with refcounts, but we now use RCU */
52a2bbe682SDenis V. Lunev res->fi = fi;
53eba618abSDavid Ahern res->nhc = fib_info_nhc(fi, 0);
54a2bbe682SDenis V. Lunev }
55a2bbe682SDenis V. Lunev
563be0686bSDavid S. Miller struct fib_prop {
573be0686bSDavid S. Miller int error;
583be0686bSDavid S. Miller u8 scope;
593be0686bSDavid S. Miller };
603be0686bSDavid S. Miller
613be0686bSDavid S. Miller extern const struct fib_prop fib_props[RTN_MAX + 1];
623be0686bSDavid S. Miller
631da177e4SLinus Torvalds #endif /* _FIB_LOOKUP_H */
64