From: Julius Volz <juliusv@google.com>
To: netdev@vger.kernel.org, lvs-devel@vger.kernel.org
Cc: horms@verge.net.au, kaber@trash.net, vbusam@google.com,
Julius Volz <juliusv@google.com>
Subject: [PATCHv2 RFC 04/25] IPVS: Add debug macros for v4 and v6 address output
Date: Mon, 1 Sep 2008 14:56:01 +0200 [thread overview]
Message-ID: <1220273782-19901-5-git-send-email-juliusv@google.com> (raw)
In-Reply-To: <1220273782-19901-1-git-send-email-juliusv@google.com>
Add some debugging macros that allow conditional output of either v4 or v6
addresses, depending on an 'af' parameter. This is done by creating a
temporary string buffer in an outer debug macro and writing addresses'
string representations into it from another macro which can only be used
when inside the outer one.
Signed-off-by: Julius Volz <juliusv@google.com>
1 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 6d9a360..45a7458 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -78,6 +78,46 @@ static inline int ip_vs_addr_equal(int af, const union nf_inet_addr *a,
#include <linux/net.h>
extern int ip_vs_get_debug_level(void);
+
+static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len,
+ const union nf_inet_addr *addr,
+ int *idx)
+{
+ int len;
+#ifdef CONFIG_IP_VS_IPV6
+ if (af == AF_INET6)
+ len = snprintf(&buf[*idx], buf_len - *idx, "[" NIP6_FMT "]",
+ NIP6(addr->in6)) + 1;
+ else
+#endif
+ len = snprintf(&buf[*idx], buf_len - *idx, NIPQUAD_FMT,
+ NIPQUAD(addr->ip)) + 1;
+
+ *idx += len;
+ BUG_ON(*idx > buf_len + 1);
+ return &buf[*idx - len];
+}
+
+#define IP_VS_DBG_BUF(level, msg...) \
+ do { \
+ char ip_vs_dbg_buf[160]; \
+ int ip_vs_dbg_idx = 0; \
+ if (level <= ip_vs_get_debug_level()) \
+ printk(KERN_DEBUG "IPVS: " msg); \
+ } while (0)
+#define IP_VS_ERR_BUF(msg...) \
+ do { \
+ char ip_vs_dbg_buf[160]; \
+ int ip_vs_dbg_idx = 0; \
+ printk(KERN_ERR "IPVS: " msg); \
+ } while (0)
+
+/* Only use from within IP_VS_DBG_BUF() or IP_VS_ERR_BUF macros */
+#define IP_VS_DBG_ADDR(af, addr) \
+ ip_vs_dbg_addr(af, ip_vs_dbg_buf, \
+ sizeof(ip_vs_dbg_buf), addr, \
+ &ip_vs_dbg_idx)
+
#define IP_VS_DBG(level, msg...) \
do { \
if (level <= ip_vs_get_debug_level()) \
@@ -100,6 +140,8 @@ extern int ip_vs_get_debug_level(void);
pp->debug_packet(pp, skb, ofs, msg); \
} while (0)
#else /* NO DEBUGGING at ALL */
+#define IP_VS_DBG_BUF(level, msg...) do {} while (0)
+#define IP_VS_ERR_BUF(msg...) do {} while (0)
#define IP_VS_DBG(level, msg...) do {} while (0)
#define IP_VS_DBG_RL(msg...) do {} while (0)
#define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) do {} while (0)
--
1.5.4.5
next prev parent reply other threads:[~2008-09-01 12:56 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-01 12:55 [PATCHv2 RFC 00/00] Add first IPv6 support to IPVS Julius Volz
2008-09-01 12:55 ` [PATCHv2 RFC 01/25] IPVS: Add CONFIG_IP_VS_IPV6 option for IPv6 support Julius Volz
2008-09-01 12:55 ` [PATCHv2 RFC 02/25] IPVS: Change IPVS data structures to support IPv6 addresses Julius Volz
2008-09-02 5:23 ` Simon Horman
2008-09-02 5:53 ` Simon Horman
2008-09-02 6:08 ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 03/25] IPVS: Add general v4/v6 helper functions / data structures Julius Volz
2008-09-01 12:56 ` Julius Volz [this message]
2008-09-01 12:56 ` [PATCHv2 RFC 05/25] IPVS: Add internal versions of sockopt interface structs Julius Volz
2008-09-02 6:06 ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 06/25] IPVS: Convert __ip_vs_svc_get() and __ip_vs_fwm_get() Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 07/25] IPVS: Add v6 support to ip_vs_service_get() Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 08/25] IPVS: Add IPv6 support flag to schedulers Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 09/25] IPVS: Add 'af' args to protocol handler functions Julius Volz
2008-09-02 6:26 ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 10/25] IPVS: Add protocol debug functions for IPv6 Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 11/25] IPVS: Extend protocol DNAT/SNAT and state handlers Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 12/25] IPVS: Extend functions for getting/creating connections Julius Volz
2008-09-02 6:47 ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 13/25] IPVS: Add IPv6 support to xmit() support functions Julius Volz
2008-09-02 22:28 ` Simon Horman
2008-09-03 8:43 ` Julius Volz
2008-09-03 8:48 ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 14/25] IPVS: Add and bind IPv6 xmit functions Julius Volz
2008-09-02 7:32 ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 15/25] IPVS: Extend scheduling functions for IPv6 support Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 16/25] IPVS: Add/adjust Netfilter hook functions and helpers for v6 Julius Volz
2008-09-02 7:40 ` Simon Horman
2008-09-02 13:34 ` Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 17/25] IPVS: Convert real server lookup functions Julius Volz
2008-09-02 7:46 ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 18/25] IPVS: Convert procfs files for IPv6 entry output Julius Volz
2008-09-02 7:49 ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 19/25] IVPS: Disable sync daemon for IPv6 connections Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 20/25] IPVS: Turn off FTP application helper for IPv6 Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 21/25] IPVS: Add function to determine if IPv6 address is local Julius Volz
2008-09-02 7:57 ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 22/25] IPVS: Adjust various debug outputs to use new macros Julius Volz
2008-09-02 8:00 ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 23/25] IPVS: Activate IPv6 Netfilter hooks Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 24/25] IPVS: Allow adding IPv6 services from userspace Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 25/25] IPVS: Add changelog notes to header comments Julius Volz
2008-09-02 2:25 ` Stephen Hemminger
2008-09-02 9:22 ` Julius Volz
2008-09-02 8:18 ` [PATCHv2 RFC 00/00] Add first IPv6 support to IPVS Simon Horman
2008-09-02 9:22 ` Julius Volz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1220273782-19901-5-git-send-email-juliusv@google.com \
--to=juliusv@google.com \
--cc=horms@verge.net.au \
--cc=kaber@trash.net \
--cc=lvs-devel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vbusam@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).