Re: svn commit: r196550 - in head: etc/defaults etc/rc.d share/man/man5

2009-08-28 Thread Xin LI
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Doug Barton wrote:
 Xin LI wrote:
 
 I think /etc/rc.d/static_arp stop should revert what was done by
 static_arp start by removing entries from the ARP table. 
 
 I agree with you.
 
 Gleb has
 kindly worked out a patch that adds '-d -f' functionality.
 
 But wouldn't it be easier to just parse the file and undo whatever arp
 -f does? It's up to you, but I would not be supportive of making
 changes to the arp binary this late in the release cycle.

Yes this is done by Gleb's patch.  I think it's more reasonable to teach
arp(8) about this for completeness reasons.  I.e. I feel sensible that
if arp(8) can do '-f' then it is supposed to undo the effect.  My $0.02 :)

Cheers,
- --
Xin LI delp...@delphij.nethttp://www.delphij.net/
FreeBSD - The Power to Serve!
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.12 (FreeBSD)

iEYEARECAAYFAkqXVr8ACgkQi+vbBBjt66CPHQCgmkIQQoAZSlmy+ooPVfRzRwvx
gCkAn0GgjhXX0ahYK0cQvWjIs3XIuiCm
=qSU/
-END PGP SIGNATURE-
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196609 - head/sys/net

2009-08-28 Thread Qing Li
Author: qingli
Date: Fri Aug 28 07:01:09 2009
New Revision: 196609
URL: http://svn.freebsd.org/changeset/base/196609

Log:
  In ip_output(), the flow-table module must not try to cache L2/L3
  information for interface of IFF_POINTOPOINT or IFF_LOOPBACK type.
  Since the L2 information (rt_lle) is invalid for these interface
  types, accidental caching attempt will trigger panic when the invalid
  rt_lle reference is accessed.
  
  When installing a new route, or when updating an existing route, the
  user supplied gateway address may be an interface address (this is
  particularly true for point-to-point interface related modules such
  as ppp, if_tun, if_gif). Currently the routing command handler always
  set the RTF_GATEWAY flag if the gateway address is given as part of the
  command paramters. Therefore the gateway address must be verified against
  interface addresses or else the route would be treated as an indirect
  route, thus making that route unusable.
  
  Reviewed by:  kmacy, julia, rwatson
  Verified by:  marcus
  MFC after:3 days

Modified:
  head/sys/net/flowtable.c
  head/sys/net/rtsock.c

Modified: head/sys/net/flowtable.c
==
--- head/sys/net/flowtable.cFri Aug 28 05:37:31 2009(r196608)
+++ head/sys/net/flowtable.cFri Aug 28 07:01:09 2009(r196609)
@@ -692,6 +692,12 @@ uncached:
struct rtentry *rt = ro-ro_rt;
struct ifnet *ifp = rt-rt_ifp;
 
+   if (ifp-if_flags  (IFF_POINTOPOINT | IFF_LOOPBACK)) {
+   RTFREE(rt);
+   ro-ro_rt = NULL;
+   return (ENOENT);
+   }
+
if (rt-rt_flags  RTF_GATEWAY)
l3addr = rt-rt_gateway;
else

Modified: head/sys/net/rtsock.c
==
--- head/sys/net/rtsock.c   Fri Aug 28 05:37:31 2009(r196608)
+++ head/sys/net/rtsock.c   Fri Aug 28 07:01:09 2009(r196609)
@@ -513,6 +513,39 @@ route_output(struct mbuf *m, struct sock
senderr(error);
}
 
+   /*
+* The given gateway address may be an interface address.
+* For example, issuing a route change command on a route
+* entry that was created from a tunnel, and the gateway
+* address given is the local end point. In this case the 
+* RTF_GATEWAY flag must be cleared or the destination will
+* not be reachable even though there is no error message.
+*/
+   if (info.rti_info[RTAX_GATEWAY] != NULL 
+   info.rti_info[RTAX_GATEWAY]-sa_family != AF_LINK) {
+   struct route gw_ro;
+
+   bzero(gw_ro, sizeof(gw_ro));
+   gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY];
+   rtalloc_ign(gw_ro, 0);
+   /* 
+* A host route through the loopback interface is 
+* installed for each interface adddress. In pre 8.0
+* releases the interface address of a PPP link type
+* is not reachable locally. This behavior is fixed as 
+* part of the new L2/L3 redesign and rewrite work. The
+* signature of this interface address route is the
+* AF_LINK sa_family type of the rt_gateway, and the
+* rt_ifp has the IFF_LOOPBACK flag set.
+*/
+   if (gw_ro.ro_rt != NULL 
+   gw_ro.ro_rt-rt_gateway-sa_family == AF_LINK 
+   gw_ro.ro_rt-rt_ifp-if_flags  IFF_LOOPBACK)
+   info.rti_flags = ~RTF_GATEWAY;
+   if (gw_ro.ro_rt != NULL)
+   RTFREE(gw_ro.ro_rt);
+   }
+
switch (rtm-rtm_type) {
struct rtentry *saved_nrt;
 
@@ -714,7 +747,7 @@ route_output(struct mbuf *m, struct sock
RT_UNLOCK(rt);
senderr(error);
}
-   rt-rt_flags |= RTF_GATEWAY;
+   rt-rt_flags |= (RTF_GATEWAY  info.rti_flags);
}
if (info.rti_ifa != NULL 
info.rti_ifa != rt-rt_ifa) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r196609 - head/sys/net

2009-08-28 Thread Bjoern A. Zeeb

On Fri, 28 Aug 2009, Qing Li wrote:


Author: qingli
Date: Fri Aug 28 07:01:09 2009
New Revision: 196609
URL: http://svn.freebsd.org/changeset/base/196609

Log:
 In ip_output(), the flow-table module must not try to cache L2/L3
 information for interface of IFF_POINTOPOINT or IFF_LOOPBACK type.
 Since the L2 information (rt_lle) is invalid for these interface
 types, accidental caching attempt will trigger panic when the invalid
 rt_lle reference is accessed.

 When installing a new route, or when updating an existing route, the
 user supplied gateway address may be an interface address (this is
 particularly true for point-to-point interface related modules such
 as ppp, if_tun, if_gif). Currently the routing command handler always
 set the RTF_GATEWAY flag if the gateway address is given as part of the
 command paramters. Therefore the gateway address must be verified against
 interface addresses or else the route would be treated as an indirect
 route, thus making that route unusable.

 Reviewed by:   kmacy, julia, rwatson
 Verified by:   marcus
 MFC after: 3 days



Am I right that this is two entirely separate issues in one commit?




Modified:
 head/sys/net/flowtable.c
 head/sys/net/rtsock.c

Modified: head/sys/net/flowtable.c
==
--- head/sys/net/flowtable.cFri Aug 28 05:37:31 2009(r196608)
+++ head/sys/net/flowtable.cFri Aug 28 07:01:09 2009(r196609)
@@ -692,6 +692,12 @@ uncached:
struct rtentry *rt = ro-ro_rt;
struct ifnet *ifp = rt-rt_ifp;

+   if (ifp-if_flags  (IFF_POINTOPOINT | IFF_LOOPBACK)) {
+   RTFREE(rt);
+   ro-ro_rt = NULL;
+   return (ENOENT);
+   }
+
if (rt-rt_flags  RTF_GATEWAY)
l3addr = rt-rt_gateway;
else

Modified: head/sys/net/rtsock.c
==
--- head/sys/net/rtsock.c   Fri Aug 28 05:37:31 2009(r196608)
+++ head/sys/net/rtsock.c   Fri Aug 28 07:01:09 2009(r196609)
@@ -513,6 +513,39 @@ route_output(struct mbuf *m, struct sock
senderr(error);
}

+   /*
+* The given gateway address may be an interface address.
+* For example, issuing a route change command on a route
+* entry that was created from a tunnel, and the gateway
+* address given is the local end point. In this case the
+* RTF_GATEWAY flag must be cleared or the destination will
+* not be reachable even though there is no error message.
+*/
+   if (info.rti_info[RTAX_GATEWAY] != NULL 
+   info.rti_info[RTAX_GATEWAY]-sa_family != AF_LINK) {
+   struct route gw_ro;
+
+   bzero(gw_ro, sizeof(gw_ro));
+   gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY];
+   rtalloc_ign(gw_ro, 0);


This ignores the FIB?  Shouldn't it be:
rtalloc_ign_fib(gw_ro, 0, so-so_fibnum);

Considering that julia reviewed it, I wonder what I am missing here?




+   /*
+* A host route through the loopback interface is
+* installed for each interface adddress. In pre 8.0
+* releases the interface address of a PPP link type
+* is not reachable locally. This behavior is fixed as
+* part of the new L2/L3 redesign and rewrite work. The
+* signature of this interface address route is the
+* AF_LINK sa_family type of the rt_gateway, and the
+* rt_ifp has the IFF_LOOPBACK flag set.
+*/
+   if (gw_ro.ro_rt != NULL 
+   gw_ro.ro_rt-rt_gateway-sa_family == AF_LINK 
+   gw_ro.ro_rt-rt_ifp-if_flags  IFF_LOOPBACK)
+   info.rti_flags = ~RTF_GATEWAY;
+   if (gw_ro.ro_rt != NULL)
+   RTFREE(gw_ro.ro_rt);
+   }
+
switch (rtm-rtm_type) {
struct rtentry *saved_nrt;

@@ -714,7 +747,7 @@ route_output(struct mbuf *m, struct sock
RT_UNLOCK(rt);
senderr(error);
}
-   rt-rt_flags |= RTF_GATEWAY;
+   rt-rt_flags |= (RTF_GATEWAY  info.rti_flags);
}
if (info.rti_ifa != NULL 
info.rti_ifa != rt-rt_ifa) {



Thanks for handling this!


/bz

--
Bjoern A. Zeeb   What was I talking about and who are you again?
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196612 - head/sys/modules

2009-08-28 Thread Ed Schouten
Author: ed
Date: Fri Aug 28 10:23:40 2009
New Revision: 196612
URL: http://svn.freebsd.org/changeset/base/196612

Log:
  Hook up the pty(4) module to the build.

Modified:
  head/sys/modules/Makefile

Modified: head/sys/modules/Makefile
==
--- head/sys/modules/Makefile   Fri Aug 28 08:49:35 2009(r196611)
+++ head/sys/modules/Makefile   Fri Aug 28 10:23:40 2009(r196612)
@@ -225,6 +225,7 @@ SUBDIR= ${_3dfx} \
procfs \
pseudofs \
${_pst} \
+   pty  \
puc \
ral \
ralfw \
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


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

2009-08-28 Thread John Baldwin
Author: jhb
Date: Fri Aug 28 14:06:55 2009
New Revision: 196615
URL: http://svn.freebsd.org/changeset/base/196615

Log:
  Extend the device pager to support different memory attributes on different
  pages in an object.
  - Add a new variant of d_mmap() currently called d_mmap2() which accepts
an additional in/out parameter that is the memory attribute to use for
the requested page.
  - A driver either uses d_mmap() or d_mmap2() for all requests but not both.
The current implementation uses a flag in the cdevsw (D_MMAP2) to indicate
that the driver provides a d_mmap2() handler instead of d_mmap().  This
is done to make the change ABI compatible with existing drivers and
MFC'able to 7 and 8.
  
  Submitted by: alc
  MFC after:1 month

Modified:
  head/sys/kern/kern_conf.c
  head/sys/sys/conf.h
  head/sys/sys/types.h
  head/sys/vm/device_pager.c
  head/sys/vm/vm.h

Modified: head/sys/kern/kern_conf.c
==
--- head/sys/kern/kern_conf.c   Fri Aug 28 10:25:26 2009(r196614)
+++ head/sys/kern/kern_conf.c   Fri Aug 28 14:06:55 2009(r196615)
@@ -302,7 +302,7 @@ static struct cdevsw dead_cdevsw = {
 #define no_read(d_read_t *)enodev
 #define no_write   (d_write_t *)enodev
 #define no_ioctl   (d_ioctl_t *)enodev
-#define no_mmap(d_mmap_t *)enodev
+#define no_mmap(d_mmap2_t *)enodev
 #define no_kqfilter(d_kqfilter_t *)enodev
 #define no_mmap_single (d_mmap_single_t *)enodev
 
@@ -469,7 +469,8 @@ giant_kqfilter(struct cdev *dev, struct 
 }
 
 static int
-giant_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot)
+giant_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot,
+vm_memattr_t *memattr)
 {
struct cdevsw *dsw;
int retval;
@@ -478,7 +479,11 @@ giant_mmap(struct cdev *dev, vm_offset_t
if (dsw == NULL)
return (ENXIO);
mtx_lock(Giant);
-   retval = dsw-d_gianttrick-d_mmap(dev, offset, paddr, nprot);
+   if (dsw-d_gianttrick-d_flags  D_MMAP2)
+   retval = dsw-d_gianttrick-d_mmap2(dev, offset, paddr, nprot,
+   memattr);
+   else
+   retval = dsw-d_gianttrick-d_mmap(dev, offset, paddr, nprot);
mtx_unlock(Giant);
dev_relthread(dev);
return (retval);
@@ -614,6 +619,7 @@ prep_cdevsw(struct cdevsw *devsw)
if (devsw-d_gianttrick == NULL) {
memcpy(dsw2, devsw, sizeof *dsw2);
devsw-d_gianttrick = dsw2;
+   devsw-d_flags |= D_MMAP2;
dsw2 = NULL;
}
}
@@ -634,7 +640,7 @@ prep_cdevsw(struct cdevsw *devsw)
FIXUP(d_write,  no_write,   giant_write);
FIXUP(d_ioctl,  no_ioctl,   giant_ioctl);
FIXUP(d_poll,   no_poll,giant_poll);
-   FIXUP(d_mmap,   no_mmap,giant_mmap);
+   FIXUP(d_mmap2,  no_mmap,giant_mmap);
FIXUP(d_strategy,   no_strategy,giant_strategy);
FIXUP(d_kqfilter,   no_kqfilter,giant_kqfilter);
FIXUP(d_mmap_single,no_mmap_single, giant_mmap_single);

Modified: head/sys/sys/conf.h
==
--- head/sys/sys/conf.h Fri Aug 28 10:25:26 2009(r196614)
+++ head/sys/sys/conf.h Fri Aug 28 14:06:55 2009(r196615)
@@ -137,6 +137,8 @@ typedef int d_poll_t(struct cdev *dev, i
 typedef int d_kqfilter_t(struct cdev *dev, struct knote *kn);
 typedef int d_mmap_t(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr,
 int nprot);
+typedef int d_mmap2_t(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr,
+int nprot, vm_memattr_t *memattr);
 typedef int d_mmap_single_t(struct cdev *cdev, vm_ooffset_t *offset,
 vm_size_t size, struct vm_object **object, int nprot);
 typedef void d_purge_t(struct cdev *dev);
@@ -170,6 +172,7 @@ typedef int dumper_t(
 #define D_PSEUDO   0x0020  /* make_dev() can return NULL */
 #define D_NEEDGIANT0x0040  /* driver want Giant */
 #defineD_NEEDMINOR 0x0080  /* driver uses clone_create() */
+#defineD_MMAP2 0x0100  /* driver uses d_mmap2() */
 
 /*
  * Version numbers.
@@ -198,7 +201,10 @@ struct cdevsw {
d_write_t   *d_write;
d_ioctl_t   *d_ioctl;
d_poll_t*d_poll;
-   d_mmap_t*d_mmap;
+   union {
+   d_mmap_t*old;
+   d_mmap2_t   *new;
+   } __d_mmap;
d_strategy_t*d_strategy;
dumper_t*d_dump;
d_kqfilter_t*d_kqfilter;
@@ -218,6 +224,8 @@ struct cdevsw {
SLIST_ENTRY(cdevsw) 

svn commit: r196616 - in stable/7/sys: . amd64/amd64 amd64/include contrib/pf dev/hwpmc i386/i386 i386/include

2009-08-28 Thread John Baldwin
Author: jhb
Date: Fri Aug 28 14:22:01 2009
New Revision: 196616
URL: http://svn.freebsd.org/changeset/base/196616

Log:
  MFC 196224:
  Adjust the handling of the local APIC PMC interrupt vector:
  - Provide lapic_disable_pmc(), lapic_enable_pmc(), and lapic_reenable_pmc()
routines in the local APIC code that the hwpmc(4) driver can use to
manage the local APIC PMC interrupt vector.
  - Do not enable the local APIC PMC interrupt vector by default when
HWPMC_HOOKS is enabled.  Instead, the hwpmc(4) driver explicitly
enables the interrupt when it is succesfully initialized and disables
the interrupt when it is unloaded.  This avoids enabling the interrupt
on unsupported CPUs which may result in spurious NMIs.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/amd64/local_apic.c
  stable/7/sys/amd64/include/apicvar.h
  stable/7/sys/amd64/include/pmc_mdep.h
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/hwpmc/hwpmc_core.c
  stable/7/sys/dev/hwpmc/hwpmc_piv.c
  stable/7/sys/dev/hwpmc/hwpmc_ppro.c
  stable/7/sys/dev/hwpmc/hwpmc_x86.c
  stable/7/sys/i386/i386/local_apic.c
  stable/7/sys/i386/include/apicvar.h
  stable/7/sys/i386/include/pmc_mdep.h

Modified: stable/7/sys/amd64/amd64/local_apic.c
==
--- stable/7/sys/amd64/amd64/local_apic.c   Fri Aug 28 14:06:55 2009
(r196615)
+++ stable/7/sys/amd64/amd64/local_apic.c   Fri Aug 28 14:22:01 2009
(r196616)
@@ -119,7 +119,7 @@ static struct lvt lvts[LVT_MAX + 1] = {
{ 1, 1, 0, 1, APIC_LVT_DM_NMI, 0 }, /* LINT1: NMI */
{ 1, 1, 1, 1, APIC_LVT_DM_FIXED, APIC_TIMER_INT },  /* Timer */
{ 1, 1, 1, 1, APIC_LVT_DM_FIXED, APIC_ERROR_INT },  /* Error */
-   { 1, 1, 0, 1, APIC_LVT_DM_NMI, 0 }, /* PMC */
+   { 1, 1, 1, 1, APIC_LVT_DM_NMI, 0 }, /* PMC */
{ 1, 1, 1, 1, APIC_LVT_DM_FIXED, APIC_THERMAL_INT },/* Thermal */
 };
 
@@ -299,11 +299,9 @@ lapic_setup(int boot)
/* Program LINT[01] LVT entries. */
lapic-lvt_lint0 = lvt_mode(la, LVT_LINT0, lapic-lvt_lint0);
lapic-lvt_lint1 = lvt_mode(la, LVT_LINT1, lapic-lvt_lint1);
-#ifdef HWPMC_HOOKS
/* Program the PMC LVT entry if present. */
if (maxlvt = LVT_PMC)
lapic-lvt_pcint = lvt_mode(la, LVT_PMC, lapic-lvt_pcint);
-#endif
 
/* Program timer LVT and setup handler. */
lapic-lvt_timer = lvt_mode(la, LVT_TIMER, lapic-lvt_timer);
@@ -349,6 +347,88 @@ lapic_setup(int boot)
intr_restore(eflags);
 }
 
+void
+lapic_reenable_pmc(void)
+{
+#ifdef HWPMC_HOOKS
+   uint32_t value;
+
+   value =  lapic-lvt_pcint;
+   value = ~APIC_LVT_M;
+   lapic-lvt_pcint = value;
+#endif
+}
+
+#ifdef HWPMC_HOOKS
+static void
+lapic_update_pmc(void *dummy)
+{
+   struct lapic *la;
+
+   la = lapics[lapic_id()];
+   lapic-lvt_pcint = lvt_mode(la, LVT_PMC, lapic-lvt_pcint);
+}
+#endif
+
+int
+lapic_enable_pmc(void)
+{
+#ifdef HWPMC_HOOKS
+   u_int32_t maxlvt;
+
+   /* Fail if the local APIC is not present. */
+   if (lapic == NULL)
+   return (0);
+
+   /* Fail if the PMC LVT is not present. */
+   maxlvt = (lapic-version  APIC_VER_MAXLVT)  MAXLVTSHIFT;
+   if (maxlvt  LVT_PMC)
+   return (0);
+
+   lvts[LVT_PMC].lvt_masked = 0;
+
+#ifdef SMP
+   /*
+* If hwpmc was loaded at boot time then the APs may not be
+* started yet.  In that case, don't forward the request to
+* them as they will program the lvt when they start.
+*/
+   if (smp_started)
+   smp_rendezvous(NULL, lapic_update_pmc, NULL, NULL);
+   else
+#endif
+   lapic_update_pmc(NULL);
+   return (1);
+#else
+   return (0);
+#endif
+}
+
+void
+lapic_disable_pmc(void)
+{
+#ifdef HWPMC_HOOKS
+   u_int32_t maxlvt;
+
+   /* Fail if the local APIC is not present. */
+   if (lapic == NULL)
+   return;
+
+   /* Fail if the PMC LVT is not present. */
+   maxlvt = (lapic-version  APIC_VER_MAXLVT)  MAXLVTSHIFT;
+   if (maxlvt  LVT_PMC)
+   return;
+
+   lvts[LVT_PMC].lvt_masked = 1;
+
+#ifdef SMP
+   /* The APs should always be started when hwpmc is unloaded. */
+   KASSERT(mp_ncpus == 1 || smp_started, (hwpmc unloaded too early));
+#endif
+   smp_rendezvous(NULL, lapic_update_pmc, NULL, NULL);
+#endif
+}
+
 /*
  * Called by cpu_initclocks() on the BSP to setup the local APIC timer so
  * that it can drive hardclock, statclock, and profclock.  This function

Modified: stable/7/sys/amd64/include/apicvar.h
==
--- stable/7/sys/amd64/include/apicvar.hFri Aug 28 14:06:55 2009
(r196615)
+++ stable/7/sys/amd64/include/apicvar.hFri Aug 28 14:22:01 2009
(r196616)
@@ -198,7 +198,9 @@ int 

Re: svn commit: r196615 - in head/sys: kern sys vm

2009-08-28 Thread John Baldwin
On Friday 28 August 2009 10:06:56 am John Baldwin wrote:
 Author: jhb
 Date: Fri Aug 28 14:06:55 2009
 New Revision: 196615
 URL: http://svn.freebsd.org/changeset/base/196615
 
 Log:
   Extend the device pager to support different memory attributes on different
   pages in an object.
   - Add a new variant of d_mmap() currently called d_mmap2() which accepts
 an additional in/out parameter that is the memory attribute to use for
 the requested page.
   - A driver either uses d_mmap() or d_mmap2() for all requests but not both.
 The current implementation uses a flag in the cdevsw (D_MMAP2) to indicate
 that the driver provides a d_mmap2() handler instead of d_mmap().  This
 is done to make the change ABI compatible with existing drivers and
 MFC'able to 7 and 8.

The future plan for 9.0 is to just convert d_mmap() to the newer API/ABI and
remove d_mmap2().  However, the current version of this patch is MFC'able
without need changes to drivers that do not use the new parameter.

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


svn commit: r196618 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/re dev/xen/xenpci pci

2009-08-28 Thread Pyun YongHyeon
Author: yongari
Date: Fri Aug 28 17:34:22 2009
New Revision: 196618
URL: http://svn.freebsd.org/changeset/base/196618

Log:
  MFC r196516:
Add RTL8168DP/RTL8111DP device id. While I'm here append 8111D to
the description of RTL8168D as RL_HWREV_8168D can be either
RTL8168D or RTL8111D.
  
PR: kern/137672
  Approved by:  re (kib)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/re/if_re.c
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/pci/if_rlreg.h

Modified: stable/8/sys/dev/re/if_re.c
==
--- stable/8/sys/dev/re/if_re.c Fri Aug 28 16:45:34 2009(r196617)
+++ stable/8/sys/dev/re/if_re.c Fri Aug 28 17:34:22 2009(r196618)
@@ -174,8 +174,8 @@ static struct rl_type re_devs[] = {
{ RT_VENDORID, RT_DEVICEID_8101E, 0,
RealTek 8101E/8102E/8102EL PCIe 10/100baseTX },
{ RT_VENDORID, RT_DEVICEID_8168, 0,
-   RealTek 8168/8168B/8168C/8168CP/8168D/8111B/8111C/8111CP PCIe 
-   Gigabit Ethernet },
+   RealTek 8168/8168B/8168C/8168CP/8168D/8168DP/
+   8111B/8111C/8111CP/8111DP PCIe Gigabit Ethernet },
{ RT_VENDORID, RT_DEVICEID_8169, 0,
RealTek 8169/8169S/8169SB(L)/8110S/8110SB(L) Gigabit Ethernet },
{ RT_VENDORID, RT_DEVICEID_8169SC, 0,
@@ -217,7 +217,8 @@ static struct rl_hwrev re_hwrevs[] = {
{ RL_HWREV_8168C, RL_8169, 8168C/8111C},
{ RL_HWREV_8168C_SPIN2, RL_8169, 8168C/8111C},
{ RL_HWREV_8168CP, RL_8169, 8168CP/8111CP},
-   { RL_HWREV_8168D, RL_8169, 8168D},
+   { RL_HWREV_8168D, RL_8169, 8168D/8111D},
+   { RL_HWREV_8168DP, RL_8169, 8168DP/8111DP},
{ 0, 0, NULL }
 };
 
@@ -1282,6 +1283,7 @@ re_attach(device_t dev)
/* FALLTHROUGH */
case RL_HWREV_8168CP:
case RL_HWREV_8168D:
+   case RL_HWREV_8168DP:
sc-rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR |
RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP |
RL_FLAG_AUTOPAD;

Modified: stable/8/sys/pci/if_rlreg.h
==
--- stable/8/sys/pci/if_rlreg.h Fri Aug 28 16:45:34 2009(r196617)
+++ stable/8/sys/pci/if_rlreg.h Fri Aug 28 17:34:22 2009(r196618)
@@ -161,6 +161,7 @@
 #define RL_HWREV_8102EL0x2480
 #define RL_HWREV_8102EL_SPIN1  0x24c0
 #define RL_HWREV_8168D 0x2800
+#define RL_HWREV_8168DP0x2880
 #define RL_HWREV_8168_SPIN10x3000
 #define RL_HWREV_8100E 0x3080
 #define RL_HWREV_8101E 0x3400
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196619 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/alc dev/xen/xenpci

2009-08-28 Thread Pyun YongHyeon
Author: yongari
Date: Fri Aug 28 18:01:37 2009
New Revision: 196619
URL: http://svn.freebsd.org/changeset/base/196619

Log:
  MFC r196517:
Don't try to power down PHY when alc(4) failed to map the device.
This fixes system crash when mapping alc(4) device failed in device
attach.
  
Reported by:Jim  stapleton.41  gmail DOT com 
  Approved by:  re (kib)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/alc/if_alc.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/alc/if_alc.c
==
--- stable/8/sys/dev/alc/if_alc.c   Fri Aug 28 17:34:22 2009
(r196618)
+++ stable/8/sys/dev/alc/if_alc.c   Fri Aug 28 18:01:37 2009
(r196619)
@@ -858,7 +858,8 @@ alc_detach(device_t dev)
sc-alc_intrhand[i] = NULL;
}
}
-   alc_phy_down(sc);
+   if (sc-alc_res[0] != NULL)
+   alc_phy_down(sc);
bus_release_resources(dev, sc-alc_irq_spec, sc-alc_irq);
if ((sc-alc_flags  (ALC_FLAG_MSI | ALC_FLAG_MSIX)) != 0)
pci_release_msi(dev);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196622 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci fs/nfsclient nfsclient rpc

2009-08-28 Thread Marko Zec
Author: zec
Date: Fri Aug 28 19:12:44 2009
New Revision: 196622
URL: http://svn.freebsd.org/changeset/base/196622

Log:
  MFC r196503:
  
Fix NFS panics with options VIMAGE kernels by apropriately setting curvnet
context inside the RPC code.
  
Temporarily set td's cred to mount's cred before calling socreate() via
__rpc_nconf2socket().
  
Submitted by: rmacklem (in part)
Reviewed by:  rmacklem, rwatson
Discussed with:   dfr, bz
Approved by:  re (rwatson), julian (mentor)
  
  Approved by:  re (rwatson)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/fs/nfsclient/nfs_clvnops.c
  stable/8/sys/nfsclient/nfs_vnops.c
  stable/8/sys/rpc/clnt_dg.c
  stable/8/sys/rpc/clnt_rc.c
  stable/8/sys/rpc/clnt_vc.c
  stable/8/sys/rpc/rpc_generic.c
  stable/8/sys/rpc/svc_dg.c
  stable/8/sys/rpc/svc_generic.c
  stable/8/sys/rpc/svc_vc.c

Modified: stable/8/sys/fs/nfsclient/nfs_clvnops.c
==
--- stable/8/sys/fs/nfsclient/nfs_clvnops.c Fri Aug 28 19:10:58 2009
(r196621)
+++ stable/8/sys/fs/nfsclient/nfs_clvnops.c Fri Aug 28 19:12:44 2009
(r196622)
@@ -1405,8 +1405,8 @@ again:
}
mtx_unlock(dnp-n_mtx);
 
-   CURVNET_SET(P_TO_VNET(proc0));
 #ifdef INET
+   CURVNET_SET(CRED_TO_VNET(cnp-cn_cred));
IN_IFADDR_RLOCK();
if (!TAILQ_EMPTY(V_in_ifaddrhead))
cverf.lval[0] = 
IA_SIN(TAILQ_FIRST(V_in_ifaddrhead))-sin_addr.s_addr;
@@ -1415,9 +1415,9 @@ again:
cverf.lval[0] = create_verf;
 #ifdef INET
IN_IFADDR_RUNLOCK();
+   CURVNET_RESTORE();
 #endif
cverf.lval[1] = ++create_verf;
-   CURVNET_RESTORE();
error = nfsrpc_create(dvp, cnp-cn_nameptr, cnp-cn_namelen,
vap, cverf, fmode, cnp-cn_cred, cnp-cn_thread, dnfsva, nfsva,
nfhp, attrflag, dattrflag, NULL);

Modified: stable/8/sys/nfsclient/nfs_vnops.c
==
--- stable/8/sys/nfsclient/nfs_vnops.c  Fri Aug 28 19:10:58 2009
(r196621)
+++ stable/8/sys/nfsclient/nfs_vnops.c  Fri Aug 28 19:12:44 2009
(r196622)
@@ -50,6 +50,7 @@ __FBSDID($FreeBSD$);
 #include sys/mount.h
 #include sys/bio.h
 #include sys/buf.h
+#include sys/jail.h
 #include sys/malloc.h
 #include sys/mbuf.h
 #include sys/namei.h
@@ -1552,6 +1553,7 @@ again:
*tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE);
tl = nfsm_build(u_int32_t *, NFSX_V3CREATEVERF);
 #ifdef INET
+   CURVNET_SET(CRED_TO_VNET(cnp-cn_cred));
IN_IFADDR_RLOCK();
if (!TAILQ_EMPTY(V_in_ifaddrhead))
*tl++ = 
IA_SIN(TAILQ_FIRST(V_in_ifaddrhead))-sin_addr.s_addr;
@@ -1560,6 +1562,7 @@ again:
*tl++ = create_verf;
 #ifdef INET
IN_IFADDR_RUNLOCK();
+   CURVNET_RESTORE();
 #endif
*tl = ++create_verf;
} else {

Modified: stable/8/sys/rpc/clnt_dg.c
==
--- stable/8/sys/rpc/clnt_dg.c  Fri Aug 28 19:10:58 2009(r196621)
+++ stable/8/sys/rpc/clnt_dg.c  Fri Aug 28 19:12:44 2009(r196622)
@@ -57,6 +57,8 @@ __FBSDID($FreeBSD$);
 #include sys/time.h
 #include sys/uio.h
 
+#include net/vnet.h
+
 #include rpc/rpc.h
 #include rpc/rpc_com.h
 
@@ -197,11 +199,14 @@ clnt_dg_create(
return (NULL);
}
 
+   CURVNET_SET(so-so_vnet);
if (!__rpc_socket2sockinfo(so, si)) {
rpc_createerr.cf_stat = RPC_TLIERROR;
rpc_createerr.cf_error.re_errno = 0;
+   CURVNET_RESTORE();
return (NULL);
}
+   CURVNET_RESTORE();
 
/*
 * Find the receive and the send size

Modified: stable/8/sys/rpc/clnt_rc.c
==
--- stable/8/sys/rpc/clnt_rc.c  Fri Aug 28 19:10:58 2009(r196621)
+++ stable/8/sys/rpc/clnt_rc.c  Fri Aug 28 19:12:44 2009(r196622)
@@ -175,15 +175,16 @@ clnt_reconnect_connect(CLIENT *cl)
rc-rc_connecting = TRUE;
mtx_unlock(rc-rc_lock);
 
+   oldcred = td-td_ucred;
+   td-td_ucred = rc-rc_ucred;
so = __rpc_nconf2socket(rc-rc_nconf);
if (!so) {
stat = rpc_createerr.cf_stat = RPC_TLIERROR;
rpc_createerr.cf_error.re_errno = 0;
+   td-td_ucred = oldcred;
goto out;
}
 
-   oldcred = td-td_ucred;
-   td-td_ucred = rc-rc_ucred;
if 

svn commit: r196623 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci kern

2009-08-28 Thread Marko Zec
Author: zec
Date: Fri Aug 28 19:15:17 2009
New Revision: 196623
URL: http://svn.freebsd.org/changeset/base/196623

Log:
  MFC r196505:
  
When jail -c vnet request fails, the current code actually creates and
leaves behind an orphaned vnet.  This change ensures that such vnets get
released.
  
This change affects only options VIMAGE builds.
  
Submitted by: jamie
Discussed with:   bz
Approved by:  re (rwatson), julian (mentor)
  
  Approved by:  re (rwatson)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/kern/kern_jail.c

Modified: stable/8/sys/kern/kern_jail.c
==
--- stable/8/sys/kern/kern_jail.c   Fri Aug 28 19:12:44 2009
(r196622)
+++ stable/8/sys/kern/kern_jail.c   Fri Aug 28 19:15:17 2009
(r196623)
@@ -2456,7 +2456,7 @@ prison_deref(struct prison *pr, int flag
sx_downgrade(allprison_lock);
 
 #ifdef VIMAGE
-   if (pr-pr_flags  PR_VNET)
+   if (pr-pr_vnet != ppr-pr_vnet)
vnet_destroy(pr-pr_vnet);
 #endif
if (pr-pr_root != NULL) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196624 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net

2009-08-28 Thread Marko Zec
Author: zec
Date: Fri Aug 28 19:18:20 2009
New Revision: 196624
URL: http://svn.freebsd.org/changeset/base/196624

Log:
  MFC r196504:
  
When moving ifnets from one vnet to another, and the ifnet
has ifaddresses of AF_LINK type which thus have an embedded
if_index backpointer, we must update that if_index backpointer
to reflect the new if_index that our ifnet just got assigned.
  
This change affects only options VIMAGE builds.
  
Submitted by: bz
Reviewed by:  bz
Approved by:  re (rwatson), julian (mentor)
  
  Approved by:  re (rwatson)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/net/if.c

Modified: stable/8/sys/net/if.c
==
--- stable/8/sys/net/if.c   Fri Aug 28 19:15:17 2009(r196623)
+++ stable/8/sys/net/if.c   Fri Aug 28 19:18:20 2009(r196624)
@@ -570,6 +570,21 @@ if_attach_internal(struct ifnet *ifp, in
/* Reliably crash if used uninitialized. */
ifp-if_broadcastaddr = NULL;
}
+#ifdef VIMAGE
+   else {
+   /*
+* Update the interface index in the link layer address
+* of the interface.
+*/
+   for (ifa = ifp-if_addr; ifa != NULL;
+   ifa = TAILQ_NEXT(ifa, ifa_link)) {
+   if (ifa-ifa_addr-sa_family == AF_LINK) {
+   sdl = (struct sockaddr_dl *)ifa-ifa_addr;
+   sdl-sdl_index = ifp-if_index;
+   }
+   }
+   }
+#endif
 
IFNET_WLOCK();
TAILQ_INSERT_TAIL(V_ifnet, ifp, if_link);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196627 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net

2009-08-28 Thread Robert Watson
Author: rwatson
Date: Fri Aug 28 20:07:38 2009
New Revision: 196627
URL: http://svn.freebsd.org/changeset/base/196627

Log:
  Merge r196482 from head to stable/8:
  
Rather than using IFNET_RLOCK() when iterating over (and modifying) the
ifnet list during if_ef load, directly acquire the ifnet_sxlock
exclusively.  That way when if_alloc() recurses the lock, it's a write
recursion rather than a read-write recursion.
  
This code structure is arguably a bug, so add a comment indicating that
this is the case.  Post-8.0, we should fix this, but this commit
resolves panic-on-load for if_ef.
  
Discussed with:   bz, julian
Reported by:  phk
  
  Approved by:  re (kib)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/net/if_ef.c

Modified: stable/8/sys/net/if_ef.c
==
--- stable/8/sys/net/if_ef.cFri Aug 28 20:06:02 2009(r196626)
+++ stable/8/sys/net/if_ef.cFri Aug 28 20:07:38 2009(r196627)
@@ -492,7 +492,20 @@ ef_load(void)
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
-   IFNET_RLOCK();
+
+   /*
+* XXXRW: The following loop walks the ifnet list while
+* modifying it, something not well-supported by ifnet
+* locking.  To avoid lock upgrade/recursion issues, manually
+* acquire a write lock of ifnet_sxlock here, rather than a
+* read lock, so that when if_alloc() recurses the lock, we
+* don't panic.  This structure, in which if_ef automatically
+* attaches to all ethernet interfaces, should be replaced
+* with a model like that found in if_vlan, in which
+* interfaces are explicitly configured, which would avoid
+* this (and other) problems.
+*/
+   sx_xlock(ifnet_sxlock);
TAILQ_FOREACH(ifp, V_ifnet, if_link) {
if (ifp-if_type != IFT_ETHER) continue;
EFDEBUG(Found interface %s\n, ifp-if_xname);
@@ -523,7 +536,7 @@ ef_load(void)
efcount++;
SLIST_INSERT_HEAD(efdev, efl, el_next);
}
-   IFNET_RUNLOCK();
+   sx_xunlock(ifnet_sxlock);
CURVNET_RESTORE();
}
VNET_LIST_RUNLOCK();
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196628 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf contrib/pf/net dev/xen/xenpci

2009-08-28 Thread Max Laier
Author: mlaier
Date: Fri Aug 28 20:26:00 2009
New Revision: 196628
URL: http://svn.freebsd.org/changeset/base/196628

Log:
  MFC r196551:
Fix argument ordering to memcpy as well as the size of the copy in the
(theoretical) case that pfi_buffer_cnt should be greater than ~_max.
  
Submitted by:   pjd
Reviewed by:{krw,sthen,mark...@openbsd.org
  
  Approved by:  re (kib)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/contrib/pf/net/pf_if.c
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/contrib/pf/net/pf_if.c
==
--- stable/8/sys/contrib/pf/net/pf_if.c Fri Aug 28 20:07:38 2009
(r196627)
+++ stable/8/sys/contrib/pf/net/pf_if.c Fri Aug 28 20:26:00 2009
(r196628)
@@ -663,7 +663,7 @@ pfi_address_add(struct sockaddr *sa, int
(%d/%d)\n, pfi_buffer_cnt, PFI_BUFFER_MAX);
return;
}
-   memcpy(pfi_buffer, p, pfi_buffer_cnt * sizeof(*pfi_buffer));
+   memcpy(p, pfi_buffer, pfi_buffer_max * sizeof(*pfi_buffer));
/* no need to zero buffer */
free(pfi_buffer, PFI_MTYPE);
pfi_buffer = p;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196629 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net

2009-08-28 Thread Robert Watson
Author: rwatson
Date: Fri Aug 28 21:07:43 2009
New Revision: 196629
URL: http://svn.freebsd.org/changeset/base/196629

Log:
  Merge r196510 from head to stable/8:
  
Make if_grow static -- it's not used outside of if.c, and with the
internals destined to change, it's better if it remains that way.
  
  Approved by:  re (kib)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/net/if.c
  stable/8/sys/net/if_var.h

Modified: stable/8/sys/net/if.c
==
--- stable/8/sys/net/if.c   Fri Aug 28 20:26:00 2009(r196628)
+++ stable/8/sys/net/if.c   Fri Aug 28 21:07:43 2009(r196629)
@@ -124,6 +124,7 @@ static void if_attachdomain1(struct ifne
 static int ifconf(u_long, caddr_t);
 static voidif_freemulti(struct ifmultiaddr *);
 static voidif_init(void *);
+static voidif_grow(void);
 static voidif_check(void *);
 static voidif_route(struct ifnet *, int flag, int fam);
 static int if_setflag(struct ifnet *, int, int, int *, int);
@@ -297,7 +298,7 @@ VNET_SYSUNINIT(vnet_if_uninit, SI_SUB_IN
 vnet_if_uninit, NULL);
 #endif
 
-void
+static void
 if_grow(void)
 {
u_int n;

Modified: stable/8/sys/net/if_var.h
==
--- stable/8/sys/net/if_var.h   Fri Aug 28 20:26:00 2009(r196628)
+++ stable/8/sys/net/if_var.h   Fri Aug 28 21:07:43 2009(r196629)
@@ -826,7 +826,6 @@ int if_allmulti(struct ifnet *, int);
 struct ifnet* if_alloc(u_char);
 void   if_attach(struct ifnet *);
 void   if_dead(struct ifnet *);
-void   if_grow(void);
 intif_delmulti(struct ifnet *, struct sockaddr *);
 void   if_delmulti_ifma(struct ifmultiaddr *);
 void   if_detach(struct ifnet *);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196630 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net netinet netinet6

2009-08-28 Thread Robert Watson
Author: rwatson
Date: Fri Aug 28 21:10:26 2009
New Revision: 196630
URL: http://svn.freebsd.org/changeset/base/196630

Log:
  Merge r196535 from head to stable/8:
  
Use locks specific to the lltable code, rather than borrow the ifnet
list/index locks, to protect link layer address tables.  This avoids
lock order issues during interface teardown, but maintains the bug that
sysctl copy routines may be called while a non-sleepable lock is held.
  
Reviewed by:  bz, kmacy, qingli
  
  Approved by:  re (kib)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/net/if_llatbl.c
  stable/8/sys/net/if_llatbl.h
  stable/8/sys/netinet/in.c
  stable/8/sys/netinet6/in6.c

Modified: stable/8/sys/net/if_llatbl.c
==
--- stable/8/sys/net/if_llatbl.cFri Aug 28 21:07:43 2009
(r196629)
+++ stable/8/sys/net/if_llatbl.cFri Aug 28 21:10:26 2009
(r196630)
@@ -62,6 +62,9 @@ staticSLIST_HEAD(, lltable) lltables = 
 extern void arprequest(struct ifnet *, struct in_addr *, struct in_addr *,
u_char *);
 
+struct rwlock lltable_rwlock;
+RW_SYSINIT(lltable_rwlock, lltable_rwlock, lltable_rwlock);
+
 /*
  * Dump arp state for a specific address family.
  */
@@ -71,7 +74,7 @@ lltable_sysctl_dumparp(int af, struct sy
struct lltable *llt;
int error = 0;
 
-   IFNET_RLOCK();
+   LLTABLE_RLOCK();
SLIST_FOREACH(llt, lltables, llt_link) {
if (llt-llt_af == af) {
error = llt-llt_dump(llt, wr);
@@ -80,7 +83,7 @@ lltable_sysctl_dumparp(int af, struct sy
}
}
 done:
-   IFNET_RUNLOCK();
+   LLTABLE_RUNLOCK();
return (error);
 }
 
@@ -144,8 +147,6 @@ llentry_update(struct llentry **llep, st
 
 /*
  * Free all entries from given table and free itself.
- * Since lltables collects from all of the intefaces,
- * the caller of this function must acquire IFNET_WLOCK().
  */
 void
 lltable_free(struct lltable *llt)
@@ -155,9 +156,9 @@ lltable_free(struct lltable *llt)
 
KASSERT(llt != NULL, (%s: llt is NULL, __func__));
 
-   IFNET_WLOCK();
+   LLTABLE_WLOCK();
SLIST_REMOVE(lltables, llt, lltable, llt_link);
-   IFNET_WUNLOCK();
+   LLTABLE_WUNLOCK();
 
for (i=0; i  LLTBL_HASHTBL_SIZE; i++) {
LIST_FOREACH_SAFE(lle, llt-lle_head[i], lle_next, next) {
@@ -178,7 +179,7 @@ lltable_drain(int af)
struct llentry  *lle;
register int i;
 
-   IFNET_RLOCK();
+   LLTABLE_RLOCK();
SLIST_FOREACH(llt, lltables, llt_link) {
if (llt-llt_af != af)
continue;
@@ -192,7 +193,7 @@ lltable_drain(int af)
}
}
}
-   IFNET_RUNLOCK();
+   LLTABLE_RUNLOCK();
 }
 
 void
@@ -200,14 +201,14 @@ lltable_prefix_free(int af, struct socka
 {
struct lltable *llt;
 
-   IFNET_RLOCK_NOSLEEP();
+   LLTABLE_RLOCK();
SLIST_FOREACH(llt, lltables, llt_link) {
if (llt-llt_af != af)
continue;
 
llt-llt_prefix_free(llt, prefix, mask);
}
-   IFNET_RUNLOCK_NOSLEEP();
+   LLTABLE_RUNLOCK();
 }
 
 
@@ -230,9 +231,9 @@ lltable_init(struct ifnet *ifp, int af)
for (i = 0; i  LLTBL_HASHTBL_SIZE; i++)
LIST_INIT(llt-lle_head[i]);
 
-   IFNET_WLOCK();
+   LLTABLE_WLOCK();
SLIST_INSERT_HEAD(lltables, llt, llt_link);
-   IFNET_WUNLOCK();
+   LLTABLE_WUNLOCK();
 
return (llt);
 }
@@ -300,13 +301,13 @@ lla_rt_output(struct rt_msghdr *rtm, str
}
 
/* XXX linked list may be too expensive */
-   IFNET_RLOCK_NOSLEEP();
+   LLTABLE_RLOCK();
SLIST_FOREACH(llt, lltables, llt_link) {
if (llt-llt_af == dst-sa_family 
llt-llt_ifp == ifp)
break;
}
-   IFNET_RUNLOCK_NOSLEEP();
+   LLTABLE_RUNLOCK();
KASSERT(llt != NULL, (Yep, ugly hacks are bad\n));
 
if (flags  LLE_CREATE)

Modified: stable/8/sys/net/if_llatbl.h
==
--- stable/8/sys/net/if_llatbl.hFri Aug 28 21:07:43 2009
(r196629)
+++ stable/8/sys/net/if_llatbl.hFri Aug 28 21:10:26 2009
(r196630)
@@ -41,6 +41,13 @@ struct rt_addrinfo;
 struct llentry;
 LIST_HEAD(llentries, llentry);
 
+extern struct rwlock lltable_rwlock;
+#defineLLTABLE_RLOCK() rw_rlock(lltable_rwlock)
+#defineLLTABLE_RUNLOCK()   rw_runlock(lltable_rwlock)
+#defineLLTABLE_WLOCK() 

svn commit: r196631 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net

2009-08-28 Thread Robert Watson
Author: rwatson
Date: Fri Aug 28 21:12:38 2009
New Revision: 196631
URL: http://svn.freebsd.org/changeset/base/196631

Log:
  Merge r196553 from head to stable/8:
  
Break out allocation of new ifindex values from if_alloc() and if_vmove(),
and centralize in a single function ifindex_alloc().  Assert the
IFNET_WLOCK, and add missing IFNET_WLOCK in if_alloc().  This does not
close all known races in this code.
  
Reviewed by:  bz
  
  Approved by:  re (kib)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/net/if.c

Modified: stable/8/sys/net/if.c
==
--- stable/8/sys/net/if.c   Fri Aug 28 21:10:26 2009(r196630)
+++ stable/8/sys/net/if.c   Fri Aug 28 21:12:38 2009(r196631)
@@ -223,6 +223,37 @@ ifnet_byindex_ref(u_short idx)
return (ifp);
 }
 
+/*
+ * Allocate an ifindex array entry; return 0 on success or an error on
+ * failure.
+ */
+static int
+ifindex_alloc(u_short *idxp)
+{
+   u_short idx;
+
+   IFNET_WLOCK_ASSERT();
+
+   /*
+* Try to find an empty slot below if_index.  If we fail, take the
+* next slot.
+*/
+   for (idx = 1; idx = V_if_index; idx++) {
+   if (ifnet_byindex_locked(idx) == NULL)
+   break;
+   }
+
+   /* Catch if_index overflow. */
+   if (idx  1)
+   return (ENOSPC);
+   if (idx  V_if_index)
+   V_if_index = idx;
+   if (V_if_index = V_if_indexlim)
+   if_grow();
+   *idxp = idx;
+   return (0);
+}
+
 static void
 ifnet_setbyindex_locked(u_short idx, struct ifnet *ifp)
 {
@@ -335,32 +366,19 @@ struct ifnet *
 if_alloc(u_char type)
 {
struct ifnet *ifp;
+   u_short idx;
 
ifp = malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO);
-
-   /*
-* Try to find an empty slot below if_index.  If we fail, take
-* the next slot.
-*
-* XXX: should be locked!
-*/
-   for (ifp-if_index = 1; ifp-if_index = V_if_index; ifp-if_index++) {
-   if (ifnet_byindex(ifp-if_index) == NULL)
-   break;
-   }
-   /* Catch if_index overflow. */
-   if (ifp-if_index  1) {
+   IFNET_WLOCK();
+   if (ifindex_alloc(idx) != 0) {
+   IFNET_WUNLOCK();
free(ifp, M_IFNET);
return (NULL);
}
-   if (ifp-if_index  V_if_index)
-   V_if_index = ifp-if_index;
-   if (V_if_index = V_if_indexlim)
-   if_grow();
-
+   IFNET_WUNLOCK();
+   ifp-if_index = idx;
ifp-if_type = type;
ifp-if_alloctype = type;
-
if (if_com_alloc[type] != NULL) {
ifp-if_l2com = if_com_alloc[type](type, ifp);
if (ifp-if_l2com == NULL) {
@@ -882,6 +900,7 @@ if_detach_internal(struct ifnet *ifp, in
 void
 if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
 {
+   u_short idx;
 
/*
 * Detach from current vnet, but preserve LLADDR info, do not
@@ -907,23 +926,12 @@ if_vmove(struct ifnet *ifp, struct vnet 
 */
CURVNET_SET_QUIET(new_vnet);
 
-   /*
-* Try to find an empty slot below if_index.  If we fail, take 
-* the next slot.
-*/
IFNET_WLOCK();
-   for (ifp-if_index = 1; ifp-if_index = V_if_index; ifp-if_index++) {
-   if (ifnet_byindex_locked(ifp-if_index) == NULL)
-   break;
-   }
-   /* Catch if_index overflow. */
-   if (ifp-if_index  1)
+   if (ifindex_alloc(idx) != 0) {
+   IFNET_WUNLOCK();
panic(if_index overflow);
-
-   if (ifp-if_index  V_if_index)
-   V_if_index = ifp-if_index;
-   if (V_if_index = V_if_indexlim)
-   if_grow();
+   }
+   ifp-if_index = idx;
ifnet_setbyindex_locked(ifp-if_index, ifp);
IFNET_WUNLOCK();
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196632 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net

2009-08-28 Thread Robert Watson
Author: rwatson
Date: Fri Aug 28 21:14:04 2009
New Revision: 196632
URL: http://svn.freebsd.org/changeset/base/196632

Log:
  Merge r196559 from head to stable/8:
  
Add IFNET_HOLD reserved pointer value for the ifindex ifnet array,
which allows an index to be reserved for an ifnet without making
the ifnet available for management operations.  Use this in if_alloc()
while the ifnet lock is released between initial index allocation and
completion of ifnet initialization.
  
Add ifindex_free() to centralize the implementation of releasing an
ifindex value.  Use in if_free() and if_vmove(), as well as when
releasing a held index in if_alloc().
  
Reviewed by:  bz
  
  Approved by:  re (kib)

Modified:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/net/if.c

Modified: stable/8/sys/net/if.c
==
--- stable/8/sys/net/if.c   Fri Aug 28 21:12:38 2009(r196631)
+++ stable/8/sys/net/if.c   Fri Aug 28 21:14:04 2009(r196632)
@@ -175,6 +175,13 @@ intifqmaxlen = IFQ_MAXLEN;
 struct rwlock ifnet_rwlock;
 struct sx ifnet_sxlock;
 
+/*
+ * The allocation of network interfaces is a rather non-atomic affair; we
+ * need to select an index before we are ready to expose the interface for
+ * use, so will use this pointer value to indicate reservation.
+ */
+#defineIFNET_HOLD  (void *)(uintptr_t)(-1)
+
 static if_com_alloc_t *if_com_alloc[256];
 static if_com_free_t *if_com_free[256];
 
@@ -193,6 +200,8 @@ ifnet_byindex_locked(u_short idx)
 
if (idx  V_if_index)
return (NULL);
+   if (V_ifindex_table[idx].ife_ifnet == IFNET_HOLD)
+   return (NULL);
return (V_ifindex_table[idx].ife_ifnet);
 }
 
@@ -228,18 +237,18 @@ ifnet_byindex_ref(u_short idx)
  * failure.
  */
 static int
-ifindex_alloc(u_short *idxp)
+ifindex_alloc_locked(u_short *idxp)
 {
u_short idx;
 
IFNET_WLOCK_ASSERT();
 
/*
-* Try to find an empty slot below if_index.  If we fail, take the
+* Try to find an empty slot below V_if_index.  If we fail, take the
 * next slot.
 */
for (idx = 1; idx = V_if_index; idx++) {
-   if (ifnet_byindex_locked(idx) == NULL)
+   if (V_ifindex_table[idx].ife_ifnet == NULL)
break;
}
 
@@ -255,6 +264,27 @@ ifindex_alloc(u_short *idxp)
 }
 
 static void
+ifindex_free_locked(u_short idx)
+{
+
+   IFNET_WLOCK_ASSERT();
+
+   V_ifindex_table[idx].ife_ifnet = NULL;
+   while (V_if_index  0 
+   V_ifindex_table[V_if_index].ife_ifnet == NULL)
+   V_if_index--;
+}
+
+static void
+ifindex_free(u_short idx)
+{
+
+   IFNET_WLOCK();
+   ifindex_free_locked(idx);
+   IFNET_WUNLOCK();
+}
+
+static void
 ifnet_setbyindex_locked(u_short idx, struct ifnet *ifp)
 {
 
@@ -370,11 +400,12 @@ if_alloc(u_char type)
 
ifp = malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO);
IFNET_WLOCK();
-   if (ifindex_alloc(idx) != 0) {
+   if (ifindex_alloc_locked(idx) != 0) {
IFNET_WUNLOCK();
free(ifp, M_IFNET);
return (NULL);
}
+   ifnet_setbyindex_locked(idx, IFNET_HOLD);
IFNET_WUNLOCK();
ifp-if_index = idx;
ifp-if_type = type;
@@ -383,6 +414,7 @@ if_alloc(u_char type)
ifp-if_l2com = if_com_alloc[type](type, ifp);
if (ifp-if_l2com == NULL) {
free(ifp, M_IFNET);
+   ifindex_free(idx);
return (NULL);
}
}
@@ -421,9 +453,7 @@ if_free_internal(struct ifnet *ifp)
KASSERT(ifp == ifnet_byindex_locked(ifp-if_index),
(%s: freeing unallocated ifnet, ifp-if_xname));
 
-   ifnet_setbyindex_locked(ifp-if_index, NULL);
-   while (V_if_index  0  ifnet_byindex_locked(V_if_index) == NULL)
-   V_if_index--;
+   ifindex_free_locked(ifp-if_index);
IFNET_WUNLOCK();
 
if (if_com_free[ifp-if_alloctype] != NULL)
@@ -916,18 +946,14 @@ if_vmove(struct ifnet *ifp, struct vnet 
 * or we'd lock on one vnet and unlock on another.
 */
IFNET_WLOCK();
-   ifnet_setbyindex_locked(ifp-if_index, NULL);
-   while (V_if_index  0  ifnet_byindex_locked(V_if_index) == NULL)
-   V_if_index--;
-   IFNET_WUNLOCK();
+   ifindex_free_locked(ifp-if_index);
 
/*
 * Switch to the context of the target vnet.
 */
CURVNET_SET_QUIET(new_vnet);
 
-   IFNET_WLOCK();
-   if (ifindex_alloc(idx) != 0) {
+   if 

svn commit: r196633 - head/sys/net

2009-08-28 Thread Marko Zec
Author: zec
Date: Fri Aug 28 22:30:55 2009
New Revision: 196633
URL: http://svn.freebsd.org/changeset/base/196633

Log:
  Introduce a separate sx lock for protecting lists of vnet sysinit
  and sysuninit handlers.
  
  Previously, sx_vnet, which is a lock designated for protecting
  the vnet list, was (ab)used for protecting vnet sysinit / sysuninit
  handler lists as well.  Holding exclusively the sx_vnet lock while
  invoking sysinit and / or sysuninit handlers turned out to be
  problematic, since some of the handlers may attempt to wake up
  another thread and wait for it to walk over the vnet list, hence
  acquire a shared lock on sx_vnet, which in turn leads to a deadlock.
  Protecting vnet sysinit / sysuninit lists with a separate lock
  mitigates this issue, which was first observed with
  flowtable_flush() / flowtable_cleaner() in sys/net/flowtable.c.
  
  Reviewed by:  rwatson, jhb
  MFC after:3 days

Modified:
  head/sys/net/vnet.c

Modified: head/sys/net/vnet.c
==
--- head/sys/net/vnet.c Fri Aug 28 21:14:04 2009(r196632)
+++ head/sys/net/vnet.c Fri Aug 28 22:30:55 2009(r196633)
@@ -182,14 +182,21 @@ static VNET_DEFINE(char, modspace[VNET_M
 
 /*
  * Global lists of subsystem constructor and destructors for vnets.  They are
- * registered via VNET_SYSINIT() and VNET_SYSUNINIT().  The lists are
- * protected by the vnet_sxlock global lock.
+ * registered via VNET_SYSINIT() and VNET_SYSUNINIT().  Both lists are
+ * protected by the vnet_sysinit_sxlock global lock.
  */
 static TAILQ_HEAD(vnet_sysinit_head, vnet_sysinit) vnet_constructors =
TAILQ_HEAD_INITIALIZER(vnet_constructors);
 static TAILQ_HEAD(vnet_sysuninit_head, vnet_sysinit) vnet_destructors =
TAILQ_HEAD_INITIALIZER(vnet_destructors);
 
+struct sx  vnet_sysinit_sxlock;
+
+#defineVNET_SYSINIT_WLOCK()sx_xlock(vnet_sysinit_sxlock);
+#defineVNET_SYSINIT_WUNLOCK()  sx_xunlock(vnet_sysinit_sxlock);
+#defineVNET_SYSINIT_RLOCK()sx_slock(vnet_sysinit_sxlock);
+#defineVNET_SYSINIT_RUNLOCK()  sx_sunlock(vnet_sysinit_sxlock);
+
 struct vnet_data_free {
uintptr_t   vnd_start;
int vnd_len;
@@ -228,12 +235,10 @@ vnet_alloc(void)
 
/* Initialize / attach vnet module instances. */
CURVNET_SET_QUIET(vnet);
-
-   sx_xlock(vnet_sxlock);
vnet_sysinit();
CURVNET_RESTORE();
 
-   rw_wlock(vnet_rwlock);
+   VNET_LIST_WLOCK();
LIST_INSERT_HEAD(vnet_head, vnet, vnet_le);
VNET_LIST_WUNLOCK();
 
@@ -253,7 +258,7 @@ vnet_destroy(struct vnet *vnet)
 
VNET_LIST_WLOCK();
LIST_REMOVE(vnet, vnet_le);
-   rw_wunlock(vnet_rwlock);
+   VNET_LIST_WUNLOCK();
 
CURVNET_SET_QUIET(vnet);
 
@@ -264,8 +269,6 @@ vnet_destroy(struct vnet *vnet)
}
 
vnet_sysuninit();
-   sx_xunlock(vnet_sxlock);
-
CURVNET_RESTORE();
 
/*
@@ -287,6 +290,7 @@ vnet_init_prelink(void *arg)
 
rw_init(vnet_rwlock, vnet_rwlock);
sx_init(vnet_sxlock, vnet_sxlock);
+   sx_init(vnet_sysinit_sxlock, vnet_sysinit_sxlock);
LIST_INIT(vnet_head);
 }
 SYSINIT(vnet_init_prelink, SI_SUB_VNET_PRELINK, SI_ORDER_FIRST,
@@ -494,7 +498,7 @@ vnet_register_sysinit(void *arg)
KASSERT(vs-subsystem  SI_SUB_VNET, (vnet sysinit too early));
 
/* Add the constructor to the global list of vnet constructors. */
-   sx_xlock(vnet_sxlock);
+   VNET_SYSINIT_WLOCK();
TAILQ_FOREACH(vs2, vnet_constructors, link) {
if (vs2-subsystem  vs-subsystem)
break;
@@ -515,7 +519,7 @@ vnet_register_sysinit(void *arg)
vs-func(vs-arg);
CURVNET_RESTORE();
}
-   sx_xunlock(vnet_sxlock);
+   VNET_SYSINIT_WUNLOCK();
 }
 
 void
@@ -526,9 +530,9 @@ vnet_deregister_sysinit(void *arg)
vs = arg;
 
/* Remove the constructor from the global list of vnet constructors. */
-   sx_xlock(vnet_sxlock);
+   VNET_SYSINIT_WLOCK();
TAILQ_REMOVE(vnet_constructors, vs, link);
-   sx_xunlock(vnet_sxlock);
+   VNET_SYSINIT_WUNLOCK();
 }
 
 void
@@ -539,7 +543,7 @@ vnet_register_sysuninit(void *arg)
vs = arg;
 
/* Add the destructor to the global list of vnet destructors. */
-   sx_xlock(vnet_sxlock);
+   VNET_SYSINIT_WLOCK();
TAILQ_FOREACH(vs2, vnet_destructors, link) {
if (vs2-subsystem  vs-subsystem)
break;
@@ -550,7 +554,7 @@ vnet_register_sysuninit(void *arg)
TAILQ_INSERT_BEFORE(vs2, vs, link);
else
TAILQ_INSERT_TAIL(vnet_destructors, vs, link);
-   sx_xunlock(vnet_sxlock);
+   VNET_SYSINIT_WUNLOCK();
 }
 
 void
@@ -565,7 +569,7 @@ vnet_deregister_sysuninit(void *arg)
 * Invoke the destructor on all the existing vnets when it is
 * 

svn commit: r196634 - in head: bin/sh tools/regression/bin/sh/execution

2009-08-28 Thread Jilles Tjoelker
Author: jilles
Date: Fri Aug 28 22:41:25 2009
New Revision: 196634
URL: http://svn.freebsd.org/changeset/base/196634

Log:
  sh: Fix crash with empty functions (f() { }) introduced in r196483
  
  Empty pairs of braces are represented by a NULL node pointer, just like
  empty lines at the top level.
  
  Support for empty pairs of braces may be removed later. They make the code
  more complex, have inconsistent behaviour (may or may not change $?), are
  not specified by POSIX and are not allowed by some other shells like bash,
  dash and ksh93.
  
  Reported by:  kan

Added:
  head/tools/regression/bin/sh/execution/func2.0   (contents, props changed)
Modified:
  head/bin/sh/eval.c
  head/bin/sh/exec.c
  head/bin/sh/mknodes.c
  head/bin/sh/nodes.c.pat

Modified: head/bin/sh/eval.c
==
--- head/bin/sh/eval.c  Fri Aug 28 22:30:55 2009(r196633)
+++ head/bin/sh/eval.c  Fri Aug 28 22:41:25 2009(r196634)
@@ -807,9 +807,9 @@ evalcommand(union node *cmd, int flags, 
funcnest++;
exitstatus = oexitstatus;
if (flags  EV_TESTED)
-   evaltree(cmdentry.u.func-n, EV_TESTED);
+   evaltree(getfuncnode(cmdentry.u.func), EV_TESTED);
else
-   evaltree(cmdentry.u.func-n, 0);
+   evaltree(getfuncnode(cmdentry.u.func), 0);
funcnest--;
INTOFF;
unreffunc(cmdentry.u.func);

Modified: head/bin/sh/exec.c
==
--- head/bin/sh/exec.c  Fri Aug 28 22:30:55 2009(r196633)
+++ head/bin/sh/exec.c  Fri Aug 28 22:41:25 2009(r196634)
@@ -286,7 +286,7 @@ printentry(struct tblentry *cmdp, int ve
out1fmt(function %s, cmdp-cmdname);
if (verbose) {
INTOFF;
-   name = commandtext(cmdp-param.func-n);
+   name = commandtext(getfuncnode(cmdp-param.func));
out1c(' ');
out1str(name);
ckfree(name);

Modified: head/bin/sh/mknodes.c
==
--- head/bin/sh/mknodes.c   Fri Aug 28 22:30:55 2009(r196633)
+++ head/bin/sh/mknodes.c   Fri Aug 28 22:41:25 2009(r196634)
@@ -248,11 +248,9 @@ output(char *file)
fputs(\tstruct nodelist *next;\n, hfile);
fputs(\tunion node *n;\n, hfile);
fputs(};\n\n\n, hfile);
-   fputs(struct funcdef {\n, hfile);
-   fputs(\tunsigned int refcount;\n, hfile);
-   fputs(\tunion node n;\n, hfile);
-   fputs(};\n\n\n, hfile);
+   fputs(struct funcdef;\n, hfile);
fputs(struct funcdef *copyfunc(union node *);\n, hfile);
+   fputs(union node *getfuncnode(struct funcdef *);\n, hfile);
fputs(void reffunc(struct funcdef *);\n, hfile);
fputs(void unreffunc(struct funcdef *);\n, hfile);
 

Modified: head/bin/sh/nodes.c.pat
==
--- head/bin/sh/nodes.c.pat Fri Aug 28 22:30:55 2009(r196633)
+++ head/bin/sh/nodes.c.pat Fri Aug 28 22:41:25 2009(r196634)
@@ -61,6 +61,10 @@ STATIC struct nodelist *copynodelist(str
 STATIC char *nodesavestr(char *);
 
 
+struct funcdef {
+   unsigned int refcount;
+   union node n;
+};
 
 /*
  * Make a copy of a parse tree.
@@ -85,6 +89,12 @@ copyfunc(union node *n)
 }
 
 
+union node *
+getfuncnode(struct funcdef *fn)
+{
+   return fn == NULL ? NULL : fn-n;
+}
+
 
 STATIC void
 calcsize(union node *n)
@@ -153,7 +163,8 @@ nodesavestr(char *s)
 void
 reffunc(struct funcdef *fn)
 {
-   fn-refcount++;
+   if (fn)
+   fn-refcount++;
 }
 
 

Added: head/tools/regression/bin/sh/execution/func2.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/execution/func2.0  Fri Aug 28 22:41:25 
2009(r196634)
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+f() { }
+f
+hash -v f /dev/null
+f() { { }; }
+f
+hash -v f /dev/null
+f() { { } }
+f
+hash -v f /dev/null
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196635 - in head/sys/compat: linprocfs linux

2009-08-28 Thread Marko Zec
Author: zec
Date: Fri Aug 28 22:51:07 2009
New Revision: 196635
URL: http://svn.freebsd.org/changeset/base/196635

Log:
  Fix a few panics in linuxulator + VIMAGE due to curvnet not being set.
  
  This change affects only options VIMAGE builds.
  
  Reviewed by:  julian
  MFC after:3 days

Modified:
  head/sys/compat/linprocfs/linprocfs.c
  head/sys/compat/linux/linux_ioctl.c

Modified: head/sys/compat/linprocfs/linprocfs.c
==
--- head/sys/compat/linprocfs/linprocfs.c   Fri Aug 28 22:41:25 2009
(r196634)
+++ head/sys/compat/linprocfs/linprocfs.c   Fri Aug 28 22:51:07 2009
(r196635)
@@ -1085,6 +1085,7 @@ linprocfs_donetdev(PFS_FILL_ARGS)
bytespackets errs drop fifo frame compressed,
bytespackets errs drop fifo frame compressed);
 
+   CURVNET_SET(TD_TO_VNET(curthread));
IFNET_RLOCK();
TAILQ_FOREACH(ifp, V_ifnet, if_link) {
linux_ifname(ifp, ifname, sizeof ifname);
@@ -1095,6 +1096,7 @@ linprocfs_donetdev(PFS_FILL_ARGS)
0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL);
}
IFNET_RUNLOCK();
+   CURVNET_RESTORE();
 
return (0);
 }

Modified: head/sys/compat/linux/linux_ioctl.c
==
--- head/sys/compat/linux/linux_ioctl.c Fri Aug 28 22:41:25 2009
(r196634)
+++ head/sys/compat/linux/linux_ioctl.c Fri Aug 28 22:51:07 2009
(r196635)
@@ -2104,6 +2104,7 @@ ifname_linux_to_bsd(struct thread *td, c
return (NULL);
index = 0;
is_eth = (len == 3  !strncmp(lxname, eth, len)) ? 1 : 0;
+   CURVNET_SET(TD_TO_VNET(td));
IFNET_RLOCK();
TAILQ_FOREACH(ifp, V_ifnet, if_link) {
/*
@@ -2117,6 +2118,7 @@ ifname_linux_to_bsd(struct thread *td, c
break;
}
IFNET_RUNLOCK();
+   CURVNET_RESTORE();
if (ifp != NULL)
strlcpy(bsdname, ifp-if_xname, IFNAMSIZ);
return (ifp);
@@ -2146,6 +2148,7 @@ linux_ifconf(struct thread *td, struct i
 
max_len = MAXPHYS - 1;
 
+   CURVNET_SET(TD_TO_VNET(td));
/* handle the 'request buffer size' case */
if (ifc.ifc_buf == PTROUT(NULL)) {
ifc.ifc_len = 0;
@@ -2157,11 +2160,14 @@ linux_ifconf(struct thread *td, struct i
}
}
error = copyout(ifc, uifc, sizeof(ifc));
+   CURVNET_RESTORE();
return (error);
}
 
-   if (ifc.ifc_len = 0)
+   if (ifc.ifc_len = 0) {
+   CURVNET_RESTORE();
return (EINVAL);
+   }
 
 again:
/* Keep track of eth interfaces */
@@ -2223,6 +2229,7 @@ again:
memcpy(PTRIN(ifc.ifc_buf), sbuf_data(sb), ifc.ifc_len);
error = copyout(ifc, uifc, sizeof(ifc));
sbuf_delete(sb);
+   CURVNET_RESTORE();
 
return (error);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196636 - in head/sys: conf modules

2009-08-28 Thread Warner Losh
Author: imp
Date: Sat Aug 29 01:34:42 2009
New Revision: 196636
URL: http://svn.freebsd.org/changeset/base/196636

Log:
  Connect bwi up to the build.  While there are some problems with this
  driver still, it generally works well for most people most of the
  time.  It is still too green for GENERIC, however.
  
  Submitted by: many (latest being kwm@)
  MFC after:2 days (before RC1 if possible)

Modified:
  head/sys/conf/NOTES
  head/sys/modules/Makefile

Modified: head/sys/conf/NOTES
==
--- head/sys/conf/NOTES Fri Aug 28 22:51:07 2009(r196635)
+++ head/sys/conf/NOTES Sat Aug 29 01:34:42 2009(r196636)
@@ -1790,6 +1790,7 @@ devicemiibus
 #  BCM570x family of controllers, including the 3Com 3c996-T,
 #  the Netgear GA302T, the SysKonnect SK-9D21 and SK-9D41, and
 #  the embedded gigE NICs on Dell PowerEdge 2550 servers.
+# bwi: Broadcom BCM430* and BCM431* family of wireless adapters.
 # cas: Sun Cassini/Cassini+ and National Semiconductor DP83065 Saturn
 # cm:  Arcnet SMC COM90c26 / SMC COM90c56
 #  (and SMC COM90c66 in '56 compatibility mode) adapters.
@@ -1959,6 +1960,7 @@ devicewb  # Winbond W89C840F
 device xl  # 3Com 3c90x (``Boomerang'', ``Cyclone'')
 
 # PCI Ethernet NICs.
+device bwi # Broadcom BCM430* BCM431*
 device de  # DEC/Intel DC21x4x (``Tulip'')
 device em  # Intel Pro/1000 Gigabit Ethernet
 device igb # Intel Pro/1000 PCIE Gigabit Ethernet

Modified: head/sys/modules/Makefile
==
--- head/sys/modules/Makefile   Fri Aug 28 22:51:07 2009(r196635)
+++ head/sys/modules/Makefile   Sat Aug 29 01:34:42 2009(r196636)
@@ -40,6 +40,7 @@ SUBDIR=   ${_3dfx} \
${_bktr} \
${_bm} \
bridgestp \
+   bwi \
cam \
${_canbepm} \
${_canbus} \
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196637 - head/sys/vm

2009-08-28 Thread John Baldwin
Author: jhb
Date: Sat Aug 29 02:17:40 2009
New Revision: 196637
URL: http://svn.freebsd.org/changeset/base/196637

Log:
  Mark the fake pages constructed by the OBJT_SG pager valid.  This was
  accidentally lost at one point during the PAT development.  Without this
  fix vm_pager_get_pages() was zeroing each of the pages.
  
  Submitted by: czander @ NVidia
  MFC after:3 days

Modified:
  head/sys/vm/sg_pager.c

Modified: head/sys/vm/sg_pager.c
==
--- head/sys/vm/sg_pager.c  Sat Aug 29 01:34:42 2009(r196636)
+++ head/sys/vm/sg_pager.c  Sat Aug 29 02:17:40 2009(r196637)
@@ -204,6 +204,7 @@ sg_pager_getpages(vm_object_t object, vm
vm_page_unlock_queues();
vm_page_insert(page, object, offset);
m[reqpage] = page;
+   page-valid = VM_PAGE_BITS_ALL;
 
return (VM_PAGER_OK);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196638 - head/lib/libc/posix1e

2009-08-28 Thread Tim Kientzle
Author: kientzle
Date: Sat Aug 29 03:17:24 2009
New Revision: 196638
URL: http://svn.freebsd.org/changeset/base/196638

Log:
  Style: Remove trailing whitespace.

Modified:
  head/lib/libc/posix1e/acl_support.c

Modified: head/lib/libc/posix1e/acl_support.c
==
--- head/lib/libc/posix1e/acl_support.c Sat Aug 29 02:17:40 2009
(r196637)
+++ head/lib/libc/posix1e/acl_support.c Sat Aug 29 03:17:24 2009
(r196638)
@@ -80,7 +80,7 @@ _acl_differs(const acl_t a, const acl_t 
 
return (0);
 }
-   
+
 /*
  * _posix1e_acl_entry_compare -- compare two acl_entry structures to
  * determine the order they should appear in.  Used by _posix1e_acl_sort to
@@ -164,7 +164,7 @@ _posix1e_acl(acl_t acl, acl_type_t type)
  * from code in sys/kern/kern_acl.c, and if changes are made in one, they
  * should be made in the other also.  This copy of acl_check is made
  * available * in userland for the benefit of processes wanting to check ACLs
- * for validity before submitting them to the kernel, or for performing 
+ * for validity before submitting them to the kernel, or for performing
  * in userland file system checking.  Needless to say, the kernel makes
  * the real checks on calls to get/setacl.
  *
@@ -203,7 +203,7 @@ _posix1e_acl_check(acl_t acl)
stage = ACL_USER;
count_user_obj++;
break;
-   
+
case ACL_USER:
/* printf(_posix1e_acl_check: %d: ACL_USER\n, i); */
if (stage  ACL_USER)
@@ -213,8 +213,8 @@ _posix1e_acl_check(acl_t acl)
return (EINVAL);
highest_uid = entry-ae_id;
count_user++;
-   break;  
-   
+   break;
+
case ACL_GROUP_OBJ:
/* printf(_posix1e_acl_check: %d: ACL_GROUP_OBJ\n,
i); */
@@ -223,7 +223,7 @@ _posix1e_acl_check(acl_t acl)
stage = ACL_GROUP;
count_group_obj++;
break;
-   
+
case ACL_GROUP:
/* printf(_posix1e_acl_check: %d: ACL_GROUP\n, i); */
if (stage  ACL_GROUP)
@@ -234,7 +234,7 @@ _posix1e_acl_check(acl_t acl)
highest_gid = entry-ae_id;
count_group++;
break;
-   
+
case ACL_MASK:
/* printf(_posix1e_acl_check: %d: ACL_MASK\n, i); */
if (stage  ACL_MASK)
@@ -242,7 +242,7 @@ _posix1e_acl_check(acl_t acl)
stage = ACL_MASK;
count_mask++;
break;
-   
+
case ACL_OTHER:
/* printf(_posix1e_acl_check: %d: ACL_OTHER\n, i); */
if (stage  ACL_OTHER)
@@ -250,7 +250,7 @@ _posix1e_acl_check(acl_t acl)
stage = ACL_OTHER;
count_other++;
break;
-   
+
default:
/* printf(_posix1e_acl_check: %d: INVALID\n, i); */
return (EINVAL);
@@ -260,7 +260,7 @@ _posix1e_acl_check(acl_t acl)
 
if (count_user_obj != 1)
return (EINVAL);
-   
+
if (count_group_obj != 1)
return (EINVAL);
 
@@ -312,7 +312,7 @@ _posix1e_acl_id_to_name(acl_tag_t tag, u
g = NULL;
else
g = getgrgid(id);
-   if (g == NULL) 
+   if (g == NULL)
i = snprintf(buf, buf_len, %d, id);
else
i = snprintf(buf, buf_len, %s, g-gr_name);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r196639 - stable/8/usr.sbin/ppp

2009-08-28 Thread Brian Somers
Author: brian
Date: Sat Aug 29 04:15:37 2009
New Revision: 196639
URL: http://svn.freebsd.org/changeset/base/196639

Log:
  MFC r196530: Document that ppp handles pipe(2) descriptors specially in
   -direct mode.
  
  Approved by:  re (kib)

Modified:
  stable/8/usr.sbin/ppp/   (props changed)
  stable/8/usr.sbin/ppp/ppp.8.m4

Modified: stable/8/usr.sbin/ppp/ppp.8.m4
==
--- stable/8/usr.sbin/ppp/ppp.8.m4  Sat Aug 29 03:17:24 2009
(r196638)
+++ stable/8/usr.sbin/ppp/ppp.8.m4  Sat Aug 29 04:15:37 2009
(r196639)
@@ -27,7 +27,7 @@ changecom(,)dnl
 .\
 .\ $FreeBSD$
 .\
-.Dd May 24, 2007
+.Dd August 25, 2009
 .Dt PPP 8
 .Os
 .Sh NAME
@@ -171,6 +171,17 @@ If callback is configured,
 will use the
 .Dq set device
 information when dialing back.
+.Pp
+When run in
+.Fl direct
+mode,
+.Nm
+will behave slightly differently if descriptor 0 was created by
+.Xr pipe 2 .
+As pipes are not bi-directional, ppp will redirect all writes to descriptor
+1 (standard output), leaving only reads acting on descriptor 0.
+No special action is taken if descriptor 0 was created by
+.Xr socketpair 2 .
 .It Fl dedicated
 This option is designed for machines connected with a dedicated
 wire.
@@ -6055,6 +6066,8 @@ This socket is used to pass links betwee
 .Xr tcpdump 1 ,
 .Xr telnet 1 ,
 .Xr kldload 2 ,
+.Xr pipe 2 ,
+.Xr socketpair 2 ,
 ifdef({LOCALNAT},{},{.Xr libalias 3 ,
 })dnl
 ifdef({LOCALRAD},{},{.Xr libradius 3 ,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org