ip6_input() clears M_AUTHIPHDR and M_AUTHIPDGM on every packet. The
inner packet of a tunnel mode AH SA reaches it through netisr after
ipsec[46]_common_input_cb() has stripped the outer header, so it loses
the flags that ah_input_cb() set after verifying the ICV. The inbound
policy check in ipsec_in_reject() then finds no AH flag on a packet
whose policy requires AH and drops it as a policy violation ("inbound
packets violated process security policy" in netstat -sp ipsec6). With
the usual "require" level, every IPv6 packet carried by a tunnel mode
AH SA is dropped, whatever the outer address family. ESP is not
affected, since M_DECRYPTED is not cleared, and neither are IPv4 inner
packets, since ip_input() has never cleared the flags.
net.inet.ipsec.check_policy_history does not help: ipsec_in_reject()
checks the flags in addition to the history tags.
The clearing comes from KAME, whose ah6_input() deliberately did not
consider the inner packet authentic and cleared the flags itself. The
comment refers to ah4_input(), removed with the rest of the KAME IPsec
code in e66ff7fc8e12. Fast IPsec marks the inner packet authenticated,
since the ICV of a tunnel mode SA covers it entirely, and its IPv4 path
has relied on that from the start. Drop the clearing, as PR 122562
proposed in 2008.
Add an AH tunnel test to the netipsec tunnel suite; the inet6 case fails
without this change. ist_setkey() in utils.subr now emits AH SAs and
policies when no encryption algorithm is given, and ist_test() quotes
its argument list so that empty arguments reach it.
PR: 122562
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")