svn commit: r253563 - head/contrib/libstdc++/include/c_std

2013-07-23 Thread David Chisnall
Author: theraven
Date: Tue Jul 23 10:23:43 2013
New Revision: 253563
URL: http://svnweb.freebsd.org/changeset/base/253563

Log:
  Add isnan() and isinf() to the global namespace in libstdc++'s cmath.
  
  The standard (n3242, section 17.6.1.1, paragraph 4) says that, because these 
are
  declared as macros in the C specification (even though they are
  implemented as functions in the C++ library) they should be in the global
  namespace.
  
  A surprising number of configure checks rely on this.  It was broken by recent
  cleanups to math.h.

Modified:
  head/contrib/libstdc++/include/c_std/std_cmath.h

Modified: head/contrib/libstdc++/include/c_std/std_cmath.h
==
--- head/contrib/libstdc++/include/c_std/std_cmath.hTue Jul 23 05:11:22 
2013(r253562)
+++ head/contrib/libstdc++/include/c_std/std_cmath.hTue Jul 23 10:23:43 
2013(r253563)
@@ -589,6 +589,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 { return ::__gnu_cxx::__capture_isunordered(__f1, __f2); }
 
 _GLIBCXX_END_NAMESPACE
+using std::isnan;
+using std::isinf;
 
 #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
 #endif
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253564 - head/sys/netgraph

2013-07-23 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jul 23 10:25:34 2013
New Revision: 253564
URL: http://svnweb.freebsd.org/changeset/base/253564

Log:
  Add constant for PPP-Max-PayLoad tag.
  
  Submitted by: Dmitry Luhtionov dmitryluhtionov gmail.com

Modified:
  head/sys/netgraph/ng_pppoe.c
  head/sys/netgraph/ng_pppoe.h

Modified: head/sys/netgraph/ng_pppoe.c
==
--- head/sys/netgraph/ng_pppoe.cTue Jul 23 10:23:43 2013
(r253563)
+++ head/sys/netgraph/ng_pppoe.cTue Jul 23 10:25:34 2013
(r253564)
@@ -1887,6 +1887,7 @@ scan_tags(sessp   sp, const struct pppoe_h
casePTT_SRV_ERR:
casePTT_SYS_ERR:
casePTT_GEN_ERR:
+   casePTT_MAX_PAYL:
break;
}
pt = (const struct pppoe_tag*)ptn;

Modified: head/sys/netgraph/ng_pppoe.h
==
--- head/sys/netgraph/ng_pppoe.hTue Jul 23 10:23:43 2013
(r253563)
+++ head/sys/netgraph/ng_pppoe.hTue Jul 23 10:25:34 2013
(r253564)
@@ -172,6 +172,7 @@ struct ngpppoe_sts {
 #define PTT_AC_COOKIE  (0x0104)
 #define PTT_VENDOR (0x0105)
 #define PTT_RELAY_SID  (0x0110)
+#definePTT_MAX_PAYL(0x0120)/* PPP-Max-Payload (RFC4638) */
 #define PTT_SRV_ERR (0x0201)
 #define PTT_SYS_ERR(0x0202)
 #define PTT_GEN_ERR(0x0203)
@@ -188,6 +189,7 @@ struct ngpppoe_sts {
 #define PTT_AC_COOKIE  (0x0401)
 #define PTT_VENDOR (0x0501)
 #define PTT_RELAY_SID  (0x1001)
+#definePTT_MAX_PAYL(0x2001)/* PPP-Max-Payload (RFC4638) */
 #define PTT_SRV_ERR (0x0102)
 #define PTT_SYS_ERR(0x0202)
 #define PTT_GEN_ERR(0x0302)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253565 - in head/sys: kern vm

2013-07-23 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jul 23 11:16:40 2013
New Revision: 253565
URL: http://svnweb.freebsd.org/changeset/base/253565

Log:
  Revert r249590 and in case if mp_ncpus isn't initialized use MAXCPU. This
  allows us to init counter zone at early stage of boot.
  
  Reviewed by:  kib
  Tested by:Lytochkin Boris lytboris gmail.com

Modified:
  head/sys/kern/subr_counter.c
  head/sys/vm/uma_core.c

Modified: head/sys/kern/subr_counter.c
==
--- head/sys/kern/subr_counter.cTue Jul 23 10:25:34 2013
(r253564)
+++ head/sys/kern/subr_counter.cTue Jul 23 11:16:40 2013
(r253565)
@@ -104,4 +104,4 @@ counter_startup(void)
uint64_pcpu_zone = uma_zcreate(uint64 pcpu, sizeof(uint64_t),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_PCPU);
 }
-SYSINIT(counter, SI_SUB_CPU, SI_ORDER_FOURTH, counter_startup, NULL);
+SYSINIT(counter, SI_SUB_KMEM, SI_ORDER_ANY, counter_startup, NULL);

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Tue Jul 23 10:25:34 2013(r253564)
+++ head/sys/vm/uma_core.c  Tue Jul 23 11:16:40 2013(r253565)
@@ -1139,9 +1139,10 @@ keg_small_init(uma_keg_t keg)
u_int shsize;
 
if (keg-uk_flags  UMA_ZONE_PCPU) {
-   KASSERT(mp_ncpus  0, (%s: ncpus %d\n, __func__, mp_ncpus));
+   u_int ncpus = mp_ncpus ? mp_ncpus : MAXCPU;
+
keg-uk_slabsize = sizeof(struct pcpu);
-   keg-uk_ppera = howmany(mp_ncpus * sizeof(struct pcpu),
+   keg-uk_ppera = howmany(ncpus * sizeof(struct pcpu),
PAGE_SIZE);
} else {
keg-uk_slabsize = UMA_SLAB_SIZE;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253568 - head/sbin/etherswitchcfg

2013-07-23 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Jul 23 13:40:26 2013
New Revision: 253568
URL: http://svnweb.freebsd.org/changeset/base/253568

Log:
  Fix the usage error message.  The valid range is up to max. vlan - 1 since 
vlangroups starts at 0.
  
  Approved by:  adrian (mentor)

Modified:
  head/sbin/etherswitchcfg/etherswitchcfg.c

Modified: head/sbin/etherswitchcfg/etherswitchcfg.c
==
--- head/sbin/etherswitchcfg/etherswitchcfg.c   Tue Jul 23 12:22:37 2013
(r253567)
+++ head/sbin/etherswitchcfg/etherswitchcfg.c   Tue Jul 23 13:40:26 2013
(r253568)
@@ -626,7 +626,9 @@ main(int argc, char *argv[])
newmode(cfg, MODE_PORT);
} else if (sscanf(argv[0], vlangroup%d, cfg.unit) == 
1) {
if (cfg.unit  0 || cfg.unit = 
cfg.info.es_nvlangroups)
-   errx(EX_USAGE, port unit must be 
between 0 and %d, cfg.info.es_nvlangroups);
+   errx(EX_USAGE,
+   vlangroup unit must be between 0 
and %d,
+   cfg.info.es_nvlangroups - 1);
newmode(cfg, MODE_VLANGROUP);
} else if (strcmp(argv[0], config) == 0) {
newmode(cfg, MODE_CONFIG);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253569 - in head: sbin/etherswitchcfg sys/dev/etherswitch sys/dev/etherswitch/ip17x sys/dev/etherswitch/rtl8366

2013-07-23 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Jul 23 13:56:38 2013
New Revision: 253569
URL: http://svnweb.freebsd.org/changeset/base/253569

Log:
  Add a new flag (ETHERSWITCH_VID_VALID) to say what vlangroups are in use.
  This fix the case when etherswitch is printing the information of port 0
  vlan group (in port based vlan mode) with no member ports.
  
  Add the ETHERSWITCH_VID_VALID support to ip17x driver.
  
  Add the ETHERSWITCH_VID_VALID support to rt8366 driver.
  
  arswitch doesn't need to be updated as it doesn't support vlans management
  yet.
  
  Approved by:  adrian (mentor)

Modified:
  head/sbin/etherswitchcfg/etherswitchcfg.c
  head/sys/dev/etherswitch/etherswitch.h
  head/sys/dev/etherswitch/ip17x/ip175c.c
  head/sys/dev/etherswitch/ip17x/ip175d.c
  head/sys/dev/etherswitch/ip17x/ip17x_vlans.c
  head/sys/dev/etherswitch/rtl8366/rtl8366rb.c

Modified: head/sbin/etherswitchcfg/etherswitchcfg.c
==
--- head/sbin/etherswitchcfg/etherswitchcfg.c   Tue Jul 23 13:40:26 2013
(r253568)
+++ head/sbin/etherswitchcfg/etherswitchcfg.c   Tue Jul 23 13:56:38 2013
(r253569)
@@ -471,8 +471,9 @@ print_vlangroup(struct cfg *cfg, int vla
vg.es_vlangroup = vlangroup;
if (ioctl(cfg-fd, IOETHERSWITCHGETVLANGROUP, vg) != 0)
err(EX_OSERR, ioctl(IOETHERSWITCHGETVLANGROUP));
-   if (vg.es_vid == 0  vg.es_member_ports == 0)
+   if ((vg.es_vid  ETHERSWITCH_VID_VALID) == 0)
return;
+   vg.es_vid = ETHERSWITCH_VID_MASK;
printf(vlangroup%d:\n, vlangroup);
if (cfg-conf.vlan_mode == ETHERSWITCH_VLAN_PORT)
printf(\tport: %d\n, vg.es_vid);

Modified: head/sys/dev/etherswitch/etherswitch.h
==
--- head/sys/dev/etherswitch/etherswitch.h  Tue Jul 23 13:40:26 2013
(r253568)
+++ head/sys/dev/etherswitch/etherswitch.h  Tue Jul 23 13:56:38 2013
(r253569)
@@ -26,6 +26,8 @@ struct etherswitch_phyreg {
 typedef struct etherswitch_phyreg etherswitch_phyreg_t;
 
 #defineETHERSWITCH_NAMEMAX 64
+#defineETHERSWITCH_VID_MASK0xfff
+#defineETHERSWITCH_VID_VALID   (1  12)
 #defineETHERSWITCH_VLAN_ISL(1  0)/* ISL */
 #defineETHERSWITCH_VLAN_PORT   (1  1)/* Port based 
vlan */
 #defineETHERSWITCH_VLAN_DOT1Q  (1  2)/* 802.1q */

Modified: head/sys/dev/etherswitch/ip17x/ip175c.c
==
--- head/sys/dev/etherswitch/ip17x/ip175c.c Tue Jul 23 13:40:26 2013
(r253568)
+++ head/sys/dev/etherswitch/ip17x/ip175c.c Tue Jul 23 13:56:38 2013
(r253569)
@@ -147,9 +147,9 @@ ip175c_dot1q_vlan_setup(struct ip17x_sof
memset(vlans, 0, sizeof(vlans));
for (i = 0; i  IP17X_MAX_VLANS; i++) {
v = sc-vlan[i];
-   if (v-vlanid == 0)
+   if ((v-vlanid  ETHERSWITCH_VID_VALID) == 0)
continue;
-   vlans[v-vlanid] = v-ports;
+   vlans[v-vlanid  ETHERSWITCH_VID_MASK] = v-ports;
}
 
for (j = 0, i = 1; i = IP17X_MAX_VLANS / 2; i++) {

Modified: head/sys/dev/etherswitch/ip17x/ip175d.c
==
--- head/sys/dev/etherswitch/ip17x/ip175d.c Tue Jul 23 13:40:26 2013
(r253568)
+++ head/sys/dev/etherswitch/ip17x/ip175d.c Tue Jul 23 13:56:38 2013
(r253569)
@@ -94,7 +94,8 @@ ip175d_hw_setup(struct ip17x_softc *sc)
striptag[i] = 0;
 
v = sc-vlan[i];
-   if (v-vlanid == 0 || sc-vlan_mode == 0) {
+   if ((v-vlanid  ETHERSWITCH_VID_VALID) == 0 ||
+   sc-vlan_mode == 0) {
/* Vlangroup disabled.  Reset the filter. */
ip17x_writephy(sc-sc_dev, 22, 14 + i, i + 1);
ports[i] = 0x3f;
@@ -105,7 +106,8 @@ ip175d_hw_setup(struct ip17x_softc *sc)
ports[i] = v-ports;
 
/* Setup the filter, write the VLAN id. */
-   ip17x_writephy(sc-sc_dev, 22, 14 + i, v-vlanid);
+   ip17x_writephy(sc-sc_dev, 22, 14 + i,
+   v-vlanid  ETHERSWITCH_VID_MASK);
 
for (j = 0; j  MII_NPHY; j++) {
if ((ports[i]  (1  j)) == 0)

Modified: head/sys/dev/etherswitch/ip17x/ip17x_vlans.c
==
--- head/sys/dev/etherswitch/ip17x/ip17x_vlans.cTue Jul 23 13:40:26 
2013(r253568)
+++ head/sys/dev/etherswitch/ip17x/ip17x_vlans.cTue Jul 23 13:56:38 
2013(r253569)
@@ -74,7 +74,7 @@ ip17x_reset_vlans(struct ip17x_softc *sc
if (((1  phy)  sc-phymask) == 0)

svn commit: r253570 - head/sys/dev/etherswitch/arswitch

2013-07-23 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Jul 23 14:02:38 2013
New Revision: 253570
URL: http://svnweb.freebsd.org/changeset/base/253570

Log:
  Fix the arswitch instability problem.  It turns out that the
  arswitch_writereg() routine was writing the registers in the wrong order.
  
  Revert -r241918 as the root problem is now fixed. Remove another workaround
  from arswitch_ar7240.c.
  
  Simplify and fix the code on arswitch_writephy() by using
  arswitch_writereg().
  
  While here remove a redundant declaration from arswitchvar.h.
  
  Approved by:  adrian (mentor)

Modified:
  head/sys/dev/etherswitch/arswitch/arswitch_7240.c
  head/sys/dev/etherswitch/arswitch/arswitch_phy.c
  head/sys/dev/etherswitch/arswitch/arswitch_reg.c
  head/sys/dev/etherswitch/arswitch/arswitchvar.h

Modified: head/sys/dev/etherswitch/arswitch/arswitch_7240.c
==
--- head/sys/dev/etherswitch/arswitch/arswitch_7240.c   Tue Jul 23 13:56:38 
2013(r253569)
+++ head/sys/dev/etherswitch/arswitch/arswitch_7240.c   Tue Jul 23 14:02:38 
2013(r253570)
@@ -75,12 +75,6 @@ ar7240_hw_setup(struct arswitch_softc *s
arswitch_writereg(sc-sc_dev, AR8X16_REG_CPU_PORT,
AR8X16_CPU_PORT_EN | AR8X16_CPU_MIRROR_DIS);
 
-   /*
-* Let things settle; probing PHY4 doesn't seem reliable
-* without a litle delay.
-*/
-   DELAY(1000);
-
return (0);
 }
 

Modified: head/sys/dev/etherswitch/arswitch/arswitch_phy.c
==
--- head/sys/dev/etherswitch/arswitch/arswitch_phy.cTue Jul 23 13:56:38 
2013(r253569)
+++ head/sys/dev/etherswitch/arswitch/arswitch_phy.cTue Jul 23 14:02:38 
2013(r253570)
@@ -127,16 +127,13 @@ arswitch_writephy(device_t dev, int phy,
return (ENXIO);
 
ARSWITCH_LOCK(sc);
-   err = arswitch_writereg_lsb(dev, AR8X16_REG_MDIO_CTRL,
-   (data  AR8X16_MDIO_CTRL_DATA_MASK));
-   if (err != 0)
-   goto out;
-   err = arswitch_writereg_msb(dev, AR8X16_REG_MDIO_CTRL,
+   err = arswitch_writereg(dev, AR8X16_REG_MDIO_CTRL,
AR8X16_MDIO_CTRL_BUSY |
AR8X16_MDIO_CTRL_MASTER_EN |
AR8X16_MDIO_CTRL_CMD_WRITE |
(phy  AR8X16_MDIO_CTRL_PHY_ADDR_SHIFT) |
-   (reg  AR8X16_MDIO_CTRL_REG_ADDR_SHIFT));
+   (reg  AR8X16_MDIO_CTRL_REG_ADDR_SHIFT) |
+   (data  AR8X16_MDIO_CTRL_DATA_MASK));
if (err != 0)
goto out;
for (timeout = 100; timeout--; ) {

Modified: head/sys/dev/etherswitch/arswitch/arswitch_reg.c
==
--- head/sys/dev/etherswitch/arswitch/arswitch_reg.cTue Jul 23 13:56:38 
2013(r253569)
+++ head/sys/dev/etherswitch/arswitch/arswitch_reg.cTue Jul 23 14:02:38 
2013(r253570)
@@ -72,17 +72,10 @@ arswitch_split_setpage(device_t dev, uin
*phy = (((addr)  6)  0x07) | 0x10;
*reg = ((addr)  1)  0x1f;
 
-   /*
-* The earlier code would only switch the page
-* over if the page were different.  Experiments have
-* shown that this is unstable.
-*
-* Hence, the page is always set here.
-*
-* See PR kern/172968
-*/
-   MDIO_WRITEREG(device_get_parent(dev), 0x18, 0, page);
-   sc-page = page;
+   if (sc-page != page) {
+   MDIO_WRITEREG(device_get_parent(dev), 0x18, 0, page);
+   sc-page = page;
+   }
 }
 
 /*
@@ -171,8 +164,8 @@ arswitch_writereg(device_t dev, int addr
 {
 
/* XXX Check the first write too? */
-   arswitch_writereg_lsb(dev, addr, value);
-   return (arswitch_writereg_msb(dev, addr, value));
+   arswitch_writereg_msb(dev, addr, value);
+   return (arswitch_writereg_lsb(dev, addr, value));
 }
 
 int

Modified: head/sys/dev/etherswitch/arswitch/arswitchvar.h
==
--- head/sys/dev/etherswitch/arswitch/arswitchvar.h Tue Jul 23 13:56:38 
2013(r253569)
+++ head/sys/dev/etherswitch/arswitch/arswitchvar.h Tue Jul 23 14:02:38 
2013(r253570)
@@ -42,8 +42,6 @@ typedef enum {
 #defineAR8X16_IS_SWITCH(_sc, _type) \
(!!((_sc)-sc_switchtype == AR8X16_SWITCH_ ## _type))
 
-struct arswitch_softc;
-
 struct arswitch_softc {
struct mtx  sc_mtx; /* serialize access to softc */
device_tsc_dev;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253571 - in head: sys/netinet sys/netinet6 sys/netipsec usr.bin/netstat

2013-07-23 Thread Andrey V. Elsukov
Author: ae
Date: Tue Jul 23 14:14:24 2013
New Revision: 253571
URL: http://svnweb.freebsd.org/changeset/base/253571

Log:
  Remove the large part of struct ipsecstat. Only few fields of this
  structure is used, but they already have equal fields in the struct
  newipsecstat, that was introduced with FAST_IPSEC and then was merged
  together with old ipsecstat structure.
  
  This fixes kernel stack overflow on some architectures after migration
  ipsecstat to PCPU counters.
  
  Reported by:  Taku YAMAMOTO, Maciej Milewski

Modified:
  head/sys/netinet/sctp_input.c
  head/sys/netinet/tcp_input.c
  head/sys/netinet/udp_usrreq.c
  head/sys/netinet6/ip6_forward.c
  head/sys/netinet6/raw_ip6.c
  head/sys/netinet6/udp6_usrreq.c
  head/sys/netipsec/ipsec.h
  head/usr.bin/netstat/ipsec.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Tue Jul 23 14:02:38 2013
(r253570)
+++ head/sys/netinet/sctp_input.c   Tue Jul 23 14:14:24 2013
(r253571)
@@ -5705,7 +5705,7 @@ sctp_common_input_processing(struct mbuf
 #ifdef INET
case AF_INET:
if (ipsec4_in_reject(m, inp-ip_inp.inp)) {
-   IPSECSTAT_INC(in_polvio);
+   IPSECSTAT_INC(ips_in_polvio);
SCTP_STAT_INCR(sctps_hdrops);
goto out;
}
@@ -5714,7 +5714,7 @@ sctp_common_input_processing(struct mbuf
 #ifdef INET6
case AF_INET6:
if (ipsec6_in_reject(m, inp-ip_inp.inp)) {
-   IPSEC6STAT_INC(in_polvio);
+   IPSEC6STAT_INC(ips_in_polvio);
SCTP_STAT_INCR(sctps_hdrops);
goto out;
}

Modified: head/sys/netinet/tcp_input.c
==
--- head/sys/netinet/tcp_input.cTue Jul 23 14:02:38 2013
(r253570)
+++ head/sys/netinet/tcp_input.cTue Jul 23 14:14:24 2013
(r253571)
@@ -899,12 +899,12 @@ findpcb:
 #ifdef IPSEC
 #ifdef INET6
if (isipv6  ipsec6_in_reject(m, inp)) {
-   IPSEC6STAT_INC(in_polvio);
+   IPSEC6STAT_INC(ips_in_polvio);
goto dropunlock;
} else
 #endif /* INET6 */
if (ipsec4_in_reject(m, inp) != 0) {
-   IPSECSTAT_INC(in_polvio);
+   IPSECSTAT_INC(ips_in_polvio);
goto dropunlock;
}
 #endif /* IPSEC */

Modified: head/sys/netinet/udp_usrreq.c
==
--- head/sys/netinet/udp_usrreq.c   Tue Jul 23 14:02:38 2013
(r253570)
+++ head/sys/netinet/udp_usrreq.c   Tue Jul 23 14:14:24 2013
(r253571)
@@ -282,7 +282,7 @@ udp_append(struct inpcb *inp, struct ip 
/* Check AH/ESP integrity. */
if (ipsec4_in_reject(n, inp)) {
m_freem(n);
-   IPSECSTAT_INC(in_polvio);
+   IPSECSTAT_INC(ips_in_polvio);
return;
}
 #ifdef IPSEC_NAT_T
@@ -1294,7 +1294,7 @@ udp4_espdecap(struct inpcb *inp, struct 
if (minlen  m-m_pkthdr.len)
minlen = m-m_pkthdr.len;
if ((m = m_pullup(m, minlen)) == NULL) {
-   IPSECSTAT_INC(in_inval);
+   IPSECSTAT_INC(ips_in_inval);
return (NULL);  /* Bypass caller processing. */
}
data = mtod(m, caddr_t);/* Points to ip header. */
@@ -1334,7 +1334,7 @@ udp4_espdecap(struct inpcb *inp, struct 
uint32_t spi;
 
if (payload = sizeof(struct esp)) {
-   IPSECSTAT_INC(in_inval);
+   IPSECSTAT_INC(ips_in_inval);
m_freem(m);
return (NULL);  /* Discard. */
}
@@ -1355,7 +1355,7 @@ udp4_espdecap(struct inpcb *inp, struct 
tag = m_tag_get(PACKET_TAG_IPSEC_NAT_T_PORTS,
2 * sizeof(uint16_t), M_NOWAIT);
if (tag == NULL) {
-   IPSECSTAT_INC(in_nomem);
+   IPSECSTAT_INC(ips_in_nomem);
m_freem(m);
return (NULL);  /* Discard. */
}

Modified: head/sys/netinet6/ip6_forward.c
==
--- head/sys/netinet6/ip6_forward.c Tue Jul 23 14:02:38 2013
(r253570)
+++ head/sys/netinet6/ip6_forward.c Tue Jul 23 14:14:24 2013
(r253571)
@@ -120,7 +120,7 @@ ip6_forward(struct mbuf *m, int srcrt)
 * before forwarding packet actually.
 */
if (ipsec6_in_reject(m, NULL)) {
-   IPSEC6STAT_INC(in_polvio);
+   IPSEC6STAT_INC(ips_in_polvio);
m_freem(m);
   

svn commit: r253581 - in head: lib/libc/gen tools/regression/lib/libc/gen

2013-07-23 Thread Jilles Tjoelker
Author: jilles
Date: Tue Jul 23 21:09:26 2013
New Revision: 253581
URL: http://svnweb.freebsd.org/changeset/base/253581

Log:
  wordexp(): Fix syntax validation for backslashes in single-quotes.

Modified:
  head/lib/libc/gen/wordexp.c
  head/tools/regression/lib/libc/gen/test-wordexp.c

Modified: head/lib/libc/gen/wordexp.c
==
--- head/lib/libc/gen/wordexp.c Tue Jul 23 19:34:09 2013(r253580)
+++ head/lib/libc/gen/wordexp.c Tue Jul 23 21:09:26 2013(r253581)
@@ -251,7 +251,8 @@ we_check(const char *words, int flags)
while ((c = *words++) != '\0') {
switch (c) {
case '\\':
-   quote ^= 1;
+   if (squote == 0)
+   quote ^= 1;
continue;
case '\'':
if (quote + dquote == 0)

Modified: head/tools/regression/lib/libc/gen/test-wordexp.c
==
--- head/tools/regression/lib/libc/gen/test-wordexp.c   Tue Jul 23 19:34:09 
2013(r253580)
+++ head/tools/regression/lib/libc/gen/test-wordexp.c   Tue Jul 23 21:09:26 
2013(r253581)
@@ -195,6 +195,18 @@ main(int argc, char *argv[])
r = wordexp(test } test, we, 0);
assert(r == WRDE_BADCHAR);
 
+   /* WRDE_SYNTAX */
+   r = wordexp(', we, 0);
+   assert(r == WRDE_SYNTAX);
+   r = wordexp(', we, WRDE_UNDEF);
+   assert(r == WRDE_SYNTAX);
+   r = wordexp('\\', we, 0);
+   assert(r == 0);
+   assert(we.we_wordc == 1);
+   assert(strcmp(we.we_wordv[0], \\) == 0);
+   assert(we.we_wordv[1] == NULL);
+   wordfree(we);
+
/* With a SIGCHLD handler that reaps all zombies. */
sa.sa_flags = 0;
sigemptyset(sa.sa_mask);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253582 - head/sys/amd64/amd64

2013-07-23 Thread Neel Natu
Author: neel
Date: Tue Jul 23 22:17:00 2013
New Revision: 253582
URL: http://svnweb.freebsd.org/changeset/base/253582

Log:
  Fix a bug introduced in r252646 that causes a page with the PG_PTE_PAT bit set
  to be interpreted as a superpage. This is because PG_PTE_PAT is at the same
  bit position in PTE as PG_PS is in a PDE.
  
  This caused a number of regressions on amd64 systems: panic when starting
  X applications, freeze during shutdown etc.
  
  Pointy hat to:me
  Tested by: gpe...@entel.upc.edu, joel, dumbbell
  Reviewed by: kib

Modified:
  head/sys/amd64/amd64/pmap.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Tue Jul 23 21:09:26 2013(r253581)
+++ head/sys/amd64/amd64/pmap.c Tue Jul 23 22:17:00 2013(r253582)
@@ -4401,6 +4401,7 @@ pmap_remove_pages(pmap_t pmap)
int64_t bit;
uint64_t inuse, bitmask;
int allfree, field, freed, idx;
+   boolean_t superpage;
vm_paddr_t pa;
 
if (pmap != PCPU_GET(curpmap)) {
@@ -4427,12 +4428,26 @@ pmap_remove_pages(pmap_t pmap)
pte = pmap_pdpe_to_pde(pte, pv-pv_va);
tpte = *pte;
if ((tpte  (PG_PS | PG_V)) == PG_V) {
+   superpage = FALSE;
ptepde = tpte;
pte = (pt_entry_t *)PHYS_TO_DMAP(tpte 
PG_FRAME);
pte = pte[pmap_pte_index(pv-pv_va)];
tpte = *pte;
+   } else {
+   /*
+* Keep track whether 'tpte' is a
+* superpage explicitly instead of
+* relying on PG_PS being set.
+*
+* This is because PG_PS is numerically
+* identical to PG_PTE_PAT and thus a
+* regular page could be mistaken for
+* a superpage.
+*/
+   superpage = TRUE;
}
+
if ((tpte  PG_V) == 0) {
panic(bad pte va %lx pte %lx,
pv-pv_va, tpte);
@@ -4446,7 +4461,7 @@ pmap_remove_pages(pmap_t pmap)
continue;
}
 
-   if (tpte  PG_PS)
+   if (superpage)
pa = tpte  PG_PS_FRAME;
else
pa = tpte  PG_FRAME;
@@ -4468,7 +4483,7 @@ pmap_remove_pages(pmap_t pmap)
 * Update the vm_page_t clean/reference bits.
 */
if ((tpte  (PG_M | PG_RW)) == (PG_M | PG_RW)) {
-   if ((tpte  PG_PS) != 0) {
+   if (superpage) {
for (mt = m; mt  m[NBPDR / 
PAGE_SIZE]; mt++)
vm_page_dirty(mt);
} else
@@ -4479,7 +4494,7 @@ pmap_remove_pages(pmap_t pmap)
 
/* Mark free */
pc-pc_map[field] |= bitmask;
-   if ((tpte  PG_PS) != 0) {
+   if (superpage) {
pmap_resident_count_dec(pmap, NBPDR / 
PAGE_SIZE);
pvh = pa_to_pvh(tpte  PG_PS_FRAME);
TAILQ_REMOVE(pvh-pv_list, pv, 
pv_next);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r253504 - head/sbin/route

2013-07-23 Thread Dimitry Andric
On Jul 20, 2013, at 18:46, Hiroki Sato h...@freebsd.org wrote:
 Author: hrs
 Date: Sat Jul 20 16:46:51 2013
 New Revision: 253504
 URL: http://svnweb.freebsd.org/changeset/base/253504
 
 Log:
  - Simplify getaddr() and print_getmsg() by using RTAX_* instead of RTA_*
as the argument.
  - Reduce unnecessary loop in print_getmsg().
 
 Modified:
  head/sbin/route/route.c

Hi,

This breaks /etc/rc.d/defaultroute, since it relies on route -n get
-inet default printing a line with interface: in it.  Before r253504
it prints:

   route to: 0.0.0.0
destination: 0.0.0.0
   mask: 56.18.1.0
gateway: router.example.com
fib: 0
  interface: em0
  flags: UP,GATEWAY,DONE,STATIC
 recvpipe  sendpipe  ssthresh  rtt,msecmtuweightexpire
   0 0 0 0  1500 1 0

(note also the mask seems to be busted, and even though -n is given, the
hostname of the gateway is printed, but this is another issue)

At r253504 it gives:

   route to: 0.0.0.0
destination: 0.0.0.0
   mask: 56.18.1.0
gateway: router.example.com
fib: 0
  flags: UP,GATEWAY,DONE,STATIC
 recvpipe  sendpipe  ssthresh  rtt,msecmtuweightexpire
   0 0 0 0  1500 1 0

So for some reason, the interface: line is gone..

-Dimitry

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253583 - head/sys/vm

2013-07-23 Thread Jeff Roberson
Author: jeff
Date: Tue Jul 23 22:52:38 2013
New Revision: 253583
URL: http://svnweb.freebsd.org/changeset/base/253583

Log:
   - Correct a stale comment.  We don't have vclean() anymore.  The work is
 done by vgonel() and destroy_vobject() should only be called once from
 VOP_INACTIVE().
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/vm/vnode_pager.c

Modified: head/sys/vm/vnode_pager.c
==
--- head/sys/vm/vnode_pager.c   Tue Jul 23 22:17:00 2013(r253582)
+++ head/sys/vm/vnode_pager.c   Tue Jul 23 22:52:38 2013(r253583)
@@ -158,11 +158,6 @@ vnode_destroy_vobject(struct vnode *vp)
VM_OBJECT_WLOCK(obj);
if (obj-ref_count == 0) {
/*
-* vclean() may be called twice. The first time
-* removes the primary reference to the object,
-* the second time goes one further and is a
-* special-case to terminate the object.
-*
 * don't double-terminate the object
 */
if ((obj-flags  OBJ_DEAD) == 0)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253585 - head/sys/amd64/vmm

2013-07-23 Thread Neel Natu
Author: neel
Date: Tue Jul 23 23:43:00 2013
New Revision: 253585
URL: http://svnweb.freebsd.org/changeset/base/253585

Log:
  Add support for emulation of the or r/m, imm8 instruction.
  
  Submitted by: Zhixiang Yu (zxyu.c...@gmail.com)
  Obtained from:GSoC 2013 (AHCI device emulation for bhyve)

Modified:
  head/sys/amd64/vmm/vmm_instruction_emul.c

Modified: head/sys/amd64/vmm/vmm_instruction_emul.c
==
--- head/sys/amd64/vmm/vmm_instruction_emul.c   Tue Jul 23 22:53:01 2013
(r253584)
+++ head/sys/amd64/vmm/vmm_instruction_emul.c   Tue Jul 23 23:43:00 2013
(r253585)
@@ -60,6 +60,7 @@ enum {
VIE_OP_TYPE_NONE = 0,
VIE_OP_TYPE_MOV,
VIE_OP_TYPE_AND,
+   VIE_OP_TYPE_OR,
VIE_OP_TYPE_LAST
 };
 
@@ -94,7 +95,13 @@ static const struct vie_op one_byte_opco
.op_byte = 0x81,
.op_type = VIE_OP_TYPE_AND,
.op_flags = VIE_OP_F_IMM,
-   }
+   },
+   [0x83] = {
+   /* XXX Group 1 extended opcode - not just OR */
+   .op_byte = 0x83,
+   .op_type = VIE_OP_TYPE_OR,
+   .op_flags = VIE_OP_F_IMM8,
+   },
 };
 
 /* struct vie.mod */
@@ -338,8 +345,8 @@ emulate_and(void *vm, int vcpuid, uint64
break;
case 0x81:
/*
-* AND reg (ModRM:reg) with immediate and store the
-* result in reg
+* AND mem (ModRM:r/m) with immediate and store the
+* result in mem.
 *
 * 81/  and r/m32, imm32
 * REX.W + 81/  and r/m64, imm32 sign-extended to 64
@@ -371,6 +378,52 @@ emulate_and(void *vm, int vcpuid, uint64
return (error);
 }
 
+static int
+emulate_or(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
+   mem_region_read_t memread, mem_region_write_t memwrite, void *arg)
+{
+   int error, size;
+   uint64_t val1;
+
+   size = 4;
+   error = EINVAL;
+
+   switch (vie-op.op_byte) {
+   case 0x83:
+   /*
+* OR mem (ModRM:r/m) with immediate and store the
+* result in mem.
+*
+* 83/  OR r/m32, imm8 sign-extended to 32
+* REX.W + 83/  OR r/m64, imm8 sign-extended to 64
+*
+* Currently, only the OR operation of the 0x83 opcode
+* is implemented (ModRM:reg = b001).
+*/
+   if ((vie-reg  7) != 1)
+   break;
+
+   if (vie-rex_w)
+   size = 8;
+   
+   /* get the first operand */
+error = memread(vm, vcpuid, gpa, val1, size, arg);
+if (error)
+   break;
+
+/*
+* perform the operation with the pre-fetched immediate
+* operand and write the result
+*/
+val1 |= vie-immediate;
+error = memwrite(vm, vcpuid, gpa, val1, size, arg);
+   break;
+   default:
+   break;
+   }
+   return (error);
+}
+
 int
 vmm_emulate_instruction(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
mem_region_read_t memread, mem_region_write_t memwrite,
@@ -390,6 +443,10 @@ vmm_emulate_instruction(void *vm, int vc
error = emulate_and(vm, vcpuid, gpa, vie,
memread, memwrite, memarg);
break;
+   case VIE_OP_TYPE_OR:
+   error = emulate_or(vm, vcpuid, gpa, vie,
+   memread, memwrite, memarg);
+   break;
default:
error = EINVAL;
break;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r253504 - head/sbin/route

2013-07-23 Thread Hiroki Sato
Dimitry Andric d...@freebsd.org wrote
  in 36e48152-1a64-432d-a32d-75059a56e...@freebsd.org:

di On Jul 20, 2013, at 18:46, Hiroki Sato h...@freebsd.org wrote:
di  Author: hrs
di  Date: Sat Jul 20 16:46:51 2013
di  New Revision: 253504
di  URL: http://svnweb.freebsd.org/changeset/base/253504
di 
di  Log:
di   - Simplify getaddr() and print_getmsg() by using RTAX_* instead of RTA_*
di as the argument.
di   - Reduce unnecessary loop in print_getmsg().
di 
di  Modified:
di   head/sbin/route/route.c
di
di Hi,
di
di This breaks /etc/rc.d/defaultroute, since it relies on route -n get
di -inet default printing a line with interface: in it.  Before r253504
di it prints:
di
diroute to: 0.0.0.0
di destination: 0.0.0.0
dimask: 56.18.1.0
di gateway: router.example.com
di fib: 0
di   interface: em0
di   flags: UP,GATEWAY,DONE,STATIC
di  recvpipe  sendpipe  ssthresh  rtt,msecmtuweightexpire
di0 0 0 0  1500 1 0
di
di (note also the mask seems to be busted, and even though -n is given, the
di hostname of the gateway is printed, but this is another issue)
di
di At r253504 it gives:
di
diroute to: 0.0.0.0
di destination: 0.0.0.0
dimask: 56.18.1.0
di gateway: router.example.com
di fib: 0
di   flags: UP,GATEWAY,DONE,STATIC
di  recvpipe  sendpipe  ssthresh  rtt,msecmtuweightexpire
di0 0 0 0  1500 1 0
di
di So for some reason, the interface: line is gone..

 Gr, sorry.  This is my fault.  I will fix it soon.

-- Hiroki


pgpS9zCyKzVuT.pgp
Description: PGP signature


Re: svn commit: r253563 - head/contrib/libstdc++/include/c_std

2013-07-23 Thread Mark Linimon
On Tue, Jul 23, 2013 at 10:23:43AM +, David Chisnall wrote:
 A surprising number of configure checks rely on this.  It was broken by recent
 cleanups to math.h.

Once you have the experiences with the ports tree that I have had, you
will no longer assume anything about how ports configure checks work
(or many other similar items.)  Whatever the number, I would hardly find
it surprising.

The quality of code in the ports collection varies wildly.  Some of it
is truly professional-quality.  Some of it is written by people who
cannot even tie their own shoelaces.  The bulk of it is somewhere in
the middle -- and many of those people simply do not have the patience
or aptitude to understand the multitude of build and configure systems
that are out there.

We simply don't have the several thousand people that it would probably
take to audit the tens of millions of lines of code involved.

I would like to very politely suggest that regression testing such
changes beforehand is a far more effective strategy -- both technical
and inter-personal -- than simply assuming that either port authors
or maintainers will get such issues correct.  They can be subtle, and
there are an indefinite number of them.

mcl
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253587 - head/sys/vm

2013-07-23 Thread Jeff Roberson
Author: jeff
Date: Wed Jul 24 01:25:56 2013
New Revision: 253587
URL: http://svnweb.freebsd.org/changeset/base/253587

Log:
   - Remove the long obsolete 'vm_pageout_algorithm' experiment.
  
  Discussed with:   alc
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/vm/vm_pageout.c

Modified: head/sys/vm/vm_pageout.c
==
--- head/sys/vm/vm_pageout.cWed Jul 24 01:08:45 2013(r253586)
+++ head/sys/vm/vm_pageout.cWed Jul 24 01:25:56 2013(r253587)
@@ -157,7 +157,6 @@ static int vm_pageout_stats;
 static int vm_pageout_stats_interval;
 static int vm_pageout_full_stats;
 static int vm_pageout_full_stats_interval;
-static int vm_pageout_algorithm;
 static int defer_swap_pageouts;
 static int disable_swap_pageouts;
 
@@ -169,9 +168,6 @@ static int vm_swap_enabled = 1;
 static int vm_swap_idle_enabled = 0;
 #endif
 
-SYSCTL_INT(_vm, VM_PAGEOUT_ALGORITHM, pageout_algorithm,
-   CTLFLAG_RW, vm_pageout_algorithm, 0, LRU page mgmt);
-
 SYSCTL_INT(_vm, OID_AUTO, max_launder,
CTLFLAG_RW, vm_max_launder, 0, Limit dirty flushes in pageout);
 
@@ -756,9 +752,7 @@ vm_pageout_object_deactivate_pages(pmap_
if (actcount == 0) {
p-act_count -= min(p-act_count,
ACT_DECLINE);
-   if (!remove_mode 
-   (vm_pageout_algorithm ||
-   p-act_count == 0)) {
+   if (!remove_mode  p-act_count == 0) {
pmap_remove_all(p);
vm_page_deactivate(p);
} else
@@ -1356,8 +1350,7 @@ relock_queues:
vm_page_requeue_locked(m);
else {
m-act_count -= min(m-act_count, ACT_DECLINE);
-   if (vm_pageout_algorithm ||
-   object-ref_count == 0 ||
+   if (object-ref_count == 0 ||
m-act_count == 0) {
page_shortage--;
/* Dequeue to avoid later lock recursion. */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253589 - head/sbin/route

2013-07-23 Thread Hiroki Sato
Author: hrs
Date: Wed Jul 24 04:05:48 2013
New Revision: 253589
URL: http://svnweb.freebsd.org/changeset/base/253589

Log:
  Fix a bug in cp += SA_SIZE() in RTA_* loop.  This could prevent
  RTA_IFP from displaying correctly in route get subcommand.
  
  Spotted by:   dim

Modified:
  head/sbin/route/route.c

Modified: head/sbin/route/route.c
==
--- head/sbin/route/route.c Wed Jul 24 02:01:01 2013(r253588)
+++ head/sbin/route/route.c Wed Jul 24 04:05:48 2013(r253589)
@@ -1699,16 +1699,15 @@ print_getmsg(struct rt_msghdr *rtm, int 
return;
}
cp = ((char *)(rtm + 1));
-   for (i = 0; i  RTAX_MAX; i++) {
-   if (rtm-rtm_addrs  (1  i))
+   for (i = 0; i  RTAX_MAX; i++)
+   if (rtm-rtm_addrs  (1  i)) {
sp[i] = (struct sockaddr *)cp;
-   cp += SA_SIZE((struct sockaddr *)cp);
-   }
-   if (rtm-rtm_addrs  RTA_IFP) {
-   if (sp[RTAX_IFP]-sa_family != AF_LINK ||
-  ((struct sockaddr_dl *)(void *)sp[RTAX_IFP])-sdl_nlen == 0)
+   cp += SA_SIZE((struct sockaddr *)cp);
+   }
+   if ((rtm-rtm_addrs  RTA_IFP) 
+   (sp[RTAX_IFP]-sa_family != AF_LINK ||
+((struct sockaddr_dl *)(void *)sp[RTAX_IFP])-sdl_nlen == 0))
sp[RTAX_IFP] = NULL;
-   }
if (sp[RTAX_DST]  sp[RTAX_NETMASK])
sp[RTAX_NETMASK]-sa_family = sp[RTAX_DST]-sa_family; /* XXX */
if (sp[RTAX_DST])
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r253504 - head/sbin/route

2013-07-23 Thread Hiroki Sato
Dimitry Andric d...@freebsd.org wrote
  in 36e48152-1a64-432d-a32d-75059a56e...@freebsd.org:

di On Jul 20, 2013, at 18:46, Hiroki Sato h...@freebsd.org wrote:
di  Author: hrs
di  Date: Sat Jul 20 16:46:51 2013
di  New Revision: 253504
di  URL: http://svnweb.freebsd.org/changeset/base/253504
di 
di  Log:
di   - Simplify getaddr() and print_getmsg() by using RTAX_* instead of RTA_*
di as the argument.
di   - Reduce unnecessary loop in print_getmsg().
di 
di  Modified:
di   head/sbin/route/route.c
di
di Hi,
di
di This breaks /etc/rc.d/defaultroute, since it relies on route -n get
di -inet default printing a line with interface: in it.  Before r253504
di it prints:
di
diroute to: 0.0.0.0
di destination: 0.0.0.0
dimask: 56.18.1.0
di gateway: router.example.com
di fib: 0
di   interface: em0
di   flags: UP,GATEWAY,DONE,STATIC
di  recvpipe  sendpipe  ssthresh  rtt,msecmtuweightexpire
di0 0 0 0  1500 1 0
di
di (note also the mask seems to be busted, and even though -n is given, the
di hostname of the gateway is printed, but this is another issue)
di
di At r253504 it gives:
di
diroute to: 0.0.0.0
di destination: 0.0.0.0
dimask: 56.18.1.0
di gateway: router.example.com
di fib: 0
di   flags: UP,GATEWAY,DONE,STATIC
di  recvpipe  sendpipe  ssthresh  rtt,msecmtuweightexpire
di0 0 0 0  1500 1 0
di
di So for some reason, the interface: line is gone..

 Should be fixed in r253589.  Sorry for the breakage.

-- Hiroki


pgp6wgp4ECYWj.pgp
Description: PGP signature


svn commit: r253590 - in head/sys: kern net sys

2013-07-23 Thread Marcel Moolenaar
Author: marcel
Date: Wed Jul 24 04:24:21 2013
New Revision: 253590
URL: http://svnweb.freebsd.org/changeset/base/253590

Log:
  Decouple the UUID generator from network interfaces by having MAC
  addresses added to the UUID generator using uuid_ether_add(). The
  UUID generator keeps an arbitrary number of MAC addresses, under
  the assumption that they are rarely removed (= uuid_ether_del()).
  This achieves the following:
  1.  It brings up closer to having the network stack as a loadable
  module.
  2.  It allows the UUID generator to filter MAC addresses for best
  results (= highest chance of uniqeness).
  3.  MAC addresses can come from anywhere, irrespactive of whether
  it's used for an interface or not.
  
  A side-effect of the change is that when no MAC addresses have been
  added, a random multicast MAC address is created once and re-used if
  needed. Previusly, when a random MAC address was needed, it was
  created for every call. Thus, a change in behaviour is introduced
  for when no MAC addresses exist.
  
  Obtained from:Juniper Networks, Inc.

Modified:
  head/sys/kern/kern_uuid.c
  head/sys/net/if_ethersubr.c
  head/sys/sys/uuid.h

Modified: head/sys/kern/kern_uuid.c
==
--- head/sys/kern/kern_uuid.c   Wed Jul 24 04:05:48 2013(r253589)
+++ head/sys/kern/kern_uuid.c   Wed Jul 24 04:24:21 2013(r253590)
@@ -71,54 +71,41 @@ struct uuid_private {
 
 CTASSERT(sizeof(struct uuid_private) == 16);
 
+struct uuid_macaddr {
+   uint16_tstate;
+#defineUUID_ETHER_EMPTY0
+#defineUUID_ETHER_RANDOM   1
+#defineUUID_ETHER_UNIQUE   2
+   uint16_tnode[UUID_NODE_LEN1];
+};
+
 static struct uuid_private uuid_last;
 
+#define UUID_NETHER4
+static struct uuid_macaddr uuid_ether[UUID_NETHER];
+
 static struct mtx uuid_mutex;
 MTX_SYSINIT(uuid_lock, uuid_mutex, UUID generator mutex lock, MTX_DEF);
 
 /*
- * Return the first MAC address we encounter or, if none was found,
- * construct a sufficiently random multicast address. We don't try
- * to return the same MAC address as previously returned. We always
- * generate a new multicast address if no MAC address exists in the
- * system.
- * It would be nice to know if 'ifnet' or any of its sub-structures
- * has been changed in any way. If not, we could simply skip the
- * scan and safely return the MAC address we returned before.
+ * Return the first MAC address added in the array. If it's empty, then
+ * construct a sufficiently random multicast MAC address first. Any
+ * addresses added later will bump the random MAC address up tp the next
+ * index.
  */
 static void
 uuid_node(uint16_t *node)
 {
-   struct ifnet *ifp;
-   struct ifaddr *ifa;
-   struct sockaddr_dl *sdl;
int i;
 
-   CURVNET_SET(TD_TO_VNET(curthread));
-   IFNET_RLOCK_NOSLEEP();
-   TAILQ_FOREACH(ifp, V_ifnet, if_link) {
-   /* Walk the address list */
-   IF_ADDR_RLOCK(ifp);
-   TAILQ_FOREACH(ifa, ifp-if_addrhead, ifa_link) {
-   sdl = (struct sockaddr_dl*)ifa-ifa_addr;
-   if (sdl != NULL  sdl-sdl_family == AF_LINK 
-   sdl-sdl_type == IFT_ETHER) {
-   /* Got a MAC address. */
-   bcopy(LLADDR(sdl), node, UUID_NODE_LEN);
-   IF_ADDR_RUNLOCK(ifp);
-   IFNET_RUNLOCK_NOSLEEP();
-   CURVNET_RESTORE();
-   return;
-   }
-   }
-   IF_ADDR_RUNLOCK(ifp);
+   if (uuid_ether[0].state == UUID_ETHER_EMPTY) {
+   for (i = 0; i  (UUID_NODE_LEN1); i++)
+   uuid_ether[0].node[i] = (uint16_t)arc4random();
+   *((uint8_t*)uuid_ether[0].node) |= 0x01;
+   uuid_ether[0].state = UUID_ETHER_RANDOM;
}
-   IFNET_RUNLOCK_NOSLEEP();
-
for (i = 0; i  (UUID_NODE_LEN1); i++)
-   node[i] = (uint16_t)arc4random();
-   *((uint8_t*)node) |= 0x01;
-   CURVNET_RESTORE();
+   node[i] = uuid_ether[0].node[i];
 }
 
 /*
@@ -211,6 +198,77 @@ sys_uuidgen(struct thread *td, struct uu
 }
 
 int
+uuid_ether_add(const uint8_t *addr)
+{
+   int i;
+   uint8_t c;
+
+   /*
+* Validate input. No multicast addresses and no addresses that
+* are all zeroes.
+*/
+   if (addr[0]  0x01)
+   return (EINVAL);
+   c = 0;
+   for (i = 0; i  UUID_NODE_LEN; i++)
+   c += addr[i];
+   if (c == 0)
+   return (EINVAL);
+
+   mtx_lock(uuid_mutex);
+
+   /* Make sure the MAC isn't known already and that there's space. */
+   i = 0;
+   while (i  UUID_NETHER  uuid_ether[i].state == UUID_ETHER_UNIQUE) {
+   if