Merge "ANDROID: Fix 32-bit x86 iproute2 on 64-bit kernel"
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
new file mode 120000
index 0000000..f43ae1b
--- /dev/null
+++ b/include/linux/xfrm.h
@@ -0,0 +1 @@
+../uapi/linux/xfrm.h
\ No newline at end of file
diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
index 93fb192..8312d3d 100644
--- a/include/uapi/linux/xfrm.h
+++ b/include/uapi/linux/xfrm.h
@@ -381,7 +381,11 @@
 #define XFRM_STATE_AF_UNSPEC	32
 #define XFRM_STATE_ALIGN4	64
 #define XFRM_STATE_ESN		128
-};
+}
+#ifdef __i386__
+__attribute__((aligned(8))) /* b/138147164 */
+#endif
+;
 
 #define XFRM_SA_XFLAG_DONT_ENCAP_DSCP	1
 
@@ -420,7 +424,11 @@
 	/* Automatically expand selector to include matching ICMP payloads. */
 #define XFRM_POLICY_ICMP	2
 	__u8				share;
-};
+}
+#ifdef __i386__
+__attribute__((aligned(8))) /* b/138147164 */
+#endif
+;
 
 struct xfrm_userpolicy_id {
 	struct xfrm_selector		sel;
diff --git a/ip/xfrm.h b/ip/xfrm.h
index 71be574..f1d3d0e 100644
--- a/ip/xfrm.h
+++ b/ip/xfrm.h
@@ -30,6 +30,19 @@
 #include <linux/xfrm.h>
 #include <linux/ipsec.h>
 
+#ifdef __i386__
+/* b/138147164 */
+/* Adapted from checks in system/netd/server/XfrmController.h */
+_Static_assert(sizeof(struct xfrm_usersa_info) - offsetof(struct xfrm_usersa_info, flags) == 8,
+               "struct xfrm_usersa_info probably misaligned with kernel struct.");
+_Static_assert(sizeof(struct xfrm_usersa_info) % 8 == 0,
+               "struct xfrm_usersa_info is not 64-bit aligned.");
+_Static_assert(sizeof(struct xfrm_userpolicy_info) - offsetof(struct xfrm_userpolicy_info, share) == 5,
+               "struct xfrm_userpolicy_info probably misaligned with kernel struct.");
+_Static_assert(sizeof(struct xfrm_userpolicy_info) % 8 == 0,
+               "struct xfrm_userpolicy_info is not 64-bit aligned.");
+#endif /* __i386__ */
+
 #ifndef IPPROTO_MH
 #define IPPROTO_MH              135
 #endif