]> git.ipfire.org Git - people/ms/strongswan.git/commit
socket-default: Add an option to force the sending interface via IP_PKTINFO
authorMartin Willi <martin@strongswan.org>
Fri, 16 Sep 2016 12:50:07 +0000 (14:50 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 23 May 2017 14:49:39 +0000 (16:49 +0200)
commit9b29003cd9e12075070106eb9481954ab34912ca
treedde24a01c6a66630aa1ad5964558f77e97b65691
parent46a3f92a76b748a3086912215e14a3c9f1a5a98b
socket-default: Add an option to force the sending interface via IP_PKTINFO

On Linux, setting the source address is insufficient to force a packet to be
sent over a certain path. The kernel uses the best route to select the outgoing
interface, even if we set a source address of a lower priority interface. This
is not only true for interfaces attaching to the same subnet, but also for
unrelated interfaces; the kernel (at least on 4.7) sends out the packet on
whatever interface it sees fit, even if that network does not expect packets
from the source address we force to.

When a better interface becomes available, strongSwan sends its MOBIKE address
list update using the old source address. But the kernel sends that packet over
the new best interface. If that network drops packets having the unexpected
source address from the old path, the MOBIKE update fails and the SA finally
times out.

To enforce a specific interface for our packet, we explicitly set the interface
index from the interface where the source address is installed. According to
ip(7), this overrules the specified source address to the primary interface
address. As this could have side effects to installations using multiple
addresses on a single interface, we disable the option by default for now.

This also allows using IPv6 link-local addresses, which won't work if
the outbound interface is not set explicitly.
conf/plugins/socket-default.opt
src/libcharon/plugins/socket_default/socket_default_socket.c