dhcp-4.2.0-PPP.patch 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. diff -up dhcp-4.2.0-P1/client/dhc6.c.PPP dhcp-4.2.0-P1/client/dhc6.c
  2. --- dhcp-4.2.0-P1/client/dhc6.c.PPP 2010-11-05 10:47:37.000000000 +0100
  3. +++ dhcp-4.2.0-P1/client/dhc6.c 2010-11-09 15:54:12.000000000 +0100
  4. @@ -129,7 +129,7 @@ extern int stateless;
  5. * is not how it is intended. Upcoming rearchitecting the client should
  6. * address this "one daemon model."
  7. */
  8. -void
  9. +isc_result_t
  10. form_duid(struct data_string *duid, const char *file, int line)
  11. {
  12. struct interface_info *ip;
  13. @@ -141,6 +141,15 @@ form_duid(struct data_string *duid, cons
  14. if (ip == NULL)
  15. log_fatal("Impossible condition at %s:%d.", MDL);
  16. + while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
  17. + /* Try the other interfaces */
  18. + log_debug("Cannot form default DUID from interface %s.", ip->name);
  19. + ip = ip->next;
  20. + }
  21. + if (ip == NULL) {
  22. + return ISC_R_UNEXPECTED;
  23. + }
  24. +
  25. if ((ip->hw_address.hlen == 0) ||
  26. (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
  27. log_fatal("Impossible hardware address length at %s:%d.", MDL);
  28. @@ -176,6 +185,8 @@ form_duid(struct data_string *duid, cons
  29. memcpy(duid->buffer->data + 4, ip->hw_address.hbuf + 1,
  30. ip->hw_address.hlen - 1);
  31. }
  32. +
  33. + return ISC_R_SUCCESS;
  34. }
  35. /*
  36. @@ -5289,7 +5300,8 @@ make_client6_options(struct client_state
  37. */
  38. if ((oc = lookup_option(&dhcpv6_universe, *op,
  39. D6O_CLIENTID)) == NULL) {
  40. - if (!option_cache(&oc, &default_duid, NULL, clientid_option,
  41. + if (default_duid.len == 0 ||
  42. + !option_cache(&oc, &default_duid, NULL, clientid_option,
  43. MDL))
  44. log_fatal("Failure assembling a DUID.");
  45. diff -up dhcp-4.2.0-P1/client/dhclient.c.PPP dhcp-4.2.0-P1/client/dhclient.c
  46. --- dhcp-4.2.0-P1/client/dhclient.c.PPP 2010-11-05 10:47:37.000000000 +0100
  47. +++ dhcp-4.2.0-P1/client/dhclient.c 2010-11-09 15:37:26.000000000 +0100
  48. @@ -911,8 +911,8 @@ main(int argc, char **argv) {
  49. if (default_duid.buffer != NULL)
  50. data_string_forget(&default_duid, MDL);
  51. - form_duid(&default_duid, MDL);
  52. - write_duid(&default_duid);
  53. + if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
  54. + write_duid(&default_duid);
  55. }
  56. for (ip = interfaces ; ip != NULL ; ip = ip->next) {
  57. diff -up dhcp-4.2.0-P1/common/bpf.c.PPP dhcp-4.2.0-P1/common/bpf.c
  58. --- dhcp-4.2.0-P1/common/bpf.c.PPP 2010-11-05 10:47:37.000000000 +0100
  59. +++ dhcp-4.2.0-P1/common/bpf.c 2010-11-09 15:42:42.000000000 +0100
  60. @@ -599,6 +599,22 @@ get_hw_addr(const char *name, struct har
  61. memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
  62. break;
  63. #endif /* IFT_FDDI */
  64. +#if defined(IFT_PPP)
  65. + case IFT_PPP:
  66. + if (local_family != AF_INET6)
  67. + log_fatal("Unsupported device type %d for \"%s\"",
  68. + sa->sdl_type, name);
  69. + hw->hlen = 0;
  70. + hw->hbuf[0] = HTYPE_RESERVED;
  71. + /* 0xdeadbeef should never occur on the wire,
  72. + * and is a signature that something went wrong.
  73. + */
  74. + hw->hbuf[1] = 0xde;
  75. + hw->hbuf[2] = 0xad;
  76. + hw->hbuf[3] = 0xbe;
  77. + hw->hbuf[4] = 0xef;
  78. + break;
  79. +#endif
  80. default:
  81. log_fatal("Unsupported device type %d for \"%s\"",
  82. sa->sdl_type, name);
  83. diff -up dhcp-4.2.0-P1/common/lpf.c.PPP dhcp-4.2.0-P1/common/lpf.c
  84. --- dhcp-4.2.0-P1/common/lpf.c.PPP 2010-11-05 10:47:37.000000000 +0100
  85. +++ dhcp-4.2.0-P1/common/lpf.c 2010-11-09 15:45:40.000000000 +0100
  86. @@ -502,6 +502,22 @@ get_hw_addr(const char *name, struct har
  87. hw->hbuf[0] = HTYPE_FDDI;
  88. memcpy(&hw->hbuf[1], sa->sa_data, 16);
  89. break;
  90. +#if defined(ARPHRD_PPP)
  91. + case ARPHRD_PPP:
  92. + if (local_family != AF_INET6)
  93. + log_fatal("Unsupported device type %d for \"%s\"",
  94. + sa->sa_family, name);
  95. + hw->hlen = 0;
  96. + hw->hbuf[0] = HTYPE_RESERVED;
  97. + /* 0xdeadbeef should never occur on the wire,
  98. + * and is a signature that something went wrong.
  99. + */
  100. + hw->hbuf[1] = 0xde;
  101. + hw->hbuf[2] = 0xad;
  102. + hw->hbuf[3] = 0xbe;
  103. + hw->hbuf[4] = 0xef;
  104. + break;
  105. +#endif
  106. default:
  107. log_fatal("Unsupported device type %ld for \"%s\"",
  108. (long int)sa->sa_family, name);
  109. diff -up dhcp-4.2.0-P1/includes/dhcpd.h.PPP dhcp-4.2.0-P1/includes/dhcpd.h
  110. --- dhcp-4.2.0-P1/includes/dhcpd.h.PPP 2010-11-05 10:47:37.000000000 +0100
  111. +++ dhcp-4.2.0-P1/includes/dhcpd.h 2010-11-09 15:46:58.000000000 +0100
  112. @@ -2733,7 +2733,7 @@ void dhcpv4_client_assignments(void);
  113. void dhcpv6_client_assignments(void);
  114. /* dhc6.c */
  115. -void form_duid(struct data_string *duid, const char *file, int line);
  116. +isc_result_t form_duid(struct data_string *duid, const char *file, int line);
  117. void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line);
  118. void start_init6(struct client_state *client);
  119. void start_info_request6(struct client_state *client);
  120. diff -up dhcp-4.2.0-P1/includes/dhcp.h.PPP dhcp-4.2.0-P1/includes/dhcp.h
  121. --- dhcp-4.2.0-P1/includes/dhcp.h.PPP 2010-11-05 10:47:37.000000000 +0100
  122. +++ dhcp-4.2.0-P1/includes/dhcp.h 2010-11-09 15:48:53.000000000 +0100
  123. @@ -80,6 +80,8 @@ struct dhcp_packet {
  124. #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */
  125. #define HTYPE_FDDI 8 /* FDDI... */
  126. +#define HTYPE_RESERVED 0 /* RFC 5494 */
  127. +
  128. /* Magic cookie validating dhcp options field (and bootp vendor
  129. extensions field). */
  130. #define DHCP_OPTIONS_COOKIE "\143\202\123\143"
  131. diff -up dhcp-4.2.0-P1/server/dhcpv6.c.PPP dhcp-4.2.0-P1/server/dhcpv6.c
  132. --- dhcp-4.2.0-P1/server/dhcpv6.c.PPP 2010-11-05 10:47:37.000000000 +0100
  133. +++ dhcp-4.2.0-P1/server/dhcpv6.c 2010-11-09 15:50:17.000000000 +0100
  134. @@ -300,6 +300,9 @@ generate_new_server_duid(void) {
  135. if (p->hw_address.hlen > 0) {
  136. break;
  137. }
  138. + if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
  139. + log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
  140. + }
  141. }
  142. if (p == NULL) {
  143. return ISC_R_UNEXPECTED;