Skip to content

Commit 02b408f

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nf_tables: rt: allow checking if dst has xfrm attached
Useful e.g. to avoid NATting inner headers of to-be-encrypted packets. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent a82738a commit 02b408f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/uapi/linux/netfilter/nf_tables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,12 +826,14 @@ enum nft_meta_keys {
826826
* @NFT_RT_NEXTHOP4: routing nexthop for IPv4
827827
* @NFT_RT_NEXTHOP6: routing nexthop for IPv6
828828
* @NFT_RT_TCPMSS: fetch current path tcp mss
829+
* @NFT_RT_XFRM: boolean, skb->dst->xfrm != NULL
829830
*/
830831
enum nft_rt_keys {
831832
NFT_RT_CLASSID,
832833
NFT_RT_NEXTHOP4,
833834
NFT_RT_NEXTHOP6,
834835
NFT_RT_TCPMSS,
836+
NFT_RT_XFRM,
835837
__NFT_RT_MAX
836838
};
837839
#define NFT_RT_MAX (__NFT_RT_MAX - 1)

net/netfilter/nft_rt.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ static void nft_rt_get_eval(const struct nft_expr *expr,
9090
case NFT_RT_TCPMSS:
9191
nft_reg_store16(dest, get_tcpmss(pkt, dst));
9292
break;
93+
#ifdef CONFIG_XFRM
94+
case NFT_RT_XFRM:
95+
nft_reg_store8(dest, !!dst->xfrm);
96+
break;
97+
#endif
9398
default:
9499
WARN_ON(1);
95100
goto err;
@@ -130,6 +135,11 @@ static int nft_rt_get_init(const struct nft_ctx *ctx,
130135
case NFT_RT_TCPMSS:
131136
len = sizeof(u16);
132137
break;
138+
#ifdef CONFIG_XFRM
139+
case NFT_RT_XFRM:
140+
len = sizeof(u8);
141+
break;
142+
#endif
133143
default:
134144
return -EOPNOTSUPP;
135145
}
@@ -164,6 +174,7 @@ static int nft_rt_validate(const struct nft_ctx *ctx, const struct nft_expr *exp
164174
case NFT_RT_NEXTHOP4:
165175
case NFT_RT_NEXTHOP6:
166176
case NFT_RT_CLASSID:
177+
case NFT_RT_XFRM:
167178
return 0;
168179
case NFT_RT_TCPMSS:
169180
hooks = (1 << NF_INET_FORWARD) |

0 commit comments

Comments
 (0)