mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-01 10:03:39 -05:00
net: skbuff: generalize the skb->decrypted bit
The ->decrypted bit can be reused for other crypto protocols. Remove the direct dependency on TLS, add helpers to clean up the ifdefs leaking out everywhere. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
0d875bb4a7
commit
9f06f87fef
@@ -992,7 +992,7 @@ struct sk_buff {
|
||||
#ifdef CONFIG_NETFILTER_SKIP_EGRESS
|
||||
__u8 nf_skip_egress:1;
|
||||
#endif
|
||||
#ifdef CONFIG_TLS_DEVICE
|
||||
#ifdef CONFIG_SKB_DECRYPTED
|
||||
__u8 decrypted:1;
|
||||
#endif
|
||||
__u8 slow_gro:1;
|
||||
@@ -1615,17 +1615,26 @@ static inline void skb_copy_hash(struct sk_buff *to, const struct sk_buff *from)
|
||||
static inline int skb_cmp_decrypted(const struct sk_buff *skb1,
|
||||
const struct sk_buff *skb2)
|
||||
{
|
||||
#ifdef CONFIG_TLS_DEVICE
|
||||
#ifdef CONFIG_SKB_DECRYPTED
|
||||
return skb2->decrypted - skb1->decrypted;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline bool skb_is_decrypted(const struct sk_buff *skb)
|
||||
{
|
||||
#ifdef CONFIG_SKB_DECRYPTED
|
||||
return skb->decrypted;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void skb_copy_decrypted(struct sk_buff *to,
|
||||
const struct sk_buff *from)
|
||||
{
|
||||
#ifdef CONFIG_TLS_DEVICE
|
||||
#ifdef CONFIG_SKB_DECRYPTED
|
||||
to->decrypted = from->decrypted;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2835,12 +2835,10 @@ static inline struct sk_buff *sk_validate_xmit_skb(struct sk_buff *skb,
|
||||
|
||||
if (sk && sk_fullsock(sk) && sk->sk_validate_xmit_skb) {
|
||||
skb = sk->sk_validate_xmit_skb(sk, dev, skb);
|
||||
#ifdef CONFIG_TLS_DEVICE
|
||||
} else if (unlikely(skb->decrypted)) {
|
||||
} else if (unlikely(skb_is_decrypted(skb))) {
|
||||
pr_warn_ratelimited("unencrypted skb with no associated socket - dropping\n");
|
||||
kfree_skb(skb);
|
||||
skb = NULL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user