Commit 482db2f1 authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Steffen Klassert

xfrm: store and rely on direction to construct offload flags

XFRM state doesn't need anything from flags except to understand
direction, so store it separately. For future patches, such change
will allow us to reuse xfrm_dev_offload for policy offload too, which
has three possible directions instead of two.
Reviewed-by: default avatarRaed Salem <raeds@nvidia.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent 87e0a94e
...@@ -126,12 +126,18 @@ struct xfrm_state_walk { ...@@ -126,12 +126,18 @@ struct xfrm_state_walk {
struct xfrm_address_filter *filter; struct xfrm_address_filter *filter;
}; };
enum {
XFRM_DEV_OFFLOAD_IN = 1,
XFRM_DEV_OFFLOAD_OUT,
};
struct xfrm_dev_offload { struct xfrm_dev_offload {
struct net_device *dev; struct net_device *dev;
netdevice_tracker dev_tracker; netdevice_tracker dev_tracker;
struct net_device *real_dev; struct net_device *real_dev;
unsigned long offload_handle; unsigned long offload_handle;
u8 flags; u8 flags;
u8 dir : 2;
}; };
struct xfrm_mode { struct xfrm_mode {
......
...@@ -117,7 +117,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur ...@@ -117,7 +117,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
sp = skb_sec_path(skb); sp = skb_sec_path(skb);
x = sp->xvec[sp->len - 1]; x = sp->xvec[sp->len - 1];
if (xo->flags & XFRM_GRO || x->xso.flags & XFRM_OFFLOAD_INBOUND) if (xo->flags & XFRM_GRO || x->xso.dir == XFRM_DEV_OFFLOAD_IN)
return skb; return skb;
/* This skb was already validated on the upper/virtual dev */ /* This skb was already validated on the upper/virtual dev */
...@@ -267,10 +267,16 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x, ...@@ -267,10 +267,16 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
/* Don't forward bit that is not implemented */ /* Don't forward bit that is not implemented */
xso->flags = xuo->flags & ~XFRM_OFFLOAD_IPV6; xso->flags = xuo->flags & ~XFRM_OFFLOAD_IPV6;
if (xuo->flags & XFRM_OFFLOAD_INBOUND)
xso->dir = XFRM_DEV_OFFLOAD_IN;
else
xso->dir = XFRM_DEV_OFFLOAD_OUT;
err = dev->xfrmdev_ops->xdo_dev_state_add(x); err = dev->xfrmdev_ops->xdo_dev_state_add(x);
if (err) { if (err) {
xso->flags = 0; xso->flags = 0;
xso->dev = NULL; xso->dev = NULL;
xso->dir = 0;
xso->real_dev = NULL; xso->real_dev = NULL;
dev_put_track(dev, &xso->dev_tracker); dev_put_track(dev, &xso->dev_tracker);
......
...@@ -852,7 +852,8 @@ static int copy_user_offload(struct xfrm_dev_offload *xso, struct sk_buff *skb) ...@@ -852,7 +852,8 @@ static int copy_user_offload(struct xfrm_dev_offload *xso, struct sk_buff *skb)
xuo = nla_data(attr); xuo = nla_data(attr);
memset(xuo, 0, sizeof(*xuo)); memset(xuo, 0, sizeof(*xuo));
xuo->ifindex = xso->dev->ifindex; xuo->ifindex = xso->dev->ifindex;
xuo->flags = xso->flags; if (xso->dir == XFRM_DEV_OFFLOAD_IN)
xuo->flags = XFRM_OFFLOAD_INBOUND;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment