2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-01 14:55:18 +00:00

Fix non-static instances of "struct vlog_rate_limit" and add check.

A non-static vlog_rate_limit is not actually going to rate-limit anything.
This commit is contained in:
Ben Pfaff
2011-01-12 09:22:12 -08:00
parent 815bba308c
commit db5ce51427
5 changed files with 20 additions and 9 deletions

View File

@@ -124,6 +124,17 @@ distfiles: Makefile
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t" | sort -u > $@
CLEANFILES += distfiles
# Check that "struct vlog_ratelimit" is always declared "static".
ALL_LOCAL += rate-limit-check
rate-limit-check:
@if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
git --no-pager grep -n -E '^[ ]+struct vlog_rate_limit.*=' $(srcdir); \
then \
echo "See above for list of violations of the rule that "; \
echo "'struct vlog_rate_limit' must always be 'static'"; \
exit 1; \
fi
dist-hook: $(DIST_HOOKS)
all-local: $(ALL_LOCAL)
clean-local: $(CLEAN_LOCAL)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2010 Nicira Networks.
* Copyright (c) 2009, 2010, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -966,7 +966,7 @@ dp_netdev_run(void)
if (!error) {
dp_netdev_port_input(dp, port, &packet);
} else if (error != EAGAIN && error != EOPNOTSUPP) {
struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_ERR_RL(&rl, "error receiving data from %s: %s",
netdev_get_name(port->netdev), strerror(error));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2009, 2010 Nicira Networks.
* Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -114,7 +114,7 @@ int
lookup_ip(const char *host_name, struct in_addr *addr)
{
if (!inet_aton(host_name, addr)) {
struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_ERR_RL(&rl, "\"%s\" is not a valid IP address", host_name);
return ENOENT;
}
@@ -129,7 +129,7 @@ get_socket_error(int fd)
int error;
socklen_t len = sizeof(error);
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 10);
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 10);
error = errno;
VLOG_ERR_RL(&rl, "getsockopt(SO_ERROR): %s", strerror(error));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2010 Nicira Networks.
* Copyright (c) 2009, 2010, 2011 Nicira Networks.
* Copyright (c) 2010 Jean Tourrilhes - HP-Labs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -2681,7 +2681,7 @@ xlate_table_action(struct action_xlate_ctx *ctx, uint16_t in_port)
ctx->recurse--;
}
} else {
struct vlog_rate_limit recurse_rl = VLOG_RATE_LIMIT_INIT(1, 1);
static struct vlog_rate_limit recurse_rl = VLOG_RATE_LIMIT_INIT(1, 1);
VLOG_ERR_RL(&recurse_rl, "NXAST_RESUBMIT recursed over %d times",
MAX_RESUBMIT_RECURSION);

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2009, 2010 Nicira Networks
/* Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -917,7 +917,7 @@ handle_fdb_query_cmd(const struct ovsrec_open_vswitch *ovs,
if (sscanf(line, "%d %d "ETH_ADDR_SCAN_FMT" %d",
&port, &vlan, ETH_ADDR_SCAN_ARGS(mac), &age)
!= 2 + ETH_ADDR_SCAN_COUNT + 1) {
struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
VLOG_INFO_RL(&rl, "fdb/show output has invalid format: %s", line);
continue;
}