carp: link state is DOWN until it becomes a MASTER

This is consitent with other BSD's handling of CARP and means
we don't have to carry a custom flag for it.
This commit is contained in:
roy 2020-10-12 15:18:48 +00:00
parent f184b4ad4d
commit 30ba5d0082
3 changed files with 8 additions and 24 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: carp.4,v 1.7 2020/01/16 12:56:39 kardel Exp $
.\" $NetBSD: carp.4,v 1.8 2020/10/12 15:18:48 roy Exp $
.\" $OpenBSD: carp.4,v 1.19 2005/08/09 09:52:12 jmc Exp $
.\"
.\" Copyright (c) 2003, Ryan McBride. All rights reserved.
@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd January 16, 2020
.Dd October 12, 2020
.Dt CARP 4
.Os
.Sh NAME
@ -76,20 +76,6 @@ or through the
.Dv SIOCSVH
ioctl.
.Pp
Setting the
.Cm link0
parameter will cause the carp interface to report
.Dv LINK_STATE_DOWN
in non
.Dv MASTER/BACKUP
mode instead of
.Dv LINK_STATE_UNKNOWN
as link status.
This prevents routing software to announce routes for the carp
interface when in
.Dv INIT
mode.
.Pp
Additionally, there are a number of global parameters which can be set using
.Xr sysctl 8 :
.Bl -tag -width xxxxxxxxxxxxxxxxxxxxxxxxxx

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_carp.c,v 1.112 2020/10/12 11:07:27 roy Exp $ */
/* $NetBSD: ip_carp.c,v 1.113 2020/10/12 15:18:48 roy Exp $ */
/* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */
/*
@ -33,7 +33,7 @@
#endif
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.112 2020/10/12 11:07:27 roy Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.113 2020/10/12 15:18:48 roy Exp $");
/*
* TODO:
@ -890,6 +890,7 @@ carp_clone_create(struct if_clone *ifc, int unit)
/* Overwrite ethernet defaults */
ifp->if_type = IFT_CARP;
ifp->if_output = carp_output;
ifp->if_link_state = LINK_STATE_DOWN;
carp_set_enaddr(sc);
if_register(ifp);
@ -2228,8 +2229,8 @@ carp_update_link_state(struct carp_softc *sc)
link_state = LINK_STATE_UP;
break;
default:
link_state = ((sc->sc_if.if_flags & IFF_ONLY_MASTER_UP) != 0)
? LINK_STATE_DOWN : LINK_STATE_UNKNOWN;
/* Not useable, so down makes perfect sense. */
link_state = LINK_STATE_DOWN;
break;
}
if_link_state_change(&sc->sc_if, link_state);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_carp.h,v 1.11 2020/01/16 12:56:40 kardel Exp $ */
/* $NetBSD: ip_carp.h,v 1.12 2020/10/12 15:18:48 roy Exp $ */
/* $OpenBSD: ip_carp.h,v 1.18 2005/04/20 23:00:41 mpf Exp $ */
/*
@ -133,9 +133,6 @@ struct carpreq {
unsigned char carpr_key[CARP_KEY_LEN];
};
/* enable link status up only for MASTER state */
#define IFF_ONLY_MASTER_UP IFF_LINK0
/*
* Names for CARP sysctl objects
*/