|
12 | 12 | #include <linux/netlink.h> |
13 | 13 | #include <linux/netfilter.h> |
14 | 14 | #include <linux/netfilter/nf_tables.h> |
15 | | -#include <net/netfilter/nf_tables.h> |
| 15 | +#include <net/netfilter/nf_tables_core.h> |
16 | 16 | #include <net/netfilter/nf_conntrack.h> |
17 | 17 | #include <net/netfilter/nf_conntrack_acct.h> |
18 | 18 | #include <net/netfilter/nf_conntrack_tuple.h> |
|
23 | 23 | #include <net/netfilter/nf_conntrack_l4proto.h> |
24 | 24 | #include <net/netfilter/nf_conntrack_expect.h> |
25 | 25 |
|
26 | | -struct nft_ct { |
27 | | - enum nft_ct_keys key:8; |
28 | | - enum ip_conntrack_dir dir:8; |
29 | | - u8 len; |
30 | | - union { |
31 | | - u8 dreg; |
32 | | - u8 sreg; |
33 | | - }; |
34 | | -}; |
35 | | - |
36 | 26 | struct nft_ct_helper_obj { |
37 | 27 | struct nf_conntrack_helper *helper4; |
38 | 28 | struct nf_conntrack_helper *helper6; |
@@ -759,6 +749,18 @@ static bool nft_ct_set_reduce(struct nft_regs_track *track, |
759 | 749 | return false; |
760 | 750 | } |
761 | 751 |
|
| 752 | +#ifdef CONFIG_RETPOLINE |
| 753 | +static const struct nft_expr_ops nft_ct_get_fast_ops = { |
| 754 | + .type = &nft_ct_type, |
| 755 | + .size = NFT_EXPR_SIZE(sizeof(struct nft_ct)), |
| 756 | + .eval = nft_ct_get_fast_eval, |
| 757 | + .init = nft_ct_get_init, |
| 758 | + .destroy = nft_ct_get_destroy, |
| 759 | + .dump = nft_ct_get_dump, |
| 760 | + .reduce = nft_ct_set_reduce, |
| 761 | +}; |
| 762 | +#endif |
| 763 | + |
762 | 764 | static const struct nft_expr_ops nft_ct_set_ops = { |
763 | 765 | .type = &nft_ct_type, |
764 | 766 | .size = NFT_EXPR_SIZE(sizeof(struct nft_ct)), |
@@ -791,8 +793,21 @@ nft_ct_select_ops(const struct nft_ctx *ctx, |
791 | 793 | if (tb[NFTA_CT_DREG] && tb[NFTA_CT_SREG]) |
792 | 794 | return ERR_PTR(-EINVAL); |
793 | 795 |
|
794 | | - if (tb[NFTA_CT_DREG]) |
| 796 | + if (tb[NFTA_CT_DREG]) { |
| 797 | +#ifdef CONFIG_RETPOLINE |
| 798 | + u32 k = ntohl(nla_get_be32(tb[NFTA_CT_KEY])); |
| 799 | + |
| 800 | + switch (k) { |
| 801 | + case NFT_CT_STATE: |
| 802 | + case NFT_CT_DIRECTION: |
| 803 | + case NFT_CT_STATUS: |
| 804 | + case NFT_CT_MARK: |
| 805 | + case NFT_CT_SECMARK: |
| 806 | + return &nft_ct_get_fast_ops; |
| 807 | + } |
| 808 | +#endif |
795 | 809 | return &nft_ct_get_ops; |
| 810 | + } |
796 | 811 |
|
797 | 812 | if (tb[NFTA_CT_SREG]) { |
798 | 813 | #ifdef CONFIG_NF_CONNTRACK_ZONES |
|
0 commit comments