Debian Codegraph @

include/net/netfilter/nft_fib.h

raw
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _NFT_FIB_H_
3 #define _NFT_FIB_H_
4
5 #include <net/l3mdev.h>
6 #include <net/netfilter/nf_tables.h>
7
8 struct nft_fib {
9 u8 dreg;
10 u8 result;
11 u32 flags;
12 };
13
14 extern const struct nla_policy nft_fib_policy[];
15
16 static inline bool
17 nft_fib_is_loopback(const struct sk_buff *skb, const struct net_device *in)
18 {
19 return skb->pkt_type == PACKET_LOOPBACK || in->flags & IFF_LOOPBACK;
20 }
21
22 static inline bool nft_fib_can_skip(const struct nft_pktinfo *pkt)
23 {
24 const struct net_device *indev = nft_in(pkt);
25 const struct sock *sk;
26
27 switch (nft_hook(pkt)) {
28 case NF_INET_PRE_ROUTING:
29 case NF_INET_INGRESS:
30 case NF_INET_LOCAL_IN:
31 break;
32 default:
33 return false;
34 }
35
36 sk = pkt->skb->sk;
37 if (sk && sk_fullsock(sk))
38 return sk->sk_rx_dst_ifindex == indev->ifindex;
39
40 return nft_fib_is_loopback(pkt->skb, indev);
41 }
42
43 static inline int nft_fib_l3mdev_master_ifindex_rcu(const struct nft_pktinfo *pkt,
44 const struct net_device *iif)
45 {
46 const struct net_device *dev = iif ? iif : pkt->skb->dev;
47
48 return l3mdev_master_ifindex_rcu(dev);
49 }
50
51 int nft_fib_dump(struct sk_buff *skb, const struct nft_expr *expr, bool reset);
52 int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
53 const struct nlattr * const tb[]);
54 int nft_fib_validate(const struct nft_ctx *ctx, const struct nft_expr *expr);
55
56 void nft_fib4_eval_type(const struct nft_expr *expr, struct nft_regs *regs,
57 const struct nft_pktinfo *pkt);
58 void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
59 const struct nft_pktinfo *pkt);
60
61 void nft_fib6_eval_type(const struct nft_expr *expr, struct nft_regs *regs,
62 const struct nft_pktinfo *pkt);
63 void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs,
64 const struct nft_pktinfo *pkt);
65
66 void nft_fib_store_result(void *reg, const struct nft_fib *priv,
67 const struct net_device *dev);
68
69 bool nft_fib_reduce(struct nft_regs_track *track,
70 const struct nft_expr *expr);
71 #endif