Commit 9d7298cd authored by Simon Horman's avatar Simon Horman Committed by David S. Miller

net/sched: act_tunnel_key: add extended ack support

Add extended ack support for the tunnel key action by using NL_SET_ERR_MSG
during validation of user input.

Cc: Alexander Aring <aring@mojatatu.com>
Signed-off-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a1165b59
...@@ -86,16 +86,22 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, ...@@ -86,16 +86,22 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
int ret = 0; int ret = 0;
int err; int err;
if (!nla) if (!nla) {
NL_SET_ERR_MSG(extack, "Tunnel requires attributes to be passed");
return -EINVAL; return -EINVAL;
}
err = nla_parse_nested(tb, TCA_TUNNEL_KEY_MAX, nla, tunnel_key_policy, err = nla_parse_nested(tb, TCA_TUNNEL_KEY_MAX, nla, tunnel_key_policy,
NULL); extack);
if (err < 0) if (err < 0) {
NL_SET_ERR_MSG(extack, "Failed to parse nested tunnel key attributes");
return err; return err;
}
if (!tb[TCA_TUNNEL_KEY_PARMS]) if (!tb[TCA_TUNNEL_KEY_PARMS]) {
NL_SET_ERR_MSG(extack, "Missing tunnel key parameters");
return -EINVAL; return -EINVAL;
}
parm = nla_data(tb[TCA_TUNNEL_KEY_PARMS]); parm = nla_data(tb[TCA_TUNNEL_KEY_PARMS]);
exists = tcf_idr_check(tn, parm->index, a, bind); exists = tcf_idr_check(tn, parm->index, a, bind);
...@@ -107,6 +113,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, ...@@ -107,6 +113,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
break; break;
case TCA_TUNNEL_KEY_ACT_SET: case TCA_TUNNEL_KEY_ACT_SET:
if (!tb[TCA_TUNNEL_KEY_ENC_KEY_ID]) { if (!tb[TCA_TUNNEL_KEY_ENC_KEY_ID]) {
NL_SET_ERR_MSG(extack, "Missing tunnel key id");
ret = -EINVAL; ret = -EINVAL;
goto err_out; goto err_out;
} }
...@@ -144,11 +151,13 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, ...@@ -144,11 +151,13 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
0, flags, 0, flags,
key_id, 0); key_id, 0);
} else { } else {
NL_SET_ERR_MSG(extack, "Missing either ipv4 or ipv6 src and dst");
ret = -EINVAL; ret = -EINVAL;
goto err_out; goto err_out;
} }
if (!metadata) { if (!metadata) {
NL_SET_ERR_MSG(extack, "Cannot allocate tunnel metadata dst");
ret = -ENOMEM; ret = -ENOMEM;
goto err_out; goto err_out;
} }
...@@ -156,6 +165,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, ...@@ -156,6 +165,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
metadata->u.tun_info.mode |= IP_TUNNEL_INFO_TX; metadata->u.tun_info.mode |= IP_TUNNEL_INFO_TX;
break; break;
default: default:
NL_SET_ERR_MSG(extack, "Unknown tunnel key action");
ret = -EINVAL; ret = -EINVAL;
goto err_out; goto err_out;
} }
...@@ -163,14 +173,18 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, ...@@ -163,14 +173,18 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
if (!exists) { if (!exists) {
ret = tcf_idr_create(tn, parm->index, est, a, ret = tcf_idr_create(tn, parm->index, est, a,
&act_tunnel_key_ops, bind, true); &act_tunnel_key_ops, bind, true);
if (ret) if (ret) {
NL_SET_ERR_MSG(extack, "Cannot create TC IDR");
return ret; return ret;
}
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
tcf_idr_release(*a, bind); tcf_idr_release(*a, bind);
if (!ovr) if (!ovr) {
NL_SET_ERR_MSG(extack, "TC IDR already exists");
return -EEXIST; return -EEXIST;
}
} }
t = to_tunnel_key(*a); t = to_tunnel_key(*a);
...@@ -180,6 +194,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, ...@@ -180,6 +194,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
if (unlikely(!params_new)) { if (unlikely(!params_new)) {
if (ret == ACT_P_CREATED) if (ret == ACT_P_CREATED)
tcf_idr_release(*a, bind); tcf_idr_release(*a, bind);
NL_SET_ERR_MSG(extack, "Cannot allocate tunnel key parameters");
return -ENOMEM; return -ENOMEM;
} }
......
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