0004-Update-odhcp6c-from-Barrier-Breaker.patch 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Sat, 11 Jan 2014 11:47:58 +0100
  3. Subject: Update odhcp6c from Barrier Breaker
  4. diff --git a/package/odhcp6c/Makefile b/package/odhcp6c/Makefile
  5. index e767064..f18e7fa 100644
  6. --- a/package/odhcp6c/Makefile
  7. +++ b/package/odhcp6c/Makefile
  8. @@ -8,26 +8,37 @@
  9. include $(TOPDIR)/rules.mk
  10. PKG_NAME:=odhcp6c
  11. -PKG_VERSION:=2013-10-02
  12. -PKG_RELEASE=$(PKG_SOURCE_VERSION)-1
  13. +PKG_VERSION:=2014-04-09
  14. +PKG_RELEASE=$(PKG_SOURCE_VERSION)
  15. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  16. PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
  17. PKG_SOURCE_URL:=git://github.com/sbyx/odhcp6c.git
  18. PKG_SOURCE_PROTO:=git
  19. -PKG_SOURCE_VERSION:=357ecc1f5163bc7f74c64f4bca387e8d44a2eac5
  20. +PKG_SOURCE_VERSION:=6bbd2b0208fc17b6566595bfdfef2ff1d012d143
  21. PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
  22. include $(INCLUDE_DIR)/package.mk
  23. include $(INCLUDE_DIR)/cmake.mk
  24. +ifneq ($(CONFIG_PACKAGE_odhcp6c_ext_prefix_class),0)
  25. + CMAKE_OPTIONS += -DEXT_PREFIX_CLASS=$(CONFIG_PACKAGE_odhcp6c_ext_prefix_class)
  26. +endif
  27. +
  28. define Package/odhcp6c
  29. - SECTION:=ipv6
  30. - CATEGORY:=IPv6
  31. + SECTION:=net
  32. + CATEGORY:=Network
  33. TITLE:=Embedded DHCPv6-client for OpenWrt
  34. DEPENDS:=+kmod-ipv6
  35. endef
  36. +define Package/odhcp6c/config
  37. + config PACKAGE_odhcp6c_ext_prefix_class
  38. + int "Prefix Class Extension ID (0 = disabled)"
  39. + depends on PACKAGE_odhcp6c
  40. + default 0
  41. +endef
  42. +
  43. define Package/odhcp6c/install
  44. $(INSTALL_DIR) $(1)/usr/sbin/
  45. $(INSTALL_BIN) $(PKG_BUILD_DIR)/odhcp6c $(1)/usr/sbin/
  46. diff --git a/package/odhcp6c/files/dhcpv6.script b/package/odhcp6c/files/dhcpv6.script
  47. index 324a823..d228014 100755
  48. --- a/package/odhcp6c/files/dhcpv6.script
  49. +++ b/package/odhcp6c/files/dhcpv6.script
  50. @@ -64,23 +64,34 @@ setup_interface () {
  51. entry="${entry#*,}"
  52. local metric="${entry%%,*}"
  53. - proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid"
  54. + if [ -z "$SOURCE_ROUTING" -o -z "$gw" ]; then
  55. + proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid"
  56. + else
  57. + proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid" "::/128"
  58. + for prefix in $PREFIXES $ADDRESSES; do
  59. + local paddr="${prefix%%,*}"
  60. + proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid" "$paddr"
  61. + done
  62. + fi
  63. done
  64. + proto_add_data
  65. + [ -n "$CER" ] && json_add_string cer "$CER"
  66. + proto_close_data
  67. +
  68. proto_send_update "$INTERFACE"
  69. if [ -n "$AFTR_IP " -a -n "$IFACE_DSLITE" ]; then
  70. -uci -q batch <<-EOF >/dev/null
  71. -set network.$IFACE_DSLITE.proto=dslite
  72. -set network.$IFACE_DSLITE.auto=0
  73. -set network.$IFACE_DSLITE.peeraddr=$AFTR_IP
  74. -set network.$IFACE_DSLITE.tunlink=$INTERFACE
  75. -commit network
  76. -EOF
  77. -
  78. - ifdown "$IFACE_DSLITE"
  79. - /etc/init.d/network reload
  80. - ifup "$IFACE_DSLITE"
  81. + json_init
  82. + json_add_string name "$IFACE_DSLITE"
  83. + json_add_string ifname "@$INTERFACE"
  84. + json_add_string proto "dslite"
  85. + json_add_string peeraddr "$AFTR_IP"
  86. + json_add_string tunlink "$INTERFACE"
  87. + [ -n "$ZONE_DSLITE" ] && json_add_string zone "$ZONE_DSLITE"
  88. + [ -n "$IFACE_DSLITE_DELEGATE" ] && json_add_boolean delegate "$IFACE_DSLITE_DELEGATE"
  89. + json_close_object
  90. + ubus call network add_dynamic "$(json_dump)"
  91. fi
  92. # TODO: $SNTP_IP $SIP_IP $SNTP_FQDN $SIP_DOMAIN
  93. diff --git a/package/odhcp6c/files/dhcpv6.sh b/package/odhcp6c/files/dhcpv6.sh
  94. index bf6cd9a..90a8371 100755
  95. --- a/package/odhcp6c/files/dhcpv6.sh
  96. +++ b/package/odhcp6c/files/dhcpv6.sh
  97. @@ -5,23 +5,31 @@
  98. init_proto "$@"
  99. proto_dhcpv6_init_config() {
  100. - proto_config_add_string "reqaddress"
  101. - proto_config_add_string "reqprefix"
  102. - proto_config_add_string "clientid"
  103. - proto_config_add_string "reqopts"
  104. - proto_config_add_string "noslaaconly"
  105. - proto_config_add_string "norelease"
  106. - proto_config_add_string "ip6prefix"
  107. - proto_config_add_string "iface_dslite"
  108. - proto_config_add_string "ifaceid"
  109. + renew_handler=1
  110. +
  111. + proto_config_add_string 'reqaddress:or("try","force","none")'
  112. + proto_config_add_string 'reqprefix:or("auto","no",range(0, 64))'
  113. + proto_config_add_string clientid
  114. + proto_config_add_string 'reqopts:list(uinteger)'
  115. + proto_config_add_string 'noslaaconly:bool'
  116. + proto_config_add_string 'forceprefix:bool'
  117. + proto_config_add_string 'norelease:bool'
  118. + proto_config_add_string 'ip6prefix:ip6addr'
  119. + proto_config_add_string iface_dslite
  120. + proto_config_add_string zone_dslite
  121. + proto_config_add_string 'ifaceid:ip6addr'
  122. + proto_config_add_string 'sourcerouting:bool'
  123. + proto_config_add_string "userclass"
  124. + proto_config_add_string "vendorclass"
  125. + proto_config_add_boolean delegate
  126. }
  127. proto_dhcpv6_setup() {
  128. local config="$1"
  129. local iface="$2"
  130. - local reqaddress reqprefix clientid reqopts noslaaconly norelease ip6prefix iface_dslite ifaceid
  131. - json_get_vars reqaddress reqprefix clientid reqopts noslaaconly norelease ip6prefix iface_dslite ifaceid
  132. + local reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite ifaceid sourcerouting userclass vendorclass delegate zone_dslite
  133. + json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite ifaceid sourcerouting userclass vendorclass delegate zone_dslite
  134. # Configure
  135. @@ -35,16 +43,25 @@ proto_dhcpv6_setup() {
  136. [ "$noslaaconly" = "1" ] && append opts "-S"
  137. + [ "$forceprefix" = "1" ] && append opts "-F"
  138. +
  139. [ "$norelease" = "1" ] && append opts "-k"
  140. [ -n "$ifaceid" ] && append opts "-i$ifaceid"
  141. + [ -n "$vendorclass" ] && append opts "-V$vendorclass"
  142. +
  143. + [ -n "$userclass" ] && append opts "-u$userclass"
  144. +
  145. for opt in $reqopts; do
  146. append opts "-r$opt"
  147. done
  148. [ -n "$ip6prefix" ] && proto_export "USERPREFIX=$ip6prefix"
  149. [ -n "$iface_dslite" ] && proto_export "IFACE_DSLITE=$iface_dslite"
  150. + [ "$sourcerouting" != "0" ] && proto_export "SOURCE_ROUTING=1"
  151. + [ "$delegate" = "0" ] && proto_export "IFACE_DSLITE_DELEGATE=0"
  152. + [ -n "$zone_dslite" ] && proto_export "ZONE_DSLITE=$zone_dslite"
  153. proto_export "INTERFACE=$config"
  154. proto_run_command "$config" odhcp6c \
  155. @@ -52,6 +69,13 @@ proto_dhcpv6_setup() {
  156. $opts $iface
  157. }
  158. +proto_dhcpv6_renew() {
  159. + local interface="$1"
  160. + # SIGUSR1 forces odhcp6c to renew its lease
  161. + local sigusr1="$(kill -l SIGUSR1)"
  162. + [ -n "$sigusr1" ] && proto_kill_command "$interface" $sigusr1
  163. +}
  164. +
  165. proto_dhcpv6_teardown() {
  166. local interface="$1"
  167. proto_kill_command "$interface"
  168. diff --git a/package/odhcp6c/patches/001-fix-integer-overflow-after-50-days.patch b/package/odhcp6c/patches/001-fix-integer-overflow-after-50-days.patch
  169. deleted file mode 100644
  170. index 292d023..0000000
  171. --- a/package/odhcp6c/patches/001-fix-integer-overflow-after-50-days.patch
  172. +++ /dev/null
  173. @@ -1,25 +0,0 @@
  174. -From 5b98f902f616bd9b96a2128587bc6995555a43c1 Mon Sep 17 00:00:00 2001
  175. -From: Steven Barth <steven@midlink.org>
  176. -Date: Fri, 7 Mar 2014 10:33:49 +0100
  177. -Subject: [PATCH] fix integer overflow after 50 days (thx Hauke Mehrtens)
  178. -
  179. ----
  180. - src/odhcp6c.c | 2 +-
  181. - 1 file changed, 1 insertion(+), 1 deletion(-)
  182. -
  183. -diff --git a/src/odhcp6c.c b/src/odhcp6c.c
  184. -index 3c6b3b0..ba11ced 100644
  185. ---- a/src/odhcp6c.c
  186. -+++ b/src/odhcp6c.c
  187. -@@ -470,7 +470,7 @@ uint64_t odhcp6c_get_milli_time(void)
  188. - {
  189. - struct timespec t = {0, 0};
  190. - syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &t);
  191. -- return t.tv_sec * 1000 + t.tv_nsec / 1000000;
  192. -+ return ((uint64_t)t.tv_sec) * 1000 + ((uint64_t)t.tv_nsec) / 1000000;
  193. - }
  194. -
  195. -
  196. ---
  197. -1.7.10.4
  198. -