Networking Forums

Networking Forums > Computer Networking > Linux Networking > How to keep route uptodate?

Reply
Thread Tools Display Modes

How to keep route uptodate?

 
 
Florian Erfurth
Guest
Posts: n/a

 
      03-27-2009, 09:55 AM
Hi, I'm using Kubuntu on my Laptop (8.10) and on my Workstation (7.10). I'm
developing a application which works with mysql-database. The problem is, my
application "hangs" if I unplug the network-cable, which must not happen.

I examined and found out... the application hangs only on Workstation but
not on my Laptop (on Laptop I get "Connection to database failed" just as I
programmed this text, which is ok). I found out which may cause the problem:

floh@Turion:~$ route -n
Kernel-IP-Routentabelle
Ziel Router Genmask Flags Metric Ref Use Iface
192.168.7.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
0.0.0.0 192.168.7.254 0.0.0.0 UG 0 0 0 eth0

Now I unplug the cable and retry the same command at once:
floh@Turion:~$ route -n
Kernel-IP-Routentabelle
Ziel Router Genmask Flags Metric Ref Use Iface

This seems to be ok. On my workstation I tried the same, but the content of
'route -n' is unchanged before and after unplugging.

Now my question is: Which tool/daemon is responsible for updating route? Or
why wasn't route changed after unplugging network cable?

cu Floh

 
Reply With Quote
 
 
 
 
David Schwartz
Guest
Posts: n/a

 
      03-27-2009, 10:39 AM
On Mar 27, 3:55*am, Florian Erfurth <floh-erfu...@arcor.de> wrote:

> floh@Turion:~$ route -n
> Kernel-IP-Routentabelle
> Ziel * * * * * Router * * * * *Genmask * * * * Flags Metric Ref * *Use Iface
> 192.168.7.0 * * 0.0.0.0 * * * * 255.255.255.0 * U * * 1* * *0 * * * *0 eth0
> 169.254.0.0 * * 0.0.0.0 * * * * 255.255.0.0 * * U * *1000 * 0 * * * *0 eth0
> 0.0.0.0 * * * * 192.168.7.254 * 0.0.0.0 * * * * UG * *0 * * *0 * * * *0 eth0
>
> Now I unplug the cable and retry the same command at once:
> floh@Turion:~$ route -n
> Kernel-IP-Routentabelle
> Ziel * * * * * Router * * * * *Genmask * * * * Flags Metric Ref * *Use Iface
>
> This seems to be ok. On my workstation I tried the same, but the content of
> 'route -n' is unchanged before and after unplugging.


You are never guaranteed that the loss of a link will be detectable.
Links can fail in both detectable and undetectable ways.

Figure out why your application is hanging, rather than detecting that
it cannot reach the other side, and fix the application.

DS

 
Reply With Quote
 
Florian Erfurth
Guest
Posts: n/a

 
      03-27-2009, 10:52 AM
David Schwartz wrote:

> On Mar 27, 3:55Â*am, Florian Erfurth <floh-erfu...@arcor.de> wrote:
>
>> This seems to be ok. On my workstation I tried the same, but the content
>> of 'route -n' is unchanged before and after unplugging.

>
> You are never guaranteed that the loss of a link will be detectable.
> Links can fail in both detectable and undetectable ways.
>
> Figure out why your application is hanging, rather than detecting that
> it cannot reach the other side, and fix the application.

Sure I should fix my application, but how? Here is the part of the code:

if(mysql_real_connect(Connection, "192.168.0.2", "user", "password",
"database", 0, NULL, 0))
{
printf("\033[0;93m Connection was successful! \033[0m\n");
mysql_close(Connection);
}
else
printf("\033[0;93m Connection failed!!! \033[0m\n");

If I unplug ethernet cable on my laptop, the application replys "Connection
failed!!!" at once. On Workstation the app freezes at mysql_real_connect()
and after ca. 1,5minutes(!) I got the reply "Connection failed!!!". I
already tried with Timeout=5sec but it doesn't help.

cu Floh

 
Reply With Quote
 
Joe Pfeiffer
Guest
Posts: n/a

 
      03-27-2009, 12:51 PM
Florian Erfurth <floh-(E-Mail Removed)> writes:
>
> This seems to be ok. On my workstation I tried the same, but the content of
> 'route -n' is unchanged before and after unplugging.
>
> Now my question is: Which tool/daemon is responsible for updating route? Or
> why wasn't route changed after unplugging network cable?


A daemon to do that may or may not be present on your system. I've
got ifplugd running on my Debian laptop for that purpose, and it works
well.
 
Reply With Quote
 
Florian Erfurth
Guest
Posts: n/a

 
      03-27-2009, 01:58 PM
Joe Pfeiffer wrote:

> Florian Erfurth <floh-(E-Mail Removed)> writes:
>>
>> This seems to be ok. On my workstation I tried the same, but the content
>> of 'route -n' is unchanged before and after unplugging.
>>
>> Now my question is: Which tool/daemon is responsible for updating route?
>> Or why wasn't route changed after unplugging network cable?

>
> A daemon to do that may or may not be present on your system. I've
> got ifplugd running on my Debian laptop for that purpose, and it works
> well.

Thank you for your information. I found out on my Laptop there is
NetworkManager. On workstation there is no NetworkManager runnung. This
explains such behaviour.

Thank you.
cu Floh


 
Reply With Quote
 
Joe Beanfish
Guest
Posts: n/a

 
      03-27-2009, 03:58 PM
Florian Erfurth wrote:
> David Schwartz wrote:
>
>> On Mar 27, 3:55 am, Florian Erfurth <floh-erfu...@arcor.de> wrote:
>>
>>> This seems to be ok. On my workstation I tried the same, but the content
>>> of 'route -n' is unchanged before and after unplugging.

>> You are never guaranteed that the loss of a link will be detectable.
>> Links can fail in both detectable and undetectable ways.
>>
>> Figure out why your application is hanging, rather than detecting that
>> it cannot reach the other side, and fix the application.

> Sure I should fix my application, but how? Here is the part of the code:
>
> if(mysql_real_connect(Connection, "192.168.0.2", "user", "password",
> "database", 0, NULL, 0))
> {
> printf("\033[0;93m Connection was successful! \033[0m\n");
> mysql_close(Connection);
> }
> else
> printf("\033[0;93m Connection failed!!! \033[0m\n");
>
> If I unplug ethernet cable on my laptop, the application replys "Connection
> failed!!!" at once. On Workstation the app freezes at mysql_real_connect()
> and after ca. 1,5minutes(!) I got the reply "Connection failed!!!". I
> already tried with Timeout=5sec but it doesn't help.


That sounds perfectly normal and ok to me. But if you want to be friendlier
about it you could try pinging before connect. But who's to say that someone
won't chop the cable after you've connected while you're trying to execute
sql? Then you're in as bad or worse shape. Your app must be able to handle
network failures.
 
Reply With Quote
 
Joe Pfeiffer
Guest
Posts: n/a

 
      03-27-2009, 07:16 PM
Joe Beanfish <(E-Mail Removed)> writes:

> Florian Erfurth wrote:
>> David Schwartz wrote:
>>
>>> On Mar 27, 3:55 am, Florian Erfurth <floh-erfu...@arcor.de> wrote:
>>>
>>>> This seems to be ok. On my workstation I tried the same, but the content
>>>> of 'route -n' is unchanged before and after unplugging.
>>> You are never guaranteed that the loss of a link will be detectable.
>>> Links can fail in both detectable and undetectable ways.
>>>
>>> Figure out why your application is hanging, rather than detecting that
>>> it cannot reach the other side, and fix the application.

>> Sure I should fix my application, but how? Here is the part of the code:
>>
>> if(mysql_real_connect(Connection, "192.168.0.2", "user",
>> "password", "database", 0, NULL, 0))
>> {
>> printf("\033[0;93m Connection was successful! \033[0m\n");
>> mysql_close(Connection);
>> }
>> else
>> printf("\033[0;93m Connection failed!!! \033[0m\n");
>>
>> If I unplug ethernet cable on my laptop, the application replys
>> "Connection failed!!!" at once. On Workstation the app freezes at
>> mysql_real_connect() and after ca. 1,5minutes(!) I got the reply
>> "Connection failed!!!". I already tried with Timeout=5sec but it
>> doesn't help.

>
> That sounds perfectly normal and ok to me. But if you want to be friendlier
> about it you could try pinging before connect. But who's to say that someone
> won't chop the cable after you've connected while you're trying to execute
> sql? Then you're in as bad or worse shape. Your app must be able to handle
> network failures.


His application is handling network failures as well as it can under
the circumstances: the mysql client library is waiting a long, long
time to timeout when the network is disconnected, after which his
application is finally able to do something reasonable.

Increasing the probability that the timeout will be much shorter is a
good thing to do, and is the direction he's headed.
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      03-27-2009, 09:43 PM
On Mar 27, 7:58*am, Florian Erfurth <floh-erfu...@arcor.de> wrote:

> Thank you for your information. I found out on my Laptop there is
> NetworkManager. On workstation there is no NetworkManager runnung. This
> explains such behaviour.


Right, and that's a great help for failure conditions NM can detect.
But there are many failure conditions NM cannot detect. So *relying*
on NM to detect the problem is not a solution.

NM will provide a great quick detection for the subset of problems it
can detect. But there are many it cannot. For example, suppose it's
the cable that goes to the server that's pulled out. NM cannot detect
this.

DS
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      03-27-2009, 09:43 PM
On Mar 27, 4:52*am, Florian Erfurth <floh-erfu...@arcor.de> wrote:

> Sure I should fix my application, but how? Here is the part of the code:
>
> * * if(mysql_real_connect(Connection, "192.168.0.2", "user", "password",
> "database", 0, NULL, 0))
> * * {
> * * * * printf("\033[0;93m Connection was successful! \033[0m\n");
> * * * * mysql_close(Connection);
> * * }
> * * else
> * * * * printf("\033[0;93m Connection failed!!! \033[0m\n");
>
> If I unplug ethernet cable on my laptop, the application replys "Connection
> failed!!!" at once. On Workstation the app freezes at mysql_real_connect()
> and after ca. 1,5minutes(!) I got the reply "Connection failed!!!". I
> already tried with Timeout=5sec but it doesn't help.


Your code is asking mysql to block until it can either make a
connection or determine that one cannot be made. If that's not what
you want, your code is broken.

DS
 
Reply With Quote
 
Joe Pfeiffer
Guest
Posts: n/a

 
      03-28-2009, 01:33 AM
Florian Erfurth <floh-(E-Mail Removed)> writes:
>
> If I unplug ethernet cable on my laptop, the application replys "Connection
> failed!!!" at once. On Workstation the app freezes at mysql_real_connect()
> and after ca. 1,5minutes(!) I got the reply "Connection failed!!!". I
> already tried with Timeout=5sec but it doesn't help.


Spending some time looking at the documentation for mysql_options(), I
wonder if something's up with your use of timeout -- the documentation
sure gives the impression that with that setting it ought to be giving
up much more quickly than it is.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VPN client adds wrong route to local route table snowdog_2112 Windows Networking 7 11-01-2005 02:05 PM
The best route please... Conbloodyfused Windows Networking 1 07-05-2005 04:08 PM
route orangeKDS@mail.ru Linux Networking 4 12-25-2004 05:54 PM
What's the best way to keep uptodate with Wi-Fi developments? Arawak Wireless Internet 0 03-07-2004 12:40 AM
route and static route to a gateway Sting Linux Networking 2 02-21-2004 03:35 AM



1 2 3 4 5 6 7 8 9 10 11