Skip to contentSkip to conversation

net/sched: act_police: add support for packet-per-second policing

PATCH Applied Simon Horman 4 participants 12 messages Mar 12, 2021 – Mar 16, 2021

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

v3 cover net/sched: act_police: add support for packet-per-second policing

This series enhances the TC policer action implementation to allow a policer action instance to enforce a rate-limit based on packets-per-second, configurable using a packet-per-second rate and burst parameters.

In the hope of aiding review this is broken up into three patches.

* [PATCH 1/3] flow_offload: add support for packet-per-second policing

Add support for this feature to the flow_offload API that is used to allow programming flows, including TC rules and their actions, into hardware.

* [PATCH 2/3] flow_offload: reject configuration of packet-per-second policing in offload drivers

Teach all exiting users of the flow_offload API that allow offload of policer action instances to reject offload if packet-per-second rate limiting is configured: none support it at this time

* [PATCH 3/3] net/sched: act_police: add support for packet-per-second policing

With the above ground-work in place add the new feature to the TC policer action itself

With the above in place the feature may be used.

As follow-ups we plan to provide:
* Corresponding updates to iproute2
* Corresponding self tests (which depend on the iproute2 changes)
* Hardware offload support for the NFP driver

Key changes since v2:
* Added patches 1 and 2, which makes adding patch 3 safe for existing hardware offload of the policer action
* Re-worked patch 3 so that a TC policer action instance may be configured for packet-per-second or byte-per-second rate limiting, but not both.
* Corrected kdoc usage

Baowen Zheng (2):
flow_offload: reject configuration of packet-per-second policing in
offload drivers
net/sched: act_police: add support for packet-per-second policing

Xingfeng Hu (1):
flow_offload: add support for packet-per-second policing

 drivers/net/dsa/sja1105/sja1105_flower.c      |  6 ++
 .../chelsio/cxgb4/cxgb4_tc_matchall.c         | 11 ++-
 .../net/ethernet/freescale/enetc/enetc_qos.c  |  5 ++
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   |  4 +
 .../ethernet/mellanox/mlxsw/spectrum_flower.c |  5 ++
 drivers/net/ethernet/mscc/ocelot_flower.c     |  5 ++
 drivers/net/ethernet/mscc/ocelot_net.c        |  6 ++
 .../ethernet/netronome/nfp/flower/qos_conf.c  |  5 ++
 include/net/flow_offload.h                    |  2 +
 include/net/sch_generic.h                     | 14 ++++
 include/net/tc_act/tc_police.h                | 52 +++++++++++++
 include/uapi/linux/pkt_cls.h                  |  2 +
 net/sched/act_police.c                        | 59 +++++++++++++--
 net/sched/cls_api.c                           |  3 +
 net/sched/sch_generic.c                       | 75 ++++++++++++-------
 15 files changed, 221 insertions(+), 33 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v3 1/3 flow_offload: add support for packet-per-second policing

From: Xingfeng Hu <[email protected]>

Allow flow_offload API to configure packet-per-second policing using rate and burst parameters.

Dummy implementations of tcf_police_rate_pkt_ps() and tcf_police_burst_pkt() are supplied which return 0, the unconfigured state. This is to facilitate splitting the offload, driver, and TC code portion of this feature into separate patches with the aim of providing a logical flow for review. And the implementation of these helpers will be filled out by a follow-up patch.

---
 include/net/flow_offload.h     |  2 ++
 include/net/tc_act/tc_police.h | 12 ++++++++++++
 net/sched/cls_api.c            |  3 +++
 3 files changed, 17 insertions(+)
include/net/flow_offload.h +2 -0
index e6bd8ebf9ac3..fde025c57b4f 100644
@@ -234,6 +234,8 @@ struct flow_action_entry {
 			u32			index;
 			u32			burst;
 			u64			rate_bytes_ps;
+			u64			burst_pkt;
+			u64			rate_pkt_ps;
 			u32			mtu;
 		} police;
 		struct {				/* FLOW_ACTION_CT */
include/net/tc_act/tc_police.h +12 -0
index 6d1e26b709b5..ae117f7937d5 100644
@@ -97,6 +97,18 @@ static inline u32 tcf_police_burst(const struct tc_action *act)
 	return burst;
 }
 
+static inline u64 tcf_police_rate_pkt_ps(const struct tc_action *act)
+{
+	/* Not implemented */
+	return 0;
+}
+
+static inline u32 tcf_police_burst_pkt(const struct tc_action *act)
+{
+	/* Not implemented */
+	return 0;
+}
+
 static inline u32 tcf_police_tcfp_mtu(const struct tc_action *act)
 {
 	struct tcf_police *police = to_police(act);
net/sched/cls_api.c +3 -0
index e37556cc37ab..ca8e177bf31b 100644
@@ -3661,6 +3661,9 @@ int tc_setup_flow_action(struct flow_action *flow_action,
 			entry->police.burst = tcf_police_burst(act);
 			entry->police.rate_bytes_ps =
 				tcf_police_rate_bytes_ps(act);
+			entry->police.burst_pkt = tcf_police_burst_pkt(act);
+			entry->police.rate_pkt_ps =
+				tcf_police_rate_pkt_ps(act);
 			entry->police.mtu = tcf_police_tcfp_mtu(act);
 			entry->police.index = act->tcfa_index;
 		} else if (is_tcf_ct(act)) {
Signature · 1 line
2.20.1
#2 lore raw

PATCH v3 2/3 flow_offload: reject configuration of packet-per-second policing in offload drivers

In reply to Simon Horman

From: Baowen Zheng <[email protected]>

A follow-up patch will allow users to configures packet-per-second policing in the software datapath. In preparation for this, teach all drivers that support offload of the policer action to reject such configuration as currently none of them support it.

---
 drivers/net/dsa/sja1105/sja1105_flower.c              |  6 ++++++
 .../net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c    | 11 ++++++++++-
 drivers/net/ethernet/freescale/enetc/enetc_qos.c      |  5 +++++
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c       |  4 ++++
 drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c |  5 +++++
 drivers/net/ethernet/mscc/ocelot_flower.c             |  5 +++++
 drivers/net/ethernet/mscc/ocelot_net.c                |  6 ++++++
 drivers/net/ethernet/netronome/nfp/flower/qos_conf.c  |  5 +++++
 8 files changed, 46 insertions(+), 1 deletion(-)
drivers/net/dsa/sja1105/sja1105_flower.c +6 -0
index 12e76020bea3..f78b767f86ee 100644
@@ -322,6 +322,12 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port,
 	flow_action_for_each(i, act, &rule->action) {
 		switch (act->id) {
 		case FLOW_ACTION_POLICE:
+			if (act->police.rate_pkt_ps) {
+				NL_SET_ERR_MSG_MOD(extack,
+						   "QoS offload not support packets per second");
+				goto out;
+			}
+
 			rc = sja1105_flower_policer(priv, port, extack, cookie,
 						    &key,
 						    act->police.rate_bytes_ps,
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c +10 -1
index 2e309f6673f7..28fd2de9e4cf 100644
@@ -48,6 +48,11 @@ static int cxgb4_matchall_egress_validate(struct net_device *dev,
 	flow_action_for_each(i, entry, actions) {
 		switch (entry->id) {
 		case FLOW_ACTION_POLICE:
+			if (entry->police.rate_pkt_ps) {
+				NL_SET_ERR_MSG_MOD(extack,
+						   "QoS offload not support packets per second");
+				return -EOPNOTSUPP;
+			}
 			/* Convert bytes per second to bits per second */
 			if (entry->police.rate_bytes_ps * 8 > max_link_rate) {
 				NL_SET_ERR_MSG_MOD(extack,
@@ -145,7 +150,11 @@ static int cxgb4_matchall_alloc_tc(struct net_device *dev,
 	flow_action_for_each(i, entry, &cls->rule->action)
 		if (entry->id == FLOW_ACTION_POLICE)
 			break;
-
+	if (entry->police.rate_pkt_ps) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "QoS offload not support packets per second");
+		return -EOPNOTSUPP;
+	}
 	/* Convert from bytes per second to Kbps */
 	p.u.params.maxrate = div_u64(entry->police.rate_bytes_ps * 8, 1000);
 	p.u.params.channel = pi->tx_chan;
drivers/net/ethernet/freescale/enetc/enetc_qos.c +5 -0
index a9aee219fb58..cb7fa4bceaf2 100644
@@ -1221,6 +1221,11 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv,
 
 	/* Flow meter and max frame size */
 	if (entryp) {
+		if (entryp->police.rate_pkt_ps) {
+			NL_SET_ERR_MSG_MOD(extack, "QoS offload not support packets per second");
+			err = -EOPNOTSUPP;
+			goto free_sfi;
+		}
 		if (entryp->police.burst) {
 			fmi = kzalloc(sizeof(*fmi), GFP_KERNEL);
 			if (!fmi) {
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +4 -0
index dc126389291d..1fe745653a53 100644
@@ -4480,6 +4480,10 @@ static int scan_tc_matchall_fdb_actions(struct mlx5e_priv *priv,
 	flow_action_for_each(i, act, flow_action) {
 		switch (act->id) {
 		case FLOW_ACTION_POLICE:
+			if (act->police.rate_pkt_ps) {
+				NL_SET_ERR_MSG_MOD(extack, "QoS offload not support packets per second");
+				return -EOPNOTSUPP;
+			}
 			err = apply_police_params(priv, act->police.rate_bytes_ps, extack);
 			if (err)
 				return err;
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +5 -0
index 41855e58564b..ea637fa552f5 100644
@@ -190,6 +190,11 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
 				return -EOPNOTSUPP;
 			}
 
+			if (act->police.rate_pkt_ps) {
+				NL_SET_ERR_MSG_MOD(extack, "QoS offload not support packets per second");
+				return -EOPNOTSUPP;
+			}
+
 			/* The kernel might adjust the requested burst size so
 			 * that it is not exactly a power of two. Re-adjust it
 			 * here since the hardware only supports burst sizes
drivers/net/ethernet/mscc/ocelot_flower.c +5 -0
index a41b458b1b3e..8b843d3c9189 100644
@@ -220,6 +220,11 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port,
 						   "Last action must be GOTO");
 				return -EOPNOTSUPP;
 			}
+			if (a->police.rate_pkt_ps) {
+				NL_SET_ERR_MSG_MOD(extack,
+						   "QoS offload not support packets per second");
+				return -EOPNOTSUPP;
+			}
 			filter->action.police_ena = true;
 			rate = a->police.rate_bytes_ps;
 			filter->action.pol.rate = div_u64(rate, 1000) * 8;
drivers/net/ethernet/mscc/ocelot_net.c +6 -0
index 12cb6867a2d0..c08164cd88f4 100644
@@ -251,6 +251,12 @@ static int ocelot_setup_tc_cls_matchall(struct ocelot_port_private *priv,
 			return -EEXIST;
 		}
 
+		if (action->police.rate_pkt_ps) {
+			NL_SET_ERR_MSG_MOD(extack,
+					   "QoS offload not support packets per second");
+			return -EOPNOTSUPP;
+		}
+
 		pol.rate = (u32)div_u64(action->police.rate_bytes_ps, 1000) * 8;
 		pol.burst = action->police.burst;
 
drivers/net/ethernet/netronome/nfp/flower/qos_conf.c +5 -0
index d4ce8f9ef3cc..88bea6ad59bc 100644
@@ -104,6 +104,11 @@ nfp_flower_install_rate_limiter(struct nfp_app *app, struct net_device *netdev,
 		return -EOPNOTSUPP;
 	}
 
+	if (action->police.rate_pkt_ps) {
+		NL_SET_ERR_MSG_MOD(extack, "unsupported offload: qos rate limit offload not support packets per second");
+		return -EOPNOTSUPP;
+	}
+
 	rate = action->police.rate_bytes_ps;
 	burst = action->police.burst;
 	netdev_port_id = nfp_repr_get_port_id(netdev);
Signature · 1 line
2.20.1
#3 lore raw

PATCH v3 3/3 net/sched: act_police: add support for packet-per-second policing

In reply to Simon Horman

From: Baowen Zheng <[email protected]>

Allow a policer action to enforce a rate-limit based on packets-per-second, configurable using a packet-per-second rate and burst parameters.

e.g.
tc filter add dev tap1 parent ffff: u32 match \

        u32 0 0 police pkts_rate 3000 pkts_burst 1000

Testing was unable to uncover a performance impact of this change on existing features.

---
 include/net/sch_generic.h      | 14 +++++++
 include/net/tc_act/tc_police.h | 48 ++++++++++++++++++++--
 include/uapi/linux/pkt_cls.h   |  2 +
 net/sched/act_police.c         | 59 ++++++++++++++++++++++----
 net/sched/sch_generic.c        | 75 ++++++++++++++++++++++------------
 5 files changed, 162 insertions(+), 36 deletions(-)
include/net/sch_generic.h +14 -0
index 2d6eb60c58c8..f7a6e14491fb 100644
@@ -1242,6 +1242,20 @@ static inline void psched_ratecfg_getrate(struct tc_ratespec *res,
 	res->linklayer = (r->linklayer & TC_LINKLAYER_MASK);
 }
 
+struct psched_pktrate {
+	u64	rate_pkts_ps; /* packets per second */
+	u32	mult;
+	u8	shift;
+};
+
+static inline u64 psched_pkt2t_ns(const struct psched_pktrate *r,
+				  unsigned int pkt_num)
+{
+	return ((u64)pkt_num * r->mult) >> r->shift;
+}
+
+void psched_ppscfg_precompute(struct psched_pktrate *r, u64 pktrate64);
+
 /* Mini Qdisc serves for specific needs of ingress/clsact Qdisc.
  * The fast path only needs to access filter list and to update stats
  */
include/net/tc_act/tc_police.h +44 -4

74 lines not on this page · raw message

include/uapi/linux/pkt_cls.h +2 -0
index 7ea59cfe1fa7..025c40fef93d 100644
@@ -190,6 +190,8 @@ enum {
 	TCA_POLICE_PAD,
 	TCA_POLICE_RATE64,
 	TCA_POLICE_PEAKRATE64,
+	TCA_POLICE_PKTRATE64,
+	TCA_POLICE_PKTBURST64,
 	__TCA_POLICE_MAX
 #define TCA_POLICE_RESULT TCA_POLICE_RESULT
 };
net/sched/act_police.c +52 -7

111 lines not on this page · raw message

net/sched/sch_generic.c +50 -25

90 lines not on this page · raw message

Signature · 1 line
2.20.1
#4 lore raw
In reply to Simon Horman
Quoted 4 lines · Simon Horman

This series enhances the TC policer action implementation to allow a policer action instance to enforce a rate-limit based on packets-per-second, configurable using a packet-per-second rate and burst parameters.

...

Sorry, I missed CCing a number of interested parties when posting this patch-set. I've added them to this email.

Ref: https://lore.kernel.org/netdev/[email protected]/

maintainer Reviewed-by
#5 lore raw
Quoted 6 lines · Simon Horman
Quoted 4 lines · Simon Horman

This series enhances the TC policer action implementation to allow a policer action instance to enforce a rate-limit based on packets-per-second, configurable using a packet-per-second rate and burst parameters.

Quoted 7 lines

...

Sorry, I missed CCing a number of interested parties when posting this patch-set. I've added them to this email.

Ref: https://lore.kernel.org/netdev/[email protected]/

For 2/3:

If you submit one or two testcases to tools/testing/selftests/tc-testing you'll be both a hero and someone committing an act of kindness.

cheers,
jamal

#6 lore raw
Quoted 12 lines · Jamal Hadi Salim
Quoted 11 lines · Simon Horman
Quoted 4 lines · Simon Horman

This series enhances the TC policer action implementation to allow a policer action instance to enforce a rate-limit based on packets-per-second, configurable using a packet-per-second rate and burst parameters.

...

Sorry, I missed CCing a number of interested parties when posting this patch-set. I've added them to this email.

Quoted 8 lines
Quoted 2 lines

Ref: https://lore.kernel.org/netdev/[email protected]/

For 2/3:

If you submit one or two testcases to tools/testing/selftests/tc-testing you'll be both a hero and someone committing an act of kindness.

Thanks Jamal,

my team are heroes and are working on testcases.

#7 lore raw
In reply to Simon Horman
This series was applied to netdev/net-next.git (refs/heads/master):

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

Quoted 8 lines · On Fri, 12 Mar 2021 15:08:28 +0100 you wrote:

This series enhances the TC policer action implementation to allow a policer action instance to enforce a rate-limit based on packets-per-second, configurable using a packet-per-second rate and burst parameters.

In the hope of aiding review this is broken up into three patches.

[...]

Here is the summary with links:
- [v3,net-next,1/3] flow_offload: add support for packet-per-second policing

    https://git.kernel.org/netdev/net-next/c/25660156f4cc
  - [v3,net-next,2/3] flow_offload: reject configuration of packet-per-second policing in offload drivers
    https://git.kernel.org/netdev/net-next/c/6a56e19902af
  - [v3,net-next,3/3] net/sched: act_police: add support for packet-per-second policing
    https://git.kernel.org/netdev/net-next/c/2ffe0395288a

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

#8 lore raw
In reply to Simon Horman
Quoted 20 lines · Simon Horman

This series enhances the TC policer action implementation to allow a policer action instance to enforce a rate-limit based on packets-per-second, configurable using a packet-per-second rate and burst parameters.

In the hope of aiding review this is broken up into three patches.

* [PATCH 1/3] flow_offload: add support for packet-per-second policing

Add support for this feature to the flow_offload API that is used to allow programming flows, including TC rules and their actions, into hardware.

* [PATCH 2/3] flow_offload: reject configuration of packet-per-second policing in offload drivers

Teach all exiting users of the flow_offload API that allow offload of policer action instances to reject offload if packet-per-second rate limiting is configured: none support it at this time

* [PATCH 3/3] net/sched: act_police: add support for packet-per-second policing

Quoted 8 lines

With the above ground-work in place add the new feature to the TC policer action itself

With the above in place the feature may be used.

As follow-ups we plan to provide:
* Corresponding updates to iproute2
* Corresponding self tests (which depend on the iproute2 changes)

I was about to ask :)

FYI, there is this selftest:
tools/testing/selftests/net/forwarding/tc_police.sh

Which can be extended to also test packet rate policing

Quoted 8 lines

* Hardware offload support for the NFP driver

Key changes since v2:
* Added patches 1 and 2, which makes adding patch 3 safe for existing hardware offload of the policer action
* Re-worked patch 3 so that a TC policer action instance may be configured for packet-per-second or byte-per-second rate limiting, but not both.
* Corrected kdoc usage

Thanks!

#9 lore raw
Quoted 30 lines · Ido Schimmel
Quoted 20 lines · Simon Horman

This series enhances the TC policer action implementation to allow a policer action instance to enforce a rate-limit based on packets-per-second, configurable using a packet-per-second rate and burst parameters.

In the hope of aiding review this is broken up into three patches.

* [PATCH 1/3] flow_offload: add support for packet-per-second policing

Add support for this feature to the flow_offload API that is used to allow programming flows, including TC rules and their actions, into hardware.

* [PATCH 2/3] flow_offload: reject configuration of packet-per-second policing in offload drivers

Teach all exiting users of the flow_offload API that allow offload of policer action instances to reject offload if packet-per-second rate limiting is configured: none support it at this time

* [PATCH 3/3] net/sched: act_police: add support for packet-per-second policing

Quoted 8 lines

With the above ground-work in place add the new feature to the TC policer action itself

With the above in place the feature may be used.

As follow-ups we plan to provide:
* Corresponding updates to iproute2
* Corresponding self tests (which depend on the iproute2 changes)

Quoted 6 lines

I was about to ask :)

FYI, there is this selftest:
tools/testing/selftests/net/forwarding/tc_police.sh

Which can be extended to also test packet rate policing

Thanks Ido,

The approach we have taken is to add tests to tools/testing/selftests/tc-testing/tc-tests/actions/police.json

Do you think adding a test to tc_police.sh is also worthwhile? Or should be done instead of updating police.json?

Lastly, my assumption is that the tests should be posted once iproute2 changes they depend on have been accepted. Is this correct in your opinion?

In any case, I'll get moving on posting the iproute2 changes.

Quoted 10 lines
Quoted 8 lines

* Hardware offload support for the NFP driver

Key changes since v2:
* Added patches 1 and 2, which makes adding patch 3 safe for existing hardware offload of the policer action
* Re-worked patch 3 so that a TC policer action instance may be configured for packet-per-second or byte-per-second rate limiting, but not both.
* Corrected kdoc usage

Thanks!

#10 lore raw

Sorry for the delay. Was AFK yesterday

Quoted 38 lines · Simon Horman
Quoted 30 lines · Ido Schimmel
Quoted 20 lines · Simon Horman

This series enhances the TC policer action implementation to allow a policer action instance to enforce a rate-limit based on packets-per-second, configurable using a packet-per-second rate and burst parameters.

In the hope of aiding review this is broken up into three patches.

* [PATCH 1/3] flow_offload: add support for packet-per-second policing

Add support for this feature to the flow_offload API that is used to allow programming flows, including TC rules and their actions, into hardware.

* [PATCH 2/3] flow_offload: reject configuration of packet-per-second policing in offload drivers

Teach all exiting users of the flow_offload API that allow offload of policer action instances to reject offload if packet-per-second rate limiting is configured: none support it at this time

* [PATCH 3/3] net/sched: act_police: add support for packet-per-second policing

Quoted 8 lines

With the above ground-work in place add the new feature to the TC policer action itself

With the above in place the feature may be used.

As follow-ups we plan to provide:
* Corresponding updates to iproute2
* Corresponding self tests (which depend on the iproute2 changes)

Quoted 6 lines

I was about to ask :)

FYI, there is this selftest:
tools/testing/selftests/net/forwarding/tc_police.sh

Which can be extended to also test packet rate policing

Quoted 7 lines

Thanks Ido,

The approach we have taken is to add tests to tools/testing/selftests/tc-testing/tc-tests/actions/police.json

Do you think adding a test to tc_police.sh is also worthwhile? Or should be done instead of updating police.json?

IIUC, police.json only performs configuration tests. tc_police.sh on the other hand, configures a topology, injects traffic and validates that the bandwidth after the police action is according to user configuration. You can test the software data path by using veth pairs or the hardware data path by using physical ports looped to each other.

So I think that extending both tests is worthwhile.

Quoted 3 lines

Lastly, my assumption is that the tests should be posted once iproute2 changes they depend on have been accepted. Is this correct in your opinion?

Personally, I prefer selftests to be posted together with the implementation, regardless if they depend on new iproute2 functionality. In the unlikely case that the kernel patches were accepted, but changes were requested for the command line interface, you can always patch the selftests later.

Jakub recently added this section:
https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html#how-do-i-post-corresponding-changes-to-user-space-components

He writes "User space code exercising kernel features should be posted alongside kernel patches."

And you can see that in the example the last patch is a selftest:

```
[PATCH net-next 0/3] net: some feature cover letter
 └─ [PATCH net-next 1/3] net: some feature prep
 └─ [PATCH net-next 2/3] net: some feature do it
 └─ [PATCH net-next 3/3] selftest: net: some feature

[PATCH iproute2-next] ip: add support for some feature
```
Quoted 2 lines

In any case, I'll get moving on posting the iproute2 changes.

Thanks!

Quoted 11 lines
Quoted 11 lines
Quoted 9 lines

* Hardware offload support for the NFP driver

Key changes since v2:
* Added patches 1 and 2, which makes adding patch 3 safe for existing hardware offload of the policer action
* Re-worked patch 3 so that a TC policer action instance may be configured for packet-per-second or byte-per-second rate limiting, but not both.
* Corrected kdoc usage

Thanks!

#11 lore raw

Hi Ido,

Quoted 1 line · Ido Schimmel

Sorry for the delay. Was AFK yesterday

No problem at all.

...

Quoted 19 lines
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines

As follow-ups we plan to provide:
* Corresponding updates to iproute2
* Corresponding self tests (which depend on the iproute2 changes)

I was about to ask :)

FYI, there is this selftest:
tools/testing/selftests/net/forwarding/tc_police.sh

Which can be extended to also test packet rate policing

Quoted 7 lines

Thanks Ido,

The approach we have taken is to add tests to tools/testing/selftests/tc-testing/tc-tests/actions/police.json

Do you think adding a test to tc_police.sh is also worthwhile? Or should be done instead of updating police.json?

Quoted 7 lines

IIUC, police.json only performs configuration tests. tc_police.sh on the other hand, configures a topology, injects traffic and validates that the bandwidth after the police action is according to user configuration. You can test the software data path by using veth pairs or the hardware data path by using physical ports looped to each other.

So I think that extending both tests is worthwhile.

Thanks, we'll see about making it so.

Quoted 17 lines
Quoted 2 lines

Lastly, my assumption is that the tests should be posted once iproute2 changes they depend on have been accepted. Is this correct in your opinion?

Personally, I prefer selftests to be posted together with the implementation, regardless if they depend on new iproute2 functionality. In the unlikely case that the kernel patches were accepted, but changes were requested for the command line interface, you can always patch the selftests later.

Jakub recently added this section:
https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html#how-do-i-post-corresponding-changes-to-user-space-components

He writes "User space code exercising kernel features should be posted alongside kernel patches."

And you can see that in the example the last patch is a selftest:

Quoted 8 lines
```
[PATCH net-next 0/3] net: some feature cover letter
 └─ [PATCH net-next 1/3] net: some feature prep
 └─ [PATCH net-next 2/3] net: some feature do it
 └─ [PATCH net-next 3/3] selftest: net: some feature

[PATCH iproute2-next] ip: add support for some feature
```

Thanks, we'll try to follow this in our next feature submission.

...