# Carp on FreeBSD 10.1, kernel: ifa_add_loopback_route: insertion failed: 17



## RockerMan (Jan 18, 2016)

Hi

I'm setting up carp on FreeBSD 10.1

```
FreeBSD stunnel_carp2 10.1-RELEASE-p26 FreeBSD 10.1-RELEASE-p26
```
CARP is work

```
Jan 18 12:57:35 stunnel_carp1 devd: Executing '/etc/rc.d/dhclient quietstart em0'
Jan 18 13:02:48 stunnel_carp1 kernel: carp: VHID 1@em0: BACKUP -> MASTER (master down)
```
but in /var/log/messages give error

```
Jan 18 13:02:48 stunnel_carp1 kernel: ifa_add_loopback_route: insertion failed: 17
```

Not found in google resolve this error, maybe somebody already solved it?

my config files
master rc.conf:

```
ifconfig_em0="inet 10.10.0.71 netmask 255.255.255.0"
ifconfig_em0_alias0="inet alias 10.10.0.73 netmask 255.255.255.0 vhid 1 advskew 0 pass testpass"
```
backup rc.conf:

```
ifconfig_em0="inet 10.10.0.72 netmask 255.255.255.0"
ifconfig_em0_alias0="inet alias 10.10.0.73 netmask 255.255.255.0 vhid 1 advskew 100 pass testpass"
```
sysctl.conf:

```
net.inet.ip.forwarding=1
net.inet.carp.allow=1
net.inet.carp.preempt=1
net.inet.carp.log=2
```


----------



## SirDice (Jan 18, 2016)

RockerMan said:


> sysctl.conf:
> 
> ```
> net.inet.ip.forwarding=1
> ```


Don't set this in sysctl.conf. Use this in /etc/rc.conf:

```
gateway_enable="YES"
```
No need to set this, it's the default:

```
net.inet.carp.allow=1
```

Only useful if you have more than one carp(4) interface on the same machine:

```
net.inet.carp.preempt=1
```


----------



## RockerMan (Jan 18, 2016)

Hi , SirDice

So, i'm use only one carp interface, but without

```
net.inet.carp.preempt=1
```
master server does not automatically return in the erver master mode, after its on. Only if manually disabled the interface to the backup server.
Error persists


```
Jan 18 13:56:21 stunnel_carp1 kernel: carp: VHID 1@em0: BACKUP -> MASTER (master down)
Jan 18 13:57:50 stunnel_carp1 kernel: carp: demoted by 240 to 240 (interface down)
Jan 18 13:57:50 stunnel_carp1 kernel: em0: link state changed to DOWN
Jan 18 13:58:06 stunnel_carp1 kernel: carp: VHID 1@em0: INIT -> BACKUP
Jan 18 13:58:06 stunnel_carp1 kernel: carp: demoted by -240 to 0 (interface up)
Jan 18 13:58:06 stunnel_carp1 kernel: em0: link state changed to UP
Jan 18 13:58:06 stunnel_carp1 devd: Executing '/etc/rc.d/dhclient quietstart em0'
Jan 18 13:58:59 stunnel_carp1 kernel: carp: VHID 1@em0: BACKUP -> MASTER (master down)
Jan 18 13:58:59 stunnel_carp1 kernel: ifa_add_loopback_route: insertion failed: 17
```


```
Jan 18 13:56:19 stunnel_carp2 kernel: em0: link state changed to DOWN
Jan 18 13:56:32 stunnel_carp2 kernel: carp: VHID 1@em0: INIT -> BACKUP
Jan 18 13:56:32 stunnel_carp2 kernel: carp: demoted by -240 to 0 (interface up)
Jan 18 13:56:32 stunnel_carp2 kernel: em0: link state changed to UP
Jan 18 13:56:32 stunnel_carp2 devd: Executing '/etc/rc.d/dhclient quietstart em0'
Jan 18 13:57:53 stunnel_carp2 kernel: carp: VHID 1@em0: BACKUP -> MASTER (master down)
Jan 18 13:57:53 stunnel_carp2 kernel: ifa_add_loopback_route: insertion failed: 17
Jan 18 13:58:57 stunnel_carp2 kernel: carp: demoted by 240 to 240 (interface down)
Jan 18 13:58:57 stunnel_carp2 kernel: em0: link state changed to DOWN
Jan 18 13:59:09 stunnel_carp2 kernel: carp: VHID 1@em0: INIT -> BACKUP
Jan 18 13:59:09 stunnel_carp2 kernel: carp: demoted by -240 to 0 (interface up)
Jan 18 13:59:09 stunnel_carp2 kernel: em0: link state changed to UP
Jan 18 13:59:09 stunnel_carp2 devd: Executing '/etc/rc.d/dhclient quietstart em0'
```


----------



## SirDice (Jan 18, 2016)

Why is it trying to run dhclient(8) when the interface comes up? You have static addresses so there's no need for it and may be the cause of the error.


----------



## RockerMan (Jan 18, 2016)

This

```
Jan 18 13:56:32 stunnel_carp2 devd: Executing '/etc/rc.d/dhclient quietstart em0'
```
from configuration file /etc/devd.conf

```
# Try to start dhclient on Ethernet-like interfaces when the link comes
# up.  Only devices that are configured to support DHCP will actually
# run it.  No link down rule exists because dhclient automatically exits
# when the link goes down.
```
iI disable scanning interface when he picked up

```
#notify 0 {
#<----->match "system"<><------>"IFNET";
#<----->match "type"<--><------>"LINK_UP";
#<----->media-type<----><------>"ethernet";
#<----->action "/etc/rc.d/dhclient quietstart $subsystem";
#};
```
it did not help

```
Jan 18 16:29:07 stunnel_carp1 kernel: em0: link state changed to DOWN
Jan 18 16:29:32 stunnel_carp1 kernel: carp: VHID 1@em0: INIT -> BACKUP
Jan 18 16:29:32 stunnel_carp1 kernel: carp: demoted by -240 to 0 (interface up)
Jan 18 16:29:32 stunnel_carp1 kernel: em0: link state changed to UP
Jan 18 16:29:33 stunnel_carp1 kernel: carp: VHID 1@em0: BACKUP -> MASTER (preempting a slower master)
Jan 18 16:29:33 stunnel_carp1 kernel: ifa_add_loopback_route: insertion failed: 17
```


----------



## RockerMan (Jan 19, 2016)

mMaybe it's a bug?
aAnd need to send to maintainers of the product?


----------



## rootwyrm (Jan 23, 2016)

This doesn't look like a bug to me - this looks like expected behavior. You haven't posted the output of `netstat -rn` but I'm sure there's an existing 127.0.0.1 route in there. Because of the way dhclient works, it gets in the way of other things. Thus when carp() calls `ifa_add_loopback_route()` on a `dhclient` controlled interface it will and *should *return error. In this case, the error is harmless - but the configuration is definitely wrong. carp() and `dhclient` should not be run on the same interface.


----------



## SirDice (Jan 25, 2016)

While working on a FreeBSD 9.3 server for a client I noticed the same behavior. For some reason dhclient(8) gets called when the carp(4) interface comes up. There's no reason why it should do that, we have static addresses on everything and do not use DHCP. Apparently setting net.inet.carp.preempt causes this, you don't get the messages if you turn preempt off.


----------

