Detecting ethernet gadget connections
Joel Newkirk
freerunner at newkirk.us
Fri Mar 6 13:51:44 CET 2009
On Fri, 06 Mar 2009 11:04:40 +0100
Helge Hafting <helge.hafting at hist.no> wrote:
> Daniel Benoy wrote:
> > I'm working on a script that will detect which network interfaces
> > are connected and mess with the routing accordingly, but I'm having
> > trouble detecting whether my USB ethernet gadget connection is up
> > or down.
> >
> > ----
> > ethtool when it's up:
> > lisa:~# ethtool usb0
> > Settings for usb0:
> > Link detected: yes
> >
> > ethtool when it's down:
> > lisa:~# ethtool usb0
> > Settings for usb0:
> > Link detected: yes
> > ----
> >
> > Unlike on the host side, the usb0 interface doesn't appear and
> > disappear, allowing udev scripts to bring up/down the interface.
> >
> > Anyone know if there's a way to detect that a network connection
> > has actually been established?
> >
>
> Is this necessary?
> Just set a higher metric on usb0, then routes thorough eth0 will be
> preferred when available. The default route through usb0 will only be
> used as a last resort when there is no other way.
>
> Such a setup works very well on my laptop. It doesn't on the
> freerunner yet, because the "ip" utility in busybox currently can't
> set metrics. But port that (or use debian with its binary ip utility)
> and you'll be fine.
>
> Helge Hafting
You should be able to find iproute2 for freerunner... I know I've got
an ipk of 2.2.26 at http://newkirk.us/om - my "OM stuff" attic, but I
think it's in the feeds as well.
Apart from that, I dug into this exact situation before,
including dealing with usb0, wrote an article about it at my blog.
(http://jthinks.com/better-freerunner-networking) You can use the
standard 'route' command to set metrics, so iproute2 isn't required.
j
More information about the community
mailing list