charon-nm: Use configured interface name if available
If connection.interface-name is configured, we use that instead of the randomly generated name. References strongswan/strongswan#1747
This commit is contained in:
@@ -138,7 +138,8 @@ static void delete_interface(NMStrongswanPluginPrivate *priv)
|
|||||||
/**
|
/**
|
||||||
* Create an XFRM or TUN interface
|
* Create an XFRM or TUN interface
|
||||||
*/
|
*/
|
||||||
static void create_interface(NMStrongswanPluginPrivate *priv)
|
static void create_interface(NMStrongswanPluginPrivate *priv,
|
||||||
|
const char *interface_name)
|
||||||
{
|
{
|
||||||
if (priv->xfrmi_manager)
|
if (priv->xfrmi_manager)
|
||||||
{
|
{
|
||||||
@@ -148,8 +149,15 @@ static void create_interface(NMStrongswanPluginPrivate *priv)
|
|||||||
/* allocate a random interface ID */
|
/* allocate a random interface ID */
|
||||||
priv->xfrmi_id = random();
|
priv->xfrmi_id = random();
|
||||||
|
|
||||||
/* use the interface ID to get a unique name, fine if it's cut off */
|
if (interface_name)
|
||||||
snprintf(name, sizeof(name), "nm-xfrm-%" PRIu32, priv->xfrmi_id);
|
{ /* use the preferred interface name if one is provided */
|
||||||
|
snprintf(name, sizeof(name), "%s", interface_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* use the interface ID to get a unique name, fine if it's cut off */
|
||||||
|
snprintf(name, sizeof(name), "nm-xfrm-%" PRIu32, priv->xfrmi_id);
|
||||||
|
}
|
||||||
|
|
||||||
mtu = lib->settings->get_int(lib->settings, "charon-nm.mtu",
|
mtu = lib->settings->get_int(lib->settings, "charon-nm.mtu",
|
||||||
XFRMI_DEFAULT_MTU);
|
XFRMI_DEFAULT_MTU);
|
||||||
@@ -900,7 +908,7 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
|
|||||||
* for NM etc. to play with...
|
* for NM etc. to play with...
|
||||||
*/
|
*/
|
||||||
delete_interface(priv);
|
delete_interface(priv);
|
||||||
create_interface(priv);
|
create_interface(priv, nm_setting_connection_get_interface_name(conn));
|
||||||
if (priv->xfrmi_id)
|
if (priv->xfrmi_id)
|
||||||
{ /* set the same mark as for IKE packets on the ESP packets so no routing
|
{ /* set the same mark as for IKE packets on the ESP packets so no routing
|
||||||
* loop is created if the TS covers the VPN server's IP */
|
* loop is created if the TS covers the VPN server's IP */
|
||||||
|
|||||||
Reference in New Issue
Block a user