diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2016-05-01 11:21:29 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2016-05-11 12:49:25 +0200 |
commit | 1c7668f8960cd449cc9eb2c94e9025bdb438cbf0 (patch) | |
tree | 3336eeca7b7f0a0356e6c2bac81227775087e9ba | |
parent | e35d3bfb4143f4fc50a319785ac300b9b0db96e6 (diff) | |
download | NetworkManager-1c7668f8960cd449cc9eb2c94e9025bdb438cbf0.tar.gz |
dnsmasq: don't add router option for non-default-route connections
This is useful to set up a DHCP server, but don't hijack the default
route of the clients.
(cherry picked from commit 9770024f63b85da604f1134a8bc8dc968278dcd1)
-rw-r--r-- | src/dnsmasq-manager/nm-dnsmasq-manager.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/dnsmasq-manager/nm-dnsmasq-manager.c b/src/dnsmasq-manager/nm-dnsmasq-manager.c index 31c1db247e..764aba2905 100644 --- a/src/dnsmasq-manager/nm-dnsmasq-manager.c +++ b/src/dnsmasq-manager/nm-dnsmasq-manager.c @@ -221,7 +221,7 @@ dm_watch_cb (GPid pid, gint status, gpointer user_data) static NMCmdLine * create_dm_cmd_line (const char *iface, - const NMPlatformIP4Address *listen_address, + const NMIP4Config *ip4_config, const char *pidfile, GError **error) { @@ -232,7 +232,9 @@ create_dm_cmd_line (const char *iface, char localaddr[INET_ADDRSTRLEN]; char *error_desc = NULL; const char *dm_binary; + const NMPlatformIP4Address *listen_address; + listen_address = nm_ip4_config_get_address (ip4_config, 0); g_return_val_if_fail (listen_address, NULL); dm_binary = nm_utils_find_helper ("dnsmasq", DNSMASQ_PATH, error); @@ -290,10 +292,12 @@ create_dm_cmd_line (const char *iface, nm_cmd_line_add_string (cmd, s->str); g_string_free (s, TRUE); - s = g_string_new ("--dhcp-option=option:router,"); - g_string_append (s, localaddr); - nm_cmd_line_add_string (cmd, s->str); - g_string_free (s, TRUE); + if (!nm_ip4_config_get_never_default (ip4_config)) { + s = g_string_new ("--dhcp-option=option:router,"); + g_string_append (s, localaddr); + nm_cmd_line_add_string (cmd, s->str); + g_string_free (s, TRUE); + } nm_cmd_line_add_string (cmd, "--dhcp-lease-max=50"); @@ -365,7 +369,7 @@ nm_dnsmasq_manager_start (NMDnsMasqManager *manager, kill_existing_by_pidfile (priv->pidfile); - dm_cmd = create_dm_cmd_line (priv->iface, nm_ip4_config_get_address (ip4_config, 0), priv->pidfile, error); + dm_cmd = create_dm_cmd_line (priv->iface, ip4_config, priv->pidfile, error); if (!dm_cmd) return FALSE; |