0004-Update-odhcp6c-from-Barrier-Breaker-r41830.patch 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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 (r41830)
  4. diff --git a/package/odhcp6c/Makefile b/package/odhcp6c/Makefile
  5. index e767064..3ec58e1 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-07-21
  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:=67b311ab81736b35858664219d345844ab08fcc7
  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..8c1ba18 100755
  66. --- a/package/odhcp6c/files/dhcpv6.script
  67. +++ b/package/odhcp6c/files/dhcpv6.script
  68. @@ -64,23 +64,68 @@ 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. + [ -n "$ZONE" ] && json_add_string zone "$ZONE"
  86. + proto_close_data
  87. +
  88. proto_send_update "$INTERFACE"
  89. - if [ -n "$AFTR_IP " -a -n "$IFACE_DSLITE" ]; then
  90. -uci -q batch <<-EOF >/dev/null
  91. -set network.$IFACE_DSLITE.proto=dslite
  92. -set network.$IFACE_DSLITE.auto=0
  93. -set network.$IFACE_DSLITE.peeraddr=$AFTR_IP
  94. -set network.$IFACE_DSLITE.tunlink=$INTERFACE
  95. -commit network
  96. -EOF
  97. -
  98. - ifdown "$IFACE_DSLITE"
  99. - /etc/init.d/network reload
  100. - ifup "$IFACE_DSLITE"
  101. + MAPTYPE=""
  102. + MAPRULE=""
  103. +
  104. + if [ -n "$MAPE" -a -f /lib/netifd/proto/map.sh ]; then
  105. + MAPTYPE="map-e"
  106. + MAPRULE="$MAPE"
  107. + elif [ -n "$MAPT" -a -f /lib/netifd/proto/map.sh -a -f /proc/net/nat46/control ]; then
  108. + MAPTYPE="map-t"
  109. + MAPRULE="$MAPT"
  110. + elif [ -n "$LW4O6" -a -f /lib/netifd/proto/map.sh ]; then
  111. + MAPTYPE="lw4o6"
  112. + MAPRULE="$LW4O6"
  113. + fi
  114. +
  115. + [ -n "$ZONE" ] || ZONE=$(fw3 network $INTERFACE)
  116. +
  117. + if [ "$IFACE_MAP" != 0 -a -n "$MAPTYPE" -a -n "$MAPRULE" ]; then
  118. + [ -z "$IFACE_MAP" -o "$IFACE_MAP" = 1 ] && IFACE_MAP=${INTERFACE}_map
  119. + json_init
  120. + json_add_string name "$IFACE_MAP"
  121. + json_add_string ifname "@$INTERFACE"
  122. + json_add_string proto map
  123. + json_add_string type "$MAPTYPE"
  124. + json_add_string rule "$MAPRULE"
  125. + json_add_string tunlink "$INTERFACE"
  126. + [ -n "$ZONE_MAP" ] || ZONE_MAP=$ZONE
  127. + [ -n "$ZONE_MAP" ] && json_add_string zone "$ZONE_MAP"
  128. + [ -n "$IFACE_MAP_DELEGATE" ] && json_add_boolean delegate "$IFACE_MAP_DELEGATE"
  129. + json_close_object
  130. + ubus call network add_dynamic "$(json_dump)"
  131. + elif [ -n "$AFTR_IP " -a "$IFACE_DSLITE" != 0 -a -f /lib/netifd/proto/dslite.sh ]; then
  132. + [ -z "$IFACE_DSLITE" -o "$IFACE_DSLITE" = 1 ] && IFACE_DSLITE=${INTERFACE}_dslite
  133. + json_init
  134. + json_add_string name "$IFACE_DSLITE"
  135. + json_add_string ifname "@$INTERFACE"
  136. + json_add_string proto "dslite"
  137. + json_add_string peeraddr "$AFTR_IP"
  138. + json_add_string tunlink "$INTERFACE"
  139. + [ -n "$ZONE_DSLITE" ] || ZONE_DSLITE=$ZONE
  140. + [ -n "$ZONE_DSLITE" ] && json_add_string zone "$ZONE_DSLITE"
  141. + [ -n "$IFACE_DSLITE_DELEGATE" ] && json_add_boolean delegate "$IFACE_DSLITE_DELEGATE"
  142. + json_close_object
  143. + ubus call network add_dynamic "$(json_dump)"
  144. fi
  145. # TODO: $SNTP_IP $SIP_IP $SNTP_FQDN $SIP_DOMAIN
  146. diff --git a/package/odhcp6c/files/dhcpv6.sh b/package/odhcp6c/files/dhcpv6.sh
  147. index bf6cd9a..0690bd1 100755
  148. --- a/package/odhcp6c/files/dhcpv6.sh
  149. +++ b/package/odhcp6c/files/dhcpv6.sh
  150. @@ -5,23 +5,35 @@
  151. init_proto "$@"
  152. proto_dhcpv6_init_config() {
  153. - proto_config_add_string "reqaddress"
  154. - proto_config_add_string "reqprefix"
  155. - proto_config_add_string "clientid"
  156. - proto_config_add_string "reqopts"
  157. - proto_config_add_string "noslaaconly"
  158. - proto_config_add_string "norelease"
  159. - proto_config_add_string "ip6prefix"
  160. - proto_config_add_string "iface_dslite"
  161. - proto_config_add_string "ifaceid"
  162. + renew_handler=1
  163. +
  164. + proto_config_add_string 'reqaddress:or("try","force","none")'
  165. + proto_config_add_string 'reqprefix:or("auto","no",range(0, 64))'
  166. + proto_config_add_string clientid
  167. + proto_config_add_string 'reqopts:list(uinteger)'
  168. + proto_config_add_string 'noslaaconly:bool'
  169. + proto_config_add_string 'forceprefix:bool'
  170. + proto_config_add_string 'norelease:bool'
  171. + proto_config_add_string 'ip6prefix:ip6addr'
  172. + proto_config_add_string iface_dslite
  173. + proto_config_add_string zone_dslite
  174. + proto_config_add_string iface_map
  175. + proto_config_add_string zone_map
  176. + proto_config_add_string zone
  177. + proto_config_add_string 'ifaceid:ip6addr'
  178. + proto_config_add_string 'sourcerouting:bool'
  179. + proto_config_add_string "userclass"
  180. + proto_config_add_string "vendorclass"
  181. + proto_config_add_boolean delegate
  182. + proto_config_add_int "soltimeout"
  183. }
  184. proto_dhcpv6_setup() {
  185. local config="$1"
  186. local iface="$2"
  187. - local reqaddress reqprefix clientid reqopts noslaaconly norelease ip6prefix iface_dslite ifaceid
  188. - json_get_vars reqaddress reqprefix clientid reqopts noslaaconly norelease ip6prefix iface_dslite ifaceid
  189. + local reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout
  190. + json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout
  191. # Configure
  192. @@ -35,16 +47,31 @@ proto_dhcpv6_setup() {
  193. [ "$noslaaconly" = "1" ] && append opts "-S"
  194. + [ "$forceprefix" = "1" ] && append opts "-F"
  195. +
  196. [ "$norelease" = "1" ] && append opts "-k"
  197. [ -n "$ifaceid" ] && append opts "-i$ifaceid"
  198. + [ -n "$vendorclass" ] && append opts "-V$vendorclass"
  199. +
  200. + [ -n "$userclass" ] && append opts "-u$userclass"
  201. +
  202. for opt in $reqopts; do
  203. append opts "-r$opt"
  204. done
  205. + append opts "-t${soltimeout:-120}"
  206. +
  207. [ -n "$ip6prefix" ] && proto_export "USERPREFIX=$ip6prefix"
  208. [ -n "$iface_dslite" ] && proto_export "IFACE_DSLITE=$iface_dslite"
  209. + [ -n "$iface_map" ] && proto_export "IFACE_MAP=$iface_map"
  210. + [ "$sourcerouting" != "0" ] && proto_export "SOURCE_ROUTING=1"
  211. + [ "$delegate" = "0" ] && proto_export "IFACE_DSLITE_DELEGATE=0"
  212. + [ "$delegate" = "0" ] && proto_export "IFACE_MAP_DELEGATE=0"
  213. + [ -n "$zone_dslite" ] && proto_export "ZONE_DSLITE=$zone_dslite"
  214. + [ -n "$zone_map" ] && proto_export "ZONE_MAP=$zone_map"
  215. + [ -n "$zone" ] && proto_export "ZONE=$zone"
  216. proto_export "INTERFACE=$config"
  217. proto_run_command "$config" odhcp6c \
  218. @@ -52,6 +79,13 @@ proto_dhcpv6_setup() {
  219. $opts $iface
  220. }
  221. +proto_dhcpv6_renew() {
  222. + local interface="$1"
  223. + # SIGUSR1 forces odhcp6c to renew its lease
  224. + local sigusr1="$(kill -l SIGUSR1)"
  225. + [ -n "$sigusr1" ] && proto_kill_command "$interface" $sigusr1
  226. +}
  227. +
  228. proto_dhcpv6_teardown() {
  229. local interface="$1"
  230. proto_kill_command "$interface"
  231. 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
  232. deleted file mode 100644
  233. index 292d023..0000000
  234. --- a/package/odhcp6c/patches/001-fix-integer-overflow-after-50-days.patch
  235. +++ /dev/null
  236. @@ -1,25 +0,0 @@
  237. -From 5b98f902f616bd9b96a2128587bc6995555a43c1 Mon Sep 17 00:00:00 2001
  238. -From: Steven Barth <steven@midlink.org>
  239. -Date: Fri, 7 Mar 2014 10:33:49 +0100
  240. -Subject: [PATCH] fix integer overflow after 50 days (thx Hauke Mehrtens)
  241. -
  242. ----
  243. - src/odhcp6c.c | 2 +-
  244. - 1 file changed, 1 insertion(+), 1 deletion(-)
  245. -
  246. -diff --git a/src/odhcp6c.c b/src/odhcp6c.c
  247. -index 3c6b3b0..ba11ced 100644
  248. ---- a/src/odhcp6c.c
  249. -+++ b/src/odhcp6c.c
  250. -@@ -470,7 +470,7 @@ uint64_t odhcp6c_get_milli_time(void)
  251. - {
  252. - struct timespec t = {0, 0};
  253. - syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &t);
  254. -- return t.tv_sec * 1000 + t.tv_nsec / 1000000;
  255. -+ return ((uint64_t)t.tv_sec) * 1000 + ((uint64_t)t.tv_nsec) / 1000000;
  256. - }
  257. -
  258. -
  259. ---
  260. -1.7.10.4
  261. -