Closing Ethernet

Gene Smith gds at
Tue Oct 21 20:31:47 UTC 2008

Leon Pollak wrote:
> On Friday October 17 2008, Chris Johns wrote:
>> Leon Pollak wrote:
>>> Hello, all.
>>> I need to exit from the application which uses networking.
>>> What is the proper way to close networking?
>>> The only thing relevant I found was rtems_bsdnet_detach(...), but nobody
>>> seems to call it...
>>> And I do not know how...:-(
>>> And it seems to me not the correct routine...
> Thanks, Chris.
> I hope, my two other mails will be commented soon too...:-)
> Waiting for the comments to finalize the corrections...
>> There is not single defined way to close networking. Your application
>> should close all sockets. For TCP you may need to consider the linger
>> option. For UDP sockets your application handling the protocol may need to
>> signal a disconnect to the remote end. Once all sockets are closed and you
>> are happy the data has been sent you could "down" the interface. Check the
>> FreeBSD ifconfig man page for details. The down option is documented as:
>> down    Mark an interface ``down''.  When an interface is marked
>> 	``down'', the system will not attempt to transmit messages
>> 	through that interface.  If possible, the interface will be reset
>> 	to disable reception as well.  This action does not automatically
>> 	disable routes using the interface.
>> After this there is nothing else you need to do.
> Sure I miss something.
> How can I issue ifconfig down...?

ioctl() maybe, SIOCSIFFLAGS  ??

>> The rtems_bsdnet_detach is available to provide a means for a specific
>> driver to release any hardware resources it has. If RTEMS ever needs hot
>> swap or plug and play support this can be used.
> Still, I do not know how to call it.
> May be I explained myself bad. Sorry.
> What I need is to stop all the Ethernet HW as I am exiting from the 
> application into boot loader to load another application.
> If the HW will remain active, then, for example, incoming packet will cause an 
> interrupt, while there is no code to server it.
> So, how can I do this from my application?

This sounds similar to what I just solved, but maybe in the opposite 
direction. Bootloader (uMon) running ethernet/UDP loads RTEMS and 
branches to RTEMS at startup. Eth driver in bootloader was still doing 
DMA to RAM and caused RTEMS to re-init ethernet and crash while it was 
starting up. Had to reset ethernet hardware on entering RTEMS (start.S) 
(or could do same thing before leaving bootloader). So adding code to 
reset the mac and phy at beginning of start.S stopped ethernet activity 
and fixed it. There may be better way but this worked for me but is 
definitely not a "graceful" shutdown.

>> Regards
>> Chris
> Again, thanks and BR

More information about the users mailing list