]> git.pld-linux.org Git - packages/ntp.git/blame - ntp-4.2.4p5-rtnetlink.patch
openssl rebuild
[packages/ntp.git] / ntp-4.2.4p5-rtnetlink.patch
CommitLineData
6fca7355
ER
1diff -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;
6 };
7
8+#define HAS_ROUTING_SOCKET 1
9+#define HAVE_RTNETLINK 1
10+
11 #if !defined(HAVE_IO_COMPLETION_PORT) && defined(HAS_ROUTING_SOCKET)
12 /*
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>
17
18+#ifdef HAVE_RTNETLINK
19+#include <linux/rtnetlink.h>
20+#endif
21+
22 #ifndef UPDATE_GRACE
23 #define UPDATE_GRACE 2 /* wait UPDATE_GRACE seconds before scanning */
24 #endif
25@@ -3866,9 +3873,12 @@ static void
26 process_routing_msgs(struct asyncio_reader *reader)
27 {
28 char buffer[5120];
29- char *p = buffer;
30-
31- int cnt;
32+ int cnt, msg_type;
33+#ifdef HAVE_RTNETLINK
34+ struct nlmsghdr *nh;
35+#else
36+ char *p;
37+#endif
38
39 if (disable_dynamic_updates) {
40 /*
41@@ -3892,8 +3902,11 @@ process_routing_msgs(struct asyncio_read
42 /*
43 * process routing message
44 */
45- while ((p + sizeof(struct rt_msghdr)) <= (buffer + cnt))
46- {
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;
50+#else
51+ for (p = buffer; (p + sizeof(struct rt_msghdr)) <= (buffer + cnt); p += rtm->rtm_msglen) {
52 struct rt_msghdr *rtm;
53
54 rtm = (struct rt_msghdr *)p;
55@@ -3903,8 +3916,9 @@ process_routing_msgs(struct asyncio_read
56 delete_asyncio_reader(reader);
57 return;
58 }
59-
60- switch (rtm->rtm_type) {
61+ msg_type = rtm->rtm_type;
62+#endif
63+ switch (msg_type) {
64 #ifdef RTM_NEWADDR
65 case RTM_NEWADDR:
66 #endif
67@@ -3935,17 +3949,21 @@ process_routing_msgs(struct asyncio_read
68 /*
69 * we are keen on new and deleted addresses and if an interface goes up and down or routing changes
70 */
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);
74 break;
75+#ifdef HAVE_RTNETLINK
76+ case NLMSG_DONE:
77+ /* end of multipart message */
78+ return;
79+#endif
80 default:
81 /*
82 * the rest doesn't bother us.
83 */
84- DPRINTF(4, ("routing message op = %d: ignored\n", rtm->rtm_type));
85+ DPRINTF(4, ("routing message op = %d: ignored\n", msg_type));
86 break;
87 }
88- p += rtm->rtm_msglen;
89 }
90 }
91
92@@ -3956,10 +3974,24 @@ static void
93 init_async_notifications()
94 {
95 struct asyncio_reader *reader;
96+#ifdef HAVE_RTNETLINK
97+ int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
98+ struct sockaddr_nl sa;
99+#else
100 int fd = socket(PF_ROUTE, SOCK_RAW, 0);
101+#endif
102
103 if (fd >= 0) {
104 fd = move_fd(fd);
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");
111+ return;
112+ }
113+#endif
114 init_nonblocking_io(fd);
115 #if defined(HAVE_SIGNALED_IO)
116 init_socket_sig(fd);
This page took 0.035794 seconds and 4 git commands to generate.