Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net_sched: refactor TC action init API

TC action ->init() API has 10 parameters, it becomes harder
to read. Some of them are just boolean and can be replaced
by flags. Similarly for the internal API tcf_action_init()
and tcf_exts_validate().

This patch converts them to flags and fold them into
the upper 16 bits of "flags", whose lower 16 bits are still
reserved for user-space. More specifically, the following
kernel flags are introduced:

TCA_ACT_FLAGS_POLICE replace 'name' in a few contexts, to
distinguish whether it is compatible with policer.

TCA_ACT_FLAGS_BIND replaces 'bind', to indicate whether
this action is bound to a filter.

TCA_ACT_FLAGS_REPLACE replaces 'ovr' in most contexts,
means we are replacing an existing action.

TCA_ACT_FLAGS_NO_RTNL replaces 'rtnl_held' but has the
opposite meaning, because we still hold RTNL in most
cases.

The only user-space flag TCA_ACT_FLAGS_NO_PERCPU_STATS is
untouched and still stored as before.

I have tested this patch with tdc and I do not see any
failure related to this patch.

Tested-by: Vlad Buslov <vladbu@nvidia.com>
Acked-by: Jamal Hadi Salim<jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Cong Wang and committed by
David S. Miller
695176bf 451395f7

+185 -169
+14 -8
include/net/act_api.h
··· 58 58 #define TCA_ACT_HW_STATS_ANY (TCA_ACT_HW_STATS_IMMEDIATE | \ 59 59 TCA_ACT_HW_STATS_DELAYED) 60 60 61 + /* Reserve 16 bits for user-space. See TCA_ACT_FLAGS_NO_PERCPU_STATS. */ 62 + #define TCA_ACT_FLAGS_USER_BITS 16 63 + #define TCA_ACT_FLAGS_USER_MASK 0xffff 64 + #define TCA_ACT_FLAGS_POLICE (1U << TCA_ACT_FLAGS_USER_BITS) 65 + #define TCA_ACT_FLAGS_BIND (1U << (TCA_ACT_FLAGS_USER_BITS + 1)) 66 + #define TCA_ACT_FLAGS_REPLACE (1U << (TCA_ACT_FLAGS_USER_BITS + 2)) 67 + #define TCA_ACT_FLAGS_NO_RTNL (1U << (TCA_ACT_FLAGS_USER_BITS + 3)) 68 + 61 69 /* Update lastuse only if needed, to avoid dirtying a cache line. 62 70 * We use a temp variable to avoid fetching jiffies twice. 63 71 */ ··· 107 99 void (*cleanup)(struct tc_action *); 108 100 int (*lookup)(struct net *net, struct tc_action **a, u32 index); 109 101 int (*init)(struct net *net, struct nlattr *nla, 110 - struct nlattr *est, struct tc_action **act, int ovr, 111 - int bind, bool rtnl_held, struct tcf_proto *tp, 102 + struct nlattr *est, struct tc_action **act, 103 + struct tcf_proto *tp, 112 104 u32 flags, struct netlink_ext_ack *extack); 113 105 int (*walk)(struct net *, struct sk_buff *, 114 106 struct netlink_callback *, int, ··· 187 179 int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, 188 180 int nr_actions, struct tcf_result *res); 189 181 int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, 190 - struct nlattr *est, char *name, int ovr, int bind, 182 + struct nlattr *est, 191 183 struct tc_action *actions[], int init_res[], size_t *attr_size, 192 - bool rtnl_held, struct netlink_ext_ack *extack); 193 - struct tc_action_ops *tc_action_load_ops(char *name, struct nlattr *nla, 184 + u32 flags, struct netlink_ext_ack *extack); 185 + struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, bool police, 194 186 bool rtnl_held, 195 187 struct netlink_ext_ack *extack); 196 188 struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, 197 189 struct nlattr *nla, struct nlattr *est, 198 - char *name, int ovr, int bind, 199 190 struct tc_action_ops *a_o, int *init_res, 200 - bool rtnl_held, 201 - struct netlink_ext_ack *extack); 191 + u32 flags, struct netlink_ext_ack *extack); 202 192 int tcf_action_dump(struct sk_buff *skb, struct tc_action *actions[], int bind, 203 193 int ref, bool terse); 204 194 int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
+1 -1
include/net/pkt_cls.h
··· 319 319 320 320 int tcf_exts_validate(struct net *net, struct tcf_proto *tp, 321 321 struct nlattr **tb, struct nlattr *rate_tlv, 322 - struct tcf_exts *exts, bool ovr, bool rtnl_held, 322 + struct tcf_exts *exts, u32 flags, 323 323 struct netlink_ext_ack *extack); 324 324 void tcf_exts_destroy(struct tcf_exts *exts); 325 325 void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src);
+1 -1
include/net/sch_generic.h
··· 357 357 int (*change)(struct net *net, struct sk_buff *, 358 358 struct tcf_proto*, unsigned long, 359 359 u32 handle, struct nlattr **, 360 - void **, bool, bool, 360 + void **, u32, 361 361 struct netlink_ext_ack *); 362 362 int (*delete)(struct tcf_proto *tp, void *arg, 363 363 bool *last, bool rtnl_held,
+1
include/uapi/linux/pkt_cls.h
··· 22 22 __TCA_ACT_MAX 23 23 }; 24 24 25 + /* See other TCA_ACT_FLAGS_ * flags in include/net/act_api.h. */ 25 26 #define TCA_ACT_FLAGS_NO_PERCPU_STATS 1 /* Don't use percpu allocator for 26 27 * actions stats. 27 28 */
+31 -30
net/sched/act_api.c
··· 495 495 p->tcfa_tm.install = jiffies; 496 496 p->tcfa_tm.lastuse = jiffies; 497 497 p->tcfa_tm.firstuse = 0; 498 - p->tcfa_flags = flags; 498 + p->tcfa_flags = flags & TCA_ACT_FLAGS_USER_MASK; 499 499 if (est) { 500 500 err = gen_new_estimator(&p->tcfa_bstats, p->cpu_bstats, 501 501 &p->tcfa_rate_est, ··· 941 941 } 942 942 } 943 943 944 - struct tc_action_ops *tc_action_load_ops(char *name, struct nlattr *nla, 944 + struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, bool police, 945 945 bool rtnl_held, 946 946 struct netlink_ext_ack *extack) 947 947 { ··· 951 951 struct nlattr *kind; 952 952 int err; 953 953 954 - if (name == NULL) { 954 + if (!police) { 955 955 err = nla_parse_nested_deprecated(tb, TCA_ACT_MAX, nla, 956 956 tcf_action_policy, extack); 957 957 if (err < 0) ··· 967 967 return ERR_PTR(err); 968 968 } 969 969 } else { 970 - if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ) { 970 + if (strlcpy(act_name, "police", IFNAMSIZ) >= IFNAMSIZ) { 971 971 NL_SET_ERR_MSG(extack, "TC action name too long"); 972 972 return ERR_PTR(-EINVAL); 973 973 } ··· 1004 1004 1005 1005 struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, 1006 1006 struct nlattr *nla, struct nlattr *est, 1007 - char *name, int ovr, int bind, 1008 1007 struct tc_action_ops *a_o, int *init_res, 1009 - bool rtnl_held, 1010 - struct netlink_ext_ack *extack) 1008 + u32 flags, struct netlink_ext_ack *extack) 1011 1009 { 1012 - struct nla_bitfield32 flags = { 0, 0 }; 1010 + bool police = flags & TCA_ACT_FLAGS_POLICE; 1011 + struct nla_bitfield32 userflags = { 0, 0 }; 1013 1012 u8 hw_stats = TCA_ACT_HW_STATS_ANY; 1014 1013 struct nlattr *tb[TCA_ACT_MAX + 1]; 1015 1014 struct tc_cookie *cookie = NULL; ··· 1016 1017 int err; 1017 1018 1018 1019 /* backward compatibility for policer */ 1019 - if (name == NULL) { 1020 + if (!police) { 1020 1021 err = nla_parse_nested_deprecated(tb, TCA_ACT_MAX, nla, 1021 1022 tcf_action_policy, extack); 1022 1023 if (err < 0) ··· 1031 1032 } 1032 1033 hw_stats = tcf_action_hw_stats_get(tb[TCA_ACT_HW_STATS]); 1033 1034 if (tb[TCA_ACT_FLAGS]) 1034 - flags = nla_get_bitfield32(tb[TCA_ACT_FLAGS]); 1035 + userflags = nla_get_bitfield32(tb[TCA_ACT_FLAGS]); 1035 1036 1036 - err = a_o->init(net, tb[TCA_ACT_OPTIONS], est, &a, ovr, bind, 1037 - rtnl_held, tp, flags.value, extack); 1037 + err = a_o->init(net, tb[TCA_ACT_OPTIONS], est, &a, tp, 1038 + userflags.value | flags, extack); 1038 1039 } else { 1039 - err = a_o->init(net, nla, est, &a, ovr, bind, rtnl_held, 1040 - tp, flags.value, extack); 1040 + err = a_o->init(net, nla, est, &a, tp, userflags.value | flags, 1041 + extack); 1041 1042 } 1042 1043 if (err < 0) 1043 1044 goto err_out; 1044 1045 *init_res = err; 1045 1046 1046 - if (!name && tb[TCA_ACT_COOKIE]) 1047 + if (!police && tb[TCA_ACT_COOKIE]) 1047 1048 tcf_set_action_cookie(&a->act_cookie, cookie); 1048 1049 1049 - if (!name) 1050 + if (!police) 1050 1051 a->hw_stats = hw_stats; 1051 1052 1052 1053 return a; ··· 1062 1063 /* Returns numbers of initialized actions or negative error. */ 1063 1064 1064 1065 int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, 1065 - struct nlattr *est, char *name, int ovr, int bind, 1066 - struct tc_action *actions[], int init_res[], size_t *attr_size, 1067 - bool rtnl_held, struct netlink_ext_ack *extack) 1066 + struct nlattr *est, struct tc_action *actions[], 1067 + int init_res[], size_t *attr_size, u32 flags, 1068 + struct netlink_ext_ack *extack) 1068 1069 { 1069 1070 struct tc_action_ops *ops[TCA_ACT_MAX_PRIO] = {}; 1070 1071 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1]; ··· 1081 1082 for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) { 1082 1083 struct tc_action_ops *a_o; 1083 1084 1084 - a_o = tc_action_load_ops(name, tb[i], rtnl_held, extack); 1085 + a_o = tc_action_load_ops(tb[i], flags & TCA_ACT_FLAGS_POLICE, 1086 + !(flags & TCA_ACT_FLAGS_NO_RTNL), 1087 + extack); 1085 1088 if (IS_ERR(a_o)) { 1086 1089 err = PTR_ERR(a_o); 1087 1090 goto err_mod; ··· 1092 1091 } 1093 1092 1094 1093 for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) { 1095 - act = tcf_action_init_1(net, tp, tb[i], est, name, ovr, bind, 1096 - ops[i - 1], &init_res[i - 1], rtnl_held, 1097 - extack); 1094 + act = tcf_action_init_1(net, tp, tb[i], est, ops[i - 1], 1095 + &init_res[i - 1], flags, extack); 1098 1096 if (IS_ERR(act)) { 1099 1097 err = PTR_ERR(act); 1100 1098 goto err; ··· 1113 1113 goto err_mod; 1114 1114 1115 1115 err: 1116 - tcf_action_destroy(actions, bind); 1116 + tcf_action_destroy(actions, flags & TCA_ACT_FLAGS_BIND); 1117 1117 err_mod: 1118 1118 for (i = 0; i < TCA_ACT_MAX_PRIO; i++) { 1119 1119 if (ops[i]) ··· 1495 1495 } 1496 1496 1497 1497 static int tcf_action_add(struct net *net, struct nlattr *nla, 1498 - struct nlmsghdr *n, u32 portid, int ovr, 1498 + struct nlmsghdr *n, u32 portid, u32 flags, 1499 1499 struct netlink_ext_ack *extack) 1500 1500 { 1501 1501 size_t attr_size = 0; ··· 1504 1504 int init_res[TCA_ACT_MAX_PRIO] = {}; 1505 1505 1506 1506 for (loop = 0; loop < 10; loop++) { 1507 - ret = tcf_action_init(net, NULL, nla, NULL, NULL, ovr, 0, 1508 - actions, init_res, &attr_size, true, extack); 1507 + ret = tcf_action_init(net, NULL, nla, NULL, actions, init_res, 1508 + &attr_size, flags, extack); 1509 1509 if (ret != -EAGAIN) 1510 1510 break; 1511 1511 } ··· 1535 1535 struct net *net = sock_net(skb->sk); 1536 1536 struct nlattr *tca[TCA_ROOT_MAX + 1]; 1537 1537 u32 portid = NETLINK_CB(skb).portid; 1538 - int ret = 0, ovr = 0; 1538 + u32 flags = 0; 1539 + int ret = 0; 1539 1540 1540 1541 if ((n->nlmsg_type != RTM_GETACTION) && 1541 1542 !netlink_capable(skb, CAP_NET_ADMIN)) ··· 1562 1561 * is zero) then just set this 1563 1562 */ 1564 1563 if (n->nlmsg_flags & NLM_F_REPLACE) 1565 - ovr = 1; 1566 - ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, portid, ovr, 1564 + flags = TCA_ACT_FLAGS_REPLACE; 1565 + ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, portid, flags, 1567 1566 extack); 1568 1567 break; 1569 1568 case RTM_DELACTION:
+2 -2
net/sched/act_bpf.c
··· 275 275 276 276 static int tcf_bpf_init(struct net *net, struct nlattr *nla, 277 277 struct nlattr *est, struct tc_action **act, 278 - int replace, int bind, bool rtnl_held, 279 278 struct tcf_proto *tp, u32 flags, 280 279 struct netlink_ext_ack *extack) 281 280 { 282 281 struct tc_action_net *tn = net_generic(net, bpf_net_id); 282 + bool bind = flags & TCA_ACT_FLAGS_BIND; 283 283 struct nlattr *tb[TCA_ACT_BPF_MAX + 1]; 284 284 struct tcf_chain *goto_ch = NULL; 285 285 struct tcf_bpf_cfg cfg, old; ··· 317 317 if (bind) 318 318 return 0; 319 319 320 - if (!replace) { 320 + if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 321 321 tcf_idr_release(*act, bind); 322 322 return -EEXIST; 323 323 }
+2 -2
net/sched/act_connmark.c
··· 96 96 97 97 static int tcf_connmark_init(struct net *net, struct nlattr *nla, 98 98 struct nlattr *est, struct tc_action **a, 99 - int ovr, int bind, bool rtnl_held, 100 99 struct tcf_proto *tp, u32 flags, 101 100 struct netlink_ext_ack *extack) 102 101 { 103 102 struct tc_action_net *tn = net_generic(net, connmark_net_id); 104 103 struct nlattr *tb[TCA_CONNMARK_MAX + 1]; 104 + bool bind = flags & TCA_ACT_FLAGS_BIND; 105 105 struct tcf_chain *goto_ch = NULL; 106 106 struct tcf_connmark_info *ci; 107 107 struct tc_connmark *parm; ··· 144 144 ci = to_connmark(*a); 145 145 if (bind) 146 146 return 0; 147 - if (!ovr) { 147 + if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 148 148 tcf_idr_release(*a, bind); 149 149 return -EEXIST; 150 150 }
+4 -3
net/sched/act_csum.c
··· 41 41 static struct tc_action_ops act_csum_ops; 42 42 43 43 static int tcf_csum_init(struct net *net, struct nlattr *nla, 44 - struct nlattr *est, struct tc_action **a, int ovr, 45 - int bind, bool rtnl_held, struct tcf_proto *tp, 44 + struct nlattr *est, struct tc_action **a, 45 + struct tcf_proto *tp, 46 46 u32 flags, struct netlink_ext_ack *extack) 47 47 { 48 48 struct tc_action_net *tn = net_generic(net, csum_net_id); 49 + bool bind = flags & TCA_ACT_FLAGS_BIND; 49 50 struct tcf_csum_params *params_new; 50 51 struct nlattr *tb[TCA_CSUM_MAX + 1]; 51 52 struct tcf_chain *goto_ch = NULL; ··· 79 78 } else if (err > 0) { 80 79 if (bind)/* dont override defaults */ 81 80 return 0; 82 - if (!ovr) { 81 + if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 83 82 tcf_idr_release(*a, bind); 84 83 return -EEXIST; 85 84 }
+2 -2
net/sched/act_ct.c
··· 1235 1235 1236 1236 static int tcf_ct_init(struct net *net, struct nlattr *nla, 1237 1237 struct nlattr *est, struct tc_action **a, 1238 - int replace, int bind, bool rtnl_held, 1239 1238 struct tcf_proto *tp, u32 flags, 1240 1239 struct netlink_ext_ack *extack) 1241 1240 { 1242 1241 struct tc_action_net *tn = net_generic(net, ct_net_id); 1242 + bool bind = flags & TCA_ACT_FLAGS_BIND; 1243 1243 struct tcf_ct_params *params = NULL; 1244 1244 struct nlattr *tb[TCA_CT_MAX + 1]; 1245 1245 struct tcf_chain *goto_ch = NULL; ··· 1279 1279 if (bind) 1280 1280 return 0; 1281 1281 1282 - if (!replace) { 1282 + if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 1283 1283 tcf_idr_release(*a, bind); 1284 1284 return -EEXIST; 1285 1285 }
+2 -2
net/sched/act_ctinfo.c
··· 154 154 155 155 static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, 156 156 struct nlattr *est, struct tc_action **a, 157 - int ovr, int bind, bool rtnl_held, 158 157 struct tcf_proto *tp, u32 flags, 159 158 struct netlink_ext_ack *extack) 160 159 { 161 160 struct tc_action_net *tn = net_generic(net, ctinfo_net_id); 161 + bool bind = flags & TCA_ACT_FLAGS_BIND; 162 162 u32 dscpmask = 0, dscpstatemask, index; 163 163 struct nlattr *tb[TCA_CTINFO_MAX + 1]; 164 164 struct tcf_ctinfo_params *cp_new; ··· 221 221 } else if (err > 0) { 222 222 if (bind) /* don't override defaults */ 223 223 return 0; 224 - if (!ovr) { 224 + if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 225 225 tcf_idr_release(*a, bind); 226 226 return -EEXIST; 227 227 }
+2 -2
net/sched/act_gact.c
··· 52 52 53 53 static int tcf_gact_init(struct net *net, struct nlattr *nla, 54 54 struct nlattr *est, struct tc_action **a, 55 - int ovr, int bind, bool rtnl_held, 56 55 struct tcf_proto *tp, u32 flags, 57 56 struct netlink_ext_ack *extack) 58 57 { 59 58 struct tc_action_net *tn = net_generic(net, gact_net_id); 59 + bool bind = flags & TCA_ACT_FLAGS_BIND; 60 60 struct nlattr *tb[TCA_GACT_MAX + 1]; 61 61 struct tcf_chain *goto_ch = NULL; 62 62 struct tc_gact *parm; ··· 109 109 } else if (err > 0) { 110 110 if (bind)/* dont override defaults */ 111 111 return 0; 112 - if (!ovr) { 112 + if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 113 113 tcf_idr_release(*a, bind); 114 114 return -EEXIST; 115 115 }
+2 -2
net/sched/act_gate.c
··· 295 295 296 296 static int tcf_gate_init(struct net *net, struct nlattr *nla, 297 297 struct nlattr *est, struct tc_action **a, 298 - int ovr, int bind, bool rtnl_held, 299 298 struct tcf_proto *tp, u32 flags, 300 299 struct netlink_ext_ack *extack) 301 300 { 302 301 struct tc_action_net *tn = net_generic(net, gate_net_id); 303 302 enum tk_offsets tk_offset = TK_OFFS_TAI; 303 + bool bind = flags & TCA_ACT_FLAGS_BIND; 304 304 struct nlattr *tb[TCA_GATE_MAX + 1]; 305 305 struct tcf_chain *goto_ch = NULL; 306 306 u64 cycletime = 0, basetime = 0; ··· 364 364 } 365 365 366 366 ret = ACT_P_CREATED; 367 - } else if (!ovr) { 367 + } else if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 368 368 tcf_idr_release(*a, bind); 369 369 return -EEXIST; 370 370 }
+5 -4
net/sched/act_ife.c
··· 479 479 480 480 static int tcf_ife_init(struct net *net, struct nlattr *nla, 481 481 struct nlattr *est, struct tc_action **a, 482 - int ovr, int bind, bool rtnl_held, 483 482 struct tcf_proto *tp, u32 flags, 484 483 struct netlink_ext_ack *extack) 485 484 { 486 485 struct tc_action_net *tn = net_generic(net, ife_net_id); 486 + bool bind = flags & TCA_ACT_FLAGS_BIND; 487 487 struct nlattr *tb[TCA_IFE_MAX + 1]; 488 488 struct nlattr *tb2[IFE_META_MAX + 1]; 489 489 struct tcf_chain *goto_ch = NULL; ··· 532 532 kfree(p); 533 533 return err; 534 534 } 535 - err = load_metalist(tb2, rtnl_held); 535 + err = load_metalist(tb2, !(flags & TCA_ACT_FLAGS_NO_RTNL)); 536 536 if (err) { 537 537 kfree(p); 538 538 return err; ··· 560 560 return ret; 561 561 } 562 562 ret = ACT_P_CREATED; 563 - } else if (!ovr) { 563 + } else if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 564 564 tcf_idr_release(*a, bind); 565 565 kfree(p); 566 566 return -EEXIST; ··· 600 600 } 601 601 602 602 if (tb[TCA_IFE_METALST]) { 603 - err = populate_metalist(ife, tb2, exists, rtnl_held); 603 + err = populate_metalist(ife, tb2, exists, 604 + !(flags & TCA_ACT_FLAGS_NO_RTNL)); 604 605 if (err) 605 606 goto metadata_parse_err; 606 607 } else {
+11 -10
net/sched/act_ipt.c
··· 94 94 95 95 static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla, 96 96 struct nlattr *est, struct tc_action **a, 97 - const struct tc_action_ops *ops, int ovr, int bind, 97 + const struct tc_action_ops *ops, 98 98 struct tcf_proto *tp, u32 flags) 99 99 { 100 100 struct tc_action_net *tn = net_generic(net, id); 101 + bool bind = flags & TCA_ACT_FLAGS_BIND; 101 102 struct nlattr *tb[TCA_IPT_MAX + 1]; 102 103 struct tcf_ipt *ipt; 103 104 struct xt_entry_target *td, *t; ··· 155 154 if (bind)/* dont override defaults */ 156 155 return 0; 157 156 158 - if (!ovr) { 157 + if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 159 158 tcf_idr_release(*a, bind); 160 159 return -EEXIST; 161 160 } ··· 202 201 } 203 202 204 203 static int tcf_ipt_init(struct net *net, struct nlattr *nla, 205 - struct nlattr *est, struct tc_action **a, int ovr, 206 - int bind, bool rtnl_held, struct tcf_proto *tp, 204 + struct nlattr *est, struct tc_action **a, 205 + struct tcf_proto *tp, 207 206 u32 flags, struct netlink_ext_ack *extack) 208 207 { 209 - return __tcf_ipt_init(net, ipt_net_id, nla, est, a, &act_ipt_ops, ovr, 210 - bind, tp, flags); 208 + return __tcf_ipt_init(net, ipt_net_id, nla, est, a, &act_ipt_ops, 209 + tp, flags); 211 210 } 212 211 213 212 static int tcf_xt_init(struct net *net, struct nlattr *nla, 214 - struct nlattr *est, struct tc_action **a, int ovr, 215 - int bind, bool unlocked, struct tcf_proto *tp, 213 + struct nlattr *est, struct tc_action **a, 214 + struct tcf_proto *tp, 216 215 u32 flags, struct netlink_ext_ack *extack) 217 216 { 218 - return __tcf_ipt_init(net, xt_net_id, nla, est, a, &act_xt_ops, ovr, 219 - bind, tp, flags); 217 + return __tcf_ipt_init(net, xt_net_id, nla, est, a, &act_xt_ops, 218 + tp, flags); 220 219 } 221 220 222 221 static int tcf_ipt_act(struct sk_buff *skb, const struct tc_action *a,
+2 -2
net/sched/act_mirred.c
··· 91 91 92 92 static int tcf_mirred_init(struct net *net, struct nlattr *nla, 93 93 struct nlattr *est, struct tc_action **a, 94 - int ovr, int bind, bool rtnl_held, 95 94 struct tcf_proto *tp, 96 95 u32 flags, struct netlink_ext_ack *extack) 97 96 { 98 97 struct tc_action_net *tn = net_generic(net, mirred_net_id); 98 + bool bind = flags & TCA_ACT_FLAGS_BIND; 99 99 struct nlattr *tb[TCA_MIRRED_MAX + 1]; 100 100 struct tcf_chain *goto_ch = NULL; 101 101 bool mac_header_xmit = false; ··· 155 155 return ret; 156 156 } 157 157 ret = ACT_P_CREATED; 158 - } else if (!ovr) { 158 + } else if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 159 159 tcf_idr_release(*a, bind); 160 160 return -EEXIST; 161 161 }
+2 -2
net/sched/act_mpls.c
··· 152 152 153 153 static int tcf_mpls_init(struct net *net, struct nlattr *nla, 154 154 struct nlattr *est, struct tc_action **a, 155 - int ovr, int bind, bool rtnl_held, 156 155 struct tcf_proto *tp, u32 flags, 157 156 struct netlink_ext_ack *extack) 158 157 { 159 158 struct tc_action_net *tn = net_generic(net, mpls_net_id); 159 + bool bind = flags & TCA_ACT_FLAGS_BIND; 160 160 struct nlattr *tb[TCA_MPLS_MAX + 1]; 161 161 struct tcf_chain *goto_ch = NULL; 162 162 struct tcf_mpls_params *p; ··· 255 255 } 256 256 257 257 ret = ACT_P_CREATED; 258 - } else if (!ovr) { 258 + } else if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 259 259 tcf_idr_release(*a, bind); 260 260 return -EEXIST; 261 261 }
+3 -3
net/sched/act_nat.c
··· 34 34 }; 35 35 36 36 static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, 37 - struct tc_action **a, int ovr, int bind, 38 - bool rtnl_held, struct tcf_proto *tp, 37 + struct tc_action **a, struct tcf_proto *tp, 39 38 u32 flags, struct netlink_ext_ack *extack) 40 39 { 41 40 struct tc_action_net *tn = net_generic(net, nat_net_id); 41 + bool bind = flags & TCA_ACT_FLAGS_BIND; 42 42 struct nlattr *tb[TCA_NAT_MAX + 1]; 43 43 struct tcf_chain *goto_ch = NULL; 44 44 struct tc_nat *parm; ··· 70 70 } else if (err > 0) { 71 71 if (bind) 72 72 return 0; 73 - if (!ovr) { 73 + if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 74 74 tcf_idr_release(*a, bind); 75 75 return -EEXIST; 76 76 }
+2 -2
net/sched/act_pedit.c
··· 136 136 137 137 static int tcf_pedit_init(struct net *net, struct nlattr *nla, 138 138 struct nlattr *est, struct tc_action **a, 139 - int ovr, int bind, bool rtnl_held, 140 139 struct tcf_proto *tp, u32 flags, 141 140 struct netlink_ext_ack *extack) 142 141 { 143 142 struct tc_action_net *tn = net_generic(net, pedit_net_id); 143 + bool bind = flags & TCA_ACT_FLAGS_BIND; 144 144 struct nlattr *tb[TCA_PEDIT_MAX + 1]; 145 145 struct tcf_chain *goto_ch = NULL; 146 146 struct tc_pedit_key *keys = NULL; ··· 198 198 } else if (err > 0) { 199 199 if (bind) 200 200 goto out_free; 201 - if (!ovr) { 201 + if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 202 202 ret = -EEXIST; 203 203 goto out_release; 204 204 }
+2 -2
net/sched/act_police.c
··· 48 48 49 49 static int tcf_police_init(struct net *net, struct nlattr *nla, 50 50 struct nlattr *est, struct tc_action **a, 51 - int ovr, int bind, bool rtnl_held, 52 51 struct tcf_proto *tp, u32 flags, 53 52 struct netlink_ext_ack *extack) 54 53 { 55 54 int ret = 0, tcfp_result = TC_ACT_OK, err, size; 55 + bool bind = flags & TCA_ACT_FLAGS_BIND; 56 56 struct nlattr *tb[TCA_POLICE_MAX + 1]; 57 57 struct tcf_chain *goto_ch = NULL; 58 58 struct tc_police *parm; ··· 97 97 } 98 98 ret = ACT_P_CREATED; 99 99 spin_lock_init(&(to_police(*a)->tcfp_lock)); 100 - } else if (!ovr) { 100 + } else if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 101 101 tcf_idr_release(*a, bind); 102 102 return -EEXIST; 103 103 }
+4 -3
net/sched/act_sample.c
··· 34 34 }; 35 35 36 36 static int tcf_sample_init(struct net *net, struct nlattr *nla, 37 - struct nlattr *est, struct tc_action **a, int ovr, 38 - int bind, bool rtnl_held, struct tcf_proto *tp, 37 + struct nlattr *est, struct tc_action **a, 38 + struct tcf_proto *tp, 39 39 u32 flags, struct netlink_ext_ack *extack) 40 40 { 41 41 struct tc_action_net *tn = net_generic(net, sample_net_id); 42 + bool bind = flags & TCA_ACT_FLAGS_BIND; 42 43 struct nlattr *tb[TCA_SAMPLE_MAX + 1]; 43 44 struct psample_group *psample_group; 44 45 u32 psample_group_num, rate, index; ··· 76 75 return ret; 77 76 } 78 77 ret = ACT_P_CREATED; 79 - } else if (!ovr) { 78 + } else if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 80 79 tcf_idr_release(*a, bind); 81 80 return -EEXIST; 82 81 }
+2 -2
net/sched/act_simple.c
··· 85 85 86 86 static int tcf_simp_init(struct net *net, struct nlattr *nla, 87 87 struct nlattr *est, struct tc_action **a, 88 - int ovr, int bind, bool rtnl_held, 89 88 struct tcf_proto *tp, u32 flags, 90 89 struct netlink_ext_ack *extack) 91 90 { 92 91 struct tc_action_net *tn = net_generic(net, simp_net_id); 92 + bool bind = flags & TCA_ACT_FLAGS_BIND; 93 93 struct nlattr *tb[TCA_DEF_MAX + 1]; 94 94 struct tcf_chain *goto_ch = NULL; 95 95 struct tc_defact *parm; ··· 147 147 tcf_action_set_ctrlact(*a, parm->action, goto_ch); 148 148 ret = ACT_P_CREATED; 149 149 } else { 150 - if (!ovr) { 150 + if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 151 151 err = -EEXIST; 152 152 goto release_idr; 153 153 }
+2 -2
net/sched/act_skbedit.c
··· 96 96 97 97 static int tcf_skbedit_init(struct net *net, struct nlattr *nla, 98 98 struct nlattr *est, struct tc_action **a, 99 - int ovr, int bind, bool rtnl_held, 100 99 struct tcf_proto *tp, u32 act_flags, 101 100 struct netlink_ext_ack *extack) 102 101 { 103 102 struct tc_action_net *tn = net_generic(net, skbedit_net_id); 103 + bool bind = act_flags & TCA_ACT_FLAGS_BIND; 104 104 struct tcf_skbedit_params *params_new; 105 105 struct nlattr *tb[TCA_SKBEDIT_MAX + 1]; 106 106 struct tcf_chain *goto_ch = NULL; ··· 186 186 ret = ACT_P_CREATED; 187 187 } else { 188 188 d = to_skbedit(*a); 189 - if (!ovr) { 189 + if (!(act_flags & TCA_ACT_FLAGS_REPLACE)) { 190 190 tcf_idr_release(*a, bind); 191 191 return -EEXIST; 192 192 }
+2 -1
net/sched/act_skbmod.c
··· 100 100 101 101 static int tcf_skbmod_init(struct net *net, struct nlattr *nla, 102 102 struct nlattr *est, struct tc_action **a, 103 - int ovr, int bind, bool rtnl_held, 104 103 struct tcf_proto *tp, u32 flags, 105 104 struct netlink_ext_ack *extack) 106 105 { 107 106 struct tc_action_net *tn = net_generic(net, skbmod_net_id); 107 + bool ovr = flags & TCA_ACT_FLAGS_REPLACE; 108 + bool bind = flags & TCA_ACT_FLAGS_BIND; 108 109 struct nlattr *tb[TCA_SKBMOD_MAX + 1]; 109 110 struct tcf_skbmod_params *p, *p_old; 110 111 struct tcf_chain *goto_ch = NULL;
+2 -2
net/sched/act_tunnel_key.c
··· 355 355 356 356 static int tunnel_key_init(struct net *net, struct nlattr *nla, 357 357 struct nlattr *est, struct tc_action **a, 358 - int ovr, int bind, bool rtnl_held, 359 358 struct tcf_proto *tp, u32 act_flags, 360 359 struct netlink_ext_ack *extack) 361 360 { 362 361 struct tc_action_net *tn = net_generic(net, tunnel_key_net_id); 362 + bool bind = act_flags & TCA_ACT_FLAGS_BIND; 363 363 struct nlattr *tb[TCA_TUNNEL_KEY_MAX + 1]; 364 364 struct tcf_tunnel_key_params *params_new; 365 365 struct metadata_dst *metadata = NULL; ··· 504 504 } 505 505 506 506 ret = ACT_P_CREATED; 507 - } else if (!ovr) { 507 + } else if (!(act_flags & TCA_ACT_FLAGS_REPLACE)) { 508 508 NL_SET_ERR_MSG(extack, "TC IDR already exists"); 509 509 ret = -EEXIST; 510 510 goto release_tun_meta;
+2 -2
net/sched/act_vlan.c
··· 114 114 115 115 static int tcf_vlan_init(struct net *net, struct nlattr *nla, 116 116 struct nlattr *est, struct tc_action **a, 117 - int ovr, int bind, bool rtnl_held, 118 117 struct tcf_proto *tp, u32 flags, 119 118 struct netlink_ext_ack *extack) 120 119 { 121 120 struct tc_action_net *tn = net_generic(net, vlan_net_id); 121 + bool bind = flags & TCA_ACT_FLAGS_BIND; 122 122 struct nlattr *tb[TCA_VLAN_MAX + 1]; 123 123 struct tcf_chain *goto_ch = NULL; 124 124 bool push_prio_exists = false; ··· 223 223 } 224 224 225 225 ret = ACT_P_CREATED; 226 - } else if (!ovr) { 226 + } else if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 227 227 tcf_idr_release(*a, bind); 228 228 return -EEXIST; 229 229 }
+17 -11
net/sched/cls_api.c
··· 1949 1949 int err; 1950 1950 int tp_created; 1951 1951 bool rtnl_held = false; 1952 + u32 flags = 0; 1952 1953 1953 1954 if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) 1954 1955 return -EPERM; ··· 2113 2112 goto errout; 2114 2113 } 2115 2114 2115 + if (!(n->nlmsg_flags & NLM_F_CREATE)) 2116 + flags |= TCA_ACT_FLAGS_REPLACE; 2117 + if (!rtnl_held) 2118 + flags |= TCA_ACT_FLAGS_NO_RTNL; 2116 2119 err = tp->ops->change(net, skb, tp, cl, t->tcm_handle, tca, &fh, 2117 - n->nlmsg_flags & NLM_F_CREATE ? TCA_ACT_NOREPLACE : TCA_ACT_REPLACE, 2118 - rtnl_held, extack); 2120 + flags, extack); 2119 2121 if (err == 0) { 2120 2122 tfilter_notify(net, skb, n, tp, block, q, parent, fh, 2121 2123 RTM_NEWTFILTER, false, rtnl_held); ··· 3024 3020 EXPORT_SYMBOL(tcf_exts_destroy); 3025 3021 3026 3022 int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, 3027 - struct nlattr *rate_tlv, struct tcf_exts *exts, bool ovr, 3028 - bool rtnl_held, struct netlink_ext_ack *extack) 3023 + struct nlattr *rate_tlv, struct tcf_exts *exts, 3024 + u32 flags, struct netlink_ext_ack *extack) 3029 3025 { 3030 3026 #ifdef CONFIG_NET_CLS_ACT 3031 3027 { ··· 3036 3032 if (exts->police && tb[exts->police]) { 3037 3033 struct tc_action_ops *a_o; 3038 3034 3039 - a_o = tc_action_load_ops("police", tb[exts->police], rtnl_held, extack); 3035 + a_o = tc_action_load_ops(tb[exts->police], true, 3036 + !(flags & TCA_ACT_FLAGS_NO_RTNL), 3037 + extack); 3040 3038 if (IS_ERR(a_o)) 3041 3039 return PTR_ERR(a_o); 3040 + flags |= TCA_ACT_FLAGS_POLICE | TCA_ACT_FLAGS_BIND; 3042 3041 act = tcf_action_init_1(net, tp, tb[exts->police], 3043 - rate_tlv, "police", ovr, 3044 - TCA_ACT_BIND, a_o, init_res, 3045 - rtnl_held, extack); 3042 + rate_tlv, a_o, init_res, flags, 3043 + extack); 3046 3044 module_put(a_o->owner); 3047 3045 if (IS_ERR(act)) 3048 3046 return PTR_ERR(act); ··· 3056 3050 } else if (exts->action && tb[exts->action]) { 3057 3051 int err; 3058 3052 3053 + flags |= TCA_ACT_FLAGS_BIND; 3059 3054 err = tcf_action_init(net, tp, tb[exts->action], 3060 - rate_tlv, NULL, ovr, TCA_ACT_BIND, 3061 - exts->actions, init_res, 3062 - &attr_size, rtnl_held, extack); 3055 + rate_tlv, exts->actions, init_res, 3056 + &attr_size, flags, extack); 3063 3057 if (err < 0) 3064 3058 return err; 3065 3059 exts->nr_actions = err;
+5 -5
net/sched/cls_basic.c
··· 145 145 static int basic_set_parms(struct net *net, struct tcf_proto *tp, 146 146 struct basic_filter *f, unsigned long base, 147 147 struct nlattr **tb, 148 - struct nlattr *est, bool ovr, 148 + struct nlattr *est, u32 flags, 149 149 struct netlink_ext_ack *extack) 150 150 { 151 151 int err; 152 152 153 - err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, true, extack); 153 + err = tcf_exts_validate(net, tp, tb, est, &f->exts, flags, extack); 154 154 if (err < 0) 155 155 return err; 156 156 ··· 169 169 170 170 static int basic_change(struct net *net, struct sk_buff *in_skb, 171 171 struct tcf_proto *tp, unsigned long base, u32 handle, 172 - struct nlattr **tca, void **arg, bool ovr, 173 - bool rtnl_held, struct netlink_ext_ack *extack) 172 + struct nlattr **tca, void **arg, 173 + u32 flags, struct netlink_ext_ack *extack) 174 174 { 175 175 int err; 176 176 struct basic_head *head = rtnl_dereference(tp->root); ··· 216 216 goto errout; 217 217 } 218 218 219 - err = basic_set_parms(net, tp, fnew, base, tb, tca[TCA_RATE], ovr, 219 + err = basic_set_parms(net, tp, fnew, base, tb, tca[TCA_RATE], flags, 220 220 extack); 221 221 if (err < 0) { 222 222 if (!fold)
+4 -4
net/sched/cls_bpf.c
··· 404 404 405 405 static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp, 406 406 struct cls_bpf_prog *prog, unsigned long base, 407 - struct nlattr **tb, struct nlattr *est, bool ovr, 407 + struct nlattr **tb, struct nlattr *est, u32 flags, 408 408 struct netlink_ext_ack *extack) 409 409 { 410 410 bool is_bpf, is_ebpf, have_exts = false; ··· 416 416 if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf)) 417 417 return -EINVAL; 418 418 419 - ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, ovr, true, 419 + ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, flags, 420 420 extack); 421 421 if (ret < 0) 422 422 return ret; ··· 455 455 static int cls_bpf_change(struct net *net, struct sk_buff *in_skb, 456 456 struct tcf_proto *tp, unsigned long base, 457 457 u32 handle, struct nlattr **tca, 458 - void **arg, bool ovr, bool rtnl_held, 458 + void **arg, u32 flags, 459 459 struct netlink_ext_ack *extack) 460 460 { 461 461 struct cls_bpf_head *head = rtnl_dereference(tp->root); ··· 500 500 goto errout; 501 501 prog->handle = handle; 502 502 503 - ret = cls_bpf_set_parms(net, tp, prog, base, tb, tca[TCA_RATE], ovr, 503 + ret = cls_bpf_set_parms(net, tp, prog, base, tb, tca[TCA_RATE], flags, 504 504 extack); 505 505 if (ret < 0) 506 506 goto errout_idr;
+3 -3
net/sched/cls_cgroup.c
··· 76 76 static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, 77 77 struct tcf_proto *tp, unsigned long base, 78 78 u32 handle, struct nlattr **tca, 79 - void **arg, bool ovr, bool rtnl_held, 79 + void **arg, u32 flags, 80 80 struct netlink_ext_ack *extack) 81 81 { 82 82 struct nlattr *tb[TCA_CGROUP_MAX + 1]; ··· 108 108 if (err < 0) 109 109 goto errout; 110 110 111 - err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &new->exts, ovr, 112 - true, extack); 111 + err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &new->exts, flags, 112 + extack); 113 113 if (err < 0) 114 114 goto errout; 115 115
+3 -3
net/sched/cls_flow.c
··· 387 387 static int flow_change(struct net *net, struct sk_buff *in_skb, 388 388 struct tcf_proto *tp, unsigned long base, 389 389 u32 handle, struct nlattr **tca, 390 - void **arg, bool ovr, bool rtnl_held, 390 + void **arg, u32 flags, 391 391 struct netlink_ext_ack *extack) 392 392 { 393 393 struct flow_head *head = rtnl_dereference(tp->root); ··· 442 442 if (err < 0) 443 443 goto err2; 444 444 445 - err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &fnew->exts, ovr, 446 - true, extack); 445 + err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &fnew->exts, flags, 446 + extack); 447 447 if (err < 0) 448 448 goto err2; 449 449
+9 -9
net/sched/cls_flower.c
··· 1915 1915 static int fl_set_parms(struct net *net, struct tcf_proto *tp, 1916 1916 struct cls_fl_filter *f, struct fl_flow_mask *mask, 1917 1917 unsigned long base, struct nlattr **tb, 1918 - struct nlattr *est, bool ovr, 1919 - struct fl_flow_tmplt *tmplt, bool rtnl_held, 1918 + struct nlattr *est, 1919 + struct fl_flow_tmplt *tmplt, u32 flags, 1920 1920 struct netlink_ext_ack *extack) 1921 1921 { 1922 1922 int err; 1923 1923 1924 - err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, rtnl_held, 1925 - extack); 1924 + err = tcf_exts_validate(net, tp, tb, est, &f->exts, flags, extack); 1926 1925 if (err < 0) 1927 1926 return err; 1928 1927 1929 1928 if (tb[TCA_FLOWER_CLASSID]) { 1930 1929 f->res.classid = nla_get_u32(tb[TCA_FLOWER_CLASSID]); 1931 - if (!rtnl_held) 1930 + if (flags & TCA_ACT_FLAGS_NO_RTNL) 1932 1931 rtnl_lock(); 1933 1932 tcf_bind_filter(tp, &f->res, base); 1934 - if (!rtnl_held) 1933 + if (flags & TCA_ACT_FLAGS_NO_RTNL) 1935 1934 rtnl_unlock(); 1936 1935 } 1937 1936 ··· 1974 1975 static int fl_change(struct net *net, struct sk_buff *in_skb, 1975 1976 struct tcf_proto *tp, unsigned long base, 1976 1977 u32 handle, struct nlattr **tca, 1977 - void **arg, bool ovr, bool rtnl_held, 1978 + void **arg, u32 flags, 1978 1979 struct netlink_ext_ack *extack) 1979 1980 { 1980 1981 struct cls_fl_head *head = fl_head_dereference(tp); 1982 + bool rtnl_held = !(flags & TCA_ACT_FLAGS_NO_RTNL); 1981 1983 struct cls_fl_filter *fold = *arg; 1982 1984 struct cls_fl_filter *fnew; 1983 1985 struct fl_flow_mask *mask; ··· 2034 2034 } 2035 2035 } 2036 2036 2037 - err = fl_set_parms(net, tp, fnew, mask, base, tb, tca[TCA_RATE], ovr, 2038 - tp->chain->tmplt_priv, rtnl_held, extack); 2037 + err = fl_set_parms(net, tp, fnew, mask, base, tb, tca[TCA_RATE], 2038 + tp->chain->tmplt_priv, flags, extack); 2039 2039 if (err) 2040 2040 goto errout; 2041 2041
+6 -7
net/sched/cls_fw.c
··· 198 198 199 199 static int fw_set_parms(struct net *net, struct tcf_proto *tp, 200 200 struct fw_filter *f, struct nlattr **tb, 201 - struct nlattr **tca, unsigned long base, bool ovr, 201 + struct nlattr **tca, unsigned long base, u32 flags, 202 202 struct netlink_ext_ack *extack) 203 203 { 204 204 struct fw_head *head = rtnl_dereference(tp->root); 205 205 u32 mask; 206 206 int err; 207 207 208 - err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &f->exts, ovr, 209 - true, extack); 208 + err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &f->exts, flags, 209 + extack); 210 210 if (err < 0) 211 211 return err; 212 212 ··· 237 237 static int fw_change(struct net *net, struct sk_buff *in_skb, 238 238 struct tcf_proto *tp, unsigned long base, 239 239 u32 handle, struct nlattr **tca, void **arg, 240 - bool ovr, bool rtnl_held, 241 - struct netlink_ext_ack *extack) 240 + u32 flags, struct netlink_ext_ack *extack) 242 241 { 243 242 struct fw_head *head = rtnl_dereference(tp->root); 244 243 struct fw_filter *f = *arg; ··· 276 277 return err; 277 278 } 278 279 279 - err = fw_set_parms(net, tp, fnew, tb, tca, base, ovr, extack); 280 + err = fw_set_parms(net, tp, fnew, tb, tca, base, flags, extack); 280 281 if (err < 0) { 281 282 tcf_exts_destroy(&fnew->exts); 282 283 kfree(fnew); ··· 325 326 f->id = handle; 326 327 f->tp = tp; 327 328 328 - err = fw_set_parms(net, tp, f, tb, tca, base, ovr, extack); 329 + err = fw_set_parms(net, tp, f, tb, tca, base, flags, extack); 329 330 if (err < 0) 330 331 goto errout; 331 332
+8 -9
net/sched/cls_matchall.c
··· 163 163 static int mall_set_parms(struct net *net, struct tcf_proto *tp, 164 164 struct cls_mall_head *head, 165 165 unsigned long base, struct nlattr **tb, 166 - struct nlattr *est, bool ovr, 166 + struct nlattr *est, u32 flags, 167 167 struct netlink_ext_ack *extack) 168 168 { 169 169 int err; 170 170 171 - err = tcf_exts_validate(net, tp, tb, est, &head->exts, ovr, true, 172 - extack); 171 + err = tcf_exts_validate(net, tp, tb, est, &head->exts, flags, extack); 173 172 if (err < 0) 174 173 return err; 175 174 ··· 182 183 static int mall_change(struct net *net, struct sk_buff *in_skb, 183 184 struct tcf_proto *tp, unsigned long base, 184 185 u32 handle, struct nlattr **tca, 185 - void **arg, bool ovr, bool rtnl_held, 186 + void **arg, u32 flags, 186 187 struct netlink_ext_ack *extack) 187 188 { 188 189 struct cls_mall_head *head = rtnl_dereference(tp->root); 189 190 struct nlattr *tb[TCA_MATCHALL_MAX + 1]; 190 191 struct cls_mall_head *new; 191 - u32 flags = 0; 192 + u32 userflags = 0; 192 193 int err; 193 194 194 195 if (!tca[TCA_OPTIONS]) ··· 203 204 return err; 204 205 205 206 if (tb[TCA_MATCHALL_FLAGS]) { 206 - flags = nla_get_u32(tb[TCA_MATCHALL_FLAGS]); 207 - if (!tc_flags_valid(flags)) 207 + userflags = nla_get_u32(tb[TCA_MATCHALL_FLAGS]); 208 + if (!tc_flags_valid(userflags)) 208 209 return -EINVAL; 209 210 } 210 211 ··· 219 220 if (!handle) 220 221 handle = 1; 221 222 new->handle = handle; 222 - new->flags = flags; 223 + new->flags = userflags; 223 224 new->pf = alloc_percpu(struct tc_matchall_pcnt); 224 225 if (!new->pf) { 225 226 err = -ENOMEM; 226 227 goto err_alloc_percpu; 227 228 } 228 229 229 - err = mall_set_parms(net, tp, new, base, tb, tca[TCA_RATE], ovr, 230 + err = mall_set_parms(net, tp, new, base, tb, tca[TCA_RATE], flags, 230 231 extack); 231 232 if (err) 232 233 goto err_set_parms;
+5 -5
net/sched/cls_route.c
··· 382 382 unsigned long base, struct route4_filter *f, 383 383 u32 handle, struct route4_head *head, 384 384 struct nlattr **tb, struct nlattr *est, int new, 385 - bool ovr, struct netlink_ext_ack *extack) 385 + u32 flags, struct netlink_ext_ack *extack) 386 386 { 387 387 u32 id = 0, to = 0, nhandle = 0x8000; 388 388 struct route4_filter *fp; ··· 390 390 struct route4_bucket *b; 391 391 int err; 392 392 393 - err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, true, extack); 393 + err = tcf_exts_validate(net, tp, tb, est, &f->exts, flags, extack); 394 394 if (err < 0) 395 395 return err; 396 396 ··· 464 464 465 465 static int route4_change(struct net *net, struct sk_buff *in_skb, 466 466 struct tcf_proto *tp, unsigned long base, u32 handle, 467 - struct nlattr **tca, void **arg, bool ovr, 468 - bool rtnl_held, struct netlink_ext_ack *extack) 467 + struct nlattr **tca, void **arg, u32 flags, 468 + struct netlink_ext_ack *extack) 469 469 { 470 470 struct route4_head *head = rtnl_dereference(tp->root); 471 471 struct route4_filter __rcu **fp; ··· 510 510 } 511 511 512 512 err = route4_set_parms(net, tp, base, f, handle, head, tb, 513 - tca[TCA_RATE], new, ovr, extack); 513 + tca[TCA_RATE], new, flags, extack); 514 514 if (err < 0) 515 515 goto errout; 516 516
+3 -4
net/sched/cls_rsvp.h
··· 470 470 471 471 static int rsvp_change(struct net *net, struct sk_buff *in_skb, 472 472 struct tcf_proto *tp, unsigned long base, 473 - u32 handle, 474 - struct nlattr **tca, 475 - void **arg, bool ovr, bool rtnl_held, 473 + u32 handle, struct nlattr **tca, 474 + void **arg, u32 flags, 476 475 struct netlink_ext_ack *extack) 477 476 { 478 477 struct rsvp_head *data = rtnl_dereference(tp->root); ··· 498 499 err = tcf_exts_init(&e, net, TCA_RSVP_ACT, TCA_RSVP_POLICE); 499 500 if (err < 0) 500 501 return err; 501 - err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, ovr, true, 502 + err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, flags, 502 503 extack); 503 504 if (err < 0) 504 505 goto errout2;
+5 -5
net/sched/cls_tcindex.c
··· 330 330 tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, 331 331 u32 handle, struct tcindex_data *p, 332 332 struct tcindex_filter_result *r, struct nlattr **tb, 333 - struct nlattr *est, bool ovr, struct netlink_ext_ack *extack) 333 + struct nlattr *est, u32 flags, struct netlink_ext_ack *extack) 334 334 { 335 335 struct tcindex_filter_result new_filter_result, *old_r = r; 336 336 struct tcindex_data *cp = NULL, *oldp; ··· 342 342 err = tcf_exts_init(&e, net, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE); 343 343 if (err < 0) 344 344 return err; 345 - err = tcf_exts_validate(net, tp, tb, est, &e, ovr, true, extack); 345 + err = tcf_exts_validate(net, tp, tb, est, &e, flags, extack); 346 346 if (err < 0) 347 347 goto errout; 348 348 ··· 529 529 static int 530 530 tcindex_change(struct net *net, struct sk_buff *in_skb, 531 531 struct tcf_proto *tp, unsigned long base, u32 handle, 532 - struct nlattr **tca, void **arg, bool ovr, 533 - bool rtnl_held, struct netlink_ext_ack *extack) 532 + struct nlattr **tca, void **arg, u32 flags, 533 + struct netlink_ext_ack *extack) 534 534 { 535 535 struct nlattr *opt = tca[TCA_OPTIONS]; 536 536 struct nlattr *tb[TCA_TCINDEX_MAX + 1]; ··· 551 551 return err; 552 552 553 553 return tcindex_set_parms(net, tp, base, handle, p, r, tb, 554 - tca[TCA_RATE], ovr, extack); 554 + tca[TCA_RATE], flags, extack); 555 555 } 556 556 557 557 static void tcindex_walk(struct tcf_proto *tp, struct tcf_walker *walker,
+12 -12
net/sched/cls_u32.c
··· 709 709 static int u32_set_parms(struct net *net, struct tcf_proto *tp, 710 710 unsigned long base, 711 711 struct tc_u_knode *n, struct nlattr **tb, 712 - struct nlattr *est, bool ovr, 712 + struct nlattr *est, u32 flags, 713 713 struct netlink_ext_ack *extack) 714 714 { 715 715 int err; 716 716 717 - err = tcf_exts_validate(net, tp, tb, est, &n->exts, ovr, true, extack); 717 + err = tcf_exts_validate(net, tp, tb, est, &n->exts, flags, extack); 718 718 if (err < 0) 719 719 return err; 720 720 ··· 840 840 841 841 static int u32_change(struct net *net, struct sk_buff *in_skb, 842 842 struct tcf_proto *tp, unsigned long base, u32 handle, 843 - struct nlattr **tca, void **arg, bool ovr, bool rtnl_held, 843 + struct nlattr **tca, void **arg, u32 flags, 844 844 struct netlink_ext_ack *extack) 845 845 { 846 846 struct tc_u_common *tp_c = tp->data; ··· 849 849 struct tc_u32_sel *s; 850 850 struct nlattr *opt = tca[TCA_OPTIONS]; 851 851 struct nlattr *tb[TCA_U32_MAX + 1]; 852 - u32 htid, flags = 0; 852 + u32 htid, userflags = 0; 853 853 size_t sel_size; 854 854 int err; 855 855 ··· 868 868 return err; 869 869 870 870 if (tb[TCA_U32_FLAGS]) { 871 - flags = nla_get_u32(tb[TCA_U32_FLAGS]); 872 - if (!tc_flags_valid(flags)) { 871 + userflags = nla_get_u32(tb[TCA_U32_FLAGS]); 872 + if (!tc_flags_valid(userflags)) { 873 873 NL_SET_ERR_MSG_MOD(extack, "Invalid filter flags"); 874 874 return -EINVAL; 875 875 } ··· 884 884 return -EINVAL; 885 885 } 886 886 887 - if ((n->flags ^ flags) & 887 + if ((n->flags ^ userflags) & 888 888 ~(TCA_CLS_FLAGS_IN_HW | TCA_CLS_FLAGS_NOT_IN_HW)) { 889 889 NL_SET_ERR_MSG_MOD(extack, "Key node flags do not match passed flags"); 890 890 return -EINVAL; ··· 895 895 return -ENOMEM; 896 896 897 897 err = u32_set_parms(net, tp, base, new, tb, 898 - tca[TCA_RATE], ovr, extack); 898 + tca[TCA_RATE], flags, extack); 899 899 900 900 if (err) { 901 901 u32_destroy_key(new, false); ··· 955 955 ht->handle = handle; 956 956 ht->prio = tp->prio; 957 957 idr_init(&ht->handle_idr); 958 - ht->flags = flags; 958 + ht->flags = userflags; 959 959 960 - err = u32_replace_hw_hnode(tp, ht, flags, extack); 960 + err = u32_replace_hw_hnode(tp, ht, userflags, extack); 961 961 if (err) { 962 962 idr_remove(&tp_c->handle_idr, handle); 963 963 kfree(ht); ··· 1038 1038 RCU_INIT_POINTER(n->ht_up, ht); 1039 1039 n->handle = handle; 1040 1040 n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0; 1041 - n->flags = flags; 1041 + n->flags = userflags; 1042 1042 1043 1043 err = tcf_exts_init(&n->exts, net, TCA_U32_ACT, TCA_U32_POLICE); 1044 1044 if (err < 0) ··· 1060 1060 } 1061 1061 #endif 1062 1062 1063 - err = u32_set_parms(net, tp, base, n, tb, tca[TCA_RATE], ovr, 1063 + err = u32_set_parms(net, tp, base, n, tb, tca[TCA_RATE], flags, 1064 1064 extack); 1065 1065 if (err == 0) { 1066 1066 struct tc_u_knode __rcu **ins;