mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-07 00:31:11 +00:00
nm-dispatcher: dispatch on reapply
Trigger a dispatcher event when a connection is reapplied on a NM device. Some devices such as phones have already a DHCP client running for accepting connections when they are plugged into USB to transfer data over SSH. When NetworkManager switches the connection IP method to shared, it spawns a dnsmasq process to handle DHCP and DNS for that connection. However, a dispatcher event is needed to disable the external DHCP server for these USB connections as NetworkManager's dnsmasq handles them now. Moreover, when the connection method is switched to a different mode, the external DHCP server needs to be spawned again to make sure that SSH connections are still possible to the device. To achieve this, add a new NetworkManager Dispatcher event 'reapply' which is triggered when a connection is reapplied on a NM device. This way, a dispatcher script can handle the case above by inspecting the IP method in the dispatcher script.
This commit is contained in:
parent
8b66865a88
commit
cef880c66f
|
@ -13041,6 +13041,10 @@ check_and_reapply_connection(NMDevice *self,
|
|||
if (priv->state >= NM_DEVICE_STATE_ACTIVATED)
|
||||
nm_device_update_metered(self);
|
||||
|
||||
/* Notify dispatcher when re-applied */
|
||||
_LOGD(LOGD_DEVICE, "Notifying re-apply complete");
|
||||
nm_dispatcher_call_device(NM_DISPATCHER_ACTION_REAPPLY, self, NULL, NULL, NULL, NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -468,7 +468,8 @@ static const char *action_table[] = {[NM_DISPATCHER_ACTION_HOSTNAME] = NMD_
|
|||
[NM_DISPATCHER_ACTION_DHCP_CHANGE_4] = NMD_ACTION_DHCP4_CHANGE,
|
||||
[NM_DISPATCHER_ACTION_DHCP_CHANGE_6] = NMD_ACTION_DHCP6_CHANGE,
|
||||
[NM_DISPATCHER_ACTION_CONNECTIVITY_CHANGE] =
|
||||
NMD_ACTION_CONNECTIVITY_CHANGE};
|
||||
NMD_ACTION_CONNECTIVITY_CHANGE,
|
||||
[NM_DISPATCHER_ACTION_REAPPLY] = NMD_ACTION_REAPPLY};
|
||||
|
||||
static const char *
|
||||
action_to_string(NMDispatcherAction action)
|
||||
|
|
|
@ -21,7 +21,8 @@ typedef enum {
|
|||
NM_DISPATCHER_ACTION_VPN_DOWN,
|
||||
NM_DISPATCHER_ACTION_DHCP_CHANGE_4,
|
||||
NM_DISPATCHER_ACTION_DHCP_CHANGE_6,
|
||||
NM_DISPATCHER_ACTION_CONNECTIVITY_CHANGE
|
||||
NM_DISPATCHER_ACTION_CONNECTIVITY_CHANGE,
|
||||
NM_DISPATCHER_ACTION_REAPPLY,
|
||||
} NMDispatcherAction;
|
||||
|
||||
#define NM_DISPATCHER_ACTION_DHCP_CHANGE_X(IS_IPv4) \
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#define NMD_ACTION_DHCP4_CHANGE "dhcp4-change"
|
||||
#define NMD_ACTION_DHCP6_CHANGE "dhcp6-change"
|
||||
#define NMD_ACTION_CONNECTIVITY_CHANGE "connectivity-change"
|
||||
#define NMD_ACTION_REAPPLY "reapply"
|
||||
|
||||
typedef enum {
|
||||
DISPATCH_RESULT_UNKNOWN = 0,
|
||||
|
|
Loading…
Reference in a new issue