diff options
| author | Michael Biebl <biebl@debian.org> | 2011-10-28 23:04:16 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2011-10-28 23:04:16 +0200 |
| commit | 485d149fe80915d94ed49ea6c2c0552cf7a3e79a (patch) | |
| tree | 6a48492b46b8c1e3df1c58626c28f05a978c61f7 /src/dns-manager | |
| parent | 263bf4c0c89bb88dc995acd9a6a2de9095fbd461 (diff) | |
Imported Upstream version 0.9.1.95 upstream/0.9.1.95
Diffstat (limited to 'src/dns-manager')
| -rw-r--r-- | src/dns-manager/Makefile.in | 8 | ||||
| -rw-r--r-- | src/dns-manager/nm-dns-bind.c | 3 | ||||
| -rw-r--r-- | src/dns-manager/nm-dns-dnsmasq.c | 73 | ||||
| -rw-r--r-- | src/dns-manager/nm-dns-manager.c | 3 | ||||
| -rw-r--r-- | src/dns-manager/nm-dns-plugin.c | 6 | ||||
| -rw-r--r-- | src/dns-manager/nm-dns-plugin.h | 6 |
6 files changed, 77 insertions, 22 deletions
diff --git a/src/dns-manager/Makefile.in b/src/dns-manager/Makefile.in index aad1c562..d44c3bfc 100644 --- a/src/dns-manager/Makefile.in +++ b/src/dns-manager/Makefile.in @@ -190,8 +190,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNL1_CFLAGS = @LIBNL1_CFLAGS@ +LIBNL1_LIBS = @LIBNL1_LIBS@ +LIBNL2_CFLAGS = @LIBNL2_CFLAGS@ +LIBNL2_LIBS = @LIBNL2_LIBS@ +LIBNL3_CFLAGS = @LIBNL3_CFLAGS@ +LIBNL3_LIBS = @LIBNL3_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ +LIBNL_ROUTE3_CFLAGS = @LIBNL_ROUTE3_CFLAGS@ +LIBNL_ROUTE3_LIBS = @LIBNL_ROUTE3_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ diff --git a/src/dns-manager/nm-dns-bind.c b/src/dns-manager/nm-dns-bind.c index fc7af776..55fce030 100644 --- a/src/dns-manager/nm-dns-bind.c +++ b/src/dns-manager/nm-dns-bind.c @@ -297,7 +297,8 @@ update (NMDnsPlugin *plugin, const GSList *vpn_configs, const GSList *dev_configs, const GSList *other_configs, - const char *hostname) + const char *hostname, + const char *iface) { NMDnsBind *self = NM_DNS_BIND (plugin); NMDnsBindPrivate *priv = NM_DNS_BIND_GET_PRIVATE (self); diff --git a/src/dns-manager/nm-dns-dnsmasq.c b/src/dns-manager/nm-dns-dnsmasq.c index 9cc01978..a602c54f 100644 --- a/src/dns-manager/nm-dns-dnsmasq.c +++ b/src/dns-manager/nm-dns-dnsmasq.c @@ -133,23 +133,56 @@ add_ip4_config (GString *str, NMIP4Config *ip4, gboolean split) return TRUE; } -static gboolean -ip6_addr_to_string (const struct in6_addr *addr, char *buf, size_t buflen) +#define IP6_ADDR_BUFLEN (INET6_ADDRSTRLEN + 50) + +static char * +ip6_addr_to_string (const struct in6_addr *addr, const char *iface) { - memset (buf, 0, buflen); + char *buf, *p; + + /* allocate enough space for the address + interface name */ + buf = g_malloc0 (IP6_ADDR_BUFLEN + 1); /* inet_ntop is probably supposed to do this for us, but it doesn't */ - if (IN6_IS_ADDR_V4MAPPED (addr)) - return !!inet_ntop (AF_INET, &(addr->s6_addr32[3]), buf, buflen); + if (IN6_IS_ADDR_V4MAPPED (addr)) { + if (!inet_ntop (AF_INET, &(addr->s6_addr32[3]), buf, IP6_ADDR_BUFLEN)) + goto error; + return buf; + } - return !!inet_ntop (AF_INET6, addr, buf, buflen); + if (!inet_ntop (AF_INET6, addr, buf, IP6_ADDR_BUFLEN)) + goto error; + + /* In the case of addr being a link-local address, inet_ntop can either + * return an address with scope identifier already in place (like + * fe80::202:b3ff:fe8d:7aaf%wlan0) or it returns an address without + * scope identifier at all (like fe80::202:b3ff:fe8d:7aaf) + */ + p = strchr (buf, '%'); + if (p) { + /* If we got a scope identifier, we need to replace the '%' + * with '@', since dnsmasq supports '%' in server= addresses + * only since version 2.58 and up + */ + *p = '@'; + } else if (IN6_IS_ADDR_LINKLOCAL (addr)) { + /* If we got no scope identifier at all append the interface name */ + strncat (buf, "@", IP6_ADDR_BUFLEN - strlen (buf)); + strncat (buf, iface, IP6_ADDR_BUFLEN - strlen (buf)); + } + + return buf; + +error: + g_free (buf); + return NULL; } static gboolean -add_ip6_config (GString *str, NMIP6Config *ip6, gboolean split) +add_ip6_config (GString *str, NMIP6Config *ip6, gboolean split, const char *iface) { - char buf[INET6_ADDRSTRLEN + 1]; const struct in6_addr *addr; + char *buf; int n, i; gboolean added = FALSE; @@ -159,7 +192,8 @@ add_ip6_config (GString *str, NMIP6Config *ip6, gboolean split) * the first nameserver here. */ addr = nm_ip6_config_get_nameserver (ip6, 0); - if (!ip6_addr_to_string (addr, &buf[0], sizeof (buf))) + buf = ip6_addr_to_string (addr, iface); + if (!buf) return FALSE; /* searches are preferred over domains */ @@ -181,6 +215,8 @@ add_ip6_config (GString *str, NMIP6Config *ip6, gboolean split) added = TRUE; } } + + g_free (buf); } /* If no searches or domains, just add the namservers */ @@ -188,8 +224,11 @@ add_ip6_config (GString *str, NMIP6Config *ip6, gboolean split) n = nm_ip6_config_get_num_nameservers (ip6); for (i = 0; i < n; i++) { addr = nm_ip6_config_get_nameserver (ip6, i); - if (ip6_addr_to_string (addr, &buf[0], sizeof (buf))) + buf = ip6_addr_to_string (addr, iface); + if (buf) { g_string_append_printf (str, "server=%s\n", buf); + g_free (buf); + } } } @@ -201,12 +240,13 @@ update (NMDnsPlugin *plugin, const GSList *vpn_configs, const GSList *dev_configs, const GSList *other_configs, - const char *hostname) + const char *hostname, + const char *iface) { NMDnsDnsmasq *self = NM_DNS_DNSMASQ (plugin); GString *conf; GSList *iter; - const char *argv[10]; + const char *argv[11]; GError *error = NULL; int ignored; GPid pid = 0; @@ -226,7 +266,7 @@ update (NMDnsPlugin *plugin, if (NM_IS_IP4_CONFIG (iter->data)) add_ip4_config (conf, NM_IP4_CONFIG (iter->data), TRUE); else if (NM_IS_IP6_CONFIG (iter->data)) - add_ip6_config (conf, NM_IP6_CONFIG (iter->data), TRUE); + add_ip6_config (conf, NM_IP6_CONFIG (iter->data), TRUE, iface); } /* Now add interface configs without split DNS */ @@ -234,7 +274,7 @@ update (NMDnsPlugin *plugin, if (NM_IS_IP4_CONFIG (iter->data)) add_ip4_config (conf, NM_IP4_CONFIG (iter->data), FALSE); else if (NM_IS_IP6_CONFIG (iter->data)) - add_ip6_config (conf, NM_IP6_CONFIG (iter->data), FALSE); + add_ip6_config (conf, NM_IP6_CONFIG (iter->data), FALSE, iface); } /* And any other random configs */ @@ -242,7 +282,7 @@ update (NMDnsPlugin *plugin, if (NM_IS_IP4_CONFIG (iter->data)) add_ip4_config (conf, NM_IP4_CONFIG (iter->data), FALSE); else if (NM_IS_IP6_CONFIG (iter->data)) - add_ip6_config (conf, NM_IP6_CONFIG (iter->data), FALSE); + add_ip6_config (conf, NM_IP6_CONFIG (iter->data), FALSE, iface); } /* Write out the config file */ @@ -267,7 +307,8 @@ update (NMDnsPlugin *plugin, argv[5] = "--pid-file=" PIDFILE; argv[6] = "--listen-address=127.0.0.1"; /* Should work for both 4 and 6 */ argv[7] = "--conf-file=" CONFFILE; - argv[8] = NULL; + argv[8] = "--cache-size=400"; + argv[9] = NULL; /* And finally spawn dnsmasq */ pid = nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, PIDFILE, "bin/dnsmasq"); diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c index 49cd74e5..0203f2bb 100644 --- a/src/dns-manager/nm-dns-manager.c +++ b/src/dns-manager/nm-dns-manager.c @@ -711,7 +711,8 @@ update_dns (NMDnsManager *self, vpn_configs, dev_configs, other_configs, - priv->hostname)) { + priv->hostname, + iface)) { nm_log_warn (LOGD_DNS, "DNS: plugin %s update failed", plugin_name); /* If the plugin failed to update, we shouldn't write out a local diff --git a/src/dns-manager/nm-dns-plugin.c b/src/dns-manager/nm-dns-plugin.c index ae230ada..e997948e 100644 --- a/src/dns-manager/nm-dns-plugin.c +++ b/src/dns-manager/nm-dns-plugin.c @@ -55,7 +55,8 @@ nm_dns_plugin_update (NMDnsPlugin *self, const GSList *vpn_configs, const GSList *dev_configs, const GSList *other_configs, - const char *hostname) + const char *hostname, + const char *iface) { g_return_val_if_fail (NM_DNS_PLUGIN_GET_CLASS (self)->update != NULL, FALSE); @@ -63,7 +64,8 @@ nm_dns_plugin_update (NMDnsPlugin *self, vpn_configs, dev_configs, other_configs, - hostname); + hostname, + iface); } static gboolean diff --git a/src/dns-manager/nm-dns-plugin.h b/src/dns-manager/nm-dns-plugin.h index d4298b86..37dd7336 100644 --- a/src/dns-manager/nm-dns-plugin.h +++ b/src/dns-manager/nm-dns-plugin.h @@ -53,7 +53,8 @@ typedef struct { const GSList *vpn_configs, const GSList *dev_configs, const GSList *other_configs, - const char *hostname); + const char *hostname, + const char *iface); /* Subclasses should override and return TRUE if they start a local * caching nameserver that listens on localhost and would block any @@ -91,7 +92,8 @@ gboolean nm_dns_plugin_update (NMDnsPlugin *self, const GSList *vpn_configs, const GSList *dev_configs, const GSList *other_configs, - const char *hostname); + const char *hostname, + const char *iface); /* For subclasses/plugins */ |