ipsec{4,6}_check_pmtu() looks up the SA of the last request of a policy to
learn the path MTU. When that request is at level "use" and has no SA, the
lookup returns EJUSTRETURN, and ipsec{4,6}_common_output() took that to
mean that the packet needs no IPsec processing. That holds for a policy
with one request. For a bundle it also skipped the requests before the
last one, for example the ESP tunnel request of
"esp/tunnel/A-B/require ah/transport//use", and the packet was sent without
their transforms.
For IPv4 the check runs when net.inet.ipsec.dfbit is 1, or is above 1 and
the packet has DF set, and not with the default of 0. For IPv6 it runs for
forwarded packets and not for locally originated ones.
Return 0 from the check in this case and keep the reference to the SP, so
that ipsec{4,6}_process_packet() goes through the requests as it does when
the check does not run. It returns EJUSTRETURN itself when no request
applies, so a policy with a single skipped request behaves as before. No
PMTU check is made for such a packet.
Fixes: 6b66194bcb7e ("ipsec: Check PMTU before sending a frame.")
Fixes: 9dfc8606eb80 ("ipsec: Add support for PMTUD for IPv6...")
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")