#define POLICE_ADD_CMD "/sbin/tc qdisc add dev %s handle ffff: ingress"
#define POLICE_CONFIG_CMD "/sbin/tc filter add dev %s parent ffff: protocol ip prio 50 u32 match ip src 0.0.0.0/0 police rate %dkbit burst %dk mtu 65535 drop flowid :1"
-#define POLICE_DEL_CMD "/sbin/tc qdisc del dev %s handle ffff: ingress"
+/* We redirect stderr to /dev/null because we often want to remove all
+ * traffic control configuration on a port so its in a known state. If
+ * this done when there is no such configuration, tc complains, so we just
+ * always ignore it.
+ */
+#define POLICE_DEL_CMD "/sbin/tc qdisc del dev %s handle ffff: ingress 2>/dev/null"
/* Attempts to set input rate limiting (policing) policy. */
int
/* xxx This should be more careful about only adding if it
* xxx actually exists, as opposed to always deleting it. */
snprintf(command, sizeof(command), POLICE_DEL_CMD, netdev_name);
- system(command);
+ if (system(command) == -1) {
+ VLOG_WARN_RL(&rl, "%s: problem removing policing", netdev_name);
+ }
snprintf(command, sizeof(command), POLICE_ADD_CMD, netdev_name);
if (system(command) != 0) {
}
} else {
snprintf(command, sizeof(command), POLICE_DEL_CMD, netdev_name);
- if (system(command) != 0) {
+ if (system(command) == -1) {
VLOG_WARN_RL(&rl, "%s: problem removing policing", netdev_name);
- return -1;
}
}