Skip to content

Commit

Permalink
net/sctp: Use pr_fmt and pr_<level>
Browse files Browse the repository at this point in the history
Change SCTP_DEBUG_PRINTK and SCTP_DEBUG_PRINTK_IPADDR to
use do { print } while (0) guards.
Add SCTP_DEBUG_PRINTK_CONT to fix errors in log when
lines were continued.
Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Add a missing newline in "Failed bind hash alloc"

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
JoePerches authored and davem330 committed Aug 26, 2010
1 parent dee06e4 commit 145ce50
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 117 deletions.
48 changes: 30 additions & 18 deletions include/net/sctp/sctp.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,24 +275,35 @@ struct sctp_mib {
/* Print debugging messages. */
#if SCTP_DEBUG
extern int sctp_debug_flag;
#define SCTP_DEBUG_PRINTK(whatever...) \
((void) (sctp_debug_flag && printk(KERN_DEBUG whatever)))
#define SCTP_DEBUG_PRINTK_IPADDR(lead, trail, leadparm, saddr, otherparms...) \
if (sctp_debug_flag) { \
if (saddr->sa.sa_family == AF_INET6) { \
printk(KERN_DEBUG \
lead "%pI6" trail, \
leadparm, \
&saddr->v6.sin6_addr, \
otherparms); \
} else { \
printk(KERN_DEBUG \
lead "%pI4" trail, \
leadparm, \
&saddr->v4.sin_addr.s_addr, \
otherparms); \
} \
}
#define SCTP_DEBUG_PRINTK(fmt, args...) \
do { \
if (sctp_debug_flag) \
printk(KERN_DEBUG pr_fmt(fmt), ##args); \
} while (0)
#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) \
do { \
if (sctp_debug_flag) \
pr_cont(fmt, ##args); \
} while (0)
#define SCTP_DEBUG_PRINTK_IPADDR(fmt_lead, fmt_trail, \
args_lead, saddr, args_trail...) \
do { \
if (sctp_debug_flag) { \
if (saddr->sa.sa_family == AF_INET6) { \
printk(KERN_DEBUG \
pr_fmt(fmt_lead "%pI6" fmt_trail), \
args_lead, \
&saddr->v6.sin6_addr, \
args_trail); \
} else { \
printk(KERN_DEBUG \
pr_fmt(fmt_lead "%pI4" fmt_trail), \
args_lead, \
&saddr->v4.sin_addr.s_addr, \
args_trail); \
} \
} \
} while (0)
#define SCTP_ENABLE_DEBUG { sctp_debug_flag = 1; }
#define SCTP_DISABLE_DEBUG { sctp_debug_flag = 0; }

Expand All @@ -306,6 +317,7 @@ extern int sctp_debug_flag;
#else /* SCTP_DEBUG */

#define SCTP_DEBUG_PRINTK(whatever...)
#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
#define SCTP_ENABLE_DEBUG
#define SCTP_DISABLE_DEBUG
Expand Down
2 changes: 2 additions & 0 deletions net/sctp/associola.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
* be incorporated into the next SCTP release.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/types.h>
#include <linux/fcntl.h>
#include <linux/poll.h>
Expand Down
2 changes: 2 additions & 0 deletions net/sctp/chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
* be incorporated into the next SCTP release.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/net.h>
Expand Down
2 changes: 2 additions & 0 deletions net/sctp/inqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
* be incorporated into the next SCTP release.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <net/sctp/sctp.h>
#include <net/sctp/sm.h>
#include <linux/interrupt.h>
Expand Down
4 changes: 3 additions & 1 deletion net/sctp/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
* be incorporated into the next SCTP release.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/errno.h>
#include <linux/types.h>
Expand Down Expand Up @@ -336,7 +338,7 @@ static void sctp_v6_get_saddr(struct sctp_sock *sk,
memcpy(saddr, baddr, sizeof(union sctp_addr));
SCTP_DEBUG_PRINTK("saddr: %pI6\n", &saddr->v6.sin6_addr);
} else {
printk(KERN_ERR "%s: asoc:%p Could not find a valid source "
pr_err("%s: asoc:%p Could not find a valid source "
"address for the dest:%pI6\n",
__func__, asoc, &daddr->v6.sin6_addr);
}
Expand Down
5 changes: 3 additions & 2 deletions net/sctp/objcnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
* be incorporated into the next SCTP release.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/kernel.h>
#include <net/sctp/sctp.h>

Expand Down Expand Up @@ -134,8 +136,7 @@ void sctp_dbg_objcnt_init(void)
ent = proc_create("sctp_dbg_objcnt", 0,
proc_net_sctp, &sctp_objcnt_ops);
if (!ent)
printk(KERN_WARNING
"sctp_dbg_objcnt: Unable to create /proc entry.\n");
pr_warn("sctp_dbg_objcnt: Unable to create /proc entry.\n");
}

/* Cleanup the objcount entry in the proc filesystem. */
Expand Down
2 changes: 2 additions & 0 deletions net/sctp/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
* be incorporated into the next SCTP release.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/wait.h>
Expand Down
34 changes: 18 additions & 16 deletions net/sctp/outqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
* be incorporated into the next SCTP release.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/types.h>
#include <linux/list.h> /* For struct list_head */
#include <linux/socket.h>
Expand Down Expand Up @@ -1463,23 +1465,23 @@ static void sctp_check_transmitted(struct sctp_outq *q,
/* Display the end of the
* current range.
*/
SCTP_DEBUG_PRINTK("-%08x",
dbg_last_ack_tsn);
SCTP_DEBUG_PRINTK_CONT("-%08x",
dbg_last_ack_tsn);
}

/* Start a new range. */
SCTP_DEBUG_PRINTK(",%08x", tsn);
SCTP_DEBUG_PRINTK_CONT(",%08x", tsn);
dbg_ack_tsn = tsn;
break;

case 1: /* The last TSN was NOT ACKed. */
if (dbg_last_kept_tsn != dbg_kept_tsn) {
/* Display the end of current range. */
SCTP_DEBUG_PRINTK("-%08x",
dbg_last_kept_tsn);
SCTP_DEBUG_PRINTK_CONT("-%08x",
dbg_last_kept_tsn);
}

SCTP_DEBUG_PRINTK("\n");
SCTP_DEBUG_PRINTK_CONT("\n");

/* FALL THROUGH... */
default:
Expand Down Expand Up @@ -1526,18 +1528,18 @@ static void sctp_check_transmitted(struct sctp_outq *q,
break;

if (dbg_last_kept_tsn != dbg_kept_tsn)
SCTP_DEBUG_PRINTK("-%08x",
dbg_last_kept_tsn);
SCTP_DEBUG_PRINTK_CONT("-%08x",
dbg_last_kept_tsn);

SCTP_DEBUG_PRINTK(",%08x", tsn);
SCTP_DEBUG_PRINTK_CONT(",%08x", tsn);
dbg_kept_tsn = tsn;
break;

case 0:
if (dbg_last_ack_tsn != dbg_ack_tsn)
SCTP_DEBUG_PRINTK("-%08x",
dbg_last_ack_tsn);
SCTP_DEBUG_PRINTK("\n");
SCTP_DEBUG_PRINTK_CONT("-%08x",
dbg_last_ack_tsn);
SCTP_DEBUG_PRINTK_CONT("\n");

/* FALL THROUGH... */
default:
Expand All @@ -1556,17 +1558,17 @@ static void sctp_check_transmitted(struct sctp_outq *q,
switch (dbg_prt_state) {
case 0:
if (dbg_last_ack_tsn != dbg_ack_tsn) {
SCTP_DEBUG_PRINTK("-%08x\n", dbg_last_ack_tsn);
SCTP_DEBUG_PRINTK_CONT("-%08x\n", dbg_last_ack_tsn);
} else {
SCTP_DEBUG_PRINTK("\n");
SCTP_DEBUG_PRINTK_CONT("\n");
}
break;

case 1:
if (dbg_last_kept_tsn != dbg_kept_tsn) {
SCTP_DEBUG_PRINTK("-%08x\n", dbg_last_kept_tsn);
SCTP_DEBUG_PRINTK_CONT("-%08x\n", dbg_last_kept_tsn);
} else {
SCTP_DEBUG_PRINTK("\n");
SCTP_DEBUG_PRINTK_CONT("\n");
}
}
#endif /* SCTP_DEBUG */
Expand Down
4 changes: 3 additions & 1 deletion net/sctp/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/kernel.h>
#include <linux/kprobes.h>
#include <linux/socket.h>
Expand Down Expand Up @@ -192,7 +194,7 @@ static __init int sctpprobe_init(void)
if (ret)
goto remove_proc;

pr_info("SCTP probe registered (port=%d)\n", port);
pr_info("probe registered (port=%d)\n", port);

return 0;

Expand Down
17 changes: 8 additions & 9 deletions net/sctp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
* be incorporated into the next SCTP release.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/init.h>
#include <linux/netdevice.h>
Expand Down Expand Up @@ -707,8 +709,7 @@ static int sctp_ctl_sock_init(void)
&init_net);

if (err < 0) {
printk(KERN_ERR
"SCTP: Failed to create the SCTP control socket.\n");
pr_err("Failed to create the SCTP control socket\n");
return err;
}
return 0;
Expand Down Expand Up @@ -1206,7 +1207,7 @@ SCTP_STATIC __init int sctp_init(void)
__get_free_pages(GFP_ATOMIC, order);
} while (!sctp_assoc_hashtable && --order > 0);
if (!sctp_assoc_hashtable) {
printk(KERN_ERR "SCTP: Failed association hash alloc.\n");
pr_err("Failed association hash alloc\n");
status = -ENOMEM;
goto err_ahash_alloc;
}
Expand All @@ -1220,7 +1221,7 @@ SCTP_STATIC __init int sctp_init(void)
sctp_ep_hashtable = (struct sctp_hashbucket *)
kmalloc(64 * sizeof(struct sctp_hashbucket), GFP_KERNEL);
if (!sctp_ep_hashtable) {
printk(KERN_ERR "SCTP: Failed endpoint_hash alloc.\n");
pr_err("Failed endpoint_hash alloc\n");
status = -ENOMEM;
goto err_ehash_alloc;
}
Expand All @@ -1239,7 +1240,7 @@ SCTP_STATIC __init int sctp_init(void)
__get_free_pages(GFP_ATOMIC, order);
} while (!sctp_port_hashtable && --order > 0);
if (!sctp_port_hashtable) {
printk(KERN_ERR "SCTP: Failed bind hash alloc.");
pr_err("Failed bind hash alloc\n");
status = -ENOMEM;
goto err_bhash_alloc;
}
Expand All @@ -1248,8 +1249,7 @@ SCTP_STATIC __init int sctp_init(void)
INIT_HLIST_HEAD(&sctp_port_hashtable[i].chain);
}

printk(KERN_INFO "SCTP: Hash tables configured "
"(established %d bind %d)\n",
pr_info("Hash tables configured (established %d bind %d)\n",
sctp_assoc_hashsize, sctp_port_hashsize);

/* Disable ADDIP by default. */
Expand Down Expand Up @@ -1290,8 +1290,7 @@ SCTP_STATIC __init int sctp_init(void)

/* Initialize the control inode/socket for handling OOTB packets. */
if ((status = sctp_ctl_sock_init())) {
printk (KERN_ERR
"SCTP: Failed to initialize the SCTP control sock.\n");
pr_err("Failed to initialize the SCTP control sock\n");
goto err_ctl_sock_init;
}

Expand Down
2 changes: 2 additions & 0 deletions net/sctp/sm_make_chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
* be incorporated into the next SCTP release.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/ip.h>
Expand Down
21 changes: 10 additions & 11 deletions net/sctp/sm_sideeffect.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
* be incorporated into the next SCTP release.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/skbuff.h>
#include <linux/types.h>
#include <linux/socket.h>
Expand Down Expand Up @@ -1146,26 +1148,23 @@ static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,

case SCTP_DISPOSITION_VIOLATION:
if (net_ratelimit())
printk(KERN_ERR "sctp protocol violation state %d "
"chunkid %d\n", state, subtype.chunk);
pr_err("protocol violation state %d chunkid %d\n",
state, subtype.chunk);
break;

case SCTP_DISPOSITION_NOT_IMPL:
printk(KERN_WARNING "sctp unimplemented feature in state %d, "
"event_type %d, event_id %d\n",
state, event_type, subtype.chunk);
pr_warn("unimplemented feature in state %d, event_type %d, event_id %d\n",
state, event_type, subtype.chunk);
break;

case SCTP_DISPOSITION_BUG:
printk(KERN_ERR "sctp bug in state %d, "
"event_type %d, event_id %d\n",
pr_err("bug in state %d, event_type %d, event_id %d\n",
state, event_type, subtype.chunk);
BUG();
break;

default:
printk(KERN_ERR "sctp impossible disposition %d "
"in state %d, event_type %d, event_id %d\n",
pr_err("impossible disposition %d in state %d, event_type %d, event_id %d\n",
status, state, event_type, subtype.chunk);
BUG();
break;
Expand Down Expand Up @@ -1679,8 +1678,8 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
sctp_cmd_send_asconf(asoc);
break;
default:
printk(KERN_WARNING "Impossible command: %u, %p\n",
cmd->verb, cmd->obj.ptr);
pr_warn("Impossible command: %u, %p\n",
cmd->verb, cmd->obj.ptr);
break;
}

Expand Down
Loading

0 comments on commit 145ce50

Please sign in to comment.