Skip to content

Commit e005d19

Browse files
JoePerchesdavem330
authored andcommitted
net: core: Use pr_<level>
Use the current logging style. This enables use of dynamic debugging as well. Convert printk(KERN_<LEVEL> to pr_<level>. Add pr_fmt. Remove embedded prefixes, use %s, __func__ instead. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 675418d commit e005d19

File tree

6 files changed

+44
-36
lines changed

6 files changed

+44
-36
lines changed

net/core/drop_monitor.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Copyright (C) 2009 Neil Horman <nhorman@tuxdriver.com>
55
*/
66

7+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
8+
79
#include <linux/netdevice.h>
810
#include <linux/etherdevice.h>
911
#include <linux/string.h>
@@ -381,24 +383,24 @@ static int __init init_net_drop_monitor(void)
381383
struct per_cpu_dm_data *data;
382384
int cpu, rc;
383385

384-
printk(KERN_INFO "Initializing network drop monitor service\n");
386+
pr_info("Initializing network drop monitor service\n");
385387

386388
if (sizeof(void *) > 8) {
387-
printk(KERN_ERR "Unable to store program counters on this arch, Drop monitor failed\n");
389+
pr_err("Unable to store program counters on this arch, Drop monitor failed\n");
388390
return -ENOSPC;
389391
}
390392

391393
rc = genl_register_family_with_ops(&net_drop_monitor_family,
392394
dropmon_ops,
393395
ARRAY_SIZE(dropmon_ops));
394396
if (rc) {
395-
printk(KERN_ERR "Could not create drop monitor netlink family\n");
397+
pr_err("Could not create drop monitor netlink family\n");
396398
return rc;
397399
}
398400

399401
rc = register_netdevice_notifier(&dropmon_net_notifier);
400402
if (rc < 0) {
401-
printk(KERN_CRIT "Failed to register netdevice notifier\n");
403+
pr_crit("Failed to register netdevice notifier\n");
402404
goto out_unreg;
403405
}
404406

net/core/neighbour.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* Harald Welte Add neighbour cache statistics like rtstat
1616
*/
1717

18+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19+
1820
#include <linux/slab.h>
1921
#include <linux/types.h>
2022
#include <linux/kernel.h>
@@ -712,14 +714,13 @@ void neigh_destroy(struct neighbour *neigh)
712714
NEIGH_CACHE_STAT_INC(neigh->tbl, destroys);
713715

714716
if (!neigh->dead) {
715-
printk(KERN_WARNING
716-
"Destroying alive neighbour %p\n", neigh);
717+
pr_warn("Destroying alive neighbour %p\n", neigh);
717718
dump_stack();
718719
return;
719720
}
720721

721722
if (neigh_del_timer(neigh))
722-
printk(KERN_WARNING "Impossible event.\n");
723+
pr_warn("Impossible event\n");
723724

724725
skb_queue_purge(&neigh->arp_queue);
725726
neigh->arp_queue_len_bytes = 0;
@@ -1554,8 +1555,8 @@ void neigh_table_init(struct neigh_table *tbl)
15541555
write_unlock(&neigh_tbl_lock);
15551556

15561557
if (unlikely(tmp)) {
1557-
printk(KERN_ERR "NEIGH: Registering multiple tables for "
1558-
"family %d\n", tbl->family);
1558+
pr_err("Registering multiple tables for family %d\n",
1559+
tbl->family);
15591560
dump_stack();
15601561
}
15611562
}
@@ -1571,7 +1572,7 @@ int neigh_table_clear(struct neigh_table *tbl)
15711572
pneigh_queue_purge(&tbl->proxy_queue);
15721573
neigh_ifdown(tbl, NULL);
15731574
if (atomic_read(&tbl->entries))
1574-
printk(KERN_CRIT "neighbour leakage\n");
1575+
pr_crit("neighbour leakage\n");
15751576
write_lock(&neigh_tbl_lock);
15761577
for (tp = &neigh_tables; *tp; tp = &(*tp)->next) {
15771578
if (*tp == tbl) {

net/core/net_namespace.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2+
13
#include <linux/workqueue.h>
24
#include <linux/rtnetlink.h>
35
#include <linux/cache.h>
@@ -212,8 +214,8 @@ static void net_free(struct net *net)
212214
{
213215
#ifdef NETNS_REFCNT_DEBUG
214216
if (unlikely(atomic_read(&net->use_count) != 0)) {
215-
printk(KERN_EMERG "network namespace not free! Usage: %d\n",
216-
atomic_read(&net->use_count));
217+
pr_emerg("network namespace not free! Usage: %d\n",
218+
atomic_read(&net->use_count));
217219
return;
218220
}
219221
#endif

net/core/netprio_cgroup.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* Authors: Neil Horman <nhorman@tuxdriver.com>
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/module.h>
1315
#include <linux/slab.h>
1416
#include <linux/types.h>
@@ -88,7 +90,7 @@ static void extend_netdev_table(struct net_device *dev, u32 new_len)
8890
old_priomap = rtnl_dereference(dev->priomap);
8991

9092
if (!new_priomap) {
91-
printk(KERN_WARNING "Unable to alloc new priomap!\n");
93+
pr_warn("Unable to alloc new priomap!\n");
9294
return;
9395
}
9496

@@ -136,7 +138,7 @@ static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp)
136138

137139
ret = get_prioidx(&cs->prioidx);
138140
if (ret != 0) {
139-
printk(KERN_WARNING "No space in priority index array\n");
141+
pr_warn("No space in priority index array\n");
140142
kfree(cs);
141143
return ERR_PTR(ret);
142144
}

net/core/skbuff.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
* The functions in this file will not compile correctly with gcc 2.4.x
3737
*/
3838

39+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
40+
3941
#include <linux/module.h>
4042
#include <linux/types.h>
4143
#include <linux/kernel.h>
@@ -118,11 +120,10 @@ static const struct pipe_buf_operations sock_pipe_buf_ops = {
118120
*/
119121
static void skb_over_panic(struct sk_buff *skb, int sz, void *here)
120122
{
121-
printk(KERN_EMERG "skb_over_panic: text:%p len:%d put:%d head:%p "
122-
"data:%p tail:%#lx end:%#lx dev:%s\n",
123-
here, skb->len, sz, skb->head, skb->data,
124-
(unsigned long)skb->tail, (unsigned long)skb->end,
125-
skb->dev ? skb->dev->name : "<NULL>");
123+
pr_emerg("%s: text:%p len:%d put:%d head:%p data:%p tail:%#lx end:%#lx dev:%s\n",
124+
__func__, here, skb->len, sz, skb->head, skb->data,
125+
(unsigned long)skb->tail, (unsigned long)skb->end,
126+
skb->dev ? skb->dev->name : "<NULL>");
126127
BUG();
127128
}
128129

@@ -137,11 +138,10 @@ static void skb_over_panic(struct sk_buff *skb, int sz, void *here)
137138

138139
static void skb_under_panic(struct sk_buff *skb, int sz, void *here)
139140
{
140-
printk(KERN_EMERG "skb_under_panic: text:%p len:%d put:%d head:%p "
141-
"data:%p tail:%#lx end:%#lx dev:%s\n",
142-
here, skb->len, sz, skb->head, skb->data,
143-
(unsigned long)skb->tail, (unsigned long)skb->end,
144-
skb->dev ? skb->dev->name : "<NULL>");
141+
pr_emerg("%s: text:%p len:%d put:%d head:%p data:%p tail:%#lx end:%#lx dev:%s\n",
142+
__func__, here, skb->len, sz, skb->head, skb->data,
143+
(unsigned long)skb->tail, (unsigned long)skb->end,
144+
skb->dev ? skb->dev->name : "<NULL>");
145145
BUG();
146146
}
147147

net/core/sock.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
* 2 of the License, or (at your option) any later version.
9090
*/
9191

92+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
93+
9294
#include <linux/capability.h>
9395
#include <linux/errno.h>
9496
#include <linux/types.h>
@@ -297,9 +299,8 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen)
297299
*timeo_p = 0;
298300
if (warned < 10 && net_ratelimit()) {
299301
warned++;
300-
printk(KERN_INFO "sock_set_timeout: `%s' (pid %d) "
301-
"tries to set negative timeout\n",
302-
current->comm, task_pid_nr(current));
302+
pr_info("%s: `%s' (pid %d) tries to set negative timeout\n",
303+
__func__, current->comm, task_pid_nr(current));
303304
}
304305
return 0;
305306
}
@@ -317,8 +318,8 @@ static void sock_warn_obsolete_bsdism(const char *name)
317318
static char warncomm[TASK_COMM_LEN];
318319
if (strcmp(warncomm, current->comm) && warned < 5) {
319320
strcpy(warncomm, current->comm);
320-
printk(KERN_WARNING "process `%s' is using obsolete "
321-
"%s SO_BSDCOMPAT\n", warncomm, name);
321+
pr_warn("process `%s' is using obsolete %s SO_BSDCOMPAT\n",
322+
warncomm, name);
322323
warned++;
323324
}
324325
}
@@ -1238,8 +1239,8 @@ static void __sk_free(struct sock *sk)
12381239
sock_disable_timestamp(sk, SK_FLAGS_TIMESTAMP);
12391240

12401241
if (atomic_read(&sk->sk_omem_alloc))
1241-
printk(KERN_DEBUG "%s: optmem leakage (%d bytes) detected.\n",
1242-
__func__, atomic_read(&sk->sk_omem_alloc));
1242+
pr_debug("%s: optmem leakage (%d bytes) detected\n",
1243+
__func__, atomic_read(&sk->sk_omem_alloc));
12431244

12441245
if (sk->sk_peer_cred)
12451246
put_cred(sk->sk_peer_cred);
@@ -2424,7 +2425,7 @@ static void assign_proto_idx(struct proto *prot)
24242425
prot->inuse_idx = find_first_zero_bit(proto_inuse_idx, PROTO_INUSE_NR);
24252426

24262427
if (unlikely(prot->inuse_idx == PROTO_INUSE_NR - 1)) {
2427-
printk(KERN_ERR "PROTO_INUSE_NR exhausted\n");
2428+
pr_err("PROTO_INUSE_NR exhausted\n");
24282429
return;
24292430
}
24302431

@@ -2454,8 +2455,8 @@ int proto_register(struct proto *prot, int alloc_slab)
24542455
NULL);
24552456

24562457
if (prot->slab == NULL) {
2457-
printk(KERN_CRIT "%s: Can't create sock SLAB cache!\n",
2458-
prot->name);
2458+
pr_crit("%s: Can't create sock SLAB cache!\n",
2459+
prot->name);
24592460
goto out;
24602461
}
24612462

@@ -2469,8 +2470,8 @@ int proto_register(struct proto *prot, int alloc_slab)
24692470
SLAB_HWCACHE_ALIGN, NULL);
24702471

24712472
if (prot->rsk_prot->slab == NULL) {
2472-
printk(KERN_CRIT "%s: Can't create request sock SLAB cache!\n",
2473-
prot->name);
2473+
pr_crit("%s: Can't create request sock SLAB cache!\n",
2474+
prot->name);
24742475
goto out_free_request_sock_slab_name;
24752476
}
24762477
}

0 commit comments

Comments
 (0)