1
0

0027-Fix-e7bfd556c079c8b5e7425aed44abc35925b24043-to-actu.patch 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. From 9c0d445ef4abffa2b9342ad65e85ef425c1f83bb Mon Sep 17 00:00:00 2001
  2. From: Simon Kelley <simon@thekelleys.org.uk>
  3. Date: Wed, 9 Jan 2019 17:57:56 +0000
  4. Subject: [PATCH 27/32] Fix e7bfd556c079c8b5e7425aed44abc35925b24043 to
  5. actually work.
  6. Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
  7. ---
  8. src/dhcp.c | 54 +++++++++++++++++++++++++----------------------------
  9. src/dhcp6.c | 2 +-
  10. 2 files changed, 26 insertions(+), 30 deletions(-)
  11. --- a/src/dhcp.c
  12. +++ b/src/dhcp.c
  13. @@ -754,19 +754,6 @@ int address_allocate(struct dhcp_context
  14. if (addr.s_addr == d->router.s_addr)
  15. break;
  16. - /* in consec-ip mode, skip addresses equal to
  17. - the number of addresses rejected by clients. This
  18. - should avoid the same client being offered the same
  19. - address after it has rjected it. */
  20. - if (option_bool(OPT_CONSEC_ADDR))
  21. - {
  22. - if (c->addr_epoch)
  23. - {
  24. - c->addr_epoch--;
  25. - d = context; /* d non-NULL skips the address. */
  26. - }
  27. - }
  28. -
  29. /* Addresses which end in .255 and .0 are broken in Windows even when using
  30. supernetting. ie dhcp-range=192.168.0.1,192.168.1.254,255,255,254.0
  31. then 192.168.0.255 is a valid IP address, but not for Windows as it's
  32. @@ -778,24 +765,33 @@ int address_allocate(struct dhcp_context
  33. (!IN_CLASSC(ntohl(addr.s_addr)) ||
  34. ((ntohl(addr.s_addr) & 0xff) != 0xff && ((ntohl(addr.s_addr) & 0xff) != 0x0))))
  35. {
  36. - struct ping_result *r;
  37. -
  38. - if ((r = do_icmp_ping(now, addr, j, loopback)))
  39. - {
  40. - /* consec-ip mode: we offered this address for another client
  41. - (different hash) recently, don't offer it to this one. */
  42. - if (!option_bool(OPT_CONSEC_ADDR) || r->hash == j)
  43. - {
  44. - *addrp = addr;
  45. - return 1;
  46. - }
  47. - }
  48. + /* in consec-ip mode, skip addresses equal to
  49. + the number of addresses rejected by clients. This
  50. + should avoid the same client being offered the same
  51. + address after it has rjected it. */
  52. + if (option_bool(OPT_CONSEC_ADDR) && c->addr_epoch)
  53. + c->addr_epoch--;
  54. else
  55. {
  56. - /* address in use: perturb address selection so that we are
  57. - less likely to try this address again. */
  58. - if (!option_bool(OPT_CONSEC_ADDR))
  59. - c->addr_epoch++;
  60. + struct ping_result *r;
  61. +
  62. + if ((r = do_icmp_ping(now, addr, j, loopback)))
  63. + {
  64. + /* consec-ip mode: we offered this address for another client
  65. + (different hash) recently, don't offer it to this one. */
  66. + if (!option_bool(OPT_CONSEC_ADDR) || r->hash == j)
  67. + {
  68. + *addrp = addr;
  69. + return 1;
  70. + }
  71. + }
  72. + else
  73. + {
  74. + /* address in use: perturb address selection so that we are
  75. + less likely to try this address again. */
  76. + if (!option_bool(OPT_CONSEC_ADDR))
  77. + c->addr_epoch++;
  78. + }
  79. }
  80. }
  81. --- a/src/dhcp6.c
  82. +++ b/src/dhcp6.c
  83. @@ -436,7 +436,7 @@ struct dhcp_context *address6_allocate(s
  84. skip addresses equal to the number of addresses rejected
  85. by clients. This should avoid the same client being offered the same
  86. address after it has rjected it. */
  87. - start = lease_find_max_addr6(c) + serial + c->addr_epoch;
  88. + start = lease_find_max_addr6(c) + 1 + serial + c->addr_epoch;
  89. if (c->addr_epoch)
  90. c->addr_epoch--;
  91. }