Commit 9f1a948f authored by Ziyang Chen's avatar Ziyang Chen Committed by Jakub Kicinski

nfp: flower: add validation of for police actions which are independent of flows

Validation of police actions was added to offload drivers in
commit d97b4b10 ("flow_offload: reject offload for all drivers with
invalid police parameters")

This patch extends that validation in the nfp driver to include
police actions which are created independently of flows.
Signed-off-by: default avatarZiyang Chen <ziyang.chen@corigine.com>
Reviewed-by: default avatarBaowen Zheng <baowen.zheng@corigine.com>
Reviewed-by: default avatarLouis Peens <louis.peens@corigine.com>
Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4fa37e49
...@@ -119,7 +119,8 @@ int nfp_flower_offload_one_police(struct nfp_app *app, bool ingress, ...@@ -119,7 +119,8 @@ int nfp_flower_offload_one_police(struct nfp_app *app, bool ingress,
static int nfp_policer_validate(const struct flow_action *action, static int nfp_policer_validate(const struct flow_action *action,
const struct flow_action_entry *act, const struct flow_action_entry *act,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack,
bool ingress)
{ {
if (act->police.exceed.act_id != FLOW_ACTION_DROP) { if (act->police.exceed.act_id != FLOW_ACTION_DROP) {
NL_SET_ERR_MSG_MOD(extack, NL_SET_ERR_MSG_MOD(extack,
...@@ -127,12 +128,20 @@ static int nfp_policer_validate(const struct flow_action *action, ...@@ -127,12 +128,20 @@ static int nfp_policer_validate(const struct flow_action *action,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if (act->police.notexceed.act_id != FLOW_ACTION_CONTINUE && if (ingress) {
act->police.notexceed.act_id != FLOW_ACTION_PIPE && if (act->police.notexceed.act_id != FLOW_ACTION_CONTINUE &&
act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) { act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) {
NL_SET_ERR_MSG_MOD(extack, NL_SET_ERR_MSG_MOD(extack,
"Offload not supported when conform action is not continue, pipe or ok"); "Offload not supported when conform action is not continue or ok");
return -EOPNOTSUPP; return -EOPNOTSUPP;
}
} else {
if (act->police.notexceed.act_id != FLOW_ACTION_PIPE &&
act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) {
NL_SET_ERR_MSG_MOD(extack,
"Offload not supported when conform action is not pipe or ok");
return -EOPNOTSUPP;
}
} }
if (act->police.notexceed.act_id == FLOW_ACTION_ACCEPT && if (act->police.notexceed.act_id == FLOW_ACTION_ACCEPT &&
...@@ -218,7 +227,7 @@ nfp_flower_install_rate_limiter(struct nfp_app *app, struct net_device *netdev, ...@@ -218,7 +227,7 @@ nfp_flower_install_rate_limiter(struct nfp_app *app, struct net_device *netdev,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
err = nfp_policer_validate(&flow->rule->action, action, extack); err = nfp_policer_validate(&flow->rule->action, action, extack, true);
if (err) if (err)
return err; return err;
...@@ -687,6 +696,7 @@ nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act, ...@@ -687,6 +696,7 @@ nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act,
bool pps_support, pps; bool pps_support, pps;
bool add = false; bool add = false;
u64 rate; u64 rate;
int err;
pps_support = !!(fl_priv->flower_ext_feats & NFP_FL_FEATS_QOS_PPS); pps_support = !!(fl_priv->flower_ext_feats & NFP_FL_FEATS_QOS_PPS);
...@@ -698,6 +708,11 @@ nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act, ...@@ -698,6 +708,11 @@ nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act,
"unsupported offload: qos rate limit offload requires police action"); "unsupported offload: qos rate limit offload requires police action");
continue; continue;
} }
err = nfp_policer_validate(&fl_act->action, action, extack, false);
if (err)
return err;
if (action->police.rate_bytes_ps > 0) { if (action->police.rate_bytes_ps > 0) {
rate = action->police.rate_bytes_ps; rate = action->police.rate_bytes_ps;
burst = action->police.burst; burst = action->police.burst;
......
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