When you configure advskew in CARP to be something other than 0, then try to change it back to 0, FreeBSD refuses to do so. It can be changed to any value other than 0, but never back to 0. This is a semi-common scenario, as it's how people would generally demote a system from master to backup for maintenance or other purposes, and would generally want to set it back to 0 afterwards. Initially setting it to 0 works fine. Tested on 10.0 release and 10.1-RC3, both behave the same. The following shows the issue and how to replicate. # ifconfig em0 vhid 55 advskew 0 pass PASSWORD alias 192.168.124.222/24 # ifconfig em0 em0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM> ether 00:0c:29:11:5e:be inet 192.168.124.132 netmask 0xffffff00 broadcast 192.168.124.255 inet 192.168.124.222 netmask 0xffffff00 broadcast 192.168.124.255 vhid 55 nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL> media: Ethernet autoselect (1000baseT <full-duplex>) status: active carp: MASTER vhid 55 advbase 1 advskew 0 Change it, it'll work. # ifconfig em0 vhid 55 advskew 100 # ifconfig em0 | grep carp: carp: MASTER vhid 55 advbase 1 advskew 100 Try changing it back to 0, and it won't. # ifconfig em0 vhid 55 advskew 0 # ifconfig em0 | grep carp: carp: MASTER vhid 55 advbase 1 advskew 100 But can change it to 1 or other values. # ifconfig em0 vhid 55 advskew 1 # ifconfig em0 | grep carp: carp: MASTER vhid 55 advbase 1 advskew 1
Looking into sys/netinet/ip_carp.c at line 1706: if (carpr.carpr_advskew > 0) { if (carpr.carpr_advskew >= 255) { error = EINVAL; break; } sc->sc_advskew = carpr.carpr_advskew; } It silently accepts 0 as a good value (no error returned) but it doesn't set sc->sc_advskew. Is it expected to work this way?
Created attachment 151093 [details] Fix set advskew back to 0 The attached patch make it possible to set advskew back to 0
Created attachment 151123 [details] 2nd attempt, fix also advbase check There is one more issue, advbase should be >= 1 and <= 255, it makes proper check and also fix default advbase value on ifconfig to 1
Please ignore second patch, it has issues, will send a new one shortly
Created attachment 151128 [details] 3rd version - Fix advskew and advbase checks, set default advbase for new entries This version changes ifconfig to set default advbase to 1 on new entries, and because of that make advbase and advskew checks correct on kernel side
A commit references this bug: Author: loos Date: Tue Jan 6 13:07:14 UTC 2015 New revision: 276751 URL: https://svnweb.freebsd.org/changeset/base/276751 Log: Remove the check that prevent carp(4) advskew to be set to '0'. CARP devices are created with advskew set to '0' and once you set it to any other value in the valid range (0..254) you can't set it back to zero. The code in question is also used to prevent that zeroed values overwrite the CARP defaults when a new CARP device is created. Since advskew already defaults to '0' for newly created devices and the new value is guaranteed to be within the valid range, it is safe to overwrite it here. PR: 194672 Reported by: cmb@pfsense.org In collaboration with: garga Tested by: garga MFC after: 2 weeks Changes: head/sys/netinet/ip_carp.c
A commit references this bug: Author: loos Date: Mon Feb 2 11:42:36 UTC 2015 New revision: 278075 URL: https://svnweb.freebsd.org/changeset/base/278075 Log: MFC r276751: Remove the check that prevent carp(4) advskew to be set to '0'. CARP devices are created with advskew set to '0' and once you set it to any other value in the valid range (0..254) you can't set it back to zero. The code in question is also used to prevent that zeroed values overwrite the CARP defaults when a new CARP device is created. Since advskew already defaults to '0' for newly created devices and the new value is guaranteed to be within the valid range, it is safe to overwrite it here. PR: 194672 Reported by: cmb@pfsense.org Changes: _U stable/10/ stable/10/sys/netinet/ip_carp.c
The fix was committed to -head and 10-stable. Thanks!