Can't delete a route in FreeBSD 9.2

Hello,

I'm trying FreeBSD 9.2-RELEASE and faced with one trouble. I'm using the MPD5.7 client to connect to the internet provider. After connecting the script is run that deletes the route to the VPN server and adds the new route via the local gateway.

This is script
Code:
#!/bin/sh

route delete $8
route add $8 10.165.32.1
route delete default
route add default $4

route delete $8 does not work

For example, I deleted the script and tried to delete the route manually.

I.e. from
Code:
root@Eviko:/home/mrstalker # netstat -nrf inet
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            10.165.32.1        UGS         0       27    re0
2.93.209.127       link#7             UHS         0        0    lo0
10.0.0.0/8         10.165.32.1        UGS         0       14    re0
10.165.32.0/21     link#3             U           0 12836759    re0
10.165.38.3        link#3             UHS         0        0    lo0
85.21.230.206      link#7             UH          0        0    ng0
127.0.0.1          link#6             UH          0       57    lo0

Delete

Code:
root@Eviko:/home/mrstalker # route delete 85.21.230.206
route: writing to routing socket: Address already in use
delete host 85.21.230.206 fib 0: gateway uses the same route

The same operation in FreeBSD 9.1-RELEASE runs successfully.

Code:
root@Test:/home/mrstalker # route delete 85.21.230.206
delete host 85.21.230.206

Also, this trouble is repeated on the two clean (9.1 and 9.2) virtual machines. Kernels - GENERIC without changes.
 
You can't delete that route because the IP address is still bound to the interface. If you remove the IP address from the interface the route will disappear automatically.
 
Then why in FreeBSD 9.1 (and earlier) the route is deleted without problems?
Code:
root@Test2:/home/mrstalker # ifconfig ng0
ng0: flags=88d1<UP,POINTOPOINT,RUNNING,NOARP,SIMPLEX,MULTICAST> metric 0 mtu 1460                                                                             0
        inet 176.15.246.28 --> 85.21.230.206 netmask 0xffffffff
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
root@Test2:/home/mrstalker # netstat -nrf inet
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            10.165.32.1        UGS         0       45    re0
10.0.0.0/8         10.165.32.1        UGS         0        0    re0
10.165.32.0/21     link#1             U           0   115106    re0
10.165.35.154      link#1             UHS         0        0    lo0
85.21.230.206      link#3             UH          0        0    ng0
127.0.0.1          link#2             UH          0        0    lo0
176.15.246.28      link#3             UHS         0        0    lo0
root@Test2:/home/mrstalker # route delete 85.21.230.206
delete host 85.21.230.206
root@Test2:/home/mrstalker # netstat -nrf inet
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            10.165.32.1        UGS         0       83    re0
10.0.0.0/8         10.165.32.1        UGS         0        0    re0
10.165.32.0/21     link#1             U           0   115132    re0
10.165.35.154      link#1             UHS         0        0    lo0
127.0.0.1          link#2             UH          0        0    lo0
176.15.246.28      link#3             UHS         0        0    lo0
root@Test2:/home/mrstalker # route add 85.21.230.206 10.165.32.1
add host 85.21.230.206: gateway 10.165.32.1
root@Test2:/home/mrstalker # netstat -nrf inet
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            10.165.32.1        UGS         0      104    re0
10.0.0.0/8         10.165.32.1        UGS         0        0    re0
10.165.32.0/21     link#1             U           0   115152    re0
10.165.35.154      link#1             UHS         0        0    lo0
85.21.230.206      10.165.32.1        UGHS        0        0    re0
127.0.0.1          link#2             UH          0        0    lo0
176.15.246.28      link#3             UHS         0        0    lo0
root@Test2:/home/mrstalker # route change default 85.21.230.206
change net default: gateway 85.21.230.206
root@Test2:/home/mrstalker # netstat -nrf inet
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            85.21.230.206      UGS         0      133    ng0
10.0.0.0/8         10.165.32.1        UGS         0        0    re0
10.165.32.0/21     link#1             U           0   115179    re0
10.165.35.154      link#1             UHS         0        0    lo0
85.21.230.206      10.165.32.1        UGHS        0       11    re0
127.0.0.1          link#2             UH          0        0    lo0
176.15.246.28      link#3             UHS         0        0    lo0
root@Test2:/home/mrstalker # ping google.com
PING google.com (173.194.32.135): 56 data bytes
64 bytes from 173.194.32.135: icmp_seq=0 ttl=56 time=4.321 ms
64 bytes from 173.194.32.135: icmp_seq=1 ttl=56 time=4.325 ms
64 bytes from 173.194.32.135: icmp_seq=2 ttl=56 time=4.277 ms
64 bytes from 173.194.32.135: icmp_seq=3 ttl=56 time=4.285 ms
^C
--- google.com ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 4.277/4.302/4.325/0.021 ms

In FreeBSD 9.2:
Code:
root@Eviko:/home/mrstalker # ifconfig ng0
ng0: flags=88d1<UP,POINTOPOINT,RUNNING,NOARP,SIMPLEX,MULTICAST> metric 0 mtu 1460                                                                             0
        inet 2.92.203.93 --> 85.21.230.206 netmask 0xffffffff
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
root@Eviko:/home/mrstalker # netstat -nrf inet
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            10.165.32.1        UGS         0 48818724    re0
2.92.203.93        link#7             UHS         0        0    lo0
10.0.0.0/8         10.165.32.1        UGS         0      692    re0
10.165.32.0/21     link#3             U           0 48770253    re0
10.165.38.3        link#3             UHS         0        0    lo0
85.21.230.206      link#7             UH          0        0    ng0
127.0.0.1          link#6             UH          0        0    lo0
root@Eviko:/home/mrstalker # route delete 85.21.230.206
route: writing to routing socket: Address already in use
delete host 85.21.230.206 fib 0: gateway uses the same route
What has changed?
And how now can change the route?
 
According to the DIAGNOSTICS section of the route(8)() man page:
gateway uses the same route A change operation resulted in a route whose gateway uses the same route as the one being changed. The next-hop gateway should be reachable through a different route.

Try # route delete -net 85.21.230.206 -iface ng0 -fib 0
 
Code:
root@Eviko:/home/mrstalker # route delete -inet 85.21.230.206 -iface ng0 -fib 0
route: writing to routing socket: Address already in use
delete host 85.21.230.206: gateway ng0 fib 0: gateway uses the same route
Does not work...
Why?
I'm trying update 9.1 to 9.2 (svn://svn.freebsd.org/base/releng/9.2/). After the update, there is the same problem.
 
What you're trying to delete isn't really a route (as indicated by the link#), it's an address on an interface (ng0).
 
Then how can I get this result?
Code:
Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            85.21.230.206      UGS         0      133    ng0
85.21.230.206      10.165.32.1        UGHS        0       11    re0
For my internet provider need that route to the VPN server go via gate 10.165.32.1 at interface re0.
When connecting creates the route to the VPN server via interface ng0, what will not work.
I need get this route via the local gate.
How to do it? I have no idea...
 
SirDice said:
What you're trying to delete isn't really a route (as indicated by the link#), it's an address on an interface (ng0).

You are right, @SirDice. All is clearly explained into the section 30.2. Gateways and Routes of the FreeBSD Handbook:
This is called routing. A "route" is a defined pair of addresses: a "destination" and a "gateway". The pair indicates that when trying to get to this destination, communicate through this gateway. There are three types of destinations: individual hosts, subnets, and "default". The "default route" is used if none of the other routes apply. There are also three types of gateways: individual hosts, interfaces (also called "links"), and Ethernet hardware (MAC) addresses.

@MrStalker, have you tried using ifconfig(8)() instead route(8)() command to do that? Try # ifconfig ng0 delete 85.21.230.206

What related entries do you have in /etc/rc.conf?

I suggest you to review your configuration by using as reference this recent tutorial.
 
Last edited by a moderator:
Also you can change your if-up.sh as following:
Code:
#!/bin/sh
gateway_ip="10.165.32.1"

route add $4 $gateway_ip
route delete default
route add default $4
 
cpm said:
@MrStalker, have you tried using ifconfig(8)() instead route(8)() command to do that? Try # ifconfig ng0 delete 85.21.230.206
Code:
root@Eviko:/home/mrstalker # ifconfig ng0 delete 85.21.230.206
ifconfig: ioctl (SIOCDIFADDR): Can't assign requested address
root@Eviko:/home/mrstalker # ifconfig ng0
ng0: flags=88d1<UP,POINTOPOINT,RUNNING,NOARP,SIMPLEX,MULTICAST> metric 0 mtu 1460
        inet 2.93.209.197 --> 85.21.230.206 netmask 0xffffffff
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

cpm said:
What related entries do you have in /etc/rc.conf?
Code:
root@Eviko:/home/mrstalker # cat /etc/rc.conf
hostname="Eviko"
keymap="ru.koi8-r.win.kbd"
ifconfig_re0="SYNCDHCP"
defaultrouter="10.165.32.1"
sshd_enable="YES"
ftpd_enable="YES"
ntpd_enable="YES"
powerd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="NO"
fsck_y_enable="YES"
background_fsck="NO"

cpm said:
I suggest you to review your configuration by using as reference this recent tutorial.
Thanks for the tutorial. But it is written for use mpd5 as the server.
I configured mpd5 according to the internet provider instruction, and two years ago I edited configuration file for a current specification of the provider.

This is my mpd.conf:
Code:
root@Eviko:/home/mrstalker # cat /usr/local/etc/mpd5/mpd.conf
default:
        load l2tp_client
l2tp_client:
        create bundle static B1
        set iface up-script /usr/local/etc/mpd5/up.sh
        set iface down-script /usr/local/etc/mpd5/down.sh
        create link static L1 l2tp
        set link action bundle B1
        set auth authname mrstalker
        set auth password password
        set link max-redial 0
        set l2tp peer tp.internet.beeline.ru
        open

cpm said:
Also you can change your if-up.sh as following:
Code:
#!/bin/sh
gateway_ip="10.165.32.1"

route add $4 $gateway_ip
route delete default
route add default $4
Did not help...
And manually:
Code:
root@Eviko:/home/mrstalker # route add 85.21.230.206 10.165.32.1
route: writing to routing socket: File exists
add host 85.21.230.206: gateway 10.165.32.1 fib 0: route already in table
 
Last edited by a moderator:
ifconfig ng0 destroy probably works better than ifconfig ng0 delete 85.21.230.206. The interface ng0 is a point-to-point connection and the IP address you're trying to delete is the other end of the point-to-point connection.
 
MrStalker said:
Thanks for the tutorial. But it is written for use mpd5 as the server.
I configured mpd5 according to the internet provider instruction, and two years ago I edited configuration file for a current specification of the provider.

It was an oversight, sorry for that, you should go ahead, try to run @SirDice's command and see what happens ;)

Show the output of # ifconfig ng0 destroy
 
Last edited by a moderator:
Unfortunately...
Code:
ng0: flags=88d1<UP,POINTOPOINT,RUNNING,NOARP,SIMPLEX,MULTICAST> metric 0 mtu 1460
        inet 78.106.211.37 --> 85.21.230.206 netmask 0xffffffff
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
root@Eviko:/home/mrstalker # ifconfig ng0 destroy
ifconfig: SIOCIFDESTROY: Invalid argument
 
MrStalker said:
Unfortunately...
Code:
ng0: flags=88d1<UP,POINTOPOINT,RUNNING,NOARP,SIMPLEX,MULTICAST> metric 0 mtu 1460
        inet 78.106.211.37 --> 85.21.230.206 netmask 0xffffffff
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
root@Eviko:/home/mrstalker # ifconfig ng0 destroy
ifconfig: SIOCIFDESTROY: Invalid argument

Seems that ifconfig <interface> destroy only works on devices created via ifconfig <interface> create

For a possible solution, read: http://lists.freebsd.org/pipermail/freebsd-questions/2012-January/237128.html.
 
MrStalker said:
@cpm, thank you for the help in Private Messages, but unsuccessfully :(

After many experiments, I found the source of the problem.
The problem appear since r248070 in the HEAD.
http://lists.freebsd.org/pipermail/svn-src-head/2013-March/045550.html
That explains it...

But, what to do now?
How to get the necessary route?

There is still a problem related to p2p routes due to their different behavior (so PINNED flag is set to the other tunnel end which is wrong). I'll try to fix this in HEAD soon
 
Last edited by a moderator:
Ok!
melifaro said:
There is still a problem related to p2p routes due to their different behavior (so PINNED flag is set to the other tunnel end which is wrong). I'll try to fix this in HEAD soon
Sure hope so :)
All great thanks! Especially @cpm :)

I hope for the best, what will be possible to solve this problem normally.

" said:
Is there any workaround except rollback to 9.1?
As temporary solution, i wrote the patch (attached).
Using patch:
# tar xvzf route-fix.patch.tgz
# cd /usr/src
# patch < /PATH/TO/route-fix.patch
After that, need to rebuild "world" and kernel.
After rebuild, the route can be deleted as before.

UPDATE: Reattached patch.
 

Attachments

  • route-fix.patch.tgz
    771 bytes · Views: 477
Last edited by a moderator:

That discussion thread didn't shed any light on the issue though. It hints that setfib(1) is the solution, however nothing else new under the sun.
I tried setting up mpd along with two routing tables, 0 as the default system routing table and 1 as the routing table for mpd.

The two routing tables along with the vpn interface details are posted below.
Code:
root@nibbler:~ # setfib 0 netstat -rnf inet
Routing tables

Internet:
Destination        Gateway            Flags      Netif Expire
default            79.138.64.249      UGS         ng0
10.0.16.79         link#3             UHS         lo0
79.138.64.249      link#3             UH          ng0
127.0.0.1          link#2             UH          lo0
192.168.23.0/25    link#1             U        vtnet0
192.168.23.121     link#1             UHS         lo0

root@nibbler:~ # setfib 1 netstat -rnf inet
Routing tables (fib: 1)

Internet:
Destination        Gateway            Flags      Netif Expire
default            192.168.23.1       UGS      vtnet0
79.138.64.249      link#3             UH          ng0
127.0.0.1          link#2             UH          lo0
192.168.23.0/25    link#1             U        vtnet0

root@nibbler:~ # ifconfig ng0
ng0: flags=88d1<UP,POINTOPOINT,RUNNING,NOARP,SIMPLEX,MULTICAST> metric 0 mtu 1356
        inet 10.0.16.86 --> 79.138.64.249 netmask 0xffffffff
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

mpd was executed with
Code:
setfib 1 mpd
mpd.conf contains no scripts or settings that in anyway modifies the routing tables. I manually added the default route in fib 0. I also noticed that the local vpn address, 10.0.16.79 and the ethernet interface address, 192.168.23.121, are both absent in fib 1, while they exist in fib 0.

The issue I have is that the kernel is issuing warnings about a loop on ng0
Code:
nibbler kernel: Loop detected on ng0
 
Can you show the content of the following scripts?

io-up-pptp.sh and io-down-pptp.sh
 
Back
Top