Date: Fri, 27 Sep 2002 13:50:04 -0700 (PDT) From: marius@alchemy.franken.de To: freebsd-bugs@FreeBSD.org Subject: Re: i386/39327: bind ntpd to only one IP Message-ID: <200209272050.g8RKo4FL036618@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR i386/39327; it has been noted by GNATS. From: marius@alchemy.franken.de To: freebsd-gnats-submit@FreeBSD.org Cc: fbsd@koethe.net, marck@rinet.ru, "."@babolo.ru, dougb@FreeBSD.org Subject: Re: i386/39327: bind ntpd to only one IP Date: Fri, 27 Sep 2002 22:42:18 +0200 --9s922KAXlWjPfK/Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, the patch at http://free.babolo.ru/patch/src.usr.sbin.ntp.patch doesn't work, it makes ntpd to only bind to the address specified with "-h" but then ntpd just sits there and apparently does nothing. The patch Dmitry submitted as a followup does work, however I think adding a "-h" flag is the wrong approach. Ntpd already only binds to the first IP-address of an interface if there are aliases on BSD/OS: ntp_io.c around line 306: /* * look for an already existing source interface address. If * the machine has multiple point to point interfaces, then * the local address may appear more than once. * * A second problem exists if we have two addresses on * the same network (via "ifconfig alias ..."). Don't * make two xntp interfaces for the two aliases on the * one physical interface. -wsr */ for (j=0; j < i; j++) if (inter_list[j].sin.sin_addr.s_addr & inter_list[j].mask.sin_addr.s_addr == inter_list[i].sin.sin_addr.s_addr & inter_list[i].mask.sin_addr.s_addr) { if (inter_list[j].flags & INT_LOOPBACK) inter_list[j] = inter_list[i]; break; } NetBSD once fixed this for xntpd: http://cvsweb.netbsd.org/bsdweb.cgi/basesrc/usr.sbin/xntp/xntpd/Attic/ntp_io.c?rev=1.10&content-type=text/x-cvsweb-markup and now use and fixed the BSD/OS code: http://cvsweb.netbsd.org/bsdweb.cgi/basesrc/dist/ntp/ntpd/ntp_io.c?rev=1.6&content-type=text/x-cvsweb-markup Unfortunately their code doesn't work on FreeBSD to also determine aliases because FreeBSD does not use the same netmask for aliases as for the non- alias IP-address (like BSD/OS, NetBSD, OpenBSD, ...) but 0xffffffff. Therefore I think something like the attached should be commited. This isn't exactly what a "-h" would offer but fixes ntpd for usage in a jail host (which IMHO is the main concern here). --9s922KAXlWjPfK/Q Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ntp_io.c.diff" --- ntp_io.c.orig Fri Sep 27 16:29:34 2002 +++ ntp_io.c Fri Sep 27 22:09:46 2002 @@ -579,10 +579,32 @@ * look for an already existing source interface address. If * the machine has multiple point to point interfaces, then * the local address may appear more than once. + * + * A second problem exists if we have two addresses on + * the same network (via "ifconfig alias ..."). Don't + * make two xntp interfaces for the two aliases on the + * one physical interface. -wsr */ for (j=0; j < i; j++) - if (inter_list[j].sin.sin_addr.s_addr == - inter_list[i].sin.sin_addr.s_addr) { + if (((inter_list[j].sin.sin_addr.s_addr & + inter_list[j].mask.sin_addr.s_addr) == + (inter_list[i].sin.sin_addr.s_addr & + inter_list[i].mask.sin_addr.s_addr)) +#ifdef __FreeBSD__ + /* + * FreeBSD uses a mask of 0xffffffff for aliases, + * therefore we check if the address is in the same + * subnet as an already existing source interface + * address. + */ + || ((inter_list[j].sin.sin_addr.s_addr & + inter_list[j].mask.sin_addr.s_addr) == + (inter_list[i].sin.sin_addr.s_addr & + inter_list[j].mask.sin_addr.s_addr)) +#endif + ) { + if (inter_list[j].flags & INT_LOOPBACK) + inter_list[j] = inter_list[i]; break; } if (j == i) --9s922KAXlWjPfK/Q-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209272050.g8RKo4FL036618>