Comments (6)
Could you try running it with this patch?
https://gist.github.com/arsv/ba776748c44e5763af2ff9b93fe70b6f
ifi->ifi_flags & IFF_RUNNING) ? "Up" : "Down"
That's exactly what ifmon monitors:
minibase/src/net2/ifmon_netlink.c
Line 82 in ebf7f02
Also afaik there's no such thing as cable detection, at least at userspace level. It only detects carrier. The cable is unplugged, or cable is plugged but the router is off — it's the same state, "no-carrier".
The problem is not that it cannot detect router-off condition, it can. Rapid changes in carrier state are most likely the problem.
from minibase.
The situation in the first post, with cable plugged in and router turned off. 'ifmon' with the traces patch is running. Now turn on the router:
carrier up on eth0
carrier rising edge
fork 5365 conf-request eth0
+++ conf-request eth0
dhcp: discover: ETIMEDOUT
exit 5365 65280
carrier down on eth0
carrier falling edge
carrier up on eth0
carrier rising edge
fork 5427 conf-request eth0
+++ conf-request eth0
dhcp: discover: ETIMEDOUT
exit 5427 65280
...interesting, is is calling conf-request. Now, unplug the cable:
carrier down on eth0
carrier falling edge
Now plug in the cable:
carrier up on eth0
carrier rising edge
fork 6286 conf-request eth0
+++ conf-request eth0
+++ dhcp-gw 192.168.1.1
+++ dhcp-dns 192.168.43.1 168.126.63.2
exit 6286 0
assuming discontinuous mode dhcp
...and now online!
from minibase.
Ah, I see. The router brings up carrier early but cannot respond to DHCP requests until much later in its boot process. The initial configuration attempt times out before the router boots up, and ifmon never re-tries.
So my current idea on this is to increase re-send timeout and the number of allowed re-sends for dhcp
, let it try for several seconds maybe, and also probably add a command to ifctl
to force a re-try. Neither is a good solution, but I don't think there's any way for ifmon
to know that the router is finally ready.
This may be a valid reason to introduce per-profile dhcp scripts, at least as an option.
from minibase.
Yes, it will need a fix, even if not optimal, as I think this is probably a common situation, the user forgetting to turn on the modem/router, or having to reset it.
from minibase.
I have a workaround, not elegant, but it works. In /etc/net/conf-request, I inserted a call to script /sbin/dhcp-delayed:
#!/bin/sh
IF="$1"
echo "+++ conf-request ${IF}"
dhcp-delayed ${IF} & #fallback
dhcp ${IF} request
Content of /sbin/dhcp-delayed:
#!/bin/sh
IF="$1"
PIDS=$(pidof dhcp-delayed | wc -w) #get 2 when only one running.
[ $PIDS -gt 2 ] && exit
sleep 40
DNS="$(dhcp ${IF} show | grep '^dns ')"
[ "$DNS" ] && exit
echo "Attempting delayed execution: dhcp ${IF} request"
dhcp $IF request
Pretty simple, dhcp-delayed waits long enough so that all the carrier up/downs have finished, and if the "dhcp $IF request" has not succeeded, does it again.
I don't know if anything like this can be put into ifmon, but anyway, the script works for me. 40 seconds is just long enough, might be better to increase it a bit.
from minibase.
Currently dhcp
keeps re-trying for 5s. Which is about as high as it should be for this mode of operation. I thought it was lower but turns out I changed the timeout some time ago. Timeouts around 40s call for a different solution. A script like this is very host-specific, I cannot just hard-code some large time constant and expect it to work well for everyone.
I checked a couple of other implementations, dhcpcd
retries for 30s by default and udhcpd
from Busybox for 20s. That's already high enough to be configurable (prompting per-profile scripts) yet probably too low to handle your case.
Not sure what's the proper solution here. dhcp
is designed around the assumption that it can be a short-running tool. And that should be enough for the vast majority of cases, per my understanding of the DHCP protocol. DHCP makes no provisions for servers suddenly appearing long after the clients sent all their requests.
Your script is actually a good idea, but it can be simplified further.
conf-request:
#!/bin/sh
dhcp-delayed $1
dhcp-delayed:
#!/bin/sh
dhcp $1 request && exit 0
sleep 40
dhcp $1 request
Your own custom double-request dhcp client.
from minibase.
Related Issues (20)
- dhcp remove alarms, result unclear HOT 2
- Use MAC address for unique ID HOT 6
- how to test if password already supplied HOT 5
- aarch64 compile fail HOT 1
- Small problems with ARM machines HOT 1
- vtmux, X11 and VT switch problem HOT 2
- vtmux and wayland problem HOT 2
- wifi hang on connection request HOT 10
- feature request: support TKIP in wsupp HOT 5
- Unclear how dhconf replaces dhcp HOT 1
- No suitable APs HOT 7
- ifctl cannot be called as expected within /etc/net/identify HOT 1
- wifi connect does not return zero on success
- inputs not factored right? HOT 1
- Limitation of ifmon HOT 4
- Non-existent conf-cancel HOT 7
- Most appropriate way to run and kill net daemons HOT 1
- wsupp waits forever for AP HOT 8
- wsupp cannot run wifi-wpa HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minibase.