xfrm: don't check offload_handle for nonzero

The offload_handle should be an opaque data cookie for the driver
to use, much like the data cookie for a timer or alarm callback.
Thus, the XFRM stack should not be checking for non-zero, because
the driver might use that to store an array reference, which could
be zero, or some other zero but meaningful value.

We can remove the checks for non-zero because there are plenty
other attributes also being checked to see if there is an offload
in place for the SA in question.

Signed-off-by: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
Shannon Nelson 2018-06-26 14:19:10 -07:00 committed by Steffen Klassert
parent 03dc7a35fc
commit fcb662deeb
3 changed files with 7 additions and 11 deletions

View File

@ -135,8 +135,7 @@ static struct sk_buff *esp4_gso_segment(struct sk_buff *skb,
skb->encap_hdr_csum = 1; skb->encap_hdr_csum = 1;
if (!(features & NETIF_F_HW_ESP) || !x->xso.offload_handle || if (!(features & NETIF_F_HW_ESP) || x->xso.dev != skb->dev)
(x->xso.dev != skb->dev))
esp_features = features & ~(NETIF_F_SG | NETIF_F_CSUM_MASK); esp_features = features & ~(NETIF_F_SG | NETIF_F_CSUM_MASK);
else if (!(features & NETIF_F_HW_ESP_TX_CSUM)) else if (!(features & NETIF_F_HW_ESP_TX_CSUM))
esp_features = features & ~NETIF_F_CSUM_MASK; esp_features = features & ~NETIF_F_CSUM_MASK;
@ -179,8 +178,7 @@ static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features_
if (!xo) if (!xo)
return -EINVAL; return -EINVAL;
if (!(features & NETIF_F_HW_ESP) || !x->xso.offload_handle || if (!(features & NETIF_F_HW_ESP) || x->xso.dev != skb->dev) {
(x->xso.dev != skb->dev)) {
xo->flags |= CRYPTO_FALLBACK; xo->flags |= CRYPTO_FALLBACK;
hw_offload = false; hw_offload = false;
} }

View File

@ -162,8 +162,7 @@ static struct sk_buff *esp6_gso_segment(struct sk_buff *skb,
skb->encap_hdr_csum = 1; skb->encap_hdr_csum = 1;
if (!(features & NETIF_F_HW_ESP) || !x->xso.offload_handle || if (!(features & NETIF_F_HW_ESP) || x->xso.dev != skb->dev)
(x->xso.dev != skb->dev))
esp_features = features & ~(NETIF_F_SG | NETIF_F_CSUM_MASK); esp_features = features & ~(NETIF_F_SG | NETIF_F_CSUM_MASK);
else if (!(features & NETIF_F_HW_ESP_TX_CSUM)) else if (!(features & NETIF_F_HW_ESP_TX_CSUM))
esp_features = features & ~NETIF_F_CSUM_MASK; esp_features = features & ~NETIF_F_CSUM_MASK;
@ -207,8 +206,7 @@ static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features
if (!xo) if (!xo)
return -EINVAL; return -EINVAL;
if (!(features & NETIF_F_HW_ESP) || !x->xso.offload_handle || if (!(features & NETIF_F_HW_ESP) || x->xso.dev != skb->dev) {
(x->xso.dev != skb->dev)) {
xo->flags |= CRYPTO_FALLBACK; xo->flags |= CRYPTO_FALLBACK;
hw_offload = false; hw_offload = false;
} }

View File

@ -56,7 +56,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
if (skb_is_gso(skb)) { if (skb_is_gso(skb)) {
struct net_device *dev = skb->dev; struct net_device *dev = skb->dev;
if (unlikely(!x->xso.offload_handle || (x->xso.dev != dev))) { if (unlikely(x->xso.dev != dev)) {
struct sk_buff *segs; struct sk_buff *segs;
/* Packet got rerouted, fixup features and segment it. */ /* Packet got rerouted, fixup features and segment it. */
@ -211,8 +211,8 @@ bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
if (!x->type_offload || x->encap) if (!x->type_offload || x->encap)
return false; return false;
if ((!dev || (x->xso.offload_handle && (dev == xfrm_dst_path(dst)->dev))) && if ((!dev || (dev == xfrm_dst_path(dst)->dev)) &&
(!xdst->child->xfrm && x->type->get_mtu)) { (!xdst->child->xfrm && x->type->get_mtu)) {
mtu = x->type->get_mtu(x, xdst->child_mtu_cached); mtu = x->type->get_mtu(x, xdst->child_mtu_cached);
if (skb->len <= mtu) if (skb->len <= mtu)