Subject: Re: [PATCH net-next] inet_ecn: Use csum16_add() helper for IP_ECN_set_* helpers

From: kernel test robot <[email-masked]>
Date: Thu, 10 Dec 2020 23:43:23 +0800

Hi "Toke,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Toke-H-iland-J-rgensen/inet_ecn-Use-csum16_add-helper-for-IP_ECN_set_-helpers/20201210-190846
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git a7105e3472bf6bb3099d1293ea7d70e7783aa582
config: i386-randconfig-s001-20201209 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-179-ga00755aa-dirty
        # https://github.com/0day-ci/linux/commit/fbed6705f871b8eb4e522c874927ac8e57c8889b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Toke-H-iland-J-rgensen/inet_ecn-Use-csum16_add-helper-for-IP_ECN_set_-helpers/20201210-190846
        git checkout fbed6705f871b8eb4e522c874927ac8e57c8889b
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email-masked]>

"sparse warnings: (new ones prefixed by >>)"
   net/sched/sch_choke.c: note: in included file:
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
--
   net/sched/sch_sfb.c: note: in included file:
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
--
   net/sched/sch_codel.c: note: in included file (through include/net/codel.h):
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
--
   net/sched/sch_red.c: note: in included file:
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
--
   net/sched/sch_fq.c: note: in included file (through include/net/tcp.h):
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
--
   net/sched/sch_fq_codel.c: note: in included file (through include/net/codel.h):
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
--
   net/sched/sch_netem.c: note: in included file:
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
--
   net/sched/sch_sfq.c: note: in included file (through include/net/red.h):
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add
>> include/net/inet_ecn.h:97:21: sparse: sparse: restricted __be16 degrades to integer
   include/net/inet_ecn.h:97:37: sparse: sparse: restricted __be16 degrades to integer
>> include/net/inet_ecn.h:99:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __be16 [usertype] addend @@     got unsigned short [assigned] [usertype] check_add @@
   include/net/inet_ecn.h:99:45: sparse:     expected restricted __be16 [usertype] addend
   include/net/inet_ecn.h:99:45: sparse:     got unsigned short [assigned] [usertype] check_add

vim +97 include/net/inet_ecn.h

    67	
    68	#define IP6_ECN_flow_init(label) do {		\
    69	      (label) &= ~htonl(INET_ECN_MASK << 20);	\
    70	    } while (0)
    71	
    72	#define	IP6_ECN_flow_xmit(sk, label) do {				\
    73		if (INET_ECN_is_capable(inet6_sk(sk)->tclass))			\
    74			(label) |= htonl(INET_ECN_ECT_0 << 20);			\
    75	    } while (0)
    76	
    77	static inline int IP_ECN_set_ce(struct iphdr *iph)
    78	{
    79		u32 ecn = (iph->tos + 1) & INET_ECN_MASK;
    80		u16 check_add;
    81	
    82		/*
    83		 * After the last operation we have (in binary):
    84		 * INET_ECN_NOT_ECT => 01
    85		 * INET_ECN_ECT_1   => 10
    86		 * INET_ECN_ECT_0   => 11
    87		 * INET_ECN_CE      => 00
    88		 */
    89		if (!(ecn & 2))
    90			return !ecn;
    91	
    92		/*
    93		 * The following gives us:
    94		 * INET_ECN_ECT_1 => check += htons(0xFFFD)
    95		 * INET_ECN_ECT_0 => check += htons(0xFFFE)
    96		 */
  > 97		check_add = htons(0xFFFB) + htons(ecn);
    98	
  > 99		iph->check = csum16_add(iph->check, check_add);
   100		iph->tos |= INET_ECN_CE;
   101		return 1;
   102	}
   103	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email-masked]