aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Volz <juliusv@google.com>2008-09-02 09:55:35 -0400
committerSimon Horman <horms@verge.net.au>2008-09-04 21:17:04 -0400
commitc842a3ada9ba8f0cca38a70de3fe0effcfab254c (patch)
treebbd46b4eb6918a6983794432d00eb14d8b1cc3ee
parent64aae3cb9fd22f33e491c4730d363eb2229ef910 (diff)
IPVS: Add debug macros for v4 and v6 address output
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> Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--include/net/ip_vs.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 5d6313d972fc..0400e590b6a2 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,
78#include <linux/net.h> 78#include <linux/net.h>
79 79
80extern int ip_vs_get_debug_level(void); 80extern int ip_vs_get_debug_level(void);
81
82static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len,
83 const union nf_inet_addr *addr,
84 int *idx)
85{
86 int len;
87#ifdef CONFIG_IP_VS_IPV6
88 if (af == AF_INET6)
89 len = snprintf(&buf[*idx], buf_len - *idx, "[" NIP6_FMT "]",
90 NIP6(addr->in6)) + 1;
91 else
92#endif
93 len = snprintf(&buf[*idx], buf_len - *idx, NIPQUAD_FMT,
94 NIPQUAD(addr->ip)) + 1;
95
96 *idx += len;
97 BUG_ON(*idx > buf_len + 1);
98 return &buf[*idx - len];
99}
100
101#define IP_VS_DBG_BUF(level, msg...) \
102 do { \
103 char ip_vs_dbg_buf[160]; \
104 int ip_vs_dbg_idx = 0; \
105 if (level <= ip_vs_get_debug_level()) \
106 printk(KERN_DEBUG "IPVS: " msg); \
107 } while (0)
108#define IP_VS_ERR_BUF(msg...) \
109 do { \
110 char ip_vs_dbg_buf[160]; \
111 int ip_vs_dbg_idx = 0; \
112 printk(KERN_ERR "IPVS: " msg); \
113 } while (0)
114
115/* Only use from within IP_VS_DBG_BUF() or IP_VS_ERR_BUF macros */
116#define IP_VS_DBG_ADDR(af, addr) \
117 ip_vs_dbg_addr(af, ip_vs_dbg_buf, \
118 sizeof(ip_vs_dbg_buf), addr, \
119 &ip_vs_dbg_idx)
120
81#define IP_VS_DBG(level, msg...) \ 121#define IP_VS_DBG(level, msg...) \
82 do { \ 122 do { \
83 if (level <= ip_vs_get_debug_level()) \ 123 if (level <= ip_vs_get_debug_level()) \
@@ -100,6 +140,8 @@ extern int ip_vs_get_debug_level(void);
100 pp->debug_packet(pp, skb, ofs, msg); \ 140 pp->debug_packet(pp, skb, ofs, msg); \
101 } while (0) 141 } while (0)
102#else /* NO DEBUGGING at ALL */ 142#else /* NO DEBUGGING at ALL */
143#define IP_VS_DBG_BUF(level, msg...) do {} while (0)
144#define IP_VS_ERR_BUF(msg...) do {} while (0)
103#define IP_VS_DBG(level, msg...) do {} while (0) 145#define IP_VS_DBG(level, msg...) do {} while (0)
104#define IP_VS_DBG_RL(msg...) do {} while (0) 146#define IP_VS_DBG_RL(msg...) do {} while (0)
105#define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) do {} while (0) 147#define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) do {} while (0)