netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] skb: add a comment to skb_csum_unnecessary to avoid miuse
@ 2013-01-23  0:30 Koki Sanagi
  2013-01-23  1:53 ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Koki Sanagi @ 2013-01-23  0:30 UTC (permalink / raw)
  To: netdev; +Cc: davem

Due to its name and appearance, someone thinks this only checks if ip_summed is
CHECKSUM_UNNECESARRY.  But actually, this returns true even if ip_summed is
CHECKSUM_PARTIAL.  To avoid misuse, this patch a comment which specifies that
CHECKSUM_PARTIAL is OK.

Signed-off-by: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
---
 include/linux/skbuff.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 8b2256e..bc41f64 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2522,6 +2522,16 @@ void skb_complete_wifi_ack(struct sk_buff *skb, bool acked);
 extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len);
 extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
 
+/**
+ * skb_csum_unnecessary - check if the checksum needs to be verified
+ * @skb: skb to check
+ *
+ * check if the checksum of this skb needs to be verified.  This function is
+ * effective only against skbs on inbound path.
+ *
+ * NB: This returns true if ip_summed is CHECKSUM_UNNECESSARY or
+ *     CHECKSUM_PARTIAL.
+ **/
 static inline int skb_csum_unnecessary(const struct sk_buff *skb)
 {
 	return skb->ip_summed & CHECKSUM_UNNECESSARY;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] skb: add a comment to skb_csum_unnecessary to avoid miuse
  2013-01-23  0:30 [PATCH] skb: add a comment to skb_csum_unnecessary to avoid miuse Koki Sanagi
@ 2013-01-23  1:53 ` David Miller
  2013-01-23  2:32   ` Sanagi, Koki
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2013-01-23  1:53 UTC (permalink / raw)
  To: sanagi.koki; +Cc: netdev

From: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
Date: Wed, 23 Jan 2013 09:30:16 +0900

> Due to its name and appearance, someone thinks this only checks if ip_summed is
> CHECKSUM_UNNECESARRY.  But actually, this returns true even if ip_summed is
> CHECKSUM_PARTIAL.  To avoid misuse, this patch a comment which specifies that
> CHECKSUM_PARTIAL is OK.
> 
> Signed-off-by: Koki Sanagi <sanagi.koki@jp.fujitsu.com>

I'm not applying this, sorry.  It's a one line function and it's not
so non-obvious that it deserves an 8 line comment.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] skb: add a comment to skb_csum_unnecessary to avoid miuse
  2013-01-23  1:53 ` David Miller
@ 2013-01-23  2:32   ` Sanagi, Koki
  2013-01-23  4:13     ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Sanagi, Koki @ 2013-01-23  2:32 UTC (permalink / raw)
  To: David Miller; +Cc: netdev@vger.kernel.org

> From: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
> Date: Wed, 23 Jan 2013 09:30:16 +0900
> 
> > Due to its name and appearance, someone thinks this only checks if
> > ip_summed is CHECKSUM_UNNECESARRY.  But actually, this returns true
> > even if ip_summed is CHECKSUM_PARTIAL.  To avoid misuse, this patch a
> > comment which specifies that CHECKSUM_PARTIAL is OK.
> >
> > Signed-off-by: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
> 
> I'm not applying this, sorry.  It's a one line function and it's not so
> non-obvious that it deserves an 8 line comment.

OK.  I just felt weird that CHECKSUM_* is not bit flag but this function handles
it as if it was bit flag.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] skb: add a comment to skb_csum_unnecessary to avoid miuse
  2013-01-23  2:32   ` Sanagi, Koki
@ 2013-01-23  4:13     ` David Miller
  2013-01-23  5:11       ` Sanagi, Koki
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2013-01-23  4:13 UTC (permalink / raw)
  To: sanagi.koki; +Cc: netdev

From: "Sanagi, Koki" <sanagi.koki@jp.fujitsu.com>
Date: Wed, 23 Jan 2013 02:32:52 +0000

>> From: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
>> Date: Wed, 23 Jan 2013 09:30:16 +0900
>> 
>> > Due to its name and appearance, someone thinks this only checks if
>> > ip_summed is CHECKSUM_UNNECESARRY.  But actually, this returns true
>> > even if ip_summed is CHECKSUM_PARTIAL.  To avoid misuse, this patch a
>> > comment which specifies that CHECKSUM_PARTIAL is OK.
>> >
>> > Signed-off-by: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
>> 
>> I'm not applying this, sorry.  It's a one line function and it's not so
>> non-obvious that it deserves an 8 line comment.
> 
> OK.  I just felt weird that CHECKSUM_* is not bit flag but this function handles
> it as if it was bit flag.

The function name says what it does, it determines whether a checksum
is necessary or not.  How that is implemented is another issue.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] skb: add a comment to skb_csum_unnecessary to avoid miuse
  2013-01-23  4:13     ` David Miller
@ 2013-01-23  5:11       ` Sanagi, Koki
  2013-01-23  5:21         ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Sanagi, Koki @ 2013-01-23  5:11 UTC (permalink / raw)
  To: David Miller; +Cc: netdev@vger.kernel.org

> From: "Sanagi, Koki" <sanagi.koki@jp.fujitsu.com>
> Date: Wed, 23 Jan 2013 02:32:52 +0000
> 
> >> From: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
> >> Date: Wed, 23 Jan 2013 09:30:16 +0900
> >>
> >> > Due to its name and appearance, someone thinks this only checks if
> >> > ip_summed is CHECKSUM_UNNECESARRY.  But actually, this returns true
> >> > even if ip_summed is CHECKSUM_PARTIAL.  To avoid misuse, this patch
> >> > a comment which specifies that CHECKSUM_PARTIAL is OK.
> >> >
> >> > Signed-off-by: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
> >>
> >> I'm not applying this, sorry.  It's a one line function and it's not
> >> so non-obvious that it deserves an 8 line comment.
> >
> > OK.  I just felt weird that CHECKSUM_* is not bit flag but this
> > function handles it as if it was bit flag.
> 
> The function name says what it does, it determines whether a checksum is
> necessary or not.  How that is implemented is another issue.

As for name of the function which confused me, I'm ok now.  But as for how to implement,
I still think it is inappropriate because of the above reason.  So, how about introducing
CHECKSUM_UNNECESSARY_BIT like below ?

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 8b2256e..b1dbd36 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -39,6 +39,8 @@
 #define CHECKSUM_COMPLETE 2
 #define CHECKSUM_PARTIAL 3

+#define CHECKSUM_UNNECESSARY_BIT (1 << 0)
+
 #define SKB_DATA_ALIGN(X)      (((X) + (SMP_CACHE_BYTES - 1)) & \
                                 ~(SMP_CACHE_BYTES - 1))
 #define SKB_WITH_OVERHEAD(X)   \
@@ -2524,7 +2526,7 @@ extern __sum16 __skb_checksum_complete(struct sk_buff *skb);

 static inline int skb_csum_unnecessary(const struct sk_buff *skb)
 {
-       return skb->ip_summed & CHECKSUM_UNNECESSARY;
+       return skb->ip_summed & CHECKSUM_UNNECESSARY_BIT;
 }

 /**

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] skb: add a comment to skb_csum_unnecessary to avoid miuse
  2013-01-23  5:11       ` Sanagi, Koki
@ 2013-01-23  5:21         ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-01-23  5:21 UTC (permalink / raw)
  To: sanagi.koki; +Cc: netdev

From: "Sanagi, Koki" <sanagi.koki@jp.fujitsu.com>
Date: Wed, 23 Jan 2013 05:11:14 +0000

> As for name of the function which confused me, I'm ok now.  But as
> for how to implement, I still think it is inappropriate because of
> the above reason.  So, how about introducing
> CHECKSUM_UNNECESSARY_BIT like below ?

If the user has to look at the implementation, they will see
the "&" and there is no confusion.

Please stop splitting hairs, this is a waste of time.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-01-23  5:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-23  0:30 [PATCH] skb: add a comment to skb_csum_unnecessary to avoid miuse Koki Sanagi
2013-01-23  1:53 ` David Miller
2013-01-23  2:32   ` Sanagi, Koki
2013-01-23  4:13     ` David Miller
2013-01-23  5:11       ` Sanagi, Koki
2013-01-23  5:21         ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).