inet: add uint64_t accessors to in6_addr union

Message ID 20171112065412.18641-1-slandden@gmail.com
State New
Headers show
Series
  • inet: add uint64_t accessors to in6_addr union
Related show

Commit Message

Shawn Landden Nov. 12, 2017, 6:54 a.m.
64-bit architectures are common so this makes sense to have.
64-bit arches were not so common 1997-02-16.

Signed-off-by: Shawn Landden <slandden@gmail.com>
---
 inet/netinet/in.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Florian Weimer Nov. 12, 2017, 7:27 a.m. | #1
* Shawn Landden:

> diff --git a/inet/netinet/in.h b/inet/netinet/in.h
> index f94b4b4e1c..72d5dec312 100644
> --- a/inet/netinet/in.h
> +++ b/inet/netinet/in.h
> @@ -215,11 +215,13 @@ struct in6_addr
>  	uint8_t	__u6_addr8[16];
>  	uint16_t __u6_addr16[8];
>  	uint32_t __u6_addr32[4];
> +	uint64_t __u6_addr64[2];
>        } __in6_u;

I believe this breaks ABI because it changes the alignment of struct
in6_addr.
Shawn Landden Nov. 12, 2017, 11:03 a.m. | #2
On Nov 11, 2017 23:27, "Florian Weimer" <fw@deneb.enyo.de> wrote:

* Shawn Landden:

> diff --git a/inet/netinet/in.h b/inet/netinet/in.h
> index f94b4b4e1c..72d5dec312 100644
> --- a/inet/netinet/in.h
> +++ b/inet/netinet/in.h
> @@ -215,11 +215,13 @@ struct in6_addr
>       uint8_t __u6_addr8[16];
>       uint16_t __u6_addr16[8];
>       uint32_t __u6_addr32[4];
> +     uint64_t __u6_addr64[2];
>        } __in6_u;

I believe this breaks ABI because it changes the alignment of struct
in6_addr.

Oh my bad. I think you are right, as it would have been 32-bit aligned.
<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Nov 11, 2017 23:27, &quot;Florian Weimer&quot; &lt;<a href="mailto:fw@deneb.enyo.de">fw@deneb.enyo.de</a>&gt; wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">* Shawn Landden:<br>
<div class="quoted-text"><br>
&gt; diff --git a/inet/netinet/in.h b/inet/netinet/in.h<br>
&gt; index f94b4b4e1c..72d5dec312 100644<br>
&gt; --- a/inet/netinet/in.h<br>
&gt; +++ b/inet/netinet/in.h<br>
&gt; @@ -215,11 +215,13 @@ struct in6_addr<br>
&gt;       uint8_t __u6_addr8[16];<br>
&gt;       uint16_t __u6_addr16[8];<br>
&gt;       uint32_t __u6_addr32[4];<br>
&gt; +     uint64_t __u6_addr64[2];<br>
&gt;        } __in6_u;<br>
<br>
</div>I believe this breaks ABI because it changes the alignment of struct<br>
in6_addr.<br>
</blockquote></div>Oh my bad. I think you are right, as it would have been 32-bit aligned.</div></div></div>

Patch

diff --git a/inet/netinet/in.h b/inet/netinet/in.h
index f94b4b4e1c..72d5dec312 100644
--- a/inet/netinet/in.h
+++ b/inet/netinet/in.h
@@ -215,11 +215,13 @@  struct in6_addr
 	uint8_t	__u6_addr8[16];
 	uint16_t __u6_addr16[8];
 	uint32_t __u6_addr32[4];
+	uint64_t __u6_addr64[2];
       } __in6_u;
 #define s6_addr			__in6_u.__u6_addr8
 #ifdef __USE_MISC
 # define s6_addr16		__in6_u.__u6_addr16
 # define s6_addr32		__in6_u.__u6_addr32
+# define s6_addr64		__in6_u.__u6_addr64
 #endif
   };
 #endif /* !__USE_KERNEL_IPV6_DEFS */