From owner-freebsd-net@freebsd.org Mon Jun 27 20:35:09 2016 Return-Path: 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 5626AB850FD for ; Mon, 27 Jun 2016 20:35:09 +0000 (UTC) (envelope-from pallav_bose@yahoo.com) Received: from nm36-vm9.bullet.mail.gq1.yahoo.com (nm36-vm9.bullet.mail.gq1.yahoo.com [98.136.216.170]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 301A12015 for ; Mon, 27 Jun 2016 20:35:08 +0000 (UTC) (envelope-from pallav_bose@yahoo.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1467059702; bh=rwQ9FZ8PIul5HRBQFZvxNxRs+0rEYrNB03pSEYkIWmA=; h=Date:From:Reply-To:To:Subject:References:From:Subject; b=ZB5chMOtZNoRgFEquq6pCU2XUbFj+BWGQvx7LF0QHapUo2POzv6+8aj4LJaUyXtB5Hu+6wCexFOcyi2wWs7p4GNb/2GSHnsrcTWlnkVRGJVMeKhcf2pI+19KlD3udCwrkUiU4tSYqfxvVadBfQHCv2QG+QYQCkaPkc7flv0anjI4AoH8dJFykucZUd7k9OehJ2LIH1ITihw2sHPM2c4ueQoq2phDgMLYZJFebGywvD2RpaZOpH3GHevLCs9DFo5f5eHNUxgxJQ5uXMhtx0eYEmrfEKINxoE200SxjJEoMqX5T3skN9/REV8yQQBi0PFoSZxfxzi7CpCJMC62YehSjg== Received: from [127.0.0.1] by nm36.bullet.mail.gq1.yahoo.com with NNFMP; 27 Jun 2016 20:35:02 -0000 Received: from [98.137.12.59] by nm36.bullet.mail.gq1.yahoo.com with NNFMP; 27 Jun 2016 20:32:19 -0000 Received: from [98.137.12.196] by tm4.bullet.mail.gq1.yahoo.com with NNFMP; 27 Jun 2016 20:32:19 -0000 Received: from [127.0.0.1] by omp1004.mail.gq1.yahoo.com with NNFMP; 27 Jun 2016 20:32:19 -0000 X-Yahoo-Newman-Property: ymail-4 X-Yahoo-Newman-Id: 246890.76427.bm@omp1004.mail.gq1.yahoo.com X-YMail-OSG: ZlQVQsUVM1mrbW7jXV0wXSWl70gxUqE2bCtvZiDw5phaJ.gTWYhb0xmkH5QtgaE taRSr78sOf9SS4FUR74kZ7y_I3TpG5mbPHFQNrZpR2yIPMsc.Eb_X_OkbvtqwkhAPS34zNcf2qP0 xQuCeTH8_jEtXTS.8AG3PrLz6K_2qY67HvFL9n.RjUeYyLYdW9lkHctJObzWHIXBa738lEtOFvwS 8tAIQw99O.c09_FGKMSihLw.8xVc49t8rpGtS8XN6DILOvj4lgFaJtW3R5Hw481MhG__81aE1N06 xygqEC6ZEAOkSoug2siTegfKUNeCP66oSaVcvayOGvSuEjsLL4gROD1A2.bYtgi.pndwk8uczVG8 WlcXhNum9yOmfGMVH4_Y6_e9714W5oHUX2RUX.uiMc_EH3DRP3oWZZiqPV_vQG1oIt4iup.kczjD CGdBsgrQ.C3P98RCmnH3yOrcFf2GCI2cK78Lc8oj4_1VU8neCuGj1SwY9Lgve7J1BStHm50iVfl3 0K9E5klCl_xe30zVZCVGXl.m7y6sx34sdR_b9o30m Received: from jws10754.mail.gq1.yahoo.com by sendmailws101.mail.gq1.yahoo.com; Mon, 27 Jun 2016 20:32:18 +0000; 1467059538.734 Date: Mon, 27 Jun 2016 20:32:18 +0000 (UTC) From: Pallav Bose Reply-To: Pallav Bose To: "freebsd-net@freebsd.org" Message-ID: <613325570.2292399.1467059538523.JavaMail.yahoo@mail.yahoo.com> Subject: Wiring down network interfaces MIME-Version: 1.0 References: <613325570.2292399.1467059538523.JavaMail.yahoo.ref@mail.yahoo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jun 2016 20:35:09 -0000 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 , 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: 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 ; 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 ; 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 , 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 Message-ID: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 To: Randall Stewart , current@freebsd.org Cc: hselasky@FreeBSD.org, net@FreeBSD.org Message-ID: 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--