An example of troubleshooting embedded Linux OpenWrt

Source: Internet
Author: User
Tags syslog

It doesn't matter what the big data is, it just helps a friend get in a wrong record.

Former relationship is very good colleagues, currently in the enterprise-level WiFi domain business, procurement of our big data services, is to do the platform for him to build and debug. And these days he was the CEO in the debugging of the router encountered some problems, in the big data at the same time the hand to solve his problem.

OpenWRT, Embedded Linux, is primarily used on MIPS or ARM devices. Many routers and WiFi devices will use this system, which is characterized by its lightness.

Coova-chilli, the access controller under the OpenWrt, provides an authentication gateway that can be used for access billing, such as RADIUS or HTTP.

Normal, after starting chilli, will start four Tun Virtual tunnel network card, and the fault is sporadic, irregular will have two IP address of the same Tun device. Like this,

Tun1 10.1.0.1

Tun2 10.2.0.1

Tun3 10.3.0.1

Tun4 10.4.0.1

Under normal circumstances should be only tun0-3 device, but each boot will be more than one or two tun, and is not fixed, sometimes tun0-1 IP address, sometimes tun2-3 IP address. Also, OpenWrt does not log syslog by default. Difficult to troubleshoot. The syslog can actually be read from the Logread, but nothing is recorded in the syslog.

That dude used to write code, languish three nights did not find the problem where, in the Chilli startup script set a variety of log,wait,sleep, are useless. In the afternoon, the need to discuss the current big data platform is all right, and then I have to show him the script with my spare egg ache, chilli script should not have too many problems, and then he was built according to the official deployment document. I didn't see the problem at first. The chilli script is placed in the/ETC/INIT.D directory by default. Ordinarily there was no problem, and afterwards the thrill came, and he told me he had written a command at rc.local to do the boot, and I looked at rc.local inside, and he wrote a startup script that put it under/root. VI that in the/root under the startup script, which wrote a/etc/init.d/chilli restart. I asked him what it was for, and he said WRT official let's write it, saying it's insurance. I tried to log off restart line, reboot 10 times, Tun Tunnel is no problem. 20 minutes to fix it.

Problem analysis

Chilli The original script is as follows

#! /bin/sh # # # BEGIN INIT INFO # provides:chilli # required-start: $remote _fs $syslog $network # Req Uired-stop: $remote _fs $syslog $network # default-start:2 3 4 5 # default-stop:0 1 6 # SHORT-DESCR    Iption:start CoovaChilli daemon at boot time # description:enable CoovaChilli service provided by Daemon. # # # END INIT INFO path=/sbin:/bin:/usr/sbin:/usr/bin daemon=/usr/sbin/chilli name=chilli Desc=chilli START_ chilli=0 if [-f/etc/default/chilli]; Then. /etc/default/chilli fi If ["$START _chilli"! = "1"]; Then echo "Chilli default off. Look At/etc/default/chilli "Exit 0 fi test-f $DAEMON | | Exit 0.  /etc/chilli/functions multi=$ (ls/etc/chilli/*/chilli.conf 2>/dev/null) [-Z "$DHCPIF"] && [-N "$MULTI"     ] && {for C in $MULTI; Do echo "Found configuration $c" dhcpif=$ (basename $ (echo $c |sed ' s#/chilli.conf## ')) export dhcpif ECho "Running dhcpif= $DHCPIF $ $*" sh $ $* done exit} if [-N "$DHCPIF"]; Then config=/etc/chilli/$DHCPIF/chilli.conf Else config=/etc/chilli.conf fi [-f $CONFIG] | |      {echo ' $CONFIG not found ' exit 0} check_required retval=0 prog= "Chilli" case "$" in start) Echo-n "Starting $DESC:"/sbin/modprobe tun >/dev/null 2>&1 echo 1 >/proc/sys/net/ipv4/ip_forwa Rd Writeconfig radiusconfig Test ${hs_adminterval:-0}-gt 0 && {(crontab-l 2>&-| grep -V-echo "*/$HS _adminterval * * * * * $ radconfig") | crontab-2>&-} ifconfig $HS _lanif 0.0.0.0 start-stop-daemon--start--quiet--pidfile/var/run/$NA      ME. $HS _lanif.pid \--exec $DAEMON---c $CONFIG retval=$?      echo "$NAME."    ;; checkrunning) check= ' Start-stop-daemon--start--exec $DAEMON--test ' If [x ' $check "! = X" $DAEMON already runnin G. "] ; Then $0 start fi;; Radconfig) [-e $MAIN _conf] | |    Writeconfig Radiusconfig;      Restart) $ Stop Sleep 1 $ start retval=$?    ;; Stop) echo-n "stopping $DESC:" Crontab-l 2>&-| Grep-v |      Crontab-start-stop-daemon--oknodo--stop--quiet--pidfile/var/run/$NAME. $HS _lanif.pid \--exec $DAEMON      echo "$NAME."    ;;      Reload) echo "reloading $DESC."    Start-stop-daemon--stop--signal 1--quiet--pidfile \/var/run/$NAME. $HS _lanif.pid--exec $DAEMON;; Condrestart) check= ' Start-stop-daemon--start--exec $DAEMON--test ' If [x ' $check "! = X" $DAEMON already running ." ] ;      Then restart retval=$?    fi;;      Status) status Chilli retval=$?    ;;      *) n=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|condrestart|status|reload|radconfig}" >&2    Exit 1;; ESAC Exit 0

The problem is, when he was debugging, in the for-C in $MULTI Loop, in order to ensure that each child process started successfully, added a wait, behind the establishment of the Tun channel in order to debug and add a few sleep. According to the official document, he added a restart to the rc.local inside, so the problem came,/ETC/INIT.D inside is automatically executed chilli start command, and added wait and sleep. INIT.D's startup script waits, and at this time Linux launches the chilli Restart command in the rc.local with different TTY, so two or three identical Tun IP addresses will be present together.

Anyway, given the fact that he stayed up three nights for this kind of thing, I could educate the CEO of this personal commissioning program in the voice of the Prophet: "Do not book as much as you believe." The official documentation of the open source system often lags behind, possibly the new version has already solved the question which needs to restart, but the document did not update in time, causes this kind of problem to occur.

Summarize how important it is to understand how the various systems work.

    • This article is from: Linux Tutorial Network

An example of troubleshooting embedded Linux OpenWrt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.