Skip to contentSkip to conversation

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

PATCH Superseded Maciej Żenczykowski 4 participants 8 messages Dec 4, 2023 – Dec 6, 2023

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX

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 <[email protected]>
Cc David Ahern <[email protected]>
Cc Lorenzo Colitti <[email protected]>
Fixes 60872d54d963 ("[IPV6]: Add notification for MIB:ipv6Prefix events.")
---
 include/net/addrconf.h | 12 ++++++++++--
 include/net/if_inet6.h |  4 ----
 net/ipv6/addrconf.c    |  6 +-----
 3 files changed, 11 insertions(+), 11 deletions(-)
include/net/addrconf.h +10 -2
index 82da55101b5a..1faece7b9c72 100644
@@ -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>
include/net/if_inet6.h +0 -4
index 3e454c4d7ba6..f07642264c1e 100644
@@ -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,
net/ipv6/addrconf.c +1 -5
index 3aaea56b5166..2692a7b24c40 100644
@@ -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;
Signature · 1 line
2.43.0.rc2.451.g8631bc7472-goog
#1 lore raw
kernel test robot noticed the following build errors:

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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

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

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#2 lore raw
Quoted 7 lines · kernel test robot

Hi Maciej,

kernel test robot noticed the following build errors:

[auto build test ERROR on net/main]

Quoted 7 lines
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/[email protected]/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/[email protected]/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
Quoted 103 lines

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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

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:
Quoted 1 line
Quoted 1 line

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:

Quoted 1 line
Quoted 1 line

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:
Quoted 1 line
Quoted 1 line

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:
Quoted 1 line
Quoted 1 line

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

#3 lore raw
Quoted 24 lines · Maciej Żenczykowski
Quoted 7 lines · kernel test robot

Hi Maciej,

kernel test robot noticed the following build errors:

[auto build test ERROR on net/main]

Quoted 7 lines
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/[email protected]/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/[email protected]/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
Quoted 4 lines
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

Quoted 103 lines
Quoted 103 lines

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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

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:
Quoted 1 line
Quoted 1 line

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:

Quoted 1 line
Quoted 1 line

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:
Quoted 1 line
Quoted 1 line

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:
Quoted 1 line
Quoted 1 line

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

#4 lore raw
Quoted 26 lines · Maciej Żenczykowski
Quoted 24 lines · Maciej Żenczykowski
Quoted 7 lines · kernel test robot

Hi Maciej,

kernel test robot noticed the following build errors:

[auto build test ERROR on net/main]

Quoted 7 lines
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/[email protected]/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/[email protected]/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
Quoted 6 lines
Quoted 4 lines
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.

Quoted 104 lines
Quoted 104 lines
Quoted 104 lines

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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

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:
Quoted 1 line
Quoted 1 line

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:

Quoted 1 line
Quoted 1 line

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:
Quoted 1 line
Quoted 1 line

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:
Quoted 1 line
Quoted 1 line

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

#5 lore raw
Quoted 33 lines · Maciej Żenczykowski
Quoted 31 lines · Maciej Żenczykowski
Quoted 28 lines · Maciej Żenczykowski
Quoted 7 lines · kernel test robot

Hi Maciej,

kernel test robot noticed the following build errors:

[auto build test ERROR on net/main]

Quoted 7 lines
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/[email protected]/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/[email protected]/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
Quoted 6 lines
Quoted 1 line

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...

Quoted 105 lines
Quoted 105 lines
Quoted 105 lines
Quoted 105 lines

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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

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:
Quoted 1 line
Quoted 1 line

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:

Quoted 1 line
Quoted 1 line

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:
Quoted 1 line
Quoted 1 line

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:
Quoted 1 line
Quoted 1 line

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

maintainer
#6 lore raw
In reply to Maciej Żenczykowski
Quoted 3 lines · Maciej Żenczykowski

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?

#7 lore raw
Quoted 7 lines · David Ahern
Quoted 3 lines

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.