0004-Update-odhcp6c-from-Barrier-Breaker-r41447.patch 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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 (r41447)
  4. diff --git a/package/odhcp6c/Makefile b/package/odhcp6c/Makefile
  5. index e767064..7ad9bd2 100644
  6. --- a/package/odhcp6c/Makefile
  7. +++ b/package/odhcp6c/Makefile
  8. @@ -8,26 +8,55 @@
  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-06-04
  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:=26c5466e626735f27dd073b727b02612c5a807cd
  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. +ifneq ($(CONFIG_PACKAGE_odhcp6c_ext_cer_id),0)
  29. + CMAKE_OPTIONS += -DEXT_CER_ID=$(CONFIG_PACKAGE_odhcp6c_ext_cer_id)
  30. +endif
  31. +
  32. +ifneq ($(CONFIG_PACKAGE_odhcp6c_ext_s46),0)
  33. + CMAKE_OPTIONS += -DEXT_S46=$(CONFIG_PACKAGE_odhcp6c_ext_s46)
  34. +endif
  35. +
  36. define Package/odhcp6c
  37. - SECTION:=ipv6
  38. - CATEGORY:=IPv6
  39. + SECTION:=net
  40. + CATEGORY:=Network
  41. TITLE:=Embedded DHCPv6-client for OpenWrt
  42. DEPENDS:=+kmod-ipv6
  43. endef
  44. +define Package/odhcp6c/config
  45. + config PACKAGE_odhcp6c_ext_prefix_class
  46. + int "Prefix Class Extension ID (0 = disabled)"
  47. + depends on PACKAGE_odhcp6c
  48. + default 0
  49. +
  50. + config PACKAGE_odhcp6c_ext_cer_id
  51. + int "CER-ID Extension ID (0 = disabled)"
  52. + depends on PACKAGE_odhcp6c
  53. + default 0
  54. +
  55. + config PACKAGE_odhcp6c_ext_s46
  56. + int "Softwire MAP Extension ID (0 = disabled)"
  57. + depends on PACKAGE_odhcp6c
  58. + default 0
  59. +endef
  60. +
  61. define Package/odhcp6c/install
  62. $(INSTALL_DIR) $(1)/usr/sbin/
  63. $(INSTALL_BIN) $(PKG_BUILD_DIR)/odhcp6c $(1)/usr/sbin/
  64. diff --git a/package/odhcp6c/files/dhcpv6.script b/package/odhcp6c/files/dhcpv6.script
  65. index 324a823..42c67c1 100755
  66. --- a/package/odhcp6c/files/dhcpv6.script
  67. +++ b/package/odhcp6c/files/dhcpv6.script
  68. @@ -64,23 +64,63 @@ setup_interface () {
  69. entry="${entry#*,}"
  70. local metric="${entry%%,*}"
  71. - proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid"
  72. + if [ -z "$SOURCE_ROUTING" -o -z "$gw" ]; then
  73. + proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid"
  74. + else
  75. + proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid" "::/128"
  76. + for prefix in $PREFIXES $ADDRESSES; do
  77. + local paddr="${prefix%%,*}"
  78. + proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid" "$paddr"
  79. + done
  80. + fi
  81. done
  82. + proto_add_data
  83. + [ -n "$CER" ] && json_add_string cer "$CER"
  84. + [ -n "$PASSTHRU" ] && json_add_string passthru "$PASSTHRU"
  85. + proto_close_data
  86. +
  87. proto_send_update "$INTERFACE"
  88. if [ -n "$AFTR_IP " -a -n "$IFACE_DSLITE" ]; then
  89. -uci -q batch <<-EOF >/dev/null
  90. -set network.$IFACE_DSLITE.proto=dslite
  91. -set network.$IFACE_DSLITE.auto=0
  92. -set network.$IFACE_DSLITE.peeraddr=$AFTR_IP
  93. -set network.$IFACE_DSLITE.tunlink=$INTERFACE
  94. -commit network
  95. -EOF
  96. -
  97. - ifdown "$IFACE_DSLITE"
  98. - /etc/init.d/network reload
  99. - ifup "$IFACE_DSLITE"
  100. + json_init
  101. + json_add_string name "$IFACE_DSLITE"
  102. + json_add_string ifname "@$INTERFACE"
  103. + json_add_string proto "dslite"
  104. + json_add_string peeraddr "$AFTR_IP"
  105. + json_add_string tunlink "$INTERFACE"
  106. + [ -n "$ZONE_DSLITE" ] && json_add_string zone "$ZONE_DSLITE"
  107. + [ -n "$IFACE_DSLITE_DELEGATE" ] && json_add_boolean delegate "$IFACE_DSLITE_DELEGATE"
  108. + json_close_object
  109. + ubus call network add_dynamic "$(json_dump)"
  110. + fi
  111. +
  112. + MAPTYPE=""
  113. + MAPRULE=""
  114. +
  115. + if [ -n "$MAPE" ]; then
  116. + MAPTYPE="map-e"
  117. + MAPRULE="$MAPE"
  118. + elif [ -n "$MAPT" ]; then
  119. + MAPTYPE="map-t"
  120. + MAPRULE="$MAPT"
  121. + elif [ -n "$LW4O6" ]; then
  122. + MAPTYPE="lw4o6"
  123. + MAPRULE="$LW4O6"
  124. + fi
  125. +
  126. + if [ -n "$IFACE_MAP" -a -n "$MAPTYPE" -a -n "$MAPRULE" ]; then
  127. + json_init
  128. + json_add_string name "$IFACE_MAP"
  129. + json_add_string ifname "@$INTERFACE"
  130. + json_add_string proto map
  131. + json_add_string type "$MAPTYPE"
  132. + json_add_string rule "$MAPRULE"
  133. + json_add_string tunlink "$INTERFACE"
  134. + [ -n "$ZONE_MAP" ] && json_add_string zone "$ZONE_MAP"
  135. + [ -n "$IFACE_MAP_DELEGATE" ] && json_add_boolean delegate "$IFACE_MAP_DELEGATE"
  136. + json_close_object
  137. + ubus call network add_dynamic "$(json_dump)"
  138. fi
  139. # TODO: $SNTP_IP $SIP_IP $SNTP_FQDN $SIP_DOMAIN
  140. diff --git a/package/odhcp6c/files/dhcpv6.sh b/package/odhcp6c/files/dhcpv6.sh
  141. index bf6cd9a..1c6d609 100755
  142. --- a/package/odhcp6c/files/dhcpv6.sh
  143. +++ b/package/odhcp6c/files/dhcpv6.sh
  144. @@ -5,23 +5,34 @@
  145. init_proto "$@"
  146. proto_dhcpv6_init_config() {
  147. - proto_config_add_string "reqaddress"
  148. - proto_config_add_string "reqprefix"
  149. - proto_config_add_string "clientid"
  150. - proto_config_add_string "reqopts"
  151. - proto_config_add_string "noslaaconly"
  152. - proto_config_add_string "norelease"
  153. - proto_config_add_string "ip6prefix"
  154. - proto_config_add_string "iface_dslite"
  155. - proto_config_add_string "ifaceid"
  156. + renew_handler=1
  157. +
  158. + proto_config_add_string 'reqaddress:or("try","force","none")'
  159. + proto_config_add_string 'reqprefix:or("auto","no",range(0, 64))'
  160. + proto_config_add_string clientid
  161. + proto_config_add_string 'reqopts:list(uinteger)'
  162. + proto_config_add_string 'noslaaconly:bool'
  163. + proto_config_add_string 'forceprefix:bool'
  164. + proto_config_add_string 'norelease:bool'
  165. + proto_config_add_string 'ip6prefix:ip6addr'
  166. + proto_config_add_string iface_dslite
  167. + proto_config_add_string zone_dslite
  168. + proto_config_add_string iface_map
  169. + proto_config_add_string zone_map
  170. + proto_config_add_string 'ifaceid:ip6addr'
  171. + proto_config_add_string 'sourcerouting:bool'
  172. + proto_config_add_string "userclass"
  173. + proto_config_add_string "vendorclass"
  174. + proto_config_add_boolean delegate
  175. + proto_config_add_int "soltimeout"
  176. }
  177. proto_dhcpv6_setup() {
  178. local config="$1"
  179. local iface="$2"
  180. - local reqaddress reqprefix clientid reqopts noslaaconly norelease ip6prefix iface_dslite ifaceid
  181. - json_get_vars reqaddress reqprefix clientid reqopts noslaaconly norelease ip6prefix iface_dslite ifaceid
  182. + local reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map soltimeout
  183. + json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map soltimeout
  184. # Configure
  185. @@ -35,16 +46,30 @@ proto_dhcpv6_setup() {
  186. [ "$noslaaconly" = "1" ] && append opts "-S"
  187. + [ "$forceprefix" = "1" ] && append opts "-F"
  188. +
  189. [ "$norelease" = "1" ] && append opts "-k"
  190. [ -n "$ifaceid" ] && append opts "-i$ifaceid"
  191. + [ -n "$vendorclass" ] && append opts "-V$vendorclass"
  192. +
  193. + [ -n "$userclass" ] && append opts "-u$userclass"
  194. +
  195. for opt in $reqopts; do
  196. append opts "-r$opt"
  197. done
  198. + append opts "-t${soltimeout:-120}"
  199. +
  200. [ -n "$ip6prefix" ] && proto_export "USERPREFIX=$ip6prefix"
  201. [ -n "$iface_dslite" ] && proto_export "IFACE_DSLITE=$iface_dslite"
  202. + [ -n "$iface_map" ] && proto_export "IFACE_MAP=$iface_map"
  203. + [ "$sourcerouting" != "0" ] && proto_export "SOURCE_ROUTING=1"
  204. + [ "$delegate" = "0" ] && proto_export "IFACE_DSLITE_DELEGATE=0"
  205. + [ "$delegate" = "0" ] && proto_export "IFACE_MAP_DELEGATE=0"
  206. + [ -n "$zone_dslite" ] && proto_export "ZONE_DSLITE=$zone_dslite"
  207. + [ -n "$zone_map" ] && proto_export "ZONE_MAP=$zone_map"
  208. proto_export "INTERFACE=$config"
  209. proto_run_command "$config" odhcp6c \
  210. @@ -52,6 +77,13 @@ proto_dhcpv6_setup() {
  211. $opts $iface
  212. }
  213. +proto_dhcpv6_renew() {
  214. + local interface="$1"
  215. + # SIGUSR1 forces odhcp6c to renew its lease
  216. + local sigusr1="$(kill -l SIGUSR1)"
  217. + [ -n "$sigusr1" ] && proto_kill_command "$interface" $sigusr1
  218. +}
  219. +
  220. proto_dhcpv6_teardown() {
  221. local interface="$1"
  222. proto_kill_command "$interface"
  223. 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
  224. deleted file mode 100644
  225. index 292d023..0000000
  226. --- a/package/odhcp6c/patches/001-fix-integer-overflow-after-50-days.patch
  227. +++ /dev/null
  228. @@ -1,25 +0,0 @@
  229. -From 5b98f902f616bd9b96a2128587bc6995555a43c1 Mon Sep 17 00:00:00 2001
  230. -From: Steven Barth <steven@midlink.org>
  231. -Date: Fri, 7 Mar 2014 10:33:49 +0100
  232. -Subject: [PATCH] fix integer overflow after 50 days (thx Hauke Mehrtens)
  233. -
  234. ----
  235. - src/odhcp6c.c | 2 +-
  236. - 1 file changed, 1 insertion(+), 1 deletion(-)
  237. -
  238. -diff --git a/src/odhcp6c.c b/src/odhcp6c.c
  239. -index 3c6b3b0..ba11ced 100644
  240. ---- a/src/odhcp6c.c
  241. -+++ b/src/odhcp6c.c
  242. -@@ -470,7 +470,7 @@ uint64_t odhcp6c_get_milli_time(void)
  243. - {
  244. - struct timespec t = {0, 0};
  245. - syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &t);
  246. -- return t.tv_sec * 1000 + t.tv_nsec / 1000000;
  247. -+ return ((uint64_t)t.tv_sec) * 1000 + ((uint64_t)t.tv_nsec) / 1000000;
  248. - }
  249. -
  250. -
  251. ---
  252. -1.7.10.4
  253. -