svn commit: r336237 - head/sys/geom/gate

2018-07-13 Thread Mikolaj Golub
Author: trociny (ports committer)
Date: Fri Jul 13 07:08:06 2018
New Revision: 336237
URL: https://svnweb.freebsd.org/changeset/base/336237

Log:
  geom_gate: enable resize
  
  Reviewed By:  pjd
  Approved By:  pjd
  Differential Revision:https://reviews.freebsd.org/D11531

Modified:
  head/sys/geom/gate/g_gate.c

Modified: head/sys/geom/gate/g_gate.c
==
--- head/sys/geom/gate/g_gate.c Fri Jul 13 02:02:16 2018(r336236)
+++ head/sys/geom/gate/g_gate.c Fri Jul 13 07:08:06 2018(r336237)
@@ -616,8 +616,8 @@ g_gate_modify(struct g_gate_softc *sc, struct g_gate_c
G_GATE_DEBUG(1, "Invalid media size.");
return (EINVAL);
}
-   /* TODO */
-   return (EOPNOTSUPP);
+   g_resize_provider(pp, ggio->gctl_mediasize);
+   return (0);
}
 
if ((ggio->gctl_modify & GG_MODIFY_INFO) != 0)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r270117 - head/sbin/hastd

2014-08-19 Thread Mikolaj Golub
On Mon, Aug 18, 2014 at 12:50:09AM +, Garrett Cooper wrote:

Hi Garrett,

 Log:
   Add -ll to LDADD to fix make checkdpadd

 Modified: head/sbin/hastd/Makefile
 ==
 --- head/sbin/hastd/Makefile  Sun Aug 17 23:30:45 2014(r270116)
 +++ head/sbin/hastd/Makefile  Mon Aug 18 00:50:09 2014(r270117)
 @@ -31,7 +31,7 @@ CFLAGS+=-DINET6
  .endif
  
  DPADD=   ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF} ${LIBL} ${LIBPTHREAD} 
 ${LIBUTIL}
 -LDADD=   -lgeom -lbsdxml -lsbuf -lpthread -lutil
 +LDADD=   -lgeom -lbsdxml -lsbuf -ll -lpthread -lutil

I think the proper fix is to remove ${LIBL} from DPADD instead. In
r250503 the intention was to remove libl dependency. It looks like I
forgot to update DPADD then.

-- 
Mikolaj Golub
___
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: r268061 - stable/10/sys/netgraph/bluetooth/socket

2014-06-30 Thread Mikolaj Golub
Author: trociny
Date: Mon Jun 30 19:46:17 2014
New Revision: 268061
URL: http://svnweb.freebsd.org/changeset/base/268061

Log:
  MFC r267336:
  
  PF_BLUETOOTH protocols: skip initialization of non-virtualized globals
  for non-default VNET instances.
  
  This fixes panic on a vnet initialization when ng_btsocket is loaded.

Modified:
  stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
  stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
  stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c
  stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
  stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_sco.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
==
--- stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c   Mon Jun 
30 19:36:08 2014(r268060)
+++ stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c   Mon Jun 
30 19:46:17 2014(r268061)
@@ -51,6 +51,9 @@
 #include sys/socketvar.h
 #include sys/sysctl.h
 #include sys/taskqueue.h
+
+#include net/vnet.h
+
 #include netgraph/ng_message.h
 #include netgraph/netgraph.h
 #include netgraph/bluetooth/include/ng_bluetooth.h
@@ -728,6 +731,10 @@ ng_btsocket_hci_raw_init(void)
bitstr_t*f = NULL;
int  error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_hci_raw_node = NULL;
ng_btsocket_hci_raw_debug_level = NG_BTSOCKET_WARN_LEVEL;
ng_btsocket_hci_raw_ioctl_timeout = 5;

Modified: stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
==
--- stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c Mon Jun 30 
19:36:08 2014(r268060)
+++ stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c Mon Jun 30 
19:46:17 2014(r268061)
@@ -1813,6 +1813,10 @@ ng_btsocket_l2cap_init(void)
 {
int error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_l2cap_node = NULL;
ng_btsocket_l2cap_debug_level = NG_BTSOCKET_WARN_LEVEL;
 

Modified: stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c
==
--- stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c Mon Jun 
30 19:36:08 2014(r268060)
+++ stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c Mon Jun 
30 19:46:17 2014(r268061)
@@ -50,6 +50,9 @@
 #include sys/socketvar.h
 #include sys/sysctl.h
 #include sys/taskqueue.h
+
+#include net/vnet.h
+
 #include netgraph/ng_message.h
 #include netgraph/netgraph.h
 #include netgraph/bluetooth/include/ng_bluetooth.h
@@ -513,6 +516,10 @@ ng_btsocket_l2cap_raw_init(void)
 {
int error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_l2cap_raw_node = NULL;
ng_btsocket_l2cap_raw_debug_level = NG_BTSOCKET_WARN_LEVEL;
ng_btsocket_l2cap_raw_ioctl_timeout = 5;

Modified: stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
==
--- stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.cMon Jun 
30 19:36:08 2014(r268060)
+++ stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.cMon Jun 
30 19:46:17 2014(r268061)
@@ -328,6 +328,11 @@ ng_btsocket_rfcomm_check_fcs(u_int8_t *d
 void
 ng_btsocket_rfcomm_init(void)
 {
+
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_rfcomm_debug_level = NG_BTSOCKET_WARN_LEVEL;
ng_btsocket_rfcomm_timo = 60;
 

Modified: stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_sco.c
==
--- stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_sco.c   Mon Jun 30 
19:36:08 2014(r268060)
+++ stable/10/sys/netgraph/bluetooth/socket/ng_btsocket_sco.c   Mon Jun 30 
19:46:17 2014(r268061)
@@ -1107,6 +1107,10 @@ ng_btsocket_sco_init(void)
 {
int error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_sco_node = NULL;
ng_btsocket_sco_debug_level = NG_BTSOCKET_WARN_LEVEL;
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any 

svn commit: r268062 - stable/9/sys/netgraph/bluetooth/socket

2014-06-30 Thread Mikolaj Golub
Author: trociny
Date: Mon Jun 30 19:47:26 2014
New Revision: 268062
URL: http://svnweb.freebsd.org/changeset/base/268062

Log:
  MFC r267336:
  
  PF_BLUETOOTH protocols: skip initialization of non-virtualized globals
  for non-default VNET instances.
  
  This fixes panic on a vnet initialization when ng_btsocket is loaded.

Modified:
  stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
  stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
  stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c
  stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
  stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_sco.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
==
--- stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.cMon Jun 
30 19:46:17 2014(r268061)
+++ stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.cMon Jun 
30 19:47:26 2014(r268062)
@@ -51,6 +51,9 @@
 #include sys/socketvar.h
 #include sys/sysctl.h
 #include sys/taskqueue.h
+
+#include net/vnet.h
+
 #include netgraph/ng_message.h
 #include netgraph/netgraph.h
 #include netgraph/bluetooth/include/ng_bluetooth.h
@@ -728,6 +731,10 @@ ng_btsocket_hci_raw_init(void)
bitstr_t*f = NULL;
int  error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_hci_raw_node = NULL;
ng_btsocket_hci_raw_debug_level = NG_BTSOCKET_WARN_LEVEL;
ng_btsocket_hci_raw_ioctl_timeout = 5;

Modified: stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
==
--- stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c  Mon Jun 30 
19:46:17 2014(r268061)
+++ stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c  Mon Jun 30 
19:47:26 2014(r268062)
@@ -1813,6 +1813,10 @@ ng_btsocket_l2cap_init(void)
 {
int error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_l2cap_node = NULL;
ng_btsocket_l2cap_debug_level = NG_BTSOCKET_WARN_LEVEL;
 

Modified: stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c
==
--- stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c  Mon Jun 
30 19:46:17 2014(r268061)
+++ stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c  Mon Jun 
30 19:47:26 2014(r268062)
@@ -50,6 +50,9 @@
 #include sys/socketvar.h
 #include sys/sysctl.h
 #include sys/taskqueue.h
+
+#include net/vnet.h
+
 #include netgraph/ng_message.h
 #include netgraph/netgraph.h
 #include netgraph/bluetooth/include/ng_bluetooth.h
@@ -513,6 +516,10 @@ ng_btsocket_l2cap_raw_init(void)
 {
int error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_l2cap_raw_node = NULL;
ng_btsocket_l2cap_raw_debug_level = NG_BTSOCKET_WARN_LEVEL;
ng_btsocket_l2cap_raw_ioctl_timeout = 5;

Modified: stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
==
--- stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c Mon Jun 30 
19:46:17 2014(r268061)
+++ stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c Mon Jun 30 
19:47:26 2014(r268062)
@@ -328,6 +328,11 @@ ng_btsocket_rfcomm_check_fcs(u_int8_t *d
 void
 ng_btsocket_rfcomm_init(void)
 {
+
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_rfcomm_debug_level = NG_BTSOCKET_WARN_LEVEL;
ng_btsocket_rfcomm_timo = 60;
 

Modified: stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_sco.c
==
--- stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_sco.cMon Jun 30 
19:46:17 2014(r268061)
+++ stable/9/sys/netgraph/bluetooth/socket/ng_btsocket_sco.cMon Jun 30 
19:47:26 2014(r268062)
@@ -1107,6 +1107,10 @@ ng_btsocket_sco_init(void)
 {
int error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_sco_node = NULL;
ng_btsocket_sco_debug_level = NG_BTSOCKET_WARN_LEVEL;
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to 

svn commit: r267336 - head/sys/netgraph/bluetooth/socket

2014-06-10 Thread Mikolaj Golub
Author: trociny
Date: Tue Jun 10 18:21:37 2014
New Revision: 267336
URL: http://svnweb.freebsd.org/changeset/base/267336

Log:
  PF_BLUETOOTH protocols: skip initialization of non-virtualized globals
  for non-default VNET instances.
  
  This fixes panic on a vnet initialization when ng_btsocket is loaded.
  
  MFC after:1 week

Modified:
  head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
  head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
  head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c
  head/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
  head/sys/netgraph/bluetooth/socket/ng_btsocket_sco.c

Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
==
--- head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.cTue Jun 10 
17:54:24 2014(r267335)
+++ head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.cTue Jun 10 
18:21:37 2014(r267336)
@@ -51,6 +51,9 @@
 #include sys/socketvar.h
 #include sys/sysctl.h
 #include sys/taskqueue.h
+
+#include net/vnet.h
+
 #include netgraph/ng_message.h
 #include netgraph/netgraph.h
 #include netgraph/bluetooth/include/ng_bluetooth.h
@@ -728,6 +731,10 @@ ng_btsocket_hci_raw_init(void)
bitstr_t*f = NULL;
int  error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_hci_raw_node = NULL;
ng_btsocket_hci_raw_debug_level = NG_BTSOCKET_WARN_LEVEL;
ng_btsocket_hci_raw_ioctl_timeout = 5;

Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
==
--- head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c  Tue Jun 10 
17:54:24 2014(r267335)
+++ head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c  Tue Jun 10 
18:21:37 2014(r267336)
@@ -1813,6 +1813,10 @@ ng_btsocket_l2cap_init(void)
 {
int error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_l2cap_node = NULL;
ng_btsocket_l2cap_debug_level = NG_BTSOCKET_WARN_LEVEL;
 

Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c
==
--- head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c  Tue Jun 10 
17:54:24 2014(r267335)
+++ head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c  Tue Jun 10 
18:21:37 2014(r267336)
@@ -50,6 +50,9 @@
 #include sys/socketvar.h
 #include sys/sysctl.h
 #include sys/taskqueue.h
+
+#include net/vnet.h
+
 #include netgraph/ng_message.h
 #include netgraph/netgraph.h
 #include netgraph/bluetooth/include/ng_bluetooth.h
@@ -513,6 +516,10 @@ ng_btsocket_l2cap_raw_init(void)
 {
int error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_l2cap_raw_node = NULL;
ng_btsocket_l2cap_raw_debug_level = NG_BTSOCKET_WARN_LEVEL;
ng_btsocket_l2cap_raw_ioctl_timeout = 5;

Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
==
--- head/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c Tue Jun 10 
17:54:24 2014(r267335)
+++ head/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c Tue Jun 10 
18:21:37 2014(r267336)
@@ -328,6 +328,11 @@ ng_btsocket_rfcomm_check_fcs(u_int8_t *d
 void
 ng_btsocket_rfcomm_init(void)
 {
+
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_rfcomm_debug_level = NG_BTSOCKET_WARN_LEVEL;
ng_btsocket_rfcomm_timo = 60;
 

Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_sco.c
==
--- head/sys/netgraph/bluetooth/socket/ng_btsocket_sco.cTue Jun 10 
17:54:24 2014(r267335)
+++ head/sys/netgraph/bluetooth/socket/ng_btsocket_sco.cTue Jun 10 
18:21:37 2014(r267336)
@@ -1107,6 +1107,10 @@ ng_btsocket_sco_init(void)
 {
int error = 0;
 
+   /* Skip initialization of globals for non-default instances. */
+   if (!IS_DEFAULT_VNET(curvnet))
+   return;
+
ng_btsocket_sco_node = NULL;
ng_btsocket_sco_debug_level = NG_BTSOCKET_WARN_LEVEL;
 
___
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: r266394 - in head/sys/dev/usb: . controller

2014-06-07 Thread Mikolaj Golub
Hi,

On Sun, May 18, 2014 at 09:13:29AM +, Hans Petter Selasky wrote:
 Author: hselasky
 Date: Sun May 18 09:13:29 2014
 New Revision: 266394
 URL: http://svnweb.freebsd.org/changeset/base/266394
 
 Log:
   - Add softc pointer argument to FIFO functions as an optimisation.
   - Implement support for interrupt filters in the DWC OTG driver, to
   reduce the amount of CPU task switching when only feeding the FIFOs.
   - Add common spinlock to the USB bus structure.

I observe panic on WITNESS enabled kernel:

 lock (xhci0) spin mutex does not match earlier (sleep mutex) lock.

in 

_mtx_init()
usb_bus_mem_alloc_all
xchi_init
xhci_pci_attach
device_attach

 
 Modified: head/sys/dev/usb/controller/usb_controller.c
 ==
 --- head/sys/dev/usb/controller/usb_controller.c  Sun May 18 04:33:24 
 2014(r266393)
 +++ head/sys/dev/usb/controller/usb_controller.c  Sun May 18 09:13:29 
 2014(r266394)
 @@ -901,6 +901,9 @@ usb_bus_mem_alloc_all(struct usb_bus *bu
   mtx_init(bus-bus_mtx, device_get_nameunit(bus-parent),
   NULL, MTX_DEF | MTX_RECURSE);
  
 + mtx_init(bus-bus_spin_lock, device_get_nameunit(bus-parent),
 + NULL, MTX_SPIN | MTX_RECURSE);
 +

I think because sleep mutex bus_mtx and spin mutex bus_spin_lock are
initilized with the same name here.

The pacth below fixes the issue for me. Not sure about its correctnes,
did not find quickly a good example in the source.

Index: sys/dev/usb/controller/usb_controller.c
===
--- sys/dev/usb/controller/usb_controller.c (revision 267176)
+++ sys/dev/usb/controller/usb_controller.c (working copy)
@@ -898,10 +898,10 @@
bus-alloc_failed = 0;
 
mtx_init(bus-bus_mtx, device_get_nameunit(bus-parent),
-   NULL, MTX_DEF | MTX_RECURSE);
+   bus_mtx, MTX_DEF | MTX_RECURSE);
 
mtx_init(bus-bus_spin_lock, device_get_nameunit(bus-parent),
-   NULL, MTX_SPIN | MTX_RECURSE);
+   bus_spin_lock, MTX_SPIN | MTX_RECURSE);
 
usb_callout_init_mtx(bus-power_wdog,
bus-bus_mtx, 0);

-- 
Mikolaj Golub
___
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: r265227 - stable/10/sys/netpfil/ipfw

2014-05-02 Thread Mikolaj Golub
Author: trociny
Date: Fri May  2 14:44:17 2014
New Revision: 265227
URL: http://svnweb.freebsd.org/changeset/base/265227

Log:
  MFC r264963:
  
  Define startup order the same way as it is in dummynet.

Modified:
  stable/10/sys/netpfil/ipfw/ip_fw_nat.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netpfil/ipfw/ip_fw_nat.c
==
--- stable/10/sys/netpfil/ipfw/ip_fw_nat.c  Fri May  2 13:32:07 2014
(r265226)
+++ stable/10/sys/netpfil/ipfw/ip_fw_nat.c  Fri May  2 14:44:17 2014
(r265227)
@@ -674,8 +674,8 @@ static moduledata_t ipfw_nat_mod = {
 };
 
 /* Define startup order. */
-#defineIPFW_NAT_SI_SUB_FIREWALL(SI_SUB_PROTO_IFATTACHDOMAIN + 
1)
-#defineIPFW_NAT_MODEVENT_ORDER (SI_ORDER_ANY - 255)
+#defineIPFW_NAT_SI_SUB_FIREWALLSI_SUB_PROTO_IFATTACHDOMAIN
+#defineIPFW_NAT_MODEVENT_ORDER (SI_ORDER_ANY - 128) /* after 
ipfw */
 #defineIPFW_NAT_MODULE_ORDER   (IPFW_NAT_MODEVENT_ORDER + 1)
 #defineIPFW_NAT_VNET_ORDER (IPFW_NAT_MODEVENT_ORDER + 2)
 
___
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: r264963 - head/sys/netpfil/ipfw

2014-04-26 Thread Mikolaj Golub
Author: trociny
Date: Sat Apr 26 08:05:16 2014
New Revision: 264963
URL: http://svnweb.freebsd.org/changeset/base/264963

Log:
  Define startup order the same way as it is in dummynet.

Modified:
  head/sys/netpfil/ipfw/ip_fw_nat.c

Modified: head/sys/netpfil/ipfw/ip_fw_nat.c
==
--- head/sys/netpfil/ipfw/ip_fw_nat.c   Sat Apr 26 01:00:37 2014
(r264962)
+++ head/sys/netpfil/ipfw/ip_fw_nat.c   Sat Apr 26 08:05:16 2014
(r264963)
@@ -676,8 +676,8 @@ static moduledata_t ipfw_nat_mod = {
 };
 
 /* Define startup order. */
-#defineIPFW_NAT_SI_SUB_FIREWALL(SI_SUB_PROTO_IFATTACHDOMAIN + 
1)
-#defineIPFW_NAT_MODEVENT_ORDER (SI_ORDER_ANY - 255)
+#defineIPFW_NAT_SI_SUB_FIREWALLSI_SUB_PROTO_IFATTACHDOMAIN
+#defineIPFW_NAT_MODEVENT_ORDER (SI_ORDER_ANY - 128) /* after 
ipfw */
 #defineIPFW_NAT_MODULE_ORDER   (IPFW_NAT_MODEVENT_ORDER + 1)
 #defineIPFW_NAT_VNET_ORDER (IPFW_NAT_MODEVENT_ORDER + 2)
 
___
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: r262196 - head/sys/netpfil/pf

2014-02-19 Thread Mikolaj Golub
On Tue, Feb 18, 2014 at 10:17:12PM +, Martin Matuska wrote:
 Author: mm
 Date: Tue Feb 18 22:17:12 2014
 New Revision: 262196
 URL: http://svnweb.freebsd.org/changeset/base/262196
 
 Log:
   De-virtualize pf_mtag_z [1]
   Process V_pf_overloadqueue in vnet context [2]

Martin I saw you reverted it but it looks you are going to work on it
still, so one comment below.

...

 -SLIST_HEAD(pf_overload_head, pf_overload_entry);
 +struct pf_overload_head {
 + SLIST_HEAD(, pf_overload_entry) head;
 + struct vnet *vnet;
 +};
  static VNET_DEFINE(struct pf_overload_head, pf_overloadqueue);
  #define V_pf_overloadqueue   VNET(pf_overloadqueue)

...

 - SLIST_INIT(V_pf_overloadqueue);
 + SLIST_INIT(V_pf_overloadqueue.head);
   TASK_INIT(V_pf_overloadtask, 0, pf_overload_task, V_pf_overloadqueue);
 + V_pf_overloadqueue.vnet = curvnet;

Why not pass vnet as a context to pf_overload_task instead of
V_pf_overloadqueue? Then you would not need this hack with storing a
vnet inside a vnet variable.

-- 
Mikolaj Golub
___
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: r261650 - in head/sys: net netinet netinet/cc

2014-02-09 Thread Mikolaj Golub
Author: trociny
Date: Sun Feb  9 08:13:17 2014
New Revision: 261650
URL: http://svnweb.freebsd.org/changeset/base/261650

Log:
  Fixup for r261590 (vnet sysctl handlers cleanup).
  
  Reviewed by:  glebius

Modified:
  head/sys/net/vnet.h
  head/sys/netinet/cc/cc_cdg.c
  head/sys/netinet/sctp_sysctl.c

Modified: head/sys/net/vnet.h
==
--- head/sys/net/vnet.h Sun Feb  9 02:39:00 2014(r261649)
+++ head/sys/net/vnet.h Sun Feb  9 08:13:17 2014(r261650)
@@ -303,7 +303,7 @@ void vnet_data_free(void *start_arg, in
descr)  \
SYSCTL_OID(parent, nbr, name,   \
CTLTYPE_OPAQUE|CTLFLAG_VNET|(access), ptr, len, \
-   vnet_sysctl_handle_opaque, fmt, descr)
+   sysctl_handle_opaque, fmt, descr)
 #defineSYSCTL_VNET_STRING(parent, nbr, name, access, arg, len, descr)  
\
SYSCTL_OID(parent, nbr, name,   \
CTLTYPE_STRING|CTLFLAG_VNET|(access),   \

Modified: head/sys/netinet/cc/cc_cdg.c
==
--- head/sys/netinet/cc/cc_cdg.cSun Feb  9 02:39:00 2014
(r261649)
+++ head/sys/netinet/cc/cc_cdg.cSun Feb  9 08:13:17 2014
(r261650)
@@ -81,11 +81,6 @@ __FBSDID($FreeBSD$);
 
 #defineCAST_PTR_INT(X) (*((int*)(X)))
 
-#ifndefVIMAGE
-#definevnet_sysctl_handle_uint(oidp, arg1, arg2, req) \
-sysctl_handle_int(oidp, arg1, arg2, req)
-#endif
-
 /* Private delay-gradient induced congestion control signal. */
 #defineCC_CDG_DELAY 0x0100
 
@@ -357,7 +352,7 @@ cdg_beta_handler(SYSCTL_HANDLER_ARGS)
(CAST_PTR_INT(req-newptr) == 0 || CAST_PTR_INT(req-newptr)  100))
return (EINVAL);
 
-   return (vnet_sysctl_handle_uint(oidp, arg1, arg2, req));
+   return (sysctl_handle_int(oidp, arg1, arg2, req));
 }
 
 static int
@@ -367,7 +362,7 @@ cdg_exp_backoff_scale_handler(SYSCTL_HAN
if (req-newptr != NULL  CAST_PTR_INT(req-newptr)  1)
return (EINVAL);
 
-   return (vnet_sysctl_handle_uint(oidp, arg1, arg2, req));
+   return (sysctl_handle_int(oidp, arg1, arg2, req));
 }
 
 static inline unsigned long

Modified: head/sys/netinet/sctp_sysctl.c
==
--- head/sys/netinet/sctp_sysctl.c  Sun Feb  9 02:39:00 2014
(r261649)
+++ head/sys/netinet/sctp_sysctl.c  Sun Feb  9 08:13:17 2014
(r261650)
@@ -587,11 +587,7 @@ sysctl_sctp_check(SYSCTL_HANDLER_ARGS)
 {
int error;
 
-#ifdef VIMAGE
-   error = vnet_sysctl_handle_int(oidp, oidp-oid_arg1, oidp-oid_arg2, 
req);
-#else
error = sysctl_handle_int(oidp, oidp-oid_arg1, oidp-oid_arg2, req);
-#endif
if (error == 0) {
RANGECHK(SCTP_BASE_SYSCTL(sctp_sendspace), 
SCTPCTL_MAXDGRAM_MIN, SCTPCTL_MAXDGRAM_MAX);
RANGECHK(SCTP_BASE_SYSCTL(sctp_recvspace), 
SCTPCTL_RECVSPACE_MIN, SCTPCTL_RECVSPACE_MAX);
___
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: r260924 - stable/10/usr.bin/script

2014-01-20 Thread Mikolaj Golub
Author: trociny
Date: Mon Jan 20 20:33:40 2014
New Revision: 260924
URL: http://svnweb.freebsd.org/changeset/base/260924

Log:
  MFC r260833:
  
  Bring back r226403, the fix for bin/161526, which was (accidentally?)
  reverted in r238896.
  
  PR:   bin/161526
  Reported by:  Karli.Sjoberg slu.se

Modified:
  stable/10/usr.bin/script/script.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/script/script.c
==
--- stable/10/usr.bin/script/script.c   Mon Jan 20 20:28:04 2014
(r260923)
+++ stable/10/usr.bin/script/script.c   Mon Jan 20 20:33:40 2014
(r260924)
@@ -235,12 +235,15 @@ main(int argc, char *argv[])
FD_SET(master, rfd);
if (readstdin)
FD_SET(STDIN_FILENO, rfd);
-   if ((!readstdin  ttyflg) || flushtime  0) {
-   tv.tv_sec = !readstdin  ttyflg ? 1 :
-   flushtime - (tvec - start);
+   if (!readstdin  ttyflg) {
+   tv.tv_sec = 1;
tv.tv_usec = 0;
tvp = tv;
readstdin = 1;
+   } else if (flushtime  0) {
+   tv.tv_sec = flushtime - (tvec - start);
+   tv.tv_usec = 0;
+   tvp = tv;
} else {
tvp = 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: r260925 - stable/9/usr.bin/script

2014-01-20 Thread Mikolaj Golub
Author: trociny
Date: Mon Jan 20 20:34:31 2014
New Revision: 260925
URL: http://svnweb.freebsd.org/changeset/base/260925

Log:
  MFC r260833:
  
  Bring back r226403, the fix for bin/161526, which was (accidentally?)
  reverted in r238896.
  
  PR:   bin/161526
  Reported by:  Karli.Sjoberg slu.se

Modified:
  stable/9/usr.bin/script/script.c
Directory Properties:
  stable/9/usr.bin/script/   (props changed)

Modified: stable/9/usr.bin/script/script.c
==
--- stable/9/usr.bin/script/script.cMon Jan 20 20:33:40 2014
(r260924)
+++ stable/9/usr.bin/script/script.cMon Jan 20 20:34:31 2014
(r260925)
@@ -235,12 +235,15 @@ main(int argc, char *argv[])
FD_SET(master, rfd);
if (readstdin)
FD_SET(STDIN_FILENO, rfd);
-   if ((!readstdin  ttyflg) || flushtime  0) {
-   tv.tv_sec = !readstdin  ttyflg ? 1 :
-   flushtime - (tvec - start);
+   if (!readstdin  ttyflg) {
+   tv.tv_sec = 1;
tv.tv_usec = 0;
tvp = tv;
readstdin = 1;
+   } else if (flushtime  0) {
+   tv.tv_sec = flushtime - (tvec - start);
+   tv.tv_usec = 0;
+   tvp = tv;
} else {
tvp = 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: r260833 - head/usr.bin/script

2014-01-17 Thread Mikolaj Golub
Author: trociny
Date: Fri Jan 17 21:45:25 2014
New Revision: 260833
URL: http://svnweb.freebsd.org/changeset/base/260833

Log:
  Bring back r226403, the fix for bin/161526, which was (accidentally?)
  reverted in r238896.
  
  PR:   bin/161526
  Reported by:  Karli.Sjoberg slu.se
  MFC after:3 days

Modified:
  head/usr.bin/script/script.c

Modified: head/usr.bin/script/script.c
==
--- head/usr.bin/script/script.cFri Jan 17 21:37:55 2014
(r260832)
+++ head/usr.bin/script/script.cFri Jan 17 21:45:25 2014
(r260833)
@@ -238,12 +238,15 @@ main(int argc, char *argv[])
FD_SET(master, rfd);
if (readstdin)
FD_SET(STDIN_FILENO, rfd);
-   if ((!readstdin  ttyflg) || flushtime  0) {
-   tv.tv_sec = !readstdin  ttyflg ? 1 :
-   flushtime - (tvec - start);
+   if (!readstdin  ttyflg) {
+   tv.tv_sec = 1;
tv.tv_usec = 0;
tvp = tv;
readstdin = 1;
+   } else if (flushtime  0) {
+   tv.tv_sec = flushtime - (tvec - start);
+   tv.tv_usec = 0;
+   tvp = tv;
} else {
tvp = 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: r260412 - stable/10/usr.sbin/bsnmpd/modules/snmp_hast

2014-01-07 Thread Mikolaj Golub
Author: trociny
Date: Tue Jan  7 21:23:41 2014
New Revision: 260412
URL: http://svnweb.freebsd.org/changeset/base/260412

Log:
  MFC r260049:
  
  Add mibs for hastd(1) queue stats.

Modified:
  stable/10/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
  stable/10/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
  stable/10/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
==
--- stable/10/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txtTue Jan 
 7 21:14:28 2014(r260411)
+++ stable/10/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txtTue Jan 
 7 21:23:41 2014(r260412)
@@ -60,6 +60,11 @@ begemotHast MODULE-IDENTITY
 REVISION 20130701Z
 DESCRIPTION
Added hastResourceWorkerPid.
+REVISION 20131229Z
+DESCRIPTION
+   Added hastResourceLocalQueue, hastResourceSendQueue,
+   hastResourceRecvQueue, hastResourceDoneQueue,
+   hastResourceIdleQueue.
 ::= { begemot 220 }
 
 begemotHastObjects OBJECT IDENTIFIER ::= { begemotHast 1 }
@@ -120,7 +125,12 @@ HastResourceEntry ::= SEQUENCE {
 hastResourceWriteErrorsCounter64,
 hastResourceDeleteErrors   Counter64,
 hastResourceFlushErrorsCounter64,
-hastResourceWorkerPid  INTEGER
+hastResourceWorkerPid  INTEGER,
+hastResourceLocalQueue UNSIGNED32,
+hastResourceSendQueue  UNSIGNED32,
+hastResourceRecvQueue  UNSIGNED32,
+hastResourceDoneQueue  UNSIGNED32,
+hastResourceIdleQueue  UNSIGNED32
 }
 
 hastResourceIndex OBJECT-TYPE
@@ -307,4 +317,46 @@ hastResourceWorkerPid OBJECT-TYPE
Worker process ID.
 ::= { hastResourceEntry 22 }
 
+hastResourceLocalQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests to the local component.
+::= { hastResourceEntry 23 }
+
+hastResourceSendQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests to send to the remote
+   component.
+::= { hastResourceEntry 24 }
+
+hastResourceRecvQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests waiting for response
+   from the remote component.
+::= { hastResourceEntry 25 }
+
+hastResourceDoneQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of processed I/O requests to return to the kernel.
+::= { hastResourceEntry 26 }
+
+hastResourceIdleQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of request objects in the free bucket.
+::= { hastResourceEntry 27 }
+
 END

Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
==
--- stable/10/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c Tue Jan  7 
21:14:28 2014(r260411)
+++ stable/10/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c Tue Jan  7 
21:23:41 2014(r260412)
@@ -79,6 +79,11 @@ struct hast_snmp_resource {
uint64_tdelete_errors;
uint64_tflush_errors;
pid_t   workerpid;
+   uint32_tlocal_queue;
+   uint32_tsend_queue;
+   uint32_trecv_queue;
+   uint32_tdone_queue;
+   uint32_tidle_queue;
 };
 
 static TAILQ_HEAD(, hast_snmp_resource) resources =
@@ -345,6 +350,16 @@ update_resources(void)
res-flush_errors =
nv_get_uint64(nvout, stat_flush_error%u, i);
res-workerpid = nv_get_int32(nvout, workerpid%u, i);
+   res-local_queue =
+   nv_get_uint64(nvout, local_queue_size%u, i);
+   res-send_queue =
+   nv_get_uint64(nvout, send_queue_size%u, i);
+   res-recv_queue =
+   nv_get_uint64(nvout, recv_queue_size%u, i);
+   res-done_queue =
+   nv_get_uint64(nvout, done_queue_size%u, i);
+   res-idle_queue =
+   nv_get_uint64(nvout, idle_queue_size%u, i);
TAILQ_INSERT_TAIL(resources, res, link);
}
nv_free(nvout);
@@ -503,6 +518,21 @@ op_hastResourceTable(struct snmp_context
case LEAF_hastResourceWorkerPid:
value-v.integer = res-workerpid;
break;
+   case LEAF_hastResourceLocalQueue:
+   value-v.uint32 = res-local_queue;
+

svn commit: r260413 - stable/9/usr.sbin/bsnmpd/modules/snmp_hast

2014-01-07 Thread Mikolaj Golub
Author: trociny
Date: Tue Jan  7 21:24:34 2014
New Revision: 260413
URL: http://svnweb.freebsd.org/changeset/base/260413

Log:
  MFC r260049:
  
  Add mibs for hastd(1) queue stats.

Modified:
  stable/9/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
  stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
  stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def
Directory Properties:
  stable/9/usr.sbin/bsnmpd/   (props changed)

Modified: stable/9/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
==
--- stable/9/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Tue Jan 
 7 21:23:41 2014(r260412)
+++ stable/9/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Tue Jan 
 7 21:24:34 2014(r260413)
@@ -60,6 +60,11 @@ begemotHast MODULE-IDENTITY
 REVISION 20130701Z
 DESCRIPTION
Added hastResourceWorkerPid.
+REVISION 20131229Z
+DESCRIPTION
+   Added hastResourceLocalQueue, hastResourceSendQueue,
+   hastResourceRecvQueue, hastResourceDoneQueue,
+   hastResourceIdleQueue.
 ::= { begemot 220 }
 
 begemotHastObjects OBJECT IDENTIFIER ::= { begemotHast 1 }
@@ -120,7 +125,12 @@ HastResourceEntry ::= SEQUENCE {
 hastResourceWriteErrorsCounter64,
 hastResourceDeleteErrors   Counter64,
 hastResourceFlushErrorsCounter64,
-hastResourceWorkerPid  INTEGER
+hastResourceWorkerPid  INTEGER,
+hastResourceLocalQueue UNSIGNED32,
+hastResourceSendQueue  UNSIGNED32,
+hastResourceRecvQueue  UNSIGNED32,
+hastResourceDoneQueue  UNSIGNED32,
+hastResourceIdleQueue  UNSIGNED32
 }
 
 hastResourceIndex OBJECT-TYPE
@@ -307,4 +317,46 @@ hastResourceWorkerPid OBJECT-TYPE
Worker process ID.
 ::= { hastResourceEntry 22 }
 
+hastResourceLocalQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests to the local component.
+::= { hastResourceEntry 23 }
+
+hastResourceSendQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests to send to the remote
+   component.
+::= { hastResourceEntry 24 }
+
+hastResourceRecvQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests waiting for response
+   from the remote component.
+::= { hastResourceEntry 25 }
+
+hastResourceDoneQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of processed I/O requests to return to the kernel.
+::= { hastResourceEntry 26 }
+
+hastResourceIdleQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of request objects in the free bucket.
+::= { hastResourceEntry 27 }
+
 END

Modified: stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
==
--- stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Tue Jan  7 
21:23:41 2014(r260412)
+++ stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Tue Jan  7 
21:24:34 2014(r260413)
@@ -79,6 +79,11 @@ struct hast_snmp_resource {
uint64_tdelete_errors;
uint64_tflush_errors;
pid_t   workerpid;
+   uint32_tlocal_queue;
+   uint32_tsend_queue;
+   uint32_trecv_queue;
+   uint32_tdone_queue;
+   uint32_tidle_queue;
 };
 
 static TAILQ_HEAD(, hast_snmp_resource) resources =
@@ -345,6 +350,16 @@ update_resources(void)
res-flush_errors =
nv_get_uint64(nvout, stat_flush_error%u, i);
res-workerpid = nv_get_int32(nvout, workerpid%u, i);
+   res-local_queue =
+   nv_get_uint64(nvout, local_queue_size%u, i);
+   res-send_queue =
+   nv_get_uint64(nvout, send_queue_size%u, i);
+   res-recv_queue =
+   nv_get_uint64(nvout, recv_queue_size%u, i);
+   res-done_queue =
+   nv_get_uint64(nvout, done_queue_size%u, i);
+   res-idle_queue =
+   nv_get_uint64(nvout, idle_queue_size%u, i);
TAILQ_INSERT_TAIL(resources, res, link);
}
nv_free(nvout);
@@ -503,6 +518,21 @@ op_hastResourceTable(struct snmp_context
case LEAF_hastResourceWorkerPid:
value-v.integer = res-workerpid;
break;
+   case LEAF_hastResourceLocalQueue:
+   value-v.uint32 = res-local_queue;
+  

svn commit: r260414 - stable/8/usr.sbin/bsnmpd/modules/snmp_hast

2014-01-07 Thread Mikolaj Golub
Author: trociny
Date: Tue Jan  7 21:25:18 2014
New Revision: 260414
URL: http://svnweb.freebsd.org/changeset/base/260414

Log:
  MFC r260049:
  
  Add mibs for hastd(1) queue stats.

Modified:
  stable/8/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
  stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
  stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def
Directory Properties:
  stable/8/usr.sbin/bsnmpd/   (props changed)

Modified: stable/8/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
==
--- stable/8/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Tue Jan 
 7 21:24:34 2014(r260413)
+++ stable/8/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Tue Jan 
 7 21:25:18 2014(r260414)
@@ -60,6 +60,11 @@ begemotHast MODULE-IDENTITY
 REVISION 20130701Z
 DESCRIPTION
Added hastResourceWorkerPid.
+REVISION 20131229Z
+DESCRIPTION
+   Added hastResourceLocalQueue, hastResourceSendQueue,
+   hastResourceRecvQueue, hastResourceDoneQueue,
+   hastResourceIdleQueue.
 ::= { begemot 220 }
 
 begemotHastObjects OBJECT IDENTIFIER ::= { begemotHast 1 }
@@ -120,7 +125,12 @@ HastResourceEntry ::= SEQUENCE {
 hastResourceWriteErrorsCounter64,
 hastResourceDeleteErrors   Counter64,
 hastResourceFlushErrorsCounter64,
-hastResourceWorkerPid  INTEGER
+hastResourceWorkerPid  INTEGER,
+hastResourceLocalQueue UNSIGNED32,
+hastResourceSendQueue  UNSIGNED32,
+hastResourceRecvQueue  UNSIGNED32,
+hastResourceDoneQueue  UNSIGNED32,
+hastResourceIdleQueue  UNSIGNED32
 }
 
 hastResourceIndex OBJECT-TYPE
@@ -307,4 +317,46 @@ hastResourceWorkerPid OBJECT-TYPE
Worker process ID.
 ::= { hastResourceEntry 22 }
 
+hastResourceLocalQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests to the local component.
+::= { hastResourceEntry 23 }
+
+hastResourceSendQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests to send to the remote
+   component.
+::= { hastResourceEntry 24 }
+
+hastResourceRecvQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests waiting for response
+   from the remote component.
+::= { hastResourceEntry 25 }
+
+hastResourceDoneQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of processed I/O requests to return to the kernel.
+::= { hastResourceEntry 26 }
+
+hastResourceIdleQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of request objects in the free bucket.
+::= { hastResourceEntry 27 }
+
 END

Modified: stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
==
--- stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Tue Jan  7 
21:24:34 2014(r260413)
+++ stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Tue Jan  7 
21:25:18 2014(r260414)
@@ -79,6 +79,11 @@ struct hast_snmp_resource {
uint64_tdelete_errors;
uint64_tflush_errors;
pid_t   workerpid;
+   uint32_tlocal_queue;
+   uint32_tsend_queue;
+   uint32_trecv_queue;
+   uint32_tdone_queue;
+   uint32_tidle_queue;
 };
 
 static TAILQ_HEAD(, hast_snmp_resource) resources =
@@ -345,6 +350,16 @@ update_resources(void)
res-flush_errors =
nv_get_uint64(nvout, stat_flush_error%u, i);
res-workerpid = nv_get_int32(nvout, workerpid%u, i);
+   res-local_queue =
+   nv_get_uint64(nvout, local_queue_size%u, i);
+   res-send_queue =
+   nv_get_uint64(nvout, send_queue_size%u, i);
+   res-recv_queue =
+   nv_get_uint64(nvout, recv_queue_size%u, i);
+   res-done_queue =
+   nv_get_uint64(nvout, done_queue_size%u, i);
+   res-idle_queue =
+   nv_get_uint64(nvout, idle_queue_size%u, i);
TAILQ_INSERT_TAIL(resources, res, link);
}
nv_free(nvout);
@@ -503,6 +518,21 @@ op_hastResourceTable(struct snmp_context
case LEAF_hastResourceWorkerPid:
value-v.integer = res-workerpid;
break;
+   case LEAF_hastResourceLocalQueue:
+   value-v.uint32 = res-local_queue;
+  

svn commit: r260049 - head/usr.sbin/bsnmpd/modules/snmp_hast

2013-12-29 Thread Mikolaj Golub
Author: trociny
Date: Sun Dec 29 19:02:33 2013
New Revision: 260049
URL: http://svnweb.freebsd.org/changeset/base/260049

Log:
  Add mibs for hastd(1) queue stats.
  
  MFC after:1 week

Modified:
  head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
  head/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
  head/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def

Modified: head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
==
--- head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Sun Dec 29 
18:53:45 2013(r260048)
+++ head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Sun Dec 29 
19:02:33 2013(r260049)
@@ -60,6 +60,11 @@ begemotHast MODULE-IDENTITY
 REVISION 20130701Z
 DESCRIPTION
Added hastResourceWorkerPid.
+REVISION 20131229Z
+DESCRIPTION
+   Added hastResourceLocalQueue, hastResourceSendQueue,
+   hastResourceRecvQueue, hastResourceDoneQueue,
+   hastResourceIdleQueue.
 ::= { begemot 220 }
 
 begemotHastObjects OBJECT IDENTIFIER ::= { begemotHast 1 }
@@ -120,7 +125,12 @@ HastResourceEntry ::= SEQUENCE {
 hastResourceWriteErrorsCounter64,
 hastResourceDeleteErrors   Counter64,
 hastResourceFlushErrorsCounter64,
-hastResourceWorkerPid  INTEGER
+hastResourceWorkerPid  INTEGER,
+hastResourceLocalQueue UNSIGNED32,
+hastResourceSendQueue  UNSIGNED32,
+hastResourceRecvQueue  UNSIGNED32,
+hastResourceDoneQueue  UNSIGNED32,
+hastResourceIdleQueue  UNSIGNED32
 }
 
 hastResourceIndex OBJECT-TYPE
@@ -307,4 +317,46 @@ hastResourceWorkerPid OBJECT-TYPE
Worker process ID.
 ::= { hastResourceEntry 22 }
 
+hastResourceLocalQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests to the local component.
+::= { hastResourceEntry 23 }
+
+hastResourceSendQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests to send to the remote
+   component.
+::= { hastResourceEntry 24 }
+
+hastResourceRecvQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of outstanding I/O requests waiting for response
+   from the remote component.
+::= { hastResourceEntry 25 }
+
+hastResourceDoneQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of processed I/O requests to return to the kernel.
+::= { hastResourceEntry 26 }
+
+hastResourceIdleQueue OBJECT-TYPE
+SYNTAX UNSIGNED32
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Number of request objects in the free bucket.
+::= { hastResourceEntry 27 }
+
 END

Modified: head/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
==
--- head/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Sun Dec 29 18:53:45 
2013(r260048)
+++ head/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Sun Dec 29 19:02:33 
2013(r260049)
@@ -79,6 +79,11 @@ struct hast_snmp_resource {
uint64_tdelete_errors;
uint64_tflush_errors;
pid_t   workerpid;
+   uint32_tlocal_queue;
+   uint32_tsend_queue;
+   uint32_trecv_queue;
+   uint32_tdone_queue;
+   uint32_tidle_queue;
 };
 
 static TAILQ_HEAD(, hast_snmp_resource) resources =
@@ -345,6 +350,16 @@ update_resources(void)
res-flush_errors =
nv_get_uint64(nvout, stat_flush_error%u, i);
res-workerpid = nv_get_int32(nvout, workerpid%u, i);
+   res-local_queue =
+   nv_get_uint64(nvout, local_queue_size%u, i);
+   res-send_queue =
+   nv_get_uint64(nvout, send_queue_size%u, i);
+   res-recv_queue =
+   nv_get_uint64(nvout, recv_queue_size%u, i);
+   res-done_queue =
+   nv_get_uint64(nvout, done_queue_size%u, i);
+   res-idle_queue =
+   nv_get_uint64(nvout, idle_queue_size%u, i);
TAILQ_INSERT_TAIL(resources, res, link);
}
nv_free(nvout);
@@ -503,6 +518,21 @@ op_hastResourceTable(struct snmp_context
case LEAF_hastResourceWorkerPid:
value-v.integer = res-workerpid;
break;
+   case LEAF_hastResourceLocalQueue:
+   value-v.uint32 = res-local_queue;
+   break;
+   case LEAF_hastResourceSendQueue:
+   value-v.uint32 = res-send_queue;
+ 

svn commit: r260006 - in stable/10/sbin: hastctl hastd

2013-12-28 Thread Mikolaj Golub
Author: trociny
Date: Sat Dec 28 19:21:22 2013
New Revision: 260006
URL: http://svnweb.freebsd.org/changeset/base/260006

Log:
  MFC r257155, r257582, r259191, r259192, r259193, r259194, r259195, r259196:
  
  r257155:
  
  Make hastctl list command output current queue sizes.
  
  Reviewed by:  pjd
  
  r257582 (pjd):
  
  Correct alignment.
  
  r259191:
  
  For memsync replication, hio_countdown is used not only as an
  indication when a request can be moved to done queue, but also for
  detecting the current state of memsync request.
  
  This approach has problems, e.g. leaking a request if memsynk ack from
  the secondary failed, or racy usage of write_complete, which should be
  called only once per write request, but for memsync can be entered by
  local_send_thread and ggate_send_thread simultaneously.
  
  So the following approach is implemented instead:
  
  1) Use hio_countdown only for counting components we waiting to
 complete, i.e. initially it is always 2 for any replication mode.
  
  2) To distinguish between memsync ack and memsync fin responses
 from the secondary, add and use hio_memsyncacked field.
  
  3) write_complete() in component threads is called only before
 releasing hio_countdown (i.e. before the hio may be returned to the
 done queue).
  
  4) Add and use hio_writecount refcounter to detect when
 write_complete() can be called in memsync case.
  
  Reported by:  Pete French petefrench ingresso.co.uk
  Tested by:Pete French petefrench ingresso.co.uk
  
  r259192:
  
  Add some macros to make the code more readable (no functional chages).
  
  r259193:
  
  Fix compiler warnings.
  
  r259194:
  
  In remote_send_thread, if sending a request fails don't take the
  request back from the receive queue -- it might already be processed
  by remote_recv_thread, which lead to crashes like below:
  
(primary) Unable to receive reply header: Connection reset by peer.
(primary) Unable to send request (Connection reset by peer):
WRITE(954662912, 131072).
(primary) Disconnected from kopusha:7772.
(primary) Increasing localcnt to 1.
(primary) Assertion failed: (old  0), function refcnt_release,
file refcnt.h, line 62.
  
  Taking the request back was not necessary (it would properly be
  processed by the remote_recv_thread) and only complicated things.
  
  r259195:
  
  Send wakeup to threads waiting on empty queue before releasing the
  lock to decrease spurious wakeups.
  
  Submitted by: davidxu
  
  r259196:
  
  Check remote protocol version only for the first connection (when it
  is actually sent by the remote node).
  
  Otherwise it generated confusing Negotiated protocol version 1 debug
  messages when processing the second connection.

Modified:
  stable/10/sbin/hastctl/hastctl.c
  stable/10/sbin/hastd/control.c
  stable/10/sbin/hastd/hast.h
  stable/10/sbin/hastd/hastd.8
  stable/10/sbin/hastd/hastd.c
  stable/10/sbin/hastd/nv.c
  stable/10/sbin/hastd/primary.c
  stable/10/sbin/hastd/proto.c
  stable/10/sbin/hastd/secondary.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/hastctl/hastctl.c
==
--- stable/10/sbin/hastctl/hastctl.cSat Dec 28 16:08:10 2013
(r260005)
+++ stable/10/sbin/hastctl/hastctl.cSat Dec 28 19:21:22 2013
(r260006)
@@ -355,6 +355,13 @@ control_list(struct nv *nv)
(uintmax_t)nv_get_uint64(nv, stat_write_error%u, ii),
(uintmax_t)nv_get_uint64(nv, stat_delete_error%u, ii),
(uintmax_t)nv_get_uint64(nv, stat_flush_error%u, ii));
+   printf(queues: 
+   local: %ju, send: %ju, recv: %ju, done: %ju, idle: %ju\n,
+   (uintmax_t)nv_get_uint64(nv, local_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, send_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, recv_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, done_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, idle_queue_size%u, ii));
}
return (ret);
 }

Modified: stable/10/sbin/hastd/control.c
==
--- stable/10/sbin/hastd/control.c  Sat Dec 28 16:08:10 2013
(r260005)
+++ stable/10/sbin/hastd/control.c  Sat Dec 28 19:21:22 2013
(r260006)
@@ -215,6 +215,16 @@ control_status_worker(struct hast_resour
stat_delete_error%u, no);
nv_add_uint64(nvout, nv_get_uint64(cnvin, stat_flush_error),
stat_flush_error%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, idle_queue_size),
+   idle_queue_size%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, local_queue_size),
+   local_queue_size%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, send_queue_size),
+   

svn commit: r260007 - in stable/9/sbin: hastctl hastd

2013-12-28 Thread Mikolaj Golub
Author: trociny
Date: Sat Dec 28 19:22:23 2013
New Revision: 260007
URL: http://svnweb.freebsd.org/changeset/base/260007

Log:
  MFC r257155, r257582, r259191, r259192, r259193, r259194, r259195, r259196:
  
  r257155:
  
  Make hastctl list command output current queue sizes.
  
  Reviewed by:  pjd
  
  r257582 (pjd):
  
  Correct alignment.
  
  r259191:
  
  For memsync replication, hio_countdown is used not only as an
  indication when a request can be moved to done queue, but also for
  detecting the current state of memsync request.
  
  This approach has problems, e.g. leaking a request if memsynk ack from
  the secondary failed, or racy usage of write_complete, which should be
  called only once per write request, but for memsync can be entered by
  local_send_thread and ggate_send_thread simultaneously.
  
  So the following approach is implemented instead:
  
  1) Use hio_countdown only for counting components we waiting to
 complete, i.e. initially it is always 2 for any replication mode.
  
  2) To distinguish between memsync ack and memsync fin responses
 from the secondary, add and use hio_memsyncacked field.
  
  3) write_complete() in component threads is called only before
 releasing hio_countdown (i.e. before the hio may be returned to the
 done queue).
  
  4) Add and use hio_writecount refcounter to detect when
 write_complete() can be called in memsync case.
  
  Reported by:  Pete French petefrench ingresso.co.uk
  Tested by:Pete French petefrench ingresso.co.uk
  
  r259192:
  
  Add some macros to make the code more readable (no functional chages).
  
  r259193:
  
  Fix compiler warnings.
  
  r259194:
  
  In remote_send_thread, if sending a request fails don't take the
  request back from the receive queue -- it might already be processed
  by remote_recv_thread, which lead to crashes like below:
  
(primary) Unable to receive reply header: Connection reset by peer.
(primary) Unable to send request (Connection reset by peer):
WRITE(954662912, 131072).
(primary) Disconnected from kopusha:7772.
(primary) Increasing localcnt to 1.
(primary) Assertion failed: (old  0), function refcnt_release,
file refcnt.h, line 62.
  
  Taking the request back was not necessary (it would properly be
  processed by the remote_recv_thread) and only complicated things.
  
  r259195:
  
  Send wakeup to threads waiting on empty queue before releasing the
  lock to decrease spurious wakeups.
  
  Submitted by: davidxu
  
  r259196:
  
  Check remote protocol version only for the first connection (when it
  is actually sent by the remote node).
  
  Otherwise it generated confusing Negotiated protocol version 1 debug
  messages when processing the second connection.

Modified:
  stable/9/sbin/hastctl/hastctl.c
  stable/9/sbin/hastd/control.c
  stable/9/sbin/hastd/hast.h
  stable/9/sbin/hastd/hastd.8
  stable/9/sbin/hastd/hastd.c
  stable/9/sbin/hastd/nv.c
  stable/9/sbin/hastd/primary.c
  stable/9/sbin/hastd/proto.c
  stable/9/sbin/hastd/secondary.c
Directory Properties:
  stable/9/sbin/hastctl/   (props changed)
  stable/9/sbin/hastd/   (props changed)

Modified: stable/9/sbin/hastctl/hastctl.c
==
--- stable/9/sbin/hastctl/hastctl.c Sat Dec 28 19:21:22 2013
(r260006)
+++ stable/9/sbin/hastctl/hastctl.c Sat Dec 28 19:22:23 2013
(r260007)
@@ -355,6 +355,13 @@ control_list(struct nv *nv)
(uintmax_t)nv_get_uint64(nv, stat_write_error%u, ii),
(uintmax_t)nv_get_uint64(nv, stat_delete_error%u, ii),
(uintmax_t)nv_get_uint64(nv, stat_flush_error%u, ii));
+   printf(queues: 
+   local: %ju, send: %ju, recv: %ju, done: %ju, idle: %ju\n,
+   (uintmax_t)nv_get_uint64(nv, local_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, send_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, recv_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, done_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, idle_queue_size%u, ii));
}
return (ret);
 }

Modified: stable/9/sbin/hastd/control.c
==
--- stable/9/sbin/hastd/control.c   Sat Dec 28 19:21:22 2013
(r260006)
+++ stable/9/sbin/hastd/control.c   Sat Dec 28 19:22:23 2013
(r260007)
@@ -215,6 +215,16 @@ control_status_worker(struct hast_resour
stat_delete_error%u, no);
nv_add_uint64(nvout, nv_get_uint64(cnvin, stat_flush_error),
stat_flush_error%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, idle_queue_size),
+   idle_queue_size%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, local_queue_size),
+   local_queue_size%u, no);
+   nv_add_uint64(nvout, 

svn commit: r260008 - in stable/8/sbin: hastctl hastd

2013-12-28 Thread Mikolaj Golub
Author: trociny
Date: Sat Dec 28 19:23:16 2013
New Revision: 260008
URL: http://svnweb.freebsd.org/changeset/base/260008

Log:
  MFC r257155, r257582, r259191, r259192, r259193, r259194, r259195, r259196:
  
  r257155:
  
  Make hastctl list command output current queue sizes.
  
  Reviewed by:  pjd
  
  r257582 (pjd):
  
  Correct alignment.
  
  r259191:
  
  For memsync replication, hio_countdown is used not only as an
  indication when a request can be moved to done queue, but also for
  detecting the current state of memsync request.
  
  This approach has problems, e.g. leaking a request if memsynk ack from
  the secondary failed, or racy usage of write_complete, which should be
  called only once per write request, but for memsync can be entered by
  local_send_thread and ggate_send_thread simultaneously.
  
  So the following approach is implemented instead:
  
  1) Use hio_countdown only for counting components we waiting to
 complete, i.e. initially it is always 2 for any replication mode.
  
  2) To distinguish between memsync ack and memsync fin responses
 from the secondary, add and use hio_memsyncacked field.
  
  3) write_complete() in component threads is called only before
 releasing hio_countdown (i.e. before the hio may be returned to the
 done queue).
  
  4) Add and use hio_writecount refcounter to detect when
 write_complete() can be called in memsync case.
  
  Reported by:  Pete French petefrench ingresso.co.uk
  Tested by:Pete French petefrench ingresso.co.uk
  
  r259192:
  
  Add some macros to make the code more readable (no functional chages).
  
  r259193:
  
  Fix compiler warnings.
  
  r259194:
  
  In remote_send_thread, if sending a request fails don't take the
  request back from the receive queue -- it might already be processed
  by remote_recv_thread, which lead to crashes like below:
  
(primary) Unable to receive reply header: Connection reset by peer.
(primary) Unable to send request (Connection reset by peer):
WRITE(954662912, 131072).
(primary) Disconnected from kopusha:7772.
(primary) Increasing localcnt to 1.
(primary) Assertion failed: (old  0), function refcnt_release,
file refcnt.h, line 62.
  
  Taking the request back was not necessary (it would properly be
  processed by the remote_recv_thread) and only complicated things.
  
  r259195:
  
  Send wakeup to threads waiting on empty queue before releasing the
  lock to decrease spurious wakeups.
  
  Submitted by: davidxu
  
  r259196:
  
  Check remote protocol version only for the first connection (when it
  is actually sent by the remote node).
  
  Otherwise it generated confusing Negotiated protocol version 1 debug
  messages when processing the second connection.

Modified:
  stable/8/sbin/hastctl/hastctl.c
  stable/8/sbin/hastd/control.c
  stable/8/sbin/hastd/hast.h
  stable/8/sbin/hastd/hastd.8
  stable/8/sbin/hastd/hastd.c
  stable/8/sbin/hastd/nv.c
  stable/8/sbin/hastd/primary.c
  stable/8/sbin/hastd/proto.c
  stable/8/sbin/hastd/secondary.c
Directory Properties:
  stable/8/sbin/hastctl/   (props changed)
  stable/8/sbin/hastd/   (props changed)

Modified: stable/8/sbin/hastctl/hastctl.c
==
--- stable/8/sbin/hastctl/hastctl.c Sat Dec 28 19:22:23 2013
(r260007)
+++ stable/8/sbin/hastctl/hastctl.c Sat Dec 28 19:23:16 2013
(r260008)
@@ -355,6 +355,13 @@ control_list(struct nv *nv)
(uintmax_t)nv_get_uint64(nv, stat_write_error%u, ii),
(uintmax_t)nv_get_uint64(nv, stat_delete_error%u, ii),
(uintmax_t)nv_get_uint64(nv, stat_flush_error%u, ii));
+   printf(queues: 
+   local: %ju, send: %ju, recv: %ju, done: %ju, idle: %ju\n,
+   (uintmax_t)nv_get_uint64(nv, local_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, send_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, recv_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, done_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, idle_queue_size%u, ii));
}
return (ret);
 }

Modified: stable/8/sbin/hastd/control.c
==
--- stable/8/sbin/hastd/control.c   Sat Dec 28 19:22:23 2013
(r260007)
+++ stable/8/sbin/hastd/control.c   Sat Dec 28 19:23:16 2013
(r260008)
@@ -215,6 +215,16 @@ control_status_worker(struct hast_resour
stat_delete_error%u, no);
nv_add_uint64(nvout, nv_get_uint64(cnvin, stat_flush_error),
stat_flush_error%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, idle_queue_size),
+   idle_queue_size%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, local_queue_size),
+   local_queue_size%u, no);
+   nv_add_uint64(nvout, 

svn commit: r259191 - head/sbin/hastd

2013-12-10 Thread Mikolaj Golub
Author: trociny
Date: Tue Dec 10 19:56:26 2013
New Revision: 259191
URL: http://svnweb.freebsd.org/changeset/base/259191

Log:
  For memsync replication, hio_countdown is used not only as an
  indication when a request can be moved to done queue, but also for
  detecting the current state of memsync request.
  
  This approach has problems, e.g. leaking a request if memsynk ack from
  the secondary failed, or racy usage of write_complete, which should be
  called only once per write request, but for memsync can be entered by
  local_send_thread and ggate_send_thread simultaneously.
  
  So the following approach is implemented instead:
  
  1) Use hio_countdown only for counting components we waiting to
 complete, i.e. initially it is always 2 for any replication mode.
  
  2) To distinguish between memsync ack and memsync fin responses
 from the secondary, add and use hio_memsyncacked field.
  
  3) write_complete() in component threads is called only before
 releasing hio_countdown (i.e. before the hio may be returned to the
 done queue).
  
  4) Add and use hio_writecount refcounter to detect when
 write_complete() can be called in memsync case.
  
  Reported by:  Pete French petefrench ingresso.co.uk
  Tested by:Pete French petefrench ingresso.co.uk
  MFC after:2 weeks

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Tue Dec 10 19:48:48 2013(r259190)
+++ head/sbin/hastd/primary.c   Tue Dec 10 19:56:26 2013(r259191)
@@ -94,6 +94,15 @@ struct hio {
 */
bool hio_done;
/*
+* Number of components we are still waiting before sending write
+* completion ack to GEOM Gate. Used for memsync.
+*/
+   refcnt_t hio_writecount;
+   /*
+* Memsync request was acknowleged by remote.
+*/
+   bool hio_memsyncacked;
+   /*
 * Remember replication from the time the request was initiated,
 * so we won't get confused when replication changes on reload.
 */
@@ -231,6 +240,9 @@ static pthread_mutex_t metadata_lock;
 #defineISSYNCREQ(hio)  ((hio)-hio_ggio.gctl_unit == -1)
 #defineSYNCREQDONE(hio)do { (hio)-hio_ggio.gctl_unit = -2; } 
while (0)
 #defineISSYNCREQDONE(hio)  ((hio)-hio_ggio.gctl_unit == -2)
+#define ISMEMSYNCWRITE(hio)\
+   (((hio)-hio_replication == HAST_REPLICATION_MEMSYNC  \
+   (hio)-hio_ggio.gctl_cmd == BIO_WRITE  !ISSYNCREQ(hio)))
 
 static struct hast_resource *gres;
 
@@ -1344,6 +1356,10 @@ ggate_recv_thread(void *arg)
} else {
mtx_unlock(res-hr_amp_lock);
}
+   if (hio-hio_replication == HAST_REPLICATION_MEMSYNC) {
+   hio-hio_memsyncacked = false;
+   refcnt_init(hio-hio_writecount, ncomps);
+   }
break;
case BIO_DELETE:
res-hr_stat_delete++;
@@ -1354,13 +1370,7 @@ ggate_recv_thread(void *arg)
}
pjdlog_debug(2,
ggate_recv: (%p) Moving request to the send queues., hio);
-   if (hio-hio_replication == HAST_REPLICATION_MEMSYNC 
-   ggio-gctl_cmd == BIO_WRITE) {
-   /* Each remote request needs two responses in memsync. 
*/
-   refcnt_init(hio-hio_countdown, ncomps + 1);
-   } else {
-   refcnt_init(hio-hio_countdown, ncomps);
-   }
+   refcnt_init(hio-hio_countdown, ncomps);
for (ii = ncomp; ii  ncomps; ii++)
QUEUE_INSERT1(hio, send, ii);
}
@@ -1470,42 +1480,13 @@ local_send_thread(void *arg)
}
break;
}
-
-   if (hio-hio_replication != HAST_REPLICATION_MEMSYNC ||
-   ggio-gctl_cmd != BIO_WRITE || ISSYNCREQ(hio)) {
-   if (refcnt_release(hio-hio_countdown)  0)
-   continue;
-   } else {
-   /*
-* Depending on hio_countdown value, requests finished
-* in the following order:
-* 0: remote memsync, remote final, local write
-* 1: remote memsync, local write, (remote final)
-* 2: local write, (remote memsync), (remote final)
-*/
-   switch (refcnt_release(hio-hio_countdown)) {
-   case 0:
-   /*
-* Local write finished as last.
-   

svn commit: r259192 - head/sbin/hastd

2013-12-10 Thread Mikolaj Golub
Author: trociny
Date: Tue Dec 10 19:58:10 2013
New Revision: 259192
URL: http://svnweb.freebsd.org/changeset/base/259192

Log:
  Add some macros to make the code more readable (no functional chages).
  
  MFC after:2 weeks

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Tue Dec 10 19:56:26 2013(r259191)
+++ head/sbin/hastd/primary.c   Tue Dec 10 19:58:10 2013(r259192)
@@ -233,6 +233,10 @@ static pthread_mutex_t metadata_lock;
mtx_unlock(hio_##name##_list_lock);\
 } while (0)
 
+#define ISFULLSYNC(hio)((hio)-hio_replication == 
HAST_REPLICATION_FULLSYNC)
+#define ISMEMSYNC(hio) ((hio)-hio_replication == HAST_REPLICATION_MEMSYNC)
+#define ISASYNC(hio)   ((hio)-hio_replication == HAST_REPLICATION_ASYNC)
+
 #defineSYNCREQ(hio)do {
\
(hio)-hio_ggio.gctl_unit = -1; \
(hio)-hio_ggio.gctl_seq = 1;   \
@@ -240,9 +244,9 @@ static pthread_mutex_t metadata_lock;
 #defineISSYNCREQ(hio)  ((hio)-hio_ggio.gctl_unit == -1)
 #defineSYNCREQDONE(hio)do { (hio)-hio_ggio.gctl_unit = -2; } 
while (0)
 #defineISSYNCREQDONE(hio)  ((hio)-hio_ggio.gctl_unit == -2)
-#define ISMEMSYNCWRITE(hio)\
-   (((hio)-hio_replication == HAST_REPLICATION_MEMSYNC  \
-   (hio)-hio_ggio.gctl_cmd == BIO_WRITE  !ISSYNCREQ(hio)))
+
+#define ISMEMSYNCWRITE(hio)(ISMEMSYNC(hio)   \
+   (hio)-hio_ggio.gctl_cmd == BIO_WRITE  !ISSYNCREQ(hio))
 
 static struct hast_resource *gres;
 
@@ -1356,7 +1360,7 @@ ggate_recv_thread(void *arg)
} else {
mtx_unlock(res-hr_amp_lock);
}
-   if (hio-hio_replication == HAST_REPLICATION_MEMSYNC) {
+   if (ISMEMSYNC(hio)) {
hio-hio_memsyncacked = false;
refcnt_init(hio-hio_writecount, ncomps);
}
@@ -1441,8 +1445,7 @@ local_send_thread(void *arg)
ret, (intmax_t)ggio-gctl_length);
} else {
hio-hio_errors[ncomp] = 0;
-   if (hio-hio_replication ==
-   HAST_REPLICATION_ASYNC) {
+   if (ISASYNC(hio)) {
ggio-gctl_error = 0;
write_complete(res, hio);
}
___
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: r259193 - head/sbin/hastd

2013-12-10 Thread Mikolaj Golub
Author: trociny
Date: Tue Dec 10 20:02:09 2013
New Revision: 259193
URL: http://svnweb.freebsd.org/changeset/base/259193

Log:
  Fix compiler warnings.
  
  MFC after:2 weeks

Modified:
  head/sbin/hastd/nv.c
  head/sbin/hastd/proto.c

Modified: head/sbin/hastd/nv.c
==
--- head/sbin/hastd/nv.cTue Dec 10 19:58:10 2013(r259192)
+++ head/sbin/hastd/nv.cTue Dec 10 20:02:09 2013(r259193)
@@ -566,7 +566,7 @@ nv_get_string(struct nv *nv, const char 
return (NULL);
PJDLOG_ASSERT((nvh-nvh_type  NV_ORDER_MASK) == NV_ORDER_HOST);
PJDLOG_ASSERT(nvh-nvh_dsize = 1);
-   str = NVH_DATA(nvh);
+   str = (char *)NVH_DATA(nvh);
PJDLOG_ASSERT(str[nvh-nvh_dsize - 1] == '\0');
PJDLOG_ASSERT(strlen(str) == nvh-nvh_dsize - 1);
return (str);

Modified: head/sbin/hastd/proto.c
==
--- head/sbin/hastd/proto.c Tue Dec 10 19:58:10 2013(r259192)
+++ head/sbin/hastd/proto.c Tue Dec 10 20:02:09 2013(r259193)
@@ -298,8 +298,8 @@ proto_connection_send(const struct proto
protoname = mconn-pc_proto-prt_name;
PJDLOG_ASSERT(protoname != NULL);
 
-   ret = conn-pc_proto-prt_send(conn-pc_ctx, protoname,
-   strlen(protoname) + 1, fd);
+   ret = conn-pc_proto-prt_send(conn-pc_ctx,
+   (const unsigned char *)protoname, strlen(protoname) + 1, fd);
proto_close(mconn);
if (ret != 0) {
errno = ret;
@@ -325,7 +325,7 @@ proto_connection_recv(const struct proto
 
bzero(protoname, sizeof(protoname));
 
-   ret = conn-pc_proto-prt_recv(conn-pc_ctx, protoname,
+   ret = conn-pc_proto-prt_recv(conn-pc_ctx, (unsigned char *)protoname,
sizeof(protoname) - 1, fd);
if (ret != 0) {
errno = ret;
___
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: r259194 - head/sbin/hastd

2013-12-10 Thread Mikolaj Golub
Author: trociny
Date: Tue Dec 10 20:05:07 2013
New Revision: 259194
URL: http://svnweb.freebsd.org/changeset/base/259194

Log:
  In remote_send_thread, if sending a request fails don't take the
  request back from the receive queue -- it might already be processed
  by remote_recv_thread, which lead to crashes like below:
  
(primary) Unable to receive reply header: Connection reset by peer.
(primary) Unable to send request (Connection reset by peer):
WRITE(954662912, 131072).
(primary) Disconnected from kopusha:7772.
(primary) Increasing localcnt to 1.
(primary) Assertion failed: (old  0), function refcnt_release,
file refcnt.h, line 62.
  
  Taking the request back was not necessary (it would properly be
  processed by the remote_recv_thread) and only complicated things.
  
  MFC after:2 weeks

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Tue Dec 10 20:02:09 2013(r259193)
+++ head/sbin/hastd/primary.c   Tue Dec 10 20:05:07 2013(r259194)
@@ -1656,18 +1656,9 @@ remote_send_thread(void *arg)
Unable to send request (%s): ,
strerror(hio-hio_errors[ncomp]));
remote_close(res, ncomp);
-   /*
-* Take request back from the receive queue and move
-* it immediately to the done queue.
-*/
-   mtx_lock(hio_recv_list_lock[ncomp]);
-   TAILQ_REMOVE(hio_recv_list[ncomp], hio,
-   hio_next[ncomp]);
-   hio_recv_list_size[ncomp]--;
-   mtx_unlock(hio_recv_list_lock[ncomp]);
-   goto done_queue;
+   } else {
+   rw_unlock(hio_remote_lock[ncomp]);
}
-   rw_unlock(hio_remote_lock[ncomp]);
nv_free(nv);
if (wakeup)
cv_signal(hio_recv_list_cond[ncomp]);
___
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: r259195 - head/sbin/hastd

2013-12-10 Thread Mikolaj Golub
Author: trociny
Date: Tue Dec 10 20:06:41 2013
New Revision: 259195
URL: http://svnweb.freebsd.org/changeset/base/259195

Log:
  Send wakeup to threads waiting on empty queue before releasing the
  lock to decrease spurious wakeups.
  
  Submitted by: davidxu
  MFC after:2 weeks

Modified:
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Tue Dec 10 20:05:07 2013(r259194)
+++ head/sbin/hastd/primary.c   Tue Dec 10 20:06:41 2013(r259195)
@@ -180,27 +180,21 @@ static pthread_mutex_t metadata_lock;
((res)-hr_remotein != NULL  (res)-hr_remoteout != NULL)
 
 #defineQUEUE_INSERT1(hio, name, ncomp) do {
\
-   bool _wakeup;   \
-   \
mtx_lock(hio_##name##_list_lock[(ncomp)]); \
-   _wakeup = TAILQ_EMPTY(hio_##name##_list[(ncomp)]); \
+   if (TAILQ_EMPTY(hio_##name##_list[(ncomp)]))   \
+   cv_broadcast(hio_##name##_list_cond[(ncomp)]); \
TAILQ_INSERT_TAIL(hio_##name##_list[(ncomp)], (hio),   \
hio_next[(ncomp)]); \
hio_##name##_list_size[(ncomp)]++;  \
-   mtx_unlock(hio_##name##_list_lock[ncomp]); \
-   if (_wakeup)\
-   cv_broadcast(hio_##name##_list_cond[(ncomp)]); \
+   mtx_unlock(hio_##name##_list_lock[(ncomp)]);   \
 } while (0)
 #defineQUEUE_INSERT2(hio, name)do {
\
-   bool _wakeup;   \
-   \
mtx_lock(hio_##name##_list_lock);  \
-   _wakeup = TAILQ_EMPTY(hio_##name##_list);  \
+   if (TAILQ_EMPTY(hio_##name##_list))\
+   cv_broadcast(hio_##name##_list_cond);  \
TAILQ_INSERT_TAIL(hio_##name##_list, (hio), hio_##name##_next);\
hio_##name##_list_size++;   \
mtx_unlock(hio_##name##_list_lock);\
-   if (_wakeup)\
-   cv_broadcast(hio_##name##_list_cond);  \
 } while (0)
 #defineQUEUE_TAKE1(hio, name, ncomp, timeout)  do {
\
bool _last; \

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Tue Dec 10 20:05:07 2013(r259194)
+++ head/sbin/hastd/secondary.c Tue Dec 10 20:06:41 2013(r259195)
@@ -110,15 +110,12 @@ static void *disk_thread(void *arg);
 static void *send_thread(void *arg);
 
 #defineQUEUE_INSERT(name, hio) do {
\
-   bool _wakeup;   \
-   \
mtx_lock(hio_##name##_list_lock);  \
-   _wakeup = TAILQ_EMPTY(hio_##name##_list);  \
+   if (TAILQ_EMPTY(hio_##name##_list))\
+   cv_broadcast(hio_##name##_list_cond);  \
TAILQ_INSERT_TAIL(hio_##name##_list, (hio), hio_next); \
hio_##name##_list_size++;   \
mtx_unlock(hio_##name##_list_lock);\
-   if (_wakeup)\
-   cv_broadcast(hio_##name##_list_cond);  \
 } while (0)
 #defineQUEUE_TAKE(name, hio)   do {
\
mtx_lock(hio_##name##_list_lock);  \
___
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: r259196 - head/sbin/hastd

2013-12-10 Thread Mikolaj Golub
Author: trociny
Date: Tue Dec 10 20:09:49 2013
New Revision: 259196
URL: http://svnweb.freebsd.org/changeset/base/259196

Log:
  Check remote protocol version only for the first connection (when it
  is actually sent by the remote node).
  
  Otherwise it generated confusing Negotiated protocol version 1 debug
  messages when processing the second connection.
  
  MFC after:2 weeks

Modified:
  head/sbin/hastd/hastd.c

Modified: head/sbin/hastd/hastd.c
==
--- head/sbin/hastd/hastd.c Tue Dec 10 20:06:41 2013(r259195)
+++ head/sbin/hastd/hastd.c Tue Dec 10 20:09:49 2013(r259196)
@@ -806,12 +806,6 @@ listen_accept(struct hastd_listen *lst)
 */
version = 1;
}
-   if (version  HAST_PROTO_VERSION) {
-   pjdlog_info(Remote protocol version %hhu is not supported, 
falling back to version %hhu.,
-   version, (unsigned char)HAST_PROTO_VERSION);
-   version = HAST_PROTO_VERSION;
-   }
-   pjdlog_debug(1, Negotiated protocol version %hhu., version);
token = nv_get_uint8_array(nvin, size, token);
/*
 * NULL token means that this is first connection.
@@ -925,6 +919,12 @@ listen_accept(struct hastd_listen *lst)
 */
 
if (token == NULL) {
+   if (version  HAST_PROTO_VERSION) {
+   pjdlog_info(Remote protocol version %hhu is not 
supported, falling back to version %hhu.,
+   version, (unsigned char)HAST_PROTO_VERSION);
+   version = HAST_PROTO_VERSION;
+   }
+   pjdlog_debug(1, Negotiated protocol version %hhu., version);
res-hr_version = version;
arc4random_buf(res-hr_token, sizeof(res-hr_token));
nvout = nv_alloc();
___
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: r258258 - head/sys/netinet

2013-11-17 Thread Mikolaj Golub
Author: trociny
Date: Sun Nov 17 15:09:39 2013
New Revision: 258258
URL: http://svnweb.freebsd.org/changeset/base/258258

Log:
  Deregister helper hooks on vnet destroy.

Modified:
  head/sys/netinet/tcp_subr.c

Modified: head/sys/netinet/tcp_subr.c
==
--- head/sys/netinet/tcp_subr.c Sun Nov 17 14:44:22 2013(r258257)
+++ head/sys/netinet/tcp_subr.c Sun Nov 17 15:09:39 2013(r258258)
@@ -432,6 +432,7 @@ tcp_init(void)
 void
 tcp_destroy(void)
 {
+   int error;
 
tcp_reass_destroy();
tcp_hc_destroy();
@@ -440,6 +441,19 @@ tcp_destroy(void)
in_pcbinfo_destroy(V_tcbinfo);
uma_zdestroy(V_sack_hole_zone);
uma_zdestroy(V_tcpcb_zone);
+
+   error = hhook_head_deregister(V_tcp_hhh[HHOOK_TCP_EST_IN]);
+   if (error != 0) {
+   printf(%s: WARNING: unable to deregister helper hook 
+   type=%d, id=%d: error %d returned\n, __func__,
+   HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN, error);
+   }
+   error = hhook_head_deregister(V_tcp_hhh[HHOOK_TCP_EST_OUT]);
+   if (error != 0) {
+   printf(%s: WARNING: unable to deregister helper hook 
+   type=%d, id=%d: error %d returned\n, __func__,
+   HHOOK_TYPE_TCP, HHOOK_TCP_EST_OUT, error);
+   }
 }
 #endif
 
___
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: r257465 - head/share/misc

2013-10-31 Thread Mikolaj Golub
Author: trociny
Date: Thu Oct 31 19:55:36 2013
New Revision: 257465
URL: http://svnweb.freebsd.org/changeset/base/257465

Log:
  Add myself as a ports committer
  
  Approved by:  bdrewery (mentor)

Modified:
  head/share/misc/committers-ports.dot

Modified: head/share/misc/committers-ports.dot
==
--- head/share/misc/committers-ports.dotThu Oct 31 18:53:39 2013
(r257464)
+++ head/share/misc/committers-ports.dotThu Oct 31 19:55:36 2013
(r257465)
@@ -207,6 +207,7 @@ tmclaugh [label=Tom McLaughlin\ntmclaug
 tota [label=TAKATSU Tomonari\nt...@freebsd.org\n2009/03/30]
 trasz [label=Edward Tomasz Napierala\ntr...@freebsd.org\n2007/04/12]
 trhodes [label=Tom Rhodes\ntrho...@freebsd.org\n2004/07/06]
+trociny [label=Mikolaj Golub\ntroc...@freebsd.org\n2013/10/17]
 uqs [label=Ulrich Spoerlein\n...@freebsd.org\n2012/01/19]
 vd [label=Vasil Dimov\n...@freebsd.org\n2006/01/19]
 vg [label=Veniamin Gvozdikov\n...@freebsd.org\n2013/06/11]
@@ -246,6 +247,7 @@ avilla - jhale
 avilla - rakuco
 
 bdrewery - dbn
+bdrewery - trociny
 
 bapt - bdrewery
 bapt - eadler
___
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: r257468 - stable/10/sbin/hastd

2013-10-31 Thread Mikolaj Golub
Author: trociny
Date: Thu Oct 31 20:30:26 2013
New Revision: 257468
URL: http://svnweb.freebsd.org/changeset/base/257468

Log:
  MFC r257154:
  
  Merging local and remote bitmaps must be protected by hr_amp lock.
  
  This is believed to fix hastd crashes, which might occur during
  synchronization, triggered by the failed assertion:
  
   Assertion failed: (amp-am_memtab[ext]  0),
   function activemap_write_complete, file activemap.c, line 351.
  
  Approved by:  re (glebius)

Modified:
  stable/10/sbin/hastd/primary.c
Directory Properties:
  stable/10/sbin/hastd/   (props changed)

Modified: stable/10/sbin/hastd/primary.c
==
--- stable/10/sbin/hastd/primary.c  Thu Oct 31 20:12:37 2013
(r257467)
+++ stable/10/sbin/hastd/primary.c  Thu Oct 31 20:30:26 2013
(r257468)
@@ -781,6 +781,7 @@ init_remote(struct hast_resource *res, s
free(map);
goto close;
}
+   mtx_lock(res-hr_amp_lock);
/*
 * Merge local and remote bitmaps.
 */
@@ -790,7 +791,6 @@ init_remote(struct hast_resource *res, s
 * Now that we merged bitmaps from both nodes, flush it to the
 * disk before we start to synchronize.
 */
-   mtx_lock(res-hr_amp_lock);
(void)hast_activemap_flush(res);
}
nv_free(nvin);
___
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: r257470 - stable/9/sbin/hastd

2013-10-31 Thread Mikolaj Golub
Author: trociny
Date: Thu Oct 31 20:31:16 2013
New Revision: 257470
URL: http://svnweb.freebsd.org/changeset/base/257470

Log:
  MFC r257154:
  
  Merging local and remote bitmaps must be protected by hr_amp lock.
  
  This is believed to fix hastd crashes, which might occur during
  synchronization, triggered by the failed assertion:
  
   Assertion failed: (amp-am_memtab[ext]  0),
   function activemap_write_complete, file activemap.c, line 351.

Modified:
  stable/9/sbin/hastd/primary.c
Directory Properties:
  stable/9/sbin/hastd/   (props changed)

Modified: stable/9/sbin/hastd/primary.c
==
--- stable/9/sbin/hastd/primary.c   Thu Oct 31 20:30:56 2013
(r257469)
+++ stable/9/sbin/hastd/primary.c   Thu Oct 31 20:31:16 2013
(r257470)
@@ -781,6 +781,7 @@ init_remote(struct hast_resource *res, s
free(map);
goto close;
}
+   mtx_lock(res-hr_amp_lock);
/*
 * Merge local and remote bitmaps.
 */
@@ -790,7 +791,6 @@ init_remote(struct hast_resource *res, s
 * Now that we merged bitmaps from both nodes, flush it to the
 * disk before we start to synchronize.
 */
-   mtx_lock(res-hr_amp_lock);
(void)hast_activemap_flush(res);
}
nv_free(nvin);
___
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: r257471 - stable/8/sbin/hastd

2013-10-31 Thread Mikolaj Golub
Author: trociny
Date: Thu Oct 31 20:32:11 2013
New Revision: 257471
URL: http://svnweb.freebsd.org/changeset/base/257471

Log:
  MFC r257154:
  
  Merging local and remote bitmaps must be protected by hr_amp lock.
  
  This is believed to fix hastd crashes, which might occur during
  synchronization, triggered by the failed assertion:
  
   Assertion failed: (amp-am_memtab[ext]  0),
   function activemap_write_complete, file activemap.c, line 351.

Modified:
  stable/8/sbin/hastd/primary.c
Directory Properties:
  stable/8/sbin/hastd/   (props changed)

Modified: stable/8/sbin/hastd/primary.c
==
--- stable/8/sbin/hastd/primary.c   Thu Oct 31 20:31:16 2013
(r257470)
+++ stable/8/sbin/hastd/primary.c   Thu Oct 31 20:32:11 2013
(r257471)
@@ -781,6 +781,7 @@ init_remote(struct hast_resource *res, s
free(map);
goto close;
}
+   mtx_lock(res-hr_amp_lock);
/*
 * Merge local and remote bitmaps.
 */
@@ -790,7 +791,6 @@ init_remote(struct hast_resource *res, s
 * Now that we merged bitmaps from both nodes, flush it to the
 * disk before we start to synchronize.
 */
-   mtx_lock(res-hr_amp_lock);
(void)hast_activemap_flush(res);
}
nv_free(nvin);
___
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: r257154 - head/sbin/hastd

2013-10-26 Thread Mikolaj Golub
Author: trociny
Date: Sat Oct 26 08:35:54 2013
New Revision: 257154
URL: http://svnweb.freebsd.org/changeset/base/257154

Log:
  Merging local and remote bitmaps must be protected by hr_amp lock.
  
  This is believed to fix hastd crashes, which might occur during
  synchronization, triggered by the failed assertion:
  
   Assertion failed: (amp-am_memtab[ext]  0),
   function activemap_write_complete, file activemap.c, line 351.
  
  MFC after:1 week

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Sat Oct 26 08:34:35 2013(r257153)
+++ head/sbin/hastd/primary.c   Sat Oct 26 08:35:54 2013(r257154)
@@ -781,6 +781,7 @@ init_remote(struct hast_resource *res, s
free(map);
goto close;
}
+   mtx_lock(res-hr_amp_lock);
/*
 * Merge local and remote bitmaps.
 */
@@ -790,7 +791,6 @@ init_remote(struct hast_resource *res, s
 * Now that we merged bitmaps from both nodes, flush it to the
 * disk before we start to synchronize.
 */
-   mtx_lock(res-hr_amp_lock);
(void)hast_activemap_flush(res);
}
nv_free(nvin);
___
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: r257155 - in head/sbin: hastctl hastd

2013-10-26 Thread Mikolaj Golub
Author: trociny
Date: Sat Oct 26 08:38:21 2013
New Revision: 257155
URL: http://svnweb.freebsd.org/changeset/base/257155

Log:
  Make hastctl list command output current queue sizes.
  
  Reviewed by:  pjd
  MFC after:1 month

Modified:
  head/sbin/hastctl/hastctl.c
  head/sbin/hastd/control.c
  head/sbin/hastd/hast.h
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastctl/hastctl.c
==
--- head/sbin/hastctl/hastctl.c Sat Oct 26 08:35:54 2013(r257154)
+++ head/sbin/hastctl/hastctl.c Sat Oct 26 08:38:21 2013(r257155)
@@ -355,6 +355,13 @@ control_list(struct nv *nv)
(uintmax_t)nv_get_uint64(nv, stat_write_error%u, ii),
(uintmax_t)nv_get_uint64(nv, stat_delete_error%u, ii),
(uintmax_t)nv_get_uint64(nv, stat_flush_error%u, ii));
+   printf(queues: 
+   local: %ju, send: %ju, recv: %ju, done: %ju, idle: %ju\n,
+   (uintmax_t)nv_get_uint64(nv, local_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, send_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, recv_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, done_queue_size%u, ii),
+   (uintmax_t)nv_get_uint64(nv, idle_queue_size%u, ii));
}
return (ret);
 }

Modified: head/sbin/hastd/control.c
==
--- head/sbin/hastd/control.c   Sat Oct 26 08:35:54 2013(r257154)
+++ head/sbin/hastd/control.c   Sat Oct 26 08:38:21 2013(r257155)
@@ -215,6 +215,16 @@ control_status_worker(struct hast_resour
stat_delete_error%u, no);
nv_add_uint64(nvout, nv_get_uint64(cnvin, stat_flush_error),
stat_flush_error%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, idle_queue_size),
+   idle_queue_size%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, local_queue_size),
+   local_queue_size%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, send_queue_size),
+   send_queue_size%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, recv_queue_size),
+   recv_queue_size%u, no);
+   nv_add_uint64(nvout, nv_get_uint64(cnvin, done_queue_size),
+   done_queue_size%u, no);
 end:
if (cnvin != NULL)
nv_free(cnvin);
@@ -478,6 +488,7 @@ ctrl_thread(void *arg)
nv_add_uint64(nvout, res-hr_stat_flush_error +
res-hr_stat_activemap_flush_error,
stat_flush_error);
+   res-output_status_aux(nvout);
nv_add_int16(nvout, 0, error);
break;
case CONTROL_RELOAD:

Modified: head/sbin/hastd/hast.h
==
--- head/sbin/hastd/hast.h  Sat Oct 26 08:35:54 2013(r257154)
+++ head/sbin/hastd/hast.h  Sat Oct 26 08:38:21 2013(r257155)
@@ -137,6 +137,8 @@ struct hastd_config {
 #defineHAST_CHECKSUM_CRC32 1
 #defineHAST_CHECKSUM_SHA2562
 
+struct nv;
+
 /*
  * Structure that describes single resource.
  */
@@ -254,6 +256,9 @@ struct hast_resource {
/* Number of activemap flush errors. */
uint64_thr_stat_activemap_flush_error;
 
+   /* Function to output worker specific info on control status request. */
+   void(*output_status_aux)(struct nv *);
+
/* Next resource. */
TAILQ_ENTRY(hast_resource) hr_next;
 };

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Sat Oct 26 08:35:54 2013(r257154)
+++ head/sbin/hastd/primary.c   Sat Oct 26 08:38:21 2013(r257155)
@@ -108,6 +108,7 @@ struct hio {
  * until some in-progress requests are freed.
  */
 static TAILQ_HEAD(, hio) hio_free_list;
+static size_t hio_free_list_size;
 static pthread_mutex_t hio_free_list_lock;
 static pthread_cond_t hio_free_list_cond;
 /*
@@ -116,20 +117,26 @@ static pthread_cond_t hio_free_list_cond
  * responsible for managing his own send list.
  */
 static TAILQ_HEAD(, hio) *hio_send_list;
+static size_t *hio_send_list_size;
 static pthread_mutex_t *hio_send_list_lock;
 static pthread_cond_t *hio_send_list_cond;
+#definehio_send_local_list_sizehio_send_list_size[0]
+#definehio_send_remote_list_size   hio_send_list_size[1]
 /*
  * There is one recv list for every component, although local components don't
  * use recv lists as local requests are done synchronously.
  */
 static TAILQ_HEAD(, hio) *hio_recv_list;
+static size_t *hio_recv_list_size;
 static pthread_mutex_t *hio_recv_list_lock;
 static pthread_cond_t *hio_recv_list_cond;
+#define

Re: svn commit: r228969 - head/sys/netinet

2013-10-17 Thread Mikolaj Golub
On Wed, Oct 16, 2013 at 05:09:04PM -0400, John Baldwin wrote:
...
#10 0x80b6f1fd in igmp_change_state (inm=0x8ae70480)
at /home/golub/freebsd/base/head/sys/netinet/igmp.c:2595
#11 0x80b76f68 in in_leavegroup_locked (inm=0x8ae70480, imf=0x8a655a00)
at /home/golub/freebsd/base/head/sys/netinet/in_mcast.c:1239
#12 0x80b76fbd in in_leavegroup (inm=0x8ae70480, imf=0x8a655a00)
at /home/golub/freebsd/base/head/sys/netinet/in_mcast.c:1184
#13 0x80b770b4 in inp_gcmoptions (context=0x0, pending=1)
at /home/golub/freebsd/base/head/sys/netinet/in_mcast.c:1554
#14 0x80a8ff2b in taskqueue_run_locked (queue=0x87594880)
at /home/golub/freebsd/base/head/sys/kern/subr_taskqueue.c:308
#15 0x80a90987 in taskqueue_thread_loop (arg=0x81186bcc)
at /home/golub/freebsd/base/head/sys/kern/subr_taskqueue.c:497
#16 0x80a1b2d8 in fork_exit (callout=0x80a90920
taskqueue_thread_loop, arg=0x81186bcc,
frame=0x872b2d28) at 
  /home/golub/freebsd/base/head/sys/kern/kern_fork.c:992
...
VNET context is not set at that point.
...
 
 I think this was just fixed by glebius@ in r256587:
 
 Author: glebius
 Date: Wed Oct 16 05:02:01 2013
 New Revision: 256587
 URL: http://svnweb.freebsd.org/changeset/base/256587
 
 Log:
   For VIMAGE kernels store vnet in the struct task, and set vnet context
   during task processing.
   
   Reported  tested by: mm

I think that particular issue was fixed earlier by hrs in r252510:

  Fix a panic when leaving MC group in a kernel with VIMAGE enabled.
  in_leavegroup() is called from an asynchronous task, and
  igmp_change_state() requires that curvnet is set by the caller.

Concerning this more general solution from Gleb, with storing the vnet
pointer in the task, I wander how it is safe when the vnet is being
removed?

In vnet_destroy() the vnet interfaces are moved back to their parent
vnets, so setting the vnet context from the interface looks safer.

-- 
Mikolaj Golub
___
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: r256025 - stable/9/usr.sbin/daemon

2013-10-03 Thread Mikolaj Golub
Author: trociny
Date: Thu Oct  3 18:48:43 2013
New Revision: 256025
URL: http://svnweb.freebsd.org/changeset/base/256025

Log:
  MFC r255521, r255526, r255707:
  
  r255521 (jmg):
  
  add support for writing the pid of the daemon program to a pid file so
  that daemon can be used w/ rc.subr and ports can use the additional
  functionality, such as keeping the ldap daemon up and running, and have
  the proper program to signal to exit..
  
  PR:   bin/181341
  Submitted by: feld
  
  r255526 (joel):
  
  mdoc: remove EOL whitespace.
  
  r255707:
  
  1. Properly clean pid files in the case of the error.
  2. Write the supervisor pid before the restart loop, so we don't
 uselessly rewrite it after every child restart.
  3. Remove duplicate ppfh and pfh initialization.

Modified:
  stable/9/usr.sbin/daemon/daemon.8
  stable/9/usr.sbin/daemon/daemon.c
Directory Properties:
  stable/9/usr.sbin/daemon/   (props changed)

Modified: stable/9/usr.sbin/daemon/daemon.8
==
--- stable/9/usr.sbin/daemon/daemon.8   Thu Oct  3 17:50:14 2013
(r256024)
+++ stable/9/usr.sbin/daemon/daemon.8   Thu Oct  3 18:48:43 2013
(r256025)
@@ -26,7 +26,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd June 4, 2012
+.Dd September 13, 2013
 .Dt DAEMON 8
 .Os
 .Sh NAME
@@ -35,7 +35,8 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl cfr
-.Op Fl p Ar pidfile
+.Op Fl p Ar child_pidfile
+.Op Fl P Ar supervisor_pidfile
 .Op Fl u Ar user
 .Ar command arguments ...
 .Sh DESCRIPTION
@@ -53,19 +54,39 @@ Change the current working directory to 
 .It Fl f
 Redirect standard input, standard output and standard error to
 .Pa /dev/null .
-.It Fl p Ar file
+.It Fl p Ar child_pidfile
 Write the ID of the created process into the
-.Ar file
+.Ar child_pidfile
 using the
 .Xr pidfile 3
 functionality.
 The program is executed in a spawned child process while the
 .Nm
 waits until it terminates to keep the
-.Ar file
+.Ar child_pidfile
 locked and removes it after the process exits.
 The
-.Ar file
+.Ar child_pidfile
+owner is the user who runs the
+.Nm
+regardless of whether the
+.Fl u
+option is used or not.
+.It Fl P Ar supervisor_pidfile
+Write the ID of the
+.Nm
+process into the
+.Ar supervisor_pidfile
+using the
+.Xr pidfile 3
+functionality.
+The program is executed in a spawned child process while the
+.Nm
+waits until it terminates to keep the
+.Ar supervisor_pidfile
+locked and removes it after the process exits.
+The
+.Ar supervisor_pidfile
 owner is the user who runs the
 .Nm
 regardless of whether the
@@ -79,27 +100,46 @@ Requires adequate superuser privileges.
 .El
 .Pp
 If the
-.Fl p
+.Fl p ,
+.Fl P
 or
 .Fl r
 option is specified the program is executed in a spawned child process.
 The
 .Nm
-waits until it terminates to keep the pid file locked and removes it
+waits until it terminates to keep the pid file(s) locked and removes them
 after the process exits or restarts the program.
 In this case if the monitoring
 .Nm
 receives software termination signal (SIGTERM) it forwards it to the
 spawned process.
-Normally it will cause the child to exit followed by the termination
-of the supervising process after removing the pidfile.
+Normally it will cause the child to exit, remove the pidfile(s)
+and then terminate.
+.Pp
+The
+.Fl P
+option is useful combined with the
+.Fl r
+option as
+.Ar supervisor_pidfile
+contains the ID of the supervisor
+not the child. This is especially important if you use
+.Fl r
+in an rc script as the
+.Fl p
+option will give you the child's ID to signal when you attempt to
+stop the service, causing
+.Nm
+to restart the child.
 .Sh EXIT STATUS
 The
 .Nm
 utility exits 1 if an error is returned by the
 .Xr daemon 3
-library routine, 2 if the
-.Ar pidfile
+library routine, 2 if
+.Ar child_pidfile
+or
+.Ar supervisor_pidfile
 is requested, but cannot be opened, 3 if process is already running (pidfile
 exists and is locked),
 otherwise 0.

Modified: stable/9/usr.sbin/daemon/daemon.c
==
--- stable/9/usr.sbin/daemon/daemon.c   Thu Oct  3 17:50:14 2013
(r256024)
+++ stable/9/usr.sbin/daemon/daemon.c   Thu Oct  3 18:48:43 2013
(r256025)
@@ -53,16 +53,16 @@ static void usage(void);
 int
 main(int argc, char *argv[])
 {
-   struct pidfh *pfh = NULL;
+   struct pidfh  *ppfh, *pfh;
sigset_t mask, oldmask;
-   int ch, nochdir, noclose, restart;
-   const char *pidfile, *user;
+   int ch, nochdir, noclose, restart, serrno;
+   const char *pidfile, *ppidfile,  *user;
pid_t otherpid, pid;
 
nochdir = noclose = 1;
restart = 0;
-   pidfile = user = NULL;
-   while ((ch = getopt(argc, argv, cfp:ru:)) != -1) {
+   ppidfile = pidfile = user = NULL;
+   while ((ch = getopt(argc, argv, cfp:P:ru:)) != -1) {
switch (ch) {
case 'c':
nochdir = 0;
@@ -73,6 +73,9 

svn commit: r256026 - stable/8/usr.sbin/daemon

2013-10-03 Thread Mikolaj Golub
Author: trociny
Date: Thu Oct  3 18:50:09 2013
New Revision: 256026
URL: http://svnweb.freebsd.org/changeset/base/256026

Log:
  MFC r255521, r255526, r255707:
  
  r255521 (jmg):
  
  add support for writing the pid of the daemon program to a pid file so
  that daemon can be used w/ rc.subr and ports can use the additional
  functionality, such as keeping the ldap daemon up and running, and have
  the proper program to signal to exit.
  
  PR:   bin/181341
  Submitted by: feld
  
  r255526 (joel):
  
  mdoc: remove EOL whitespace.
  
  r255707:
  
  1. Properly clean pid files in the case of the error.
  2. Write the supervisor pid before the restart loop, so we don't
 uselessly rewrite it after every child restart.
  3. Remove duplicate ppfh and pfh initialization.

Modified:
  stable/8/usr.sbin/daemon/daemon.8
  stable/8/usr.sbin/daemon/daemon.c
Directory Properties:
  stable/8/usr.sbin/daemon/   (props changed)

Modified: stable/8/usr.sbin/daemon/daemon.8
==
--- stable/8/usr.sbin/daemon/daemon.8   Thu Oct  3 18:48:43 2013
(r256025)
+++ stable/8/usr.sbin/daemon/daemon.8   Thu Oct  3 18:50:09 2013
(r256026)
@@ -26,7 +26,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd June 4, 2012
+.Dd September 13, 2013
 .Dt DAEMON 8
 .Os
 .Sh NAME
@@ -35,7 +35,8 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl cfr
-.Op Fl p Ar pidfile
+.Op Fl p Ar child_pidfile
+.Op Fl P Ar supervisor_pidfile
 .Op Fl u Ar user
 .Ar command arguments ...
 .Sh DESCRIPTION
@@ -53,19 +54,39 @@ Change the current working directory to 
 .It Fl f
 Redirect standard input, standard output and standard error to
 .Pa /dev/null .
-.It Fl p Ar file
+.It Fl p Ar child_pidfile
 Write the ID of the created process into the
-.Ar file
+.Ar child_pidfile
 using the
 .Xr pidfile 3
 functionality.
 The program is executed in a spawned child process while the
 .Nm
 waits until it terminates to keep the
-.Ar file
+.Ar child_pidfile
 locked and removes it after the process exits.
 The
-.Ar file
+.Ar child_pidfile
+owner is the user who runs the
+.Nm
+regardless of whether the
+.Fl u
+option is used or not.
+.It Fl P Ar supervisor_pidfile
+Write the ID of the
+.Nm
+process into the
+.Ar supervisor_pidfile
+using the
+.Xr pidfile 3
+functionality.
+The program is executed in a spawned child process while the
+.Nm
+waits until it terminates to keep the
+.Ar supervisor_pidfile
+locked and removes it after the process exits.
+The
+.Ar supervisor_pidfile
 owner is the user who runs the
 .Nm
 regardless of whether the
@@ -79,27 +100,46 @@ Requires adequate superuser privileges.
 .El
 .Pp
 If the
-.Fl p
+.Fl p ,
+.Fl P
 or
 .Fl r
 option is specified the program is executed in a spawned child process.
 The
 .Nm
-waits until it terminates to keep the pid file locked and removes it
+waits until it terminates to keep the pid file(s) locked and removes them
 after the process exits or restarts the program.
 In this case if the monitoring
 .Nm
 receives software termination signal (SIGTERM) it forwards it to the
 spawned process.
-Normally it will cause the child to exit followed by the termination
-of the supervising process after removing the pidfile.
+Normally it will cause the child to exit, remove the pidfile(s)
+and then terminate.
+.Pp
+The
+.Fl P
+option is useful combined with the
+.Fl r
+option as
+.Ar supervisor_pidfile
+contains the ID of the supervisor
+not the child. This is especially important if you use
+.Fl r
+in an rc script as the
+.Fl p
+option will give you the child's ID to signal when you attempt to
+stop the service, causing
+.Nm
+to restart the child.
 .Sh EXIT STATUS
 The
 .Nm
 utility exits 1 if an error is returned by the
 .Xr daemon 3
-library routine, 2 if the
-.Ar pidfile
+library routine, 2 if
+.Ar child_pidfile
+or
+.Ar supervisor_pidfile
 is requested, but cannot be opened, 3 if process is already running (pidfile
 exists and is locked),
 otherwise 0.

Modified: stable/8/usr.sbin/daemon/daemon.c
==
--- stable/8/usr.sbin/daemon/daemon.c   Thu Oct  3 18:48:43 2013
(r256025)
+++ stable/8/usr.sbin/daemon/daemon.c   Thu Oct  3 18:50:09 2013
(r256026)
@@ -53,16 +53,16 @@ static void usage(void);
 int
 main(int argc, char *argv[])
 {
-   struct pidfh *pfh = NULL;
+   struct pidfh  *ppfh, *pfh;
sigset_t mask, oldmask;
-   int ch, nochdir, noclose, restart;
-   const char *pidfile, *user;
+   int ch, nochdir, noclose, restart, serrno;
+   const char *pidfile, *ppidfile,  *user;
pid_t otherpid, pid;
 
nochdir = noclose = 1;
restart = 0;
-   pidfile = user = NULL;
-   while ((ch = getopt(argc, argv, cfp:ru:)) != -1) {
+   ppidfile = pidfile = user = NULL;
+   while ((ch = getopt(argc, argv, cfp:P:ru:)) != -1) {
switch (ch) {
case 'c':
nochdir = 0;
@@ -73,6 +73,9 

svn commit: r256027 - stable/9/sbin/hastd

2013-10-03 Thread Mikolaj Golub
Author: trociny
Date: Thu Oct  3 18:52:04 2013
New Revision: 256027
URL: http://svnweb.freebsd.org/changeset/base/256027

Log:
  MFC r255714, r255716, r255717:
  
  r255714:
  
  Use cv_broadcast() instead of cv_signal() when waking up threads
  waiting on an empty queue as the queue may have several consumers.
  
  Before the fix the following scenario was possible: 2 threads are
  waiting on empty queue, 2 threads are inserting simultaneously. The
  first inserting thread detects that the queue is empty and is going to
  send the signal, but before it sends the second thread inserts
  too. When the first sends the signal only one of the waiting threads
  receive it while the other one may wait forever.
  
  The scenario above is is believed to be the cause of the observed
  cases, when ggate_recv_thread() was getting stuck on taking free
  request, while the free queue was not empty.
  
  Reviewed by:  pjd
  Tested by:Yamagi Burmeister yamagi.org
  
  r255716:
  
  When updating the map of dirty extents, most recently used extents are
  kept dirty to reduce the number of on-disk metadata updates. The
  sequence of operations is:
  
  1) acquire the activemap lock;
  2) update in-memory map;
  3) if the list of keepdirty extents is changed, update on-disk metadata;
  4) release the lock.
  
  On-disk updates are not frequent in comparison with in-memory updates,
  while require much more time. So situations are possible when one
  thread is updating on-disk metadata and another one is waiting for the
  activemap lock just to update the in-memory map.
  
  Improve this by introducing additional, on-disk map lock: when
  in-memory map is updated and it is detected that the on-disk map needs
  update too, the on-disk map lock is acquired and the on-memory lock is
  released before flushing the map.
  
  Reported by:  Yamagi Burmeister yamagi.org
  Tested by:Yamagi Burmeister yamagi.org
  Reviewed by:  pjd
  
  r255717:
  
  Fix comments.

Modified:
  stable/9/sbin/hastd/hast.h
  stable/9/sbin/hastd/primary.c
  stable/9/sbin/hastd/secondary.c
Directory Properties:
  stable/9/sbin/hastd/   (props changed)

Modified: stable/9/sbin/hastd/hast.h
==
--- stable/9/sbin/hastd/hast.h  Thu Oct  3 18:50:09 2013(r256026)
+++ stable/9/sbin/hastd/hast.h  Thu Oct  3 18:52:04 2013(r256027)
@@ -226,8 +226,10 @@ struct hast_resource {
 
/* Activemap structure. */
struct activemap *hr_amp;
-   /* Locked used to synchronize access to hr_amp. */
+   /* Lock used to synchronize access to hr_amp. */
pthread_mutex_t hr_amp_lock;
+   /* Lock used to synchronize access to hr_amp diskmap. */
+   pthread_mutex_t hr_amp_diskmap_lock;
 
/* Number of BIO_READ requests. */
uint64_thr_stat_read;

Modified: stable/9/sbin/hastd/primary.c
==
--- stable/9/sbin/hastd/primary.c   Thu Oct  3 18:50:09 2013
(r256026)
+++ stable/9/sbin/hastd/primary.c   Thu Oct  3 18:52:04 2013
(r256027)
@@ -172,7 +172,7 @@ static pthread_mutex_t metadata_lock;
hio_next[(ncomp)]); \
mtx_unlock(hio_##name##_list_lock[ncomp]); \
if (_wakeup)\
-   cv_signal(hio_##name##_list_cond[(ncomp)]);\
+   cv_broadcast(hio_##name##_list_cond[(ncomp)]); \
 } while (0)
 #defineQUEUE_INSERT2(hio, name)do {
\
bool _wakeup;   \
@@ -182,7 +182,7 @@ static pthread_mutex_t metadata_lock;
TAILQ_INSERT_TAIL(hio_##name##_list, (hio), hio_##name##_next);\
mtx_unlock(hio_##name##_list_lock);\
if (_wakeup)\
-   cv_signal(hio_##name##_list_cond); \
+   cv_broadcast(hio_##name##_list_cond);  \
 } while (0)
 #defineQUEUE_TAKE1(hio, name, ncomp, timeout)  do {
\
bool _last; \
@@ -291,22 +291,28 @@ primary_exitx(int exitcode, const char *
exit(exitcode);
 }
 
+/* Expects res-hr_amp locked, returns unlocked. */
 static int
 hast_activemap_flush(struct hast_resource *res)
 {
const unsigned char *buf;
size_t size;
+   int ret;
 
+   mtx_lock(res-hr_amp_diskmap_lock);
buf = activemap_bitmap(res-hr_amp, size);
+   mtx_unlock(res-hr_amp_lock);
PJDLOG_ASSERT(buf != NULL);
PJDLOG_ASSERT((size % res-hr_local_sectorsize) == 0);
+   ret = 0;
if (pwrite(res-hr_localfd, buf, size, METADATA_SIZE) !=
(ssize_t)size) {

svn commit: r256028 - stable/8/sbin/hastd

2013-10-03 Thread Mikolaj Golub
Author: trociny
Date: Thu Oct  3 18:53:13 2013
New Revision: 256028
URL: http://svnweb.freebsd.org/changeset/base/256028

Log:
  MFC r255714, r255716, r255717:
  
  r255714:
  
  Use cv_broadcast() instead of cv_signal() when waking up threads
  waiting on an empty queue as the queue may have several consumers.
  
  Before the fix the following scenario was possible: 2 threads are
  waiting on empty queue, 2 threads are inserting simultaneously. The
  first inserting thread detects that the queue is empty and is going to
  send the signal, but before it sends the second thread inserts
  too. When the first sends the signal only one of the waiting threads
  receive it while the other one may wait forever.
  
  The scenario above is is believed to be the cause of the observed
  cases, when ggate_recv_thread() was getting stuck on taking free
  request, while the free queue was not empty.
  
  Reviewed by:  pjd
  Tested by:Yamagi Burmeister yamagi.org
  
  r255716:
  
  When updating the map of dirty extents, most recently used extents are
  kept dirty to reduce the number of on-disk metadata updates. The
  sequence of operations is:
  
  1) acquire the activemap lock;
  2) update in-memory map;
  3) if the list of keepdirty extents is changed, update on-disk metadata;
  4) release the lock.
  
  On-disk updates are not frequent in comparison with in-memory updates,
  while require much more time. So situations are possible when one
  thread is updating on-disk metadata and another one is waiting for the
  activemap lock just to update the in-memory map.
  
  Improve this by introducing additional, on-disk map lock: when
  in-memory map is updated and it is detected that the on-disk map needs
  update too, the on-disk map lock is acquired and the on-memory lock is
  released before flushing the map.
  
  Reported by:  Yamagi Burmeister yamagi.org
  Tested by:Yamagi Burmeister yamagi.org
  Reviewed by:  pjd
  
  r255717:
  
  Fix comments.

Modified:
  stable/8/sbin/hastd/hast.h
  stable/8/sbin/hastd/primary.c
  stable/8/sbin/hastd/secondary.c
Directory Properties:
  stable/8/sbin/hastd/   (props changed)

Modified: stable/8/sbin/hastd/hast.h
==
--- stable/8/sbin/hastd/hast.h  Thu Oct  3 18:52:04 2013(r256027)
+++ stable/8/sbin/hastd/hast.h  Thu Oct  3 18:53:13 2013(r256028)
@@ -226,8 +226,10 @@ struct hast_resource {
 
/* Activemap structure. */
struct activemap *hr_amp;
-   /* Locked used to synchronize access to hr_amp. */
+   /* Lock used to synchronize access to hr_amp. */
pthread_mutex_t hr_amp_lock;
+   /* Lock used to synchronize access to hr_amp diskmap. */
+   pthread_mutex_t hr_amp_diskmap_lock;
 
/* Number of BIO_READ requests. */
uint64_thr_stat_read;

Modified: stable/8/sbin/hastd/primary.c
==
--- stable/8/sbin/hastd/primary.c   Thu Oct  3 18:52:04 2013
(r256027)
+++ stable/8/sbin/hastd/primary.c   Thu Oct  3 18:53:13 2013
(r256028)
@@ -172,7 +172,7 @@ static pthread_mutex_t metadata_lock;
hio_next[(ncomp)]); \
mtx_unlock(hio_##name##_list_lock[ncomp]); \
if (_wakeup)\
-   cv_signal(hio_##name##_list_cond[(ncomp)]);\
+   cv_broadcast(hio_##name##_list_cond[(ncomp)]); \
 } while (0)
 #defineQUEUE_INSERT2(hio, name)do {
\
bool _wakeup;   \
@@ -182,7 +182,7 @@ static pthread_mutex_t metadata_lock;
TAILQ_INSERT_TAIL(hio_##name##_list, (hio), hio_##name##_next);\
mtx_unlock(hio_##name##_list_lock);\
if (_wakeup)\
-   cv_signal(hio_##name##_list_cond); \
+   cv_broadcast(hio_##name##_list_cond);  \
 } while (0)
 #defineQUEUE_TAKE1(hio, name, ncomp, timeout)  do {
\
bool _last; \
@@ -291,22 +291,28 @@ primary_exitx(int exitcode, const char *
exit(exitcode);
 }
 
+/* Expects res-hr_amp locked, returns unlocked. */
 static int
 hast_activemap_flush(struct hast_resource *res)
 {
const unsigned char *buf;
size_t size;
+   int ret;
 
+   mtx_lock(res-hr_amp_diskmap_lock);
buf = activemap_bitmap(res-hr_amp, size);
+   mtx_unlock(res-hr_amp_lock);
PJDLOG_ASSERT(buf != NULL);
PJDLOG_ASSERT((size % res-hr_local_sectorsize) == 0);
+   ret = 0;
if (pwrite(res-hr_localfd, buf, size, METADATA_SIZE) !=
(ssize_t)size) {

svn commit: r255707 - head/usr.sbin/daemon

2013-09-19 Thread Mikolaj Golub
Author: trociny
Date: Thu Sep 19 18:00:05 2013
New Revision: 255707
URL: http://svnweb.freebsd.org/changeset/base/255707

Log:
  1. Properly clean pid files in the case of the error.
  2. Write the supervisor pid before the restart loop, so we don't
 uselessly rewrite it after every child restart.
  3. Remove duplicate ppfh and pfh initialization.
  
  Approved by:  re (glebius)
  MFC after:2 weeks

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

Modified: head/usr.sbin/daemon/daemon.c
==
--- head/usr.sbin/daemon/daemon.c   Thu Sep 19 16:22:05 2013
(r255706)
+++ head/usr.sbin/daemon/daemon.c   Thu Sep 19 18:00:05 2013
(r255707)
@@ -55,13 +55,12 @@ main(int argc, char *argv[])
 {
struct pidfh  *ppfh, *pfh;
sigset_t mask, oldmask;
-   int ch, nochdir, noclose, restart;
+   int ch, nochdir, noclose, restart, serrno;
const char *pidfile, *ppidfile,  *user;
pid_t otherpid, pid;
 
nochdir = noclose = 1;
restart = 0;
-   ppfh = pfh = NULL;
ppidfile = pidfile = user = NULL;
while ((ch = getopt(argc, argv, cfp:P:ru:)) != -1) {
switch (ch) {
@@ -108,11 +107,13 @@ main(int argc, char *argv[])
err(2, pidfile ``%s'', pidfile);
}
}
-   
-   /* do same for actual daemon process */
+   /* Do the same for actual daemon process. */
if (ppidfile != NULL) {
ppfh = pidfile_open(ppidfile, 0600, otherpid);
if (ppfh == NULL) {
+   serrno = errno;
+   pidfile_remove(pfh);
+   errno = serrno;
if (errno == EEXIST) {
errx(3, process already running, pid: %d,
 otherpid);
@@ -121,8 +122,12 @@ main(int argc, char *argv[])
}
}
 
-   if (daemon(nochdir, noclose) == -1)
-   err(1, NULL);
+   if (daemon(nochdir, noclose) == -1) {
+   warn(daemon);
+   goto exit;
+   }
+   /* Write out parent pidfile if needed. */
+   pidfile_write(ppfh);
 
/*
 * If the pidfile or restart option is specified the daemon
@@ -139,22 +144,28 @@ main(int argc, char *argv[])
 * Restore default action for SIGTERM in case the
 * parent process decided to ignore it.
 */
-   if (signal(SIGTERM, SIG_DFL) == SIG_ERR)
-   err(1, signal);
+   if (signal(SIGTERM, SIG_DFL) == SIG_ERR) {
+   warn(signal);
+   goto exit;
+   }
/*
 * Because SIGCHLD is ignored by default, setup dummy handler
 * for it, so we can mask it.
 */
-   if (signal(SIGCHLD, dummy_sighandler) == SIG_ERR)
-   err(1, signal);
+   if (signal(SIGCHLD, dummy_sighandler) == SIG_ERR) {
+   warn(signal);
+   goto exit;
+   }
/*
 * Block interesting signals.
 */
sigemptyset(mask);
sigaddset(mask, SIGTERM);
sigaddset(mask, SIGCHLD);
-   if (sigprocmask(SIG_SETMASK, mask, oldmask) == -1)
-   err(1, sigprocmask);
+   if (sigprocmask(SIG_SETMASK, mask, oldmask) == -1) {
+   warn(sigprocmask);
+   goto exit;
+   }
/*
 * Try to protect against pageout kill. Ignore the
 * error, madvise(2) will fail only if a process does
@@ -168,8 +179,8 @@ restart:
 */
pid = fork();
if (pid == -1) {
-   pidfile_remove(pfh);
-   err(1, fork);
+   warn(fork);
+   goto exit;
}
}
if (pid = 0) {
@@ -192,18 +203,16 @@ restart:
 */
err(1, %s, argv[0]);
}
-   /* write out parent pidfile if needed */
-   if (ppidfile != NULL)
-   pidfile_write(ppfh);
 
setproctitle(%s[%d], argv[0], pid);
if (wait_child(pid, mask) == 0  restart) {
sleep(1);
goto restart;
}
+exit:
pidfile_remove(pfh);
pidfile_remove(ppfh);
-   exit(0); /* Exit status does not matter. */
+   exit(1); /* If daemon(3) succeeded exit status does not matter. */
 }
 
 static void
___
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: r255717 - head/sbin/hastd

2013-09-19 Thread Mikolaj Golub
Author: trociny
Date: Thu Sep 19 20:20:59 2013
New Revision: 255717
URL: http://svnweb.freebsd.org/changeset/base/255717

Log:
  Fix comments.
  
  Approved by:  re (marius)
  MFC after:3 days

Modified:
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Thu Sep 19 20:19:08 2013(r255716)
+++ head/sbin/hastd/secondary.c Thu Sep 19 20:20:59 2013(r255717)
@@ -85,14 +85,13 @@ static TAILQ_HEAD(, hio) hio_free_list;
 static pthread_mutex_t hio_free_list_lock;
 static pthread_cond_t hio_free_list_cond;
 /*
- * Disk thread (the one that do I/O requests) takes requests from this list.
+ * Disk thread (the one that does I/O requests) takes requests from this list.
  */
 static TAILQ_HEAD(, hio) hio_disk_list;
 static pthread_mutex_t hio_disk_list_lock;
 static pthread_cond_t hio_disk_list_cond;
 /*
- * There is one recv list for every component, although local components don't
- * use recv lists as local requests are done synchronously.
+ * Thread that sends requests back to primary takes requests from this list.
  */
 static TAILQ_HEAD(, hio) hio_send_list;
 static pthread_mutex_t hio_send_list_lock;
___
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: r255716 - head/sbin/hastd

2013-09-19 Thread Mikolaj Golub
Author: trociny
Date: Thu Sep 19 20:19:08 2013
New Revision: 255716
URL: http://svnweb.freebsd.org/changeset/base/255716

Log:
  When updating the map of dirty extents, most recently used extents are
  kept dirty to reduce the number of on-disk metadata updates. The
  sequence of operations is:
  
  1) acquire the activemap lock;
  2) update in-memory map;
  3) if the list of keepdirty extents is changed, update on-disk metadata;
  4) release the lock.
  
  On-disk updates are not frequent in comparison with in-memory updates,
  while require much more time. So situations are possible when one
  thread is updating on-disk metadata and another one is waiting for the
  activemap lock just to update the in-memory map.
  
  Improve this by introducing additional, on-disk map lock: when
  in-memory map is updated and it is detected that the on-disk map needs
  update too, the on-disk map lock is acquired and the on-memory lock is
  released before flushing the map.
  
  Reported by:  Yamagi Burmeister yamagi.org
  Tested by:Yamagi Burmeister yamagi.org
  Reviewed by:  pjd
  Approved by:  re (marius)
  MFC after:2 weeks

Modified:
  head/sbin/hastd/hast.h
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/hast.h
==
--- head/sbin/hastd/hast.h  Thu Sep 19 20:17:50 2013(r255715)
+++ head/sbin/hastd/hast.h  Thu Sep 19 20:19:08 2013(r255716)
@@ -226,8 +226,10 @@ struct hast_resource {
 
/* Activemap structure. */
struct activemap *hr_amp;
-   /* Locked used to synchronize access to hr_amp. */
+   /* Lock used to synchronize access to hr_amp. */
pthread_mutex_t hr_amp_lock;
+   /* Lock used to synchronize access to hr_amp diskmap. */
+   pthread_mutex_t hr_amp_diskmap_lock;
 
/* Number of BIO_READ requests. */
uint64_thr_stat_read;

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Thu Sep 19 20:17:50 2013(r255715)
+++ head/sbin/hastd/primary.c   Thu Sep 19 20:19:08 2013(r255716)
@@ -291,22 +291,28 @@ primary_exitx(int exitcode, const char *
exit(exitcode);
 }
 
+/* Expects res-hr_amp locked, returns unlocked. */
 static int
 hast_activemap_flush(struct hast_resource *res)
 {
const unsigned char *buf;
size_t size;
+   int ret;
 
+   mtx_lock(res-hr_amp_diskmap_lock);
buf = activemap_bitmap(res-hr_amp, size);
+   mtx_unlock(res-hr_amp_lock);
PJDLOG_ASSERT(buf != NULL);
PJDLOG_ASSERT((size % res-hr_local_sectorsize) == 0);
+   ret = 0;
if (pwrite(res-hr_localfd, buf, size, METADATA_SIZE) !=
(ssize_t)size) {
pjdlog_errno(LOG_ERR, Unable to flush activemap to disk);
res-hr_stat_activemap_write_error++;
-   return (-1);
+   ret = -1;
}
-   if (res-hr_metaflush == 1  g_flush(res-hr_localfd) == -1) {
+   if (ret == 0  res-hr_metaflush == 1 
+   g_flush(res-hr_localfd) == -1) {
if (errno == EOPNOTSUPP) {
pjdlog_warning(The %s provider doesn't support 
flushing write cache. Disabling it.,
res-hr_localpath);
@@ -315,10 +321,11 @@ hast_activemap_flush(struct hast_resourc
pjdlog_errno(LOG_ERR,
Unable to flush disk cache on activemap update);
res-hr_stat_activemap_flush_error++;
-   return (-1);
+   ret = -1;
}
}
-   return (0);
+   mtx_unlock(res-hr_amp_diskmap_lock);
+   return (ret);
 }
 
 static bool
@@ -783,6 +790,7 @@ init_remote(struct hast_resource *res, s
 * Now that we merged bitmaps from both nodes, flush it to the
 * disk before we start to synchronize.
 */
+   mtx_lock(res-hr_amp_lock);
(void)hast_activemap_flush(res);
}
nv_free(nvin);
@@ -1288,8 +1296,9 @@ ggate_recv_thread(void *arg)
ggio-gctl_offset, ggio-gctl_length)) {
res-hr_stat_activemap_update++;
(void)hast_activemap_flush(res);
+   } else {
+   mtx_unlock(res-hr_amp_lock);
}
-   mtx_unlock(res-hr_amp_lock);
break;
case BIO_DELETE:
res-hr_stat_delete++;
@@ -1650,8 +1659,9 @@ done_queue:
if (activemap_need_sync(res-hr_amp, ggio-gctl_offset,
ggio-gctl_length)) {
(void)hast_activemap_flush(res);
+   } else {
+   

svn commit: r255714 - head/sbin/hastd

2013-09-19 Thread Mikolaj Golub
Author: trociny
Date: Thu Sep 19 20:15:24 2013
New Revision: 255714
URL: http://svnweb.freebsd.org/changeset/base/255714

Log:
  Use cv_broadcast() instead of cv_signal() when waking up threads
  waiting on an empty queue as the queue may have several consumers.
  
  Before the fix the following scenario was possible: 2 threads are
  waiting on empty queue, 2 threads are inserting simultaneously. The
  first inserting thread detects that the queue is empty and is going to
  send the signal, but before it sends the second thread inserts
  too. When the first sends the signal only one of the waiting threads
  receive it while the other one may wait forever.
  
  The scenario above is is believed to be the cause of the observed
  cases, when ggate_recv_thread() was getting stuck on taking free
  request, while the free queue was not empty.
  
  Reviewed by:  pjd
  Tested by:Yamagi Burmeister yamagi.org
  Approved by:  re (marius)
  MFC after:2 weeks

Modified:
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Thu Sep 19 20:09:56 2013(r255713)
+++ head/sbin/hastd/primary.c   Thu Sep 19 20:15:24 2013(r255714)
@@ -172,7 +172,7 @@ static pthread_mutex_t metadata_lock;
hio_next[(ncomp)]); \
mtx_unlock(hio_##name##_list_lock[ncomp]); \
if (_wakeup)\
-   cv_signal(hio_##name##_list_cond[(ncomp)]);\
+   cv_broadcast(hio_##name##_list_cond[(ncomp)]); \
 } while (0)
 #defineQUEUE_INSERT2(hio, name)do {
\
bool _wakeup;   \
@@ -182,7 +182,7 @@ static pthread_mutex_t metadata_lock;
TAILQ_INSERT_TAIL(hio_##name##_list, (hio), hio_##name##_next);\
mtx_unlock(hio_##name##_list_lock);\
if (_wakeup)\
-   cv_signal(hio_##name##_list_cond); \
+   cv_broadcast(hio_##name##_list_cond);  \
 } while (0)
 #defineQUEUE_TAKE1(hio, name, ncomp, timeout)  do {
\
bool _last; \

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Thu Sep 19 20:09:56 2013(r255713)
+++ head/sbin/hastd/secondary.c Thu Sep 19 20:15:24 2013(r255714)
@@ -115,7 +115,7 @@ static void *send_thread(void *arg);
TAILQ_INSERT_TAIL(hio_##name##_list, (hio), hio_next); \
mtx_unlock(hio_##name##_list_lock);\
if (_wakeup)\
-   cv_signal(hio_##name##_list_cond); \
+   cv_broadcast(hio_##name##_list_cond);  \
 } while (0)
 #defineQUEUE_TAKE(name, hio)   do {
\
mtx_lock(hio_##name##_list_lock);  \
___
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: r255521 - head/usr.sbin/daemon

2013-09-14 Thread Mikolaj Golub
On Fri, Sep 13, 2013 at 04:57:28PM +, John-Mark Gurney wrote:
 Author: jmg
 Date: Fri Sep 13 16:57:28 2013
 New Revision: 255521
 URL: http://svnweb.freebsd.org/changeset/base/255521
 
 Log:
   add support for writing the pid of the daemon program to a pid file so
   that daemon can be used w/ rc.subr and ports can use the additional
   functionality, such as keeping the ldap daemon up and running, and have
   the proper program to signal to exit..
   
   PR: bin/181341
   Submitted by:   feld
   Approved by:re (glebius)

Thank you for doing this. I was aware about this issue after I had
added restart option but could not come with a solution that would
satisfy me.

Having 2 options for pid files might look a little confusing but I
think it is much better than we had before.

Still please see a couple of notes below.

 Modified: head/usr.sbin/daemon/daemon.c
 ==
 --- head/usr.sbin/daemon/daemon.c Fri Sep 13 14:15:52 2013
 (r255520)
 +++ head/usr.sbin/daemon/daemon.c Fri Sep 13 16:57:28 2013
 (r255521)
 @@ -53,16 +53,17 @@ static void usage(void);
  int
  main(int argc, char *argv[])
  {
 - struct pidfh *pfh = NULL;
 + struct pidfh  *ppfh, *pfh;
   sigset_t mask, oldmask;
   int ch, nochdir, noclose, restart;
 - const char *pidfile, *user;
 + const char *pidfile, *ppidfile,  *user;
   pid_t otherpid, pid;
  
   nochdir = noclose = 1;
   restart = 0;
 - pidfile = user = NULL;
 - while ((ch = getopt(argc, argv, cfp:ru:)) != -1) {
 + ppfh = pfh = NULL;
 + ppidfile = pidfile = user = NULL;
 + while ((ch = getopt(argc, argv, cfp:P:ru:)) != -1) {
   switch (ch) {
   case 'c':
   nochdir = 0;
 @@ -73,6 +74,9 @@ main(int argc, char *argv[])
   case 'p':
   pidfile = optarg;
   break;
 + case 'P':
 + ppidfile = optarg;
 + break;
   case 'r':
   restart = 1;
   break;
 @@ -89,7 +93,7 @@ main(int argc, char *argv[])
   if (argc == 0)
   usage();
  
 - pfh = NULL;
 + ppfh = pfh = NULL;
   /*
* Try to open the pidfile before calling daemon(3),
* to be able to report the error intelligently
 @@ -104,6 +108,18 @@ main(int argc, char *argv[])
   err(2, pidfile ``%s'', pidfile);
   }
   }
 + 
 + /* do same for actual daemon process */
 + if (ppidfile != NULL) {
 + ppfh = pidfile_open(ppidfile, 0600, otherpid);
 + if (ppfh == NULL) {
 + if (errno == EEXIST) {
 + errx(3, process already running, pid: %d,
 +  otherpid);
 + }
 + err(2, ppidfile ``%s'', ppidfile);

You have to pidfile_remove(pfh) before exiting not to leave the child
pidfile on fs. Also pidfile_remove(ppfh) if fork() fails, and there
are several other places where pidfile_remove() is missed for the
child too before err exit (me should be blamed for most of these).

 + }
 + }
  
   if (daemon(nochdir, noclose) == -1)
   err(1, NULL);
 @@ -176,12 +192,17 @@ restart:
*/
   err(1, %s, argv[0]);
   }
 + /* write out parent pidfile if needed */
 + if (ppidfile != NULL)
 + pidfile_write(ppfh);
 +

No need to check for ppidfile != NULL. It is safe to call
pidfile_write() (and pidfile_remove()) with NULL argument.

Also, doing pidfile_write() here will cause needlessly rewriting the
file after every child restart. I think it is better to call
pidfile_write(ppfh) once, before the restart loop, just after
daemon().

   setproctitle(%s[%d], argv[0], pid);
   if (wait_child(pid, mask) == 0  restart) {
   sleep(1);
   goto restart;
   }
   pidfile_remove(pfh);
 + pidfile_remove(ppfh);
   exit(0); /* Exit status does not matter. */
  }
  
 @@ -240,7 +261,7 @@ static void
  usage(void)
  {
   (void)fprintf(stderr,
 - usage: daemon [-cfr] [-p pidfile] [-u user] command 
 - arguments ...\n);
 + usage: daemon [-cfr] [-p child_pidfile] [-P supervisor_pidfile] 
 + [-u user]\n  command arguments ...\n);
   exit(1);
  }

-- 
Mikolaj Golub
___
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: r255523 - in head/sys: netinet netinet6

2013-09-13 Thread Mikolaj Golub
Author: trociny
Date: Fri Sep 13 18:45:10 2013
New Revision: 255523
URL: http://svnweb.freebsd.org/changeset/base/255523

Log:
  Unregister inet/inet6 pfil hooks on vnet destroy.
  
  Discussed with:   andre
  Approved by:  re (rodrigc)

Modified:
  head/sys/netinet/ip_input.c
  head/sys/netinet6/ip6_input.c

Modified: head/sys/netinet/ip_input.c
==
--- head/sys/netinet/ip_input.c Fri Sep 13 18:21:31 2013(r255522)
+++ head/sys/netinet/ip_input.c Fri Sep 13 18:45:10 2013(r255523)
@@ -363,6 +363,11 @@ ip_init(void)
 void
 ip_destroy(void)
 {
+   int i;
+
+   if ((i = pfil_head_unregister(V_inet_pfil_hook)) != 0)
+   printf(%s: WARNING: unable to unregister pfil hook, 
+   error %d\n, __func__, i);
 
/* Cleanup in_ifaddr hash table; should be empty. */
hashdestroy(V_in_ifaddrhashtbl, M_IFADDR, V_in_ifaddrhmask);

Modified: head/sys/netinet6/ip6_input.c
==
--- head/sys/netinet6/ip6_input.c   Fri Sep 13 18:21:31 2013
(r255522)
+++ head/sys/netinet6/ip6_input.c   Fri Sep 13 18:45:10 2013
(r255523)
@@ -307,7 +307,11 @@ ip6proto_unregister(short ip6proto)
 void
 ip6_destroy()
 {
+   int i;
 
+   if ((i = pfil_head_unregister(V_inet6_pfil_hook)) != 0)
+   printf(%s: WARNING: unable to unregister pfil hook, 
+   error %d\n, __func__, i);
hashdestroy(V_in6_ifaddrhashtbl, M_IFADDR, V_in6_ifaddrhmask);
nd6_destroy();
callout_drain(V_in6_tmpaddrtimer_ch);
___
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: r255395 - stable/9/sys/netpfil/ipfw

2013-09-08 Thread Mikolaj Golub
Author: trociny
Date: Sun Sep  8 17:47:14 2013
New Revision: 255395
URL: http://svnweb.freebsd.org/changeset/base/255395

Log:
  MFC r254776:
  
  Make ipfw nat init/unint work correctly for VIMAGE:
  
  * Do per vnet instance cleanup (previously it was only for vnet0 on
module unload, and led to libalias leaks and possible panics due to
stale pointer dereferences).
  
  * Instead of protecting ipfw hooks registering/deregistering by only
vnet0 lock (which does not prevent pointers access from another
vnets), introduce per vnet ipfw_nat_loaded variable. The variable is
set after hooks are registered and unset before they are deregistered.
  
  * Devirtualize ifaddr_event_tag as we run only one event handler for
all vnets.
  
  * It is supposed that ifaddr_change event handler is called in the
interface vnet context, so add an assertion.
  
  Reviewed by:  zec

Modified:
  stable/9/sys/netpfil/ipfw/ip_fw2.c
  stable/9/sys/netpfil/ipfw/ip_fw_nat.c
  stable/9/sys/netpfil/ipfw/ip_fw_private.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netpfil/ipfw/ip_fw2.c
==
--- stable/9/sys/netpfil/ipfw/ip_fw2.c  Sun Sep  8 17:28:11 2013
(r255394)
+++ stable/9/sys/netpfil/ipfw/ip_fw2.c  Sun Sep  8 17:47:14 2013
(r255395)
@@ -142,6 +142,8 @@ VNET_DEFINE(int, verbose_limit);
 /* layer3_chain contains the list of rules for layer 3 */
 VNET_DEFINE(struct ip_fw_chain, layer3_chain);
 
+VNET_DEFINE(int, ipfw_nat_ready) = 0;
+
 ipfw_nat_t *ipfw_nat_ptr = NULL;
 struct cfg_nat *(*lookup_nat_ptr)(struct nat_list *, int);
 ipfw_nat_cfg_t *ipfw_nat_cfg_ptr;

Modified: stable/9/sys/netpfil/ipfw/ip_fw_nat.c
==
--- stable/9/sys/netpfil/ipfw/ip_fw_nat.c   Sun Sep  8 17:28:11 2013
(r255394)
+++ stable/9/sys/netpfil/ipfw/ip_fw_nat.c   Sun Sep  8 17:47:14 2013
(r255395)
@@ -53,8 +53,7 @@ __FBSDID($FreeBSD$);
 
 #include machine/in_cksum.h  /* XXX for in_cksum */
 
-static VNET_DEFINE(eventhandler_tag, ifaddr_event_tag);
-#defineV_ifaddr_event_tag  VNET(ifaddr_event_tag)
+static eventhandler_tag ifaddr_event_tag;
 
 static void
 ifaddr_change(void *arg __unused, struct ifnet *ifp)
@@ -63,6 +62,8 @@ ifaddr_change(void *arg __unused, struct
struct ifaddr *ifa;
struct ip_fw_chain *chain;
 
+   KASSERT(curvnet == ifp-if_vnet,
+   (curvnet(%p) differs from iface vnet(%p), curvnet, ifp-if_vnet));
chain = V_layer3_chain;
IPFW_WLOCK(chain);
/* Check every nat entry... */
@@ -590,11 +591,38 @@ ipfw_nat_get_log(struct sockopt *sopt)
return(0);
 }
 
+static int
+vnet_ipfw_nat_init(const void *arg __unused)
+{
+
+   V_ipfw_nat_ready = 1;
+   return (0);
+}
+
+static int
+vnet_ipfw_nat_uninit(const void *arg __unused)
+{
+   struct cfg_nat *ptr, *ptr_temp;
+   struct ip_fw_chain *chain;
+
+   chain = V_layer3_chain;
+   IPFW_WLOCK(chain);
+   LIST_FOREACH_SAFE(ptr, chain-nat, _next, ptr_temp) {
+   LIST_REMOVE(ptr, _next);
+   del_redir_spool_cfg(ptr, ptr-redir_chain);
+   LibAliasUninit(ptr-lib);
+   free(ptr, M_IPFW);
+   }
+   flush_nat_ptrs(chain, -1 /* flush all */);
+   V_ipfw_nat_ready = 0;
+   IPFW_WUNLOCK(chain);
+   return (0);
+}
+
 static void
 ipfw_nat_init(void)
 {
 
-   IPFW_WLOCK(V_layer3_chain);
/* init ipfw hooks */
ipfw_nat_ptr = ipfw_nat;
lookup_nat_ptr = lookup_nat;
@@ -602,28 +630,16 @@ ipfw_nat_init(void)
ipfw_nat_del_ptr = ipfw_nat_del;
ipfw_nat_get_cfg_ptr = ipfw_nat_get_cfg;
ipfw_nat_get_log_ptr = ipfw_nat_get_log;
-   IPFW_WUNLOCK(V_layer3_chain);
-   V_ifaddr_event_tag = EVENTHANDLER_REGISTER(
-   ifaddr_event, ifaddr_change,
+
+   ifaddr_event_tag = EVENTHANDLER_REGISTER(ifaddr_event, ifaddr_change,
NULL, EVENTHANDLER_PRI_ANY);
 }
 
 static void
 ipfw_nat_destroy(void)
 {
-   struct cfg_nat *ptr, *ptr_temp;
-   struct ip_fw_chain *chain;
 
-   chain = V_layer3_chain;
-   IPFW_WLOCK(chain);
-   LIST_FOREACH_SAFE(ptr, chain-nat, _next, ptr_temp) {
-   LIST_REMOVE(ptr, _next);
-   del_redir_spool_cfg(ptr, ptr-redir_chain);
-   LibAliasUninit(ptr-lib);
-   free(ptr, M_IPFW);
-   }
-   EVENTHANDLER_DEREGISTER(ifaddr_event, V_ifaddr_event_tag);
-   flush_nat_ptrs(chain, -1 /* flush all */);
+   EVENTHANDLER_DEREGISTER(ifaddr_event, ifaddr_event_tag);
/* deregister ipfw_nat */
ipfw_nat_ptr = NULL;
lookup_nat_ptr = NULL;
@@ -631,7 +647,6 @@ ipfw_nat_destroy(void)
ipfw_nat_del_ptr = NULL;
ipfw_nat_get_cfg_ptr = NULL;
ipfw_nat_get_log_ptr = NULL;
-   IPFW_WUNLOCK(chain);
 }
 
 static int
@@ -641,11 

svn commit: r255397 - head/sys/netinet

2013-09-08 Thread Mikolaj Golub
Author: trociny
Date: Sun Sep  8 18:19:40 2013
New Revision: 255397
URL: http://svnweb.freebsd.org/changeset/base/255397

Log:
  Relese the interface in the last.
  
  Reviewed by:  glebius
  Approved by:  re (kib)

Modified:
  head/sys/netinet/ip_carp.c

Modified: head/sys/netinet/ip_carp.c
==
--- head/sys/netinet/ip_carp.c  Sun Sep  8 17:51:22 2013(r255396)
+++ head/sys/netinet/ip_carp.c  Sun Sep  8 18:19:40 2013(r255397)
@@ -1605,12 +1605,12 @@ carp_free_if(struct carp_if *cif)
 
IF_ADDR_WLOCK(ifp);
ifp-if_carp = NULL;
-   if_rele(ifp);
IF_ADDR_WUNLOCK(ifp);
 
CIF_LOCK_DESTROY(cif);
 
ifpromisc(ifp, 0);
+   if_rele(ifp);
 
free(cif, M_CARP);
 }
___
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: r254773 - head/sys/net

2013-09-07 Thread Mikolaj Golub
Hi,

On Sat, Aug 24, 2013 at 11:17:25AM +, Andre Oppermann wrote:
 Author: andre
 Date: Sat Aug 24 11:17:25 2013
 New Revision: 254773
 URL: http://svnweb.freebsd.org/changeset/base/254773
 
 Log:
   Resolve the confusion between the head_list and the hook list.
   
   The linked list of pfil hooks is changed to chain and this term
   is applied consistently.  The head_list remains with list term.
   
   Add KASSERT to vnet_pfil_uninit().

...

  vnet_pfil_uninit(const void *unused)
  {
  
 - /*  XXX should panic if list is not empty */
 + KASSERT(LIST_EMPTY(V_pfil_head_list),
 + (%s: pfil_head_list %p not empty, __func__, V_pfil_head_list));
   PFIL_LOCK_DESTROY_REAL(V_pfil_lock);
   return (0);
  }
 

It is triggered when destroying a vnet, due to inet/inet6 pfil hooks
are not being unregistered.

The attached patch fixes the issue for me. I am going to commit it if
there are no objections -- might the unregistration has been skipped
intentionally due to some unresolved issue?

-- 
Mikolaj Golub
Unregister inet/inet6 pfil hooks on vnet destroy.

Index: sys/netinet/ip_input.c
===
--- sys/netinet/ip_input.c	(revision 255362)
+++ sys/netinet/ip_input.c	(working copy)
@@ -363,7 +363,12 @@ ip_init(void)
 void
 ip_destroy(void)
 {
+	int i;
 
+	if ((i = pfil_head_unregister(V_inet_pfil_hook)) != 0)
+		printf(%s: WARNING: unable to unregister pfil hook, 
+		error %d\n, __func__, i);
+
 	/* Cleanup in_ifaddr hash table; should be empty. */
 	hashdestroy(V_in_ifaddrhashtbl, M_IFADDR, V_in_ifaddrhmask);
 
Index: sys/netinet6/ip6_input.c
===
--- sys/netinet6/ip6_input.c	(revision 255362)
+++ sys/netinet6/ip6_input.c	(working copy)
@@ -307,7 +307,11 @@ ip6proto_unregister(short ip6proto)
 void
 ip6_destroy()
 {
+	int i;
 
+	if ((i = pfil_head_unregister(V_inet6_pfil_hook)) != 0)
+		printf(%s: WARNING: unable to unregister pfil hook, 
+		error %d\n, __func__, i);
 	hashdestroy(V_in6_ifaddrhashtbl, M_IFADDR, V_in6_ifaddrhmask);
 	nd6_destroy();
 	callout_drain(V_in6_tmpaddrtimer_ch);
___
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: r254776 - head/sys/netpfil/ipfw

2013-08-24 Thread Mikolaj Golub
Author: trociny
Date: Sat Aug 24 11:59:51 2013
New Revision: 254776
URL: http://svnweb.freebsd.org/changeset/base/254776

Log:
  Make ipfw nat init/unint work correctly for VIMAGE:
  
  * Do per vnet instance cleanup (previously it was only for vnet0 on
module unload, and led to libalias leaks and possible panics due to
stale pointer dereferences).
  
  * Instead of protecting ipfw hooks registering/deregistering by only
vnet0 lock (which does not prevent pointers access from another
vnets), introduce per vnet ipfw_nat_loaded variable. The variable is
set after hooks are registered and unset before they are deregistered.
  
  * Devirtualize ifaddr_event_tag as we run only one event handler for
all vnets.
  
  * It is supposed that ifaddr_change event handler is called in the
interface vnet context, so add an assertion.
  
  Reviewed by:  zec
  MFC after:2 weeks

Modified:
  head/sys/netpfil/ipfw/ip_fw2.c
  head/sys/netpfil/ipfw/ip_fw_nat.c
  head/sys/netpfil/ipfw/ip_fw_private.h

Modified: head/sys/netpfil/ipfw/ip_fw2.c
==
--- head/sys/netpfil/ipfw/ip_fw2.c  Sat Aug 24 11:57:02 2013
(r254775)
+++ head/sys/netpfil/ipfw/ip_fw2.c  Sat Aug 24 11:59:51 2013
(r254776)
@@ -142,6 +142,8 @@ VNET_DEFINE(int, verbose_limit);
 /* layer3_chain contains the list of rules for layer 3 */
 VNET_DEFINE(struct ip_fw_chain, layer3_chain);
 
+VNET_DEFINE(int, ipfw_nat_ready) = 0;
+
 ipfw_nat_t *ipfw_nat_ptr = NULL;
 struct cfg_nat *(*lookup_nat_ptr)(struct nat_list *, int);
 ipfw_nat_cfg_t *ipfw_nat_cfg_ptr;

Modified: head/sys/netpfil/ipfw/ip_fw_nat.c
==
--- head/sys/netpfil/ipfw/ip_fw_nat.c   Sat Aug 24 11:57:02 2013
(r254775)
+++ head/sys/netpfil/ipfw/ip_fw_nat.c   Sat Aug 24 11:59:51 2013
(r254776)
@@ -53,8 +53,7 @@ __FBSDID($FreeBSD$);
 
 #include machine/in_cksum.h  /* XXX for in_cksum */
 
-static VNET_DEFINE(eventhandler_tag, ifaddr_event_tag);
-#defineV_ifaddr_event_tag  VNET(ifaddr_event_tag)
+static eventhandler_tag ifaddr_event_tag;
 
 static void
 ifaddr_change(void *arg __unused, struct ifnet *ifp)
@@ -63,6 +62,8 @@ ifaddr_change(void *arg __unused, struct
struct ifaddr *ifa;
struct ip_fw_chain *chain;
 
+   KASSERT(curvnet == ifp-if_vnet,
+   (curvnet(%p) differs from iface vnet(%p), curvnet, ifp-if_vnet));
chain = V_layer3_chain;
IPFW_WLOCK(chain);
/* Check every nat entry... */
@@ -589,11 +590,38 @@ ipfw_nat_get_log(struct sockopt *sopt)
return(0);
 }
 
+static int
+vnet_ipfw_nat_init(const void *arg __unused)
+{
+
+   V_ipfw_nat_ready = 1;
+   return (0);
+}
+
+static int
+vnet_ipfw_nat_uninit(const void *arg __unused)
+{
+   struct cfg_nat *ptr, *ptr_temp;
+   struct ip_fw_chain *chain;
+
+   chain = V_layer3_chain;
+   IPFW_WLOCK(chain);
+   LIST_FOREACH_SAFE(ptr, chain-nat, _next, ptr_temp) {
+   LIST_REMOVE(ptr, _next);
+   del_redir_spool_cfg(ptr, ptr-redir_chain);
+   LibAliasUninit(ptr-lib);
+   free(ptr, M_IPFW);
+   }
+   flush_nat_ptrs(chain, -1 /* flush all */);
+   V_ipfw_nat_ready = 0;
+   IPFW_WUNLOCK(chain);
+   return (0);
+}
+
 static void
 ipfw_nat_init(void)
 {
 
-   IPFW_WLOCK(V_layer3_chain);
/* init ipfw hooks */
ipfw_nat_ptr = ipfw_nat;
lookup_nat_ptr = lookup_nat;
@@ -601,28 +629,16 @@ ipfw_nat_init(void)
ipfw_nat_del_ptr = ipfw_nat_del;
ipfw_nat_get_cfg_ptr = ipfw_nat_get_cfg;
ipfw_nat_get_log_ptr = ipfw_nat_get_log;
-   IPFW_WUNLOCK(V_layer3_chain);
-   V_ifaddr_event_tag = EVENTHANDLER_REGISTER(
-   ifaddr_event, ifaddr_change,
+
+   ifaddr_event_tag = EVENTHANDLER_REGISTER(ifaddr_event, ifaddr_change,
NULL, EVENTHANDLER_PRI_ANY);
 }
 
 static void
 ipfw_nat_destroy(void)
 {
-   struct cfg_nat *ptr, *ptr_temp;
-   struct ip_fw_chain *chain;
 
-   chain = V_layer3_chain;
-   IPFW_WLOCK(chain);
-   LIST_FOREACH_SAFE(ptr, chain-nat, _next, ptr_temp) {
-   LIST_REMOVE(ptr, _next);
-   del_redir_spool_cfg(ptr, ptr-redir_chain);
-   LibAliasUninit(ptr-lib);
-   free(ptr, M_IPFW);
-   }
-   EVENTHANDLER_DEREGISTER(ifaddr_event, V_ifaddr_event_tag);
-   flush_nat_ptrs(chain, -1 /* flush all */);
+   EVENTHANDLER_DEREGISTER(ifaddr_event, ifaddr_event_tag);
/* deregister ipfw_nat */
ipfw_nat_ptr = NULL;
lookup_nat_ptr = NULL;
@@ -630,7 +646,6 @@ ipfw_nat_destroy(void)
ipfw_nat_del_ptr = NULL;
ipfw_nat_get_cfg_ptr = NULL;
ipfw_nat_get_log_ptr = NULL;
-   IPFW_WUNLOCK(chain);
 }
 
 static int
@@ -640,11 +655,9 @@ ipfw_nat_modevent(module_t mod, int type
 
switch (type) {
case 

svn commit: r254778 - in stable/9/sys: netinet netinet6

2013-08-24 Thread Mikolaj Golub
Author: trociny
Date: Sat Aug 24 12:10:11 2013
New Revision: 254778
URL: http://svnweb.freebsd.org/changeset/base/254778

Log:
  MFC r253282:
  
  A complete duplication of binding should be allowed if on both new and
  duplicated sockets a multicast address is bound and either
  SO_REUSEPORT or SO_REUSEADDR is set.
  
  But actually it works for the following combinations:
  
* SO_REUSEPORT is set for the fist socket and SO_REUSEPORT for the new;
* SO_REUSEADDR is set for the fist socket and SO_REUSEADDR for the new;
* SO_REUSEPORT is set for the fist socket and SO_REUSEADDR for the new;
  
  and fails for this:
  
* SO_REUSEADDR is set for the fist socket and SO_REUSEPORT for the new.
  
  Fix the last case.
  
  PR:   179901

Modified:
  stable/9/sys/netinet/in_pcb.c
  stable/9/sys/netinet6/in6_pcb.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netinet/in_pcb.c
==
--- stable/9/sys/netinet/in_pcb.c   Sat Aug 24 12:03:24 2013
(r254777)
+++ stable/9/sys/netinet/in_pcb.c   Sat Aug 24 12:10:11 2013
(r254778)
@@ -553,7 +553,7 @@ in_pcbbind_setup(struct inpcb *inp, stru
 * and a multicast address is bound on both
 * new and duplicated sockets.
 */
-   if (so-so_options  SO_REUSEADDR)
+   if ((so-so_options  (SO_REUSEADDR|SO_REUSEPORT)) != 0)
reuseport = SO_REUSEADDR|SO_REUSEPORT;
} else if (sin-sin_addr.s_addr != INADDR_ANY) {
sin-sin_port = 0;  /* yech... */

Modified: stable/9/sys/netinet6/in6_pcb.c
==
--- stable/9/sys/netinet6/in6_pcb.c Sat Aug 24 12:03:24 2013
(r254777)
+++ stable/9/sys/netinet6/in6_pcb.c Sat Aug 24 12:10:11 2013
(r254778)
@@ -158,7 +158,7 @@ in6_pcbbind(register struct inpcb *inp, 
 * and a multicast address is bound on both
 * new and duplicated sockets.
 */
-   if (so-so_options  SO_REUSEADDR)
+   if ((so-so_options  (SO_REUSEADDR|SO_REUSEPORT)) != 0)
reuseport = SO_REUSEADDR|SO_REUSEPORT;
} else if (!IN6_IS_ADDR_UNSPECIFIED(sin6-sin6_addr)) {
struct ifaddr *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


svn commit: r254292 - head/sys/netinet

2013-08-13 Thread Mikolaj Golub
Author: trociny
Date: Tue Aug 13 19:59:49 2013
New Revision: 254292
URL: http://svnweb.freebsd.org/changeset/base/254292

Log:
  Virtualize carp(4) variables to have per vnet control.
  
  Reviewed by:  ae, glebius

Modified:
  head/sys/netinet/ip_carp.c

Modified: head/sys/netinet/ip_carp.c
==
--- head/sys/netinet/ip_carp.c  Tue Aug 13 19:57:35 2013(r254291)
+++ head/sys/netinet/ip_carp.c  Tue Aug 13 19:59:49 2013(r254292)
@@ -187,48 +187,59 @@ static int proto_reg[] = {-1, -1};
  *   dereferencing our function pointers.
  */
 
-static int carp_allow = 1; /* Accept incoming CARP packets. */
-static int carp_preempt = 0;   /* Preempt slower nodes. */
-static int carp_log = 1;   /* Log level. */
-static int carp_demotion = 0;  /* Global advskew demotion. */
-static int carp_senderr_adj = CARP_MAXSKEW;/* Send error demotion factor */
-static int carp_ifdown_adj = CARP_MAXSKEW; /* Iface down demotion factor */
+/* Accept incoming CARP packets. */
+static VNET_DEFINE(int, carp_allow) = 1;
+#defineV_carp_allowVNET(carp_allow)
+
+/* Preempt slower nodes. */
+static VNET_DEFINE(int, carp_preempt) = 0;
+#defineV_carp_preempt  VNET(carp_preempt)
+
+/* Log level. */
+static VNET_DEFINE(int, carp_log) = 1;
+#defineV_carp_log  VNET(carp_log)
+
+/* Global advskew demotion. */
+static VNET_DEFINE(int, carp_demotion) = 0;
+#defineV_carp_demotion VNET(carp_demotion)
+
+/* Send error demotion factor. */
+static VNET_DEFINE(int, carp_senderr_adj) = CARP_MAXSKEW;
+#defineV_carp_senderr_adj  VNET(carp_senderr_adj)
+
+/* Iface down demotion factor. */
+static VNET_DEFINE(int, carp_ifdown_adj) = CARP_MAXSKEW;
+#defineV_carp_ifdown_adj   VNET(carp_ifdown_adj)
+
 static int carp_demote_adj_sysctl(SYSCTL_HANDLER_ARGS);
 
 SYSCTL_NODE(_net_inet, IPPROTO_CARP,   carp,   CTLFLAG_RW, 0,  CARP);
-SYSCTL_INT(_net_inet_carp, OID_AUTO, allow, CTLFLAG_RW, carp_allow, 0,
-Accept incoming CARP packets);
-SYSCTL_INT(_net_inet_carp, OID_AUTO, preempt, CTLFLAG_RW, carp_preempt, 0,
-High-priority backup preemption mode);
-SYSCTL_INT(_net_inet_carp, OID_AUTO, log, CTLFLAG_RW, carp_log, 0,
-CARP log level);
-SYSCTL_PROC(_net_inet_carp, OID_AUTO, demotion, CTLTYPE_INT|CTLFLAG_RW,
+SYSCTL_VNET_INT(_net_inet_carp, OID_AUTO, allow, CTLFLAG_RW,
+VNET_NAME(carp_allow), 0, Accept incoming CARP packets);
+SYSCTL_VNET_INT(_net_inet_carp, OID_AUTO, preempt, CTLFLAG_RW,
+VNET_NAME(carp_preempt), 0, High-priority backup preemption mode);
+SYSCTL_VNET_INT(_net_inet_carp, OID_AUTO, log, CTLFLAG_RW,
+VNET_NAME(carp_log), 0, CARP log level);
+SYSCTL_VNET_PROC(_net_inet_carp, OID_AUTO, demotion, CTLTYPE_INT|CTLFLAG_RW,
 0, 0, carp_demote_adj_sysctl, I,
 Adjust demotion factor (skew of advskew));
-SYSCTL_INT(_net_inet_carp, OID_AUTO, senderr_demotion_factor, CTLFLAG_RW,
-carp_senderr_adj, 0, Send error demotion factor adjustment);
-SYSCTL_INT(_net_inet_carp, OID_AUTO, ifdown_demotion_factor, CTLFLAG_RW,
-carp_ifdown_adj, 0, Interface down demotion factor adjustment);
+SYSCTL_VNET_INT(_net_inet_carp, OID_AUTO, senderr_demotion_factor, CTLFLAG_RW,
+VNET_NAME(carp_senderr_adj), 0, Send error demotion factor adjustment);
+SYSCTL_VNET_INT(_net_inet_carp, OID_AUTO, ifdown_demotion_factor, CTLFLAG_RW,
+VNET_NAME(carp_ifdown_adj), 0,
+Interface down demotion factor adjustment);
+
+VNET_PCPUSTAT_DEFINE(struct carpstats, carpstats);
+VNET_PCPUSTAT_SYSINIT(carpstats);
+VNET_PCPUSTAT_SYSUNINIT(carpstats);
 
-static counter_u64_t carpstats[sizeof(struct carpstats) / sizeof(uint64_t)];
 #defineCARPSTATS_ADD(name, val)\
-counter_u64_add(carpstats[offsetof(struct carpstats, name) / \
+counter_u64_add(VNET(carpstats)[offsetof(struct carpstats, name) / \
sizeof(uint64_t)], (val))
 #defineCARPSTATS_INC(name) CARPSTATS_ADD(name, 1)
 
-static int
-carpstats_sysctl(SYSCTL_HANDLER_ARGS)
-{
-   struct carpstats s;
-
-   COUNTER_ARRAY_COPY(carpstats, s, sizeof(s) / sizeof(uint64_t));
-   if (req-newptr)
-   COUNTER_ARRAY_ZERO(carpstats, sizeof(s) / sizeof(uint64_t));
-   return (SYSCTL_OUT(req, s, sizeof(s)));
-}
-SYSCTL_PROC(_net_inet_carp, OID_AUTO, stats, CTLTYPE_OPAQUE | CTLFLAG_RW,
-NULL, 0, carpstats_sysctl, I,
-CARP statistics (struct carpstats, netinet/ip_carp.h));
+SYSCTL_VNET_PCPUSTAT(_net_inet_carp, OID_AUTO, stats, struct carpstats,
+carpstats, CARP statistics (struct carpstats, netinet/ip_carp.h));
 
 #defineCARP_LOCK_INIT(sc)  mtx_init((sc)-sc_mtx, carp_softc,   
\
NULL, MTX_DEF)
@@ -251,12 +262,12 @@ SYSCTL_PROC(_net_inet_carp, OID_AUTO, st
 } while (0)
 
 #defineCARP_LOG(...)   do {\
-   if (carp_log  0)   \
+   if (V_carp_log  0)

Re: svn commit: r253210 - in head/sys: conf netinet

2013-07-15 Thread Mikolaj Golub
On Mon, Jul 15, 2013 at 11:36:16AM +0200, Ulrich Spörlein wrote:
 Hey Andre,
 
 I don't see why this commit triggers it, but Coverity Scan found a new
 resource leak in this file. syncache_expand() will leak *s when line
 1071 is reached. The failed: case below correctly frees the resources.
 
 1068/* how do we find the inp for the new socket? */
 22. Condition sc != scs, taking true branch
 1069if (sc != scs)
 1070syncache_free(sc);
 
 CID null (#1 of 1): Resource leak (RESOURCE_LEAK)
 23. leaked_storage: Variable s going out of scope leaks the storage it 
 points to.
 1071return (1);
 1072failed:
 1073if (sc != NULL  sc != scs)
 1074syncache_free(sc);
 1075if (s != NULL)
 1076free(s, M_TCPLOG);
 1077*lsop = NULL;
 1078return (0);
 1079}

It looks like free(s, M_TCPLOG) is missed in this branch:

  1043  if ((sc-sc_flags  SCF_TIMESTAMP)  !(to-to_flags  TOF_TS)) 
{
  1044  if ((s = tcp_log_addrs(inc, th, NULL, NULL)))
  1045  log(LOG_DEBUG, %s; %s: Timestamp missing, 
  1046  no action\n, s, __func__);
  1047  }


-- 
Mikolaj Golub
___
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: r253255 - head/sys/netgraph/bluetooth/drivers/ubt

2013-07-13 Thread Mikolaj Golub
On Fri, Jul 12, 2013 at 10:40:08PM -0700, Adrian Chadd wrote:
 Here's what I have running on my stable/9 VIMAGE laptop.
 
 http://people.freebsd.org/~adrian/ath/20130712-vimage-default-attach-detach.diff
 
 How's this look to put into -HEAD?

Your patch looks similar to Marko's:

http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20121115/0824ca85/attachment.diff

Marko took your idea of setting vnet0 context in
device_probe_and_attach(), although there is no is_default_vnet check,
and I also think it is not necessary here -- just unconditionally set
vnet0 is ok.

Also, as I understand, after handling vnet context in
device_probe_and_attach(), there is no need in curvnet setting in
kldload/kldunload, and Marko removed it.

In net/if.c, similarly to you, Marko sets vnet context in if_detach(),
but also in if_free(), so this would be good to commit too (I suppose
Marko had good reasons to do this).

I can't comment the netgraph related parts of your patch as I have no
idea what is going on here. Though I think this could be committed
separately if it is needed.

-- 
Mikolaj Golub
___
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: r253314 - head/sys/net

2013-07-13 Thread Mikolaj Golub
On Sat, Jul 13, 2013 at 04:25:03AM +, Adrian Chadd wrote:

 +static int
 +lagg_sysctl_active(SYSCTL_HANDLER_ARGS)
 +{
 + struct lagg_softc *sc = (struct lagg_softc *)arg1;
 + struct lagg_port *lp;
 + int error;
 +
 + /* LACP tracks active links automatically, the others do not */
 + if (sc-sc_proto != LAGG_PROTO_LACP) {
 + sc-sc_active = 0;
 + SLIST_FOREACH(lp, sc-sc_ports, lp_entries)
 + sc-sc_active += LAGG_PORTACTIVE(lp);

Shouldn't sc be wlocked here?

 + }
 +
 + error = sysctl_handle_int(oidp, sc-sc_active, 0, req);
 + if ((error) || (req-newptr == NULL))
 + return (error);
 +
 + return (0);
 +}

-- 
Mikolaj Golub
___
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: r253255 - head/sys/netgraph/bluetooth/drivers/ubt

2013-07-13 Thread Mikolaj Golub
On Sat, Jul 13, 2013 at 03:31:34AM -0700, Craig Rodrigues wrote:
 
 I experimented with Marko's patch, and found that the kernel crashed
 inside the code which initializes PF.
 
 /usr/home/rodrigc/freebsd/9/sys/modules/pf/../../contrib/pf/net/pf_ioctl.c:295
 295 {
 (kgdb) l
 290
 291 mtx_destroy(pf_task_mtx);
 292 }
 293 void
 294 init_zone_var(void)
 295 {
 296 V_pf_src_tree_pl = V_pf_rule_pl = NULL;
 297 V_pf_state_pl = V_pf_state_key_pl = V_pf_state_item_pl =
 NULL;
 298 V_pf_altq_pl = V_pf_pooladdr_pl = NULL;
 299 V_pf_frent_pl = V_pf_frag_pl = V_pf_cache_pl = V_pf_cent_pl
 = NULL;
 
 In init_zone_var(), curthread-td_vnet was NULL.

I wonder if it fails on current too? It looks this code is not there
any more. I will try.

 So, I don't think it is safe to remove the vnet stuff from
 kldload/kldunload just yet,
 without fixing some code in some kernel modules like PF.
 

If you have plans to merge the changes to stable then yes, I think it
is safer to commit the patch without kldload/kldunload part and commit
the last separately after testing (and fixing affected modules if
there are).

 The other parts of the patch look OK.

So it works for you with your commit reverted and without Adrians'
netgraph patch?

-- 
Mikolaj Golub
___
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: r253255 - head/sys/netgraph/bluetooth/drivers/ubt

2013-07-13 Thread Mikolaj Golub
On Sat, Jul 13, 2013 at 01:39:52PM +0200, Marko Zec wrote:

 I fear both Adrian's and my patch fall short of addressing the issue of 
 generic USB device attach handling in VIMAGE kernels, i.e. the patches 
 discussed in this thread might be OK for preventing panics with ng_ubt, but 
 what about USB ethernet or wifi devices?  If I recall correctly the USB 
 stack has a separate thread which handles device attach events, and IMO the 
 curvnet context should be set there to cover a broader set of different 
 devices.

You mean usb_process thread? But as I see it calls
device_probe_and_attach() in usb_probe_and_attach(), which has vnet
context properly set to the default vnet after your patch. So I
beleive paths like these are fixed:

http://lists.freebsd.org/pipermail/freebsd-virtualization/2009-May/000325.html
http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/169991

Or do you mean something else?

-- 
Mikolaj Golub
___
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: r253255 - head/sys/netgraph/bluetooth/drivers/ubt

2013-07-13 Thread Mikolaj Golub
On Sat, Jul 13, 2013 at 02:18:26PM +0300, Mikolaj Golub wrote:

 I wonder if it fails on current too? It looks this code is not there
 any more. I will try.

Yes. It crashes on current too. In pfattach(). Also, loading ipfw and
ipfw_nat causes panics in ipfw_init() and ipfw_nat_init(). Although
this can be easily bandaged with CURVNET_SET(vnet0), it rather reveals
problems with these modules.

E.g. currently in ipfw_nat_init() we lock virtualized layer3_chain in
vnet0 context, I think, to restrict the access to ipfw_nat_*_ptr
variables during modification. But the access is not protected from
another vnets, which might already exist at the moment when ipfw_nat
is loaded.

-- 
Mikolaj Golub
___
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: r253255 - head/sys/netgraph/bluetooth/drivers/ubt

2013-07-13 Thread Mikolaj Golub
On Sat, Jul 13, 2013 at 11:04:23AM -0700, Craig Rodrigues wrote:

 Can you try this combination of patches:
 
 (1)  Combine Adrian and Marko's patches, but omit Marko's changes to
 kldload/kldunload:
 
 http://people.freebsd.org/~rodrigc/vnet-patch-adrian+marko.txt
 
 (2)  Revert my Bluetooth patch:
 
 http://people.freebsd.org/~rodrigc/patch-revert-GRN-253255.txt

Currently I don't have any pluggable device so my testing would not be
very useful. I tried Marko's patch to test kldload/kldunload change,
which is not in your patch.

Concerning your combined patch, as I said previously I don't like very
much that dance with is_default_vnet. What is a purpose of it? As for
me, it only makes the code less readable. I would just set curvnet to
vnet0, as it is in Marko's patch.

-- 
Mikolaj Golub
___
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: r253255 - head/sys/netgraph/bluetooth/drivers/ubt

2013-07-13 Thread Mikolaj Golub
On Sat, Jul 13, 2013 at 12:45:13PM -0700, Craig Rodrigues wrote:

 OK, just to double check, based on reading your post:
 http://lists.freebsd.org/pipermail/svn-src-all/2013-July/071848.html ,
 with Marko's kldload/kldunload change, you encountered kernel panics in PF
 and IPFW?

Yes. Also in lagg :(

 I also encountered kernel panics in PF with that patch.
 Maybe we can clean up those modules in a separate pass,
 and apply the kldload/kldunload fix some time in the future.
 
 
 
 
  Concerning your combined patch, as I said previously I don't like very
  much that dance with is_default_vnet. What is a purpose of it? As for
  me, it only makes the code less readable. I would just set curvnet to
  vnet0, as it is in Marko's patch.
 
 
 Fine by me.  I have re-rolled my combined patch to remove the
 is_default_vnet check
 and go with Marko's code to set curvnet to vnet0:
 
 (1)  Combine Adrian and Marko's patches, but omit Marko's changes to
 kldload/kldunload:
 
 http://people.freebsd.org/~rodrigc/vnet-patch-adrian+marko-p2.txt
 
 (2)  Revert my Bluetooth patch:
 
 http://people.freebsd.org/~rodrigc/patch-revert-GRN-253255.txt

Thanks.

-- 
Mikolaj Golub
___
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: r253281 - in stable/9/sys: netinet netinet6

2013-07-12 Thread Mikolaj Golub
Author: trociny
Date: Fri Jul 12 18:54:47 2013
New Revision: 253281
URL: http://svnweb.freebsd.org/changeset/base/253281

Log:
  MFC r252710:
  
  In r227207, to fix the issue with possible NULL inp_socket pointer
  dereferencing, when checking for SO_REUSEPORT option (and SO_REUSEADDR
  for multicast), INP_REUSEPORT flag was introduced to cache the socket
  option.  It was decided then that one flag would be enough to cache
  both SO_REUSEPORT and SO_REUSEADDR: when processing SO_REUSEADDR
  setsockopt(2), it was checked if it was called for a multicast address
  and INP_REUSEPORT was set accordingly.
  
  Unfortunately that approach does not work when setsockopt(2) is called
  before binding to a multicast address: the multicast check fails and
  INP_REUSEPORT is not set.
  
  Fix this by adding INP_REUSEADDR flag to unconditionally cache
  SO_REUSEADDR.
  
  PR:   179901
  Submitted by: Michael Gmelin freebsd grem.de (initial version)
  Reviewed by:  rwatson
  Approved by:  re (kib)

Modified:
  stable/9/sys/netinet/in_pcb.c
  stable/9/sys/netinet/in_pcb.h
  stable/9/sys/netinet/ip_output.c
  stable/9/sys/netinet6/in6_pcb.c
  stable/9/sys/netinet6/ip6_output.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netinet/in_pcb.c
==
--- stable/9/sys/netinet/in_pcb.c   Fri Jul 12 18:52:33 2013
(r253280)
+++ stable/9/sys/netinet/in_pcb.c   Fri Jul 12 18:54:47 2013
(r253281)
@@ -466,6 +466,23 @@ in_pcb_lport(struct inpcb *inp, struct i
 
return (0);
 }
+
+/*
+ * Return cached socket options.
+ */
+short
+inp_so_options(const struct inpcb *inp)
+{
+   short so_options;
+
+   so_options = 0;
+
+   if ((inp-inp_flags2  INP_REUSEPORT) != 0)
+  so_options |= SO_REUSEPORT;
+   if ((inp-inp_flags2  INP_REUSEADDR) != 0)
+  so_options |= SO_REUSEADDR;
+   return (so_options);
+}
 #endif /* INET || INET6 */
 
 #ifdef INET
@@ -594,8 +611,7 @@ in_pcbbind_setup(struct inpcb *inp, stru
if (tw == NULL ||
(reuseport  tw-tw_so_options) == 0)
return (EADDRINUSE);
-   } else if (t  (reuseport == 0 ||
-   (t-inp_flags2  INP_REUSEPORT) == 0)) {
+   } else if (t  (reuseport  inp_so_options(t)) == 0) {
 #ifdef INET6
if (ntohl(sin-sin_addr.s_addr) !=
INADDR_ANY ||

Modified: stable/9/sys/netinet/in_pcb.h
==
--- stable/9/sys/netinet/in_pcb.h   Fri Jul 12 18:52:33 2013
(r253280)
+++ stable/9/sys/netinet/in_pcb.h   Fri Jul 12 18:54:47 2013
(r253281)
@@ -442,6 +442,7 @@ struct tcpcb *
inp_inpcbtotcpcb(struct inpcb *inp);
 void   inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
uint32_t *faddr, uint16_t *fp);
+short  inp_so_options(const struct inpcb *inp);
 
 #endif /* _KERNEL */
 
@@ -543,6 +544,7 @@ voidinp_4tuple_get(struct inpcb *inp, 
 #defineINP_PCBGROUPWILD0x0004 /* in pcbgroup wildcard list 
*/
 #defineINP_REUSEPORT   0x0008 /* SO_REUSEPORT option is 
set */
 #defineINP_FREED   0x0010 /* inp itself is not valid */
+#defineINP_REUSEADDR   0x0020 /* SO_REUSEADDR option is 
set */
 
 /*
  * Flags passed to in_pcblookup*() functions.

Modified: stable/9/sys/netinet/ip_output.c
==
--- stable/9/sys/netinet/ip_output.cFri Jul 12 18:52:33 2013
(r253280)
+++ stable/9/sys/netinet/ip_output.cFri Jul 12 18:54:47 2013
(r253281)
@@ -899,13 +899,10 @@ ip_ctloutput(struct socket *so, struct s
switch (sopt-sopt_name) {
case SO_REUSEADDR:
INP_WLOCK(inp);
-   if (IN_MULTICAST(ntohl(inp-inp_laddr.s_addr))) 
{
-   if ((so-so_options 
-   (SO_REUSEADDR | SO_REUSEPORT)) != 0)
-   inp-inp_flags2 |= 
INP_REUSEPORT;
-   else
-   inp-inp_flags2 = 
~INP_REUSEPORT;
-   }
+   if ((so-so_options  SO_REUSEADDR) != 0)
+   inp-inp_flags2 |= INP_REUSEADDR;
+   else
+   inp-inp_flags2 = ~INP_REUSEADDR;
INP_WUNLOCK(inp);
error = 0;
break;

Modified: stable/9/sys/netinet6/in6_pcb.c

svn commit: r253282 - in head/sys: netinet netinet6

2013-07-12 Thread Mikolaj Golub
Author: trociny
Date: Fri Jul 12 19:08:33 2013
New Revision: 253282
URL: http://svnweb.freebsd.org/changeset/base/253282

Log:
  A complete duplication of binding should be allowed if on both new and
  duplicated sockets a multicast address is bound and either
  SO_REUSEPORT or SO_REUSEADDR is set.
  
  But actually it works for the following combinations:
  
* SO_REUSEPORT is set for the fist socket and SO_REUSEPORT for the new;
* SO_REUSEADDR is set for the fist socket and SO_REUSEADDR for the new;
* SO_REUSEPORT is set for the fist socket and SO_REUSEADDR for the new;
  
  and fails for this:
  
* SO_REUSEADDR is set for the fist socket and SO_REUSEPORT for the new.
  
  Fix the last case.
  
  PR:   179901
  MFC after:1 month

Modified:
  head/sys/netinet/in_pcb.c
  head/sys/netinet6/in6_pcb.c

Modified: head/sys/netinet/in_pcb.c
==
--- head/sys/netinet/in_pcb.c   Fri Jul 12 18:54:47 2013(r253281)
+++ head/sys/netinet/in_pcb.c   Fri Jul 12 19:08:33 2013(r253282)
@@ -554,7 +554,7 @@ in_pcbbind_setup(struct inpcb *inp, stru
 * and a multicast address is bound on both
 * new and duplicated sockets.
 */
-   if (so-so_options  SO_REUSEADDR)
+   if ((so-so_options  (SO_REUSEADDR|SO_REUSEPORT)) != 0)
reuseport = SO_REUSEADDR|SO_REUSEPORT;
} else if (sin-sin_addr.s_addr != INADDR_ANY) {
sin-sin_port = 0;  /* yech... */

Modified: head/sys/netinet6/in6_pcb.c
==
--- head/sys/netinet6/in6_pcb.c Fri Jul 12 18:54:47 2013(r253281)
+++ head/sys/netinet6/in6_pcb.c Fri Jul 12 19:08:33 2013(r253282)
@@ -156,7 +156,7 @@ in6_pcbbind(register struct inpcb *inp, 
 * and a multicast address is bound on both
 * new and duplicated sockets.
 */
-   if (so-so_options  SO_REUSEADDR)
+   if ((so-so_options  (SO_REUSEADDR|SO_REUSEPORT)) != 0)
reuseport = SO_REUSEADDR|SO_REUSEPORT;
} else if (!IN6_IS_ADDR_UNSPECIFIED(sin6-sin6_addr)) {
struct ifaddr *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: r253255 - head/sys/netgraph/bluetooth/drivers/ubt

2013-07-12 Thread Mikolaj Golub
On Fri, Jul 12, 2013 at 11:39:34AM -0700, Craig Rodrigues wrote:
 I like your patch.  It may be worth having one more Netgraph person review
 it and give a sanity check, but
 I think we should commit your patch ASAP.
 I am new to VNET, but I am wondering if in your patch we can KASSERT if
 node-vnet is NULL.  That would make
 things easier to debug.
 
 The part of my patch which which does CURVNET_SET is still necessary upon
 attach in Bluetooth.
 However, with your patch, we can get rid of the part of my patch which does
 CURVNET_SET upon Bluetooth detach.

Some time ago there was a long discussion about VIMAGE issue with
hotplugabble network devices:

http://lists.freebsd.org/pipermail/freebsd-hackers/2012-October/040784.html

(I wander why Adrian did not mention it as he was deeply involved)

Then Marko came up with a patch that mihght fix the issue in a more
generic way:

http://lists.freebsd.org/pipermail/freebsd-hackers/2012-November/041120.html

Unfortunately it was not tested. I think it would be very interesting
to try it with hotplugabble devices. (I don't have any so can't test).

-- 
Mikolaj Golub
___
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: r253210 - in head/sys: conf netinet

2013-07-11 Thread Mikolaj Golub
Hi, Andre

On Thu, Jul 11, 2013 at 03:29:25PM +, Andre Oppermann wrote:
 Author: andre
 Date: Thu Jul 11 15:29:25 2013
 New Revision: 253210
 URL: http://svnweb.freebsd.org/changeset/base/253210
 
 Log:
   Improve SYN cookies by encoding the MSS, WSCALE (window scaling) and SACK
   information into the ISN (initial sequence number) without the additional
   use of timestamp bits and switching to the very fast and cryptographically
   strong SipHash-2-4 MAC hash algorithm to protect the SYN cookie against
   forgeries.

It fails to build with VIMAGE:

cc  -c -O2 -pipe -fno-strict-aliasing  -std=c99 -g -Wall -Wredundant-decls 
-Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith 
-Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions  
-Wmissing-include-dirs -fdiagnostics-show-option  
-Wno-error-tautological-compare -Wno-error-empty-body  
-Wno-error-parentheses-equality  -nostdinc  -I. 
-I/home/golub/freebsd/base/head/sys 
-I/home/golub/freebsd/base/head/sys/contrib/altq 
-I/home/golub/freebsd/base/head/sys/contrib/libfdt -D_KERNEL 
-DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h  -fno-omit-frame-pointer 
-mno-omit-leaf-frame-pointer -mno-aes -mno-avx -mcmodel=kernel -mno-red-zone 
-mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding 
-fstack-protector -Werror  
/home/golub/freebsd/base/head/sys/netinet/tcp_syncache.c
/home/golub/freebsd/base/head/sys/netinet/tcp_syncache.c:266:17: error: no 
member named 'vnet' in
  'struct tcp_syncache'
V_tcp_syncache.vnet = curvnet;
~~ ^
/home/golub/freebsd/base/head/sys/netinet/tcp_syncache.c:438:27: error: no 
member named 'vnet' in
  'struct tcp_syncache'
CURVNET_SET(sch-sch_sc-vnet);
~~~  ^

 Modified: head/sys/netinet/tcp_syncache.h
 ==
...
  struct tcp_syncache {
 @@ -115,6 +118,19 @@ struct tcp_syncache {
   u_int   cache_limit;
   u_int   rexmt_limit;
   u_int   hash_secret;
 + struct vnet *sch_vnet;

I think you meant here:

+   struct vnet *vnet;

-- 
Mikolaj Golub
___
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: r253166 - stable/9/lib/libkvm

2013-07-10 Thread Mikolaj Golub
Author: trociny
Date: Wed Jul 10 19:42:07 2013
New Revision: 253166
URL: http://svnweb.freebsd.org/changeset/base/253166

Log:
  Direct commit to stable branch to fix ABI breakage:
  
  In r227839, when removing libkvm dependency on procfs(5),
  kvm_uread() function, used for reading from /proc/pid/mem, was
  removed too. This change broke ABI.
  
  Bring kvm_uread() back so that the ABI is kept. In head soname is
  going to be bumped instead.
  
  Reported by:  rmh
  Discussed on: arch
  Suggested by: jilles

Modified:
  stable/9/lib/libkvm/kvm_proc.c

Modified: stable/9/lib/libkvm/kvm_proc.c
==
--- stable/9/lib/libkvm/kvm_proc.c  Wed Jul 10 19:15:59 2013
(r253165)
+++ stable/9/lib/libkvm/kvm_proc.c  Wed Jul 10 19:42:07 2013
(r253166)
@@ -712,3 +712,55 @@ kvm_getenvv(kvm_t *kd, const struct kinf
 {
return (kvm_argv(kd, kp, 1, nchr));
 }
+
+/*
+ * Read from user space.  The user context is given by p.
+ */
+ssize_t
+kvm_uread(kvm_t *kd, const struct kinfo_proc *kp, u_long uva, char *buf,
+   size_t len)
+{
+   char *cp;
+   char procfile[MAXPATHLEN];
+   ssize_t amount;
+   int fd;
+
+   if (!ISALIVE(kd)) {
+   _kvm_err(kd, kd-program,
+   cannot read user space from dead kernel);
+   return (0);
+   }
+
+   sprintf(procfile, /proc/%d/mem, kp-ki_pid);
+   fd = open(procfile, O_RDONLY, 0);
+   if (fd  0) {
+   _kvm_err(kd, kd-program, cannot open %s, procfile);
+   return (0);
+   }
+
+   cp = buf;
+   while (len  0) {
+   errno = 0;
+   if (lseek(fd, (off_t)uva, 0) == -1  errno != 0) {
+   _kvm_err(kd, kd-program, invalid address (%lx) in %s,
+   uva, procfile);
+   break;
+   }
+   amount = read(fd, cp, len);
+   if (amount  0) {
+   _kvm_syserr(kd, kd-program, error reading %s,
+   procfile);
+   break;
+   }
+   if (amount == 0) {
+   _kvm_err(kd, kd-program, EOF reading %s, procfile);
+   break;
+   }
+   cp += amount;
+   uva += amount;
+   len -= amount;
+   }
+
+   close(fd);
+   return ((ssize_t)(cp - buf));
+}
___
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: r253167 - in head: . lib/libkvm

2013-07-10 Thread Mikolaj Golub
Author: trociny
Date: Wed Jul 10 19:44:43 2013
New Revision: 253167
URL: http://svnweb.freebsd.org/changeset/base/253167

Log:
  In r227839, when removing libkvm dependency on procfs(5),
  kvm_uread() function, used for reading from /proc/pid/mem, was
  removed too. But the function declaration remained in kvm.h
  public header and the soname was not bumped.
  
  Remove kvm_uread() from kvm.h and bump the soname.
  
  Reported by:  rmh
  Discussed on: arch

Modified:
  head/ObsoleteFiles.inc
  head/lib/libkvm/Makefile
  head/lib/libkvm/kvm.h

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Wed Jul 10 19:42:07 2013(r253166)
+++ head/ObsoleteFiles.inc  Wed Jul 10 19:44:43 2013(r253167)
@@ -38,6 +38,9 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20130710: libkvm version bump 
+OLD_LIBS+=lib/libkvm.so.5
+OLD_LIBS+=usr/lib32/libkvm.so.5
 # 20130623: dialog update from 1.1 to 1.2
 OLD_LIBS+=usr/lib/libdialog.so.7
 OLD_LIBS+=usr/lib32/libdialog.so.7

Modified: head/lib/libkvm/Makefile
==
--- head/lib/libkvm/MakefileWed Jul 10 19:42:07 2013(r253166)
+++ head/lib/libkvm/MakefileWed Jul 10 19:44:43 2013(r253167)
@@ -3,6 +3,7 @@
 
 LIB=   kvm
 SHLIBDIR?= /lib
+SHLIB_MAJOR=   6
 CFLAGS+=-DLIBC_SCCS -I${.CURDIR}
 
 .if exists(${.CURDIR}/kvm_${MACHINE_ARCH}.c)

Modified: head/lib/libkvm/kvm.h
==
--- head/lib/libkvm/kvm.h   Wed Jul 10 19:42:07 2013(r253166)
+++ head/lib/libkvm/kvm.h   Wed Jul 10 19:44:43 2013(r253167)
@@ -89,8 +89,6 @@ kvm_t  *kvm_openfiles
(const char *, const char *, const char *, int, char *);
 ssize_t  kvm_read(kvm_t *, unsigned long, void *, size_t);
 ssize_t  kvm_read_zpcpu(kvm_t *, void *, u_long, size_t, int);
-ssize_t  kvm_uread
-   (kvm_t *, const struct kinfo_proc *, unsigned long, char *, size_t);
 ssize_t  kvm_write(kvm_t *, unsigned long, const void *, size_t);
 __END_DECLS
 
___
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: r252818 - in stable/9/sbin: hastctl hastd

2013-07-05 Thread Mikolaj Golub
Author: trociny
Date: Fri Jul  5 18:44:10 2013
New Revision: 252818
URL: http://svnweb.freebsd.org/changeset/base/252818

Log:
  MFC r252472:
  
  Make hastctl(1) ('list' command) output a worker pid.
  
  Reviewed by:  pjd

Modified:
  stable/9/sbin/hastctl/hastctl.c
  stable/9/sbin/hastd/control.c
Directory Properties:
  stable/9/sbin/hastctl/   (props changed)
  stable/9/sbin/hastd/   (props changed)

Modified: stable/9/sbin/hastctl/hastctl.c
==
--- stable/9/sbin/hastctl/hastctl.c Fri Jul  5 18:31:26 2013
(r252817)
+++ stable/9/sbin/hastctl/hastctl.c Fri Jul  5 18:44:10 2013
(r252818)
@@ -293,6 +293,7 @@ control_set_role(struct nv *nv, const ch
 static int
 control_list(struct nv *nv)
 {
+   pid_t pid;
unsigned int ii;
const char *str;
int error, ret;
@@ -331,6 +332,9 @@ control_list(struct nv *nv)
str = nv_get_string(nv, status%u, ii);
if (str != NULL)
printf(  status: %s\n, str);
+   pid = nv_get_int32(nv, workerpid%u, ii);
+   if (pid != 0)
+   printf(  workerpid: %d\n, pid);
printf(  dirty: %ju (%NB)\n,
(uintmax_t)nv_get_uint64(nv, dirty%u, ii),
(intmax_t)nv_get_uint64(nv, dirty%u, ii));

Modified: stable/9/sbin/hastd/control.c
==
--- stable/9/sbin/hastd/control.c   Fri Jul  5 18:31:26 2013
(r252817)
+++ stable/9/sbin/hastd/control.c   Fri Jul  5 18:44:10 2013
(r252818)
@@ -271,6 +271,7 @@ control_status(struct hastd_config *cfg,
nv_add_string(nvout, compression_name(res-hr_compression),
compression%u, no);
nv_add_string(nvout, role2str(res-hr_role), role%u, no);
+   nv_add_int32(nvout, res-hr_workerpid, workerpid%u, no);
 
switch (res-hr_role) {
case HAST_ROLE_PRIMARY:
___
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: r252819 - in stable/8/sbin: hastctl hastd

2013-07-05 Thread Mikolaj Golub
Author: trociny
Date: Fri Jul  5 18:44:41 2013
New Revision: 252819
URL: http://svnweb.freebsd.org/changeset/base/252819

Log:
  MFC r252472:
  
  Make hastctl(1) ('list' command) output a worker pid.
  
  Reviewed by:  pjd

Modified:
  stable/8/sbin/hastctl/hastctl.c
  stable/8/sbin/hastd/control.c
Directory Properties:
  stable/8/sbin/hastctl/   (props changed)
  stable/8/sbin/hastd/   (props changed)

Modified: stable/8/sbin/hastctl/hastctl.c
==
--- stable/8/sbin/hastctl/hastctl.c Fri Jul  5 18:44:10 2013
(r252818)
+++ stable/8/sbin/hastctl/hastctl.c Fri Jul  5 18:44:41 2013
(r252819)
@@ -293,6 +293,7 @@ control_set_role(struct nv *nv, const ch
 static int
 control_list(struct nv *nv)
 {
+   pid_t pid;
unsigned int ii;
const char *str;
int error, ret;
@@ -331,6 +332,9 @@ control_list(struct nv *nv)
str = nv_get_string(nv, status%u, ii);
if (str != NULL)
printf(  status: %s\n, str);
+   pid = nv_get_int32(nv, workerpid%u, ii);
+   if (pid != 0)
+   printf(  workerpid: %d\n, pid);
printf(  dirty: %ju (%NB)\n,
(uintmax_t)nv_get_uint64(nv, dirty%u, ii),
(intmax_t)nv_get_uint64(nv, dirty%u, ii));

Modified: stable/8/sbin/hastd/control.c
==
--- stable/8/sbin/hastd/control.c   Fri Jul  5 18:44:10 2013
(r252818)
+++ stable/8/sbin/hastd/control.c   Fri Jul  5 18:44:41 2013
(r252819)
@@ -271,6 +271,7 @@ control_status(struct hastd_config *cfg,
nv_add_string(nvout, compression_name(res-hr_compression),
compression%u, no);
nv_add_string(nvout, role2str(res-hr_role), role%u, no);
+   nv_add_int32(nvout, res-hr_workerpid, workerpid%u, no);
 
switch (res-hr_role) {
case HAST_ROLE_PRIMARY:
___
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: r252820 - stable/9/usr.sbin/bsnmpd/modules/snmp_hast

2013-07-05 Thread Mikolaj Golub
Author: trociny
Date: Fri Jul  5 18:46:35 2013
New Revision: 252820
URL: http://svnweb.freebsd.org/changeset/base/252820

Log:
  MFC r252516, r252540:
  
  Add a mib for worker process ID.

Modified:
  stable/9/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
  stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
  stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def
Directory Properties:
  stable/9/usr.sbin/bsnmpd/   (props changed)

Modified: stable/9/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
==
--- stable/9/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Fri Jul 
 5 18:44:41 2013(r252819)
+++ stable/9/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Fri Jul 
 5 18:46:35 2013(r252820)
@@ -57,6 +57,9 @@ begemotHast MODULE-IDENTITY
 REVISION 20130413Z
 DESCRIPTION
Initial revision.
+REVISION 20130701Z
+DESCRIPTION
+   Added hastResourceWorkerPid.
 ::= { begemot 220 }
 
 begemotHastObjects OBJECT IDENTIFIER ::= { begemotHast 1 }
@@ -116,7 +119,8 @@ HastResourceEntry ::= SEQUENCE {
 hastResourceReadErrors Counter64,
 hastResourceWriteErrorsCounter64,
 hastResourceDeleteErrors   Counter64,
-hastResourceFlushErrorsCounter64
+hastResourceFlushErrorsCounter64,
+hastResourceWorkerPid  INTEGER
 }
 
 hastResourceIndex OBJECT-TYPE
@@ -295,4 +299,12 @@ hastResourceFlushErrors OBJECT-TYPE
Count of resource local flush operations that failed.
 ::= { hastResourceEntry 21 }
 
+hastResourceWorkerPid OBJECT-TYPE
+SYNTAX INTEGER
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Worker process ID.
+::= { hastResourceEntry 22 }
+
 END

Modified: stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
==
--- stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Fri Jul  5 
18:44:41 2013(r252819)
+++ stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Fri Jul  5 
18:46:35 2013(r252820)
@@ -78,6 +78,7 @@ struct hast_snmp_resource {
uint64_twrite_errors;
uint64_tdelete_errors;
uint64_tflush_errors;
+   pid_t   workerpid;
 };
 
 static TAILQ_HEAD(, hast_snmp_resource) resources =
@@ -343,6 +344,7 @@ update_resources(void)
nv_get_uint64(nvout, stat_delete_error%u, i);
res-flush_errors =
nv_get_uint64(nvout, stat_flush_error%u, i);
+   res-workerpid = nv_get_int32(nvout, workerpid%u, i);
TAILQ_INSERT_TAIL(resources, res, link);
}
nv_free(nvout);
@@ -498,6 +500,9 @@ op_hastResourceTable(struct snmp_context
case LEAF_hastResourceFlushErrors:
value-v.counter64 = res-flush_errors;
break;
+   case LEAF_hastResourceWorkerPid:
+   value-v.integer = res-workerpid;
+   break;
default:
ret = SNMP_ERR_RES_UNAVAIL;
break;

Modified: stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def
==
--- stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.defFri Jul  5 
18:44:41 2013(r252819)
+++ stable/9/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.defFri Jul  5 
18:46:35 2013(r252820)
@@ -59,6 +59,7 @@
   (19 hastResourceWriteErrors COUNTER64 GET)
   (20 hastResourceDeleteErrors COUNTER64 GET)
   (21 hastResourceFlushErrors COUNTER64 GET)
+  (22 hastResourceWorkerPid INTEGER GET)
 )
   )
 )
___
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: r252821 - stable/8/usr.sbin/bsnmpd/modules/snmp_hast

2013-07-05 Thread Mikolaj Golub
Author: trociny
Date: Fri Jul  5 18:47:25 2013
New Revision: 252821
URL: http://svnweb.freebsd.org/changeset/base/252821

Log:
  MFC r252516, r252540:
  
  Add a mib for worker process ID.

Modified:
  stable/8/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
  stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
  stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def
Directory Properties:
  stable/8/usr.sbin/bsnmpd/   (props changed)

Modified: stable/8/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
==
--- stable/8/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Fri Jul 
 5 18:46:35 2013(r252820)
+++ stable/8/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Fri Jul 
 5 18:47:25 2013(r252821)
@@ -57,6 +57,9 @@ begemotHast MODULE-IDENTITY
 REVISION 20130413Z
 DESCRIPTION
Initial revision.
+REVISION 20130701Z
+DESCRIPTION
+   Added hastResourceWorkerPid.
 ::= { begemot 220 }
 
 begemotHastObjects OBJECT IDENTIFIER ::= { begemotHast 1 }
@@ -116,7 +119,8 @@ HastResourceEntry ::= SEQUENCE {
 hastResourceReadErrors Counter64,
 hastResourceWriteErrorsCounter64,
 hastResourceDeleteErrors   Counter64,
-hastResourceFlushErrorsCounter64
+hastResourceFlushErrorsCounter64,
+hastResourceWorkerPid  INTEGER
 }
 
 hastResourceIndex OBJECT-TYPE
@@ -295,4 +299,12 @@ hastResourceFlushErrors OBJECT-TYPE
Count of resource local flush operations that failed.
 ::= { hastResourceEntry 21 }
 
+hastResourceWorkerPid OBJECT-TYPE
+SYNTAX INTEGER
+MAX-ACCESS read-only
+STATUS current
+DESCRIPTION
+   Worker process ID.
+::= { hastResourceEntry 22 }
+
 END

Modified: stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
==
--- stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Fri Jul  5 
18:46:35 2013(r252820)
+++ stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Fri Jul  5 
18:47:25 2013(r252821)
@@ -78,6 +78,7 @@ struct hast_snmp_resource {
uint64_twrite_errors;
uint64_tdelete_errors;
uint64_tflush_errors;
+   pid_t   workerpid;
 };
 
 static TAILQ_HEAD(, hast_snmp_resource) resources =
@@ -343,6 +344,7 @@ update_resources(void)
nv_get_uint64(nvout, stat_delete_error%u, i);
res-flush_errors =
nv_get_uint64(nvout, stat_flush_error%u, i);
+   res-workerpid = nv_get_int32(nvout, workerpid%u, i);
TAILQ_INSERT_TAIL(resources, res, link);
}
nv_free(nvout);
@@ -498,6 +500,9 @@ op_hastResourceTable(struct snmp_context
case LEAF_hastResourceFlushErrors:
value-v.counter64 = res-flush_errors;
break;
+   case LEAF_hastResourceWorkerPid:
+   value-v.integer = res-workerpid;
+   break;
default:
ret = SNMP_ERR_RES_UNAVAIL;
break;

Modified: stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def
==
--- stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.defFri Jul  5 
18:46:35 2013(r252820)
+++ stable/8/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.defFri Jul  5 
18:47:25 2013(r252821)
@@ -59,6 +59,7 @@
   (19 hastResourceWriteErrors COUNTER64 GET)
   (20 hastResourceDeleteErrors COUNTER64 GET)
   (21 hastResourceFlushErrors COUNTER64 GET)
+  (22 hastResourceWorkerPid INTEGER GET)
 )
   )
 )
___
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: r252829 - stable/9/sys/kern

2013-07-05 Thread Mikolaj Golub
Author: trociny
Date: Fri Jul  5 19:38:57 2013
New Revision: 252829
URL: http://svnweb.freebsd.org/changeset/base/252829

Log:
  MFC r252313, r252349, 252436:
  
  To avoid LOR, drop the filedesc lock in export_fd_to_sb(), before
  writing to sbuf.
  
  MFC r252351 (mjg):
  
  Remove duplicate NULL check in kern_proc_filedesc_out.
  No functional changes.

Modified:
  stable/9/sys/kern/kern_descrip.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_descrip.c
==
--- stable/9/sys/kern/kern_descrip.cFri Jul  5 19:36:34 2013
(r252828)
+++ stable/9/sys/kern/kern_descrip.cFri Jul  5 19:38:57 2013
(r252829)
@@ -3262,10 +3262,17 @@ static SYSCTL_NODE(_kern_proc, KERN_PROC
 CTASSERT(sizeof(struct kinfo_file) == KINFO_FILE_SIZE);
 #endif
 
+struct export_fd_buf {
+   struct filedesc *fdp;
+   struct sbuf *sb;
+   ssize_t remainder;
+   struct kinfo_file   kif;
+};
+
 static int
 export_fd_to_sb(void *data, int type, int fd, int fflags, int refcnt,
 int64_t offset, int fd_is_cap, cap_rights_t fd_cap_rights,
-struct kinfo_file *kif, struct sbuf *sb, ssize_t *remainder)
+struct export_fd_buf *efbuf)
 {
struct {
int fflag;
@@ -3288,16 +3295,23 @@ export_fd_to_sb(void *data, int type, in
{ O_TRUNC, KF_FLAG_TRUNC }
};
 #defineNFFLAGS (sizeof(fflags_table) / sizeof(*fflags_table))
+   struct kinfo_file *kif;
struct vnode *vp;
-   int error, vfslocked;
+   int error, locked, vfslocked;
unsigned int i;
 
-   if (*remainder == 0)
+   if (efbuf-remainder == 0)
return (0);
+   kif = efbuf-kif;
bzero(kif, sizeof(*kif));
+   locked = efbuf-fdp != NULL;
switch (type) {
case KF_TYPE_FIFO:
case KF_TYPE_VNODE:
+   if (locked) {
+   FILEDESC_SUNLOCK(efbuf-fdp);
+   locked = 0;
+   }
vp = (struct vnode *)data;
error = fill_vnode_info(vp, kif);
vfslocked = VFS_LOCK_GIANT(vp-v_mount);
@@ -3346,15 +3360,21 @@ export_fd_to_sb(void *data, int type, in
kif-kf_structsize = offsetof(struct kinfo_file, kf_path) +
strlen(kif-kf_path) + 1;
kif-kf_structsize = roundup(kif-kf_structsize, sizeof(uint64_t));
-   if (*remainder != -1) {
-   if (*remainder  kif-kf_structsize) {
+   if (efbuf-remainder != -1) {
+   if (efbuf-remainder  kif-kf_structsize) {
/* Terminate export. */
-   *remainder = 0;
+   efbuf-remainder = 0;
+   if (efbuf-fdp != NULL  !locked)
+   FILEDESC_SLOCK(efbuf-fdp);
return (0);
}
-   *remainder -= kif-kf_structsize;
+   efbuf-remainder -= kif-kf_structsize;
}
-   error = sbuf_bcat(sb, kif, kif-kf_structsize);
+   if (locked)
+   FILEDESC_SUNLOCK(efbuf-fdp);
+   error = sbuf_bcat(efbuf-sb, kif, kif-kf_structsize);
+   if (efbuf-fdp != NULL)
+   FILEDESC_SLOCK(efbuf-fdp);
return (error);
 }
 
@@ -3368,18 +3388,16 @@ kern_proc_filedesc_out(struct proc *p,  
 {
struct file *fp;
struct filedesc *fdp;
-   struct kinfo_file *kif;
+   struct export_fd_buf *efbuf;
struct vnode *cttyvp, *textvp, *tracevp;
int64_t offset;
void *data;
-   ssize_t remainder;
int error, i;
int fd_is_cap, type, refcnt, fflags;
cap_rights_t fd_cap_rights;
 
PROC_LOCK_ASSERT(p, MA_OWNED);
 
-   remainder = maxlen;
/* ktrace vnode */
tracevp = p-p_tracevp;
if (tracevp != NULL)
@@ -3397,46 +3415,44 @@ kern_proc_filedesc_out(struct proc *p,  
}
fdp = fdhold(p);
PROC_UNLOCK(p);
-   kif = malloc(sizeof(*kif), M_TEMP, M_WAITOK);
+   efbuf = malloc(sizeof(*efbuf), M_TEMP, M_WAITOK);
+   efbuf-fdp = NULL;
+   efbuf-sb = sb;
+   efbuf-remainder = maxlen;
if (tracevp != NULL)
export_fd_to_sb(tracevp, KF_TYPE_VNODE, KF_FD_TYPE_TRACE,
-   FREAD | FWRITE, -1, -1, 0, 0, kif, sb, remainder);
+   FREAD | FWRITE, -1, -1, 0, 0, efbuf);
if (textvp != NULL)
export_fd_to_sb(textvp, KF_TYPE_VNODE, KF_FD_TYPE_TEXT,
-   FREAD, -1, -1, 0, 0, kif, sb, remainder);
+   FREAD, -1, -1, 0, 0, efbuf);
if (cttyvp != NULL)
export_fd_to_sb(cttyvp, KF_TYPE_VNODE, KF_FD_TYPE_CTTY,
-   FREAD | FWRITE, -1, -1, 0, 0, kif, sb, remainder);
+   FREAD | FWRITE, -1, -1, 0, 0, efbuf);
error = 0;
if (fdp == NULL)

svn commit: r252710 - in head/sys: netinet netinet6

2013-07-04 Thread Mikolaj Golub
Author: trociny
Date: Thu Jul  4 18:38:00 2013
New Revision: 252710
URL: http://svnweb.freebsd.org/changeset/base/252710

Log:
  In r227207, to fix the issue with possible NULL inp_socket pointer
  dereferencing, when checking for SO_REUSEPORT option (and SO_REUSEADDR
  for multicast), INP_REUSEPORT flag was introduced to cache the socket
  option.  It was decided then that one flag would be enough to cache
  both SO_REUSEPORT and SO_REUSEADDR: when processing SO_REUSEADDR
  setsockopt(2), it was checked if it was called for a multicast address
  and INP_REUSEPORT was set accordingly.
  
  Unfortunately that approach does not work when setsockopt(2) is called
  before binding to a multicast address: the multicast check fails and
  INP_REUSEPORT is not set.
  
  Fix this by adding INP_REUSEADDR flag to unconditionally cache
  SO_REUSEADDR.
  
  PR:   179901
  Submitted by: Michael Gmelin freebsd grem.de (initial version)
  Reviewed by:  rwatson
  MFC after:1 week

Modified:
  head/sys/netinet/in_pcb.c
  head/sys/netinet/in_pcb.h
  head/sys/netinet/ip_output.c
  head/sys/netinet6/in6_pcb.c
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet/in_pcb.c
==
--- head/sys/netinet/in_pcb.c   Thu Jul  4 18:00:27 2013(r252709)
+++ head/sys/netinet/in_pcb.c   Thu Jul  4 18:38:00 2013(r252710)
@@ -467,6 +467,23 @@ in_pcb_lport(struct inpcb *inp, struct i
 
return (0);
 }
+
+/*
+ * Return cached socket options.
+ */
+short
+inp_so_options(const struct inpcb *inp)
+{
+   short so_options;
+
+   so_options = 0;
+
+   if ((inp-inp_flags2  INP_REUSEPORT) != 0)
+  so_options |= SO_REUSEPORT;
+   if ((inp-inp_flags2  INP_REUSEADDR) != 0)
+  so_options |= SO_REUSEADDR;
+   return (so_options);
+}
 #endif /* INET || INET6 */
 
 #ifdef INET
@@ -595,8 +612,7 @@ in_pcbbind_setup(struct inpcb *inp, stru
if (tw == NULL ||
(reuseport  tw-tw_so_options) == 0)
return (EADDRINUSE);
-   } else if (t  (reuseport == 0 ||
-   (t-inp_flags2  INP_REUSEPORT) == 0)) {
+   } else if (t  (reuseport  inp_so_options(t)) == 0) {
 #ifdef INET6
if (ntohl(sin-sin_addr.s_addr) !=
INADDR_ANY ||

Modified: head/sys/netinet/in_pcb.h
==
--- head/sys/netinet/in_pcb.h   Thu Jul  4 18:00:27 2013(r252709)
+++ head/sys/netinet/in_pcb.h   Thu Jul  4 18:38:00 2013(r252710)
@@ -442,6 +442,7 @@ struct tcpcb *
inp_inpcbtotcpcb(struct inpcb *inp);
 void   inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
uint32_t *faddr, uint16_t *fp);
+short  inp_so_options(const struct inpcb *inp);
 
 #endif /* _KERNEL */
 
@@ -543,6 +544,7 @@ voidinp_4tuple_get(struct inpcb *inp, 
 #defineINP_PCBGROUPWILD0x0004 /* in pcbgroup wildcard list 
*/
 #defineINP_REUSEPORT   0x0008 /* SO_REUSEPORT option is 
set */
 #defineINP_FREED   0x0010 /* inp itself is not valid */
+#defineINP_REUSEADDR   0x0020 /* SO_REUSEADDR option is 
set */
 
 /*
  * Flags passed to in_pcblookup*() functions.

Modified: head/sys/netinet/ip_output.c
==
--- head/sys/netinet/ip_output.cThu Jul  4 18:00:27 2013
(r252709)
+++ head/sys/netinet/ip_output.cThu Jul  4 18:38:00 2013
(r252710)
@@ -900,13 +900,10 @@ ip_ctloutput(struct socket *so, struct s
switch (sopt-sopt_name) {
case SO_REUSEADDR:
INP_WLOCK(inp);
-   if (IN_MULTICAST(ntohl(inp-inp_laddr.s_addr))) 
{
-   if ((so-so_options 
-   (SO_REUSEADDR | SO_REUSEPORT)) != 0)
-   inp-inp_flags2 |= 
INP_REUSEPORT;
-   else
-   inp-inp_flags2 = 
~INP_REUSEPORT;
-   }
+   if ((so-so_options  SO_REUSEADDR) != 0)
+   inp-inp_flags2 |= INP_REUSEADDR;
+   else
+   inp-inp_flags2 = ~INP_REUSEADDR;
INP_WUNLOCK(inp);
error = 0;
break;

Modified: head/sys/netinet6/in6_pcb.c
==
--- head/sys/netinet6/in6_pcb.c Thu Jul  4 18:00:27 2013(r252709)
+++ 

Re: svn commit: r252710 - in head/sys: netinet netinet6

2013-07-04 Thread Mikolaj Golub
On Thu, Jul 04, 2013 at 06:38:01PM +, Mikolaj Golub wrote:
 Author: trociny
 Date: Thu Jul  4 18:38:00 2013
 New Revision: 252710
 URL: http://svnweb.freebsd.org/changeset/base/252710
 
 Log:
   In r227207, to fix the issue with possible NULL inp_socket pointer
   dereferencing, when checking for SO_REUSEPORT option (and SO_REUSEADDR
   for multicast), INP_REUSEPORT flag was introduced to cache the socket
   option.  It was decided then that one flag would be enough to cache
   both SO_REUSEPORT and SO_REUSEADDR: when processing SO_REUSEADDR
   setsockopt(2), it was checked if it was called for a multicast address
   and INP_REUSEPORT was set accordingly.
   
   Unfortunately that approach does not work when setsockopt(2) is called
   before binding to a multicast address: the multicast check fails and
   INP_REUSEPORT is not set.
   
   Fix this by adding INP_REUSEADDR flag to unconditionally cache
   SO_REUSEADDR.
   
   PR: 179901
   Submitted by:   Michael Gmelin freebsd grem.de (initial version)
   Reviewed by:rwatson
   MFC after:  1 week

Also, in this PR another issue is reported by Michael: if SO_REUSEADDR
is set for the first multicast bound socket and one tries to bind a
socket to the same address:port with SO_REUSEPORT, it fails, although
for multicast there should not be difference between SO_REUSEPORT and
SO_REUSEADDR. This is an old issue (observed on FreeBSD7 too), but I
would like to fix it. Below is a patch I am going to commit to HEAD.
Though I am not going to MFC it before 9.2 unless I have strong
support from people.

-- 
Mikolaj Golub
commit 7cf3a6a95d74ae91c80350fc1ae8e96fe59c3c65
Author: Mikolaj Golub troc...@freebsd.org
Date:   Sun Jun 30 00:09:20 2013 +0300

A complete duplication of binding should be allowed if on both new and
duplicated sockets a multicast address is bound and either
SO_REUSEPORT or SO_REUSEADDR is set.

But actually it works for the following combinations:

 * SO_REUSEPORT is set for the fist socket and SO_REUSEPORT for the new;
 * SO_REUSEADDR is set for the fist socket and SO_REUSEADDR for the new;
 * SO_REUSEPORT is set for the fist socket and SO_REUSEADDR for the new;

and fails for this:

 * SO_REUSEADDR is set for the fist socket and SO_REUSEPORT for the new.

Fix the last case.

PR:		179901

diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 3506b74..eb15a38 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -554,7 +554,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
 			 * and a multicast address is bound on both
 			 * new and duplicated sockets.
 			 */
-			if (so-so_options  SO_REUSEADDR)
+			if ((so-so_options  (SO_REUSEADDR|SO_REUSEPORT)) != 0)
 reuseport = SO_REUSEADDR|SO_REUSEPORT;
 		} else if (sin-sin_addr.s_addr != INADDR_ANY) {
 			sin-sin_port = 0;		/* yech... */
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index a0a6874..fb84279 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -156,7 +156,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
 			 * and a multicast address is bound on both
 			 * new and duplicated sockets.
 			 */
-			if (so-so_options  SO_REUSEADDR)
+			if ((so-so_options  (SO_REUSEADDR|SO_REUSEPORT)) != 0)
 reuseport = SO_REUSEADDR|SO_REUSEPORT;
 		} else if (!IN6_IS_ADDR_UNSPECIFIED(sin6-sin6_addr)) {
 			struct ifaddr *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

svn commit: r252516 - head/usr.sbin/bsnmpd/modules/snmp_hast

2013-07-02 Thread Mikolaj Golub
Author: trociny
Date: Tue Jul  2 18:54:39 2013
New Revision: 252516
URL: http://svnweb.freebsd.org/changeset/base/252516

Log:
  Add a mib for worker process ID.
  
  MFC after:3 days

Modified:
  head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
  head/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
  head/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def

Modified: head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
==
--- head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Tue Jul  2 
18:45:37 2013(r252515)
+++ head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Tue Jul  2 
18:54:39 2013(r252516)
@@ -57,6 +57,9 @@ begemotHast MODULE-IDENTITY
 REVISION 20130413Z
 DESCRIPTION
Initial revision.
+REVISION 20130701Z
+DESCRIPTION
+   Added hastResourceWorkerPid.
 ::= { begemot 220 }
 
 begemotHastObjects OBJECT IDENTIFIER ::= { begemotHast 1 }
@@ -116,7 +119,8 @@ HastResourceEntry ::= SEQUENCE {
 hastResourceReadErrors Counter64,
 hastResourceWriteErrorsCounter64,
 hastResourceDeleteErrors   Counter64,
-hastResourceFlushErrorsCounter64
+hastResourceFlushErrorsCounter64,
+hastResourceWorkerPid  INTEGER
 }
 
 hastResourceIndex OBJECT-TYPE
@@ -295,4 +299,12 @@ hastResourceFlushErrors OBJECT-TYPE
Count of resource local flush operations that failed.
 ::= { hastResourceEntry 21 }
 
+hastResourceWorkerPid OBJECT-TYPE
+SYNTAX INTEGER
+MAX-ACCESS read-write
+STATUS current
+DESCRIPTION
+   Worker process ID.
+::= { hastResourceEntry 22 }
+
 END

Modified: head/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
==
--- head/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Tue Jul  2 18:45:37 
2013(r252515)
+++ head/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c  Tue Jul  2 18:54:39 
2013(r252516)
@@ -78,6 +78,7 @@ struct hast_snmp_resource {
uint64_twrite_errors;
uint64_tdelete_errors;
uint64_tflush_errors;
+   pid_t   workerpid;
 };
 
 static TAILQ_HEAD(, hast_snmp_resource) resources =
@@ -343,6 +344,7 @@ update_resources(void)
nv_get_uint64(nvout, stat_delete_error%u, i);
res-flush_errors =
nv_get_uint64(nvout, stat_flush_error%u, i);
+   res-workerpid = nv_get_int32(nvout, workerpid%u, i);
TAILQ_INSERT_TAIL(resources, res, link);
}
nv_free(nvout);
@@ -498,6 +500,9 @@ op_hastResourceTable(struct snmp_context
case LEAF_hastResourceFlushErrors:
value-v.counter64 = res-flush_errors;
break;
+   case LEAF_hastResourceWorkerPid:
+   value-v.integer = res-workerpid;
+   break;
default:
ret = SNMP_ERR_RES_UNAVAIL;
break;

Modified: head/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def
==
--- head/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.defTue Jul  2 
18:45:37 2013(r252515)
+++ head/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.defTue Jul  2 
18:54:39 2013(r252516)
@@ -59,6 +59,7 @@
   (19 hastResourceWriteErrors COUNTER64 GET)
   (20 hastResourceDeleteErrors COUNTER64 GET)
   (21 hastResourceFlushErrors COUNTER64 GET)
+  (22 hastResourceWorkerPid INTEGER GET)
 )
   )
 )
___
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: r252517 - stable/9/sbin/hastd

2013-07-02 Thread Mikolaj Golub
Author: trociny
Date: Tue Jul  2 19:27:07 2013
New Revision: 252517
URL: http://svnweb.freebsd.org/changeset/base/252517

Log:
  MFC r248294, r248296:
  
  r248294 (pjd):
  
  Delete requests can be larger than MAXPHYS.
  
  r248296 (pjd):
  
  Minor corrections.

Modified:
  stable/9/sbin/hastd/hastd.8
  stable/9/sbin/hastd/secondary.c
Directory Properties:
  stable/9/sbin/hastd/   (props changed)

Modified: stable/9/sbin/hastd/hastd.8
==
--- stable/9/sbin/hastd/hastd.8 Tue Jul  2 18:54:39 2013(r252516)
+++ stable/9/sbin/hastd/hastd.8 Tue Jul  2 19:27:07 2013(r252517)
@@ -51,7 +51,7 @@ Only one machine (cluster node) can acti
 This machine is called primary.
 The
 .Nm
-daemon operates on block level, which makes it transparent for file
+daemon operates on block level, which makes it transparent to file
 systems and applications.
 .Pp
 There is one main
@@ -68,7 +68,7 @@ The exact format is:
 hastd: resource name (role)
 .Ed
 .Pp
-When (and only when)
+If (and only if)
 .Nm
 operates in primary role for the given resource, corresponding
 .Pa /dev/hast/name
@@ -77,8 +77,8 @@ File systems and applications can use th
 requests to.
 Every write, delete and flush operation
 .Dv ( BIO_WRITE , BIO_DELETE , BIO_FLUSH )
-is send to local component and synchronously replicated
-to the remote (secondary) node if it is available.
+is send to local component and replicated to the remote (secondary) node if it
+is available.
 Read operations
 .Dv ( BIO_READ )
 are handled locally unless I/O error occurs or local version of the data

Modified: stable/9/sbin/hastd/secondary.c
==
--- stable/9/sbin/hastd/secondary.c Tue Jul  2 18:54:39 2013
(r252516)
+++ stable/9/sbin/hastd/secondary.c Tue Jul  2 19:27:07 2013
(r252517)
@@ -582,7 +582,7 @@ requnpack(struct hast_resource *res, str
hio-hio_error = EINVAL;
goto end;
}
-   if (hio-hio_length  MAXPHYS) {
+   if (hio-hio_cmd != HIO_DELETE  hio-hio_length  MAXPHYS) {
pjdlog_error(Data length is too large (%ju  %ju).,
(uintmax_t)hio-hio_length, (uintmax_t)MAXPHYS);
hio-hio_error = EINVAL;
___
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: r252518 - stable/8/sbin/hastd

2013-07-02 Thread Mikolaj Golub
Author: trociny
Date: Tue Jul  2 19:28:16 2013
New Revision: 252518
URL: http://svnweb.freebsd.org/changeset/base/252518

Log:
  MFC r248294, r248296:
  
  r248294 (pjd):
  
  Delete requests can be larger than MAXPHYS.
  
  r248296 (pjd):
  
  Minor corrections.

Modified:
  stable/8/sbin/hastd/hastd.8
  stable/8/sbin/hastd/secondary.c
Directory Properties:
  stable/8/sbin/hastd/   (props changed)

Modified: stable/8/sbin/hastd/hastd.8
==
--- stable/8/sbin/hastd/hastd.8 Tue Jul  2 19:27:07 2013(r252517)
+++ stable/8/sbin/hastd/hastd.8 Tue Jul  2 19:28:16 2013(r252518)
@@ -51,7 +51,7 @@ Only one machine (cluster node) can acti
 This machine is called primary.
 The
 .Nm
-daemon operates on block level, which makes it transparent for file
+daemon operates on block level, which makes it transparent to file
 systems and applications.
 .Pp
 There is one main
@@ -68,7 +68,7 @@ The exact format is:
 hastd: resource name (role)
 .Ed
 .Pp
-When (and only when)
+If (and only if)
 .Nm
 operates in primary role for the given resource, corresponding
 .Pa /dev/hast/name
@@ -77,8 +77,8 @@ File systems and applications can use th
 requests to.
 Every write, delete and flush operation
 .Dv ( BIO_WRITE , BIO_DELETE , BIO_FLUSH )
-is send to local component and synchronously replicated
-to the remote (secondary) node if it is available.
+is send to local component and replicated to the remote (secondary) node if it
+is available.
 Read operations
 .Dv ( BIO_READ )
 are handled locally unless I/O error occurs or local version of the data

Modified: stable/8/sbin/hastd/secondary.c
==
--- stable/8/sbin/hastd/secondary.c Tue Jul  2 19:27:07 2013
(r252517)
+++ stable/8/sbin/hastd/secondary.c Tue Jul  2 19:28:16 2013
(r252518)
@@ -582,7 +582,7 @@ requnpack(struct hast_resource *res, str
hio-hio_error = EINVAL;
goto end;
}
-   if (hio-hio_length  MAXPHYS) {
+   if (hio-hio_cmd != HIO_DELETE  hio-hio_length  MAXPHYS) {
pjdlog_error(Data length is too large (%ju  %ju).,
(uintmax_t)hio-hio_length, (uintmax_t)MAXPHYS);
hio-hio_error = EINVAL;
___
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: r252519 - stable/9/sbin/hastctl

2013-07-02 Thread Mikolaj Golub
Author: trociny
Date: Tue Jul  2 19:29:00 2013
New Revision: 252519
URL: http://svnweb.freebsd.org/changeset/base/252519

Log:
  MFC r248286 (pjd):
  
  Removed redundant includes.

Modified:
  stable/9/sbin/hastctl/hastctl.c
Directory Properties:
  stable/9/sbin/hastctl/   (props changed)

Modified: stable/9/sbin/hastctl/hastctl.c
==
--- stable/9/sbin/hastctl/hastctl.c Tue Jul  2 19:28:16 2013
(r252518)
+++ stable/9/sbin/hastctl/hastctl.c Tue Jul  2 19:29:00 2013
(r252519)
@@ -31,21 +31,11 @@
 __FBSDID($FreeBSD$);
 
 #include sys/param.h
-#include sys/disk.h
-#include sys/ioctl.h
-#include sys/stat.h
-#include sys/sysctl.h
 
 #include err.h
-#include errno.h
-#include fcntl.h
 #include libutil.h
-#include limits.h
-#include signal.h
 #include stdio.h
-#include stdlib.h
 #include string.h
-#include sysexits.h
 #include unistd.h
 
 #include activemap.h
___
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: r252520 - stable/8/sbin/hastctl

2013-07-02 Thread Mikolaj Golub
Author: trociny
Date: Tue Jul  2 19:29:45 2013
New Revision: 252520
URL: http://svnweb.freebsd.org/changeset/base/252520

Log:
  MFC r248286 (pjd):
  
  Removed redundant includes.

Modified:
  stable/8/sbin/hastctl/hastctl.c
Directory Properties:
  stable/8/sbin/hastctl/   (props changed)

Modified: stable/8/sbin/hastctl/hastctl.c
==
--- stable/8/sbin/hastctl/hastctl.c Tue Jul  2 19:29:00 2013
(r252519)
+++ stable/8/sbin/hastctl/hastctl.c Tue Jul  2 19:29:45 2013
(r252520)
@@ -31,21 +31,11 @@
 __FBSDID($FreeBSD$);
 
 #include sys/param.h
-#include sys/disk.h
-#include sys/ioctl.h
-#include sys/stat.h
-#include sys/sysctl.h
 
 #include err.h
-#include errno.h
-#include fcntl.h
 #include libutil.h
-#include limits.h
-#include signal.h
 #include stdio.h
-#include stdlib.h
 #include string.h
-#include sysexits.h
 #include unistd.h
 
 #include activemap.h
___
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: r252540 - head/usr.sbin/bsnmpd/modules/snmp_hast

2013-07-02 Thread Mikolaj Golub
Author: trociny
Date: Wed Jul  3 05:54:23 2013
New Revision: 252540
URL: http://svnweb.freebsd.org/changeset/base/252540

Log:
  hastResourceWorkerPid is read-only.
  
  Submitted by: jilles
  MFC after:3 days

Modified:
  head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt

Modified: head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
==
--- head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Wed Jul  3 
05:48:46 2013(r252539)
+++ head/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt Wed Jul  3 
05:54:23 2013(r252540)
@@ -301,7 +301,7 @@ hastResourceFlushErrors OBJECT-TYPE
 
 hastResourceWorkerPid OBJECT-TYPE
 SYNTAX INTEGER
-MAX-ACCESS read-write
+MAX-ACCESS read-only
 STATUS current
 DESCRIPTION
Worker process ID.
___
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: r252516 - head/usr.sbin/bsnmpd/modules/snmp_hast

2013-07-02 Thread Mikolaj Golub
On Tue, Jul 02, 2013 at 11:40:50PM +0200, Jilles Tjoelker wrote:

  +hastResourceWorkerPid OBJECT-TYPE
  +SYNTAX INTEGER
  +MAX-ACCESS read-write
 
 I think MAX-ACCESS should be read-only here. The process ID is assigned
 when the worker process is created and it makes no sense for a network
 management system to change it.

Yes, it was intended to be read-only. Fixed. Thank you for spotting this.

-- 
Mikolaj Golub
___
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: r252472 - in head/sbin: hastctl hastd

2013-07-01 Thread Mikolaj Golub
Author: trociny
Date: Mon Jul  1 18:41:07 2013
New Revision: 252472
URL: http://svnweb.freebsd.org/changeset/base/252472

Log:
  Make hastctl(1) ('list' command) output a worker pid.
  
  Reviewed by:  pjd
  MFC after:3 days

Modified:
  head/sbin/hastctl/hastctl.c
  head/sbin/hastd/control.c

Modified: head/sbin/hastctl/hastctl.c
==
--- head/sbin/hastctl/hastctl.c Mon Jul  1 17:57:22 2013(r252471)
+++ head/sbin/hastctl/hastctl.c Mon Jul  1 18:41:07 2013(r252472)
@@ -293,6 +293,7 @@ control_set_role(struct nv *nv, const ch
 static int
 control_list(struct nv *nv)
 {
+   pid_t pid;
unsigned int ii;
const char *str;
int error, ret;
@@ -331,6 +332,9 @@ control_list(struct nv *nv)
str = nv_get_string(nv, status%u, ii);
if (str != NULL)
printf(  status: %s\n, str);
+   pid = nv_get_int32(nv, workerpid%u, ii);
+   if (pid != 0)
+   printf(  workerpid: %d\n, pid);
printf(  dirty: %ju (%NB)\n,
(uintmax_t)nv_get_uint64(nv, dirty%u, ii),
(intmax_t)nv_get_uint64(nv, dirty%u, ii));

Modified: head/sbin/hastd/control.c
==
--- head/sbin/hastd/control.c   Mon Jul  1 17:57:22 2013(r252471)
+++ head/sbin/hastd/control.c   Mon Jul  1 18:41:07 2013(r252472)
@@ -271,6 +271,7 @@ control_status(struct hastd_config *cfg,
nv_add_string(nvout, compression_name(res-hr_compression),
compression%u, no);
nv_add_string(nvout, role2str(res-hr_role), role%u, no);
+   nv_add_int32(nvout, res-hr_workerpid, workerpid%u, no);
 
switch (res-hr_role) {
case HAST_ROLE_PRIMARY:
___
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: r252410 - stable/9/lib/libprocstat

2013-06-30 Thread Mikolaj Golub
Author: trociny
Date: Sun Jun 30 08:36:19 2013
New Revision: 252410
URL: http://svnweb.freebsd.org/changeset/base/252410

Log:
  MFC r250378:
  
  Make errbuf optional, so if a caller is not interested in an error
  message she can pass NULL (procstat(1) already does this).

Modified:
  stable/9/lib/libprocstat/libprocstat.c
Directory Properties:
  stable/9/lib/libprocstat/   (props changed)

Modified: stable/9/lib/libprocstat/libprocstat.c
==
--- stable/9/lib/libprocstat/libprocstat.c  Sun Jun 30 07:46:22 2013
(r252409)
+++ stable/9/lib/libprocstat/libprocstat.c  Sun Jun 30 08:36:19 2013
(r252410)
@@ -902,7 +902,8 @@ procstat_get_pipe_info(struct procstat *
return (procstat_get_pipe_info_sysctl(fst, ps, errbuf));
} else {
warnx(unknown access method: %d, procstat-type);
-   snprintf(errbuf, _POSIX2_LINE_MAX, error);
+   if (errbuf != NULL)
+   snprintf(errbuf, _POSIX2_LINE_MAX, error);
return (1);
}
 }
@@ -931,7 +932,8 @@ procstat_get_pipe_info_kvm(kvm_t *kd, st
return (0);
 
 fail:
-   snprintf(errbuf, _POSIX2_LINE_MAX, error);
+   if (errbuf != NULL)
+   snprintf(errbuf, _POSIX2_LINE_MAX, error);
return (1);
 }
 
@@ -967,7 +969,8 @@ procstat_get_pts_info(struct procstat *p
return (procstat_get_pts_info_sysctl(fst, pts, errbuf));
} else {
warnx(unknown access method: %d, procstat-type);
-   snprintf(errbuf, _POSIX2_LINE_MAX, error);
+   if (errbuf != NULL)
+   snprintf(errbuf, _POSIX2_LINE_MAX, error);
return (1);
}
 }
@@ -995,7 +998,8 @@ procstat_get_pts_info_kvm(kvm_t *kd, str
return (0);
 
 fail:
-   snprintf(errbuf, _POSIX2_LINE_MAX, error);
+   if (errbuf != NULL)
+   snprintf(errbuf, _POSIX2_LINE_MAX, error);
return (1);
 }
 
@@ -1030,7 +1034,8 @@ procstat_get_sem_info(struct procstat *p
return (procstat_get_sem_info_sysctl(fst, sem, errbuf));
} else {
warnx(unknown access method: %d, procstat-type);
-   snprintf(errbuf, _POSIX2_LINE_MAX, error);
+   if (errbuf != NULL)
+   snprintf(errbuf, _POSIX2_LINE_MAX, error);
return (1);
}
 }
@@ -1076,7 +1081,8 @@ procstat_get_sem_info_kvm(kvm_t *kd, str
return (0);
 
 fail:
-   snprintf(errbuf, _POSIX2_LINE_MAX, error);
+   if (errbuf != NULL)
+   snprintf(errbuf, _POSIX2_LINE_MAX, error);
return (1);
 }
 
@@ -,7 +1117,8 @@ procstat_get_shm_info(struct procstat *p
return (procstat_get_shm_info_sysctl(fst, shm, errbuf));
} else {
warnx(unknown access method: %d, procstat-type);
-   snprintf(errbuf, _POSIX2_LINE_MAX, error);
+   if (errbuf != NULL)
+   snprintf(errbuf, _POSIX2_LINE_MAX, error);
return (1);
}
 }
@@ -1157,7 +1164,8 @@ procstat_get_shm_info_kvm(kvm_t *kd, str
return (0);
 
 fail:
-   snprintf(errbuf, _POSIX2_LINE_MAX, error);
+   if (errbuf != NULL)
+   snprintf(errbuf, _POSIX2_LINE_MAX, error);
return (1);
 }
 
@@ -1192,7 +1200,8 @@ procstat_get_vnode_info(struct procstat 
return (procstat_get_vnode_info_sysctl(fst, vn, errbuf));
} else {
warnx(unknown access method: %d, procstat-type);
-   snprintf(errbuf, _POSIX2_LINE_MAX, error);
+   if (errbuf != NULL)
+   snprintf(errbuf, _POSIX2_LINE_MAX, error);
return (1);
}
 }
@@ -1264,7 +1273,8 @@ procstat_get_vnode_info_kvm(kvm_t *kd, s
break;
}
if (i == NTYPES) {
-   snprintf(errbuf, _POSIX2_LINE_MAX, ?(%s), tagstr);
+   if (errbuf != NULL)
+   snprintf(errbuf, _POSIX2_LINE_MAX, ?(%s), tagstr);
return (1);
}
vn-vn_mntdir = getmnton(kd, vnode.v_mount);
@@ -1278,7 +1288,8 @@ procstat_get_vnode_info_kvm(kvm_t *kd, s
return (0);
 
 fail:
-   snprintf(errbuf, _POSIX2_LINE_MAX, error);
+   if (errbuf != NULL)
+   snprintf(errbuf, _POSIX2_LINE_MAX, error);
return (1);
 }
 
@@ -1359,7 +1370,10 @@ procstat_get_vnode_info_sysctl(struct fi
if (vntype == PS_FST_VTYPE_VNON || vntype == PS_FST_VTYPE_VBAD)
return (0);
if ((status  KF_ATTR_VALID) == 0) {
-   snprintf(errbuf, _POSIX2_LINE_MAX, ? (no info available));
+   if (errbuf != NULL) {
+   snprintf(errbuf, _POSIX2_LINE_MAX,
+   ? (no info available));
+   }
return (1);
}
if (path  *path) 

svn commit: r252436 - head/sys/kern

2013-06-30 Thread Mikolaj Golub
Author: trociny
Date: Mon Jul  1 03:27:14 2013
New Revision: 252436
URL: http://svnweb.freebsd.org/changeset/base/252436

Log:
  Plug up the lock lock leakage when exporting to a short buffer.
  
  Reported by:  Alexander Leidinger
  Submitted by: mjg
  MFC after:1 week

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cMon Jul  1 03:00:15 2013
(r252435)
+++ head/sys/kern/kern_descrip.cMon Jul  1 03:27:14 2013
(r252436)
@@ -3272,6 +3272,8 @@ export_fd_to_sb(void *data, int type, in
if (efbuf-remainder  kif-kf_structsize) {
/* Terminate export. */
efbuf-remainder = 0;
+   if (efbuf-fdp != NULL  !locked)
+   FILEDESC_SLOCK(efbuf-fdp);
return (0);
}
efbuf-remainder -= kif-kf_structsize;
___
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: r252313 - head/sys/kern

2013-06-28 Thread Mikolaj Golub
On Fri, Jun 28, 2013 at 09:44:30AM +0300, Konstantin Belousov wrote:
 On Fri, Jun 28, 2013 at 03:03:46AM +0200, Mateusz Guzik wrote:
  On Thu, Jun 27, 2013 at 07:14:04PM +, Mikolaj Golub wrote:
   Author: trociny
   Date: Thu Jun 27 19:14:03 2013
   New Revision: 252313
   URL: http://svnweb.freebsd.org/changeset/base/252313
   
   Log:
 To avoid LOR, always drop the filedesc lock before exporting fd to sbuf.
 
 Reviewed by:kib
 MFC after:  3 days
   
   Modified:
 head/sys/kern/kern_descrip.c
   
   Modified: head/sys/kern/kern_descrip.c
   ==
   --- head/sys/kern/kern_descrip.c  Thu Jun 27 18:59:07 2013
   (r252312)
   +++ head/sys/kern/kern_descrip.c  Thu Jun 27 19:14:03 2013
   (r252313)
   @@ -3427,12 +3427,10 @@ kern_proc_filedesc_out(struct proc *p,  
  * re-validate and re-evaluate its properties when
  * the loop continues.
  */
   - if (type == KF_TYPE_VNODE || type == KF_TYPE_FIFO)
   - FILEDESC_SUNLOCK(fdp);
   + FILEDESC_SUNLOCK(fdp);
 error = export_fd_to_sb(data, type, i, fflags, refcnt,
 offset, fd_cap_rights, kif, sb, remainder);
   - if (type == KF_TYPE_VNODE || type == KF_TYPE_FIFO)
   - FILEDESC_SLOCK(fdp);
   + FILEDESC_SLOCK(fdp);
 if (error)
 break;
 }
  
  Is this really ok? What prevents given fd from going away during
  export_fd_to_sb execution? Both DTYPE_VNODE and DTYPE_FIFO pass down
  a vrefed vnode so these are safe. But for example DTYPE_SOCKET goes with
  fp-f_data, which can go away in the meantime (or I'm misreading the code).
  

Thanks!

  I suggest obtainng ref to fp and passing it down in all cases.
 
 Oops, I am sorry for missed this. But, I do not actually like the
 idea of referencing the fd.  It de-facto means that the process calling
 the sysctl duped the descriptor, potentially causing the close to be
 performed in the sysctl context on dereference.
 
 Ideal solution would be to drop the filedesc lock between processing
 of the filedescriptors and draining sbuf while lock is dropped.

You mean something like below? (not well tested yet)

-- 
Mikolaj Golub
Index: sys/kern/kern_descrip.c
===
--- sys/kern/kern_descrip.c	(revision 252313)
+++ sys/kern/kern_descrip.c	(working copy)
@@ -3176,10 +3176,16 @@
 CTASSERT(sizeof(struct kinfo_file) == KINFO_FILE_SIZE);
 #endif
 
+struct export_fd_buf {
+	struct filedesc		*fdp;
+	struct sbuf 		*sb;
+	ssize_t			remainder;
+	struct kinfo_file	kif;
+};
+
 static int
 export_fd_to_sb(void *data, int type, int fd, int fflags, int refcnt,
-int64_t offset, cap_rights_t fd_cap_rights, struct kinfo_file *kif,
-struct sbuf *sb, ssize_t *remainder)
+int64_t offset, cap_rights_t fd_cap_rights, struct export_fd_buf *efbuf)
 {
 	struct {
 		int	fflag;
@@ -3202,16 +3208,20 @@
 		{ O_TRUNC, KF_FLAG_TRUNC }
 	};
 #define	NFFLAGS	(sizeof(fflags_table) / sizeof(*fflags_table))
+	struct kinfo_file *kif;
 	struct vnode *vp;
 	int error;
 	unsigned int i;
 
-	if (*remainder == 0)
+	if (efbuf-remainder == 0)
 		return (0);
+	kif = efbuf-kif;
 	bzero(kif, sizeof(*kif));
 	switch (type) {
 	case KF_TYPE_FIFO:
 	case KF_TYPE_VNODE:
+		if (efbuf-fdp != NULL)
+			FILEDESC_SUNLOCK(efbuf-fdp);
 		vp = (struct vnode *)data;
 		error = fill_vnode_info(vp, kif);
 		vrele(vp);
@@ -3255,15 +3265,19 @@
 	kif-kf_structsize = offsetof(struct kinfo_file, kf_path) +
 	strlen(kif-kf_path) + 1;
 	kif-kf_structsize = roundup(kif-kf_structsize, sizeof(uint64_t));
-	if (*remainder != -1) {
-		if (*remainder  kif-kf_structsize) {
+	if (efbuf-remainder != -1) {
+		if (efbuf-remainder  kif-kf_structsize) {
 			/* Terminate export. */
-			*remainder = 0;
+			efbuf-remainder = 0;
 			return (0);
 		}
-		*remainder -= kif-kf_structsize;
+		efbuf-remainder -= kif-kf_structsize;
 	}
-	error = sbuf_bcat(sb, kif, kif-kf_structsize);
+	if (efbuf-fdp != NULL  type != KF_TYPE_FIFO  type != KF_TYPE_VNODE)
+		FILEDESC_SUNLOCK(efbuf-fdp);
+	error = sbuf_bcat(efbuf-sb, kif, kif-kf_structsize);
+	if (efbuf-fdp != NULL)
+		FILEDESC_SLOCK(efbuf-fdp);
 	return (error);
 }
 
@@ -3277,18 +3291,16 @@
 {
 	struct file *fp;
 	struct filedesc *fdp;
-	struct kinfo_file *kif;
+	struct export_fd_buf *efbuf;
 	struct vnode *cttyvp, *textvp, *tracevp;
 	int64_t offset;
 	void *data;
-	ssize_t remainder;
 	int error, i;
 	int type, refcnt, fflags;
 	cap_rights_t fd_cap_rights;
 
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 
-	remainder = maxlen;
 	/* ktrace vnode */
 	tracevp = p-p_tracevp;
 	if (tracevp != NULL)
@@ -3306,46 +3318,44 @@
 	}
 	fdp = fdhold(p);
 	PROC_UNLOCK(p);
-	kif = malloc(sizeof(*kif), M_TEMP, M_WAITOK);
+	efbuf = malloc(sizeof(*efbuf), M_TEMP, M_WAITOK);
+	efbuf-fdp = NULL;
+	efbuf-sb = sb;
+	efbuf-remainder = maxlen

svn commit: r252349 - head/sys/kern

2013-06-28 Thread Mikolaj Golub
Author: trociny
Date: Fri Jun 28 18:07:41 2013
New Revision: 252349
URL: http://svnweb.freebsd.org/changeset/base/252349

Log:
  Rework r252313:
  
  The filedesc lock may not be dropped unconditionally before exporting
  fd to sbuf: fd might go away during execution.  While it is ok for
  DTYPE_VNODE and DTYPE_FIFO because the export is from a vrefed vnode
  here, for other types it is unsafe.
  
  Instead, drop the lock in export_fd_to_sb(), after preparing data in
  memory and before writing to sbuf.
  
  Spotted by:   mjg
  Suggested by: kib
  Review by:kib
  MFC after:1 week

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Jun 28 17:18:28 2013
(r252348)
+++ head/sys/kern/kern_descrip.cFri Jun 28 18:07:41 2013
(r252349)
@@ -3176,10 +3176,16 @@ static SYSCTL_NODE(_kern_proc, KERN_PROC
 CTASSERT(sizeof(struct kinfo_file) == KINFO_FILE_SIZE);
 #endif
 
+struct export_fd_buf {
+   struct filedesc *fdp;
+   struct sbuf *sb;
+   ssize_t remainder;
+   struct kinfo_file   kif;
+};
+
 static int
 export_fd_to_sb(void *data, int type, int fd, int fflags, int refcnt,
-int64_t offset, cap_rights_t fd_cap_rights, struct kinfo_file *kif,
-struct sbuf *sb, ssize_t *remainder)
+int64_t offset, cap_rights_t fd_cap_rights, struct export_fd_buf *efbuf)
 {
struct {
int fflag;
@@ -3202,16 +3208,23 @@ export_fd_to_sb(void *data, int type, in
{ O_TRUNC, KF_FLAG_TRUNC }
};
 #defineNFFLAGS (sizeof(fflags_table) / sizeof(*fflags_table))
+   struct kinfo_file *kif;
struct vnode *vp;
-   int error;
+   int error, locked;
unsigned int i;
 
-   if (*remainder == 0)
+   if (efbuf-remainder == 0)
return (0);
+   kif = efbuf-kif;
bzero(kif, sizeof(*kif));
+   locked = efbuf-fdp != NULL;
switch (type) {
case KF_TYPE_FIFO:
case KF_TYPE_VNODE:
+   if (locked) {
+   FILEDESC_SUNLOCK(efbuf-fdp);
+   locked = 0;
+   }
vp = (struct vnode *)data;
error = fill_vnode_info(vp, kif);
vrele(vp);
@@ -3255,15 +3268,19 @@ export_fd_to_sb(void *data, int type, in
kif-kf_structsize = offsetof(struct kinfo_file, kf_path) +
strlen(kif-kf_path) + 1;
kif-kf_structsize = roundup(kif-kf_structsize, sizeof(uint64_t));
-   if (*remainder != -1) {
-   if (*remainder  kif-kf_structsize) {
+   if (efbuf-remainder != -1) {
+   if (efbuf-remainder  kif-kf_structsize) {
/* Terminate export. */
-   *remainder = 0;
+   efbuf-remainder = 0;
return (0);
}
-   *remainder -= kif-kf_structsize;
+   efbuf-remainder -= kif-kf_structsize;
}
-   error = sbuf_bcat(sb, kif, kif-kf_structsize);
+   if (locked)
+   FILEDESC_SUNLOCK(efbuf-fdp);
+   error = sbuf_bcat(efbuf-sb, kif, kif-kf_structsize);
+   if (efbuf-fdp != NULL)
+   FILEDESC_SLOCK(efbuf-fdp);
return (error);
 }
 
@@ -3277,18 +3294,16 @@ kern_proc_filedesc_out(struct proc *p,  
 {
struct file *fp;
struct filedesc *fdp;
-   struct kinfo_file *kif;
+   struct export_fd_buf *efbuf;
struct vnode *cttyvp, *textvp, *tracevp;
int64_t offset;
void *data;
-   ssize_t remainder;
int error, i;
int type, refcnt, fflags;
cap_rights_t fd_cap_rights;
 
PROC_LOCK_ASSERT(p, MA_OWNED);
 
-   remainder = maxlen;
/* ktrace vnode */
tracevp = p-p_tracevp;
if (tracevp != NULL)
@@ -3306,46 +3321,44 @@ kern_proc_filedesc_out(struct proc *p,  
}
fdp = fdhold(p);
PROC_UNLOCK(p);
-   kif = malloc(sizeof(*kif), M_TEMP, M_WAITOK);
+   efbuf = malloc(sizeof(*efbuf), M_TEMP, M_WAITOK);
+   efbuf-fdp = NULL;
+   efbuf-sb = sb;
+   efbuf-remainder = maxlen;
if (tracevp != NULL)
export_fd_to_sb(tracevp, KF_TYPE_VNODE, KF_FD_TYPE_TRACE,
-   FREAD | FWRITE, -1, -1, 0, kif, sb, remainder);
+   FREAD | FWRITE, -1, -1, 0, efbuf);
if (textvp != NULL)
export_fd_to_sb(textvp, KF_TYPE_VNODE, KF_FD_TYPE_TEXT,
-   FREAD, -1, -1, 0, kif, sb, remainder);
+   FREAD, -1, -1, 0, efbuf);
if (cttyvp != NULL)
export_fd_to_sb(cttyvp, KF_TYPE_VNODE, KF_FD_TYPE_CTTY,
-   FREAD | FWRITE, -1, -1, 0, kif, sb, remainder);
+   FREAD | FWRITE, -1, -1, 0, efbuf);
error = 0;
if (fdp == NULL)
 

svn commit: r252313 - head/sys/kern

2013-06-27 Thread Mikolaj Golub
Author: trociny
Date: Thu Jun 27 19:14:03 2013
New Revision: 252313
URL: http://svnweb.freebsd.org/changeset/base/252313

Log:
  To avoid LOR, always drop the filedesc lock before exporting fd to sbuf.
  
  Reviewed by:  kib
  MFC after:3 days

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cThu Jun 27 18:59:07 2013
(r252312)
+++ head/sys/kern/kern_descrip.cThu Jun 27 19:14:03 2013
(r252313)
@@ -3427,12 +3427,10 @@ kern_proc_filedesc_out(struct proc *p,  
 * re-validate and re-evaluate its properties when
 * the loop continues.
 */
-   if (type == KF_TYPE_VNODE || type == KF_TYPE_FIFO)
-   FILEDESC_SUNLOCK(fdp);
+   FILEDESC_SUNLOCK(fdp);
error = export_fd_to_sb(data, type, i, fflags, refcnt,
offset, fd_cap_rights, kif, sb, remainder);
-   if (type == KF_TYPE_VNODE || type == KF_TYPE_FIFO)
-   FILEDESC_SLOCK(fdp);
+   FILEDESC_SLOCK(fdp);
if (error)
break;
}
___
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: r251779 - stable/9/sys/net

2013-06-15 Thread Mikolaj Golub
Author: trociny
Date: Sat Jun 15 08:06:22 2013
New Revision: 251779
URL: http://svnweb.freebsd.org/changeset/base/251779

Log:
  MFC r251490:
  
  Properly set curvnet context in lagg_port_setlladdr() task handler.
  
  Reported by:  Nikos Vassiliadis nvass gmx.com
  Submitted by: zec
  Tested by:Nikos Vassiliadis nvass gmx.com

Modified:
  stable/9/sys/net/if_lagg.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/net/   (props changed)

Modified: stable/9/sys/net/if_lagg.c
==
--- stable/9/sys/net/if_lagg.c  Sat Jun 15 06:45:17 2013(r251778)
+++ stable/9/sys/net/if_lagg.c  Sat Jun 15 08:06:22 2013(r251779)
@@ -494,7 +494,9 @@ lagg_port_setlladdr(void *arg, int pendi
ifp = llq-llq_ifp;
 
/* Set the link layer address */
+   CURVNET_SET(ifp-if_vnet);
error = if_setlladdr(ifp, llq-llq_lladdr, ETHER_ADDR_LEN);
+   CURVNET_RESTORE();
if (error)
printf(%s: setlladdr failed on %s\n, __func__,
ifp-if_xname);
___
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: r251780 - stable/8/sys/net

2013-06-15 Thread Mikolaj Golub
Author: trociny
Date: Sat Jun 15 08:07:47 2013
New Revision: 251780
URL: http://svnweb.freebsd.org/changeset/base/251780

Log:
  MFC r251490:
  
  Properly set curvnet context in lagg_port_setlladdr() task handler.
  
  Reported by:  Nikos Vassiliadis nvass gmx.com
  Submitted by: zec
  Tested by:Nikos Vassiliadis nvass gmx.com

Modified:
  stable/8/sys/net/if_lagg.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/net/   (props changed)

Modified: stable/8/sys/net/if_lagg.c
==
--- stable/8/sys/net/if_lagg.c  Sat Jun 15 08:06:22 2013(r251779)
+++ stable/8/sys/net/if_lagg.c  Sat Jun 15 08:07:47 2013(r251780)
@@ -487,7 +487,9 @@ lagg_port_setlladdr(void *arg, int pendi
ifp = llq-llq_ifp;
 
/* Set the link layer address */
+   CURVNET_SET(ifp-if_vnet);
error = if_setlladdr(ifp, llq-llq_lladdr, ETHER_ADDR_LEN);
+   CURVNET_RESTORE();
if (error)
printf(%s: setlladdr failed on %s\n, __func__,
ifp-if_xname);
___
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: r251490 - head/sys/net

2013-06-07 Thread Mikolaj Golub
Author: trociny
Date: Fri Jun  7 10:27:50 2013
New Revision: 251490
URL: http://svnweb.freebsd.org/changeset/base/251490

Log:
  Properly set curvnet context in lagg_port_setlladdr() task handler.
  
  Reported by:  Nikos Vassiliadis nvass gmx.com
  Submitted by: zec
  Tested by:Nikos Vassiliadis nvass gmx.com
  MFC after:1 week

Modified:
  head/sys/net/if_lagg.c

Modified: head/sys/net/if_lagg.c
==
--- head/sys/net/if_lagg.c  Fri Jun  7 09:06:50 2013(r251489)
+++ head/sys/net/if_lagg.c  Fri Jun  7 10:27:50 2013(r251490)
@@ -505,7 +505,9 @@ lagg_port_setlladdr(void *arg, int pendi
ifp = llq-llq_ifp;
 
/* Set the link layer address */
+   CURVNET_SET(ifp-if_vnet);
error = if_setlladdr(ifp, llq-llq_lladdr, ETHER_ADDR_LEN);
+   CURVNET_RESTORE();
if (error)
printf(%s: setlladdr failed on %s\n, __func__,
ifp-if_xname);
___
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: r251490 - head/sys/net

2013-06-07 Thread Mikolaj Golub
On Fri, Jun 07, 2013 at 02:33:08PM +0400, Gleb Smirnoff wrote:
 On Fri, Jun 07, 2013 at 10:27:51AM +, Mikolaj Golub wrote:
 M Author: trociny
 M Date: Fri Jun  7 10:27:50 2013
 M New Revision: 251490
 M URL: http://svnweb.freebsd.org/changeset/base/251490
 M 
 M Log:
 M   Properly set curvnet context in lagg_port_setlladdr() task handler.
 M   
 M   Reported by: Nikos Vassiliadis nvass gmx.com
 M   Submitted by:zec
 M   Tested by:   Nikos Vassiliadis nvass gmx.com
 M   MFC after:   1 week
 M 
 M Modified:
 M   head/sys/net/if_lagg.c
 M 
 M Modified: head/sys/net/if_lagg.c
 M 
 ==
 M --- head/sys/net/if_lagg.c Fri Jun  7 09:06:50 2013(r251489)
 M +++ head/sys/net/if_lagg.c Fri Jun  7 10:27:50 2013(r251490)
 M @@ -505,7 +505,9 @@ lagg_port_setlladdr(void *arg, int pendi
 Mifp = llq-llq_ifp;
 M  
 M/* Set the link layer address */
 M +  CURVNET_SET(ifp-if_vnet);
 Merror = if_setlladdr(ifp, llq-llq_lladdr, ETHER_ADDR_LEN);
 M +  CURVNET_RESTORE();
 Mif (error)
 Mprintf(%s: setlladdr failed on %s\n, __func__,
 Mifp-if_xname);
 
 IMHO, the entire task function should be embraced into VNET context.

The VNET context is obtained from ifp, which is taken from the queue
just one line above.

It might be taken from lagg interface, supposing that all the lagg
ports are in the same vnet, but this may not always be true, e.g. when
you moving a lagg and its ports to another vnet, one by one.

-- 
Mikolaj Golub
___
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: r251003 - stable/9/lib/libprocstat

2013-05-26 Thread Mikolaj Golub
Author: trociny
Date: Sun May 26 18:26:29 2013
New Revision: 251003
URL: http://svnweb.freebsd.org/changeset/base/251003

Log:
  MFC r250147:
  
  procstat_getpathname: for kvm method, instead of returning the error
  that the method is not supported, return an empty string.
  
  This looks more handy for callers like procstat(1), which will not
  abort after the failed call and still output some useful information.

Modified:
  stable/9/lib/libprocstat/libprocstat.c
Directory Properties:
  stable/9/lib/libprocstat/   (props changed)

Modified: stable/9/lib/libprocstat/libprocstat.c
==
--- stable/9/lib/libprocstat/libprocstat.c  Sun May 26 17:00:15 2013
(r251002)
+++ stable/9/lib/libprocstat/libprocstat.c  Sun May 26 18:26:29 2013
(r251003)
@@ -2120,8 +2120,10 @@ procstat_getpathname(struct procstat *pr
 {
switch(procstat-type) {
case PROCSTAT_KVM:
-   warnx(kvm method is not supported);
-   return (-1);
+   /* XXX: Return empty string. */
+   if (maxlen  0)
+   pathname[0] = '\0';
+   return (0);
case PROCSTAT_SYSCTL:
return (procstat_getpathname_sysctl(kp-ki_pid, pathname,
maxlen));
___
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: r251004 - in stable/9/sbin: hastctl hastd

2013-05-26 Thread Mikolaj Golub
Author: trociny
Date: Sun May 26 18:28:36 2013
New Revision: 251004
URL: http://svnweb.freebsd.org/changeset/base/251004

Log:
  r250503
  
  Get rid of libl dependency.  We needed it only to provide yywrap.  But
  yywrap is not necessary when parsing a single hast.conf file.
  
  Suggested by: kib
  Reviewed by:  pjd

Modified:
  stable/9/sbin/hastctl/Makefile
  stable/9/sbin/hastd/Makefile
  stable/9/sbin/hastd/token.l
Directory Properties:
  stable/9/sbin/hastctl/   (props changed)
  stable/9/sbin/hastd/   (props changed)

Modified: stable/9/sbin/hastctl/Makefile
==
--- stable/9/sbin/hastctl/Makefile  Sun May 26 18:26:29 2013
(r251003)
+++ stable/9/sbin/hastctl/Makefile  Sun May 26 18:28:36 2013
(r251004)
@@ -31,8 +31,8 @@ CFLAGS+=-DINET6
 CFLAGS+=-DYY_NO_UNPUT
 CFLAGS+=-DYY_NO_INPUT
 
-DPADD= ${LIBL} ${LIBUTIL}
-LDADD= -ll -lutil
+DPADD= ${LIBUTIL}
+LDADD= -lutil
 .if ${MK_OPENSSL} != no
 DPADD+=${LIBCRYPTO}
 LDADD+=-lcrypto

Modified: stable/9/sbin/hastd/Makefile
==
--- stable/9/sbin/hastd/MakefileSun May 26 18:26:29 2013
(r251003)
+++ stable/9/sbin/hastd/MakefileSun May 26 18:28:36 2013
(r251004)
@@ -30,7 +30,7 @@ CFLAGS+=-DINET6
 .endif
 
 DPADD= ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF} ${LIBL} ${LIBPTHREAD} ${LIBUTIL}
-LDADD= -lgeom -lbsdxml -lsbuf -ll -lpthread -lutil
+LDADD= -lgeom -lbsdxml -lsbuf -lpthread -lutil
 .if ${MK_OPENSSL} != no
 DPADD+=${LIBCRYPTO}
 LDADD+=-lcrypto

Modified: stable/9/sbin/hastd/token.l
==
--- stable/9/sbin/hastd/token.l Sun May 26 18:26:29 2013(r251003)
+++ stable/9/sbin/hastd/token.l Sun May 26 18:28:36 2013(r251004)
@@ -46,6 +46,7 @@ int lineno;
 
 %option noinput
 %option nounput
+%option noyywrap
 
 %%
 control{ DP; return CONTROL; }
___
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: r251005 - in stable/8/sbin: hastctl hastd

2013-05-26 Thread Mikolaj Golub
Author: trociny
Date: Sun May 26 18:30:07 2013
New Revision: 251005
URL: http://svnweb.freebsd.org/changeset/base/251005

Log:
  MFC r250503:
  
  Get rid of libl dependency.  We needed it only to provide yywrap.  But
  yywrap is not necessary when parsing a single hast.conf file.
  
  Suggested by: kib
  Reviewed by:  pjd

Modified:
  stable/8/sbin/hastctl/Makefile
  stable/8/sbin/hastd/Makefile
  stable/8/sbin/hastd/token.l
Directory Properties:
  stable/8/sbin/hastctl/   (props changed)
  stable/8/sbin/hastd/   (props changed)

Modified: stable/8/sbin/hastctl/Makefile
==
--- stable/8/sbin/hastctl/Makefile  Sun May 26 18:28:36 2013
(r251004)
+++ stable/8/sbin/hastctl/Makefile  Sun May 26 18:30:07 2013
(r251005)
@@ -29,8 +29,8 @@ CFLAGS+=-DINET6
 # This is needed to have WARNS  1.
 CFLAGS+=-DYY_NO_UNPUT
 
-DPADD= ${LIBL} ${LIBUTIL}
-LDADD= -ll -lutil
+DPADD= ${LIBUTIL}
+LDADD= -lutil
 .if ${MK_OPENSSL} != no
 DPADD+=${LIBCRYPTO}
 LDADD+=-lcrypto

Modified: stable/8/sbin/hastd/Makefile
==
--- stable/8/sbin/hastd/MakefileSun May 26 18:28:36 2013
(r251004)
+++ stable/8/sbin/hastd/MakefileSun May 26 18:30:07 2013
(r251005)
@@ -29,7 +29,7 @@ CFLAGS+=-DINET6
 .endif
 
 DPADD= ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF} ${LIBL} ${LIBPTHREAD} ${LIBUTIL}
-LDADD= -lgeom -lbsdxml -lsbuf -ll -lpthread -lutil
+LDADD= -lgeom -lbsdxml -lsbuf -lpthread -lutil
 .if ${MK_OPENSSL} != no
 DPADD+=${LIBCRYPTO}
 LDADD+=-lcrypto

Modified: stable/8/sbin/hastd/token.l
==
--- stable/8/sbin/hastd/token.l Sun May 26 18:28:36 2013(r251004)
+++ stable/8/sbin/hastd/token.l Sun May 26 18:30:07 2013(r251005)
@@ -46,6 +46,7 @@ int lineno;
 
 %option noinput
 %option nounput
+%option noyywrap
 
 %%
 control{ DP; return CONTROL; }
___
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: r251006 - in stable/9/usr.sbin/bsnmpd/modules: . snmp_hast

2013-05-26 Thread Mikolaj Golub
Author: trociny
Date: Sun May 26 18:35:52 2013
New Revision: 251006
URL: http://svnweb.freebsd.org/changeset/base/251006

Log:
  MFC r250379, r250503:
  
  HAST module for bsnmpd(1).
  
  Reviewed by:  harti, pjd

Added:
  stable/9/usr.sbin/bsnmpd/modules/snmp_hast/
 - copied from r250379, head/usr.sbin/bsnmpd/modules/snmp_hast/
Modified:
  stable/9/usr.sbin/bsnmpd/modules/Makefile
  stable/9/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
Directory Properties:
  stable/9/usr.sbin/bsnmpd/   (props changed)

Modified: stable/9/usr.sbin/bsnmpd/modules/Makefile
==
--- stable/9/usr.sbin/bsnmpd/modules/Makefile   Sun May 26 18:30:07 2013
(r251005)
+++ stable/9/usr.sbin/bsnmpd/modules/Makefile   Sun May 26 18:35:52 2013
(r251006)
@@ -10,6 +10,7 @@ _snmp_atm= snmp_atm
 
 SUBDIR=${_snmp_atm} \
snmp_bridge \
+   snmp_hast \
snmp_hostres \
snmp_mibII \
snmp_pf \

Modified: stable/9/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
==
--- head/usr.sbin/bsnmpd/modules/snmp_hast/Makefile Wed May  8 20:03:37 
2013(r250379)
+++ stable/9/usr.sbin/bsnmpd/modules/snmp_hast/Makefile Sun May 26 18:35:52 
2013(r251006)
@@ -29,8 +29,8 @@ CFLAGS+=-DYY_NO_UNPUT
 CFLAGS+=-DYY_NO_INPUT
 CFLAGS+= -DSNMPTREE_TYPES
 
-DPADD= ${LIBL} ${LIBUTIL}
-LDADD= -ll -lutil
+DPADD= ${LIBUTIL}
+LDADD= -lutil
 
 XSYM=  begemotHast
 DEFS=  ${MOD}_tree.def
___
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: r251007 - in stable/8/usr.sbin/bsnmpd/modules: . snmp_hast

2013-05-26 Thread Mikolaj Golub
Author: trociny
Date: Sun May 26 18:37:20 2013
New Revision: 251007
URL: http://svnweb.freebsd.org/changeset/base/251007

Log:
  MFC r250379, r250503:
  
  HAST module for bsnmpd(1).
  
  Reviewed by:  harti, pjd

Added:
  stable/8/usr.sbin/bsnmpd/modules/snmp_hast/
 - copied from r250379, head/usr.sbin/bsnmpd/modules/snmp_hast/
Modified:
  stable/8/usr.sbin/bsnmpd/modules/Makefile
  stable/8/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
Directory Properties:
  stable/8/usr.sbin/bsnmpd/   (props changed)

Modified: stable/8/usr.sbin/bsnmpd/modules/Makefile
==
--- stable/8/usr.sbin/bsnmpd/modules/Makefile   Sun May 26 18:35:52 2013
(r251006)
+++ stable/8/usr.sbin/bsnmpd/modules/Makefile   Sun May 26 18:37:20 2013
(r251007)
@@ -10,6 +10,7 @@ _snmp_atm= snmp_atm
 
 SUBDIR=${_snmp_atm} \
snmp_bridge \
+   snmp_hast \
snmp_hostres \
snmp_mibII \
snmp_pf

Modified: stable/8/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
==
--- head/usr.sbin/bsnmpd/modules/snmp_hast/Makefile Wed May  8 20:03:37 
2013(r250379)
+++ stable/8/usr.sbin/bsnmpd/modules/snmp_hast/Makefile Sun May 26 18:37:20 
2013(r251007)
@@ -29,8 +29,8 @@ CFLAGS+=-DYY_NO_UNPUT
 CFLAGS+=-DYY_NO_INPUT
 CFLAGS+= -DSNMPTREE_TYPES
 
-DPADD= ${LIBL} ${LIBUTIL}
-LDADD= -ll -lutil
+DPADD= ${LIBUTIL}
+LDADD= -lutil
 
 XSYM=  begemotHast
 DEFS=  ${MOD}_tree.def
___
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: r251008 - stable/9/contrib/bsnmp

2013-05-26 Thread Mikolaj Golub
Author: trociny
Date: Sun May 26 18:38:46 2013
New Revision: 251008
URL: http://svnweb.freebsd.org/changeset/base/251008

Log:
  MFC r250380:
  
  Register OID for HAST module.

Modified:
  stable/9/contrib/bsnmp/oid-list
Directory Properties:
  stable/9/contrib/bsnmp/   (props changed)

Modified: stable/9/contrib/bsnmp/oid-list
==
--- stable/9/contrib/bsnmp/oid-list Sun May 26 18:37:20 2013
(r251007)
+++ stable/9/contrib/bsnmp/oid-list Sun May 26 18:38:46 2013
(r251008)
@@ -24,6 +24,7 @@ enterprises
   204  pingDatabsnmp-ping (Nate Nielsen 
niel...@memberwebs.com)
   205  begemotBridge   bridge module
   210  begemotWlan WLAN module
+  220  begemotHast HAST module
 
   300  BEGEMOT-ACM DLR ACM project
   303  BEGEMOT-WLINK   DLR WLINK simulator
___
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: r251009 - stable/8/contrib/bsnmp

2013-05-26 Thread Mikolaj Golub
Author: trociny
Date: Sun May 26 18:39:33 2013
New Revision: 251009
URL: http://svnweb.freebsd.org/changeset/base/251009

Log:
  MFC r250380:
  
  Register OID for HAST module.

Modified:
  stable/8/contrib/bsnmp/oid-list
Directory Properties:
  stable/8/contrib/bsnmp/   (props changed)

Modified: stable/8/contrib/bsnmp/oid-list
==
--- stable/8/contrib/bsnmp/oid-list Sun May 26 18:38:46 2013
(r251008)
+++ stable/8/contrib/bsnmp/oid-list Sun May 26 18:39:33 2013
(r251009)
@@ -17,6 +17,7 @@ enterprises
   200  BEGEMOT-PF  snmpd PF module (phil...@freebsd.org)
   201  BEGEMOT-NTP snmpd NTP module
   202  BEGEMOT-HOSTRES snmpd HOSTRES module private stuff
+  220  begemotHast HAST module
   300  BEGEMOT-ACM DLR ACM project
 
 If you need an OID and don't know where to stuck it in, I can assign you one -
___
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: r251010 - stable/9/usr.sbin/bsnmpd/modules/snmp_hast

2013-05-26 Thread Mikolaj Golub
Author: trociny
Date: Sun May 26 18:54:05 2013
New Revision: 251010
URL: http://svnweb.freebsd.org/changeset/base/251010

Log:
  MFC r250405:
  
  Move snmp_hast manual to section 3, where all other manual pages for
  bsnmp modules are located.
  
  Section 3 (Library Functions) looks wrong for this manual page, which
  contains only module description, that is why initially it was located
  to section 8 (System Manager's Manual).  On the other hand manual
  pages for all other bsnmpd modules are already located in the section
  3, and having all pages in one section looks more consistent.  Also,
  currently, similarly to manuals for other modules, snmp_hast manual
  contains LIBRARY section, which is not good style for section 8.

Added:
  stable/9/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3
 - copied unchanged from r250405, 
head/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3
Deleted:
  stable/9/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.8
Modified:
  stable/9/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
Directory Properties:
  stable/9/usr.sbin/bsnmpd/   (props changed)

Modified: stable/9/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
==
--- stable/9/usr.sbin/bsnmpd/modules/snmp_hast/Makefile Sun May 26 18:39:33 
2013(r251009)
+++ stable/9/usr.sbin/bsnmpd/modules/snmp_hast/Makefile Sun May 26 18:54:05 
2013(r251010)
@@ -13,7 +13,7 @@ SRCS+=parse.y pjdlog.c
 SRCS+= proto.c proto_common.c proto_uds.c
 SRCS+= token.l
 SRCS+= y.tab.h
-MAN=   snmp_hast.8
+MAN=   snmp_hast.3
 
 NO_WFORMAT=
 NO_WCAST_ALIGN=

Copied: stable/9/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3 (from r250405, 
head/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/9/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3  Sun May 26 
18:54:05 2013(r251010, copy of r250405, 
head/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3)
@@ -0,0 +1,69 @@
+.\-
+.\ Copyright (c) 2013 Mikolaj Golub troc...@freebsd.org
+.\ All rights reserved.
+.\
+.\ Redistribution and use in source and binary forms, with or without
+.\ modification, are permitted provided that the following conditions
+.\ are met:
+.\ 1. Redistributions of source code must retain the above copyright
+.\notice, this list of conditions and the following disclaimer.
+.\ 2. Redistributions in binary form must reproduce the above copyright
+.\notice, this list of conditions and the following disclaimer in the
+.\documentation and/or other materials provided with the distribution.
+.\
+.\ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\ ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\ SUCH DAMAGE.
+.\
+.\ $FreeBSD$
+.\
+.Dd May 9, 2013
+.Dt SNMP_HAST 3
+.Os
+.Sh NAME
+.Nm snmp_hast
+.Nd HAST module for
+.Xr bsnmpd 1
+.Sh LIBRARY
+.Pq begemotSnmpdModulePath.hast = /usr/lib/snmp_hast.so
+.Sh DESCRIPTION
+The
+.Nm snmp_hast
+module implements a private BEGEMOT-HAST-MIB, which allows
+management of HAST resources.
+.Pp
+The module uses
+.Xr hastd 8
+control socket to communicate with the daemon.
+.Va hastConfigFile
+variable can be used to specify the location of
+.Xr hast.conf 5
+file to find the address of the control connection.
+.Sh FILES
+.Bl -tag -width X
+.It Pa /usr/share/snmp/defs/hast_tree.def
+The description of the MIB tree implemented by
+.Nm .
+.It Pa /usr/share/snmp/mibs/BEGEMOT-HAST-MIB.txt
+The private BEGEMOT-HAST-MIB that is implemented by this module.
+.It Pa /etc/hast.conf
+The default
+.Xr hastd 8
+configuration file.
+.El
+.Sh SEE ALSO
+.Xr bsnmpd 1 ,
+.Xr gensnmptree 1 ,
+.Xr hastctl 8 ,
+.Xr hastd 8 ,
+.Xr snmpmod 3
+.Sh AUTHORS
+.An Mikolaj Golub Aq troc...@freebsd.org
___
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: r251011 - stable/8/usr.sbin/bsnmpd/modules/snmp_hast

2013-05-26 Thread Mikolaj Golub
Author: trociny
Date: Sun May 26 18:54:50 2013
New Revision: 251011
URL: http://svnweb.freebsd.org/changeset/base/251011

Log:
  MFC r250405:
  
  Move snmp_hast manual to section 3, where all other manual pages for
  bsnmp modules are located.
  
  Section 3 (Library Functions) looks wrong for this manual page, which
  contains only module description, that is why initially it was located
  to section 8 (System Manager's Manual).  On the other hand manual
  pages for all other bsnmpd modules are already located in the section
  3, and having all pages in one section looks more consistent.  Also,
  currently, similarly to manuals for other modules, snmp_hast manual
  contains LIBRARY section, which is not good style for section 8.

Added:
  stable/8/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3
 - copied unchanged from r250405, 
head/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3
Deleted:
  stable/8/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.8
Modified:
  stable/8/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
Directory Properties:
  stable/8/usr.sbin/bsnmpd/   (props changed)

Modified: stable/8/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
==
--- stable/8/usr.sbin/bsnmpd/modules/snmp_hast/Makefile Sun May 26 18:54:05 
2013(r251010)
+++ stable/8/usr.sbin/bsnmpd/modules/snmp_hast/Makefile Sun May 26 18:54:50 
2013(r251011)
@@ -13,7 +13,7 @@ SRCS+=parse.y pjdlog.c
 SRCS+= proto.c proto_common.c proto_uds.c
 SRCS+= token.l
 SRCS+= y.tab.h
-MAN=   snmp_hast.8
+MAN=   snmp_hast.3
 
 NO_WFORMAT=
 NO_WCAST_ALIGN=

Copied: stable/8/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3 (from r250405, 
head/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/8/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3  Sun May 26 
18:54:50 2013(r251011, copy of r250405, 
head/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3)
@@ -0,0 +1,69 @@
+.\-
+.\ Copyright (c) 2013 Mikolaj Golub troc...@freebsd.org
+.\ All rights reserved.
+.\
+.\ Redistribution and use in source and binary forms, with or without
+.\ modification, are permitted provided that the following conditions
+.\ are met:
+.\ 1. Redistributions of source code must retain the above copyright
+.\notice, this list of conditions and the following disclaimer.
+.\ 2. Redistributions in binary form must reproduce the above copyright
+.\notice, this list of conditions and the following disclaimer in the
+.\documentation and/or other materials provided with the distribution.
+.\
+.\ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\ ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\ SUCH DAMAGE.
+.\
+.\ $FreeBSD$
+.\
+.Dd May 9, 2013
+.Dt SNMP_HAST 3
+.Os
+.Sh NAME
+.Nm snmp_hast
+.Nd HAST module for
+.Xr bsnmpd 1
+.Sh LIBRARY
+.Pq begemotSnmpdModulePath.hast = /usr/lib/snmp_hast.so
+.Sh DESCRIPTION
+The
+.Nm snmp_hast
+module implements a private BEGEMOT-HAST-MIB, which allows
+management of HAST resources.
+.Pp
+The module uses
+.Xr hastd 8
+control socket to communicate with the daemon.
+.Va hastConfigFile
+variable can be used to specify the location of
+.Xr hast.conf 5
+file to find the address of the control connection.
+.Sh FILES
+.Bl -tag -width X
+.It Pa /usr/share/snmp/defs/hast_tree.def
+The description of the MIB tree implemented by
+.Nm .
+.It Pa /usr/share/snmp/mibs/BEGEMOT-HAST-MIB.txt
+The private BEGEMOT-HAST-MIB that is implemented by this module.
+.It Pa /etc/hast.conf
+The default
+.Xr hastd 8
+configuration file.
+.El
+.Sh SEE ALSO
+.Xr bsnmpd 1 ,
+.Xr gensnmptree 1 ,
+.Xr hastctl 8 ,
+.Xr hastd 8 ,
+.Xr snmpmod 3
+.Sh AUTHORS
+.An Mikolaj Golub Aq troc...@freebsd.org
___
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: r250870 - in stable/9: . lib/libprocstat

2013-05-21 Thread Mikolaj Golub
Author: trociny
Date: Tue May 21 19:04:16 2013
New Revision: 250870
URL: http://svnweb.freebsd.org/changeset/base/250870

Log:
  MFC r249666, r249667, r249670, r249672, r249674, r249676, r249677, r249679,
  r249681, r249684, r249688, r249711, r249731, r250146
  
  r249666, r249682:
  
  Make libprocstat(3) extract procstat notes from a process core file.
  
  PR:   kern/173723
  Suggested by: jhb
  Glanced by:   kib
  
  r249667:
  
  Add procstat_getvmmap function to get VM layout of a process.
  
  r249670:
  
  Add procstat_getgroups function to retrieve process groups.
  
  r249672:
  
  Add procstat_getumask function to retrieve a process umask.
  
  r249674:
  
  Add procstat_getrlimit function to retrieve a process resource limits info.
  
  r249676:
  
  Add procstat_getpathname function to retrieve a process executable.
  
  r249677:
  
  Add procstat_getosrel function to retrieve a process osrel info.
  
  r249679:
  
  Extend libprocstat with functions to retrieve process command line
  arguments and environment variables.
  
  Suggested by: stas
  Reviewed by:  jhb and stas (initial version)
  
  r249681:
  
  Add procstat_getauxv function to retrieve a process auxiliary vector.
  
  r249684:
  
  Add procstat_getkstack function to dump kernel stacks of a process.
  
  r249688:
  
  Bump date.
  
  r249711 (joel):
  
  mdoc: end function context properly.
  
  r249731:
  
  Embed revision id in the library.
  
  r250146:
  
  KVM method support for procstat_getgroups, procstat_getumask,
  procstat_getrlimit, and procstat_getosrel.

Added:
  stable/9/lib/libprocstat/core.c
 - copied, changed from r249666, head/lib/libprocstat/core.c
  stable/9/lib/libprocstat/core.h
 - copied, changed from r249666, head/lib/libprocstat/core.h
Modified:
  stable/9/Makefile.inc1   (contents, props changed)
  stable/9/lib/libprocstat/Makefile
  stable/9/lib/libprocstat/Symbol.map
  stable/9/lib/libprocstat/libprocstat.3
  stable/9/lib/libprocstat/libprocstat.c
  stable/9/lib/libprocstat/libprocstat.h
  stable/9/lib/libprocstat/libprocstat_internal.h
Directory Properties:
  stable/9/lib/libprocstat/   (props changed)

Modified: stable/9/Makefile.inc1
==
--- stable/9/Makefile.inc1  Tue May 21 18:52:37 2013(r250869)
+++ stable/9/Makefile.inc1  Tue May 21 19:04:16 2013(r250870)
@@ -1371,7 +1371,7 @@ _prebuild_libs=   ${_kerberos5_lib_libasn1
${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
${_kerberos5_lib_libroken} \
lib/libbz2 lib/libcom_err lib/libcrypt \
-   lib/libexpat \
+   lib/libelf lib/libexpat \
${_lib_libgssapi} ${_lib_libipx} \
lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
lib/ncurses/ncurses lib/ncurses/ncursesw \

Modified: stable/9/lib/libprocstat/Makefile
==
--- stable/9/lib/libprocstat/Makefile   Tue May 21 18:52:37 2013
(r250869)
+++ stable/9/lib/libprocstat/Makefile   Tue May 21 19:04:16 2013
(r250870)
@@ -6,6 +6,7 @@ LIB=procstat
 
 SRCS=  cd9660.c\
common_kvm.c\
+   core.c  \
libprocstat.c   \
 msdosfs.c  \
ntfs.c  \
@@ -19,8 +20,8 @@ INCS= libprocstat.h
 CFLAGS+=   -I. -I${.CURDIR} -D_KVM_VNODE
 SHLIB_MAJOR=   1
 
-DPADD= ${LIBKVM} ${LIBUTIL}
-LDADD= -lkvm -lutil
+DPADD= ${LIBELF} ${LIBKVM} ${LIBUTIL}
+LDADD= -lelf -lkvm -lutil
 
 MAN=   libprocstat.3
 

Modified: stable/9/lib/libprocstat/Symbol.map
==
--- stable/9/lib/libprocstat/Symbol.map Tue May 21 18:52:37 2013
(r250869)
+++ stable/9/lib/libprocstat/Symbol.map Tue May 21 19:04:16 2013
(r250870)
@@ -16,5 +16,22 @@ FBSD_1.2 {
 };
 
 FBSD_1.3 {
+   procstat_freeargv;
+   procstat_freeauxv;
+   procstat_freeenvv;
+   procstat_freegroups;
+   procstat_freekstack;
+   procstat_freevmmap;
procstat_get_shm_info;
+   procstat_getargv;
+   procstat_getauxv;
+   procstat_getenvv;
+   procstat_getgroups;
+   procstat_getkstack;
+   procstat_getosrel;
+   procstat_getpathname;
+   procstat_getrlimit;
+   procstat_getumask;
+   procstat_getvmmap;
+   procstat_open_core;
 };

Copied and modified: stable/9/lib/libprocstat/core.c (from r249666, 
head/lib/libprocstat/core.c)
==
--- head/lib/libprocstat/core.c Sat Apr 20 07:47:26 2013(r249666, copy 
source)
+++ stable/9/lib/libprocstat/core.c Tue May 21 19:04:16 2013
(r250870)
@@ -22,12 +22,14 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF 

svn commit: r250871 - stable/9/usr.bin/procstat

2013-05-21 Thread Mikolaj Golub
Author: trociny
Date: Tue May 21 19:05:27 2013
New Revision: 250871
URL: http://svnweb.freebsd.org/changeset/base/250871

Log:
  MFC r249668, r249669, r249671, r249673, r249675, r249678, r249680, r249683,
  r249685, r249686:
  
  r249668:
  
  Use procstat_getprocs(3) for retrieving thread information instead of
  direct sysctl calls.
  
  r249669:
  
  Use more generic procstat_getvmmap(3) for retrieving VM layout of a process.
  
  r249671:
  
  Use procstat_getgroups(3) for retrieving groups information instead of
  direct sysctl.
  
  r249673:
  
  Use procstat_getumask(3) for retrieving umaks information instead of
  direct sysctl.
  
  r249675:
  
  Use procstat_getrlimit(3) for retrieving rlimit information instead of
  direct sysctl calls.
  
  r249678:
  
  Use libprocstat(3) when retrieving binary information for a process.
  
  r249680:
  
  Use libprocstat(3) to retrieve process command line arguments and
  environment variables.
  
  r249683:
  
  Use libprocstat(3) to retrieve ELF auxiliary vector.
  
  r249685:
  
  Use procstat_getkstack(3) for retrieving process kernel stacks
  instead of direct sysctl calls.
  
  r249686:
  
  Make use of newly added libprocstat(3) ability to extract procstat
  info from a process core file.
  
  So now one can run procstat(1) on a process core e.g. to get a list of
  files opened by a process when it crashed:
  
  root@lisa:/ # procstat -f /root/vi.core
PID COMM   FD T V FLAGS REF  OFFSET PRO NAME
658 vi   text v r r   -   - -   /usr/bin/vi
658 vi   ctty v c rw---   -   - -   /dev/pts/0
658 vicwd v d r   -   - -   /root
658 vi   root v d r   -   - -   /
658 vi  0 v c rw---  113208 -   /dev/pts/0
658 vi  1 v c rw---  113208 -   /dev/pts/0
658 vi  2 v c rw---  113208 -   /dev/pts/0
658 vi  3 v r rn-l-   1   0 -   /tmp/vi.0AYKz3Lps7
658 vi  4 v r rw---   1   0 -   
/var/tmp/vi.recover/vi.GaGYsz
658 vi  5 v r rw---   1   0 -   -
  
  PR:   kern/173723
  Suggested by: jhb

Modified:
  stable/9/usr.bin/procstat/procstat.1
  stable/9/usr.bin/procstat/procstat.c
  stable/9/usr.bin/procstat/procstat.h
  stable/9/usr.bin/procstat/procstat_args.c
  stable/9/usr.bin/procstat/procstat_auxv.c
  stable/9/usr.bin/procstat/procstat_bin.c
  stable/9/usr.bin/procstat/procstat_cred.c
  stable/9/usr.bin/procstat/procstat_kstack.c
  stable/9/usr.bin/procstat/procstat_rlimit.c
  stable/9/usr.bin/procstat/procstat_sigs.c
  stable/9/usr.bin/procstat/procstat_threads.c
  stable/9/usr.bin/procstat/procstat_vm.c
Directory Properties:
  stable/9/usr.bin/procstat/   (props changed)

Modified: stable/9/usr.bin/procstat/procstat.1
==
--- stable/9/usr.bin/procstat/procstat.1Tue May 21 19:04:16 2013
(r250870)
+++ stable/9/usr.bin/procstat/procstat.1Tue May 21 19:05:27 2013
(r250871)
@@ -25,7 +25,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd July 11, 2012
+.Dd April 20, 2013
 .Dt PROCSTAT 1
 .Os
 .Sh NAME
@@ -38,7 +38,7 @@
 .Op Fl C
 .Op Fl w Ar interval
 .Op Fl b | c | e | f | i | j | k | l | s | t | v | x
-.Op Fl a | Ar pid ...
+.Op Fl a | Ar pid | Ar core ...
 .Sh DESCRIPTION
 The
 .Nm
@@ -47,6 +47,8 @@ utility displays detailed information ab
 arguments, or if the
 .Fl a
 flag is used, all processes.
+It can also display information extracted from a process core file, if
+the core file is specified as the argument.
 .Pp
 By default, basic process statistics are printed; one of the following
 options may be specified in order to select more detailed process information

Modified: stable/9/usr.bin/procstat/procstat.c
==
--- stable/9/usr.bin/procstat/procstat.cTue May 21 19:04:16 2013
(r250870)
+++ stable/9/usr.bin/procstat/procstat.cTue May 21 19:05:27 2013
(r250871)
@@ -50,7 +50,7 @@ usage(void)
fprintf(stderr, usage: procstat [-h] [-C] [-M core] [-N system] 
[-w interval] \n);
fprintf(stderr, [-b | -c | -e | -f | -i | -j | -k | 
-   -l | -s | -t | -v | -x] [-a | pid ...]\n);
+   -l | -s | -t | -v | -x] [-a | pid | core ...]\n);
exit(EX_USAGE);
 }
 
@@ -59,11 +59,11 @@ procstat(struct procstat *prstat, struct
 {
 
if (bflag)
-   procstat_bin(kipp);
+   procstat_bin(prstat, kipp);
else if (cflag)
-   procstat_args(kipp);
+   procstat_args(prstat, kipp);
else if (eflag)
-   procstat_env(kipp);
+   procstat_env(prstat, kipp);
else if (fflag)
procstat_files(prstat, kipp);
else if (iflag)
@@ 

svn commit: r250872 - stable/9/usr.bin/gcore

2013-05-21 Thread Mikolaj Golub
Author: trociny
Date: Tue May 21 19:06:17 2013
New Revision: 250872
URL: http://svnweb.freebsd.org/changeset/base/250872

Log:
  MFC r249687, r249704, r250511:
  
  r249687, r249704:
  
  Sync gcore(1) with the recent changes in kernel code aimed at adding
  procstat notes to a process core file.
  
  Suggested by: jhb
  
  r250511 (antoine):
  
  Add some missing DPADD.

Modified:
  stable/9/usr.bin/gcore/Makefile
  stable/9/usr.bin/gcore/elfcore.c
Directory Properties:
  stable/9/usr.bin/gcore/   (props changed)

Modified: stable/9/usr.bin/gcore/Makefile
==
--- stable/9/usr.bin/gcore/Makefile Tue May 21 19:05:27 2013
(r250871)
+++ stable/9/usr.bin/gcore/Makefile Tue May 21 19:06:17 2013
(r250872)
@@ -3,8 +3,8 @@
 
 PROG=  gcore
 SRCS=  elfcore.c gcore.c
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+DPADD= ${LIBSBUF} ${LIBUTIL}
+LDADD= -lsbuf -lutil
 
 WARNS?=1
 

Modified: stable/9/usr.bin/gcore/elfcore.c
==
--- stable/9/usr.bin/gcore/elfcore.cTue May 21 19:05:27 2013
(r250871)
+++ stable/9/usr.bin/gcore/elfcore.cTue May 21 19:06:17 2013
(r250872)
@@ -33,6 +33,7 @@ __FBSDID($FreeBSD$);
 #include sys/ptrace.h
 #include sys/queue.h
 #include sys/linker_set.h
+#include sys/sbuf.h
 #include sys/sysctl.h
 #include sys/user.h
 #include sys/wait.h
@@ -41,6 +42,7 @@ __FBSDID($FreeBSD$);
 #include vm/vm.h
 #include vm/pmap.h
 #include vm/vm_map.h
+#include assert.h
 #include err.h
 #include errno.h
 #include fcntl.h
@@ -71,16 +73,33 @@ struct sseg_closure {
size_t size;/* Total size of all writable segments. */
 };
 
+typedef void* (*notefunc_t)(void *, size_t *);
+
 static void cb_put_phdr(vm_map_entry_t, void *);
 static void cb_size_segment(vm_map_entry_t, void *);
 static void each_writable_segment(vm_map_entry_t, segment_callback,
 void *closure);
 static void elf_detach(void);  /* atexit() handler. */
-static void elf_puthdr(pid_t, vm_map_entry_t, void *, size_t *, int numsegs);
-static void elf_putnote(void *dst, size_t *off, const char *name, int type,
-const void *desc, size_t descsz);
+static void *elf_note_fpregset(void *, size_t *);
+static void *elf_note_prpsinfo(void *, size_t *);
+static void *elf_note_prstatus(void *, size_t *);
+static void *elf_note_thrmisc(void *, size_t *);
+static void *elf_note_procstat_auxv(void *, size_t *);
+static void *elf_note_procstat_files(void *, size_t *);
+static void *elf_note_procstat_groups(void *, size_t *);
+static void *elf_note_procstat_osrel(void *, size_t *);
+static void *elf_note_procstat_proc(void *, size_t *);
+static void *elf_note_procstat_psstrings(void *, size_t *);
+static void *elf_note_procstat_rlimit(void *, size_t *);
+static void *elf_note_procstat_umask(void *, size_t *);
+static void *elf_note_procstat_vmmap(void *, size_t *);
+static void elf_puthdr(pid_t, vm_map_entry_t, void *, size_t, size_t, size_t,
+int);
+static void elf_putnote(int, notefunc_t, void *, struct sbuf *);
+static void elf_putnotes(pid_t, struct sbuf *, size_t *);
 static void freemap(vm_map_entry_t);
 static vm_map_entry_t readmap(pid_t);
+static void *procstat_sysctl(void *, int, size_t, size_t *sizep);
 
 static pid_t g_pid;/* Pid being dumped, global for elf_detach */
 
@@ -114,8 +133,10 @@ elf_coredump(int efd __unused, int fd, p
 {
vm_map_entry_t map;
struct sseg_closure seginfo;
+   struct sbuf *sb;
void *hdr;
-   size_t hdrsize;
+   size_t hdrsize, notesz, segoff;
+   ssize_t n, old_len;
Elf_Phdr *php;
int i;
 
@@ -139,27 +160,32 @@ elf_coredump(int efd __unused, int fd, p
each_writable_segment(map, cb_size_segment, seginfo);
 
/*
-* Calculate the size of the core file header area by making
-* a dry run of generating it.  Nothing is written, but the
-* size is calculated.
+* Build the header and the notes using sbuf and write to the file.
 */
-   hdrsize = 0;
-   elf_puthdr(pid, map, NULL, hdrsize, seginfo.count);
-
-   /*
-* Allocate memory for building the header, fill it up,
-* and write it out.
-*/
-   if ((hdr = calloc(1, hdrsize)) == NULL)
-   errx(1, out of memory);
-
+   sb = sbuf_new_auto();
+   hdrsize = sizeof(Elf_Ehdr) + sizeof(Elf_Phdr) * (1 + seginfo.count);
+   /* Start header + notes section. */
+   sbuf_start_section(sb, NULL);
+   /* Make empty header subsection. */
+   sbuf_start_section(sb, old_len);
+   sbuf_putc(sb, 0);
+   sbuf_end_section(sb, old_len, hdrsize, 0);
+   /* Put notes. */
+   elf_putnotes(pid, sb, notesz);
+   /* Align up to a page boundary for the program segments. */
+   sbuf_end_section(sb, -1, PAGE_SIZE, 0);
+   if (sbuf_finish(sb) != 0)
+   err(1, 

  1   2   3   4   5   >