Skip to content

Commit f70f250

Browse files
committed
net: Allow IPsec GSO for local sockets
This patch allows local sockets to make use of XFRM GSO code path. Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Ilan Tayari <ilant@mellanox.com>
1 parent 7e9e920 commit f70f250

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

include/net/xfrm.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,20 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
18581858
struct xfrm_user_offload *xuo);
18591859
bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x);
18601860

1861+
static inline bool xfrm_dst_offload_ok(struct dst_entry *dst)
1862+
{
1863+
struct xfrm_state *x = dst->xfrm;
1864+
1865+
if (!x || !x->type_offload)
1866+
return false;
1867+
1868+
if (x->xso.offload_handle && (x->xso.dev == dst->path->dev) &&
1869+
!dst->child->xfrm)
1870+
return true;
1871+
1872+
return false;
1873+
}
1874+
18611875
static inline void xfrm_dev_state_delete(struct xfrm_state *x)
18621876
{
18631877
struct xfrm_state_offload *xso = &x->xso;
@@ -1900,6 +1914,11 @@ static inline bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x
19001914
{
19011915
return false;
19021916
}
1917+
1918+
static inline bool xfrm_dst_offload_ok(struct dst_entry *dst)
1919+
{
1920+
return false;
1921+
}
19031922
#endif
19041923

19051924
static inline int xfrm_mark_get(struct nlattr **attrs, struct xfrm_mark *m)

net/core/sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
17571757
sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE;
17581758
sk->sk_route_caps &= ~sk->sk_route_nocaps;
17591759
if (sk_can_gso(sk)) {
1760-
if (dst->header_len) {
1760+
if (dst->header_len && !xfrm_dst_offload_ok(dst)) {
17611761
sk->sk_route_caps &= ~NETIF_F_GSO_MASK;
17621762
} else {
17631763
sk->sk_route_caps |= NETIF_F_SG | NETIF_F_HW_CSUM;

0 commit comments

Comments
 (0)