diff mbox series

[ovs-dev,v2] vswitch: ratelimit the device add log

Message ID 20190916151657.25642-1-aconole@redhat.com
State Accepted
Commit 45bd8c563273fb914ff1960a53cfdcfddb0a5588
Headers show
Series [ovs-dev,v2] vswitch: ratelimit the device add log | expand

Commit Message

Aaron Conole Sept. 16, 2019, 3:16 p.m. UTC
It's possible that a port added to the system with certain kinds
of invalid parameters will cause the 'could not add' log to be
triggered.  When this happens, the vswitch run loop can continually
re-attempt adding the port.  While the parameters remain invalid
the vswitch run loop will re-trigger the warning, flooding the
syslog.

This patch adds a simple rate limit to the log.

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
v2: set errp

 vswitchd/bridge.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

William Tu Sept. 16, 2019, 11:57 p.m. UTC | #1
On Mon, Sep 16, 2019 at 8:17 AM Aaron Conole <aconole@redhat.com> wrote:
>
> It's possible that a port added to the system with certain kinds
> of invalid parameters will cause the 'could not add' log to be
> triggered.  When this happens, the vswitch run loop can continually
> re-attempt adding the port.  While the parameters remain invalid
> the vswitch run loop will re-trigger the warning, flooding the
> syslog.
>
> This patch adds a simple rate limit to the log.
>
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
LGTM
Acked-by: William Tu <u9012063@gmail.com>

> v2: set errp
>
>  vswitchd/bridge.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
> index d921c4ef8..8c390382f 100644
> --- a/vswitchd/bridge.c
> +++ b/vswitchd/bridge.c
> @@ -1816,8 +1816,13 @@ iface_do_create(const struct bridge *br,
>      *ofp_portp = iface_pick_ofport(iface_cfg);
>      error = ofproto_port_add(br->ofproto, netdev, ofp_portp);
>      if (error) {
> -        VLOG_WARN_BUF(errp, "could not add network device %s to ofproto (%s)",
> -                      iface_cfg->name, ovs_strerror(error));
> +        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
> +
> +        *errp = xasprintf("could not add network device %s to ofproto (%s)",
> +                          iface_cfg->name, ovs_strerror(error));
> +        if (!VLOG_DROP_WARN(&rl)) {
> +            VLOG_WARN("%s", *errp);
> +        }
>          goto error;
>      }
>
> --
> 2.21.0
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Ben Pfaff Sept. 23, 2019, 10:30 p.m. UTC | #2
On Mon, Sep 16, 2019 at 11:16:57AM -0400, Aaron Conole wrote:
> It's possible that a port added to the system with certain kinds
> of invalid parameters will cause the 'could not add' log to be
> triggered.  When this happens, the vswitch run loop can continually
> re-attempt adding the port.  While the parameters remain invalid
> the vswitch run loop will re-trigger the warning, flooding the
> syslog.
> 
> This patch adds a simple rate limit to the log.
> 
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
> v2: set errp

Thanks, Aaron (and William).  I applied this to master.
diff mbox series

Patch

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index d921c4ef8..8c390382f 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1816,8 +1816,13 @@  iface_do_create(const struct bridge *br,
     *ofp_portp = iface_pick_ofport(iface_cfg);
     error = ofproto_port_add(br->ofproto, netdev, ofp_portp);
     if (error) {
-        VLOG_WARN_BUF(errp, "could not add network device %s to ofproto (%s)",
-                      iface_cfg->name, ovs_strerror(error));
+        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+
+        *errp = xasprintf("could not add network device %s to ofproto (%s)",
+                          iface_cfg->name, ovs_strerror(error));
+        if (!VLOG_DROP_WARN(&rl)) {
+            VLOG_WARN("%s", *errp);
+        }
         goto error;
     }