Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Jun 2016 20:32:18 +0000 (UTC)
From:      Pallav Bose <pallav_bose@yahoo.com>
To:        "freebsd-net@freebsd.org" <freebsd-net@freebsd.org>
Subject:   Wiring down network interfaces
Message-ID:  <613325570.2292399.1467059538523.JavaMail.yahoo@mail.yahoo.com>
References:  <613325570.2292399.1467059538523.JavaMail.yahoo.ref@mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,
How do I wire down network interfaces based on their PCI bus addresses? Exa=
mple: I have the following network interfaces:# pciconf -l | grep bgebge0 a=
t pci0:8:0:0: =C2=A0 =C2=A0 =C2=A0 =C2=A0class=3D0x020000 card=3D0x200314e4=
 chip=3D0x165f14e4 rev=3D0x00 hdr=3D0x00bge1 at pci0:8:0:1: =C2=A0 =C2=A0 =
=C2=A0 =C2=A0class=3D0x020000 card=3D0x200314e4 chip=3D0x165f14e4 rev=3D0x0=
0 hdr=3D0x00bge2 at pci0:10:0:0: =C2=A0 =C2=A0 =C2=A0 class=3D0x020000 card=
=3D0x200314e4 chip=3D0x165f14e4 rev=3D0x00 hdr=3D0x00bge3 at pci0:10:0:1: =
=C2=A0 =C2=A0 =C2=A0 class=3D0x020000 card=3D0x200314e4 chip=3D0x165f14e4 r=
ev=3D0x00 hdr=3D0x00bge4 at pci0:2:0:0: =C2=A0 =C2=A0 =C2=A0 =C2=A0class=3D=
0x020000 card=3D0x04f81028 chip=3D0x165f14e4 rev=3D0x00 hdr=3D0x00bge5 at p=
ci0:2:0:1: =C2=A0 =C2=A0 =C2=A0 =C2=A0class=3D0x020000 card=3D0x04f81028 ch=
ip=3D0x165f14e4 rev=3D0x00 hdr=3D0x00
I want the network interface at pci0:2:0:0 to be bge0 always, and the one a=
t pci0:2:0:1 to be bge1 always. How should populate my /boot/device.hints f=
ile? I tried following the steps mentioned here <https://forums.freebsd.org=
/threads/27100/#post-151256>, but after rebooting the system, I ended up wi=
th bge2-7 instead (bge0 and bge1 were absent).
Thanks,Pallav
From owner-freebsd-net@freebsd.org  Tue Jun 28 12:53:46 2016
Return-Path: <owner-freebsd-net@freebsd.org>
Delivered-To: freebsd-net@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id E8609B81EFB
 for <freebsd-net@mailman.ysv.freebsd.org>;
 Tue, 28 Jun 2016 12:53:46 +0000 (UTC)
 (envelope-from julien.charbon@gmail.com)
Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org
 [IPv6:2001:1900:2254:206a::50:5])
 by mx1.freebsd.org (Postfix) with ESMTP id C06142738
 for <freebsd-net@freebsd.org>; Tue, 28 Jun 2016 12:53:46 +0000 (UTC)
 (envelope-from julien.charbon@gmail.com)
Received: by mailman.ysv.freebsd.org (Postfix)
 id B9839B81EF9; Tue, 28 Jun 2016 12:53:46 +0000 (UTC)
Delivered-To: net@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id B66C2B81EF6;
 Tue, 28 Jun 2016 12:53:46 +0000 (UTC)
 (envelope-from julien.charbon@gmail.com)
Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client CN "smtp.gmail.com",
 Issuer "Google Internet Authority G2" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 40BC32734;
 Tue, 28 Jun 2016 12:53:45 +0000 (UTC)
 (envelope-from julien.charbon@gmail.com)
Received: by mail-wm0-f43.google.com with SMTP id f126so138856072wma.1;
 Tue, 28 Jun 2016 05:53:45 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:subject:to:references:cc:from:message-id:date
 :user-agent:mime-version:in-reply-to;
 bh=dUKiVftu2nC9WGdNydlDM4lt1LrPlWow3gqVE05hN/g=;
 b=bdldi0ZwEwONKS2SwNUR3++SYuSCUtp5dRmdXlbi9ZNPBeY1e+GGNgfDIZFaF2UCwJ
 7dpWZIzqmWgBAVgFQFU/3WcTqwQyjxiI8b1NTq5HX2NL42ZVjKk26sWQ1xaiZ2Kkwlkw
 KwxUMTxvWy1ssj+D3YSotrWQCIHcrtgPGvcOVarfDgZSecm/zspdTP4WZZKMToKgisMS
 17EoTPLwilyjagKXnzNWmT4aw+G71bW78kVsxDmtwzk6dDV1wf4b6A3fIpwegZrPjQao
 pznybcy4YvMjL3kv93lD9UmIWDZYKtlKqZvJ5NDQqHGb0kc11GhsVw8BvgRQT4Q2dsqK
 Kw3w==
X-Gm-Message-State: ALyK8tLYj+yQ//LAWXh1yw0MBMrMSwiYl2krkOdxzV7AZzu1nV6zJc474PlzrunROA7Yjg==
X-Received: by 10.28.147.7 with SMTP id v7mr2498699wmd.37.1467107948416;
 Tue, 28 Jun 2016 02:59:08 -0700 (PDT)
Received: from [10.5.50.30]
 (125.226.200.213.static.wline.lns.sme.cust.swisscom.ch. [213.200.226.125])
 by smtp.gmail.com with ESMTPSA id ur2sm1317724wjc.33.2016.06.28.02.59.06
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Tue, 28 Jun 2016 02:59:07 -0700 (PDT)
Subject: Re: panic with tcp timers
To: Randall Stewart <rrs@netflix.com>, current@freebsd.org
References: <20160617045319.GE1076@FreeBSD.org>
 <1f28844b-b4ea-b544-3892-811f2be327b9@freebsd.org>
 <20160620073917.GI1076@FreeBSD.org>
 <1d18d0e2-3e42-cb26-928c-2989d0751884@freebsd.org>
 <20160620095822.GJ1076@FreeBSD.org>
 <74bb31b7-a9f5-3d0c-eea0-681872e6f09b@freebsd.org>
 <18D94615-810E-4E79-A889-4B0CC70F9E45@netflix.com>
 <6E52CA6A-2153-4EF9-A3E1-97CB0D07EB28@freebsd.org>
Cc: hselasky@FreeBSD.org, net@FreeBSD.org
From: Julien Charbon <jch@freebsd.org>
Message-ID: <ae21858a-e162-6aad-1597-eeff614624c9@freebsd.org>
Date: Tue, 28 Jun 2016 11:58:56 +0200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:45.0)
 Gecko/20100101 Thunderbird/45.1.1
MIME-Version: 1.0
In-Reply-To: <6E52CA6A-2153-4EF9-A3E1-97CB0D07EB28@freebsd.org>
Content-Type: multipart/signed; micalg=pgp-sha512;
 protocol="application/pgp-signature";
 boundary="V2vxqg2bse8BDAiFdbkRFrXdAgQxIDLnB"
X-BeenThere: freebsd-net@freebsd.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Networking and TCP/IP with FreeBSD <freebsd-net.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-net>,
 <mailto:freebsd-net-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-net/>;
List-Post: <mailto:freebsd-net@freebsd.org>
List-Help: <mailto:freebsd-net-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-net>,
 <mailto:freebsd-net-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Tue, 28 Jun 2016 12:53:47 -0000

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--V2vxqg2bse8BDAiFdbkRFrXdAgQxIDLnB
Content-Type: multipart/mixed; boundary="VSScAOvNUr1ikVRhBTpmu42CTd9EplESr"
From: Julien Charbon <jch@freebsd.org>
To: Randall Stewart <rrs@netflix.com>, current@freebsd.org
Cc: hselasky@FreeBSD.org, net@FreeBSD.org
Message-ID: <ae21858a-e162-6aad-1597-eeff614624c9@freebsd.org>
Subject: Re: panic with tcp timers
References: <20160617045319.GE1076@FreeBSD.org>
 <1f28844b-b4ea-b544-3892-811f2be327b9@freebsd.org>
 <20160620073917.GI1076@FreeBSD.org>
 <1d18d0e2-3e42-cb26-928c-2989d0751884@freebsd.org>
 <20160620095822.GJ1076@FreeBSD.org>
 <74bb31b7-a9f5-3d0c-eea0-681872e6f09b@freebsd.org>
 <18D94615-810E-4E79-A889-4B0CC70F9E45@netflix.com>
 <6E52CA6A-2153-4EF9-A3E1-97CB0D07EB28@freebsd.org>
In-Reply-To: <6E52CA6A-2153-4EF9-A3E1-97CB0D07EB28@freebsd.org>

--VSScAOvNUr1ikVRhBTpmu42CTd9EplESr
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable


 Hi Randall,

On 6/25/16 4:41 PM, Randall Stewart via freebsd-net wrote:
> Ok
>=20
> Lets try this again with my source changed to my @freebsd.net :-)
>=20
> Now I am also attaching a patch for you Gleb, this will take some pokin=
g to
> get in to your NF-head since it incorporates some changes we made earli=
er.
>=20
> I think this will fix the problem.. i.e. dealing with two locks in the =
callout system (which it was
> never meant to have done)..
>=20
> Note we probably can move the code to use the callout lock init now.. b=
ut lets see if this works
> on your setup on c096 and if so we can think about doing that.

 Thanks for proposing a patch.  I believe your patch will work with
callout lock init, but not without:  You still have a use-after-free
issue on the tcpcb without callout lock init.

 The case being subtle as usual, let me try to describe that could happen=
:

 With your patch we have:

void
tcp_timer_keep(void *xtp)
{
        struct tcpcb *tp =3D xtp;
        struct tcptemp *t_template;
        struct inpcb *inp;
        CURVNET_SET(tp->t_vnet);
#ifdef TCPDEBUG
        int ostate;

        ostate =3D tp->t_state;
#endif
        inp =3D tp->t_inpcb;
        KASSERT(inp !=3D NULL, ("%s: tp %p tp->t_inpcb =3D=3D NULL", __fu=
nc__,
tp));
        INP_WLOCK(inp);
        if (callout_pending(&tp->t_timers->tt_keep) ### Use after free
of tp here
            !callout_active(&tp->t_timers->tt_keep)) {
                INP_WUNLOCK(inp);
                CURVNET_RESTORE();
                return;
        }
        ...

 The use-after-free scenario:

[CPU 1] the callout fires, tcp_timer_keep entered
[CPU 1] blocks on INP_WLOCK(inp);
[CPU 2] schedules tcp_timer_keep with callout_reset()
[CPU 2] tcp_discardcb called
[CPU 2] tcp_timer_keep callout successfully canceled
[CPU 2] tcpcb freed
[CPU 1] unblocks, the tcpcb is used

 Then the tcpcb will used just after being freed...  Might also crash or
not depending in the case.

 Extra notes:

 o The invariant I see here is:  The "callout successfully canceled"
step should never happen when "the callout is currently being executed".

 o Solutions I see to enforce this invariant:

 - First solution:  Use callout lock init with inp lock, your patch
seems to permit that now.

 - Second solution:  Change callout_async_drain() behavior:  It can
return 0 (fail) when the callout is currently being executed (no matter
what).

 - Third solution:  Don't trust callout_async_drain(callout) return
value of 1 (success) if the previous call of callout_reset(callout)
returned 0 (fail).  That was the exact purpose of r284261 change, but
this solution is also step backward in modernization of TCP
timers/callout...

https://svnweb.freebsd.org/base/stable/10/sys/netinet/tcp_timer.c?r1=3D28=
4261&r2=3D284260&pathrev=3D284261

 Hopefully my description is clear enough...

--
Julien


--VSScAOvNUr1ikVRhBTpmu42CTd9EplESr--

--V2vxqg2bse8BDAiFdbkRFrXdAgQxIDLnB
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQEcBAEBCgAGBQJXckpqAAoJEKVlQ5Je6dhxbn8IAK+iSIVBRUUwNNolJFmSx47O
Y1qySRcEb04Q8qxTZrT72/0FDRyFdMydhTTKh3yifXnTEGeg+wWKomkDNP8RDhgX
96xwXhzos+Y50PEbeKy78/kAZG8UmFaSGRMCDyvUHeTBI9TIRdDjZzJzCgrVqLot
a54sCW/+Ud1tXYUO0HEdJqaMWMdAre4Xsn7QNGFF7eY0ewmFj6vbA7VST35SbRnw
vP+Oy2VBPb2otqKY+FYYHeUi6gRMs+Nsen0K+hegbokWxBRXWPhft9WuSiz3heTI
juMOCALkH/D2lrHTxVkoR3+4+1fTZ9LkmBIaoA8mgH6UbeCvLJLcaODIpvwsVYA=
=j5ic
-----END PGP SIGNATURE-----

--V2vxqg2bse8BDAiFdbkRFrXdAgQxIDLnB--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?613325570.2292399.1467059538523.JavaMail.yahoo>