mirror of
https://gitee.com/openharmony/kernel_linux
synced 2025-04-15 05:43:05 +00:00
net sched actions: update Add/Delete action API with new argument
Introduce a new function argument to carry total attributes size for correct allocation of skb in event messages. Signed-off-by: Roman Mashak <mrv@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
79134e6ce2
commit
d04e6990c9
@ -166,7 +166,8 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
|
|||||||
int nr_actions, struct tcf_result *res);
|
int nr_actions, struct tcf_result *res);
|
||||||
int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
|
int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
|
||||||
struct nlattr *est, char *name, int ovr, int bind,
|
struct nlattr *est, char *name, int ovr, int bind,
|
||||||
struct list_head *actions, struct netlink_ext_ack *extack);
|
struct list_head *actions, size_t *attr_size,
|
||||||
|
struct netlink_ext_ack *extack);
|
||||||
struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
|
struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
|
||||||
struct nlattr *nla, struct nlattr *est,
|
struct nlattr *nla, struct nlattr *est,
|
||||||
char *name, int ovr, int bind,
|
char *name, int ovr, int bind,
|
||||||
|
@ -741,7 +741,8 @@ static void cleanup_a(struct list_head *actions, int ovr)
|
|||||||
|
|
||||||
int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
|
int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
|
||||||
struct nlattr *est, char *name, int ovr, int bind,
|
struct nlattr *est, char *name, int ovr, int bind,
|
||||||
struct list_head *actions, struct netlink_ext_ack *extack)
|
struct list_head *actions, size_t *attr_size,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
|
struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
|
||||||
struct tc_action *act;
|
struct tc_action *act;
|
||||||
@ -994,12 +995,13 @@ err_out:
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,
|
tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,
|
||||||
u32 portid, struct netlink_ext_ack *extack)
|
u32 portid, size_t attr_size, struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
|
||||||
skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
|
skb = alloc_skb(attr_size <= NLMSG_GOODSIZE ? NLMSG_GOODSIZE : attr_size,
|
||||||
|
GFP_KERNEL);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
|
|
||||||
@ -1032,6 +1034,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
|
|||||||
int i, ret;
|
int i, ret;
|
||||||
struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
|
struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
|
||||||
struct tc_action *act;
|
struct tc_action *act;
|
||||||
|
size_t attr_size = 0;
|
||||||
LIST_HEAD(actions);
|
LIST_HEAD(actions);
|
||||||
|
|
||||||
ret = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL, extack);
|
ret = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL, extack);
|
||||||
@ -1059,7 +1062,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
|
|||||||
if (event == RTM_GETACTION)
|
if (event == RTM_GETACTION)
|
||||||
ret = tcf_get_notify(net, portid, n, &actions, event, extack);
|
ret = tcf_get_notify(net, portid, n, &actions, event, extack);
|
||||||
else { /* delete */
|
else { /* delete */
|
||||||
ret = tcf_del_notify(net, n, &actions, portid, extack);
|
ret = tcf_del_notify(net, n, &actions, portid, attr_size, extack);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
return ret;
|
return ret;
|
||||||
@ -1072,12 +1075,13 @@ err:
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
tcf_add_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,
|
tcf_add_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,
|
||||||
u32 portid, struct netlink_ext_ack *extack)
|
u32 portid, size_t attr_size, struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
|
skb = alloc_skb(attr_size <= NLMSG_GOODSIZE ? NLMSG_GOODSIZE : attr_size,
|
||||||
|
GFP_KERNEL);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
|
|
||||||
@ -1099,15 +1103,16 @@ static int tcf_action_add(struct net *net, struct nlattr *nla,
|
|||||||
struct nlmsghdr *n, u32 portid, int ovr,
|
struct nlmsghdr *n, u32 portid, int ovr,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
|
size_t attr_size = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
LIST_HEAD(actions);
|
LIST_HEAD(actions);
|
||||||
|
|
||||||
ret = tcf_action_init(net, NULL, nla, NULL, NULL, ovr, 0, &actions,
|
ret = tcf_action_init(net, NULL, nla, NULL, NULL, ovr, 0, &actions,
|
||||||
extack);
|
&attr_size, extack);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return tcf_add_notify(net, n, &actions, portid, extack);
|
return tcf_add_notify(net, n, &actions, portid, attr_size, extack);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 tcaa_root_flags_allowed = TCA_FLAG_LARGE_DUMP_ON;
|
static u32 tcaa_root_flags_allowed = TCA_FLAG_LARGE_DUMP_ON;
|
||||||
|
@ -1433,6 +1433,7 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
|
|||||||
#ifdef CONFIG_NET_CLS_ACT
|
#ifdef CONFIG_NET_CLS_ACT
|
||||||
{
|
{
|
||||||
struct tc_action *act;
|
struct tc_action *act;
|
||||||
|
size_t attr_size = 0;
|
||||||
|
|
||||||
if (exts->police && tb[exts->police]) {
|
if (exts->police && tb[exts->police]) {
|
||||||
act = tcf_action_init_1(net, tp, tb[exts->police],
|
act = tcf_action_init_1(net, tp, tb[exts->police],
|
||||||
@ -1450,7 +1451,7 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
|
|||||||
|
|
||||||
err = tcf_action_init(net, tp, tb[exts->action],
|
err = tcf_action_init(net, tp, tb[exts->action],
|
||||||
rate_tlv, NULL, ovr, TCA_ACT_BIND,
|
rate_tlv, NULL, ovr, TCA_ACT_BIND,
|
||||||
&actions, extack);
|
&actions, &attr_size, extack);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
list_for_each_entry(act, &actions, list)
|
list_for_each_entry(act, &actions, list)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user