|
From c123b58020c62535178051e11fd1867d4bb83459 Mon Sep 17 00:00:00 2001
|
|
From: Brent Cook <busterb@gmail.com>
|
|
Date: Tue, 30 Dec 2014 09:05:46 -0600
|
|
Subject: [PATCH 04/12] check if rdomain support is available.
|
|
|
|
---
|
|
src/usr.sbin/ntpd/parse.y | 2 ++
|
|
src/usr.sbin/ntpd/server.c | 15 ++++++++++++++-
|
|
2 files changed, 16 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/usr.sbin/ntpd/parse.y b/src/usr.sbin/ntpd/parse.y
|
|
index 6d50795..33fe13d 100644
|
|
--- a/src/usr.sbin/ntpd/parse.y
|
|
+++ b/src/usr.sbin/ntpd/parse.y
|
|
@@ -404,11 +404,13 @@ weight : WEIGHT NUMBER {
|
|
opts.weight = $2;
|
|
}
|
|
rtable : RTABLE NUMBER {
|
|
+#ifdef RT_TABLEID_MAX
|
|
if ($2 < 0 || $2 > RT_TABLEID_MAX) {
|
|
yyerror("rtable must be between 1"
|
|
" and RT_TABLEID_MAX");
|
|
YYERROR;
|
|
}
|
|
+#endif
|
|
opts.rtable = $2;
|
|
}
|
|
;
|
|
diff --git a/src/usr.sbin/ntpd/server.c b/src/usr.sbin/ntpd/server.c
|
|
index fb297d7..2e28b9b 100644
|
|
--- a/src/usr.sbin/ntpd/server.c
|
|
+++ b/src/usr.sbin/ntpd/server.c
|
|
@@ -35,11 +35,16 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
|
|
struct listen_addr *la, *nla, *lap;
|
|
struct ifaddrs *ifa, *ifap;
|
|
struct sockaddr *sa;
|
|
+#ifdef SO_RTABLE
|
|
struct if_data *ifd;
|
|
+#endif
|
|
u_int8_t *a6;
|
|
size_t sa6len = sizeof(struct in6_addr);
|
|
u_int new_cnt = 0;
|
|
- int tos = IPTOS_LOWDELAY, rdomain = 0;
|
|
+ int tos = IPTOS_LOWDELAY;
|
|
+#ifdef SO_RTABLE
|
|
+ int rdomain = 0;
|
|
+#endif
|
|
|
|
TAILQ_FOREACH(lap, &lconf->listen_addrs, entry) {
|
|
switch (lap->sa.ss_family) {
|
|
@@ -51,15 +56,19 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
|
|
sa = ifap->ifa_addr;
|
|
if (sa == NULL || SA_LEN(sa) == 0)
|
|
continue;
|
|
+#ifdef SO_RTABLE
|
|
if (sa->sa_family == AF_LINK) {
|
|
ifd = ifap->ifa_data;
|
|
rdomain = ifd->ifi_rdomain;
|
|
}
|
|
+#endif
|
|
if (sa->sa_family != AF_INET &&
|
|
sa->sa_family != AF_INET6)
|
|
continue;
|
|
+#ifdef SO_RTABLE
|
|
if (lap->rtable != -1 && rdomain != lap->rtable)
|
|
continue;
|
|
+#endif
|
|
|
|
if (sa->sa_family == AF_INET &&
|
|
((struct sockaddr_in *)sa)->sin_addr.s_addr ==
|
|
@@ -78,7 +87,9 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
|
|
fatal("setup_listeners calloc");
|
|
|
|
memcpy(&la->sa, sa, SA_LEN(sa));
|
|
+#ifdef SO_RTABLE
|
|
la->rtable = rdomain;
|
|
+#endif
|
|
|
|
TAILQ_INSERT_TAIL(&lconf->listen_addrs, la, entry);
|
|
}
|
|
@@ -123,10 +134,12 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
|
|
IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) == -1)
|
|
log_warn("setsockopt IPTOS_LOWDELAY");
|
|
|
|
+#ifdef SO_RTABLE
|
|
if (la->rtable != -1 &&
|
|
setsockopt(la->fd, SOL_SOCKET, SO_RTABLE, &la->rtable,
|
|
sizeof(la->rtable)) == -1)
|
|
fatal("setup_listeners setsockopt SO_RTABLE");
|
|
+#endif
|
|
|
|
if (bind(la->fd, (struct sockaddr *)&la->sa,
|
|
SA_LEN((struct sockaddr *)&la->sa)) == -1) {
|
|
--
|
|
2.8.1
|
|
|