From nobody@FreeBSD.org  Fri May 13 11:25:44 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7340316A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 13 May 2005 11:25:44 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4357343D5E
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 13 May 2005 11:25:44 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j4DBPhkn054437
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 13 May 2005 11:25:43 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j4DBPhtN054436;
	Fri, 13 May 2005 11:25:43 GMT
	(envelope-from nobody)
Message-Id: <200505131125.j4DBPhtN054436@www.freebsd.org>
Date: Fri, 13 May 2005 11:25:43 GMT
From: Frank Volf <frank@deze.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Destroying carp interface prevents carp from preempting ever again
X-Send-Pr-Version: www-2.3

>Number:         80972
>Category:       kern
>Synopsis:       Destroying carp interface prevents carp from preempting ever again
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    glebius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 13 11:30:01 GMT 2005
>Closed-Date:    Fri May 20 07:19:58 GMT 2005
>Last-Modified:  Fri May 20 07:19:58 GMT 2005
>Originator:     Frank Volf
>Release:        5.4
>Organization:
>Environment:
>Description:
This was discussed with Gleb Smirnoff but he does not have time to fix it. Here is the mail exchange:

  Frank,

good catch, thanks! I'll work on this next working day.

On Sun, May 01, 2005 at 12:05:02PM +0200, Frank wrote:
F> Hi Gleb,
F> 
F> I have found a bug in CARP. The problem exits if you are using 
F> preemption (net.inet.carp.preempt=1) and you destroy a carp interface 
F> that is currently down.
F> 
F> The counter carp_suppress_preempt counts the number of interfaces that 
F> are currently down. If this counter > 0 then the system will advertise 
F> with advskew 240.
F> 
F> The mechanism works fine, the counter is increased when the number of 
F> interfaces that is down increases, and decreases likewise. If the 
F> counter is 0 again, then de advskew of 240 is no longer used and the 
F> original advskew is used again.
F> 
F> The problem exists in the fact that if you destroy a CARP interface that 
F> is currently down, then the carp_suppress_preempt counter is never 
F> compenstated for that. After such an event the carp_suppress_preempt 
F> counter is always too large, and the system will use advskew forever.
F> 
F> This is fixed with the following patch (copy and pasted, so may not 
F> apply cleanly). It adds logic to carp_clone_destroy to decrease the 
F> counter if the interface is destoyed.
F> 
F> Please let me know what you think.
F> 
F> Regards,
F> 
F> Frank
F> 
F> 
F> 
F> Index: ip_carp.c
F> ===================================================================
F> RCS file: /home/cvs/firewall/FreeBSD/sys-5.4/netinet/ip_carp.c,v
F> retrieving revision 1.3
F> diff -u -r1.3 ip_carp.c
F> --- ip_carp.c   26 Apr 2005 10:55:06 -0000      1.3
F> +++ ip_carp.c   1 May 2005 09:49:37 -0000
F> @@ -405,6 +405,16 @@
F> 
F>  /*     carpdetach(sc); */
F> 
F> +       /*
F> +        * If an interface is destroyed which is suppressing the preemption,
F> +        * decrease the global counter, otherwise the host will never get
F> +        * out of the carp supressing state
F> +        */
F> +       if (sc->sc_suppress)
F> +               carp_suppress_preempt--;
F> +       sc->sc_suppress = 0;
F> +
F> +

-- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE 

On Fri, May 06, 2005 at 11:20:59PM +0200, Frank wrote:
F> Did you have a look at this? I think it should be committed asap so it 
F> makes FreeBSD 5.4 release....

ENOTIME, sorry  :( 

The release tagging has already been done yesterday...

-- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE 


>How-To-Repeat:
See above
>Fix:
See patch
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: glebius 
State-Changed-When: Sun May 15 01:45:00 GMT 2005 
State-Changed-Why:  
Committed, sorry for delay. 


Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Sun May 15 01:45:00 GMT 2005 
Responsible-Changed-Why:  
Committed, sorry for delay. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=80972 
State-Changed-From-To: patched->closed 
State-Changed-By: glebius 
State-Changed-When: Fri May 20 07:19:12 GMT 2005 
State-Changed-Why:  
Merged, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=80972 
>Unformatted:
