Subject: Re: [PATCHv2 net] net: use struct_group to copy addresses

From: Jakub Kicinski <[email-masked]>
Date: Mon, 14 Nov 2022 21:16:45 -0800

On Mon, 14 Nov 2022 16:12:10 +0800 Hangbin Liu wrote:
> diff --git a/include/uapi/linux/ip.h b/include/uapi/linux/ip.h
> index 961ec16a26b8..6f7e833a00f7 100644
> --- a/include/uapi/linux/ip.h
> +++ b/include/uapi/linux/ip.h
> @@ -100,8 +100,10 @@ struct iphdr {
>  	__u8	ttl;
>  	__u8	protocol;
>  	__sum16	check;
> -	__be32	saddr;
> -	__be32	daddr;
> +	struct_group(addrs,
> +		__be32	saddr;
> +		__be32	daddr;
> +	);
>  	/*The options start here. */
>  };
>  
> diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h
> index 03cdbe798fe3..3a3a80496c7c 100644
> --- a/include/uapi/linux/ipv6.h
> +++ b/include/uapi/linux/ipv6.h
> @@ -130,8 +130,10 @@ struct ipv6hdr {
>  	__u8			nexthdr;
>  	__u8			hop_limit;
>  
> -	struct	in6_addr	saddr;
> -	struct	in6_addr	daddr;
> +	struct_group(addrs,
> +		struct	in6_addr	saddr;
> +		struct	in6_addr	daddr;
> +	);
>  };
>  

Can you double check the build with clang? It seems to fail with an odd
message, maybe some includes missing?

In file included from ./usr/include/linux/if_tunnel.h:7:
usr/include/linux/ip.h:103:2: error: type name requires a specifier or qualifier
        struct_group(addrs,
        ^
usr/include/linux/ip.h:104:3: error: unexpected type name '__be32': expected identifier
                __be32  saddr;
                ^
usr/include/linux/ip.h:104:10: error: expected ')'
                __be32  saddr;
                        ^
usr/include/linux/ip.h:103:14: note: to match this '('
        struct_group(addrs,
                    ^
usr/include/linux/ip.h:103:15: error: a parameter list without types is only allowed in a function definition
        struct_group(addrs,
                     ^
usr/include/linux/ip.h:106:2: error: type name requires a specifier or qualifier
        );
        ^
usr/include/linux/ip.h:106:2: error: expected member name or ';' after declaration specifiers
usr/include/linux/ip.h:105:16: error: expected ';' at end of declaration list
                __be32  daddr;
                              ^
                              ;