ppp: introduce SetIfindex pppd plugin D-Bus method

If IPV6CP terminates before IPCP, pppd enters the RUNNING phase and we
start IP configuration without having an IP interface set, which
triggers assertions.

Instead, add a SetIfindex() D-Bus method that gets called by the
plugin when pppd becomes RUNNING. The method sets the IP ifindex of
the device and starts IP configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1515829
This commit is contained in:
Beniamino Galvani 2018-01-08 16:45:43 +01:00
parent 2507046fea
commit dd98ada33f
10 changed files with 191 additions and 94 deletions

View file

@ -25,5 +25,10 @@
<method name="SetState">
<arg name="state" type="u" direction="in"/>
</method>
<method name="SetIfindex">
<arg name="ifindex" type="i" direction="in"/>
</method>
</interface>
</node>

View file

@ -430,9 +430,23 @@ ppp_state_changed (NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_
}
}
static void
ppp_ifindex_set (NMPPPManager *ppp_manager,
int ifindex,
const char *iface,
gpointer user_data)
{
NMDevice *device = NM_DEVICE (user_data);
if (!nm_device_set_ip_ifindex (device, ifindex)) {
nm_device_state_changed (device,
NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
}
}
static void
ppp_ip4_config (NMPPPManager *ppp_manager,
const char *iface,
NMIP4Config *config,
gpointer user_data)
{
@ -440,7 +454,6 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
/* Ignore PPP IP4 events that come in after initial configuration */
if (nm_device_activate_ip4_state_in_conf (device)) {
nm_device_set_ip_iface (device, iface);
nm_device_activate_schedule_ip4_config_result (device, config);
}
}
@ -499,6 +512,9 @@ act_stage3_ip4_config_start (NMDevice *device,
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IFINDEX_SET,
G_CALLBACK (ppp_ifindex_set),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);

View file

@ -952,9 +952,23 @@ ppp_state_changed (NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_
}
}
static void
ppp_ifindex_set (NMPPPManager *ppp_manager,
int ifindex,
const char *iface,
gpointer user_data)
{
NMDevice *device = NM_DEVICE (user_data);
if (!nm_device_set_ip_ifindex (device, ifindex)) {
nm_device_state_changed (device,
NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
}
}
static void
ppp_ip4_config (NMPPPManager *ppp_manager,
const char *iface,
NMIP4Config *config,
gpointer user_data)
{
@ -962,7 +976,6 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
/* Ignore PPP IP4 events that come in after initial configuration */
if (nm_device_activate_ip4_state_in_conf (device)) {
nm_device_set_ip_iface (device, iface);
nm_device_activate_schedule_ip4_config_result (device, config);
}
}
@ -1009,6 +1022,9 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *out_
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IFINDEX_SET,
G_CALLBACK (ppp_ifindex_set),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);

View file

@ -36,7 +36,6 @@ _LOG_DECLARE_SELF(NMDevicePpp);
typedef struct _NMDevicePppPrivate {
NMPPPManager *ppp_manager;
NMIP4Config *pending_ip4_config;
char *pending_ifname;
} NMDevicePppPrivate;
struct _NMDevicePpp {
@ -88,37 +87,45 @@ ppp_state_changed (NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_
case NM_PPP_STATUS_DEAD:
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_FAILED);
break;
case NM_PPP_STATUS_RUNNING:
nm_device_activate_schedule_stage3_ip_config_start (device);
break;
default:
break;
}
}
static void
ppp_ifindex_set (NMPPPManager *ppp_manager,
int ifindex,
const char *iface,
gpointer user_data)
{
NMDevice *device = NM_DEVICE (user_data);
gs_free char *old_name = NULL;
if (!nm_device_take_over_link (device, ifindex, &old_name)) {
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
return;
}
if (old_name)
nm_manager_remove_device (nm_manager_get (), old_name, NM_DEVICE_TYPE_PPP);
nm_device_activate_schedule_stage3_ip_config_start (device);
}
static void
ppp_ip4_config (NMPPPManager *ppp_manager,
const char *iface,
NMIP4Config *config,
gpointer user_data)
{
NMDevice *device = NM_DEVICE (user_data);
NMDevicePpp *self = NM_DEVICE_PPP (device);
NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE (self);
gboolean renamed;
_LOGT (LOGD_DEVICE | LOGD_PPP, "received IPv4 config from pppd");
if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG) {
if (nm_device_activate_ip4_state_in_conf (device)) {
if (!nm_device_take_over_link (device, iface, &renamed)) {
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
return;
}
if (renamed)
nm_manager_remove_device (nm_manager_get (), iface, NM_DEVICE_TYPE_PPP);
nm_device_activate_schedule_ip4_config_result (device, config);
return;
}
@ -126,8 +133,6 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
if (priv->pending_ip4_config)
g_object_unref (priv->pending_ip4_config);
priv->pending_ip4_config = g_object_ref (config);
g_free (priv->pending_ifname);
priv->pending_ifname = g_strdup (iface);
}
}
@ -147,7 +152,6 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
g_return_val_if_fail (s_pppoe, NM_ACT_STAGE_RETURN_FAILURE);
g_clear_object (&priv->pending_ip4_config);
nm_clear_g_free (&priv->pending_ifname);
priv->ppp_manager = nm_ppp_manager_create (nm_setting_pppoe_get_parent (s_pppoe), &error);
@ -175,6 +179,9 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IFINDEX_SET,
G_CALLBACK (ppp_ifindex_set),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);
@ -189,13 +196,8 @@ act_stage3_ip4_config_start (NMDevice *device,
{
NMDevicePpp *self = NM_DEVICE_PPP (device);
NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE (self);
gboolean renamed;
if (priv->pending_ip4_config) {
if (!nm_device_take_over_link (device, priv->pending_ifname, &renamed))
return NM_ACT_STAGE_RETURN_FAILURE;
if (renamed)
nm_manager_remove_device (nm_manager_get (), priv->pending_ifname, NM_DEVICE_TYPE_PPP);
if (out_config)
*out_config = g_steal_pointer (&priv->pending_ip4_config);
else
@ -256,7 +258,6 @@ dispose (GObject *object)
NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE (self);
g_clear_object (&priv->pending_ip4_config);
nm_clear_g_free (&priv->pending_ifname);
G_OBJECT_CLASS (nm_device_ppp_parent_class)->dispose (object);
}

View file

@ -46,6 +46,7 @@ enum NMActStageReturn {
NMSettings *nm_device_get_settings (NMDevice *self);
gboolean nm_device_set_ip_ifindex (NMDevice *self, int ifindex);
gboolean nm_device_set_ip_iface (NMDevice *self, const char *iface);
void nm_device_activate_schedule_stage3_ip_config_start (NMDevice *device);
@ -58,7 +59,7 @@ gboolean nm_device_bring_up (NMDevice *self, gboolean wait, gboolean *no_firmwar
void nm_device_take_down (NMDevice *self, gboolean block);
gboolean nm_device_take_over_link (NMDevice *self, const char *ifname, gboolean *renamed);
gboolean nm_device_take_over_link (NMDevice *self, int ifindex, char **old_name);
gboolean nm_device_hw_addr_set (NMDevice *device,
const char *addr,

View file

@ -1179,28 +1179,26 @@ nm_device_get_iface (NMDevice *self)
}
gboolean
nm_device_take_over_link (NMDevice *self, const char *ifname, gboolean *renamed)
nm_device_take_over_link (NMDevice *self, int ifindex, char **old_name)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
const NMPlatformLink *plink;
NMPlatform *platform;
gboolean up, success = TRUE;
int ifindex;
gs_free char *name = NULL;
g_return_val_if_fail (priv->ifindex <= 0, FALSE);
g_return_val_if_fail (ifname, FALSE);
NM_SET_OUT (renamed, FALSE);
NM_SET_OUT (old_name, NULL);
platform = nm_device_get_platform (self);
plink = nm_platform_link_get_by_ifname (platform, ifname);
plink = nm_platform_link_get (platform, ifindex);
if (!plink)
return FALSE;
ifindex = plink->ifindex;
if (!nm_streq (ifname, nm_device_get_iface (self))) {
if (!nm_streq (plink->name, nm_device_get_iface (self))) {
up = NM_FLAGS_HAS (plink->n_ifi_flags, IFF_UP);
name = g_strdup (plink->name);
/* Rename the link to the device ifname */
if (up)
@ -1209,7 +1207,8 @@ nm_device_take_over_link (NMDevice *self, const char *ifname, gboolean *renamed)
if (up)
nm_platform_link_set_up (platform, ifindex, NULL);
NM_SET_OUT (renamed, success);
if (success)
NM_SET_OUT (old_name, g_steal_pointer (&name));
}
if (success) {
@ -1306,10 +1305,11 @@ nm_device_set_ip_ifindex (NMDevice *self, int ifindex)
return FALSE;
}
name = plink->name;
}
} else
g_return_val_if_fail (ifindex == 0, FALSE);
if (priv->ip_ifindex == ifindex)
return FALSE;
return TRUE;
_LOGD (LOGD_DEVICE, "ip-ifindex: update ifindex to %d", ifindex);
priv->ip_ifindex = ifindex;

View file

@ -450,20 +450,26 @@ ppp_state_changed (NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_
}
static void
set_data_port (NMModem *self, const char *new_data_port)
ppp_ifindex_set (NMPPPManager *ppp_manager,
int ifindex,
const char *iface,
gpointer user_data)
{
NMModem *self = NM_MODEM (user_data);
NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self);
if (g_strcmp0 (priv->data_port, new_data_port) != 0) {
/* Notify about the new data port to use.
*
* @iface might be %NULL. */
if (g_strcmp0 (priv->data_port, iface) != 0) {
g_free (priv->data_port);
priv->data_port = g_strdup (new_data_port);
priv->data_port = g_strdup (iface);
_notify (self, PROP_DATA_PORT);
}
}
static void
ppp_ip4_config (NMPPPManager *ppp_manager,
const char *iface,
NMIP4Config *config,
gpointer user_data)
{
@ -475,9 +481,6 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
guint32 good_dns2 = htonl (0x04020202); /* GTE nameserver */
gboolean dns_workaround = FALSE;
/* Notify about the new data port to use */
set_data_port (self, iface);
/* Work around a PPP bug (#1732) which causes many mobile broadband
* providers to return 10.11.12.13 and 10.11.12.14 for the DNS servers.
* Apparently fixed in ppp-2.4.5 but we've had some reports that this is
@ -519,16 +522,12 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
static void
ppp_ip6_config (NMPPPManager *ppp_manager,
const char *iface,
const NMUtilsIPv6IfaceId *iid,
NMIP6Config *config,
gpointer user_data)
{
NMModem *self = NM_MODEM (user_data);
/* Notify about the new data port to use */
set_data_port (self, iface);
NM_MODEM_GET_PRIVATE (self)->iid = *iid;
nm_modem_emit_ip6_config_result (self, config, NULL);
@ -639,6 +638,9 @@ ppp_stage3_ip_config_start (NMModem *self,
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IFINDEX_SET,
G_CALLBACK (ppp_ifindex_set),
self);
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);

View file

@ -76,6 +76,7 @@ GType nm_ppp_manager_get_type (void);
enum {
STATE_CHANGED,
IFINDEX_SET,
IP4_CONFIG,
IP6_CONFIG,
STATS,
@ -93,6 +94,8 @@ typedef struct {
GPid pid;
char *parent_iface;
char *ip_iface;
int ifindex;
NMActRequest *act_req;
GDBusMethodInvocation *pending_secrets_context;
@ -103,7 +106,6 @@ typedef struct {
guint ppp_timeout_handler;
/* Monitoring */
char *ip_iface;
int monitor_fd;
guint monitor_id;
@ -174,24 +176,28 @@ monitor_cb (gpointer user_data)
{
NMPPPManager *manager = NM_PPP_MANAGER (user_data);
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
struct ifreq req;
struct ppp_stats stats;
const char *ifname;
memset (&req, 0, sizeof (req));
memset (&stats, 0, sizeof (stats));
req.ifr_data = (caddr_t) &stats;
ifname = nm_platform_link_get_name (NM_PLATFORM_GET, priv->ifindex);
strncpy (req.ifr_name, priv->ip_iface, sizeof (req.ifr_name));
if (ioctl (priv->monitor_fd, SIOCGPPPSTATS, &req) < 0) {
if (errno != ENODEV)
_LOGW ("could not read ppp stats: %s", strerror (errno));
} else {
g_signal_emit (manager, signals[STATS], 0,
(guint) stats.p.ppp_ibytes,
(guint) stats.p.ppp_obytes);
if (ifname) {
struct ppp_stats stats = { };
struct ifreq req = {
.ifr_data = (caddr_t) &stats,
};
nm_utils_ifname_cpy (req.ifr_name, ifname);
if (ioctl (priv->monitor_fd, SIOCGPPPSTATS, &req) < 0) {
if (errno != ENODEV)
_LOGW ("could not read ppp stats: %s", strerror (errno));
} else {
g_signal_emit (manager, signals[STATS], 0,
(guint) stats.p.ppp_ibytes,
(guint) stats.p.ppp_obytes);
}
}
return TRUE;
return G_SOURCE_CONTINUE;
}
static void
@ -399,23 +405,54 @@ impl_ppp_manager_set_state (NMPPPManager *manager,
g_dbus_method_invocation_return_value (context, NULL);
}
static void
impl_ppp_manager_set_ifindex (NMPPPManager *manager,
GDBusMethodInvocation *context,
gint32 ifindex)
{
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
const NMPlatformLink *plink = NULL;
nm_auto_nmpobj const NMPObject *obj_keep_alive = NULL;
_LOGD ("set-ifindex %d", (int) ifindex);
if (priv->ifindex >= 0) {
_LOGW ("can't change the ifindex from %d to %d", priv->ifindex, (int) ifindex);
return;
}
if (ifindex > 0) {
plink = nm_platform_link_get (NM_PLATFORM_GET, ifindex);
if (!plink) {
nm_platform_process_events (NM_PLATFORM_GET);
plink = nm_platform_link_get (NM_PLATFORM_GET, ifindex);
}
}
if (!plink) {
_LOGW ("unknown interface with ifindex %d", ifindex);
ifindex = 0;
}
priv->ifindex = ifindex;
obj_keep_alive = nmp_object_ref (NMP_OBJECT_UP_CAST (plink));
g_signal_emit (manager, signals[IFINDEX_SET], 0, ifindex, plink->name);
g_dbus_method_invocation_return_value (context, NULL);
}
static gboolean
set_ip_config_common (NMPPPManager *self,
GVariant *config_dict,
const char *iface_prop,
guint32 *out_mtu)
{
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
NMConnection *applied_connection;
NMSettingPpp *s_ppp;
const char *iface;
if (!g_variant_lookup (config_dict, iface_prop, "&s", &iface)) {
_LOGE ("no interface received!");
if (priv->ifindex <= 0)
return FALSE;
}
if (priv->ip_iface == NULL)
priv->ip_iface = g_strdup (iface);
/* Got successful IP config; obviously the secrets worked */
applied_connection = nm_act_request_get_applied_connection (priv->act_req);
@ -441,20 +478,15 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
NMPlatformIP4Address address;
guint32 u32, mtu;
GVariantIter *iter;
int ifindex;
_LOGI ("(IPv4 Config Get) reply received.");
nm_clear_g_source (&priv->ppp_timeout_handler);
if (!set_ip_config_common (manager, config_dict, NM_PPP_IP4_CONFIG_INTERFACE, &mtu))
if (!set_ip_config_common (manager, config_dict, &mtu))
goto out;
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface);
if (ifindex <= 0)
goto out;
config = nm_ip4_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET), ifindex);
config = nm_ip4_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET), priv->ifindex);
if (mtu)
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_PPP);
@ -467,7 +499,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_GATEWAY, "u", &u32)) {
const NMPlatformIP4Route r = {
.ifindex = ifindex,
.ifindex = priv->ifindex,
.rt_source = NM_IP_CONFIG_SOURCE_PPP,
.gateway = u32,
.table_coerced = nm_platform_route_table_coerce (priv->ip4_route_table),
@ -503,7 +535,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
}
/* Push the IP4 config up to the device */
g_signal_emit (manager, signals[IP4_CONFIG], 0, priv->ip_iface, config);
g_signal_emit (manager, signals[IP4_CONFIG], 0, config);
out:
g_dbus_method_invocation_return_value (context, NULL);
@ -549,27 +581,22 @@ impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
struct in6_addr a;
NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT;
gboolean has_peer = FALSE;
int ifindex;
_LOGI ("(IPv6 Config Get) reply received.");
nm_clear_g_source (&priv->ppp_timeout_handler);
if (!set_ip_config_common (manager, config_dict, NM_PPP_IP6_CONFIG_INTERFACE, NULL))
if (!set_ip_config_common (manager, config_dict, NULL))
goto out;
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface);
if (ifindex <= 0)
goto out;
config = nm_ip6_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET), ifindex);
config = nm_ip6_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET), priv->ifindex);
memset (&addr, 0, sizeof (addr));
addr.plen = 64;
if (iid_value_to_ll6_addr (config_dict, NM_PPP_IP6_CONFIG_PEER_IID, &a, NULL)) {
const NMPlatformIP6Route r = {
.ifindex = ifindex,
.ifindex = priv->ifindex,
.rt_source = NM_IP_CONFIG_SOURCE_PPP,
.gateway = a,
.table_coerced = nm_platform_route_table_coerce (priv->ip6_route_table),
@ -587,7 +614,7 @@ impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
nm_ip6_config_add_address (config, &addr);
/* Push the IPv6 config and interface identifier up to the device */
g_signal_emit (manager, signals[IP6_CONFIG], 0, priv->ip_iface, &iid, config);
g_signal_emit (manager, signals[IP6_CONFIG], 0, &iid, config);
} else
_LOGE ("invalid IPv6 address received!");
@ -1244,6 +1271,7 @@ nm_ppp_manager_init (NMPPPManager *manager)
{
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
priv->ifindex = -1;
priv->monitor_fd = -1;
priv->ip4_route_table = RT_TABLE_MAIN;
priv->ip4_route_metric = 460;
@ -1284,7 +1312,6 @@ finalize (GObject *object)
{
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE ((NMPPPManager *) object);
g_free (priv->ip_iface);
g_free (priv->parent_iface);
G_OBJECT_CLASS (nm_ppp_manager_parent_class)->finalize (object);
@ -1320,14 +1347,23 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
G_TYPE_NONE, 1,
G_TYPE_UINT);
signals[IFINDEX_SET] =
g_signal_new (NM_PPP_MANAGER_SIGNAL_IFINDEX_SET,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 2,
G_TYPE_INT,
G_TYPE_STRING);
signals[IP4_CONFIG] =
g_signal_new (NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 2,
G_TYPE_STRING,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
signals[IP6_CONFIG] =
@ -1336,7 +1372,9 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_OBJECT);
G_TYPE_NONE, 2,
G_TYPE_POINTER,
G_TYPE_OBJECT);
signals[STATS] =
g_signal_new (NM_PPP_MANAGER_SIGNAL_STATS,
@ -1354,6 +1392,7 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
"SetIp4Config", impl_ppp_manager_set_ip4_config,
"SetIp6Config", impl_ppp_manager_set_ip6_config,
"SetState", impl_ppp_manager_set_state,
"SetIfindex", impl_ppp_manager_set_ifindex,
NULL);
}

View file

@ -25,6 +25,7 @@
#define NM_PPP_MANAGER_PARENT_IFACE "parent-iface"
#define NM_PPP_MANAGER_SIGNAL_STATE_CHANGED "state-changed"
#define NM_PPP_MANAGER_SIGNAL_IFINDEX_SET "ifindex-set"
#define NM_PPP_MANAGER_SIGNAL_IP4_CONFIG "ip4-config"
#define NM_PPP_MANAGER_SIGNAL_IP6_CONFIG "ip6-config"
#define NM_PPP_MANAGER_SIGNAL_STATS "stats"

View file

@ -28,6 +28,7 @@
#include <pppd/ipcp.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <dlfcn.h>
@ -128,6 +129,15 @@ nm_phasechange (void *data, int arg)
NULL,
NULL, NULL);
}
if (ppp_status == PHASE_RUNNING) {
g_dbus_proxy_call (proxy,
"SetIfindex",
g_variant_new ("(i)", if_nametoindex (ifname)),
G_DBUS_CALL_FLAGS_NONE, -1,
NULL,
NULL, NULL);
}
}
static void
@ -150,6 +160,9 @@ nm_ip_up (void *data, int arg)
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
/* Keep sending the interface name to be backwards compatible
* with older versions of NM during a package upgrade, where
* NM is not restarted and the pppd plugin was not loaded. */
g_variant_builder_add (&builder, "{sv}",
NM_PPP_IP4_CONFIG_INTERFACE,
g_variant_new_string (ifname));
@ -244,6 +257,9 @@ nm_ip6_up (void *data, int arg)
g_message ("nm-ppp-plugin: (%s): ip6-up event", __func__);
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
/* Keep sending the interface name to be backwards compatible
* with older versions of NM during a package upgrade, where
* NM is not restarted and the pppd plugin was not loaded. */
g_variant_builder_add (&builder, "{sv}",
NM_PPP_IP6_CONFIG_INTERFACE,
g_variant_new_string (ifname));