Re: [PATCH Netfilter] net: netfilter: Replace printk() with more standardize output format.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 11, 2018 at 12:09:07AM +0530, Arushi Singhal wrote:
> printk() is the raw way to print output and should be avoided.
> 
> For drivers with defined "struct device object", dev_*macro() is
> prefer and for "struct netdevice object", netdev_*macro() is prefer over
> dev_*macro() to standardize the output format within the subsystem.
> 
> If no "struct device object" is defined prefer pr_*macro() over
> printk().
> 
> This patch Replace printk having a log level with the appropriate output
> format according to the order of preference.
> 
> Signed-off-by: Arushi Singhal <arushisinghal19971997@xxxxxxxxx>
> ---
>  net/netfilter/nf_conntrack_acct.c      | 2 +-
>  net/netfilter/nf_conntrack_ecache.c    | 2 +-
>  net/netfilter/nf_conntrack_timestamp.c | 2 +-
>  net/netfilter/nf_nat_core.c            | 2 +-
>  net/netfilter/nfnetlink_queue.c        | 4 ++--
>  5 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
> index 8669167..fc7329d 100644
> --- a/net/netfilter/nf_conntrack_acct.c
> +++ b/net/netfilter/nf_conntrack_acct.c
> @@ -80,7 +80,7 @@ static int nf_conntrack_acct_init_sysctl(struct net *net)
>  	net->ct.acct_sysctl_header = register_net_sysctl(net, "net/netfilter",
>  							 table);
>  	if (!net->ct.acct_sysctl_header) {
> -		printk(KERN_ERR "nf_conntrack_acct: can't register to sysctl.\n");
> +		netdev_err(net->loopback_dev, "nf_conntrack_acct: can't register to sysctl.\n");

Please, use pr_err instead.

And while you are at it, add

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

whenever possible, thanks!

P.S: Send your netfilter patches to netfilter-devel@xxxxxxxxxxxxxxx.

>  		goto out_register;
>  	}
>  	return 0;
> diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
> index caac41a..c1fb296 100644
> --- a/net/netfilter/nf_conntrack_ecache.c
> +++ b/net/netfilter/nf_conntrack_ecache.c
> @@ -372,7 +372,7 @@ static int nf_conntrack_event_init_sysctl(struct net *net)
>  	net->ct.event_sysctl_header =
>  		register_net_sysctl(net, "net/netfilter", table);
>  	if (!net->ct.event_sysctl_header) {
> -		printk(KERN_ERR "nf_ct_event: can't register to sysctl.\n");
> +		netdev_err(net->loopback_dev, "nf_ct_event: can't register to sysctl.\n");
>  		goto out_register;
>  	}
>  	return 0;
> diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
> index 4c4734b..abd9fbd 100644
> --- a/net/netfilter/nf_conntrack_timestamp.c
> +++ b/net/netfilter/nf_conntrack_timestamp.c
> @@ -58,7 +58,7 @@ static int nf_conntrack_tstamp_init_sysctl(struct net *net)
>  	net->ct.tstamp_sysctl_header = register_net_sysctl(net,	"net/netfilter",
>  							   table);
>  	if (!net->ct.tstamp_sysctl_header) {
> -		printk(KERN_ERR "nf_ct_tstamp: can't register to sysctl.\n");
> +		netdev_err(net->loopback_dev, "nf_ct_tstamp: can't register to sysctl.\n");
>  		goto out_register;
>  	}
>  	return 0;
> diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
> index 6c38421..dcda5ac 100644
> --- a/net/netfilter/nf_nat_core.c
> +++ b/net/netfilter/nf_nat_core.c
> @@ -814,7 +814,7 @@ static int __init nf_nat_init(void)
>  	ret = nf_ct_extend_register(&nat_extend);
>  	if (ret < 0) {
>  		nf_ct_free_hashtable(nf_nat_bysource, nf_nat_htable_size);
> -		printk(KERN_ERR "nf_nat_core: Unable to register extension\n");
> +		pr_err("nf_nat_core: Unable to register extension\n");
>  		return ret;
>  	}
>  
> diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
> index 8bba231..4b4bef5 100644
> --- a/net/netfilter/nfnetlink_queue.c
> +++ b/net/netfilter/nfnetlink_queue.c
> @@ -834,8 +834,8 @@ nfqnl_mangle(void *data, int data_len, struct nf_queue_entry *e, int diff)
>  			nskb = skb_copy_expand(e->skb, skb_headroom(e->skb),
>  					       diff, GFP_ATOMIC);
>  			if (!nskb) {
> -				printk(KERN_WARNING "nf_queue: OOM "
> -				      "in mangle, dropping packet\n");
> +				netdev_warn(nskb->dev, "nf_queue: OOM "
> +					    "in mangle, dropping packet\n");
>  				return -ENOMEM;
>  			}
>  			kfree_skb(e->skb);
> -- 
> 2.7.4
> 
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux