dnsmasq: backport infinite dns retries fix
[openwrt/openwrt.git] / target / linux / ramips / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/system.sh
6
7 ramips_setup_rt3x5x_vlans()
8 {
9 if [ ! -x /sbin/swconfig ]; then
10 # legacy default
11 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
12 return
13 fi
14 local wanports=""
15 local lanports=""
16 for port in 5 4 3 2 1 0; do
17 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
18 continue
19 fi
20 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
21 wanports="$port:wan $wanports"
22 else
23 lanports="$port:lan $lanports"
24 fi
25 done
26 ucidef_add_switch "rt305x" $lanports $wanports "6t@eth0"
27 }
28
29 ramips_setup_interfaces()
30 {
31 local board="$1"
32
33 case $board in
34 11acnas|\
35 w2914nsv2|\
36 zbt-we2026)
37 ucidef_add_switch "switch0" \
38 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0"
39 ;;
40 3g150b|\
41 3g300m|\
42 a5-v11|\
43 all0256n-4M|\
44 all0256n-8M|\
45 all5002|\
46 all5003|\
47 broadway|\
48 dcs-930|\
49 dcs-930l-b1|\
50 ht-tm02|\
51 linkits7688 | \
52 linkits7688d | \
53 m2m|\
54 microwrt|\
55 mpr-a2|\
56 ncs601w|\
57 omega2 | \
58 omega2p | \
59 timecloud|\
60 w150m|\
61 widora-neo|\
62 wnce2001|\
63 zbt-cpe102|\
64 zte-q7)
65 ucidef_add_switch "switch0"
66 ucidef_add_switch_attr "switch0" "enable" "false"
67 ucidef_set_interface_lan "eth0"
68 ;;
69 mlw221|\
70 mr-102n)
71 ucidef_set_interface_lan "eth0.2"
72 ;;
73 3g-6200n|\
74 ai-br100|\
75 d240|\
76 db-wrt01|\
77 dir-300-b7|\
78 dir-320-b1|\
79 dir-610-a1|\
80 dir-615-h1|\
81 ew1200|\
82 firewrt|\
83 hc5661a|\
84 hc5962|\
85 hlk-rm04|\
86 k2p|\
87 kn|\
88 kn_rc|\
89 mac1200rv2|\
90 miwifi-mini|\
91 miwifi-nano|\
92 mt7621|\
93 mt7628|\
94 mzk-750dhp|\
95 mzk-w300nh2|\
96 nixcore-x1-8M|\
97 nixcore-x1-16M|\
98 oy-0001|\
99 pbr-m1|\
100 psg1208|\
101 psg1218a|\
102 r6220|\
103 sap-g3200u3|\
104 sk-wb8|\
105 u7621-06-256M-16M|\
106 vr500|\
107 wf-2881|\
108 witi|\
109 wl-wn575a3|\
110 wndr3700v5|\
111 wt1520-4M|\
112 wt1520-8M|\
113 y1|\
114 youku-yk1|\
115 zbt-ape522ii|\
116 zbt-we1326|\
117 zbt-we3526|\
118 zbt-we826-16M|\
119 zbt-we826-32M|\
120 zbt-wg2626|\
121 zbt-wg3526-16M|\
122 zbt-wg3526-32M|\
123 zbt-wr8305rt)
124 ucidef_add_switch "switch0" \
125 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
126 ;;
127 mir3g)
128 ucidef_add_switch "switch0" \
129 "2:lan:2" "3:lan:1" "1:wan" "6t@eth0"
130 ;;
131 psg1218b)
132 ucidef_add_switch "switch0" \
133 "0:lan:3" "1:lan:2" "2:lan:1" "3:wan" "6@eth0"
134 ;;
135 whr-300hp2|\
136 whr-600d|\
137 wsr-1166|\
138 wsr-600)
139 ucidef_add_switch "switch0" \
140 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan:5" "6@eth0"
141 ;;
142 ar670w|\
143 ar725w|\
144 rt-ac51u)
145 ucidef_add_switch "switch0" \
146 "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
147 ;;
148 rt-n15|\
149 wl-351)
150 ucidef_add_switch "switch0" \
151 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5@eth0"
152 ;;
153 asl26555-8M|\
154 asl26555-16M|\
155 rp-n53)
156 ucidef_add_switch "switch0" \
157 "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
158 ;;
159 atp-52b|\
160 awm002-evb-4M|\
161 awm002-evb-8M|\
162 c20i|\
163 dir-645|\
164 f5d8235-v2|\
165 gl-mt300a|\
166 gl-mt300n|\
167 gl-mt750|\
168 hg255d|\
169 jhr-n805r|\
170 jhr-n825r|\
171 jhr-n926r|\
172 mzk-wdpr|\
173 rb750gr3|\
174 rt-n14u|\
175 tl-wr840n-v4|\
176 tl-wr840n-v5|\
177 tl-wr841n-v13|\
178 u7628-01-128M-16M|\
179 ubnt-erx|\
180 ubnt-erx-sfp|\
181 ur-326n4g|\
182 wrtnode|\
183 wrtnode2p | \
184 wrtnode2r | \
185 wt3020-4M|\
186 wt3020-8M|\
187 zbt-wa05)
188 ucidef_add_switch "switch0" \
189 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
190 ;;
191 c20|\
192 c50)
193 ucidef_add_switch "switch0" \
194 "1:lan:3" "2:lan:4" "3:lan:1" "4:lan:2" "0:wan" "6@eth0"
195 ;;
196 dir-860l-b1)
197 ucidef_add_switch "switch0" \
198 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
199 ;;
200 gb-pc1)
201 ucidef_add_switch "switch0" \
202 "0:lan" "4:lan" "6@eth0"
203 ;;
204 gl-mt300n-v2)
205 ucidef_add_switch "switch0" \
206 "1:lan" "0:wan" "6@eth0"
207 ;;
208 awapn2403)
209 ucidef_add_switch "switch0" \
210 "0:lan" "1:wan" "6@eth0"
211 ;;
212 b2c|\
213 nw718|\
214 psr-680w|\
215 sl-r7205|\
216 ur-336un|\
217 w502u|\
218 wr6202)
219 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
220 ;;
221 br-6475nd)
222 ucidef_add_switch "switch0" \
223 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
224 ;;
225 c108|\
226 cf-wr800n)
227 ucidef_add_switch "switch0" \
228 "4:lan" "6t@eth0"
229 ;;
230 cy-swr1100)
231 ucidef_add_switch "switch0" \
232 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "9@eth0"
233 ;;
234 cs-qr10|\
235 d105|\
236 dch-m225|\
237 ex2700|\
238 ex3700|\
239 hpm|\
240 mzk-ex300np|\
241 mzk-ex750np|\
242 na930|\
243 pbr-d1|\
244 u25awf-h1|\
245 wli-tx4-ag300n|\
246 wmdr-143n|\
247 wmr-300|\
248 wn3000rpv3|\
249 wrh-300cr)
250 ucidef_set_interface_lan "eth0"
251 ;;
252 duzun-dm06)
253 ucidef_add_switch "switch0" \
254 "1:lan" "0:wan" "6@eth0"
255 ;;
256 e1700|\
257 mt7620a_mt7530)
258 ucidef_add_switch "switch1" \
259 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
260 ;;
261 hc5*61|\
262 y1s)
263 ucidef_add_switch "switch0" \
264 "1:lan" "2:lan" "3:lan" "4:lan" "5:lan" "0:wan" "6@eth0"
265 ;;
266 kn_rf)
267 ucidef_add_switch "switch0" \
268 "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6@eth0"
269 ;;
270 kng_rc)
271 ucidef_add_switch "switch1" \
272 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "7t@eth0"
273 ;;
274 mlwg2|\
275 wizard8800|\
276 wl-330n)
277 ucidef_set_interface_lan "eth0.1"
278 ;;
279 mr200)
280 ucidef_add_switch "switch0" \
281 "0:lan" "1:lan" "2:lan" "3:lan" "6t@eth0"
282 ucidef_set_interface_wan "usb0"
283 ;;
284 mzk-dp150n|\
285 vocore-8M|\
286 vocore-16M)
287 ucidef_add_switch "switch0" \
288 "0:lan" "4:lan" "6t@eth0"
289 ;;
290 newifi-d1)
291 ucidef_add_switch "switch0" \
292 "1:lan:2" "2:lan:1" "4:wan" "6@eth0"
293 ;;
294 re350-v1)
295 ucidef_add_switch "switch0" \
296 "0:lan" "6@eth0"
297 ;;
298 re6500)
299 ucidef_add_switch "switch0" \
300 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "6@eth0"
301 ;;
302 rt-n56u)
303 ucidef_add_switch "switch0" \
304 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "8@eth0"
305 ;;
306 tew-638apb-v2)
307 ucidef_add_switch "switch0" \
308 "4:lan" "6@eth0"
309 ;;
310 tew-691gr|\
311 tew-692gr|\
312 wlr-6000)
313 ucidef_add_switch "switch0" \
314 "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0"
315 ;;
316 vocore2|\
317 vocore2lite)
318 ucidef_add_switch "switch0" \
319 "0:lan" "2:lan" "6t@eth0"
320 ;;
321 f5d8235-v1|\
322 tew-714tru|\
323 v11st-fe|\
324 wzr-agl300nh)
325 ucidef_add_switch "switch0" \
326 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
327 ;;
328 wcr-1166ds)
329 ucidef_add_switch "switch0" \
330 "3:lan" "4:wan" "6@eth0"
331 ;;
332 wcr-150gn|\
333 we1026-5g-16m)
334 ucidef_add_switch "switch0" \
335 "0:lan" "6t@eth0"
336 ;;
337 whr-1166d)
338 ucidef_add_switch "switch0" \
339 "0:lan" "1:lan" "2:lan" "3:lan" "5:wan" "6@eth0"
340 ;;
341 wizfi630a)
342 ucidef_add_switch "switch0" \
343 "1:lan" "2:lan" "0:wan" "6@eth0"
344 ;;
345 *)
346 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
347 if [ -n "${RT3X5X}" ]; then
348 ramips_setup_rt3x5x_vlans
349 else
350 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
351 fi
352 ;;
353 esac
354 }
355
356 ramips_setup_macs()
357 {
358 local board="$1"
359 local lan_mac=""
360 local wan_mac=""
361
362 case $board in
363 a5-v11|\
364 ht-tm02|\
365 wmdr-143n)
366 lan_mac=$(cat /sys/class/net/eth0/address)
367 ;;
368 all0239-3g|\
369 carambola|\
370 freestation5|\
371 w502u|\
372 wnce2001)
373 wan_mac=$(mtd_get_mac_binary factory 46)
374 ;;
375 bc2|\
376 broadway|\
377 d105|\
378 dir-300-b7|\
379 dir-320-b1|\
380 dir-620-a1|\
381 esr-9753|\
382 freestation5|\
383 hlk-rm04|\
384 mpr-a1|\
385 psr-680w|\
386 sl-r7205|\
387 y1|\
388 y1s)
389 lan_mac=$(cat /sys/class/net/eth0/address)
390 lan_mac=$(macaddr_setbit_la "$lan_mac")
391 wan_mac=$(macaddr_add "$lan_mac" 1)
392 ;;
393 br-6475nd)
394 lan_mac=$(cat /sys/class/net/eth0/address)
395 wan_mac=$(mtd_get_mac_binary devdata 7)
396 ;;
397 cy-swr1100|\
398 dch-m225)
399 lan_mac=$(mtd_get_mac_ascii factory lanmac)
400 ;;
401 dir-645)
402 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
403 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
404 ;;
405 dir-860l-b1)
406 lan_mac=$(mtd_get_mac_ascii factory lanmac)
407 wan_mac=$(mtd_get_mac_ascii factory wanmac)
408 ;;
409 e1700)
410 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
411 ;;
412 gl-mt300n-v2)
413 wan_mac=$(mtd_get_mac_binary factory 4)
414 ;;
415 hc5*61|\
416 hc5661a|\
417 hc5962)
418 lan_mac=`mtd_get_mac_ascii bdinfo "Vfac_mac "`
419 [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
420 wan_mac=$(macaddr_add "$lan_mac" 1)
421 ;;
422 kn_rc|\
423 kn_rf|\
424 kng_rc)
425 wan_mac=$(mtd_get_mac_binary factory 40)
426 ;;
427 linkits7688 | \
428 linkits7688d)
429 wan_mac=$(mtd_get_mac_binary factory 4)
430 lan_mac=$(mtd_get_mac_binary factory 46)
431 ;;
432 mac1200rv2)
433 lan_mac=$(mtd_get_mac_binary factory_info 13)
434 wan_mac=$(macaddr_add "$lan_mac" 1)
435 ;;
436 mir3g)
437 lan_mac=$(mtd_get_mac_binary Factory 0xe006)
438 ;;
439 miwifi-mini)
440 wan_mac=$(cat /sys/class/net/eth0/address)
441 lan_mac=$(macaddr_setbit_la "$wan_mac")
442 ;;
443 m3|\
444 m4-4M|\
445 m4-8M|\
446 x5|\
447 x8)
448 lan_mac=$(cat /sys/class/net/eth0/address)
449 lan_mac=$(macaddr_add "$lan_mac" -2)
450 ;;
451 newifi-d1)
452 lan_mac=$(cat /sys/class/net/eth0/address)
453 lan_mac=$(macaddr_add "$lan_mac" 2)
454 ;;
455 omega2|\
456 omega2p)
457 wan_mac=$(mtd_get_mac_binary factory 4)
458 lan_mac=$(mtd_get_mac_binary factory 46)
459 ;;
460 oy-0001)
461 lan_mac=$(mtd_get_mac_binary factory 40)
462 wan_mac=$(mtd_get_mac_binary factory 46)
463 ;;
464 r6220)
465 wan_mac=$(mtd_get_mac_binary factory 4)
466 lan_mac=$(macaddr_add "$wan_mac" 1)
467 ;;
468 rt-n56u)
469 lan_mac=$(cat /sys/class/net/eth0/address)
470 lan_mac=$(macaddr_setbit_la "$lan_mac")
471 wan_mac=$(mtd_get_mac_binary factory 32772)
472 ;;
473 sk-wb8)
474 wan_mac=$(mtd_get_mac_binary factory 57350)
475 ;;
476 tew-691gr)
477 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 4)" 3)
478 ;;
479 tew-692gr)
480 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 4)" 1)
481 ;;
482 tiny-ac)
483 lan_mac=$(mtd_get_mac_ascii u-boot-env LAN_MAC_ADDR)
484 wan_mac=$(mtd_get_mac_ascii u-boot-env WAN_MAC_ADDR)
485 ;;
486 vr500)
487 lan_mac=$(mtd_get_mac_binary factory 57344)
488 wan_mac=$(mtd_get_mac_binary factory 57350)
489 ;;
490 w306r-v20)
491 lan_mac=$(cat /sys/class/net/eth0/address)
492 wan_mac=$(macaddr_add "$lan_mac" 5)
493 ;;
494 wcr-1166ds|\
495 wsr-1166)
496 local index="$(find_mtd_index "board_data")"
497 wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
498 lan_mac=$wan_mac
499 ;;
500 wcr-150gn)
501 wan_mac=$(mtd_get_mac_binary factory 40)
502 ;;
503 whr-1166d|\
504 whr-300hp2|\
505 whr-600d|\
506 wsr-600)
507 wan_mac=$(mtd_get_mac_binary factory 4)
508 lan_mac=$wan_mac
509 ;;
510 wizfi630a)
511 lan_mac=$(mtd_get_mac_binary factory 4)
512 wan_mac=$(mtd_get_mac_binary factory 40)
513 ;;
514 wlr-6000)
515 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 32772)" 2)
516 ;;
517 *)
518 lan_mac=$(cat /sys/class/net/eth0/address)
519 wan_mac=$(macaddr_add "$lan_mac" 1)
520 ;;
521 esac
522
523 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
524 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
525 }
526
527 board_config_update
528 board=$(board_name)
529 ramips_setup_interfaces $board
530 ramips_setup_macs $board
531 board_config_flush
532
533 exit 0