Skip to content

Commit 058bd4d

Browse files
JoePerchesdavem330
authored andcommitted
net: Convert printks to pr_<level>
Use a more current kernel messaging style. Convert a printk block to print_hex_dump. Coalesce formats, align arguments. Use %s, __func__ instead of embedding function names. Some messages that were prefixed with <foo>_close are now prefixed with <foo>_fini. Some ah4 and esp messages are now not prefixed with "ip ". The intent of this patch is to later add something like #define pr_fmt(fmt) "IPv4: " fmt. to standardize the output messages. Text size is trivially reduced. (x86-32 allyesconfig) $ size net/ipv4/built-in.o* text data bss dec hex filename 887888 31558 249696 1169142 11d6f6 net/ipv4/built-in.o.new 887934 31558 249800 1169292 11d78c net/ipv4/built-in.o.old Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 43db362 commit 058bd4d

25 files changed

Lines changed: 163 additions & 181 deletions

‎net/ipv4/af_inet.c‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,13 +1085,11 @@ void inet_register_protosw(struct inet_protosw *p)
10851085
return;
10861086

10871087
out_permanent:
1088-
printk(KERN_ERR "Attempt to override permanent protocol %d.\n",
1089-
protocol);
1088+
pr_err("Attempt to override permanent protocol %d\n", protocol);
10901089
goto out;
10911090

10921091
out_illegal:
1093-
printk(KERN_ERR
1094-
"Ignoring attempt to register invalid socket type %d.\n",
1092+
pr_err("Ignoring attempt to register invalid socket type %d\n",
10951093
p->type);
10961094
goto out;
10971095
}
@@ -1100,8 +1098,7 @@ EXPORT_SYMBOL(inet_register_protosw);
11001098
void inet_unregister_protosw(struct inet_protosw *p)
11011099
{
11021100
if (INET_PROTOSW_PERMANENT & p->flags) {
1103-
printk(KERN_ERR
1104-
"Attempt to unregister permanent protocol %d.\n",
1101+
pr_err("Attempt to unregister permanent protocol %d\n",
11051102
p->protocol);
11061103
} else {
11071104
spin_lock_bh(&inetsw_lock);
@@ -1150,8 +1147,8 @@ static int inet_sk_reselect_saddr(struct sock *sk)
11501147
return 0;
11511148

11521149
if (sysctl_ip_dynaddr > 1) {
1153-
printk(KERN_INFO "%s(): shifting inet->saddr from %pI4 to %pI4\n",
1154-
__func__, &old_saddr, &new_saddr);
1150+
pr_info("%s(): shifting inet->saddr from %pI4 to %pI4\n",
1151+
__func__, &old_saddr, &new_saddr);
11551152
}
11561153

11571154
inet->inet_saddr = inet->inet_rcv_saddr = new_saddr;
@@ -1680,14 +1677,14 @@ static int __init inet_init(void)
16801677
*/
16811678

16821679
if (inet_add_protocol(&icmp_protocol, IPPROTO_ICMP) < 0)
1683-
printk(KERN_CRIT "inet_init: Cannot add ICMP protocol\n");
1680+
pr_crit("%s: Cannot add ICMP protocol\n", __func__);
16841681
if (inet_add_protocol(&udp_protocol, IPPROTO_UDP) < 0)
1685-
printk(KERN_CRIT "inet_init: Cannot add UDP protocol\n");
1682+
pr_crit("%s: Cannot add UDP protocol\n", __func__);
16861683
if (inet_add_protocol(&tcp_protocol, IPPROTO_TCP) < 0)
1687-
printk(KERN_CRIT "inet_init: Cannot add TCP protocol\n");
1684+
pr_crit("%s: Cannot add TCP protocol\n", __func__);
16881685
#ifdef CONFIG_IP_MULTICAST
16891686
if (inet_add_protocol(&igmp_protocol, IPPROTO_IGMP) < 0)
1690-
printk(KERN_CRIT "inet_init: Cannot add IGMP protocol\n");
1687+
pr_crit("%s: Cannot add IGMP protocol\n", __func__);
16911688
#endif
16921689

16931690
/* Register the socket-side information for inet_create. */
@@ -1734,14 +1731,14 @@ static int __init inet_init(void)
17341731
*/
17351732
#if defined(CONFIG_IP_MROUTE)
17361733
if (ip_mr_init())
1737-
printk(KERN_CRIT "inet_init: Cannot init ipv4 mroute\n");
1734+
pr_crit("%s: Cannot init ipv4 mroute\n", __func__);
17381735
#endif
17391736
/*
17401737
* Initialise per-cpu ipv4 mibs
17411738
*/
17421739

17431740
if (init_ipv4_mibs())
1744-
printk(KERN_CRIT "inet_init: Cannot init ipv4 mibs\n");
1741+
pr_crit("%s: Cannot init ipv4 mibs\n", __func__);
17451742

17461743
ipv4_proc_init();
17471744

‎net/ipv4/ah4.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@ static int ah_init_state(struct xfrm_state *x)
445445

446446
if (aalg_desc->uinfo.auth.icv_fullbits/8 !=
447447
crypto_ahash_digestsize(ahash)) {
448-
printk(KERN_INFO "AH: %s digestsize %u != %hu\n",
449-
x->aalg->alg_name, crypto_ahash_digestsize(ahash),
450-
aalg_desc->uinfo.auth.icv_fullbits/8);
448+
pr_info("AH: %s digestsize %u != %hu\n",
449+
x->aalg->alg_name, crypto_ahash_digestsize(ahash),
450+
aalg_desc->uinfo.auth.icv_fullbits/8);
451451
goto error;
452452
}
453453

@@ -510,11 +510,11 @@ static const struct net_protocol ah4_protocol = {
510510
static int __init ah4_init(void)
511511
{
512512
if (xfrm_register_type(&ah_type, AF_INET) < 0) {
513-
printk(KERN_INFO "ip ah init: can't add xfrm type\n");
513+
pr_info("%s: can't add xfrm type\n", __func__);
514514
return -EAGAIN;
515515
}
516516
if (inet_add_protocol(&ah4_protocol, IPPROTO_AH) < 0) {
517-
printk(KERN_INFO "ip ah init: can't add protocol\n");
517+
pr_info("%s: can't add protocol\n", __func__);
518518
xfrm_unregister_type(&ah_type, AF_INET);
519519
return -EAGAIN;
520520
}
@@ -524,9 +524,9 @@ static int __init ah4_init(void)
524524
static void __exit ah4_fini(void)
525525
{
526526
if (inet_del_protocol(&ah4_protocol, IPPROTO_AH) < 0)
527-
printk(KERN_INFO "ip ah close: can't remove protocol\n");
527+
pr_info("%s: can't remove protocol\n", __func__);
528528
if (xfrm_unregister_type(&ah_type, AF_INET) < 0)
529-
printk(KERN_INFO "ip ah close: can't remove xfrm type\n");
529+
pr_info("%s: can't remove xfrm type\n", __func__);
530530
}
531531

532532
module_init(ah4_init);

‎net/ipv4/esp4.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,11 @@ static const struct net_protocol esp4_protocol = {
706706
static int __init esp4_init(void)
707707
{
708708
if (xfrm_register_type(&esp_type, AF_INET) < 0) {
709-
printk(KERN_INFO "ip esp init: can't add xfrm type\n");
709+
pr_info("%s: can't add xfrm type\n", __func__);
710710
return -EAGAIN;
711711
}
712712
if (inet_add_protocol(&esp4_protocol, IPPROTO_ESP) < 0) {
713-
printk(KERN_INFO "ip esp init: can't add protocol\n");
713+
pr_info("%s: can't add protocol\n", __func__);
714714
xfrm_unregister_type(&esp_type, AF_INET);
715715
return -EAGAIN;
716716
}
@@ -720,9 +720,9 @@ static int __init esp4_init(void)
720720
static void __exit esp4_fini(void)
721721
{
722722
if (inet_del_protocol(&esp4_protocol, IPPROTO_ESP) < 0)
723-
printk(KERN_INFO "ip esp close: can't remove protocol\n");
723+
pr_info("%s: can't remove protocol\n", __func__);
724724
if (xfrm_unregister_type(&esp_type, AF_INET) < 0)
725-
printk(KERN_INFO "ip esp close: can't remove xfrm type\n");
725+
pr_info("%s: can't remove xfrm type\n", __func__);
726726
}
727727

728728
module_init(esp4_init);

‎net/ipv4/fib_frontend.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)
695695
if (ifa->ifa_flags & IFA_F_SECONDARY) {
696696
prim = inet_ifa_byprefix(in_dev, prefix, mask);
697697
if (prim == NULL) {
698-
printk(KERN_WARNING "fib_add_ifaddr: bug: prim == NULL\n");
698+
pr_warn("%s: bug: prim == NULL\n", __func__);
699699
return;
700700
}
701701
}
@@ -749,11 +749,11 @@ void fib_del_ifaddr(struct in_ifaddr *ifa, struct in_ifaddr *iprim)
749749
if (ifa->ifa_flags & IFA_F_SECONDARY) {
750750
prim = inet_ifa_byprefix(in_dev, any, ifa->ifa_mask);
751751
if (prim == NULL) {
752-
printk(KERN_WARNING "fib_del_ifaddr: bug: prim == NULL\n");
752+
pr_warn("%s: bug: prim == NULL\n", __func__);
753753
return;
754754
}
755755
if (iprim && iprim != prim) {
756-
printk(KERN_WARNING "fib_del_ifaddr: bug: iprim != prim\n");
756+
pr_warn("%s: bug: iprim != prim\n", __func__);
757757
return;
758758
}
759759
} else if (!ipv4_is_zeronet(any) &&

‎net/ipv4/fib_semantics.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static void free_fib_info_rcu(struct rcu_head *head)
154154
void free_fib_info(struct fib_info *fi)
155155
{
156156
if (fi->fib_dead == 0) {
157-
pr_warning("Freeing alive fib_info %p\n", fi);
157+
pr_warn("Freeing alive fib_info %p\n", fi);
158158
return;
159159
}
160160
change_nexthops(fi) {

‎net/ipv4/fib_trie.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,9 +1170,8 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
11701170
}
11711171

11721172
if (tp && tp->pos + tp->bits > 32)
1173-
pr_warning("fib_trie"
1174-
" tp=%p pos=%d, bits=%d, key=%0x plen=%d\n",
1175-
tp, tp->pos, tp->bits, key, plen);
1173+
pr_warn("fib_trie tp=%p pos=%d, bits=%d, key=%0x plen=%d\n",
1174+
tp, tp->pos, tp->bits, key, plen);
11761175

11771176
/* Rebalance the trie */
11781177

‎net/ipv4/icmp.c‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ static void icmp_unreach(struct sk_buff *skb)
670670
break;
671671
case ICMP_FRAG_NEEDED:
672672
if (ipv4_config.no_pmtu_disc) {
673-
LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: fragmentation needed and DF set.\n",
673+
LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: fragmentation needed and DF set\n",
674674
&iph->daddr);
675675
} else {
676676
info = ip_rt_frag_needed(net, iph,
@@ -681,7 +681,7 @@ static void icmp_unreach(struct sk_buff *skb)
681681
}
682682
break;
683683
case ICMP_SR_FAILED:
684-
LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: Source Route Failed.\n",
684+
LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: Source Route Failed\n",
685685
&iph->daddr);
686686
break;
687687
default:
@@ -713,13 +713,10 @@ static void icmp_unreach(struct sk_buff *skb)
713713
if (!net->ipv4.sysctl_icmp_ignore_bogus_error_responses &&
714714
inet_addr_type(net, iph->daddr) == RTN_BROADCAST) {
715715
if (net_ratelimit())
716-
printk(KERN_WARNING "%pI4 sent an invalid ICMP "
717-
"type %u, code %u "
718-
"error to a broadcast: %pI4 on %s\n",
719-
&ip_hdr(skb)->saddr,
720-
icmph->type, icmph->code,
721-
&iph->daddr,
722-
skb->dev->name);
716+
pr_warn("%pI4 sent an invalid ICMP type %u, code %u error to a broadcast: %pI4 on %s\n",
717+
&ip_hdr(skb)->saddr,
718+
icmph->type, icmph->code,
719+
&iph->daddr, skb->dev->name);
723720
goto out;
724721
}
725722

@@ -946,8 +943,8 @@ static void icmp_address_reply(struct sk_buff *skb)
946943
break;
947944
}
948945
if (!ifa && net_ratelimit()) {
949-
printk(KERN_INFO "Wrong address mask %pI4 from %s/%pI4\n",
950-
mp, dev->name, &ip_hdr(skb)->saddr);
946+
pr_info("Wrong address mask %pI4 from %s/%pI4\n",
947+
mp, dev->name, &ip_hdr(skb)->saddr);
951948
}
952949
}
953950
}

‎net/ipv4/ip_fragment.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
643643
goto out_fail;
644644
out_oversize:
645645
if (net_ratelimit())
646-
printk(KERN_INFO "Oversized IP packet from %pI4.\n",
647-
&qp->saddr);
646+
pr_info("Oversized IP packet from %pI4\n", &qp->saddr);
648647
out_fail:
649648
IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS);
650649
return err;

‎net/ipv4/ip_gre.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,15 +1716,15 @@ static int __init ipgre_init(void)
17161716
{
17171717
int err;
17181718

1719-
printk(KERN_INFO "GRE over IPv4 tunneling driver\n");
1719+
pr_info("GRE over IPv4 tunneling driver\n");
17201720

17211721
err = register_pernet_device(&ipgre_net_ops);
17221722
if (err < 0)
17231723
return err;
17241724

17251725
err = gre_add_protocol(&ipgre_protocol, GREPROTO_CISCO);
17261726
if (err < 0) {
1727-
printk(KERN_INFO "ipgre init: can't add protocol\n");
1727+
pr_info("%s: can't add protocol\n", __func__);
17281728
goto add_proto_failed;
17291729
}
17301730

@@ -1753,7 +1753,7 @@ static void __exit ipgre_fini(void)
17531753
rtnl_link_unregister(&ipgre_tap_ops);
17541754
rtnl_link_unregister(&ipgre_link_ops);
17551755
if (gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO) < 0)
1756-
printk(KERN_INFO "ipgre close: can't remove protocol\n");
1756+
pr_info("%s: can't remove protocol\n", __func__);
17571757
unregister_pernet_device(&ipgre_net_ops);
17581758
}
17591759

‎net/ipv4/ip_input.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ static inline bool ip_rcv_options(struct sk_buff *skb)
299299
if (!IN_DEV_SOURCE_ROUTE(in_dev)) {
300300
if (IN_DEV_LOG_MARTIANS(in_dev) &&
301301
net_ratelimit())
302-
printk(KERN_INFO "source route option %pI4 -> %pI4\n",
303-
&iph->saddr, &iph->daddr);
302+
pr_info("source route option %pI4 -> %pI4\n",
303+
&iph->saddr, &iph->daddr);
304304
goto drop;
305305
}
306306
}

0 commit comments

Comments
 (0)