From owner-svn-src-all@freebsd.org Fri Sep 16 04:22:22 2016 Return-Path: Delivered-To: svn-src-all@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 74042BDC478; Fri, 16 Sep 2016 04:22:22 +0000 (UTC) (envelope-from araujo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4F433C9D; Fri, 16 Sep 2016 04:22:22 +0000 (UTC) (envelope-from araujo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8G4MLGi031063; Fri, 16 Sep 2016 04:22:21 GMT (envelope-from araujo@FreeBSD.org) Received: (from araujo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8G4MLN0031061; Fri, 16 Sep 2016 04:22:21 GMT (envelope-from araujo@FreeBSD.org) Message-Id: <201609160422.u8G4MLN0031061@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: araujo set sender to araujo@FreeBSD.org using -f From: Marcelo Araujo Date: Fri, 16 Sep 2016 04:22:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305860 - head/sbin/ifconfig X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Sep 2016 04:22:22 -0000 Author: araujo Date: Fri Sep 16 04:22:21 2016 New Revision: 305860 URL: https://svnweb.freebsd.org/changeset/base/305860 Log: Add an option called "random" that combined with "ether" can generate a random MAC address for an Ethernet interface. PR: 211984 Submitted by: pi@ Reviewed by: gnn, cem, jhb, lidl, rpokala, wblock Approved by: wblock (manpages) Modified: head/sbin/ifconfig/af_link.c head/sbin/ifconfig/ifconfig.8 Modified: head/sbin/ifconfig/af_link.c ============================================================================== --- head/sbin/ifconfig/af_link.c Fri Sep 16 04:12:32 2016 (r305859) +++ head/sbin/ifconfig/af_link.c Fri Sep 16 04:22:21 2016 (r305860) @@ -90,13 +90,23 @@ link_getaddr(const char *addr, int which if (which != ADDR) errx(1, "can't set link-level netmask or broadcast"); - if ((temp = malloc(strlen(addr) + 2)) == NULL) - errx(1, "malloc failed"); - temp[0] = ':'; - strcpy(temp + 1, addr); - sdl.sdl_len = sizeof(sdl); - link_addr(temp, &sdl); - free(temp); + if (!strcmp(addr, "random")) { + sdl.sdl_len = sizeof(sdl); + sdl.sdl_alen = ETHER_ADDR_LEN; + sdl.sdl_nlen = 0; + sdl.sdl_family = AF_LINK; + arc4random_buf(&sdl.sdl_data, ETHER_ADDR_LEN); + /* Non-multicast and claim it is a hardware address */ + sdl.sdl_data[0] &= 0xfc; + } else { + if ((temp = malloc(strlen(addr) + 2)) == NULL) + errx(1, "malloc failed"); + temp[0] = ':'; + strcpy(temp + 1, addr); + sdl.sdl_len = sizeof(sdl); + link_addr(temp, &sdl); + free(temp); + } if (sdl.sdl_alen > sizeof(sa->sa_data)) errx(1, "malformed link-level address"); sa->sa_family = AF_LINK; Modified: head/sbin/ifconfig/ifconfig.8 ============================================================================== --- head/sbin/ifconfig/ifconfig.8 Fri Sep 16 04:12:32 2016 (r305859) +++ head/sbin/ifconfig/ifconfig.8 Fri Sep 16 04:22:21 2016 (r305860) @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd June 8, 2016 +.Dd September 17, 2016 .Dt IFCONFIG 8 .Os .Sh NAME @@ -145,6 +145,12 @@ is specified as a series of colon-separa This can be used to, for example, set a new MAC address on an Ethernet interface, though the mechanism used is not Ethernet specific. +Use the +.Pq Dq random +keyword to set a randomly generated MAC address. +A randomly-generated MAC address might be the same as one already in use +in the network. +Such duplications are extremely unlikely. If the interface is already up when this option is used, it will be briefly brought down and then brought back up again in order to ensure that the receive @@ -254,7 +260,7 @@ Display subnet masks in dotted quad nota .br 255.255.0.0 or 255.255.255.192 .It Sy hex -Display subnet masks in hexidecimal, for example: +Display subnet masks in hexadecimal, for example: .br 0xffff0000 or 0xffffffc0 .El @@ -2615,13 +2621,13 @@ and .Cm vlandev must both be set at the same time. .It Cm vlanpcp Ar priority_code_point -Priority code point +Priority code point .Pq Dv PCP is an 3-bit field which refers to the IEEE 802.1p class of service and maps to the frame priority level. .Pp Values in order of priority are: -.Cm 1 +.Cm 1 .Pq Dv Background (lowest) , .Cm 0 .Pq Dv Best effort (default) , @@ -2759,7 +2765,7 @@ interface to send the frame directly to broadcasting the frame to the multicast group. This is the default. .It Fl vxlanlearn -The forwarding table is not populated by recevied packets. +The forwarding table is not populated by received packets. .It Cm vxlanflush Delete all dynamically-learned addresses from the forwarding table. .It Cm vxlanflushall