diff mbox series

[net] net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX

Message ID 20231204195252.2004515-1-maze@google.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net, async
netdev/ynl success SINGLE THREAD; Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2973 this patch: 2973
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 1277 this patch: 1277
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes fail Problems with Fixes tag: 1
netdev/build_allmodconfig_warn success Errors and warnings before: 3204 this patch: 3204
netdev/checkpatch warning WARNING: Unknown commit id '60872d54d963', maybe rebased or not pulled?
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Maciej Żenczykowski Dec. 4, 2023, 7:52 p.m. UTC
Lorenzo points out that we effectively clear all unknown
flags from PIO when copying them to userspace in the netlink
RTM_NEWPREFIX notification.

We could fix this one at a time as new flags are defined,
or in one fell swoop - I choose the latter.

We could either define 6 new reserved flags (reserved1..6) and handle
them individually (and rename them as new flags are defined), or we
could simply copy the entire unmodified byte over - I choose the latter.

This unfortunately requires some anonymous union/struct magic,
so we add a static assert on the struct size for a little extra safety.

Cc: Shirley Ma <mashirle@us.ibm.com>
Cc: David Ahern <dsahern@kernel.org>
Cc: Lorenzo Colitti <lorenzo@google.com>
Fixes: 60872d54d963 ("[IPV6]: Add notification for MIB:ipv6Prefix events.")
Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 include/net/addrconf.h | 12 ++++++++++--
 include/net/if_inet6.h |  4 ----
 net/ipv6/addrconf.c    |  6 +-----
 3 files changed, 11 insertions(+), 11 deletions(-)

Comments

kernel test robot Dec. 5, 2023, 7:12 p.m. UTC | #1
Hi Maciej,

kernel test robot noticed the following build errors:

[auto build test ERROR on net/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Maciej-enczykowski/net-ipv6-support-reporting-otherwise-unknown-prefix-flags-in-RTM_NEWPREFIX/20231205-035333
base:   net/main
patch link:    https://lore.kernel.org/r/20231204195252.2004515-1-maze%40google.com
patch subject: [PATCH net] net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX
config: arm-rpc_defconfig (https://download.01.org/0day-ci/archive/20231206/202312060307.EaL1FRwu-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060307.EaL1FRwu-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312060307.EaL1FRwu-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/linux/container_of.h:5,
                    from include/linux/list.h:5,
                    from include/linux/module.h:12,
                    from fs/lockd/svc.c:16:
>> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                         ^~~~~~~~~~~~~~
   include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
      77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
         |                                  ^~~~~~~~~~~~~~~
   include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
      58 | static_assert(sizeof(struct prefix_info) == 32);
         | ^~~~~~~~~~~~~
--
   In file included from lib/vsprintf.c:21:
>> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                         ^~~~~~~~~~~~~~
   include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
      77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
         |                                  ^~~~~~~~~~~~~~~
   include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
      58 | static_assert(sizeof(struct prefix_info) == 32);
         | ^~~~~~~~~~~~~
   lib/vsprintf.c: In function 'va_format':
   lib/vsprintf.c:1683:9: warning: function 'va_format' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
    1683 |         buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va);
         |         ^~~
--
   In file included from include/linux/container_of.h:5,
                    from include/linux/list.h:5,
                    from include/linux/module.h:12,
                    from net/ipv4/route.c:63:
>> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                         ^~~~~~~~~~~~~~
   include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
      77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
         |                                  ^~~~~~~~~~~~~~~
   include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
      58 | static_assert(sizeof(struct prefix_info) == 32);
         | ^~~~~~~~~~~~~
   net/ipv4/route.c: In function 'ip_rt_send_redirect':
   net/ipv4/route.c:880:13: warning: variable 'log_martians' set but not used [-Wunused-but-set-variable]
     880 |         int log_martians;
         |             ^~~~~~~~~~~~
--
   In file included from include/linux/container_of.h:5,
                    from include/linux/list.h:5,
                    from include/linux/timer.h:5,
                    from include/linux/workqueue.h:9,
                    from include/linux/bpf.h:10,
                    from net/ipv6/ip6_fib.c:18:
>> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                         ^~~~~~~~~~~~~~
   include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
      77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
         |                                  ^~~~~~~~~~~~~~~
   include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
      58 | static_assert(sizeof(struct prefix_info) == 32);
         | ^~~~~~~~~~~~~
   net/ipv6/ip6_fib.c: In function 'fib6_add':
   net/ipv6/ip6_fib.c:1384:32: warning: variable 'pn' set but not used [-Wunused-but-set-variable]
    1384 |         struct fib6_node *fn, *pn = NULL;
         |                                ^~


vim +78 include/linux/build_bug.h

bc6245e5efd70c Ian Abbott       2017-07-10  60  
6bab69c65013be Rasmus Villemoes 2019-03-07  61  /**
6bab69c65013be Rasmus Villemoes 2019-03-07  62   * static_assert - check integer constant expression at build time
6bab69c65013be Rasmus Villemoes 2019-03-07  63   *
6bab69c65013be Rasmus Villemoes 2019-03-07  64   * static_assert() is a wrapper for the C11 _Static_assert, with a
6bab69c65013be Rasmus Villemoes 2019-03-07  65   * little macro magic to make the message optional (defaulting to the
6bab69c65013be Rasmus Villemoes 2019-03-07  66   * stringification of the tested expression).
6bab69c65013be Rasmus Villemoes 2019-03-07  67   *
6bab69c65013be Rasmus Villemoes 2019-03-07  68   * Contrary to BUILD_BUG_ON(), static_assert() can be used at global
6bab69c65013be Rasmus Villemoes 2019-03-07  69   * scope, but requires the expression to be an integer constant
6bab69c65013be Rasmus Villemoes 2019-03-07  70   * expression (i.e., it is not enough that __builtin_constant_p() is
6bab69c65013be Rasmus Villemoes 2019-03-07  71   * true for expr).
6bab69c65013be Rasmus Villemoes 2019-03-07  72   *
6bab69c65013be Rasmus Villemoes 2019-03-07  73   * Also note that BUILD_BUG_ON() fails the build if the condition is
6bab69c65013be Rasmus Villemoes 2019-03-07  74   * true, while static_assert() fails the build if the expression is
6bab69c65013be Rasmus Villemoes 2019-03-07  75   * false.
6bab69c65013be Rasmus Villemoes 2019-03-07  76   */
6bab69c65013be Rasmus Villemoes 2019-03-07  77  #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
6bab69c65013be Rasmus Villemoes 2019-03-07 @78  #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
6bab69c65013be Rasmus Villemoes 2019-03-07  79  
07a368b3f55a79 Maxim Levitsky   2022-10-25  80
David Ahern Dec. 6, 2023, 3:39 a.m. UTC | #2
On 12/4/23 12:52 PM, Maciej Żenczykowski wrote:
> Lorenzo points out that we effectively clear all unknown
> flags from PIO when copying them to userspace in the netlink
> RTM_NEWPREFIX notification.

The existing flags have been there since before git (2005) and no new
ones have been added. So, what is the problem with existing code?
conflicts with an out-of-tree patch?
Lorenzo Colitti Dec. 6, 2023, 4:19 a.m. UTC | #3
On Wed, Dec 6, 2023 at 12:39 PM David Ahern <dsahern@kernel.org> wrote:
> > Lorenzo points out that we effectively clear all unknown
> > flags from PIO when copying them to userspace in the netlink
> > RTM_NEWPREFIX notification.
>
> The existing flags have been there since before git (2005) and no new
> ones have been added. So, what is the problem with existing code?
> conflicts with an out-of-tree patch?

One thing that's incorrect today is that RTM_NEWPREFIX doesn't pass to
userspace the R flag added in RFC 6275 (2011).

Also, the 6man working group is in the process of defining another flag, P:

 https://datatracker.ietf.org/doc/html/draft-ietf-6man-pio-pflag

Of course, it's possible to change the kernel now to understand the R
flag, and then, if/when the P flag becomes an RFC, modify the kernel
again to  support that. But it seems better simply to copy the whole
field, so we don't have to change it again when other flags are added
in the future.
Maciej Żenczykowski Dec. 6, 2023, 11 a.m. UTC | #4
On Tue, Dec 5, 2023 at 11:12 AM kernel test robot <lkp@intel.com> wrote:
>
> Hi Maciej,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on net/main]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Maciej-enczykowski/net-ipv6-support-reporting-otherwise-unknown-prefix-flags-in-RTM_NEWPREFIX/20231205-035333
> base:   net/main
> patch link:    https://lore.kernel.org/r/20231204195252.2004515-1-maze%40google.com
> patch subject: [PATCH net] net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX
> config: arm-rpc_defconfig (https://download.01.org/0day-ci/archive/20231206/202312060307.EaL1FRwu-lkp@intel.com/config)
> compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060307.EaL1FRwu-lkp@intel.com/reproduce)

I followed these steps, and it built just fine...

maze@laptop:~/K$ git log -n2 --oneline
57cde6e635d5 (HEAD) net: ipv6: support reporting otherwise unknown
prefix flags in RTM_NEWPREFIX
7037d95a047c (net/main) r8152: add vendor/device ID pair for ASUS USB-C2500

maze@laptop:~/K$ file -sL build_dir/vmlinux
build_dir/vmlinux: ELF 32-bit LSB executable, ARM, EABI5 version 1
(SYSV), statically linked,
BuildID[sha1]=ae5a34fc35b264d707b3f16e920282b96c080508, not stripped

>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202312060307.EaL1FRwu-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>    In file included from include/linux/container_of.h:5,
>                     from include/linux/list.h:5,
>                     from include/linux/module.h:12,
>                     from fs/lockd/svc.c:16:
> >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
>       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
>          |                                         ^~~~~~~~~~~~~~
>    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
>       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
>          |                                  ^~~~~~~~~~~~~~~
>    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
>       58 | static_assert(sizeof(struct prefix_info) == 32);
>          | ^~~~~~~~~~~~~
> --
>    In file included from lib/vsprintf.c:21:
> >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
>       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
>          |                                         ^~~~~~~~~~~~~~
>    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
>       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
>          |                                  ^~~~~~~~~~~~~~~
>    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
>       58 | static_assert(sizeof(struct prefix_info) == 32);
>          | ^~~~~~~~~~~~~
>    lib/vsprintf.c: In function 'va_format':
>    lib/vsprintf.c:1683:9: warning: function 'va_format' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
>     1683 |         buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va);
>          |         ^~~
> --
>    In file included from include/linux/container_of.h:5,
>                     from include/linux/list.h:5,
>                     from include/linux/module.h:12,
>                     from net/ipv4/route.c:63:
> >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
>       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
>          |                                         ^~~~~~~~~~~~~~
>    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
>       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
>          |                                  ^~~~~~~~~~~~~~~
>    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
>       58 | static_assert(sizeof(struct prefix_info) == 32);
>          | ^~~~~~~~~~~~~
>    net/ipv4/route.c: In function 'ip_rt_send_redirect':
>    net/ipv4/route.c:880:13: warning: variable 'log_martians' set but not used [-Wunused-but-set-variable]
>      880 |         int log_martians;
>          |             ^~~~~~~~~~~~
> --
>    In file included from include/linux/container_of.h:5,
>                     from include/linux/list.h:5,
>                     from include/linux/timer.h:5,
>                     from include/linux/workqueue.h:9,
>                     from include/linux/bpf.h:10,
>                     from net/ipv6/ip6_fib.c:18:
> >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
>       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
>          |                                         ^~~~~~~~~~~~~~
>    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
>       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
>          |                                  ^~~~~~~~~~~~~~~
>    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
>       58 | static_assert(sizeof(struct prefix_info) == 32);
>          | ^~~~~~~~~~~~~
>    net/ipv6/ip6_fib.c: In function 'fib6_add':
>    net/ipv6/ip6_fib.c:1384:32: warning: variable 'pn' set but not used [-Wunused-but-set-variable]
>     1384 |         struct fib6_node *fn, *pn = NULL;
>          |                                ^~
>
>
> vim +78 include/linux/build_bug.h
>
> bc6245e5efd70c Ian Abbott       2017-07-10  60
> 6bab69c65013be Rasmus Villemoes 2019-03-07  61  /**
> 6bab69c65013be Rasmus Villemoes 2019-03-07  62   * static_assert - check integer constant expression at build time
> 6bab69c65013be Rasmus Villemoes 2019-03-07  63   *
> 6bab69c65013be Rasmus Villemoes 2019-03-07  64   * static_assert() is a wrapper for the C11 _Static_assert, with a
> 6bab69c65013be Rasmus Villemoes 2019-03-07  65   * little macro magic to make the message optional (defaulting to the
> 6bab69c65013be Rasmus Villemoes 2019-03-07  66   * stringification of the tested expression).
> 6bab69c65013be Rasmus Villemoes 2019-03-07  67   *
> 6bab69c65013be Rasmus Villemoes 2019-03-07  68   * Contrary to BUILD_BUG_ON(), static_assert() can be used at global
> 6bab69c65013be Rasmus Villemoes 2019-03-07  69   * scope, but requires the expression to be an integer constant
> 6bab69c65013be Rasmus Villemoes 2019-03-07  70   * expression (i.e., it is not enough that __builtin_constant_p() is
> 6bab69c65013be Rasmus Villemoes 2019-03-07  71   * true for expr).
> 6bab69c65013be Rasmus Villemoes 2019-03-07  72   *
> 6bab69c65013be Rasmus Villemoes 2019-03-07  73   * Also note that BUILD_BUG_ON() fails the build if the condition is
> 6bab69c65013be Rasmus Villemoes 2019-03-07  74   * true, while static_assert() fails the build if the expression is
> 6bab69c65013be Rasmus Villemoes 2019-03-07  75   * false.
> 6bab69c65013be Rasmus Villemoes 2019-03-07  76   */
> 6bab69c65013be Rasmus Villemoes 2019-03-07  77  #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> 6bab69c65013be Rasmus Villemoes 2019-03-07 @78  #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> 6bab69c65013be Rasmus Villemoes 2019-03-07  79
> 07a368b3f55a79 Maxim Levitsky   2022-10-25  80
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wikiMaciej Żenczykowski, Kernel Networking Developer @ Google
Maciej Żenczykowski Dec. 6, 2023, 11:05 a.m. UTC | #5
On Wed, Dec 6, 2023 at 3:00 AM Maciej Żenczykowski <maze@google.com> wrote:
>
> On Tue, Dec 5, 2023 at 11:12 AM kernel test robot <lkp@intel.com> wrote:
> >
> > Hi Maciej,
> >
> > kernel test robot noticed the following build errors:
> >
> > [auto build test ERROR on net/main]
> >
> > url:    https://github.com/intel-lab-lkp/linux/commits/Maciej-enczykowski/net-ipv6-support-reporting-otherwise-unknown-prefix-flags-in-RTM_NEWPREFIX/20231205-035333
> > base:   net/main
> > patch link:    https://lore.kernel.org/r/20231204195252.2004515-1-maze%40google.com
> > patch subject: [PATCH net] net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX
> > config: arm-rpc_defconfig (https://download.01.org/0day-ci/archive/20231206/202312060307.EaL1FRwu-lkp@intel.com/config)
> > compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060307.EaL1FRwu-lkp@intel.com/reproduce)
>
> I followed these steps, and it built just fine...
>
> maze@laptop:~/K$ git log -n2 --oneline
> 57cde6e635d5 (HEAD) net: ipv6: support reporting otherwise unknown
> prefix flags in RTM_NEWPREFIX
> 7037d95a047c (net/main) r8152: add vendor/device ID pair for ASUS USB-C2500
>
> maze@laptop:~/K$ file -sL build_dir/vmlinux
> build_dir/vmlinux: ELF 32-bit LSB executable, ARM, EABI5 version 1
> (SYSV), statically linked,
> BuildID[sha1]=ae5a34fc35b264d707b3f16e920282b96c080508, not stripped

ah, the reproduction steps don't actually fetch the .config

> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202312060307.EaL1FRwu-lkp@intel.com/
> >
> > All errors (new ones prefixed by >>):
> >
> >    In file included from include/linux/container_of.h:5,
> >                     from include/linux/list.h:5,
> >                     from include/linux/module.h:12,
> >                     from fs/lockd/svc.c:16:
> > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> >          |                                         ^~~~~~~~~~~~~~
> >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> >          |                                  ^~~~~~~~~~~~~~~
> >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> >       58 | static_assert(sizeof(struct prefix_info) == 32);
> >          | ^~~~~~~~~~~~~
> > --
> >    In file included from lib/vsprintf.c:21:
> > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> >          |                                         ^~~~~~~~~~~~~~
> >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> >          |                                  ^~~~~~~~~~~~~~~
> >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> >       58 | static_assert(sizeof(struct prefix_info) == 32);
> >          | ^~~~~~~~~~~~~
> >    lib/vsprintf.c: In function 'va_format':
> >    lib/vsprintf.c:1683:9: warning: function 'va_format' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> >     1683 |         buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va);
> >          |         ^~~
> > --
> >    In file included from include/linux/container_of.h:5,
> >                     from include/linux/list.h:5,
> >                     from include/linux/module.h:12,
> >                     from net/ipv4/route.c:63:
> > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> >          |                                         ^~~~~~~~~~~~~~
> >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> >          |                                  ^~~~~~~~~~~~~~~
> >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> >       58 | static_assert(sizeof(struct prefix_info) == 32);
> >          | ^~~~~~~~~~~~~
> >    net/ipv4/route.c: In function 'ip_rt_send_redirect':
> >    net/ipv4/route.c:880:13: warning: variable 'log_martians' set but not used [-Wunused-but-set-variable]
> >      880 |         int log_martians;
> >          |             ^~~~~~~~~~~~
> > --
> >    In file included from include/linux/container_of.h:5,
> >                     from include/linux/list.h:5,
> >                     from include/linux/timer.h:5,
> >                     from include/linux/workqueue.h:9,
> >                     from include/linux/bpf.h:10,
> >                     from net/ipv6/ip6_fib.c:18:
> > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> >          |                                         ^~~~~~~~~~~~~~
> >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> >          |                                  ^~~~~~~~~~~~~~~
> >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> >       58 | static_assert(sizeof(struct prefix_info) == 32);
> >          | ^~~~~~~~~~~~~
> >    net/ipv6/ip6_fib.c: In function 'fib6_add':
> >    net/ipv6/ip6_fib.c:1384:32: warning: variable 'pn' set but not used [-Wunused-but-set-variable]
> >     1384 |         struct fib6_node *fn, *pn = NULL;
> >          |                                ^~
> >
> >
> > vim +78 include/linux/build_bug.h
> >
> > bc6245e5efd70c Ian Abbott       2017-07-10  60
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  61  /**
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  62   * static_assert - check integer constant expression at build time
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  63   *
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  64   * static_assert() is a wrapper for the C11 _Static_assert, with a
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  65   * little macro magic to make the message optional (defaulting to the
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  66   * stringification of the tested expression).
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  67   *
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  68   * Contrary to BUILD_BUG_ON(), static_assert() can be used at global
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  69   * scope, but requires the expression to be an integer constant
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  70   * expression (i.e., it is not enough that __builtin_constant_p() is
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  71   * true for expr).
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  72   *
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  73   * Also note that BUILD_BUG_ON() fails the build if the condition is
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  74   * true, while static_assert() fails the build if the expression is
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  75   * false.
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  76   */
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  77  #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> > 6bab69c65013be Rasmus Villemoes 2019-03-07 @78  #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > 6bab69c65013be Rasmus Villemoes 2019-03-07  79
> > 07a368b3f55a79 Maxim Levitsky   2022-10-25  80
> >
> > --
> > 0-DAY CI Kernel Test Service
> > https://github.com/intel/lkp-tests/wikiMaciej Żenczykowski, Kernel Networking Developer @ GoogleMaciej Żenczykowski, Kernel Networking Developer @ Google
Maciej Żenczykowski Dec. 6, 2023, 11:13 a.m. UTC | #6
On Wed, Dec 6, 2023 at 3:05 AM Maciej Żenczykowski <maze@google.com> wrote:
>
> On Wed, Dec 6, 2023 at 3:00 AM Maciej Żenczykowski <maze@google.com> wrote:
> >
> > On Tue, Dec 5, 2023 at 11:12 AM kernel test robot <lkp@intel.com> wrote:
> > >
> > > Hi Maciej,
> > >
> > > kernel test robot noticed the following build errors:
> > >
> > > [auto build test ERROR on net/main]
> > >
> > > url:    https://github.com/intel-lab-lkp/linux/commits/Maciej-enczykowski/net-ipv6-support-reporting-otherwise-unknown-prefix-flags-in-RTM_NEWPREFIX/20231205-035333
> > > base:   net/main
> > > patch link:    https://lore.kernel.org/r/20231204195252.2004515-1-maze%40google.com
> > > patch subject: [PATCH net] net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX
> > > config: arm-rpc_defconfig (https://download.01.org/0day-ci/archive/20231206/202312060307.EaL1FRwu-lkp@intel.com/config)
> > > compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
> > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060307.EaL1FRwu-lkp@intel.com/reproduce)
> >
> > I followed these steps, and it built just fine...
> >
> > maze@laptop:~/K$ git log -n2 --oneline
> > 57cde6e635d5 (HEAD) net: ipv6: support reporting otherwise unknown
> > prefix flags in RTM_NEWPREFIX
> > 7037d95a047c (net/main) r8152: add vendor/device ID pair for ASUS USB-C2500
> >
> > maze@laptop:~/K$ file -sL build_dir/vmlinux
> > build_dir/vmlinux: ELF 32-bit LSB executable, ARM, EABI5 version 1
> > (SYSV), statically linked,
> > BuildID[sha1]=ae5a34fc35b264d707b3f16e920282b96c080508, not stripped
>
> ah, the reproduction steps don't actually fetch the .config

the struct *somehow* comes out to be 36 bytes (it was 32 before this patch)

this tentatively looks like it might be triggering a compiler bug?
will dig deeper.

>
> > >
> > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > the same patch/commit), kindly add following tags
> > > | Reported-by: kernel test robot <lkp@intel.com>
> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202312060307.EaL1FRwu-lkp@intel.com/
> > >
> > > All errors (new ones prefixed by >>):
> > >
> > >    In file included from include/linux/container_of.h:5,
> > >                     from include/linux/list.h:5,
> > >                     from include/linux/module.h:12,
> > >                     from fs/lockd/svc.c:16:
> > > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> > >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > >          |                                         ^~~~~~~~~~~~~~
> > >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> > >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> > >          |                                  ^~~~~~~~~~~~~~~
> > >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> > >       58 | static_assert(sizeof(struct prefix_info) == 32);
> > >          | ^~~~~~~~~~~~~
> > > --
> > >    In file included from lib/vsprintf.c:21:
> > > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> > >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > >          |                                         ^~~~~~~~~~~~~~
> > >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> > >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> > >          |                                  ^~~~~~~~~~~~~~~
> > >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> > >       58 | static_assert(sizeof(struct prefix_info) == 32);
> > >          | ^~~~~~~~~~~~~
> > >    lib/vsprintf.c: In function 'va_format':
> > >    lib/vsprintf.c:1683:9: warning: function 'va_format' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> > >     1683 |         buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va);
> > >          |         ^~~
> > > --
> > >    In file included from include/linux/container_of.h:5,
> > >                     from include/linux/list.h:5,
> > >                     from include/linux/module.h:12,
> > >                     from net/ipv4/route.c:63:
> > > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> > >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > >          |                                         ^~~~~~~~~~~~~~
> > >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> > >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> > >          |                                  ^~~~~~~~~~~~~~~
> > >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> > >       58 | static_assert(sizeof(struct prefix_info) == 32);
> > >          | ^~~~~~~~~~~~~
> > >    net/ipv4/route.c: In function 'ip_rt_send_redirect':
> > >    net/ipv4/route.c:880:13: warning: variable 'log_martians' set but not used [-Wunused-but-set-variable]
> > >      880 |         int log_martians;
> > >          |             ^~~~~~~~~~~~
> > > --
> > >    In file included from include/linux/container_of.h:5,
> > >                     from include/linux/list.h:5,
> > >                     from include/linux/timer.h:5,
> > >                     from include/linux/workqueue.h:9,
> > >                     from include/linux/bpf.h:10,
> > >                     from net/ipv6/ip6_fib.c:18:
> > > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> > >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > >          |                                         ^~~~~~~~~~~~~~
> > >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> > >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> > >          |                                  ^~~~~~~~~~~~~~~
> > >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> > >       58 | static_assert(sizeof(struct prefix_info) == 32);
> > >          | ^~~~~~~~~~~~~
> > >    net/ipv6/ip6_fib.c: In function 'fib6_add':
> > >    net/ipv6/ip6_fib.c:1384:32: warning: variable 'pn' set but not used [-Wunused-but-set-variable]
> > >     1384 |         struct fib6_node *fn, *pn = NULL;
> > >          |                                ^~
> > >
> > >
> > > vim +78 include/linux/build_bug.h
> > >
> > > bc6245e5efd70c Ian Abbott       2017-07-10  60
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  61  /**
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  62   * static_assert - check integer constant expression at build time
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  63   *
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  64   * static_assert() is a wrapper for the C11 _Static_assert, with a
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  65   * little macro magic to make the message optional (defaulting to the
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  66   * stringification of the tested expression).
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  67   *
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  68   * Contrary to BUILD_BUG_ON(), static_assert() can be used at global
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  69   * scope, but requires the expression to be an integer constant
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  70   * expression (i.e., it is not enough that __builtin_constant_p() is
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  71   * true for expr).
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  72   *
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  73   * Also note that BUILD_BUG_ON() fails the build if the condition is
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  74   * true, while static_assert() fails the build if the expression is
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  75   * false.
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  76   */
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  77  #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07 @78  #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > > 6bab69c65013be Rasmus Villemoes 2019-03-07  79
> > > 07a368b3f55a79 Maxim Levitsky   2022-10-25  80
> > >
> > > --
> > > 0-DAY CI Kernel Test Service
> > > https://github.com/intel/lkp-tests/wikiMaciej Żenczykowski, Kernel Networking Developer @ GoogleMaciej Żenczykowski, Kernel Networking Developer @ GoogleMaciej Żenczykowski, Kernel Networking Developer @ Google
Maciej Żenczykowski Dec. 6, 2023, 2:13 p.m. UTC | #7
On Wed, Dec 6, 2023 at 3:13 AM Maciej Żenczykowski <maze@google.com> wrote:
>
> On Wed, Dec 6, 2023 at 3:05 AM Maciej Żenczykowski <maze@google.com> wrote:
> >
> > On Wed, Dec 6, 2023 at 3:00 AM Maciej Żenczykowski <maze@google.com> wrote:
> > >
> > > On Tue, Dec 5, 2023 at 11:12 AM kernel test robot <lkp@intel.com> wrote:
> > > >
> > > > Hi Maciej,
> > > >
> > > > kernel test robot noticed the following build errors:
> > > >
> > > > [auto build test ERROR on net/main]
> > > >
> > > > url:    https://github.com/intel-lab-lkp/linux/commits/Maciej-enczykowski/net-ipv6-support-reporting-otherwise-unknown-prefix-flags-in-RTM_NEWPREFIX/20231205-035333
> > > > base:   net/main
> > > > patch link:    https://lore.kernel.org/r/20231204195252.2004515-1-maze%40google.com
> > > > patch subject: [PATCH net] net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX
> > > > config: arm-rpc_defconfig (https://download.01.org/0day-ci/archive/20231206/202312060307.EaL1FRwu-lkp@intel.com/config)
> > > > compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
> > > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060307.EaL1FRwu-lkp@intel.com/reproduce)
> > >
> > > I followed these steps, and it built just fine...
> > >
> > > maze@laptop:~/K$ git log -n2 --oneline
> > > 57cde6e635d5 (HEAD) net: ipv6: support reporting otherwise unknown
> > > prefix flags in RTM_NEWPREFIX
> > > 7037d95a047c (net/main) r8152: add vendor/device ID pair for ASUS USB-C2500
> > >
> > > maze@laptop:~/K$ file -sL build_dir/vmlinux
> > > build_dir/vmlinux: ELF 32-bit LSB executable, ARM, EABI5 version 1
> > > (SYSV), statically linked,
> > > BuildID[sha1]=ae5a34fc35b264d707b3f16e920282b96c080508, not stripped
> >
> > ah, the reproduction steps don't actually fetch the .config
>
> the struct *somehow* comes out to be 36 bytes (it was 32 before this patch)
>
> this tentatively looks like it might be triggering a compiler bug?
> will dig deeper.

Looks like it can be fixed by adding attribute packed to both the new
union and struct.
I guess there's some arm32 ABI reason why this is needed...

>
> >
> > > >
> > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > > the same patch/commit), kindly add following tags
> > > > | Reported-by: kernel test robot <lkp@intel.com>
> > > > | Closes: https://lore.kernel.org/oe-kbuild-all/202312060307.EaL1FRwu-lkp@intel.com/
> > > >
> > > > All errors (new ones prefixed by >>):
> > > >
> > > >    In file included from include/linux/container_of.h:5,
> > > >                     from include/linux/list.h:5,
> > > >                     from include/linux/module.h:12,
> > > >                     from fs/lockd/svc.c:16:
> > > > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> > > >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > > >          |                                         ^~~~~~~~~~~~~~
> > > >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> > > >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> > > >          |                                  ^~~~~~~~~~~~~~~
> > > >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> > > >       58 | static_assert(sizeof(struct prefix_info) == 32);
> > > >          | ^~~~~~~~~~~~~
> > > > --
> > > >    In file included from lib/vsprintf.c:21:
> > > > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> > > >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > > >          |                                         ^~~~~~~~~~~~~~
> > > >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> > > >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> > > >          |                                  ^~~~~~~~~~~~~~~
> > > >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> > > >       58 | static_assert(sizeof(struct prefix_info) == 32);
> > > >          | ^~~~~~~~~~~~~
> > > >    lib/vsprintf.c: In function 'va_format':
> > > >    lib/vsprintf.c:1683:9: warning: function 'va_format' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> > > >     1683 |         buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va);
> > > >          |         ^~~
> > > > --
> > > >    In file included from include/linux/container_of.h:5,
> > > >                     from include/linux/list.h:5,
> > > >                     from include/linux/module.h:12,
> > > >                     from net/ipv4/route.c:63:
> > > > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> > > >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > > >          |                                         ^~~~~~~~~~~~~~
> > > >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> > > >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> > > >          |                                  ^~~~~~~~~~~~~~~
> > > >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> > > >       58 | static_assert(sizeof(struct prefix_info) == 32);
> > > >          | ^~~~~~~~~~~~~
> > > >    net/ipv4/route.c: In function 'ip_rt_send_redirect':
> > > >    net/ipv4/route.c:880:13: warning: variable 'log_martians' set but not used [-Wunused-but-set-variable]
> > > >      880 |         int log_martians;
> > > >          |             ^~~~~~~~~~~~
> > > > --
> > > >    In file included from include/linux/container_of.h:5,
> > > >                     from include/linux/list.h:5,
> > > >                     from include/linux/timer.h:5,
> > > >                     from include/linux/workqueue.h:9,
> > > >                     from include/linux/bpf.h:10,
> > > >                     from net/ipv6/ip6_fib.c:18:
> > > > >> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct prefix_info) == 32"
> > > >       78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > > >          |                                         ^~~~~~~~~~~~~~
> > > >    include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> > > >       77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> > > >          |                                  ^~~~~~~~~~~~~~~
> > > >    include/net/addrconf.h:58:1: note: in expansion of macro 'static_assert'
> > > >       58 | static_assert(sizeof(struct prefix_info) == 32);
> > > >          | ^~~~~~~~~~~~~
> > > >    net/ipv6/ip6_fib.c: In function 'fib6_add':
> > > >    net/ipv6/ip6_fib.c:1384:32: warning: variable 'pn' set but not used [-Wunused-but-set-variable]
> > > >     1384 |         struct fib6_node *fn, *pn = NULL;
> > > >          |                                ^~
> > > >
> > > >
> > > > vim +78 include/linux/build_bug.h
> > > >
> > > > bc6245e5efd70c Ian Abbott       2017-07-10  60
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  61  /**
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  62   * static_assert - check integer constant expression at build time
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  63   *
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  64   * static_assert() is a wrapper for the C11 _Static_assert, with a
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  65   * little macro magic to make the message optional (defaulting to the
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  66   * stringification of the tested expression).
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  67   *
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  68   * Contrary to BUILD_BUG_ON(), static_assert() can be used at global
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  69   * scope, but requires the expression to be an integer constant
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  70   * expression (i.e., it is not enough that __builtin_constant_p() is
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  71   * true for expr).
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  72   *
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  73   * Also note that BUILD_BUG_ON() fails the build if the condition is
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  74   * true, while static_assert() fails the build if the expression is
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  75   * false.
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  76   */
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  77  #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07 @78  #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > > > 6bab69c65013be Rasmus Villemoes 2019-03-07  79
> > > > 07a368b3f55a79 Maxim Levitsky   2022-10-25  80
> > > >
> > > > --
> > > > 0-DAY CI Kernel Test Service
> > > > https://github.com/intel/lkp-tests/wikiMaciej Żenczykowski, Kernel Networking Developer @ GoogleMaciej Żenczykowski, Kernel Networking Developer @ GoogleMaciej Żenczykowski, Kernel Networking Developer @ GoogleMaciej Żenczykowski, Kernel Networking Developer @ Google
diff mbox series

Patch

diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 82da55101b5a..1faece7b9c72 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -31,17 +31,22 @@  struct prefix_info {
 	__u8			length;
 	__u8			prefix_len;
 
+	union {
+		__u8		flags;
+		struct {
 #if defined(__BIG_ENDIAN_BITFIELD)
-	__u8			onlink : 1,
+			__u8	onlink : 1,
 			 	autoconf : 1,
 				reserved : 6;
 #elif defined(__LITTLE_ENDIAN_BITFIELD)
-	__u8			reserved : 6,
+			__u8	reserved : 6,
 				autoconf : 1,
 				onlink : 1;
 #else
 #error "Please fix <asm/byteorder.h>"
 #endif
+		};
+	};
 	__be32			valid;
 	__be32			prefered;
 	__be32			reserved2;
@@ -49,6 +54,9 @@  struct prefix_info {
 	struct in6_addr		prefix;
 };
 
+/* rfc4861 4.6.2: IPv6 PIO is 32 bytes in size */
+static_assert(sizeof(struct prefix_info) == 32);
+
 #include <linux/ipv6.h>
 #include <linux/netdevice.h>
 #include <net/if_inet6.h>
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index 3e454c4d7ba6..f07642264c1e 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -22,10 +22,6 @@ 
 #define IF_RS_SENT	0x10
 #define IF_READY	0x80000000
 
-/* prefix flags */
-#define IF_PREFIX_ONLINK	0x01
-#define IF_PREFIX_AUTOCONF	0x02
-
 enum {
 	INET6_IFADDR_STATE_PREDAD,
 	INET6_IFADDR_STATE_DAD,
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 3aaea56b5166..2692a7b24c40 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -6149,11 +6149,7 @@  static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
 	pmsg->prefix_len = pinfo->prefix_len;
 	pmsg->prefix_type = pinfo->type;
 	pmsg->prefix_pad3 = 0;
-	pmsg->prefix_flags = 0;
-	if (pinfo->onlink)
-		pmsg->prefix_flags |= IF_PREFIX_ONLINK;
-	if (pinfo->autoconf)
-		pmsg->prefix_flags |= IF_PREFIX_AUTOCONF;
+	pmsg->prefix_flags = pinfo->flags;
 
 	if (nla_put(skb, PREFIX_ADDRESS, sizeof(pinfo->prefix), &pinfo->prefix))
 		goto nla_put_failure;