Skip to contentSkip to conversation

ipv6: remove dependency of nf_defrag_ipv6 on ipv6 module

PATCH Superseded Florian Westphal 2 participants 5 messages Jul 12, 2018 – Jul 13, 2018

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/2 ipv6: remove dependency of nf_defrag_ipv6 on ipv6 module

IPV6=m
DEFRAG_IPV6=m
CONNTRACK=y yields:

net/netfilter/nf_conntrack_proto.o: In function `nf_ct_netns_do_get':
net/netfilter/nf_conntrack_proto.c:802: undefined reference to nf_defrag_ipv6_enable' net/netfilter/nf_conntrack_proto.o:(.rodata+0x640): undefined reference to nf_conntrack_l4proto_icmpv6'

Setting DEFRAG_IPV6=y causes undefined references to ip6_rhash_params ip6_frag_init and ip6_expire_frag_queue so it would be needed to force IPV6=y too.

This patch gets rid of the 'followup linker error' by removing the dependency of ipv6.ko symbols from netfilter ipv6 defrag.

Shared code is placed into a header, then used from both.

---
 include/net/ipv6.h                        |  28 --------
 include/net/ipv6_frag.h                   | 102 ++++++++++++++++++++++++++++++
 net/ipv6/netfilter/nf_conntrack_reasm.c   |  17 +++--
 net/ipv6/netfilter/nf_defrag_ipv6_hooks.c |   3 +-
 net/ipv6/reassembly.c                     |  92 ++-------------------------
 net/openvswitch/conntrack.c               |   1 +
 6 files changed, 123 insertions(+), 120 deletions(-)
 create mode 100644 include/net/ipv6_frag.h
include/net/ipv6.h +0 -28
index 16475c269749..0012c0a6c86e 100644
@@ -561,34 +561,6 @@ static inline bool ipv6_prefix_equal(const struct in6_addr *addr1,
 }
 #endif
 
-struct inet_frag_queue;
-
-enum ip6_defrag_users {
-	IP6_DEFRAG_LOCAL_DELIVER,
-	IP6_DEFRAG_CONNTRACK_IN,
-	__IP6_DEFRAG_CONNTRACK_IN	= IP6_DEFRAG_CONNTRACK_IN + USHRT_MAX,
-	IP6_DEFRAG_CONNTRACK_OUT,
-	__IP6_DEFRAG_CONNTRACK_OUT	= IP6_DEFRAG_CONNTRACK_OUT + USHRT_MAX,
-	IP6_DEFRAG_CONNTRACK_BRIDGE_IN,
-	__IP6_DEFRAG_CONNTRACK_BRIDGE_IN = IP6_DEFRAG_CONNTRACK_BRIDGE_IN + USHRT_MAX,
-};
-
-void ip6_frag_init(struct inet_frag_queue *q, const void *a);
-extern const struct rhashtable_params ip6_rhash_params;
-
-/*
- *	Equivalent of ipv4 struct ip
- */
-struct frag_queue {
-	struct inet_frag_queue	q;
-
-	int			iif;
-	__u16			nhoffset;
-	u8			ecn;
-};
-
-void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq);
-
 static inline bool ipv6_addr_any(const struct in6_addr *a)
 {
 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
include/net/ipv6_frag.h new file +102 -0

102 lines not on this page · raw message

net/ipv6/netfilter/nf_conntrack_reasm.c +12 -5
index 5e0332014c17..a44156b54ec9 100644
@@ -33,9 +33,8 @@
 
 #include <net/sock.h>
 #include <net/snmp.h>
-#include <net/inet_frag.h>
+#include <net/ipv6_frag.h>
 
-#include <net/ipv6.h>
 #include <net/protocol.h>
 #include <net/transp_v6.h>
 #include <net/rawv6.h>
@@ -151,7 +150,7 @@ static void nf_ct_frag6_expire(struct timer_list *t)
 	fq = container_of(frag, struct frag_queue, q);
 	net = container_of(fq->q.net, struct net, nf_frag.frags);
 
-	ip6_expire_frag_queue(net, fq);
+	ip6frag_expire_frag_queue(net, fq);
 }
 
 /* Creation primitives. */
@@ -622,16 +621,24 @@ static struct pernet_operations nf_ct_net_ops = {
 	.exit = nf_ct_net_exit,
 };
 
+static const struct rhashtable_params nfct_rhash_params = {
+	.head_offset		= offsetof(struct inet_frag_queue, node),
+	.hashfn			= ip6frag_key_hashfn,
+	.obj_hashfn		= ip6frag_obj_hashfn,
+	.obj_cmpfn		= ip6frag_obj_cmpfn,
+	.automatic_shrinking	= true,
+};
+
 int nf_ct_frag6_init(void)
 {
 	int ret = 0;
 
-	nf_frags.constructor = ip6_frag_init;
+	nf_frags.constructor = ip6frag_init;
 	nf_frags.destructor = NULL;
 	nf_frags.qsize = sizeof(struct frag_queue);
 	nf_frags.frag_expire = nf_ct_frag6_expire;
 	nf_frags.frags_cache_name = nf_frags_cache_name;
-	nf_frags.rhash_params = ip6_rhash_params;
+	nf_frags.rhash_params = nfct_rhash_params;
 	ret = inet_frags_init(&nf_frags);
 	if (ret)
 		goto out;
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c +1 -2
index e631be25337e..72dd3e202375 100644
@@ -14,8 +14,7 @@
 #include <linux/skbuff.h>
 #include <linux/icmp.h>
 #include <linux/sysctl.h>
-#include <net/ipv6.h>
-#include <net/inet_frag.h>
+#include <net/ipv6_frag.h>
 
 #include <linux/netfilter_ipv6.h>
 #include <linux/netfilter_bridge.h>
net/ipv6/reassembly.c +7 -85

124 lines not on this page · raw message

net/openvswitch/conntrack.c +1 -0
index e05bd3e53f0f..3ede65344e4d 100644
@@ -26,6 +26,7 @@
 #include <net/netfilter/nf_conntrack_seqadj.h>
 #include <net/netfilter/nf_conntrack_zones.h>
 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
+#include <net/ipv6_frag.h>
 
 #ifdef CONFIG_NF_NAT_NEEDED
 #include <linux/netfilter/nf_nat.h>
Signature · 1 line
2.16.4
author maintainer
#1 lore raw

PATCH 2/2 netfilter: fix IPV6=m CONNTRACK=y link failure

IPV6=m
DEFRAG_IPV6=m
CONNTRACK=y yields:

net/netfilter/nf_conntrack_proto.o: In function `nf_ct_netns_do_get':
net/netfilter/nf_conntrack_proto.c:802: undefined reference to nf_defrag_ipv6_enable' net/netfilter/nf_conntrack_proto.o:(.rodata+0x640): undefined reference to nf_conntrack_l4proto_icmpv6'

After previous patch, DEFRAG_IPV6 and IPV6 are no longer retain any dependencies, so we can tell Kconfig DEFRAG_IPV6 needs to be built-in as well, this resolves missing nf_defrag_ipv6_enable.

Second error can be fixed via makefile, just make sure conntrack_proto_ipv6 is part of conntrack module.

based on earlier patch from Arnd Bergmann.

Fixes 66c524acfb5186 ("netfilter: conntrack: remove l3proto abstraction")
---
 net/ipv6/netfilter/Kconfig | 7 ++-----
 net/netfilter/Kconfig      | 2 +-
 net/netfilter/Makefile     | 2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)
net/ipv6/netfilter/Kconfig +2 -5
index 07516d5c2f80..339d0762b027 100644
@@ -5,10 +5,6 @@
 menu "IPv6: Netfilter Configuration"
 	depends on INET && IPV6 && NETFILTER
 
-config NF_DEFRAG_IPV6
-	tristate
-	default n
-
 config NF_SOCKET_IPV6
 	tristate "IPv6 socket lookup support"
 	help
@@ -349,6 +345,7 @@ config IP6_NF_TARGET_NPT
 endif # IP6_NF_NAT
 
 endif # IP6_NF_IPTABLES
-
 endmenu
 
+config NF_DEFRAG_IPV6
+	tristate
net/netfilter/Kconfig +1 -1
index 6c65d756e603..e0ab50c58dc4 100644
@@ -50,7 +50,7 @@ config NF_CONNTRACK
 	tristate "Netfilter connection tracking support"
 	default m if NETFILTER_ADVANCED=n
 	select NF_DEFRAG_IPV4
-	select NF_DEFRAG_IPV6 if IPV6
+	select NF_DEFRAG_IPV6 if IPV6 != n
 	help
 	  Connection tracking keeps a record of what packets have passed
 	  through your machine, in order to figure out how they are related
net/netfilter/Makefile +1 -1
index 0b3851e825fa..53bd1ed1228a 100644
@@ -6,7 +6,7 @@ nf_conntrack-y	:= nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_exp
 		   nf_conntrack_proto_icmp.o \
 		   nf_conntrack_extend.o nf_conntrack_acct.o nf_conntrack_seqadj.o
 
-nf_conntrack-$(CONFIG_IPV6) += nf_conntrack_proto_icmpv6.o
+nf_conntrack-$(subst m,y,$(CONFIG_IPV6)) += nf_conntrack_proto_icmpv6.o
 nf_conntrack-$(CONFIG_NF_CONNTRACK_TIMEOUT) += nf_conntrack_timeout.o
 nf_conntrack-$(CONFIG_NF_CONNTRACK_TIMESTAMP) += nf_conntrack_timestamp.o
 nf_conntrack-$(CONFIG_NF_CONNTRACK_EVENTS) += nf_conntrack_ecache.o
Signature · 1 line
2.16.4
#2 lore raw
In reply to Florian Westphal
I love your patch! Yet something to improve:

Hi Florian,

I love your patch! Yet something to improve:

[auto build test ERROR on nf-next/master]

url:    https://github.com/0day-ci/linux/commits/Florian-Westphal/ipv6-remove-dependency-of-nf_defrag_ipv6-on-ipv6-module/20180713-064909
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master
config: x86_64-fedora-25 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

In file included from include/linux/kernel.h:10:0,

                    from include/linux/list.h:9,
                    from include/linux/random.h:10,
                    from include/linux/net.h:22,
                    from net/ieee802154/6lowpan/reassembly.c:17:
   net/ieee802154/6lowpan/reassembly.c: In function 'lowpan_frag_expire':
>> include/linux/kernel.h:964:51: error: dereferencing pointer to incomplete type 'struct frag_queue'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
                                                      ^
   include/linux/compiler.h:316:19: note: in definition of macro '__compiletime_assert'
      bool __cond = !(condition);    \
                      ^~~~~~~~~
   include/linux/compiler.h:339:2: note: in expansion of macro '_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:45:37: note: in expansion of macro 'compiletime_assert'
    #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                        ^~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:964:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
     ^~~~~~~~~~~~~~~~
   include/linux/kernel.h:964:20: note: in expansion of macro '__same_type'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
                       ^~~~~~~~~~~
>> net/ieee802154/6lowpan/reassembly.c:57:7: note: in expansion of macro 'container_of'
     fq = container_of(frag, struct frag_queue, q);
          ^~~~~~~~~~~~
   In file included from include/linux/compiler_types.h:58:0,
                    from <command-line>:0:
>> include/linux/compiler-gcc.h:170:2: error: invalid use of undefined type 'struct frag_queue'
     __builtin_offsetof(a, b)
     ^
   include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:967:21: note: in expansion of macro 'offsetof'
     ((type *)(__mptr - offsetof(type, member))); })
                        ^~~~~~~~
>> net/ieee802154/6lowpan/reassembly.c:57:7: note: in expansion of macro 'container_of'
     fq = container_of(frag, struct frag_queue, q);
          ^~~~~~~~~~~~
   net/ieee802154/6lowpan/reassembly.c: In function 'lowpan_net_frag_init':
>> net/ieee802154/6lowpan/reassembly.c:611:30: error: invalid application of 'sizeof' to incomplete type 'struct frag_queue'
     lowpan_frags.qsize = sizeof(struct frag_queue);
                                 ^~~~~~
--
   In file included from include/linux/kernel.h:10:0,
                    from include/linux/list.h:9,
                    from include/linux/random.h:10,
                    from include/linux/net.h:22,
                    from net/ieee802154//6lowpan/reassembly.c:17:
   net/ieee802154//6lowpan/reassembly.c: In function 'lowpan_frag_expire':
>> include/linux/kernel.h:964:51: error: dereferencing pointer to incomplete type 'struct frag_queue'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
                                                      ^
   include/linux/compiler.h:316:19: note: in definition of macro '__compiletime_assert'
      bool __cond = !(condition);    \
                      ^~~~~~~~~
   include/linux/compiler.h:339:2: note: in expansion of macro '_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:45:37: note: in expansion of macro 'compiletime_assert'
    #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                        ^~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:964:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
     ^~~~~~~~~~~~~~~~
   include/linux/kernel.h:964:20: note: in expansion of macro '__same_type'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
                       ^~~~~~~~~~~
   net/ieee802154//6lowpan/reassembly.c:57:7: note: in expansion of macro 'container_of'
     fq = container_of(frag, struct frag_queue, q);
          ^~~~~~~~~~~~
   In file included from include/linux/compiler_types.h:58:0,
                    from <command-line>:0:
>> include/linux/compiler-gcc.h:170:2: error: invalid use of undefined type 'struct frag_queue'
     __builtin_offsetof(a, b)
     ^
   include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:967:21: note: in expansion of macro 'offsetof'
     ((type *)(__mptr - offsetof(type, member))); })
                        ^~~~~~~~
   net/ieee802154//6lowpan/reassembly.c:57:7: note: in expansion of macro 'container_of'
     fq = container_of(frag, struct frag_queue, q);
          ^~~~~~~~~~~~
   net/ieee802154//6lowpan/reassembly.c: In function 'lowpan_net_frag_init':
   net/ieee802154//6lowpan/reassembly.c:611:30: error: invalid application of 'sizeof' to incomplete type 'struct frag_queue'
     lowpan_frags.qsize = sizeof(struct frag_queue);
                                 ^~~~~~

vim +964 include/linux/kernel.h

cf14f27f Alexei Starovoitov 2018-03-28  954  
^1da177e Linus Torvalds     2005-04-16  955  /**
^1da177e Linus Torvalds     2005-04-16  956   * container_of - cast a member of a structure out to the containing structure
^1da177e Linus Torvalds     2005-04-16  957   * @ptr:	the pointer to the member.
^1da177e Linus Torvalds     2005-04-16  958   * @type:	the type of the container struct this is embedded in.
^1da177e Linus Torvalds     2005-04-16  959   * @member:	the name of the member within the struct.
^1da177e Linus Torvalds     2005-04-16  960   *
^1da177e Linus Torvalds     2005-04-16  961   */
^1da177e Linus Torvalds     2005-04-16  962  #define container_of(ptr, type, member) ({				\
c7acec71 Ian Abbott         2017-07-12  963  	void *__mptr = (void *)(ptr);					\
c7acec71 Ian Abbott         2017-07-12 @964  	BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&	\
c7acec71 Ian Abbott         2017-07-12  965  			 !__same_type(*(ptr), void),			\
c7acec71 Ian Abbott         2017-07-12  966  			 "pointer type mismatch in container_of()");	\
c7acec71 Ian Abbott         2017-07-12  967  	((type *)(__mptr - offsetof(type, member))); })
^1da177e Linus Torvalds     2005-04-16  968  

:::::: The code at line 964 was first introduced by commit
:::::: c7acec713d14c6ce8a20154f9dfda258d6bcad3b kernel.h: handle pointers to arrays better in container_of()

:::::: TO: Ian Abbott <[email protected]>
:::::: CC: Linus Torvalds <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw
In reply to Florian Westphal
I love your patch! Perhaps something to improve:

Hi Florian,

I love your patch! Perhaps something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Florian-Westphal/ipv6-remove-dependency-of-nf_defrag_ipv6-on-ipv6-module/20180713-064909
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__

sparse warnings: (new ones prefixed by >>)

>> net/ieee802154/6lowpan/reassembly.c:57:14: sparse: unknown member
>> net/ieee802154/6lowpan/reassembly.c:57:14: sparse: cast from unknown type
   net/ieee802154/6lowpan/reassembly.c:58:15: sparse: using member 'q' in incomplete struct frag_queue
   net/ieee802154/6lowpan/reassembly.c:58:15: sparse: cast from unknown type
   net/ieee802154/6lowpan/reassembly.c:60:22: sparse: using member 'q' in incomplete struct frag_queue
   net/ieee802154/6lowpan/reassembly.c:62:15: sparse: using member 'q' in incomplete struct frag_queue
   net/ieee802154/6lowpan/reassembly.c:65:27: sparse: using member 'q' in incomplete struct frag_queue
   net/ieee802154/6lowpan/reassembly.c:67:24: sparse: using member 'q' in incomplete struct frag_queue
   net/ieee802154/6lowpan/reassembly.c:68:26: sparse: using member 'q' in incomplete struct frag_queue
>> net/ieee802154/6lowpan/reassembly.c:57:14: sparse: unknown expression (30 46)
   net/ieee802154/6lowpan/reassembly.c:58:15: sparse: unknown expression (8 46)
>> net/ieee802154/6lowpan/reassembly.c:60:18: sparse: call with no type!
   net/ieee802154/6lowpan/reassembly.c:62:18: sparse: unknown expression (8 46)
   net/ieee802154/6lowpan/reassembly.c:65:23: sparse: call with no type!
   net/ieee802154/6lowpan/reassembly.c:67:20: sparse: call with no type!
   net/ieee802154/6lowpan/reassembly.c:68:22: sparse: call with no type!
   In file included from include/linux/kernel.h:10:0,
                    from include/linux/list.h:9,
                    from include/linux/random.h:10,
                    from include/linux/net.h:22,
                    from net/ieee802154/6lowpan/reassembly.c:17:
   net/ieee802154/6lowpan/reassembly.c: In function 'lowpan_frag_expire':
   include/linux/kernel.h:964:51: error: dereferencing pointer to incomplete type 'struct frag_queue'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && 25-                                                   ^
   include/linux/compiler.h:316:19: note: in definition of macro '__compiletime_assert'
      bool __cond = !(condition);    28-                   ^~~~~~~~~
   include/linux/compiler.h:339:2: note: in expansion of macro '_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:45:37: note: in expansion of macro 'compiletime_assert'
    #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                        ^~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:964:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && 37-  ^~~~~~~~~~~~~~~~
   include/linux/kernel.h:964:20: note: in expansion of macro '__same_type'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && 40-                    ^~~~~~~~~~~
   net/ieee802154/6lowpan/reassembly.c:57:7: note: in expansion of macro 'container_of'
     fq = container_of(frag, struct frag_queue, q);
          ^~~~~~~~~~~~
   In file included from include/linux/compiler_types.h:58:0,
                    from <command-line>:0:
   include/linux/compiler-gcc.h:170:2: error: invalid use of undefined type 'struct frag_queue'
     __builtin_offsetof(a, b)
     ^
   include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:967:21: note: in expansion of macro 'offsetof'
     ((type *)(__mptr - offsetof(type, member))); })
                        ^~~~~~~~
   net/ieee802154/6lowpan/reassembly.c:57:7: note: in expansion of macro 'container_of'
     fq = container_of(frag, struct frag_queue, q);
          ^~~~~~~~~~~~
   net/ieee802154/6lowpan/reassembly.c: In function 'lowpan_net_frag_init':
   net/ieee802154/6lowpan/reassembly.c:611:30: error: invalid application of 'sizeof' to incomplete type 'struct frag_queue'
     lowpan_frags.qsize = sizeof(struct frag_queue);
                                 ^~~~~~

vim +57 net/ieee802154/6lowpan/reassembly.c

7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  50  
78802011f net/ieee802154/6lowpan/reassembly.c Kees Cook           2017-10-16  51  static void lowpan_frag_expire(struct timer_list *t)
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  52  {
78802011f net/ieee802154/6lowpan/reassembly.c Kees Cook           2017-10-16  53  	struct inet_frag_queue *frag = from_timer(frag, t, timer);
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  54  	struct frag_queue *fq;
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  55  	struct net *net;
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  56  
78802011f net/ieee802154/6lowpan/reassembly.c Kees Cook           2017-10-16 @57  	fq = container_of(frag, struct frag_queue, q);
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28 @58  	net = container_of(fq->q.net, struct net, ieee802154_lowpan.frags);
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  59  
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13 @60  	spin_lock(&fq->q.lock);
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13  61  
06aa8b8a0 net/ieee802154/reassembly.c         Nikolay Aleksandrov 2014-08-01  62  	if (fq->q.flags & INET_FRAG_COMPLETE)
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13  63  		goto out;
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13  64  
093ba7291 net/ieee802154/6lowpan/reassembly.c Eric Dumazet        2018-03-31  65  	inet_frag_kill(&fq->q);
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13  66  out:
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13  67  	spin_unlock(&fq->q.lock);
093ba7291 net/ieee802154/6lowpan/reassembly.c Eric Dumazet        2018-03-31  68  	inet_frag_put(&fq->q);
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  69  }
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  70  

:::::: The code at line 57 was first introduced by commit
:::::: 78802011fbe34331bdef6f2dfb1634011f0e4c32 inet: frags: Convert timers to use timer_setup()

:::::: TO: Kees Cook <[email protected]>
:::::: CC: David S. Miller <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#4 lore raw
In reply to Florian Westphal
I love your patch! Perhaps something to improve:

Hi Florian,

I love your patch! Perhaps something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Florian-Westphal/ipv6-remove-dependency-of-nf_defrag_ipv6-on-ipv6-module/20180713-064909
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__

sparse warnings: (new ones prefixed by >>)

>> net/ieee802154/6lowpan/reassembly.c:57:14: sparse: unknown member
>> net/ieee802154/6lowpan/reassembly.c:57:14: sparse: cast from unknown type
   net/ieee802154/6lowpan/reassembly.c:58:15: sparse: using member 'q' in incomplete struct frag_queue
   net/ieee802154/6lowpan/reassembly.c:58:15: sparse: cast from unknown type
   net/ieee802154/6lowpan/reassembly.c:60:22: sparse: using member 'q' in incomplete struct frag_queue
   net/ieee802154/6lowpan/reassembly.c:62:15: sparse: using member 'q' in incomplete struct frag_queue
   net/ieee802154/6lowpan/reassembly.c:65:27: sparse: using member 'q' in incomplete struct frag_queue
   net/ieee802154/6lowpan/reassembly.c:67:24: sparse: using member 'q' in incomplete struct frag_queue
   net/ieee802154/6lowpan/reassembly.c:68:26: sparse: using member 'q' in incomplete struct frag_queue
>> net/ieee802154/6lowpan/reassembly.c:57:14: sparse: unknown expression (30 46)
   net/ieee802154/6lowpan/reassembly.c:58:15: sparse: unknown expression (8 46)
>> net/ieee802154/6lowpan/reassembly.c:60:18: sparse: call with no type!
   net/ieee802154/6lowpan/reassembly.c:62:18: sparse: unknown expression (8 46)
   net/ieee802154/6lowpan/reassembly.c:65:23: sparse: call with no type!
   net/ieee802154/6lowpan/reassembly.c:67:20: sparse: call with no type!
   net/ieee802154/6lowpan/reassembly.c:68:22: sparse: call with no type!
   In file included from include/linux/kernel.h:10:0,
                    from include/linux/list.h:9,
                    from include/linux/random.h:10,
                    from include/linux/net.h:22,
                    from net/ieee802154/6lowpan/reassembly.c:17:
   net/ieee802154/6lowpan/reassembly.c: In function 'lowpan_frag_expire':
   include/linux/kernel.h:964:51: error: dereferencing pointer to incomplete type 'struct frag_queue'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && 25-                                                   ^
   include/linux/compiler.h:316:19: note: in definition of macro '__compiletime_assert'
      bool __cond = !(condition);    28-                   ^~~~~~~~~
   include/linux/compiler.h:339:2: note: in expansion of macro '_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:45:37: note: in expansion of macro 'compiletime_assert'
    #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                        ^~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:964:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && 37-  ^~~~~~~~~~~~~~~~
   include/linux/kernel.h:964:20: note: in expansion of macro '__same_type'
     BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && 40-                    ^~~~~~~~~~~
   net/ieee802154/6lowpan/reassembly.c:57:7: note: in expansion of macro 'container_of'
     fq = container_of(frag, struct frag_queue, q);
          ^~~~~~~~~~~~
   In file included from include/linux/compiler_types.h:58:0,
                    from <command-line>:0:
   include/linux/compiler-gcc.h:170:2: error: invalid use of undefined type 'struct frag_queue'
     __builtin_offsetof(a, b)
     ^
   include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:967:21: note: in expansion of macro 'offsetof'
     ((type *)(__mptr - offsetof(type, member))); })
                        ^~~~~~~~
   net/ieee802154/6lowpan/reassembly.c:57:7: note: in expansion of macro 'container_of'
     fq = container_of(frag, struct frag_queue, q);
          ^~~~~~~~~~~~
   net/ieee802154/6lowpan/reassembly.c: In function 'lowpan_net_frag_init':
   net/ieee802154/6lowpan/reassembly.c:611:30: error: invalid application of 'sizeof' to incomplete type 'struct frag_queue'
     lowpan_frags.qsize = sizeof(struct frag_queue);
                                 ^~~~~~

vim +57 net/ieee802154/6lowpan/reassembly.c

7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  50  
78802011f net/ieee802154/6lowpan/reassembly.c Kees Cook           2017-10-16  51  static void lowpan_frag_expire(struct timer_list *t)
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  52  {
78802011f net/ieee802154/6lowpan/reassembly.c Kees Cook           2017-10-16  53  	struct inet_frag_queue *frag = from_timer(frag, t, timer);
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  54  	struct frag_queue *fq;
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  55  	struct net *net;
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  56  
78802011f net/ieee802154/6lowpan/reassembly.c Kees Cook           2017-10-16 @57  	fq = container_of(frag, struct frag_queue, q);
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28 @58  	net = container_of(fq->q.net, struct net, ieee802154_lowpan.frags);
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  59  
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13 @60  	spin_lock(&fq->q.lock);
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13  61  
06aa8b8a0 net/ieee802154/reassembly.c         Nikolay Aleksandrov 2014-08-01  62  	if (fq->q.flags & INET_FRAG_COMPLETE)
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13  63  		goto out;
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13  64  
093ba7291 net/ieee802154/6lowpan/reassembly.c Eric Dumazet        2018-03-31  65  	inet_frag_kill(&fq->q);
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13  66  out:
177943260 net/ieee802154/reassembly.c         Florian Westphal    2014-03-13  67  	spin_unlock(&fq->q.lock);
093ba7291 net/ieee802154/6lowpan/reassembly.c Eric Dumazet        2018-03-31  68  	inet_frag_put(&fq->q);
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  69  }
7240cdec6 net/ieee802154/reassembly.c         Alexander Aring     2014-02-28  70  

:::::: The code at line 57 was first introduced by commit
:::::: 78802011fbe34331bdef6f2dfb1634011f0e4c32 inet: frags: Convert timers to use timer_setup()

:::::: TO: Kees Cook <[email protected]>
:::::: CC: David S. Miller <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation