kernel-netlink: Use correct 4 byte alignment for AH with IPv4
[strongswan.git] / src / libcharon / plugins / kernel_netlink / kernel_netlink_ipsec.c
index b2ccbe0..1d5e3b2 100644 (file)
@@ -1369,6 +1369,11 @@ METHOD(kernel_ipsec_t, add_sa, status_t,
                default:
                        break;
        }
+       if (id->proto == IPPROTO_AH && sa->family == AF_INET)
+       {       /* use alignment to 4 bytes for IPv4 instead of the incorrect 8 byte
+                * alignment that's used by default but is only valid for IPv6 */
+               sa->flags |= XFRM_STATE_ALIGN4;
+       }
 
        sa->reqid = data->reqid;
        sa->lft.soft_byte_limit = XFRM_LIMIT(data->lifetime->bytes.rekey);