diff options
Diffstat (limited to 'include/net/ip_vs.h')
-rw-r--r-- | include/net/ip_vs.h | 42 |
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 | ||
80 | extern int ip_vs_get_debug_level(void); | 80 | extern int ip_vs_get_debug_level(void); |
81 | |||
82 | static 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) |