NetBSD Problem Report #49507

From www@NetBSD.org  Fri Dec 26 07:53:06 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 82D9AA582D
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 26 Dec 2014 07:53:06 +0000 (UTC)
Message-Id: <20141226075305.0F002A6553@mollari.NetBSD.org>
Date: Fri, 26 Dec 2014 07:53:05 +0000 (UTC)
From: ozaki-r@netbsd.org
Reply-To: ozaki-r@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: bridge(4) doesn't extend the expire time of a MAC address entry that has traffic
X-Send-Pr-Version: www-1.0

>Number:         49507
>Category:       kern
>Synopsis:       bridge(4) doesn't extend the expire time of a MAC address entry that has traffic
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 26 07:55:00 +0000 2014
>Closed-Date:    Fri Jun 26 05:51:33 +0000 2015
>Last-Modified:  Fri Jun 26 05:51:33 +0000 2015
>Originator:     Ryota Ozaki
>Release:        current
>Organization:
>Environment:
any
>Description:
The expire time of a cache entry in a bridge MAC address table is initialized
when the entry is created and never extended (except for "brconfig bridgeN static").
See bridge_rtupdate function.

I don't think it's expected behavior of such caches. The expire time of a cache entry
should be extended when a frame for the entry go through the bridge.

bridge(4) of OpenBSD has the same behavior as NetBSD (because their code is our
original). OTOH, FreeBSD's behavior is what I expect.
>How-To-Repeat:
Setup a bridge:
  ifconfig bridge0 create
  ifconfig bridge0 up
  brconfig bridge0 add wm1
  brconfig bridge0 add wm2

Send frames over the bridge.

Show entries:
  ifconfig bridge0

You can see expire times of all address caches are constantly decreasing
regardless of traffic.
>Fix:
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 9d60662..de418d2 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -2093,6 +2093,9 @@ again:
                                brt->brt_expire = 0;
                        else
                                brt->brt_expire = time_uptime + sc->sc_brttimeout;
+               } else {
+                       if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC)
+                               brt->brt_expire = time_uptime + sc->sc_brttimeout;
                }
        }
        BRIDGE_RT_REXIT(s);

>Release-Note:

>Audit-Trail:
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/49507: bridge(4) doesn't extend the expire time of a MAC
 address entry that has traffic
Date: Sat, 27 Dec 2014 02:51:34 +0000

 (not sent to gnats)
    ------

 From: Ryota Ozaki <ozaki-r@netbsd.org>
 To: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
 Subject: Re: kern/49507: bridge(4) doesn't extend the expire time of a MAC
 	address entry that has traffic
 Date: Fri, 26 Dec 2014 16:56:59 +0900

 On Fri, Dec 26, 2014 at 4:55 PM,  <ozaki-r@netbsd.org> wrote:
 >>Number:         49507
 >>Category:       kern
 >>Synopsis:       bridge(4) doesn't extend the expire time of a MAC address entry that has traffic
 >>Confidential:   no
 >>Severity:       non-critical
 >>Priority:       medium
 >>Responsible:    kern-bug-people
 >>State:          open
 >>Class:          sw-bug
 >>Submitter-Id:   net
 >>Arrival-Date:   Fri Dec 26 07:55:00 +0000 2014
 >>Originator:     Ryota Ozaki
 >>Release:        current
 >>Organization:
 >>Environment:
 > any
 >>Description:
 > The expire time of a cache entry in a bridge MAC address table is initialized
 > when the entry is created and never extended (except for "brconfig bridgeN static").
 > See bridge_rtupdate function.
 >
 > I don't think it's expected behavior of such caches. The expire time of a cache entry
 > should be extended when a frame for the entry go through the bridge.
 >
 > bridge(4) of OpenBSD has the same behavior as NetBSD (because their code is our
 > original). OTOH, FreeBSD's behavior is what I expect.
 >>How-To-Repeat:
 > Setup a bridge:
 >   ifconfig bridge0 create
 >   ifconfig bridge0 up
 >   brconfig bridge0 add wm1
 >   brconfig bridge0 add wm2
 >
 > Send frames over the bridge.
 >
 > Show entries:
 >   ifconfig bridge0
 >
 > You can see expire times of all address caches are constantly decreasing
 > regardless of traffic.
 >>Fix:
 > diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
 > index 9d60662..de418d2 100644
 > --- a/sys/net/if_bridge.c
 > +++ b/sys/net/if_bridge.c
 > @@ -2093,6 +2093,9 @@ again:
 >                                 brt->brt_expire = 0;
 >                         else
 >                                 brt->brt_expire = time_uptime + sc->sc_brttimeout;
 > +               } else {
 > +                       if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC)
 > +                               brt->brt_expire = time_uptime + sc->sc_brttimeout;
 >                 }
 >         }
 >         BRIDGE_RT_REXIT(s);
 >

 Oops. This is the correct diff to HEAD:

 diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
 index 1ea2169..1c1ea3c 100644
 --- a/sys/net/if_bridge.c
 +++ b/sys/net/if_bridge.c
 @@ -1970,6 +1970,9 @@ bridge_rtupdate(struct bridge_softc *sc, const
 uint8_t *dst,
                         brt->brt_expire = 0;
                 else
                         brt->brt_expire = time_uptime + sc->sc_brttimeout;
 +       } else {
 +               if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC)
 +                       brt->brt_expire = time_uptime + sc->sc_brttimeout;
         }

  out:

From: "Ryota Ozaki" <ozaki-r@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49507 CVS commit: src/sys/net
Date: Thu, 1 Jan 2015 08:43:26 +0000

 Module Name:	src
 Committed By:	ozaki-r
 Date:		Thu Jan  1 08:43:26 UTC 2015

 Modified Files:
 	src/sys/net: if_bridge.c

 Log Message:
 Reset the expire time of a cache on receiving a frame for the cache

 The expire time of a cache in a bridge MAC address table was never reset
 once it is initialized regardless of traffic for the cache. The behavior
 isn't supposed and active caches are unnecessarily expired and removed.

 PR kern/49507


 To generate a diff of this commit:
 cvs rdiff -u -r1.95 -r1.96 src/sys/net/if_bridge.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Wed, 11 Feb 2015 17:15:41 +0000
State-Changed-Why:
Is this fixed?


State-Changed-From-To: feedback->closed
State-Changed-By: ozaki-r@NetBSD.org
State-Changed-When: Fri, 26 Jun 2015 05:51:33 +0000
State-Changed-Why:
I'm sorry for late response. It's fixed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.