freeswitch / sofia-sip

Sofia-SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification.
GNU Lesser General Public License v2.1
254 stars 173 forks source link

Transport interface: force socket binding to network interface #217

Open pdepaulis opened 1 year ago

pdepaulis commented 1 year ago

Address an issue seen in openWRT 22 (kernel 5.10) whereas the transport socket would not properly bind to an interface, almost at random, in a multi-homed system with a failover SIP profile. This caused the Sofia failover profile to bind to the primary interface, and thus the failover to still attempting to use the primary interface on a failover. By forcing the socket to bind to the interface explicitly (SO_BINDTODEVICE), the proper interface binding is achieved. Resolves #218

seven1240 commented 1 year ago

seems SO_BINDTODEVICE only works on Linux so need to make sure it doesn't break Windows or macOS etc.

Also, maybe make it optional and only enable it if some option is set?

pdepaulis commented 1 year ago

@seven1240 et. al. I'm trying to figure out where Sofia transport options go so I can add one as you suggested in your previous comment.

freeswitch-ci-system[bot] commented 1 year ago

Unit-tests failed: https://public-artifacts.signalwire.cloud/drone/freeswitch/sofia-sip/457/artifacts.html

pdepaulis commented 1 year ago

I now added a tp_params tag tpp_socket_bind_ifc (Linux only), that is used in the tport_xyz_init_primary() via TPTAG_SOCKET_BIND_IFC to optionally apply this (default is zero (0) so N/A by default). So, basically, to eliminate any risk for most users, as this is written, there is no change in socket-binding behavior. One can then change the default parameter value for tpp_socket_bind_ifc to one (1) if need be. In the future this behavior could be controlled via same in mod_sofia and passed in nua_create(), but that hasn't yet been implemented.