From: Frank Kardel Date: Sun, 30 Sep 2007 16:05:00 +0000 (+0000) Subject: ntp_io.c: X-Git-Tag: NTP_4_2_5P81~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45dfa453c516234a7e7db3f848e5ba8ba3a4c2c9;p=thirdparty%2Fntp.git ntp_io.c: Bug 912: detect conflicting enable/disable configuration on interfaces sharing an IP address ChangeLog: [Bug 912] detect conflicting enable/disable configuration on interfaces sharing an IP address bk: 46ffc92cInDxBxi75cWEuhUgRDcVoQ --- diff --git a/ChangeLog b/ChangeLog index cc40f91e8..dc0d12526 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* [Bug 912] detect conflicting enable/disable configuration on interfaces sharing an IP address * [Bug 771] compare scopeid if available for IPv6 addresses * [Bug 899] Only show -i/--jaildir -u/--user options if we HAVE_DROPROOT. * [Bug 916] 'cryptosw' is undefined if built without OpenSSL. diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 8544a1ec1..545b42182 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -603,7 +603,7 @@ print_interface(struct interface *iface, char *pfx, char *sfx) iface->flags, iface->scopeid, iface->ifindex); - /* Leave these as three printf calls. */ + /* Leave these as three printf calls (stoa() static buffer). */ printf(", sin=%s", stoa((&iface->sin))); if (iface->flags & INT_BROADCAST) @@ -1275,9 +1275,46 @@ update_interfaces( /* * found existing and up to date interface - mark present */ + if (iface->phase != sys_interphase) + { + /* + * on a new round we reset the name so the interface name + * shows up again if this address is not shared any more + * same reasoning goes for the enable flag + */ + strcpy(iface->name, interface.name); + iface->ignore_packets = interface.ignore_packets; + } else { + /* + * name collision - rename interface name to "*multiple*" + */ + strcpy(iface->name, "*multiple*"); + } - iface->phase = sys_interphase; DPRINT_INTERFACE(4, (iface, "updating ", " present\n")); + + if (iface->ignore_packets != interface.ignore_packets) + { + /* + * We have conflicting configurations for the interface address. + * This is caused by using -I for an interface + * that shares it address with other interfaces. We cannot disambiguate + * incoming pakets being delivered to this socket without extra + * syscalls/features. These are not (commonly) available. + * Note is is a more unusual configuration where several interfaces + * share an address but filtering via interface name is attempted. + * We resolve the configuration conflict by disabling the reception + * of pakets. This leads to a basically non-functional service on the + * interface address where the conflict occurs. + */ + msyslog(LOG_ERR, "WARNING: conflicting enable configuration for interfaces %s and %s for address %s - unsupported configuration - address DISABLED", + interface.name, iface->name, stoa(&interface.sin)); + + iface->ignore_packets = ISC_TRUE; + } + + iface->phase = sys_interphase; + ifi.action = IFS_EXISTS; ifi.interface = iface; if (receiver)