Commit 3089386d authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Jakub Kicinski

xfrm: extend add policy callback to set failure reason

Almost all validation logic is in the drivers, but they are
missing reliable way to convey failure reason to userspace
applications.

Let's use extack to return this information to users.
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 9179f5fe
...@@ -73,7 +73,7 @@ Callbacks to implement ...@@ -73,7 +73,7 @@ Callbacks to implement
/* Solely packet offload callbacks */ /* Solely packet offload callbacks */
void (*xdo_dev_state_update_curlft) (struct xfrm_state *x); void (*xdo_dev_state_update_curlft) (struct xfrm_state *x);
int (*xdo_dev_policy_add) (struct xfrm_policy *x); int (*xdo_dev_policy_add) (struct xfrm_policy *x, struct netlink_ext_ack *extack);
void (*xdo_dev_policy_delete) (struct xfrm_policy *x); void (*xdo_dev_policy_delete) (struct xfrm_policy *x);
void (*xdo_dev_policy_free) (struct xfrm_policy *x); void (*xdo_dev_policy_free) (struct xfrm_policy *x);
}; };
......
...@@ -550,7 +550,8 @@ mlx5e_ipsec_build_accel_pol_attrs(struct mlx5e_ipsec_pol_entry *pol_entry, ...@@ -550,7 +550,8 @@ mlx5e_ipsec_build_accel_pol_attrs(struct mlx5e_ipsec_pol_entry *pol_entry,
attrs->reqid = x->xfrm_vec[0].reqid; attrs->reqid = x->xfrm_vec[0].reqid;
} }
static int mlx5e_xfrm_add_policy(struct xfrm_policy *x) static int mlx5e_xfrm_add_policy(struct xfrm_policy *x,
struct netlink_ext_ack *extack)
{ {
struct net_device *netdev = x->xdo.real_dev; struct net_device *netdev = x->xdo.real_dev;
struct mlx5e_ipsec_pol_entry *pol_entry; struct mlx5e_ipsec_pol_entry *pol_entry;
......
...@@ -1042,7 +1042,7 @@ struct xfrmdev_ops { ...@@ -1042,7 +1042,7 @@ struct xfrmdev_ops {
struct xfrm_state *x); struct xfrm_state *x);
void (*xdo_dev_state_advance_esn) (struct xfrm_state *x); void (*xdo_dev_state_advance_esn) (struct xfrm_state *x);
void (*xdo_dev_state_update_curlft) (struct xfrm_state *x); void (*xdo_dev_state_update_curlft) (struct xfrm_state *x);
int (*xdo_dev_policy_add) (struct xfrm_policy *x); int (*xdo_dev_policy_add) (struct xfrm_policy *x, struct netlink_ext_ack *extack);
void (*xdo_dev_policy_delete) (struct xfrm_policy *x); void (*xdo_dev_policy_delete) (struct xfrm_policy *x);
void (*xdo_dev_policy_free) (struct xfrm_policy *x); void (*xdo_dev_policy_free) (struct xfrm_policy *x);
}; };
......
...@@ -383,14 +383,13 @@ int xfrm_dev_policy_add(struct net *net, struct xfrm_policy *xp, ...@@ -383,14 +383,13 @@ int xfrm_dev_policy_add(struct net *net, struct xfrm_policy *xp,
return -EINVAL; return -EINVAL;
} }
err = dev->xfrmdev_ops->xdo_dev_policy_add(xp); err = dev->xfrmdev_ops->xdo_dev_policy_add(xp, extack);
if (err) { if (err) {
xdo->dev = NULL; xdo->dev = NULL;
xdo->real_dev = NULL; xdo->real_dev = NULL;
xdo->type = XFRM_DEV_OFFLOAD_UNSPECIFIED; xdo->type = XFRM_DEV_OFFLOAD_UNSPECIFIED;
xdo->dir = 0; xdo->dir = 0;
netdev_put(dev, &xdo->dev_tracker); netdev_put(dev, &xdo->dev_tracker);
NL_SET_ERR_MSG(extack, "Device failed to offload this policy");
return err; return err;
} }
......
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