@@ -2448,6 +2448,7 @@ netdev_linux_set_policing(struct netdev *netdev_,
const char *netdev_name = netdev_get_name(netdev_);
int ifindex;
int error;
+ bool should_cleanup_ingress = false;
kbits_burst = (!kbits_rate ? 0 /* Force to 0 if no rate specified. */
: !kbits_burst ? 8000 /* Default to 8000 kbits if 0. */
@@ -2466,14 +2467,10 @@ netdev_linux_set_policing(struct netdev *netdev_,
/* Assume that settings haven't changed since we last set them. */
goto out;
}
+ should_cleanup_ingress = true;
netdev->cache_valid &= ~VALID_POLICING;
}
- error = get_ifindex(netdev_, &ifindex);
- if (error) {
- goto out;
- }
-
COVERAGE_INC(netdev_set_policing);
/* Use matchall for policing when offloadling ovs with tc-flower. */
@@ -2486,14 +2483,20 @@ netdev_linux_set_policing(struct netdev *netdev_,
return error;
}
- /* Remove any existing ingress qdisc. */
- error = tc_add_del_ingress_qdisc(ifindex, false, 0);
+ error = get_ifindex(netdev_, &ifindex);
if (error) {
- VLOG_WARN_RL(&rl, "%s: removing policing failed: %s",
- netdev_name, ovs_strerror(error));
goto out;
}
+ if (should_cleanup_ingress) {
+ error = tc_add_del_ingress_qdisc(ifindex, false, 0);
+ if (error) {
+ VLOG_WARN_RL(&rl, "%s: removing policing failed: %s",
+ netdev_name, ovs_strerror(error));
+ goto out;
+ }
+ }
+
if (kbits_rate) {
error = tc_add_del_ingress_qdisc(ifindex, true, 0);
if (error) {
In some case, we may not use the openvswitch tc to limit the ingress police rate. And before we add the port to openvswitch bridge, we may set the ingress policer, so don't remove the ingress when we not configured it in openvswitch. Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com> --- lib/netdev-linux.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)