diff options
author | Ben Pfaff <blp@nicira.com> | 2010-07-16 11:02:49 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2010-07-21 15:47:09 -0700 |
commit | 5136ce492c414f377f7be9ae32b259abb9f76580 (patch) | |
tree | 3590fa980be1d23746938e60ac992849d0b39edc | |
parent | 9200fb9ef9a1c55a76e4c4aa789f3fb0a76f0ed1 (diff) |
vlog: Introduce VLOG_DEFINE_THIS_MODULE for declaring vlog module in use.
Adding a macro to define the vlog module in use adds a level of
indirection, which makes it easier to change how the vlog module must be
defined. A followup commit needs to do that, so getting these widespread
changes out of the way first should make that commit easier to review.
78 files changed, 167 insertions, 164 deletions
diff --git a/extras/ezio/ezio-term.c b/extras/ezio/ezio-term.c index f7645528..b41a7c02 100644 --- a/extras/ezio/ezio-term.c +++ b/extras/ezio/ezio-term.c @@ -37,10 +37,10 @@ #include "terminal.h" #include "timeval.h" #include "util.h" - -#define THIS_MODULE VLM_ezio_term #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(ezio_term) + /* EZIO button status. */ enum btn_status { BTN_UP = 1 << 0, diff --git a/extras/ezio/ovs-switchui.c b/extras/ezio/ovs-switchui.c index b1ba8d24..092eb1e5 100644 --- a/extras/ezio/ovs-switchui.c +++ b/extras/ezio/ovs-switchui.c @@ -49,10 +49,10 @@ #include "timeval.h" #include "util.h" #include "vconn.h" +#include "vlog.h" #include "xtoxll.h" -#define THIS_MODULE VLM_switchui -#include "vlog.h" +VLOG_DEFINE_THIS_MODULE(switchui) static void parse_options(int argc, char *argv[]); static void usage(void); diff --git a/extras/ezio/terminal.c b/extras/ezio/terminal.c index 090e80e4..3e499ab0 100644 --- a/extras/ezio/terminal.c +++ b/extras/ezio/terminal.c @@ -26,10 +26,10 @@ #include "ezio.h" #include "poll-loop.h" #include "util.h" - -#define THIS_MODULE VLM_terminal #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(terminal) + /* UTF-8 decoding. */ static struct utf8_reader *utf8_reader_create(void); static void utf8_reader_destroy(struct utf8_reader *); diff --git a/extras/ezio/tty.c b/extras/ezio/tty.c index 43288285..a4bb14ce 100644 --- a/extras/ezio/tty.c +++ b/extras/ezio/tty.c @@ -28,10 +28,10 @@ #include "fatal-signal.h" #include "socket-util.h" #include "util.h" - -#define THIS_MODULE VLM_tty #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(tty) + /* Get major() and minor() macros. */ #if MAJOR_IN_MKDEV # include <sys/mkdev.h> diff --git a/extras/ezio/vt-dummy.c b/extras/ezio/vt-dummy.c index c1de6c80..18da821d 100644 --- a/extras/ezio/vt-dummy.c +++ b/extras/ezio/vt-dummy.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2009 Nicira Networks, Inc. +/* Copyright (c) 2008, 2009, 2010 Nicira Networks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,10 @@ #include <config.h> #include "extras/ezio/vt.h" #include <errno.h> - -#define THIS_MODULE VLM_vt #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(vt) + int vt_open(int open_flags) { diff --git a/extras/ezio/vt-linux.c b/extras/ezio/vt-linux.c index 92f7ebb6..b281c897 100644 --- a/extras/ezio/vt-linux.c +++ b/extras/ezio/vt-linux.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2009 Nicira Networks, Inc. +/* Copyright (c) 2008, 2009, 2010 Nicira Networks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +24,10 @@ #include <sys/ioctl.h> #include <unistd.h> #include "util.h" - -#define THIS_MODULE VLM_vt #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(vt) + static bool get_console_fd(int *fd); int diff --git a/lib/automake.mk b/lib/automake.mk index 71e4d61f..046e9ab6 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -274,8 +274,8 @@ check-for-unused-vlog-modules: lib/vlog-modules.def | \ LC_ALL=C sort -u | \ xargs echo`; \ - used_vlog=`git grep VLM_ | \ - sed -n 's/.*VLM_\([a-z_0-9]\{1,\}\).*/\1/p' | \ + used_vlog=`git grep VLOG_DEFINE_THIS_MODULE | \ + sed -n 's/.*VLOG_DEFINE_THIS_MODULE(\([a-z_0-9]\{1,\}\)).*/\1/p' | \ LC_ALL=C sort -u | \ xargs echo`; \ rc=0; \ diff --git a/lib/backtrace.c b/lib/backtrace.c index 80cae54a..131bdf4f 100644 --- a/lib/backtrace.c +++ b/lib/backtrace.c @@ -21,10 +21,10 @@ #include <stdbool.h> #include <stdio.h> #include "compiler.h" - -#define THIS_MODULE VLM_backtrace #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(backtrace) + static uintptr_t OVS_UNUSED get_max_stack(void) { diff --git a/lib/coverage.c b/lib/coverage.c index 5c99c18a..6e65810e 100644 --- a/lib/coverage.c +++ b/lib/coverage.c @@ -23,10 +23,10 @@ #include "hash.h" #include "unixctl.h" #include "util.h" - -#define THIS_MODULE VLM_coverage #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(coverage) + static unsigned int epoch; static void diff --git a/lib/daemon.c b/lib/daemon.c index 59628f23..6cb553ac 100644 --- a/lib/daemon.c +++ b/lib/daemon.c @@ -32,10 +32,10 @@ #include "socket-util.h" #include "timeval.h" #include "util.h" - -#define THIS_MODULE VLM_daemon #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(daemon) + /* Should we run in the background? */ static bool detach; diff --git a/lib/dhcp-client.c b/lib/dhcp-client.c index 7168361f..961994a2 100644 --- a/lib/dhcp-client.c +++ b/lib/dhcp-client.c @@ -35,10 +35,10 @@ #include "poll-loop.h" #include "sat-math.h" #include "timeval.h" - -#define THIS_MODULE VLM_dhcp_client #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(dhcp_client) + #define DHCLIENT_STATES \ DHCLIENT_STATE(INIT, 1 << 0) \ DHCLIENT_STATE(INIT_REBOOT, 1 << 1) \ @@ -24,10 +24,10 @@ #include <stdlib.h> #include "dynamic-string.h" #include "ofpbuf.h" - -#define THIS_MODULE VLM_dhcp #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(dhcp) + /* Information about a DHCP argument type. */ struct arg_type { const char *name; /* Name. */ diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index 432d5ed1..52d73c6b 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -41,9 +41,9 @@ #include "shash.h" #include "svec.h" #include "util.h" - #include "vlog.h" -#define THIS_MODULE VLM_dpif_linux + +VLOG_DEFINE_THIS_MODULE(dpif_linux) /* Datapath interface for the openvswitch Linux kernel module. */ struct dpif_linux { diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index fc117d20..15ff0d55 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -45,9 +45,9 @@ #include "queue.h" #include "timeval.h" #include "util.h" - #include "vlog.h" -#define THIS_MODULE VLM_dpif_netdev + +VLOG_DEFINE_THIS_MODULE(dpif_netdev) /* Configuration parameters. */ enum { N_QUEUES = 2 }; /* Number of queues for dpif_recv(). */ @@ -37,9 +37,9 @@ #include "svec.h" #include "util.h" #include "valgrind.h" - #include "vlog.h" -#define THIS_MODULE VLM_dpif + +VLOG_DEFINE_THIS_MODULE(dpif) static const struct dpif_class *base_dpif_classes[] = { #ifdef HAVE_NETLINK diff --git a/lib/fatal-signal.c b/lib/fatal-signal.c index 0f360368..d9442a3e 100644 --- a/lib/fatal-signal.c +++ b/lib/fatal-signal.c @@ -28,10 +28,10 @@ #include "shash.h" #include "socket-util.h" #include "util.h" - -#define THIS_MODULE VLM_fatal_signal #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(fatal_signal) + /* Signals to catch. */ static const int fatal_signals[] = { SIGTERM, SIGINT, SIGHUP, SIGALRM }; @@ -28,10 +28,10 @@ #include "openvswitch/datapath-protocol.h" #include "packets.h" #include "unaligned.h" +#include "vlog.h" #include "xtoxll.h" -#include "vlog.h" -#define THIS_MODULE VLM_flow +VLOG_DEFINE_THIS_MODULE(flow) static struct arp_eth_header * pull_arp(struct ofpbuf *packet) diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index 32d34b4f..5d394c68 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -32,9 +32,9 @@ #include "reconnect.h" #include "stream.h" #include "timeval.h" - -#define THIS_MODULE VLM_jsonrpc #include "vlog.h" + +VLOG_DEFINE_THIS_MODULE(jsonrpc) struct jsonrpc { struct stream *stream; diff --git a/lib/leak-checker.c b/lib/leak-checker.c index 4ab55e59..28beb0b3 100644 --- a/lib/leak-checker.c +++ b/lib/leak-checker.c @@ -18,10 +18,10 @@ #include "leak-checker.h" #include <inttypes.h> #include "backtrace.h" - -#define THIS_MODULE VLM_leak_checker #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(leak_checker) + #ifndef HAVE_MALLOC_HOOKS void leak_checker_start(const char *file_name OVS_UNUSED) diff --git a/lib/learning-switch.c b/lib/learning-switch.c index 97c424a6..d2da2523 100644 --- a/lib/learning-switch.c +++ b/lib/learning-switch.c @@ -35,10 +35,10 @@ #include "stp.h" #include "timeval.h" #include "vconn.h" +#include "vlog.h" #include "xtoxll.h" -#define THIS_MODULE VLM_learning_switch -#include "vlog.h" +VLOG_DEFINE_THIS_MODULE(learning_switch) enum port_state { P_DISABLED = 1 << 0, diff --git a/lib/lockfile.c b/lib/lockfile.c index 100440e9..84bfb3c0 100644 --- a/lib/lockfile.c +++ b/lib/lockfile.c @@ -29,10 +29,10 @@ #include "hmap.h" #include "timeval.h" #include "util.h" - -#define THIS_MODULE VLM_lockfile #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(lockfile) + struct lockfile { struct hmap_node hmap_node; char *name; diff --git a/lib/mac-learning.c b/lib/mac-learning.c index 5d64f543..c8582f31 100644 --- a/lib/mac-learning.c +++ b/lib/mac-learning.c @@ -29,10 +29,10 @@ #include "tag.h" #include "timeval.h" #include "util.h" - -#define THIS_MODULE VLM_mac_learning #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(mac_learning) + /* Returns the number of seconds since 'e' was last learned. */ int mac_entry_age(const struct mac_entry *e) diff --git a/lib/netdev-gre.c b/lib/netdev-gre.c index 25e0a646..aecc77ed 100644 --- a/lib/netdev-gre.c +++ b/lib/netdev-gre.c @@ -27,10 +27,10 @@ #include "openvswitch/gre.h" #include "packets.h" #include "socket-util.h" - -#define THIS_MODULE VLM_netdev_gre #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(netdev_gre) + struct netdev_dev_gre { struct netdev_dev netdev_dev; }; diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 09a46129..a20a1c4d 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -61,9 +61,9 @@ #include "socket-util.h" #include "shash.h" #include "svec.h" - -#define THIS_MODULE VLM_netdev_linux #include "vlog.h" + +VLOG_DEFINE_THIS_MODULE(netdev_linux) /* These were introduced in Linux 2.6.14, so they might be missing if we have * old headers. */ diff --git a/lib/netdev-patch.c b/lib/netdev-patch.c index 1340eb71..7e8b1990 100644 --- a/lib/netdev-patch.c +++ b/lib/netdev-patch.c @@ -26,10 +26,10 @@ #include "openvswitch/datapath-protocol.h" #include "packets.h" #include "socket-util.h" - -#define THIS_MODULE VLM_netdev_patch #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(netdev_patch) + struct netdev_dev_patch { struct netdev_dev netdev_dev; }; diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index 58858f90..96834115 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -24,10 +24,10 @@ #include "openvswitch/datapath-protocol.h" #include "shash.h" #include "socket-util.h" - -#define THIS_MODULE VLM_netdev_vport #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(netdev_vport) + struct netdev_vport_notifier { struct netdev_notifier notifier; struct list list_node; diff --git a/lib/netdev.c b/lib/netdev.c index 38f4dd58..7d834ad0 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -37,10 +37,10 @@ #include "poll-loop.h" #include "shash.h" #include "svec.h" - -#define THIS_MODULE VLM_netdev #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(netdev) + static const struct netdev_class *base_netdev_classes[] = { #ifdef HAVE_NETLINK &netdev_linux_class, diff --git a/lib/netlink.c b/lib/netlink.c index d59f65e0..2f7bc0a1 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -31,9 +31,9 @@ #include "poll-loop.h" #include "timeval.h" #include "util.h" - #include "vlog.h" -#define THIS_MODULE VLM_netlink + +VLOG_DEFINE_THIS_MODULE(netlink) /* Linux header file confusion causes this to be undefined. */ #ifndef SOL_NETLINK diff --git a/lib/ofp-util.c b/lib/ofp-util.c index cedeb670..fd54a03e 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -22,10 +22,10 @@ #include "ofpbuf.h" #include "packets.h" #include "random.h" +#include "vlog.h" #include "xtoxll.h" -#define THIS_MODULE VLM_ofp_util -#include "vlog.h" +VLOG_DEFINE_THIS_MODULE(ofp_util) /* Rate limit for OpenFlow message parse errors. These always indicate a bug * in the peer and so there's not much point in showing a lot of them. */ diff --git a/lib/ovsdb-error.c b/lib/ovsdb-error.c index c57175ab..5eb4ec7b 100644 --- a/lib/ovsdb-error.c +++ b/lib/ovsdb-error.c @@ -25,8 +25,7 @@ #include "util.h" #include "vlog.h" -#define THIS_MODULE VLM_ovsdb_error -#include "vlog.h" +VLOG_DEFINE_THIS_MODULE(ovsdb_error) struct ovsdb_error { const char *tag; /* String for "error" member. */ diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index f32fe0e6..2a437812 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -34,10 +34,10 @@ #include "poll-loop.h" #include "shash.h" #include "util.h" - -#define THIS_MODULE VLM_ovsdb_idl #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(ovsdb_idl) + /* An arc from one idl_row to another. When row A contains a UUID that * references row B, this is represented by an arc from A (the source) to B * (the destination). @@ -22,10 +22,10 @@ #include <string.h> #include "compiler.h" #include "ofpbuf.h" - -#define THIS_MODULE VLM_pcap #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(pcap) + struct pcap_hdr { uint32_t magic_number; /* magic number */ uint16_t version_major; /* major version number */ diff --git a/lib/poll-loop.c b/lib/poll-loop.c index 91034b04..70360b9b 100644 --- a/lib/poll-loop.c +++ b/lib/poll-loop.c @@ -28,10 +28,10 @@ #include "fatal-signal.h" #include "list.h" #include "timeval.h" - -#define THIS_MODULE VLM_poll_loop #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(poll_loop) + /* An event that will wake the following call to poll_block(). */ struct poll_waiter { /* Set when the waiter is created. */ diff --git a/lib/process.c b/lib/process.c index af867ef4..a201a88f 100644 --- a/lib/process.c +++ b/lib/process.c @@ -32,10 +32,10 @@ #include "poll-loop.h" #include "socket-util.h" #include "util.h" - -#define THIS_MODULE VLM_process #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(process) + struct process { struct list node; char *name; diff --git a/lib/rconn.c b/lib/rconn.c index 36828f3a..d254356d 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -30,10 +30,10 @@ #include "timeval.h" #include "util.h" #include "vconn.h" - -#define THIS_MODULE VLM_rconn #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(rconn) + #define STATES \ STATE(VOID, 1 << 0) \ STATE(BACKOFF, 1 << 1) \ diff --git a/lib/reconnect.c b/lib/reconnect.c index 372c2ebd..169f3173 100644 --- a/lib/reconnect.c +++ b/lib/reconnect.c @@ -21,10 +21,10 @@ #include <stdlib.h> #include "poll-loop.h" - -#define THIS_MODULE VLM_reconnect #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(reconnect) + #define STATES \ STATE(VOID, 1 << 0) \ STATE(BACKOFF, 1 << 1) \ diff --git a/lib/rtnetlink.c b/lib/rtnetlink.c index 1d302ea6..f5a6df8a 100644 --- a/lib/rtnetlink.c +++ b/lib/rtnetlink.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Nicira Networks. + * Copyright (c) 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,10 +27,10 @@ #include "coverage.h" #include "netlink.h" #include "ofpbuf.h" - -#define THIS_MODULE VLM_rtnetlink #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(rtnetlink) + /* rtnetlink socket. */ static struct nl_sock *notify_sock; diff --git a/lib/socket-util.c b/lib/socket-util.c index bf563eda..16a321c2 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -32,9 +32,9 @@ #include <unistd.h> #include "fatal-signal.h" #include "util.h" - #include "vlog.h" -#define THIS_MODULE VLM_socket_util + +VLOG_DEFINE_THIS_MODULE(socket_util) /* Sets 'fd' to non-blocking mode. Returns 0 if successful, otherwise a * positive errno value. */ @@ -17,6 +17,8 @@ /* Based on sample implementation in 802.1D-1998. Above copyright and license * applies to all modifications. */ +#include <config.h> + #include "stp.h" #include <sys/types.h> #include <netinet/in.h> @@ -27,10 +29,10 @@ #include "ofpbuf.h" #include "packets.h" #include "util.h" +#include "vlog.h" #include "xtoxll.h" -#include "vlog.h" -#define THIS_MODULE VLM_stp +VLOG_DEFINE_THIS_MODULE(stp) /* Ethernet address used as the destination for STP frames. */ const uint8_t stp_eth_addr[ETH_ADDR_LEN] diff --git a/lib/stream-fd.c b/lib/stream-fd.c index cc897b3d..9410009c 100644 --- a/lib/stream-fd.c +++ b/lib/stream-fd.c @@ -31,9 +31,9 @@ #include "util.h" #include "stream-provider.h" #include "stream.h" - #include "vlog.h" -#define THIS_MODULE VLM_stream_fd + +VLOG_DEFINE_THIS_MODULE(stream_fd) /* Active file descriptor stream. */ diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c index 1944cb9e..851e7a76 100644 --- a/lib/stream-ssl.c +++ b/lib/stream-ssl.c @@ -41,9 +41,9 @@ #include "stream-provider.h" #include "stream.h" #include "timeval.h" - #include "vlog.h" -#define THIS_MODULE VLM_stream_ssl + +VLOG_DEFINE_THIS_MODULE(stream_ssl) /* Active SSL. */ diff --git a/lib/stream-tcp.c b/lib/stream-tcp.c index 2f7e798a..d0047773 100644 --- a/lib/stream-tcp.c +++ b/lib/stream-tcp.c @@ -30,9 +30,9 @@ #include "util.h" #include "stream-provider.h" #include "stream-fd.h" - #include "vlog.h" -#define THIS_MODULE VLM_stream_tcp + +VLOG_DEFINE_THIS_MODULE(stream_tcp) /* Active TCP. */ diff --git a/lib/stream-unix.c b/lib/stream-unix.c index 930f5486..20aa5b48 100644 --- a/lib/stream-unix.c +++ b/lib/stream-unix.c @@ -33,9 +33,9 @@ #include "util.h" #include "stream-provider.h" #include "stream-fd.h" - #include "vlog.h" -#define THIS_MODULE VLM_stream_unix + +VLOG_DEFINE_THIS_MODULE(stream_unix) /* Active UNIX socket. */ diff --git a/lib/stream.c b/lib/stream.c index acbefc27..4d894e7e 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -35,10 +35,10 @@ #include "poll-loop.h" #include "random.h" #include "util.h" - -#define THIS_MODULE VLM_stream #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(stream) + /* State of an active stream.*/ enum stream_state { SCS_CONNECTING, /* Underlying stream is not connected. */ @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009 Nicira Networks. + * Copyright (c) 2008, 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,10 @@ #include <string.h> #include "dynamic-string.h" #include "util.h" - -#define THIS_MODULE VLM_svec #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(svec) + void svec_init(struct svec *svec) { diff --git a/lib/timeval.c b/lib/timeval.c index e83f5737..b95d1f42 100644 --- a/lib/timeval.c +++ b/lib/timeval.c @@ -27,9 +27,9 @@ #include "coverage.h" #include "fatal-signal.h" #include "util.h" - #include "vlog.h" -#define THIS_MODULE VLM_timeval + +VLOG_DEFINE_THIS_MODULE(timeval) /* The clock to use for measuring time intervals. This is CLOCK_MONOTONIC by * preference, but on systems that don't have a monotonic clock we fall back diff --git a/lib/unixctl.c b/lib/unixctl.c index 70785682..ac756a83 100644 --- a/lib/unixctl.c +++ b/lib/unixctl.c @@ -36,13 +36,13 @@ #include "socket-util.h" #include "svec.h" #include "util.h" +#include "vlog.h" #ifndef SCM_CREDENTIALS #include <time.h> #endif -#define THIS_MODULE VLM_unixctl -#include "vlog.h" +VLOG_DEFINE_THIS_MODULE(unixctl) struct unixctl_command { unixctl_cb_func *cb; @@ -23,10 +23,10 @@ #include <string.h> #include <unistd.h> #include "coverage.h" - -#define THIS_MODULE VLM_util #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(util) + const char *program_name; void diff --git a/lib/vconn-stream.c b/lib/vconn-stream.c index df728d5c..e6c2946d 100644 --- a/lib/vconn-stream.c +++ b/lib/vconn-stream.c @@ -32,9 +32,9 @@ #include "util.h" #include "vconn-provider.h" #include "vconn.h" - #include "vlog.h" -#define THIS_MODULE VLM_vconn_stream + +VLOG_DEFINE_THIS_MODULE(vconn_stream) /* Active stream socket vconn. */ diff --git a/lib/vconn.c b/lib/vconn.c index b558f806..99b6e7b0 100644 --- a/lib/vconn.c +++ b/lib/vconn.c @@ -36,10 +36,10 @@ #include "poll-loop.h" #include "random.h" #include "util.h" - -#define THIS_MODULE VLM_vconn #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(vconn) + /* State of an active vconn.*/ enum vconn_state { /* This is the ordinary progression of states. */ @@ -33,7 +33,7 @@ #include "unixctl.h" #include "util.h" -#define THIS_MODULE VLM_vlog +VLOG_DEFINE_THIS_MODULE(vlog) /* Name for each logging level. */ static const char *level_names[VLL_N_LEVELS] = { @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009 Nicira Networks. + * Copyright (c) 2008, 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,10 +129,12 @@ void vlog_rate_limit(enum vlog_module, enum vlog_level, struct vlog_rate_limit *, const char *, ...) __attribute__((format(printf, 4, 5))); -/* Convenience macros. To use these, define THIS_MODULE as a macro that - * expands to the module used by the current source file, e.g. - * #include "vlog.h" - * #define THIS_MODULE VLM_netlink +/* Defines THIS_MODULE as MODULE, for use with the convenience macros below. */ +#define VLOG_DEFINE_THIS_MODULE(MODULE) enum { THIS_MODULE = VLM_##MODULE }; + +/* Convenience macros. These assume that THIS_MODULE is defined as the current + * module, as set up by e.g. the VLOG_DEFINE_MODULE macro above. + * * Guaranteed to preserve errno. */ #define VLOG_EMER(...) VLOG(VLL_EMER, __VA_ARGS__) diff --git a/ofproto/collectors.c b/ofproto/collectors.c index 0b84c3ec..69eed5d7 100644 --- a/ofproto/collectors.c +++ b/ofproto/collectors.c @@ -26,10 +26,10 @@ #include "socket-util.h" #include "svec.h" #include "util.h" - -#define THIS_MODULE VLM_collectors #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(collectors) + struct collectors { int *fds; /* Sockets. */ size_t n_fds; /* Number of sockets. */ diff --git a/ofproto/discovery.c b/ofproto/discovery.c index 84f092e6..008ad62c 100644 --- a/ofproto/discovery.c +++ b/ofproto/discovery.c @@ -31,10 +31,10 @@ #include "packets.h" #include "status.h" #include "stream-ssl.h" - -#define THIS_MODULE VLM_discovery #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(discovery) + struct discovery { char *dpif_name; char *re; diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c index a86ee391..04be5ce6 100644 --- a/ofproto/fail-open.c +++ b/ofproto/fail-open.c @@ -30,10 +30,10 @@ #include "status.h" #include "timeval.h" #include "vconn.h" - -#define THIS_MODULE VLM_fail_open #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(fail_open) + /* * Fail-open mode. * diff --git a/ofproto/in-band.c b/ofproto/in-band.c index 884cf1d2..44bcd720 100644 --- a/ofproto/in-band.c +++ b/ofproto/in-band.c @@ -35,10 +35,10 @@ #include "poll-loop.h" #include "status.h" #include "timeval.h" - -#define THIS_MODULE VLM_in_band #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(in_band) + /* In-band control allows a single network to be used for OpenFlow * traffic and other data traffic. Refer to ovs-vswitchd.conf(5) and * secchan(8) for a description of configuring in-band control. diff --git a/ofproto/netflow.c b/ofproto/netflow.c index 67932f0f..dd14a8b0 100644 --- a/ofproto/netflow.c +++ b/ofproto/netflow.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009 Nicira Networks. + * Copyright (c) 2008, 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,10 +30,10 @@ #include "svec.h" #include "timeval.h" #include "util.h" +#include "vlog.h" #include "xtoxll.h" -#define THIS_MODULE VLM_netflow -#include "vlog.h" +VLOG_DEFINE_THIS_MODULE(netflow) #define NETFLOW_V5_VERSION 5 diff --git a/ofproto/ofproto-sflow.c b/ofproto/ofproto-sflow.c index cc6a6935..c74c7360 100644 --- a/ofproto/ofproto-sflow.c +++ b/ofproto/ofproto-sflow.c @@ -30,10 +30,10 @@ #include "sflow_api.h" #include "socket-util.h" #include "timeval.h" - -#define THIS_MODULE VLM_sflow #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(sflow) + struct ofproto_sflow_port { struct netdev *netdev; /* Underlying network device, for stats. */ SFLDataSource_instance dsi; /* sFlow library's notion of port number. */ diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index cf491395..66b957e1 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -57,10 +57,10 @@ #include "timeval.h" #include "unixctl.h" #include "vconn.h" +#include "vlog.h" #include "xtoxll.h" -#define THIS_MODULE VLM_ofproto -#include "vlog.h" +VLOG_DEFINE_THIS_MODULE(ofproto) #include "sflow_api.h" diff --git a/ofproto/pktbuf.c b/ofproto/pktbuf.c index b04eb595..49e5c4d6 100644 --- a/ofproto/pktbuf.c +++ b/ofproto/pktbuf.c @@ -24,10 +24,10 @@ #include "timeval.h" #include "util.h" #include "vconn.h" - -#define THIS_MODULE VLM_pktbuf #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(pktbuf) + /* Buffers are identified by a 32-bit opaque ID. We divide the ID * into a buffer number (low bits) and a cookie (high bits). The buffer number * is an index into an array of buffers. The cookie distinguishes between diff --git a/ofproto/status.c b/ofproto/status.c index 27dc86cc..a8f522d6 100644 --- a/ofproto/status.c +++ b/ofproto/status.c @@ -33,10 +33,10 @@ #include "svec.h" #include "timeval.h" #include "vconn.h" - -#define THIS_MODULE VLM_status #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(status) + struct status_category { struct list node; char *name; diff --git a/ovsdb/file.c b/ovsdb/file.c index f0913e9d..846f5566 100644 --- a/ovsdb/file.c +++ b/ovsdb/file.c @@ -36,10 +36,10 @@ #include "transaction.h" #include "uuid.h" #include "util.h" - -#define THIS_MODULE VLM_ovsdb_file #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(ovsdb_file) + /* Minimum number of milliseconds between database compactions. */ #define COMPACT_MIN_MSEC (10 * 60 * 1000) /* 10 minutes. */ diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c index bc717e46..71a44899 100644 --- a/ovsdb/jsonrpc-server.c +++ b/ovsdb/jsonrpc-server.c @@ -34,10 +34,10 @@ #include "timeval.h" #include "transaction.h" #include "trigger.h" - -#define THIS_MODULE VLM_ovsdb_jsonrpc_server #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(ovsdb_jsonrpc_server) + struct ovsdb_jsonrpc_remote; struct ovsdb_jsonrpc_session; diff --git a/ovsdb/log.c b/ovsdb/log.c index 09b9f1f7..b532f7c0 100644 --- a/ovsdb/log.c +++ b/ovsdb/log.c @@ -33,10 +33,10 @@ #include "socket-util.h" #include "transaction.h" #include "util.h" - -#define THIS_MODULE VLM_ovsdb_log #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(ovsdb_log) + enum ovsdb_log_mode { OVSDB_LOG_READ, OVSDB_LOG_WRITE diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index 8a48e8b5..b8a2fa4f 100644 --- a/ovsdb/ovsdb-client.c +++ b/ovsdb/ovsdb-client.c @@ -41,9 +41,9 @@ #include "table.h" #include "timeval.h" #include "util.h" - #include "vlog.h" -#define THIS_MODULE VLM_ovsdb_client + +VLOG_DEFINE_THIS_MODULE(ovsdb_client) /* --format: Output formatting. */ static enum { diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index ecc620df..4ca9c2d1 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -45,9 +45,9 @@ #include "trigger.h" #include "util.h" #include "unixctl.h" - #include "vlog.h" -#define THIS_MODULE VLM_ovsdb_server + +VLOG_DEFINE_THIS_MODULE(ovsdb_server) #if HAVE_OPENSSL /* SSL configuration. */ diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c index b485e8bc..0da20859 100644 --- a/ovsdb/ovsdb-tool.c +++ b/ovsdb/ovsdb-tool.c @@ -34,9 +34,9 @@ #include "table.h" #include "timeval.h" #include "util.h" - #include "vlog.h" -#define THIS_MODULE VLM_ovsdb_tool + +VLOG_DEFINE_THIS_MODULE(ovsdb_tool) /* -m, --more: Verbosity level for "show-log" command output. */ static int show_log_verbosity; diff --git a/utilities/ovs-controller.c b/utilities/ovs-controller.c index f190edc6..92b84ae1 100644 --- a/utilities/ovs-controller.c +++ b/utilities/ovs-controller.c @@ -36,9 +36,9 @@ #include "unixctl.h" #include "util.h" #include "vconn.h" - #include "vlog.h" -#define THIS_MODULE VLM_controller + +VLOG_DEFINE_THIS_MODULE(controller) #define MAX_SWITCHES 16 #define MAX_LISTENERS 16 diff --git a/utilities/ovs-discover.c b/utilities/ovs-discover.c index f5da6420..7cd1edf1 100644 --- a/utilities/ovs-discover.c +++ b/utilities/ovs-discover.c @@ -33,9 +33,9 @@ #include "timeval.h" #include "unixctl.h" #include "util.h" - #include "vlog.h" -#define THIS_MODULE VLM_ovs_discover + +VLOG_DEFINE_THIS_MODULE(ovs_discover) struct iface { const char *name; diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c index 077ae741..fe44f27e 100644 --- a/utilities/ovs-dpctl.c +++ b/utilities/ovs-dpctl.c @@ -40,9 +40,9 @@ #include "svec.h" #include "timeval.h" #include "util.h" - #include "vlog.h" -#define THIS_MODULE VLM_dpctl + +VLOG_DEFINE_THIS_MODULE(dpctl) static const struct command all_commands[]; diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 31b58a6a..54183e58 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -50,10 +50,10 @@ #include "timeval.h" #include "util.h" #include "vconn.h" +#include "vlog.h" #include "xtoxll.h" -#include "vlog.h" -#define THIS_MODULE VLM_ofctl +VLOG_DEFINE_THIS_MODULE(ofctl) #define DEFAULT_IDLE_TIMEOUT 60 diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c index 1aa3ef54..bb77d589 100644 --- a/utilities/ovs-openflowd.c +++ b/utilities/ovs-openflowd.c @@ -44,9 +44,9 @@ #include "unixctl.h" #include "util.h" #include "vconn.h" - #include "vlog.h" -#define THIS_MODULE VLM_openflowd + +VLOG_DEFINE_THIS_MODULE(openflowd) /* Settings that may be configured by the user. */ struct ofsettings { diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 17ebdb41..c18de47a 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -41,9 +41,9 @@ #include "vswitchd/vswitch-idl.h" #include "timeval.h" #include "util.h" - #include "vlog.h" -#define THIS_MODULE VLM_vsctl + +VLOG_DEFINE_THIS_MODULE(vsctl) /* vsctl_fatal() also logs the error, so it is preferred in this file. */ #define ovs_fatal please_use_vsctl_fatal_instead_of_ovs_fatal diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index e4d9cb7b..be0e8758 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -63,11 +63,11 @@ #include "vconn.h" #include "vswitchd/vswitch-idl.h" #include "xenserver.h" +#include "vlog.h" #include "xtoxll.h" #include "sflow_api.h" -#define THIS_MODULE VLM_bridge -#include "vlog.h" +VLOG_DEFINE_THIS_MODULE(bridge) struct dst { uint16_t vlan; diff --git a/vswitchd/ovs-brcompatd.c b/vswitchd/ovs-brcompatd.c index 6e620e1d..5e59373e 100644 --- a/vswitchd/ovs-brcompatd.c +++ b/vswitchd/ovs-brcompatd.c @@ -54,10 +54,10 @@ #include "timeval.h" #include "unixctl.h" #include "util.h" +#include "vlog.h" #include "vswitchd/vswitch-idl.h" -#include "vlog.h" -#define THIS_MODULE VLM_brcompatd +VLOG_DEFINE_THIS_MODULE(brcompatd) /* xxx Just hangs if datapath is rmmod/insmod. Learn to reconnect? */ diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c index a027b8cf..541cdcbc 100644 --- a/vswitchd/ovs-vswitchd.c +++ b/vswitchd/ovs-vswitchd.c @@ -45,10 +45,10 @@ #include "unixctl.h" #include "util.h" #include "vconn.h" +#include "vlog.h" #include "vswitchd/vswitch-idl.h" -#include "vlog.h" -#define THIS_MODULE VLM_vswitchd +VLOG_DEFINE_THIS_MODULE(vswitchd) static unixctl_cb_func ovs_vswitchd_exit; diff --git a/vswitchd/proc-net-compat.c b/vswitchd/proc-net-compat.c index 106a7c3f..6a8f8756 100644 --- a/vswitchd/proc-net-compat.c +++ b/vswitchd/proc-net-compat.c @@ -31,10 +31,10 @@ #include "hmap.h" #include "shash.h" #include "svec.h" - -#define THIS_MODULE VLM_proc_net_compat #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(proc_net_compat) + /* Netlink socket to bridge compatibility kernel module. */ static struct nl_sock *brc_sock; diff --git a/vswitchd/xenserver.c b/vswitchd/xenserver.c index 03c49555..976d7162 100644 --- a/vswitchd/xenserver.c +++ b/vswitchd/xenserver.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009 Nicira Networks +/* Copyright (c) 2009, 2010 Nicira Networks * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,9 @@ #include <unistd.h> #include "dynamic-string.h" #include "process.h" - #include "vlog.h" -#define THIS_MODULE VLM_xenserver + +VLOG_DEFINE_THIS_MODULE(xenserver) static char * read_host_uuid(void) |