From patchwork Wed Jan 23 05:11:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koki Sanagi X-Patchwork-Id: 214791 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 168BD2C007B for ; Wed, 23 Jan 2013 16:11:22 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751094Ab3AWFLS (ORCPT ); Wed, 23 Jan 2013 00:11:18 -0500 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:57695 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750886Ab3AWFLR convert rfc822-to-8bit (ORCPT ); Wed, 23 Jan 2013 00:11:17 -0500 Received: from m2.gw.fujitsu.co.jp (unknown [10.0.50.72]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id 130E23EE0C0 for ; Wed, 23 Jan 2013 14:11:16 +0900 (JST) Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id E911645DE59 for ; Wed, 23 Jan 2013 14:11:15 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id D143F45DE54 for ; Wed, 23 Jan 2013 14:11:15 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id C09101DB8041 for ; Wed, 23 Jan 2013 14:11:15 +0900 (JST) Received: from g01jpexchyt04.g01.fujitsu.local (g01jpexchyt04.g01.fujitsu.local [10.128.194.43]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 6ECFE1DB803C for ; Wed, 23 Jan 2013 14:11:15 +0900 (JST) Received: from G01JPEXMBYT04.g01.fujitsu.local ([10.128.194.68]) by g01jpexchyt04 ([10.128.194.43]) with mapi id 14.02.0309.002; Wed, 23 Jan 2013 14:11:15 +0900 From: "Sanagi, Koki" To: David Miller CC: "netdev@vger.kernel.org" Subject: RE: [PATCH] skb: add a comment to skb_csum_unnecessary to avoid miuse Thread-Topic: [PATCH] skb: add a comment to skb_csum_unnecessary to avoid miuse Thread-Index: AQHN+QDXVr2rW3LD1UCGSM4EKkZETJhVkBQAgACfa1D//4e7gIAAommw Date: Wed, 23 Jan 2013 05:11:14 +0000 Message-ID: References: <50FF2F18.1050408@jp.fujitsu.com> <20130122.205346.633138554393148358.davem@davemloft.net> <20130122.231353.2100388787067184936.davem@davemloft.net> In-Reply-To: <20130122.231353.2100388787067184936.davem@davemloft.net> Accept-Language: en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-securitypolicycheck: OK by SHieldMailChecker v1.8.4 x-originating-ip: [10.124.101.77] MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org > From: "Sanagi, Koki" > Date: Wed, 23 Jan 2013 02:32:52 +0000 > > >> From: Koki Sanagi > >> 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 > >> > >> 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 ? --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; } /**