2018-03-05 21:05:11

by Julia Lawall

[permalink] [raw]
Subject: Re: [Outreachy kernel] Re: [PATCH] staging: irda: Replace printk() with appropriate net_*macro_ratelimited()



On Mon, 5 Mar 2018, Arushi Singhal wrote:

>
>
> On Mon, Mar 5, 2018 at 3:33 PM, Dan Carpenter <[email protected]> wrote:
> On Mon, Mar 05, 2018 at 04:02:06AM +0530, Arushi Singhal wrote:
> > Replace printk having a log level with the appropriate
> > net_*macro_ratelimited.
> > It's better to use actual device name as a prefix in error messages.
> > Indentation is also changed, to fix the  checkpatch issue if line is not
> > exceding 80 characters.
> >
> > Signed-off-by: Arushi Singhal <[email protected]>
> > ---
> >  .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c      | 22 +++++++++++-----------
> >  1 file changed, 11 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
> > index e6648f7..200fe5f 100644
> > --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
> > +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
> > @@ -73,7 +73,7 @@ static void *ieee80211_ccmp_init(int key_idx)
> >
> >       priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
> >       if (IS_ERR(priv->tfm)) {
> > -             printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate crypto API aes\n");
> > +             net_dbg_ratelimited("ieee80211_crypt_ccmp: could not allocate crypto API aes\n");
>
>
> This should probably just be deleted.
>
> Hello Dan
> Why we should make this change?
> According to me it's use here to print debug message.
> Wanted to know more about your thought on this.
>
> >               priv->tfm = NULL;
> >               goto fail;
> >       }
> > @@ -276,22 +276,22 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
> >       keyidx = pos[3];
> >       if (!(keyidx & (1 << 5))) {
> >               if (net_ratelimit()) {
> > -                     printk(KERN_DEBUG "CCMP: received packet without ExtIV flag from %pM\n",
> > -                             hdr->addr2);
> > +                     net_dbg_ratelimited("CCMP: received packet without ExtIV flag from %pM\n",
> > +                                         hdr->addr2);
> >               }
>
> The "if (net_ratelimit()) " already means the message is ratelimited so
> it's net_dbg() ok?  I think so, but I've never looked at this before.
>
>  
> net_dbg() is an implicit declaration of a function. So we can't do this change.

Perhaps you can add the header file that declares net_dbg.

julia


2018-03-06 12:06:04

by Simran Singhal

[permalink] [raw]
Subject: Re: [Outreachy kernel] Re: [PATCH] staging: irda: Replace printk() with appropriate net_*macro_ratelimited()

On Tue, Mar 6, 2018 at 2:33 AM, Julia Lawall <[email protected]> wrote:
>
>
> On Mon, 5 Mar 2018, Arushi Singhal wrote:
>
>>
>>
>> On Mon, Mar 5, 2018 at 3:33 PM, Dan Carpenter <[email protected]> wrote:
>> On Mon, Mar 05, 2018 at 04:02:06AM +0530, Arushi Singhal wrote:
>> > Replace printk having a log level with the appropriate
>> > net_*macro_ratelimited.
>> > It's better to use actual device name as a prefix in error messages.
>> > Indentation is also changed, to fix the checkpatch issue if line is not
>> > exceding 80 characters.
>> >
>> > Signed-off-by: Arushi Singhal <[email protected]>
>> > ---
>> > .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c | 22 +++++++++++-----------
>> > 1 file changed, 11 insertions(+), 11 deletions(-)
>> >
>> > diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
>> > index e6648f7..200fe5f 100644
>> > --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
>> > +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
>> > @@ -73,7 +73,7 @@ static void *ieee80211_ccmp_init(int key_idx)
>> >
>> > priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
>> > if (IS_ERR(priv->tfm)) {
>> > - printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate crypto API aes\n");
>> > + net_dbg_ratelimited("ieee80211_crypt_ccmp: could not allocate crypto API aes\n");
>>
>>
>> This should probably just be deleted.
>>
>> Hello Dan
>> Why we should make this change?
>> According to me it's use here to print debug message.
>> Wanted to know more about your thought on this.
>>
>> > priv->tfm = NULL;
>> > goto fail;
>> > }
>> > @@ -276,22 +276,22 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
>> > keyidx = pos[3];
>> > if (!(keyidx & (1 << 5))) {
>> > if (net_ratelimit()) {
>> > - printk(KERN_DEBUG "CCMP: received packet without ExtIV flag from %pM\n",
>> > - hdr->addr2);
>> > + net_dbg_ratelimited("CCMP: received packet without ExtIV flag from %pM\n",
>> > + hdr->addr2);
>> > }
>>
>> The "if (net_ratelimit()) " already means the message is ratelimited so
>> it's net_dbg() ok? I think so, but I've never looked at this before.
>>
>>
>> net_dbg() is an implicit declaration of a function. So we can't do this change.
>
> Perhaps you can add the header file that declares net_dbg.

Hi Julia

There is such header file which declares net_dbg.
We can use dev_dbg() for all struct device object.
We can use netdev_dbg() for all struct netdevice object.
For net subsystem when there is no struct device object we can go with
net_dbg_ratelimited (preferred) or pr_debug.

I have understood this from my readings. If I am wrong somewhere
please correct me.

Thanks
Arushi

>
> julia
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.20.1803052203001.2763%40hadrien.
> For more options, visit https://groups.google.com/d/optout.