Discussion:
[avahi] Service Name Conflicts
Timothy Potter
2018-01-26 14:50:59 UTC
Permalink
I have several Linux machines all running kernel version 3.12 and avahi-daemon 0.6.31. Each machine has a unique host name and they are all advertising an ssh, sftp, and http. When I start all the machines up everything runs just fine. If one of the machines gets re-booted, when the avahi-daemon on that machine starts up again, it reports service conflicts every couple of seconds:

Jun 1 16:20:12 Node00b01973d6c8 daemon.notice avahi-daemon[1624]: Service name conflict for "%h" (/services/ssh.service), retrying with "Node00b01973d6c8 #2".
Jun 1 16:20:12 Node00b01973d6c8 daemon.notice avahi-daemon[1624]: Service name conflict for "%h" (/services/http.service), retrying with "Node00b01973d6c8 #2".
Jun 1 16:20:32 Node00b01973d6c8 daemon.notice avahi-daemon[1624]: Service name conflict for "%h" (/services/sftp-ssh.service), retrying with "Node00b01973d6c8 #2".

These message print every few seconds. The only way I have been able to make them go away is to reboot all the machines running the avahi-daemon. Any suggestions on how to fix this?
Timothy Potter
2018-01-31 14:10:15 UTC
Permalink
I think I have found the issue.

My service file is setup like this:

<!-- See avahi.service(5) for more information about this configuration file -->

<service-group>

<name replace-wildcards="yes">%h</name>

<service protocol="ipv6">
<type>_http._tcp</type>
<port>80</port>
</service>

</service-group>


In the file

avahi-daemon/static-services.c

function: entry_group_callback, if a conflict is detected a new name is created and stored in g->chosen_name and an attempt is made to add the service again with this new name.

case AVAHI_ENTRY_GROUP_COLLISION: {
char *n;

remove_static_service_group_from_server(g);

n = avahi_alternative_service_name(g->chosen_name);
avahi_free(g->chosen_name);
g->chosen_name = n;

avahi_log_notice("Service name conflict for \"%s\" (%s), retrying with \"%s\".", g->name, g->filename, g->chosen_name);

add_static_service_group_to_server(g);
break;
}


The problem is in add_static_service_group_to_server. There is an if to see if g->chosen_name = NULL or if the replace-wildcards is set to yes. If either of those are true ( in my chase it is ) it then frees the g->chosen_name and rebuilds it with the same name that was in conflict to begin with. It never tries to add the service with the new service name so I continually receive the “Service name conflict”.

static void add_static_service_group_to_server(StaticServiceGroup *g) {
StaticService *s;

assert(g);

if (g->entry_group && !avahi_s_entry_group_is_empty(g->entry_group))
/* This service group is already registered in the server */
return;

if (!g->chosen_name || (g->replace_wildcards && strstr(g->name, "%h"))) {

avahi_free(g->chosen_name);

if (g->replace_wildcards) {
char label[AVAHI_LABEL_MAX];
const char *p;

p = avahi_server_get_host_name(avahi_server);
avahi_unescape_label(&p, label, sizeof(label));

g->chosen_name = replacestr(g->name, "%h", label);
} else
g->chosen_name = avahi_strdup(g->name);

}
Post by Timothy Potter
Jun 1 16:20:12 Node00b01973d6c8 daemon.notice avahi-daemon[1624]: Service name conflict for "%h" (/services/ssh.service), retrying with "Node00b01973d6c8 #2".
Jun 1 16:20:12 Node00b01973d6c8 daemon.notice avahi-daemon[1624]: Service name conflict for "%h" (/services/http.service), retrying with "Node00b01973d6c8 #2".
Jun 1 16:20:32 Node00b01973d6c8 daemon.notice avahi-daemon[1624]: Service name conflict for "%h" (/services/sftp-ssh.service), retrying with "Node00b01973d6c8 #2".
These message print every few seconds. The only way I have been able to make them go away is to reboot all the machines running the avahi-daemon. Any suggestions on how to fix this?
Timothy Potter
2018-01-31 15:00:54 UTC
Permalink
Post by Timothy Potter
‘
if (!g->chosen_name || (g->replace_wildcards && strstr(g->name, "%h"))) {
to
Post by Timothy Potter
if (!g->chosen_name && (g->replace_wildcards && strstr(g->name, "%h"))) {
seems to fix the issue.
Post by Timothy Potter
I think I have found the issue.
<!-- See avahi.service(5) for more information about this configuration file -->
<service-group>
<name replace-wildcards="yes">%h</name>
<service protocol="ipv6">
<type>_http._tcp</type>
<port>80</port>
</service>
</service-group>
In the file
avahi-daemon/static-services.c
function: entry_group_callback, if a conflict is detected a new name is created and stored in g->chosen_name and an attempt is made to add the service again with this new name.
case AVAHI_ENTRY_GROUP_COLLISION: {
char *n;
remove_static_service_group_from_server(g);
n = avahi_alternative_service_name(g->chosen_name);
avahi_free(g->chosen_name);
g->chosen_name = n;
avahi_log_notice("Service name conflict for \"%s\" (%s), retrying with \"%s\".", g->name, g->filename, g->chosen_name);
add_static_service_group_to_server(g);
break;
}
The problem is in add_static_service_group_to_server. There is an if to see if g->chosen_name = NULL or if the replace-wildcards is set to yes. If either of those are true ( in my chase it is ) it then frees the g->chosen_name and rebuilds it with the same name that was in conflict to begin with. It never tries to add the service with the new service name so I continually receive the “Service name conflict”.
static void add_static_service_group_to_server(StaticServiceGroup *g) {
StaticService *s;
assert(g);
if (g->entry_group && !avahi_s_entry_group_is_empty(g->entry_group))
/* This service group is already registered in the server */
return;
if (!g->chosen_name || (g->replace_wildcards && strstr(g->name, "%h"))) {
avahi_free(g->chosen_name);
if (g->replace_wildcards) {
char label[AVAHI_LABEL_MAX];
const char *p;
p = avahi_server_get_host_name(avahi_server);
avahi_unescape_label(&p, label, sizeof(label));
g->chosen_name = replacestr(g->name, "%h", label);
} else
g->chosen_name = avahi_strdup(g->name);
}
Post by Timothy Potter
Jun 1 16:20:12 Node00b01973d6c8 daemon.notice avahi-daemon[1624]: Service name conflict for "%h" (/services/ssh.service), retrying with "Node00b01973d6c8 #2".
Jun 1 16:20:12 Node00b01973d6c8 daemon.notice avahi-daemon[1624]: Service name conflict for "%h" (/services/http.service), retrying with "Node00b01973d6c8 #2".
Jun 1 16:20:32 Node00b01973d6c8 daemon.notice avahi-daemon[1624]: Service name conflict for "%h" (/services/sftp-ssh.service), retrying with "Node00b01973d6c8 #2".
These message print every few seconds. The only way I have been able to make them go away is to reboot all the machines running the avahi-daemon. Any suggestions on how to fix this?
Loading...