View topic - How to get notified when an eth interface goes link down?

How to get notified when an eth interface goes link down?

Discussion about the general applications that run on QNX6

How to get notified when an eth interface goes link down?

Postby Heimeyisdead » Tue Feb 11, 2020 1:45 pm

We have an application managing TCP socket that are created with socket() and listen(). As TCP sockets are created, we keep a list of the host and port info. When a socket is closed, we clear the host and port info from our list. When the ethernet port gets disconnected (link down), the host and port info may no longer be valid. Flushing our list based on an inactivity timer is not a good option. We would like to flush the list when we lose the ethernet link.

My question is: How can our application get notified when the ethernet link that our listen socket is bound to goes link down without having to poll the driver with a devctrl() call.

Many thanks in advance for any advice or relevant info.

- Ken
Heimeyisdead
New Member
 
Posts: 2
Joined: Mon Apr 15, 2019 3:49 pm

Re: How to get notified when an eth interface goes link down

Postby Tim » Tue Feb 11, 2020 3:24 pm

Are you not using SO_KEEPALIVE as one of your socket options? Then specify a TCP_KEEPALIVE time for how often it checks the connection is 'alive'. You can then close down and clean up when you are told a connection is dead. All for the cost of a bit of extra network traffic.

There is no real mechanism to tell you when the link is truly down. You can probably setup io_notify() to get notified when it goes down as far as QNX is concerned (ie cable unplugged). But that would just tell you if the cable was unplugged from the back of the QNX machine. It wouldn't tell you if the cable was unplugged from the router side or the router itself was powered down and so on.

Tim
Tim
Senior Member
 
Posts: 1480
Joined: Wed Mar 10, 2004 12:28 am

Re: How to get notified when an eth interface goes link down

Postby Heimeyisdead » Tue Feb 11, 2020 4:00 pm

Thank you Tim. I will look into io_notify().

Yes, we are using keep alives, but there is a trade-off with how short the keep alive is versus having slow connections dropped too early.

thanks,

- Ken
Heimeyisdead
New Member
 
Posts: 2
Joined: Mon Apr 15, 2019 3:49 pm

Re: How to get notified when an eth interface goes link down

Postby Tim » Tue Feb 11, 2020 7:39 pm

As I mentioned, io-notify will only help you when the cable is unplugged locally from the QNX machine. I would imagine that to be a very rare case (other than when you are testing) in real life.

Note: The TCP Keepalive time has nothing to do network speed and isn't affected by slow connections unless your remote side is across the world over satellite where responses may be delayed by longer than the TCP stack expects. The Keepalive time is just how often you check that the remote side is still alive. For most applications I would think once a minute (maybe very aggressively at 10 seconds) is plenty to do a housekeeping check for dead connections unless you have a LOT of connections happening regularly and are very memory constrained with regards to having old ones lurking around.

Tim
Tim
Senior Member
 
Posts: 1480
Joined: Wed Mar 10, 2004 12:28 am

Re: How to get notified when an eth interface goes link down

Postby Tim » Tue Feb 11, 2020 7:42 pm

Tim wrote:As I mentioned, io-notify will only help you when the cable is unplugged locally from the QNX machine. I would imagine that to be a very rare case (other than when you are testing) in real life.

Note: The TCP Keepalive time has nothing to do network speed and isn't affected by slow connections unless your remote side is across the world over satellite where responses may be delayed by longer than the TCP stack expects. The Keepalive time is just how often you check that the remote side is still alive. For most applications I would think once a minute (maybe very aggressively at once per 10 seconds) is plenty to do a housekeeping check for dead connections unless you have a LOT of connections happening regularly and are very memory constrained with regards to having old ones lurking around.

Tim
Tim
Senior Member
 
Posts: 1480
Joined: Wed Mar 10, 2004 12:28 am


Return to QNX6 - Applications

Who is online

Users browsing this forum: No registered users and 1 guest