svn commit: r223818 - head/usr.sbin/pwd_mkdb

2011-07-06 Thread Gordon Tetlow
Author: gordon
Date: Wed Jul  6 06:34:08 2011
New Revision: 223818
URL: http://svn.freebsd.org/changeset/base/223818

Log:
  Only increment the ypcnt once per data record. The old implementation
  was incrementing it twice making it impossible to iterate the table
  since the records were 1, 3, 5, 7 (or 2, 4, 6, 8 for the v3 records).
  
  MFC after:10 days

Modified:
  head/usr.sbin/pwd_mkdb/pwd_mkdb.c

Modified: head/usr.sbin/pwd_mkdb/pwd_mkdb.c
==
--- head/usr.sbin/pwd_mkdb/pwd_mkdb.c   Wed Jul  6 05:42:52 2011
(r223817)
+++ head/usr.sbin/pwd_mkdb/pwd_mkdb.c   Wed Jul  6 06:34:08 2011
(r223818)
@@ -351,14 +351,16 @@ main(int argc, char *argv[])
if ((dp-put)(sdp, key, data, 0) == -1)
error(put);
}
-   ypcnt = 1;
+   ypcnt = 0;
data.data = (u_char *)buf;
sdata.data = (u_char *)sbuf;
key.data = (u_char *)tbuf;
for (cnt = 1; scan(fp, pwd); ++cnt) {
if (!is_comment  
-   (pwd.pw_name[0] == '+' || pwd.pw_name[0] == '-'))
+   (pwd.pw_name[0] == '+' || pwd.pw_name[0] == '-')) {
yp_enabled = 1;
+   ypcnt++;
+   }
if (is_comment)
--cnt;
 #defineCOMPACT(e)  t = e; while ((*p++ = *t++));
@@ -456,7 +458,6 @@ main(int argc, char *argv[])
tbuf[0] = CURRENT_VERSION(_PW_KEYYPBYNUM);
store = htonl(ypcnt);
memmove(tbuf + 1, store, sizeof(store));
-   ypcnt++;
key.size = sizeof(store) + 1;
if ((dp-put)(dp, key, data, method) == -1)
error(put);
@@ -547,7 +548,6 @@ main(int argc, char *argv[])
tbuf[0] = LEGACY_VERSION(_PW_KEYYPBYNUM);
store = HTOL(ypcnt);
memmove(tbuf + 1, store, sizeof(store));
-   ypcnt++;
key.size = sizeof(store) + 1;
if ((dp-put)(dp, key, data, method) == -1)
error(put);
___
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: r223822 - head/sys/netgraph/netflow

2011-07-06 Thread Gleb Smirnoff
Author: glebius
Date: Wed Jul  6 09:43:25 2011
New Revision: 223822
URL: http://svn.freebsd.org/changeset/base/223822

Log:
  Add missing unlocks.

Modified:
  head/sys/netgraph/netflow/netflow.c

Modified: head/sys/netgraph/netflow/netflow.c
==
--- head/sys/netgraph/netflow/netflow.c Wed Jul  6 07:13:28 2011
(r223821)
+++ head/sys/netgraph/netflow/netflow.c Wed Jul  6 09:43:25 2011
(r223822)
@@ -970,6 +970,7 @@ struct ngnf_show_header *resp)
if (hsh-mtx.mtx_lock  MTX_CONTESTED) {
resp-hash_id = i;
resp-list_id = list_id;
+   mtx_unlock(hsh-mtx);
return (0);
}
 
@@ -1001,6 +1002,7 @@ struct ngnf_show_header *resp)
 * we simply skip to next hash_id.
 */
resp-list_id = list_id + 1;
+   mtx_unlock(hsh-mtx);
return (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: r223823 - head/sys/vm

2011-07-06 Thread Attilio Rao
Author: attilio
Date: Wed Jul  6 15:09:52 2011
New Revision: 223823
URL: http://svn.freebsd.org/changeset/base/223823

Log:
  Handle a race between device_pager and devsw in a more graceful manner:
  return an error code rather than panic the kernel.
  
  Sponsored by: Sandvine Incorporated
  Reviewed by:  kib
  Tested by:pho
  MFC after:2 weeks

Modified:
  head/sys/vm/device_pager.c

Modified: head/sys/vm/device_pager.c
==
--- head/sys/vm/device_pager.c  Wed Jul  6 09:43:25 2011(r223822)
+++ head/sys/vm/device_pager.c  Wed Jul  6 15:09:52 2011(r223823)
@@ -217,8 +217,10 @@ dev_pager_getpages(object, m, count, req
memattr = object-memattr;
VM_OBJECT_UNLOCK(object);
csw = dev_refthread(dev, ref);
-   if (csw == NULL)
-   panic(dev_pager_getpage: no cdevsw);
+   if (csw == NULL) {
+   VM_OBJECT_LOCK(object);
+   return (VM_PAGER_FAIL);
+   }
td = curthread;
fpop = td-td_fpop;
td-td_fpop = NULL;
___
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: r223824 - head/usr.sbin/flowctl

2011-07-06 Thread Sergey Kandaurov
Author: pluknet
Date: Wed Jul  6 15:18:32 2011
New Revision: 223824
URL: http://svn.freebsd.org/changeset/base/223824

Log:
  Conditionally compile in the IPv4/IPv6 address family support.
  Test it with feature_present(3), so that we do not end up with passing
  an unsupported version to NgSendMsg(3).
  
  Approved by:  glebius

Modified:
  head/usr.sbin/flowctl/Makefile
  head/usr.sbin/flowctl/flowctl.c

Modified: head/usr.sbin/flowctl/Makefile
==
--- head/usr.sbin/flowctl/Makefile  Wed Jul  6 15:09:52 2011
(r223823)
+++ head/usr.sbin/flowctl/Makefile  Wed Jul  6 15:18:32 2011
(r223824)
@@ -14,7 +14,8 @@ LDADD=  -lnetgraph
 .if ${MK_INET6_SUPPORT} != no
 CFLAGS+= -DINET6
 .endif
-
-CFLAGS+= -I.
+.if ${MK_INET_SUPPORT} != no
+CFLAGS+= -DINET
+.endif
 
 .include bsd.prog.mk

Modified: head/usr.sbin/flowctl/flowctl.c
==
--- head/usr.sbin/flowctl/flowctl.c Wed Jul  6 15:09:52 2011
(r223823)
+++ head/usr.sbin/flowctl/flowctl.c Wed Jul  6 15:18:32 2011
(r223824)
@@ -69,12 +69,18 @@ static const char rcs_id[] =
 
 #defineCISCO_SH_VERB_FLOW6 %-14s %-30s %-14s %-30s %2u %3x %4x 
%6lu\n \
%4.4x /%-2u %-5u %4.4x /%-2u %-5u %-30s %9u %8u\n\n
+#ifdef INET
 static void flow_cache_print(struct ngnf_show_header *resp);
-static void flow_cache_print6(struct ngnf_show_header *resp);
 static void flow_cache_print_verbose(struct ngnf_show_header *resp);
+#endif
+#ifdef INET6 
+static void flow_cache_print6(struct ngnf_show_header *resp);
 static void flow_cache_print6_verbose(struct ngnf_show_header *resp);
+#endif
 static void ctl_show(int, char **);
+#if defined(INET) || defined(INET6)
 static void do_show(int, void (*func)(struct ngnf_show_header *));
+#endif
 static void help(void);
 static void execute_command(int, char **);
 
@@ -157,7 +163,10 @@ execute_command(int argc, char **argv)
 static void
 ctl_show(int argc, char **argv)
 {
-   int ipv4 = 1, ipv6 = 1, verbose = 0;
+   int ipv4, ipv6, verbose = 0;
+
+   ipv4 = feature_present(inet);
+   ipv6 = feature_present(inet6);
 
if (argc  0  !strncmp(argv[0], ipv4, 4)) {
ipv6 = 0;
@@ -173,21 +182,26 @@ ctl_show(int argc, char **argv)
if (argc  0  !strncmp(argv[0], verbose, strlen(argv[0])))
verbose = 1;
 
+#ifdef INET
if (ipv4) {
if (verbose)
do_show(4, flow_cache_print_verbose);
else
do_show(4, flow_cache_print);
}
+#endif
 
+#ifdef INET6
if (ipv6) {
if (verbose)
do_show(6, flow_cache_print6_verbose);
else
do_show(6, flow_cache_print6);
}
+#endif
 }
 
+#if defined(INET) || defined(INET6)
 static void
 do_show(int version, void (*func)(struct ngnf_show_header *))
 {
@@ -230,7 +244,9 @@ do_show(int version, void (*func)(struct
req.list_id = resp-list_id;
}
 }
+#endif
 
+#ifdef INET
 static void
 flow_cache_print(struct ngnf_show_header *resp)
 {
@@ -261,6 +277,7 @@ flow_cache_print(struct ngnf_show_header

}
 }
+#endif
 
 #ifdef INET6
 static void
@@ -295,6 +312,7 @@ flow_cache_print6(struct ngnf_show_heade
 }
 #endif
 
+#ifdef INET
 static void
 flow_cache_print_verbose(struct ngnf_show_header *resp)
 {
@@ -335,6 +353,7 @@ flow_cache_print_verbose(struct ngnf_sho

}
 }
+#endif
 
 #ifdef INET6
 static void
___
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: r223825 - in head/sys: kern vm

2011-07-06 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Jul  6 20:06:44 2011
New Revision: 223825
URL: http://svn.freebsd.org/changeset/base/223825

Log:
  All the racct_*() calls need to happen with the proc locked.  Fixing this
  won't happen before 9.0.  This commit adds #ifdef RACCT around all the
  PROC_LOCK(p); racct_whatever(p, ...); PROC_UNLOCK(p) instances, in order
  to avoid useless locking/unlocking in kernels built without options RACCT.

Modified:
  head/sys/kern/imgact_elf.c
  head/sys/kern/kern_descrip.c
  head/sys/kern/kern_exit.c
  head/sys/kern/kern_fork.c
  head/sys/kern/kern_thr.c
  head/sys/kern/sysv_msg.c
  head/sys/kern/sysv_sem.c
  head/sys/kern/sysv_shm.c
  head/sys/vm/swap_pager.c
  head/sys/vm/vm_glue.c
  head/sys/vm/vm_map.c
  head/sys/vm/vm_mmap.c
  head/sys/vm/vm_pageout.c
  head/sys/vm/vm_unix.c

Modified: head/sys/kern/imgact_elf.c
==
--- head/sys/kern/imgact_elf.c  Wed Jul  6 15:18:32 2011(r223824)
+++ head/sys/kern/imgact_elf.c  Wed Jul  6 20:06:44 2011(r223825)
@@ -1115,6 +1115,7 @@ __elfN(coredump)(struct thread *td, stru
hdrsize = 0;
__elfN(puthdr)(td, (void *)NULL, hdrsize, seginfo.count);
 
+#ifdef RACCT
PROC_LOCK(td-td_proc);
error = racct_add(td-td_proc, RACCT_CORE, hdrsize + seginfo.size);
PROC_UNLOCK(td-td_proc);
@@ -1122,6 +1123,7 @@ __elfN(coredump)(struct thread *td, stru
error = EFAULT;
goto done;
}
+#endif
if (hdrsize + seginfo.size = limit) {
error = EFAULT;
goto done;

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cWed Jul  6 15:18:32 2011
(r223824)
+++ head/sys/kern/kern_descrip.cWed Jul  6 20:06:44 2011
(r223825)
@@ -821,6 +821,7 @@ do_dup(struct thread *td, int flags, int
 * descriptors, just put the limit on the size of the 
file
 * descriptor table.
 */
+#ifdef RACCT
PROC_LOCK(p);
error = racct_set(p, RACCT_NOFILE, new + 1);
PROC_UNLOCK(p);
@@ -829,6 +830,7 @@ do_dup(struct thread *td, int flags, int
fdrop(fp, td);
return (EMFILE);
}
+#endif
fdgrowtable(fdp, new + 1);
}
if (fdp-fd_ofiles[new] == NULL)
@@ -1476,7 +1478,10 @@ fdalloc(struct thread *td, int minfd, in
 {
struct proc *p = td-td_proc;
struct filedesc *fdp = p-p_fd;
-   int fd = -1, maxfd, error;
+   int fd = -1, maxfd;
+#ifdef RACCT
+   int error;
+#endif
 
FILEDESC_XLOCK_ASSERT(fdp);
 
@@ -1499,11 +1504,13 @@ fdalloc(struct thread *td, int minfd, in
return (EMFILE);
if (fd  fdp-fd_nfiles)
break;
+#ifdef RACCT
PROC_LOCK(p);
error = racct_set(p, RACCT_NOFILE, min(fdp-fd_nfiles * 2, 
maxfd));
PROC_UNLOCK(p);
if (error != 0)
return (EMFILE);
+#endif
fdgrowtable(fdp, min(fdp-fd_nfiles * 2, maxfd));
}
 
@@ -1819,9 +1826,11 @@ fdfree(struct thread *td)
if (fdp == NULL)
return;
 
+#ifdef RACCT
PROC_LOCK(td-td_proc);
racct_set(td-td_proc, RACCT_NOFILE, 0);
PROC_UNLOCK(td-td_proc);
+#endif
 
/* Check for special need to clear POSIX style locks */
fdtol = td-td_proc-p_fdtol;

Modified: head/sys/kern/kern_exit.c
==
--- head/sys/kern/kern_exit.c   Wed Jul  6 15:18:32 2011(r223824)
+++ head/sys/kern/kern_exit.c   Wed Jul  6 20:06:44 2011(r223825)
@@ -744,9 +744,11 @@ proc_reap(struct thread *td, struct proc
 * Destroy resource accounting information associated with the process.
 */
racct_proc_exit(p);
+#ifdef RACCT
PROC_LOCK(p-p_pptr);
racct_sub(p-p_pptr, RACCT_NPROC, 1);
PROC_UNLOCK(p-p_pptr);
+#endif
 
/*
 * Free credentials, arguments, and sigacts.
@@ -905,19 +907,23 @@ loop:
 void
 proc_reparent(struct proc *child, struct proc *parent)
 {
+#ifdef RACCT
int locked;
+#endif
 
sx_assert(proctree_lock, SX_XLOCKED);
PROC_LOCK_ASSERT(child, MA_OWNED);
if (child-p_pptr == parent)
return;
 
+#ifdef RACCT
locked = PROC_LOCKED(parent);
if (!locked)
PROC_LOCK(parent);
racct_add_force(parent, RACCT_NPROC, 1);
if (!locked)
PROC_UNLOCK(parent);
+#endif
PROC_LOCK(child-p_pptr);
racct_sub(child-p_pptr, RACCT_NPROC, 1);
sigqueue_take(child-p_ksi);

Modified: 

svn commit: r223831 - head/sys/dev/e1000

2011-07-06 Thread Jack F Vogel
Author: jfv
Date: Thu Jul  7 00:46:50 2011
New Revision: 223831
URL: http://svn.freebsd.org/changeset/base/223831

Log:
  A fix to make the LINT-NOINET build happy, if this
  works out the ixgbe driver should be changed as well.

Modified:
  head/sys/dev/e1000/if_igb.c

Modified: head/sys/dev/e1000/if_igb.c
==
--- head/sys/dev/e1000/if_igb.c Thu Jul  7 00:30:34 2011(r223830)
+++ head/sys/dev/e1000/if_igb.c Thu Jul  7 00:46:50 2011(r223831)
@@ -1041,8 +1041,8 @@ igb_ioctl(struct ifnet *ifp, u_long comm
struct ifreq*ifr = (struct ifreq *)data;
 #if defined(INET) || defined(INET6)
struct ifaddr   *ifa = (struct ifaddr *)data;
-   boolavoid_reset = FALSE;
 #endif
+   boolavoid_reset = FALSE;
int error = 0;
 
if (adapter-in_detach)
@@ -1058,7 +1058,6 @@ igb_ioctl(struct ifnet *ifp, u_long comm
if (ifa-ifa_addr-sa_family == AF_INET6)
avoid_reset = TRUE;
 #endif
-#if defined(INET) || defined(INET6)
/*
** Calling init results in link renegotiation,
** so we avoid doing it when possible.
@@ -1067,10 +1066,11 @@ igb_ioctl(struct ifnet *ifp, u_long comm
ifp-if_flags |= IFF_UP;
if (!(ifp-if_drv_flags  IFF_DRV_RUNNING))
igb_init(adapter);
+#ifdef INET
if (!(ifp-if_flags  IFF_NOARP))
arp_ifinit(ifp, ifa);
-   } else
 #endif
+   } else
error = ether_ioctl(ifp, command, data);
break;
case SIOCSIFMTU:
___
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: r223832 - head/usr.sbin/bsdinstall/partedit

2011-07-06 Thread Kevin Lo
Author: kevlo
Date: Thu Jul  7 01:22:50 2011
New Revision: 223832
URL: http://svn.freebsd.org/changeset/base/223832

Log:
  Add an extra tab between fs_file and fs_vfstype
  
  Reviewed by:  nwhitehorn

Modified:
  head/usr.sbin/bsdinstall/partedit/partedit.c

Modified: head/usr.sbin/bsdinstall/partedit/partedit.c
==
--- head/usr.sbin/bsdinstall/partedit/partedit.cThu Jul  7 00:46:50 
2011(r223831)
+++ head/usr.sbin/bsdinstall/partedit/partedit.cThu Jul  7 01:22:50 
2011(r223832)
@@ -305,7 +305,7 @@ apply_changes(struct gmesh *mesh)
fprintf(fstab, # Device\tMountpoint\tFStype\tOptions\tDump\tPass#\n);
TAILQ_FOREACH(md, part_metadata, metadata) {
if (md-fstab != NULL)
-   fprintf(fstab, %s\t%s\t%s\t%s\t%d\t%d\n,
+   fprintf(fstab, %s\t%s\t\t%s\t%s\t%d\t%d\n,
md-fstab-fs_spec, md-fstab-fs_file,
md-fstab-fs_vfstype, md-fstab-fs_mntops,
md-fstab-fs_freq, md-fstab-fs_passno);
___
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: r223519 - head/etc/devd

2011-07-06 Thread Warner Losh

On Jul 3, 2011, at 7:15 AM, Ronald Klop wrote:

 On Tue, 28 Jun 2011 18:01:37 +0200, Warner Losh i...@bsdimp.com wrote:
 
 
 On Jun 28, 2011, at 2:45 AM, Alexey Dokuchaev wrote:
 
 On Sun, Jun 26, 2011 at 10:14:13PM -0600, Warner Losh wrote:
 Not in GENERIC.  9.0 is getting ready to feature freeze any minute, so
 there's no time to do the testing that a radical change like that would
 require.
 
 Fair enough.  Right now, this work seems to cover only USB kernel modules,
 is it so?  Is expansion into generic PCI area also planned, provided that
 you've already had some ideas and seem to be willing to pick up the work
 given enough support from the other developers (please excuse me if my
 understanding is wrong)?
 
 The reason we were able to relatively quickly generate this file from USB is 
 because USB is very regular and uniform in its probe routines.  They all 
 have (or could be converted to have) something approximating the same format.
 
 PCI isn't even remotely close to this, and the techniques that worked for 
 USB (and some of the short cuts taken) can't work for PCI for us.  There's 
 no uniformity in the PCI space, although many of the PCI drivers use a 
 similar design pattern.  They would all have to be converted to using the 
 same thing, which is kinda impractical at the moment (since many have 
 additional, driver specific fields).  While the tool is kinda flexible 
 enough to cope with this situation, more and more code winds up in the tool 
 to cope than is appropriate for the tool.
 
 That's why this feature is experimental.  For what it works for, it works 
 great.  For everything else, it is a lot of work to make it happy on a 
 wide-spread enough scale.  It is very instructive for how to approach 
 things, but embeds too much knowledge of the bus code into the tool to 
 generate these files than is appropriate (since it is duplicated information 
 from the driver, not exported from the bus/driver).
 
 Warner
 
 Maybe something for a GSOC 2012 project?

Yes.  that would make a good GSOC for the right student...  It would also scale 
well depending on the students skills.

Warner___
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