mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 04:01:48 -04:00
xfrm: remove get_mtu indirection from xfrm_type
esp4_get_mtu and esp6_get_mtu are exactly the same, the only difference is a single sizeof() (ipv4 vs. ipv6 header). Merge both into xfrm_state_mtu() and remove the indirection. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
This commit is contained in:
parent
8928aa6a00
commit
c7b37c769d
5 changed files with 34 additions and 56 deletions
|
|
@ -275,9 +275,8 @@ bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
|
|||
return false;
|
||||
|
||||
if ((!dev || (dev == xfrm_dst_path(dst)->dev)) &&
|
||||
(!xdst->child->xfrm && x->type->get_mtu)) {
|
||||
mtu = x->type->get_mtu(x, xdst->child_mtu_cached);
|
||||
|
||||
(!xdst->child->xfrm)) {
|
||||
mtu = xfrm_state_mtu(x, xdst->child_mtu_cached);
|
||||
if (skb->len <= mtu)
|
||||
goto ok;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
#include <linux/interrupt.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#include <crypto/aead.h>
|
||||
|
||||
#include "xfrm_hash.h"
|
||||
|
||||
#define xfrm_state_deref_prot(table, net) \
|
||||
|
|
@ -2403,16 +2405,38 @@ void xfrm_state_delete_tunnel(struct xfrm_state *x)
|
|||
}
|
||||
EXPORT_SYMBOL(xfrm_state_delete_tunnel);
|
||||
|
||||
int xfrm_state_mtu(struct xfrm_state *x, int mtu)
|
||||
u32 xfrm_state_mtu(struct xfrm_state *x, int mtu)
|
||||
{
|
||||
const struct xfrm_type *type = READ_ONCE(x->type);
|
||||
struct crypto_aead *aead;
|
||||
u32 blksize, net_adj = 0;
|
||||
|
||||
if (x->km.state == XFRM_STATE_VALID &&
|
||||
type && type->get_mtu)
|
||||
return type->get_mtu(x, mtu);
|
||||
if (x->km.state != XFRM_STATE_VALID ||
|
||||
!type || type->proto != IPPROTO_ESP)
|
||||
return mtu - x->props.header_len;
|
||||
|
||||
return mtu - x->props.header_len;
|
||||
aead = x->data;
|
||||
blksize = ALIGN(crypto_aead_blocksize(aead), 4);
|
||||
|
||||
switch (x->props.mode) {
|
||||
case XFRM_MODE_TRANSPORT:
|
||||
case XFRM_MODE_BEET:
|
||||
if (x->props.family == AF_INET)
|
||||
net_adj = sizeof(struct iphdr);
|
||||
else if (x->props.family == AF_INET6)
|
||||
net_adj = sizeof(struct ipv6hdr);
|
||||
break;
|
||||
case XFRM_MODE_TUNNEL:
|
||||
break;
|
||||
default:
|
||||
WARN_ON_ONCE(1);
|
||||
break;
|
||||
}
|
||||
|
||||
return ((mtu - x->props.header_len - crypto_aead_authsize(aead) -
|
||||
net_adj) & ~(blksize - 1)) + net_adj - 2;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(xfrm_state_mtu);
|
||||
|
||||
int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue