Message ID | 20180712143547.2194-1-fw@strlen.de |
---|---|
State | Changes Requested |
Delegated to: | Pablo Neira |
Headers | show |
Series | [nf-next,1/2] ipv6: remove dependency of nf_defrag_ipv6 on ipv6 module | expand |
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 <abbotti@mev.co.uk> :::::: CC: Linus Torvalds <torvalds@linux-foundation.org> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
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 <keescook@chromium.org> :::::: CC: David S. Miller <davem@davemloft.net> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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 <keescook@chromium.org> :::::: CC: David S. Miller <davem@davemloft.net> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" 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/net/ipv6.h b/include/net/ipv6.h index 16475c269749..0012c0a6c86e 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -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 diff --git a/include/net/ipv6_frag.h b/include/net/ipv6_frag.h new file mode 100644 index 000000000000..ff3be4ca9471 --- /dev/null +++ b/include/net/ipv6_frag.h @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _IPV6_FRAG_H +#define _IPV6_FRAG_H +#include <linux/kernel.h> +#include <net/addrconf.h> +#include <net/ipv6.h> +#include <net/inet_frag.h> + +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, +}; + +/* + * Equivalent of ipv4 struct ip + */ +struct frag_queue { + struct inet_frag_queue q; + + int iif; + __u16 nhoffset; + u8 ecn; +}; + +static inline void ip6frag_init(struct inet_frag_queue *q, const void *a) +{ + struct frag_queue *fq = container_of(q, struct frag_queue, q); + const struct frag_v6_compare_key *key = a; + + q->key.v6 = *key; + fq->ecn = 0; +} + +static inline u32 ip6frag_key_hashfn(const void *data, u32 len, u32 seed) +{ + return jhash2(data, + sizeof(struct frag_v6_compare_key) / sizeof(u32), seed); +} + +static inline u32 ip6frag_obj_hashfn(const void *data, u32 len, u32 seed) +{ + const struct inet_frag_queue *fq = data; + + return jhash2((const u32 *)&fq->key.v6, + sizeof(struct frag_v6_compare_key) / sizeof(u32), seed); +} + +static inline int +ip6frag_obj_cmpfn(struct rhashtable_compare_arg *arg, const void *ptr) +{ + const struct frag_v6_compare_key *key = arg->key; + const struct inet_frag_queue *fq = ptr; + + return !!memcmp(&fq->key, key, sizeof(*key)); +} + +static inline void +ip6frag_expire_frag_queue(struct net *net, struct frag_queue *fq) +{ + struct net_device *dev = NULL; + struct sk_buff *head; + + rcu_read_lock(); + spin_lock(&fq->q.lock); + + if (fq->q.flags & INET_FRAG_COMPLETE) + goto out; + + inet_frag_kill(&fq->q); + + dev = dev_get_by_index_rcu(net, fq->iif); + if (!dev) + goto out; + + __IP6_INC_STATS(net, __in6_dev_get(dev), IPSTATS_MIB_REASMFAILS); + __IP6_INC_STATS(net, __in6_dev_get(dev), IPSTATS_MIB_REASMTIMEOUT); + + /* Don't send error if the first segment did not arrive. */ + head = fq->q.fragments; + if (!(fq->q.flags & INET_FRAG_FIRST_IN) || !head) + goto out; + + head->dev = dev; + skb_get(head); + spin_unlock(&fq->q.lock); + + icmpv6_send(head, ICMPV6_TIME_EXCEED, ICMPV6_EXC_FRAGTIME, 0); + kfree_skb(head); + goto out_rcu_unlock; + +out: + spin_unlock(&fq->q.lock); +out_rcu_unlock: + rcu_read_unlock(); + inet_frag_put(&fq->q); +} +#endif diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 5e0332014c17..a44156b54ec9 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -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; diff --git a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c index e631be25337e..72dd3e202375 100644 --- a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c +++ b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c @@ -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> diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index b939b94e7e91..6edd2ac8ae4b 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -57,7 +57,7 @@ #include <net/rawv6.h> #include <net/ndisc.h> #include <net/addrconf.h> -#include <net/inet_frag.h> +#include <net/ipv6_frag.h> #include <net/inet_ecn.h> static const char ip6_frag_cache_name[] = "ip6-frags"; @@ -72,61 +72,6 @@ static struct inet_frags ip6_frags; static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, struct net_device *dev); -void ip6_frag_init(struct inet_frag_queue *q, const void *a) -{ - struct frag_queue *fq = container_of(q, struct frag_queue, q); - const struct frag_v6_compare_key *key = a; - - q->key.v6 = *key; - fq->ecn = 0; -} -EXPORT_SYMBOL(ip6_frag_init); - -void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq) -{ - struct net_device *dev = NULL; - struct sk_buff *head; - - rcu_read_lock(); - spin_lock(&fq->q.lock); - - if (fq->q.flags & INET_FRAG_COMPLETE) - goto out; - - inet_frag_kill(&fq->q); - - dev = dev_get_by_index_rcu(net, fq->iif); - if (!dev) - goto out; - - __IP6_INC_STATS(net, __in6_dev_get(dev), IPSTATS_MIB_REASMFAILS); - __IP6_INC_STATS(net, __in6_dev_get(dev), IPSTATS_MIB_REASMTIMEOUT); - - /* Don't send error if the first segment did not arrive. */ - head = fq->q.fragments; - if (!(fq->q.flags & INET_FRAG_FIRST_IN) || !head) - goto out; - - /* But use as source device on which LAST ARRIVED - * segment was received. And do not use fq->dev - * pointer directly, device might already disappeared. - */ - head->dev = dev; - skb_get(head); - spin_unlock(&fq->q.lock); - - icmpv6_send(head, ICMPV6_TIME_EXCEED, ICMPV6_EXC_FRAGTIME, 0); - kfree_skb(head); - goto out_rcu_unlock; - -out: - spin_unlock(&fq->q.lock); -out_rcu_unlock: - rcu_read_unlock(); - inet_frag_put(&fq->q); -} -EXPORT_SYMBOL(ip6_expire_frag_queue); - static void ip6_frag_expire(struct timer_list *t) { struct inet_frag_queue *frag = from_timer(frag, t, timer); @@ -136,7 +81,7 @@ static void ip6_frag_expire(struct timer_list *t) fq = container_of(frag, struct frag_queue, q); net = container_of(fq->q.net, struct net, ipv6.frags); - ip6_expire_frag_queue(net, fq); + ip6frag_expire_frag_queue(net, fq); } static struct frag_queue * @@ -696,42 +641,19 @@ static struct pernet_operations ip6_frags_ops = { .exit = ipv6_frags_exit_net, }; -static u32 ip6_key_hashfn(const void *data, u32 len, u32 seed) -{ - return jhash2(data, - sizeof(struct frag_v6_compare_key) / sizeof(u32), seed); -} - -static u32 ip6_obj_hashfn(const void *data, u32 len, u32 seed) -{ - const struct inet_frag_queue *fq = data; - - return jhash2((const u32 *)&fq->key.v6, - sizeof(struct frag_v6_compare_key) / sizeof(u32), seed); -} - -static int ip6_obj_cmpfn(struct rhashtable_compare_arg *arg, const void *ptr) -{ - const struct frag_v6_compare_key *key = arg->key; - const struct inet_frag_queue *fq = ptr; - - return !!memcmp(&fq->key, key, sizeof(*key)); -} - -const struct rhashtable_params ip6_rhash_params = { +static const struct rhashtable_params ip6_rhash_params = { .head_offset = offsetof(struct inet_frag_queue, node), - .hashfn = ip6_key_hashfn, - .obj_hashfn = ip6_obj_hashfn, - .obj_cmpfn = ip6_obj_cmpfn, + .hashfn = ip6frag_key_hashfn, + .obj_hashfn = ip6frag_obj_hashfn, + .obj_cmpfn = ip6frag_obj_cmpfn, .automatic_shrinking = true, }; -EXPORT_SYMBOL(ip6_rhash_params); int __init ipv6_frag_init(void) { int ret; - ip6_frags.constructor = ip6_frag_init; + ip6_frags.constructor = ip6frag_init; ip6_frags.destructor = NULL; ip6_frags.qsize = sizeof(struct frag_queue); ip6_frags.frag_expire = ip6_frag_expire; diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index e05bd3e53f0f..3ede65344e4d 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c @@ -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>
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. Signed-off-by: Florian Westphal <fw@strlen.de> --- 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