Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab65bef

Browse files
Wang LiangNipaLocal
authored andcommitted
net: replace ADDRLABEL with dynamic debug
ADDRLABEL only works when it was set in compilation phase. Replace it with net_dbg_ratelimited(). Signed-off-by: Wang Liang <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 823cc32 commit ab65bef

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

net/ipv6/addrlabel.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
#include <linux/netlink.h>
2121
#include <linux/rtnetlink.h>
2222

23-
#if 0
24-
#define ADDRLABEL(x...) printk(x)
25-
#else
26-
#define ADDRLABEL(x...) do { ; } while (0)
27-
#endif
28-
2923
/*
3024
* Policy Table
3125
*/
@@ -150,8 +144,8 @@ u32 ipv6_addr_label(struct net *net,
150144
label = p ? p->label : IPV6_ADDR_LABEL_DEFAULT;
151145
rcu_read_unlock();
152146

153-
ADDRLABEL(KERN_DEBUG "%s(addr=%pI6, type=%d, ifindex=%d) => %08x\n",
154-
__func__, addr, type, ifindex, label);
147+
net_dbg_ratelimited("%s(addr=%pI6, type=%d, ifindex=%d) => %08x\n", __func__, addr, type,
148+
ifindex, label);
155149

156150
return label;
157151
}
@@ -164,8 +158,8 @@ static struct ip6addrlbl_entry *ip6addrlbl_alloc(const struct in6_addr *prefix,
164158
struct ip6addrlbl_entry *newp;
165159
int addrtype;
166160

167-
ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d, label=%u)\n",
168-
__func__, prefix, prefixlen, ifindex, (unsigned int)label);
161+
net_dbg_ratelimited("%s(prefix=%pI6, prefixlen=%d, ifindex=%d, label=%u)\n", __func__,
162+
prefix, prefixlen, ifindex, (unsigned int)label);
169163

170164
addrtype = ipv6_addr_type(prefix) & (IPV6_ADDR_MAPPED | IPV6_ADDR_COMPATv4 | IPV6_ADDR_LOOPBACK);
171165

@@ -207,8 +201,7 @@ static int __ip6addrlbl_add(struct net *net, struct ip6addrlbl_entry *newp,
207201
struct hlist_node *n;
208202
int ret = 0;
209203

210-
ADDRLABEL(KERN_DEBUG "%s(newp=%p, replace=%d)\n", __func__, newp,
211-
replace);
204+
net_dbg_ratelimited("%s(newp=%p, replace=%d)\n", __func__, newp, replace);
212205

213206
hlist_for_each_entry_safe(p, n, &net->ipv6.ip6addrlbl_table.head, list) {
214207
if (p->prefixlen == newp->prefixlen &&
@@ -247,9 +240,8 @@ static int ip6addrlbl_add(struct net *net,
247240
struct ip6addrlbl_entry *newp;
248241
int ret = 0;
249242

250-
ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d, label=%u, replace=%d)\n",
251-
__func__, prefix, prefixlen, ifindex, (unsigned int)label,
252-
replace);
243+
net_dbg_ratelimited("%s(prefix=%pI6, prefixlen=%d, ifindex=%d, label=%u, replace=%d)\n",
244+
__func__, prefix, prefixlen, ifindex, (unsigned int)label, replace);
253245

254246
newp = ip6addrlbl_alloc(prefix, prefixlen, ifindex, label);
255247
if (IS_ERR(newp))
@@ -271,8 +263,8 @@ static int __ip6addrlbl_del(struct net *net,
271263
struct hlist_node *n;
272264
int ret = -ESRCH;
273265

274-
ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d)\n",
275-
__func__, prefix, prefixlen, ifindex);
266+
net_dbg_ratelimited("%s(prefix=%pI6, prefixlen=%d, ifindex=%d)\n", __func__, prefix,
267+
prefixlen, ifindex);
276268

277269
hlist_for_each_entry_safe(p, n, &net->ipv6.ip6addrlbl_table.head, list) {
278270
if (p->prefixlen == prefixlen &&
@@ -294,8 +286,8 @@ static int ip6addrlbl_del(struct net *net,
294286
struct in6_addr prefix_buf;
295287
int ret;
296288

297-
ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d)\n",
298-
__func__, prefix, prefixlen, ifindex);
289+
net_dbg_ratelimited("%s(prefix=%pI6, prefixlen=%d, ifindex=%d)\n", __func__, prefix,
290+
prefixlen, ifindex);
299291

300292
ipv6_addr_prefix(&prefix_buf, prefix, prefixlen);
301293
spin_lock(&net->ipv6.ip6addrlbl_table.lock);
@@ -312,8 +304,6 @@ static int __net_init ip6addrlbl_net_init(struct net *net)
312304
int err;
313305
int i;
314306

315-
ADDRLABEL(KERN_DEBUG "%s\n", __func__);
316-
317307
spin_lock_init(&net->ipv6.ip6addrlbl_table.lock);
318308
INIT_HLIST_HEAD(&net->ipv6.ip6addrlbl_table.head);
319309

0 commit comments

Comments
 (0)