1 diff -up ntp-4.2.4p5/ntpd/ntp_io.c.rtnetlink ntp-4.2.4p5/ntpd/ntp_io.c
2 --- ntp-4.2.4p5/ntpd/ntp_io.c.rtnetlink 2008-08-28 16:02:21.000000000 +0200
3 +++ ntp-4.2.4p5/ntpd/ntp_io.c 2008-08-28 16:03:58.000000000 +0200
4 @@ -216,6 +216,9 @@ struct vsock {
5 ISC_LINK(vsock_t) link;
8 +#define HAS_ROUTING_SOCKET 1
9 +#define HAVE_RTNETLINK 1
11 #if !defined(HAVE_IO_COMPLETION_PORT) && defined(HAS_ROUTING_SOCKET)
13 * async notification processing (e. g. routing sockets)
14 @@ -3858,6 +3861,10 @@ find_flagged_addr_in_list(struct sockadd
15 #ifdef HAS_ROUTING_SOCKET
16 #include <net/route.h>
18 +#ifdef HAVE_RTNETLINK
19 +#include <linux/rtnetlink.h>
23 #define UPDATE_GRACE 2 /* wait UPDATE_GRACE seconds before scanning */
25 @@ -3866,9 +3873,12 @@ static void
26 process_routing_msgs(struct asyncio_reader *reader)
33 +#ifdef HAVE_RTNETLINK
34 + struct nlmsghdr *nh;
39 if (disable_dynamic_updates) {
41 @@ -3892,8 +3902,11 @@ process_routing_msgs(struct asyncio_read
43 * process routing message
45 - while ((p + sizeof(struct rt_msghdr)) <= (buffer + cnt))
47 +#ifdef HAVE_RTNETLINK
48 + for (nh = (struct nlmsghdr *)buffer; NLMSG_OK(nh, cnt); nh = NLMSG_NEXT(nh, cnt)) {
49 + msg_type = nh->nlmsg_type;
51 + for (p = buffer; (p + sizeof(struct rt_msghdr)) <= (buffer + cnt); p += rtm->rtm_msglen) {
52 struct rt_msghdr *rtm;
54 rtm = (struct rt_msghdr *)p;
55 @@ -3903,8 +3916,9 @@ process_routing_msgs(struct asyncio_read
56 delete_asyncio_reader(reader);
60 - switch (rtm->rtm_type) {
61 + msg_type = rtm->rtm_type;
67 @@ -3935,17 +3949,21 @@ process_routing_msgs(struct asyncio_read
69 * we are keen on new and deleted addresses and if an interface goes up and down or routing changes
71 - DPRINTF(3, ("routing message op = %d: scheduling interface update\n", rtm->rtm_type));
72 + DPRINTF(3, ("routing message op = %d: scheduling interface update\n", msg_type));
73 timer_interfacetimeout(current_time + UPDATE_GRACE);
75 +#ifdef HAVE_RTNETLINK
77 + /* end of multipart message */
82 * the rest doesn't bother us.
84 - DPRINTF(4, ("routing message op = %d: ignored\n", rtm->rtm_type));
85 + DPRINTF(4, ("routing message op = %d: ignored\n", msg_type));
88 - p += rtm->rtm_msglen;
92 @@ -3956,10 +3974,24 @@ static void
93 init_async_notifications()
95 struct asyncio_reader *reader;
96 +#ifdef HAVE_RTNETLINK
97 + int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
98 + struct sockaddr_nl sa;
100 int fd = socket(PF_ROUTE, SOCK_RAW, 0);
105 +#ifdef HAVE_RTNETLINK
106 + memset(&sa, 0, sizeof(sa));
107 + sa.nl_family = PF_NETLINK;
108 + sa.nl_groups = RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR;
109 + if (bind(fd, (struct sockaddr*)&sa, sizeof(sa)) < 0) {
110 + msyslog(LOG_ERR, "bind failed on routing socket (%m) - using polled interface update");
114 init_nonblocking_io(fd);
115 #if defined(HAVE_SIGNALED_IO)