From owner-svn-src-head@freebsd.org Mon Jul 23 09:14:23 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4FB9310449F1; Mon, 23 Jul 2018 09:14:23 +0000 (UTC) (envelope-from ohartmann@walstatt.org) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9FA0773552; Mon, 23 Jul 2018 09:14:22 +0000 (UTC) (envelope-from ohartmann@walstatt.org) Received: from freyja.zeit4.iv.bundesimmobilien.de ([87.138.105.249]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M2LZc-1fxxL81zr2-00s7pt; Mon, 23 Jul 2018 11:14:14 +0200 Date: Mon, 23 Jul 2018 11:14:13 +0200 From: "O. Hartmann" To: Eugene Grosbein Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r336628 - head/sys/net Message-ID: <20180723111409.3cff3d80@freyja.zeit4.iv.bundesimmobilien.de> In-Reply-To: <201807230711.w6N7BwOj095904@repo.freebsd.org> References: <201807230711.w6N7BwOj095904@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:LmuEEQULNRZKG1QeLrD2XFb3bQHrCs/hW/2M6wiWXIb9/02i9fX rd2thnFhydUULDNOOYWFmJS5sqe3OoMlIzp+BZ0DJ2yUREEUUfOgcBq4lHP3m9ns1xW1sys VFkgnbzt9lrRgAzCjbyeIcnlw/9nNnlzSVITaekKSMV3Vssc5AkdGoEEAPCj33wF1aiSU9I 5VY9ssfw1+R5hWQjjE5wA== X-UI-Out-Filterresults: notjunk:1;V01:K0:06ToTemCvUM=:YYCdSrUXfLaNfivHE36Wkw hpzUIX5wPeuI/Mi/vVYBisMYUPb1mVZjvIixvqDwFTe2dPL3D/vHA41Kp86j/WUwS3r0BauHP QdIOhPMSJJqtPWaIrwEyUqvBuNvney5AJVrhhMjfnto/bzvXQFOTTklhzfbeqmoOuhlvr8Q81 GnYZ6IS7QRWG/5ZISPbW5NfIh2jQ6/uM79JGSJRf3E8PMC3dc61fwOwj0ErGxafc3yGX0Y8BA ilXlrSF5uUZwIf9wUDUpmYoL0GRMDoVYdVBI24/qtur6u5bvOTPSoaI/caBnekJ2uoKuQmn5F L9VC2r2Muu4ZrtqbsKX5h6iaQOyYyBBw4RRDO89lEruGOMyS1TfEzgb6bRR0XJSHJq/Q0ZRqN 2AKPhcgE41PfHes+RREyiwxA4vSOkMXEYiUevWnOxQkpMUSquciZ/akVz9OC/qcWSMqOVZXuk abGi8pjwWyNkDZm2acVaLMwY8wmT6R3YFfLxC26iWS1y8b3eVwodaGJGc4wIuglbKv9u/LW64 NML5ZYIBdd1MMCiZhkmHaSntjzrU0DZdNJ9sITXqUR5YjraKk2RfDz/zk15tQb8zCGST7/J8A bNjh1PsNtDz33cZe0x/F2j4w3N76ubLa66MNWdt03ZJh0W5Y0wCtQXrCxBcV3+WjVY4gNtK4A w2UmPz44WkwYNYO8kc+49ciVle9VDZgSasOBxzQgEKg+6AHsD+dgkDI6xOJLOOAaV/b2ypUwT UguGBxml8ufL5SaP6tMIQ4o7SRSfikHJ1+qOX7DEH0cWOWyfe2kqzzJNjS5pFbBJCFMIhC7Wh 07Stgww X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jul 2018 09:14:23 -0000 On Mon, 23 Jul 2018 07:11:58 +0000 (UTC) Eugene Grosbein wrote: > Author: eugen > Date: Mon Jul 23 07:11:58 2018 > New Revision: 336628 > URL: https://svnweb.freebsd.org/changeset/base/336628 > > Log: > epair(4): make sure we do not duplicate MAC addresses > in case of reused if_index. > > PR: 229957 > Tested by: O. Hartmann > Approved by: avg (mentor) > > Modified: > head/sys/net/if_epair.c > > Modified: head/sys/net/if_epair.c > ============================================================================== > --- head/sys/net/if_epair.c Mon Jul 23 06:38:48 2018 (r336627) > +++ head/sys/net/if_epair.c Mon Jul 23 07:11:58 2018 (r336628) > @@ -107,6 +107,7 @@ static int epair_clone_create(struct if_clone *, char > static int epair_clone_destroy(struct if_clone *, struct ifnet *); > > static const char epairname[] = "epair"; > +static unsigned int next_index = 0; > > /* Netisr related definitions and sysctl. */ > static struct netisr_handler epair_nh = { > @@ -843,12 +844,22 @@ epair_clone_create(struct if_clone *ifc, char *name, s > > /* > * Calculate the etheraddr hashing the hostid and the > - * interface index. The result would be hopefully unique > + * interface index. The result would be hopefully unique. > + * Note that the "a" component of an epair instance may get moved > + * to a different VNET after creation. In that case its index > + * will be freed and the index can get reused by new epair instance. > + * Make sure we do not create same etheraddr again. > */ > getcredhostid(curthread->td_ucred, (unsigned long *)&hostid); > if (hostid == 0) > arc4rand(&hostid, sizeof(hostid), 0); > - key[0] = (uint32_t)ifp->if_index; > + > + if (ifp->if_index > next_index) > + next_index = ifp->if_index; > + else > + next_index++; > + > + key[0] = (uint32_t)next_index; > key[1] = (uint32_t)(hostid & 0xffffffff); > key[2] = (uint32_t)((hostid >> 32) & 0xfffffffff); > hash = jenkins_hash32(key, 3, 0); > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" Thank you very much for the pretty fast patch! Regards, oh