From 5136ce492c414f377f7be9ae32b259abb9f76580 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 16 Jul 2010 11:02:49 -0700 Subject: [PATCH] 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. --- extras/ezio/ezio-term.c | 4 ++-- extras/ezio/ovs-switchui.c | 4 ++-- extras/ezio/terminal.c | 4 ++-- extras/ezio/tty.c | 4 ++-- extras/ezio/vt-dummy.c | 6 +++--- extras/ezio/vt-linux.c | 6 +++--- lib/automake.mk | 4 ++-- lib/backtrace.c | 4 ++-- lib/coverage.c | 4 ++-- lib/daemon.c | 4 ++-- lib/dhcp-client.c | 4 ++-- lib/dhcp.c | 4 ++-- lib/dpif-linux.c | 4 ++-- lib/dpif-netdev.c | 4 ++-- lib/dpif.c | 4 ++-- lib/fatal-signal.c | 4 ++-- lib/flow.c | 4 ++-- lib/jsonrpc.c | 4 ++-- lib/leak-checker.c | 4 ++-- lib/learning-switch.c | 4 ++-- lib/lockfile.c | 4 ++-- lib/mac-learning.c | 4 ++-- lib/netdev-gre.c | 4 ++-- lib/netdev-linux.c | 4 ++-- lib/netdev-patch.c | 4 ++-- lib/netdev-vport.c | 4 ++-- lib/netdev.c | 4 ++-- lib/netlink.c | 4 ++-- lib/ofp-util.c | 4 ++-- lib/ovsdb-error.c | 3 +-- lib/ovsdb-idl.c | 4 ++-- lib/pcap.c | 4 ++-- lib/poll-loop.c | 4 ++-- lib/process.c | 4 ++-- lib/rconn.c | 4 ++-- lib/reconnect.c | 4 ++-- lib/rtnetlink.c | 6 +++--- lib/socket-util.c | 4 ++-- lib/stp.c | 6 ++++-- lib/stream-fd.c | 4 ++-- lib/stream-ssl.c | 4 ++-- lib/stream-tcp.c | 4 ++-- lib/stream-unix.c | 4 ++-- lib/stream.c | 4 ++-- lib/svec.c | 6 +++--- lib/timeval.c | 4 ++-- lib/unixctl.c | 4 ++-- lib/util.c | 4 ++-- lib/vconn-stream.c | 4 ++-- lib/vconn.c | 4 ++-- lib/vlog.c | 2 +- lib/vlog.h | 12 +++++++----- ofproto/collectors.c | 4 ++-- ofproto/discovery.c | 4 ++-- ofproto/fail-open.c | 4 ++-- ofproto/in-band.c | 4 ++-- ofproto/netflow.c | 6 +++--- ofproto/ofproto-sflow.c | 4 ++-- ofproto/ofproto.c | 4 ++-- ofproto/pktbuf.c | 4 ++-- ofproto/status.c | 4 ++-- ovsdb/file.c | 4 ++-- ovsdb/jsonrpc-server.c | 4 ++-- ovsdb/log.c | 4 ++-- ovsdb/ovsdb-client.c | 4 ++-- ovsdb/ovsdb-server.c | 4 ++-- ovsdb/ovsdb-tool.c | 4 ++-- utilities/ovs-controller.c | 4 ++-- utilities/ovs-discover.c | 4 ++-- utilities/ovs-dpctl.c | 4 ++-- utilities/ovs-ofctl.c | 4 ++-- utilities/ovs-openflowd.c | 4 ++-- utilities/ovs-vsctl.c | 4 ++-- vswitchd/bridge.c | 4 ++-- vswitchd/ovs-brcompatd.c | 4 ++-- vswitchd/ovs-vswitchd.c | 4 ++-- vswitchd/proc-net-compat.c | 4 ++-- vswitchd/xenserver.c | 6 +++--- 78 files changed, 167 insertions(+), 164 deletions(-) diff --git a/extras/ezio/ezio-term.c b/extras/ezio/ezio-term.c index f76455289..b41a7c025 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 b1ba8d249..092eb1e5d 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 090e80e44..3e499ab01 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 432882852..a4bb14ce2 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 diff --git a/extras/ezio/vt-dummy.c b/extras/ezio/vt-dummy.c index c1de6c804..18da821d7 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 #include "extras/ezio/vt.h" #include - -#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 92f7ebb61..b281c8972 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 #include #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 71e4d61fb..046e9ab6e 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 80cae54a6..131bdf4fc 100644 --- a/lib/backtrace.c +++ b/lib/backtrace.c @@ -21,10 +21,10 @@ #include #include #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 5c99c18ad..6e65810e8 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 59628f233..6cb553acf 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 7168361f0..961994a2e 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) \ diff --git a/lib/dhcp.c b/lib/dhcp.c index e16176ba1..e6d5735e8 100644 --- a/lib/dhcp.c +++ b/lib/dhcp.c @@ -24,10 +24,10 @@ #include #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 432d5ed1a..52d73c6bb 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 fc117d206..15ff0d551 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(). */ diff --git a/lib/dpif.c b/lib/dpif.c index ef28ea9fa..40741a45e 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -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 0f3603689..d9442a3ef 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 }; diff --git a/lib/flow.c b/lib/flow.c index 7ae90d2b5..490c46bc1 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -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 32d34b4f1..5d394c680 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 4ab55e594..28beb0b3c 100644 --- a/lib/leak-checker.c +++ b/lib/leak-checker.c @@ -18,10 +18,10 @@ #include "leak-checker.h" #include #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 97c424a6b..d2da25237 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 100440e93..84bfb3c04 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 5d64f5437..c8582f312 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 25e0a6467..aecc77edf 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 09a461296..a20a1c4d1 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 1340eb719..7e8b1990e 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 58858f90f..96834115e 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 38f4dd585..7d834ad09 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 d59f65e04..2f7bc0a1c 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 cedeb6702..fd54a03ed 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 c57175abb..5eb4ec7bd 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 f32fe0e6b..2a4378124 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). diff --git a/lib/pcap.c b/lib/pcap.c index 028dd0cb7..cc15411d4 100644 --- a/lib/pcap.c +++ b/lib/pcap.c @@ -22,10 +22,10 @@ #include #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 91034b04e..70360b9b5 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 af867ef4e..a201a88f8 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 36828f3ab..d254356d6 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 372c2ebdc..169f3173c 100644 --- a/lib/reconnect.c +++ b/lib/reconnect.c @@ -21,10 +21,10 @@ #include #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 1d302ea63..f5a6df8a1 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 bf563edae..16a321c20 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -32,9 +32,9 @@ #include #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. */ diff --git a/lib/stp.c b/lib/stp.c index 38885c07f..c5c8b3ba8 100644 --- a/lib/stp.c +++ b/lib/stp.c @@ -17,6 +17,8 @@ /* Based on sample implementation in 802.1D-1998. Above copyright and license * applies to all modifications. */ +#include + #include "stp.h" #include #include @@ -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 cc897b3d9..9410009c4 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 1944cb9ed..851e7a76f 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 2f7e798a6..d00477732 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 930f54868..20aa5b482 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 acbefc278..4d894e7ed 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. */ diff --git a/lib/svec.c b/lib/svec.c index bc3df23d5..79c835551 100644 --- a/lib/svec.c +++ b/lib/svec.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. @@ -22,10 +22,10 @@ #include #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 e83f5737e..b95d1f425 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 707856827..ac756a834 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 #endif -#define THIS_MODULE VLM_unixctl -#include "vlog.h" +VLOG_DEFINE_THIS_MODULE(unixctl) struct unixctl_command { unixctl_cb_func *cb; diff --git a/lib/util.c b/lib/util.c index 19f13dddc..9fc99f07d 100644 --- a/lib/util.c +++ b/lib/util.c @@ -23,10 +23,10 @@ #include #include #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 df728d5cc..e6c2946d4 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 b558f8069..99b6e7b0d 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. */ diff --git a/lib/vlog.c b/lib/vlog.c index a77a6e554..388712950 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -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] = { diff --git a/lib/vlog.h b/lib/vlog.h index f50b76a16..53e8f39ac 100644 --- a/lib/vlog.h +++ b/lib/vlog.h @@ -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 0b84c3ece..69eed5d7d 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 84f092e69..008ad62ca 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 a86ee391b..04be5ce6a 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 884cf1d26..44bcd720a 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 67932f0f7..dd14a8b0d 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 cc6a6935a..c74c7360e 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 cf491395c..66b957e10 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 b04eb5955..49e5c4d63 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 27dc86cc8..a8f522d61 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 f0913e9d3..846f55668 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 bc717e469..71a44899e 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 09b9f1f7a..b532f7c0a 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 8a48e8b5d..b8a2fa4fd 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 ecc620df4..4ca9c2d1f 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 b485e8bc8..0da208590 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 f190edc63..92b84ae12 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 f5da64205..7cd1edf10 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 077ae7417..fe44f27e2 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 31b58a6ad..54183e58d 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 1aa3ef548..bb77d5896 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 17ebdb418..c18de47ae 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 e4d9cb7bc..be0e87581 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 6e620e1d6..5e59373e0 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 a027b8cfe..541cdcbc8 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 106a7c3f5..6a8f8756e 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 03c495552..976d7162c 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 #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) -- 2.43.0