Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.8 KiB

  1. From c123b58020c62535178051e11fd1867d4bb83459 Mon Sep 17 00:00:00 2001
  2. From: Brent Cook <busterb@gmail.com>
  3. Date: Tue, 30 Dec 2014 09:05:46 -0600
  4. Subject: [PATCH 04/12] check if rdomain support is available.
  5. ---
  6. src/usr.sbin/ntpd/parse.y | 2 ++
  7. src/usr.sbin/ntpd/server.c | 15 ++++++++++++++-
  8. 2 files changed, 16 insertions(+), 1 deletion(-)
  9. diff --git a/src/usr.sbin/ntpd/parse.y b/src/usr.sbin/ntpd/parse.y
  10. index 6d50795..33fe13d 100644
  11. --- a/src/usr.sbin/ntpd/parse.y
  12. +++ b/src/usr.sbin/ntpd/parse.y
  13. @@ -404,11 +404,13 @@ weight : WEIGHT NUMBER {
  14. opts.weight = $2;
  15. }
  16. rtable : RTABLE NUMBER {
  17. +#ifdef RT_TABLEID_MAX
  18. if ($2 < 0 || $2 > RT_TABLEID_MAX) {
  19. yyerror("rtable must be between 1"
  20. " and RT_TABLEID_MAX");
  21. YYERROR;
  22. }
  23. +#endif
  24. opts.rtable = $2;
  25. }
  26. ;
  27. diff --git a/src/usr.sbin/ntpd/server.c b/src/usr.sbin/ntpd/server.c
  28. index fb297d7..2e28b9b 100644
  29. --- a/src/usr.sbin/ntpd/server.c
  30. +++ b/src/usr.sbin/ntpd/server.c
  31. @@ -35,11 +35,16 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
  32. struct listen_addr *la, *nla, *lap;
  33. struct ifaddrs *ifa, *ifap;
  34. struct sockaddr *sa;
  35. +#ifdef SO_RTABLE
  36. struct if_data *ifd;
  37. +#endif
  38. u_int8_t *a6;
  39. size_t sa6len = sizeof(struct in6_addr);
  40. u_int new_cnt = 0;
  41. - int tos = IPTOS_LOWDELAY, rdomain = 0;
  42. + int tos = IPTOS_LOWDELAY;
  43. +#ifdef SO_RTABLE
  44. + int rdomain = 0;
  45. +#endif
  46. TAILQ_FOREACH(lap, &lconf->listen_addrs, entry) {
  47. switch (lap->sa.ss_family) {
  48. @@ -51,15 +56,19 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
  49. sa = ifap->ifa_addr;
  50. if (sa == NULL || SA_LEN(sa) == 0)
  51. continue;
  52. +#ifdef SO_RTABLE
  53. if (sa->sa_family == AF_LINK) {
  54. ifd = ifap->ifa_data;
  55. rdomain = ifd->ifi_rdomain;
  56. }
  57. +#endif
  58. if (sa->sa_family != AF_INET &&
  59. sa->sa_family != AF_INET6)
  60. continue;
  61. +#ifdef SO_RTABLE
  62. if (lap->rtable != -1 && rdomain != lap->rtable)
  63. continue;
  64. +#endif
  65. if (sa->sa_family == AF_INET &&
  66. ((struct sockaddr_in *)sa)->sin_addr.s_addr ==
  67. @@ -78,7 +87,9 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
  68. fatal("setup_listeners calloc");
  69. memcpy(&la->sa, sa, SA_LEN(sa));
  70. +#ifdef SO_RTABLE
  71. la->rtable = rdomain;
  72. +#endif
  73. TAILQ_INSERT_TAIL(&lconf->listen_addrs, la, entry);
  74. }
  75. @@ -123,10 +134,12 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
  76. IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) == -1)
  77. log_warn("setsockopt IPTOS_LOWDELAY");
  78. +#ifdef SO_RTABLE
  79. if (la->rtable != -1 &&
  80. setsockopt(la->fd, SOL_SOCKET, SO_RTABLE, &la->rtable,
  81. sizeof(la->rtable)) == -1)
  82. fatal("setup_listeners setsockopt SO_RTABLE");
  83. +#endif
  84. if (bind(la->fd, (struct sockaddr *)&la->sa,
  85. SA_LEN((struct sockaddr *)&la->sa)) == -1) {
  86. --
  87. 2.8.1