Skip to content

Commit d14f28b

Browse files
rleonklassert
authored andcommitted
xfrm: add new packet offload flag
In the next patches, the xfrm core code will be extended to support new type of offload - packet offload. In that mode, both policy and state should be specially configured in order to perform whole offloaded data path. Full offload takes care of encryption, decryption, encapsulation and other operations with headers. As this mode is new for XFRM policy flow, we can "start fresh" with flag bits and release first and second bit for future use. Reviewed-by: Raed Salem <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 65e6af6 commit d14f28b

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

include/net/xfrm.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,19 @@ enum {
131131
XFRM_DEV_OFFLOAD_OUT,
132132
};
133133

134+
enum {
135+
XFRM_DEV_OFFLOAD_UNSPECIFIED,
136+
XFRM_DEV_OFFLOAD_CRYPTO,
137+
XFRM_DEV_OFFLOAD_PACKET,
138+
};
139+
134140
struct xfrm_dev_offload {
135141
struct net_device *dev;
136142
netdevice_tracker dev_tracker;
137143
struct net_device *real_dev;
138144
unsigned long offload_handle;
139145
u8 dir : 2;
146+
u8 type : 2;
140147
};
141148

142149
struct xfrm_mode {

include/uapi/linux/xfrm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@ struct xfrm_user_offload {
519519
*/
520520
#define XFRM_OFFLOAD_IPV6 1
521521
#define XFRM_OFFLOAD_INBOUND 2
522+
/* Two bits above are relevant for state path only, while
523+
* offload is used for both policy and state flows.
524+
*
525+
* In policy offload mode, they are free and can be safely reused.
526+
*/
527+
#define XFRM_OFFLOAD_PACKET 4
522528

523529
struct xfrm_userpolicy_default {
524530
#define XFRM_USERPOLICY_UNSPEC 0

net/xfrm/xfrm_device.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,15 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
291291
else
292292
xso->dir = XFRM_DEV_OFFLOAD_OUT;
293293

294+
xso->type = XFRM_DEV_OFFLOAD_CRYPTO;
295+
294296
err = dev->xfrmdev_ops->xdo_dev_state_add(x);
295297
if (err) {
296298
xso->dev = NULL;
297299
xso->dir = 0;
298300
xso->real_dev = NULL;
299301
netdev_put(dev, &xso->dev_tracker);
302+
xso->type = XFRM_DEV_OFFLOAD_UNSPECIFIED;
300303

301304
if (err != -EOPNOTSUPP) {
302305
NL_SET_ERR_MSG(extack, "Device failed to offload this state");

net/xfrm/xfrm_user.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,8 @@ static int copy_user_offload(struct xfrm_dev_offload *xso, struct sk_buff *skb)
956956
xuo->ifindex = xso->dev->ifindex;
957957
if (xso->dir == XFRM_DEV_OFFLOAD_IN)
958958
xuo->flags = XFRM_OFFLOAD_INBOUND;
959+
if (xso->type == XFRM_DEV_OFFLOAD_PACKET)
960+
xuo->flags |= XFRM_OFFLOAD_PACKET;
959961

960962
return 0;
961963
}

0 commit comments

Comments
 (0)