svn commit: r303021 - in head/sys/dev/hyperv: include netvsc storvsc utilities vmbus

2016-07-18 Thread Sepherosa Ziehau
Author: sephe
Date: Tue Jul 19 05:57:19 2016
New Revision: 303021
URL: https://svnweb.freebsd.org/changeset/base/303021

Log:
  hyperv/vmbus: Function rename
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7230

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/include/vmbus.h
  head/sys/dev/hyperv/netvsc/hv_net_vsc.c
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
  head/sys/dev/hyperv/utilities/hv_util.c
  head/sys/dev/hyperv/vmbus/hv_channel.c

Modified: head/sys/dev/hyperv/include/hyperv.h
==
--- head/sys/dev/hyperv/include/hyperv.hTue Jul 19 05:46:15 2016
(r303020)
+++ head/sys/dev/hyperv/include/hyperv.hTue Jul 19 05:57:19 2016
(r303021)
@@ -267,20 +267,6 @@ typedef struct hv_vmbus_channel {
 #define VMBUS_CHAN_ST_OPENED_SHIFT 0
 #define VMBUS_CHAN_ST_OPENED   (1 << VMBUS_CHAN_ST_OPENED_SHIFT)
 
-static inline void
-hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t on)
-{
-   if (!on)
-   channel->ch_flags &= ~VMBUS_CHAN_FLAG_BATCHREAD;
-   else
-   channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD;
-}
-
-inthv_vmbus_channel_open(struct hv_vmbus_channel *chan,
-   int txbr_size, int rxbr_size, const void *udata, int udlen,
-   vmbus_chan_callback_t cb, void *cbarg);
-void   hv_vmbus_channel_close(hv_vmbus_channel *channel);
-
 /**
  * @brief Get physical address from virtual
  */

Modified: head/sys/dev/hyperv/include/vmbus.h
==
--- head/sys/dev/hyperv/include/vmbus.h Tue Jul 19 05:46:15 2016
(r303020)
+++ head/sys/dev/hyperv/include/vmbus.h Tue Jul 19 05:57:19 2016
(r303021)
@@ -89,6 +89,11 @@ struct vmbus_chanpkt_rxbuf {
 
 struct hv_vmbus_channel;
 
+intvmbus_chan_open(struct hv_vmbus_channel *chan,
+   int txbr_size, int rxbr_size, const void *udata, int udlen,
+   vmbus_chan_callback_t cb, void *cbarg);
+void   vmbus_chan_close(struct hv_vmbus_channel *chan);
+
 intvmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan,
bus_addr_t paddr, int size, uint32_t *gpadl);
 intvmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan,
@@ -98,6 +103,7 @@ void vmbus_chan_cpu_set(struct hv_vmbus_
 void   vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan);
 struct hv_vmbus_channel *
vmbus_chan_cpu2chan(struct hv_vmbus_channel *chan, int cpu);
+void   vmbus_chan_set_readbatch(struct hv_vmbus_channel *chan, bool on);
 
 struct hv_vmbus_channel **
vmbus_subchan_get(struct hv_vmbus_channel *pri_chan, int subchan_cnt);

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c Tue Jul 19 05:46:15 2016
(r303020)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c Tue Jul 19 05:57:19 2016
(r303021)
@@ -645,7 +645,7 @@ hv_nv_subchan_attach(struct hv_vmbus_cha
 {
 
chan->hv_chan_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK);
-   hv_vmbus_channel_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE,
+   vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE,
NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0,
hv_nv_on_channel_callback, chan);
 }
@@ -675,7 +675,7 @@ hv_nv_on_device_add(struct hn_softc *sc,
/*
 * Open the channel
 */
-   ret = hv_vmbus_channel_open(chan,
+   ret = vmbus_chan_open(chan,
NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE,
NULL, 0, hv_nv_on_channel_callback, chan);
if (ret != 0) {
@@ -695,7 +695,7 @@ hv_nv_on_device_add(struct hn_softc *sc,
 close:
/* Now, we can close the channel safely */
free(chan->hv_chan_rdbuf, M_NETVSC);
-   hv_vmbus_channel_close(chan);
+   vmbus_chan_close(chan);
 
 cleanup:
/*
@@ -726,7 +726,7 @@ hv_nv_on_device_remove(struct hn_softc *
/* Now, we can close the channel safely */
 
free(sc->hn_prichan->hv_chan_rdbuf, M_NETVSC);
-   hv_vmbus_channel_close(sc->hn_prichan);
+   vmbus_chan_close(sc->hn_prichan);
 
sema_destroy(_dev->channel_init_sema);
free(net_dev, M_NETVSC);

Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.cTue Jul 19 
05:46:15 2016(r303020)
+++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.cTue Jul 19 
05:57:19 2016(r303021)
@@ -318,7 +318,7 @@ storvsc_subchan_attach(struct storvsc_so
 
new_channel->hv_chan_priv1 = sc;
vmbus_chan_cpu_rr(new_channel);
-   ret = hv_vmbus_channel_open(new_channel,
+   

svn commit: r303020 - in head/sys/dev/hyperv: include storvsc vmbus

2016-07-18 Thread Sepherosa Ziehau
Author: sephe
Date: Tue Jul 19 05:46:15 2016
New Revision: 303020
URL: https://svnweb.freebsd.org/changeset/base/303020

Log:
  hyperv/vmbus: Cleanup cpu based channel selection.
  
  And create cpu to channel map at device attach time for storvsc(4).
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7229

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/include/vmbus.h
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
  head/sys/dev/hyperv/vmbus/hv_channel.c

Modified: head/sys/dev/hyperv/include/hyperv.h
==
--- head/sys/dev/hyperv/include/hyperv.hTue Jul 19 05:36:21 2016
(r303019)
+++ head/sys/dev/hyperv/include/hyperv.hTue Jul 19 05:46:15 2016
(r303020)
@@ -281,8 +281,6 @@ int hv_vmbus_channel_open(struct hv_vmb
vmbus_chan_callback_t cb, void *cbarg);
 void   hv_vmbus_channel_close(hv_vmbus_channel *channel);
 
-struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel 
*promary);
-
 /**
  * @brief Get physical address from virtual
  */

Modified: head/sys/dev/hyperv/include/vmbus.h
==
--- head/sys/dev/hyperv/include/vmbus.h Tue Jul 19 05:36:21 2016
(r303019)
+++ head/sys/dev/hyperv/include/vmbus.h Tue Jul 19 05:46:15 2016
(r303020)
@@ -96,13 +96,14 @@ int vmbus_chan_gpadl_disconnect(struct h
 
 void   vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu);
 void   vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan);
+struct hv_vmbus_channel *
+   vmbus_chan_cpu2chan(struct hv_vmbus_channel *chan, int cpu);
 
 struct hv_vmbus_channel **
vmbus_subchan_get(struct hv_vmbus_channel *pri_chan, int subchan_cnt);
 void   vmbus_subchan_rel(struct hv_vmbus_channel **subchan, int subchan_cnt);
 void   vmbus_subchan_drain(struct hv_vmbus_channel *pri_chan);
 
-
 intvmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen,
uint64_t *xactid);
 intvmbus_chan_recv_pkt(struct hv_vmbus_channel *chan,

Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.cTue Jul 19 
05:36:21 2016(r303019)
+++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.cTue Jul 19 
05:46:15 2016(r303020)
@@ -147,6 +147,8 @@ struct storvsc_softc {
struct hv_storvsc_request   hs_init_req;
struct hv_storvsc_request   hs_reset_req;
device_ths_dev;
+
+   struct hv_vmbus_channel *hs_cpu2chan[MAXCPU];
 };
 
 
@@ -664,7 +666,7 @@ hv_storvsc_io_request(struct storvsc_sof
 
vstor_packet->operation = VSTOR_OPERATION_EXECUTESRB;
 
-   outgoing_channel = vmbus_select_outgoing_channel(sc->hs_chan);
+   outgoing_channel = sc->hs_cpu2chan[curcpu];
 
mtx_unlock(>softc->hs_lock);
if (request->prp_list.gpa_range.gpa_len) {
@@ -870,6 +872,20 @@ storvsc_probe(device_t dev)
return (ret);
 }
 
+static void
+storvsc_create_cpu2chan(struct storvsc_softc *sc)
+{
+   int cpu;
+
+   CPU_FOREACH(cpu) {
+   sc->hs_cpu2chan[cpu] = vmbus_chan_cpu2chan(sc->hs_chan, cpu);
+   if (bootverbose) {
+   device_printf(sc->hs_dev, "cpu%d -> chan%u\n",
+   cpu, sc->hs_cpu2chan[cpu]->ch_id);
+   }
+   }
+}
+
 /**
  * @brief StorVSC attach function
  *
@@ -967,6 +983,9 @@ storvsc_attach(device_t dev)
goto cleanup;
}
 
+   /* Construct cpu to channel mapping */
+   storvsc_create_cpu2chan(sc);
+
/*
 * Create the device queue.
 * Hyper-V maps each target to one SCSI HBA

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==
--- head/sys/dev/hyperv/vmbus/hv_channel.c  Tue Jul 19 05:36:21 2016
(r303019)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c  Tue Jul 19 05:46:15 2016
(r303020)
@@ -1250,61 +1250,63 @@ vmbus_chan_destroy_all(struct vmbus_soft
mtx_unlock(>vmbus_prichan_lock);
 }
 
-/**
- * @brief Select the best outgoing channel
- * 
+/*
  * The channel whose vcpu binding is closest to the currect vcpu will
  * be selected.
- * If no multi-channel, always select primary channel
- * 
- * @param primary - primary channel
+ * If no multi-channel, always select primary channel.
  */
 struct hv_vmbus_channel *
-vmbus_select_outgoing_channel(struct hv_vmbus_channel *primary)
+vmbus_chan_cpu2chan(struct hv_vmbus_channel *prichan, int cpu)
 {
-   hv_vmbus_channel *new_channel = NULL;
-   hv_vmbus_channel *outgoing_channel = primary;
-   int old_cpu_distance = 0;
-   

Re: svn commit: r303019 - head/sys/geom

2016-07-18 Thread Sepherosa Ziehau
Thanks!

On Tue, Jul 19, 2016 at 1:36 PM, Andrey V. Elsukov  wrote:
> Author: ae
> Date: Tue Jul 19 05:36:21 2016
> New Revision: 303019
> URL: https://svnweb.freebsd.org/changeset/base/303019
>
> Log:
>   Use g_resize_provider() to change the size of GEOM_DISK provider,
>   when it is being opened. This should fix the possible loss of a resize
>   event when disk capacity changed.
>
>   PR:   211028
>   Reported by:  Dexuan Cui 
>   MFC after:3 weeks
>
> Modified:
>   head/sys/geom/geom_disk.c
>
> Modified: head/sys/geom/geom_disk.c
> ==
> --- head/sys/geom/geom_disk.c   Tue Jul 19 04:56:59 2016(r303018)
> +++ head/sys/geom/geom_disk.c   Tue Jul 19 05:36:21 2016(r303019)
> @@ -126,7 +126,6 @@ g_disk_access(struct g_provider *pp, int
> if (error != 0)
> return (error);
> }
> -   pp->mediasize = dp->d_mediasize;
> pp->sectorsize = dp->d_sectorsize;
> if (dp->d_maxsize == 0) {
> printf("WARNING: Disk drive %s%d has no d_maxsize\n",
> @@ -143,6 +142,7 @@ g_disk_access(struct g_provider *pp, int
> pp->stripeoffset = dp->d_stripeoffset;
> pp->stripesize = dp->d_stripesize;
> dp->d_flags |= DISKFLAG_OPEN;
> +   g_resize_provider(pp, dp->d_mediasize);
> } else if ((pp->acr + pp->acw + pp->ace) > 0 && (r + w + e) == 0) {
> if (dp->d_close != NULL) {
> error = dp->d_close(dp);
> ___
> 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"



-- 
Tomorrow Will Never Die
___
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"


svn commit: r303019 - head/sys/geom

2016-07-18 Thread Andrey V. Elsukov
Author: ae
Date: Tue Jul 19 05:36:21 2016
New Revision: 303019
URL: https://svnweb.freebsd.org/changeset/base/303019

Log:
  Use g_resize_provider() to change the size of GEOM_DISK provider,
  when it is being opened. This should fix the possible loss of a resize
  event when disk capacity changed.
  
  PR:   211028
  Reported by:  Dexuan Cui 
  MFC after:3 weeks

Modified:
  head/sys/geom/geom_disk.c

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Tue Jul 19 04:56:59 2016(r303018)
+++ head/sys/geom/geom_disk.c   Tue Jul 19 05:36:21 2016(r303019)
@@ -126,7 +126,6 @@ g_disk_access(struct g_provider *pp, int
if (error != 0)
return (error);
}
-   pp->mediasize = dp->d_mediasize;
pp->sectorsize = dp->d_sectorsize;
if (dp->d_maxsize == 0) {
printf("WARNING: Disk drive %s%d has no d_maxsize\n",
@@ -143,6 +142,7 @@ g_disk_access(struct g_provider *pp, int
pp->stripeoffset = dp->d_stripeoffset;
pp->stripesize = dp->d_stripesize;
dp->d_flags |= DISKFLAG_OPEN;
+   g_resize_provider(pp, dp->d_mediasize);
} else if ((pp->acr + pp->acw + pp->ace) > 0 && (r + w + e) == 0) {
if (dp->d_close != NULL) {
error = dp->d_close(dp);
___
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"


svn commit: r303018 - in head: sbin/ipfw sys/netinet sys/netpfil/ipfw

2016-07-18 Thread Andrey V. Elsukov
Author: ae
Date: Tue Jul 19 04:56:59 2016
New Revision: 303018
URL: https://svnweb.freebsd.org/changeset/base/303018

Log:
  Add named dynamic states support to ipfw(4).
  
  The keep-state, limit and check-state now will have additional argument
  flowname. This flowname will be assigned to dynamic rule by keep-state
  or limit opcode. And then can be matched by check-state opcode or
  O_PROBE_STATE internal opcode. To reduce possible breakage and to maximize
  compatibility with old rulesets default flowname introduced.
  It will be assigned to the rules when user has omitted state name in
  keep-state and check-state opcodes. Also if name is ambiguous (can be
  evaluated as rule opcode) it will be replaced to default.
  
  Reviewed by:  julian
  Obtained from:Yandex LLC
  MFC after:1 month
  Relnotes: yes
  Sponsored by: Yandex LLC
  Differential Revision:https://reviews.freebsd.org/D6674

Modified:
  head/sbin/ipfw/ipfw.8
  head/sbin/ipfw/ipfw2.c
  head/sys/netinet/ip_fw.h
  head/sys/netpfil/ipfw/ip_fw2.c
  head/sys/netpfil/ipfw/ip_fw_dynamic.c
  head/sys/netpfil/ipfw/ip_fw_private.h
  head/sys/netpfil/ipfw/ip_fw_sockopt.c

Modified: head/sbin/ipfw/ipfw.8
==
--- head/sbin/ipfw/ipfw.8   Tue Jul 19 03:13:51 2016(r303017)
+++ head/sbin/ipfw/ipfw.8   Tue Jul 19 04:56:59 2016(r303018)
@@ -1,7 +1,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 18, 2016
+.Dd July 19, 2016
 .Dt IPFW 8
 .Os
 .Sh NAME
@@ -750,7 +750,7 @@ will be executed when the packet matches
 .It Cm allow | accept | pass | permit
 Allow packets that match rule.
 The search terminates.
-.It Cm check-state
+.It Cm check-state Op Ar flowname | Cm any
 Checks the packet against the dynamic ruleset.
 If a match is found, execute the action associated with
 the rule which generated this dynamic rule, otherwise
@@ -765,6 +765,17 @@ rule is found, the dynamic ruleset is ch
 or
 .Cm limit
 rule.
+The
+.Ar flowname
+is symbolic name assigned to dynamic rule by
+.Cm keep-state
+opcode.
+The special flowname
+.Cm any
+can be used to ignore states flowname when matching.
+The
+.Cm default
+keyword is special name used for compatibility with old rulesets.
 .It Cm count
 Update counters for all packets that match rule.
 The search continues with the next rule.
@@ -1593,7 +1604,7 @@ specified in the same way as
 .It Cm ipversion Ar ver
 Matches IP packets whose IP version field is
 .Ar ver .
-.It Cm keep-state
+.It Cm keep-state Op Ar flowname
 Upon a match, the firewall will create a dynamic rule, whose
 default behaviour is to match bidirectional traffic between
 source and destination IP/port using the same protocol.
@@ -1601,11 +1612,20 @@ The rule has a limited lifetime (control
 .Xr sysctl 8
 variables), and the lifetime is refreshed every time a matching
 packet is found.
+The
+.Ar flowname
+is used to assign additional to addresses, ports and protocol parameter
+to dynamic rule. It can be used for more accurate matching by
+.Cm check-state
+rule.
+The
+.Cm default
+keyword is special name used for compatibility with old rulesets.
 .It Cm layer2
 Matches only layer2 packets, i.e., those passed to
 .Nm
 from ether_demux() and ether_output_frame().
-.It Cm limit Bro Cm src-addr | src-port | dst-addr | dst-port Brc Ar N
+.It Cm limit Bro Cm src-addr | src-port | dst-addr | dst-port Brc Ar N Op Ar 
flowname
 The firewall will only allow
 .Ar N
 connections with the same
@@ -1613,8 +1633,6 @@ set of parameters as specified in the ru
 One or more
 of source and destination addresses and ports can be
 specified.
-Currently,
-only IPv4 flows are supported.
 .It Cm lookup Bro Cm dst-ip | dst-port | src-ip | src-port | uid | jail Brc Ar 
name
 Search an entry in lookup table
 .Ar name
@@ -2207,6 +2225,12 @@ and
 .Em dst
 are used here only to denote the initial match addresses, but they
 are completely equivalent afterwards).
+Rules created by
+.Cm keep-state
+option also have a
+.Ar flowname
+taken from it.
+This name is used in matching together with addresses, ports and protocol.
 Dynamic rules will be checked at the first
 .Cm check-state, keep-state
 or
@@ -2215,23 +2239,23 @@ occurrence, and the action performed upo
 as in the parent rule.
 .Pp
 Note that no additional attributes other than protocol and IP addresses
-and ports are checked on dynamic rules.
+and ports and flowname are checked on dynamic rules.
 .Pp
 The typical use of dynamic rules is to keep a closed firewall configuration,
 but let the first TCP SYN packet from the inside network install a
 dynamic rule for the flow so that packets belonging to that session
 will be allowed through the firewall:
 .Pp
-.Dl "ipfw add check-state"
-.Dl "ipfw add allow tcp from my-subnet to any setup keep-state"
+.Dl "ipfw add check-state OUTBOUND"
+.Dl "ipfw add allow tcp from my-subnet to any setup keep-state OUTBOUND"
 .Dl "ipfw add deny tcp from any to any"
 .Pp
 A similar approach can be 

svn commit: r303017 - in head/sys/dev: nvd nvme

2016-07-18 Thread Scott Long
Author: scottl
Date: Tue Jul 19 03:13:51 2016
New Revision: 303017
URL: https://svnweb.freebsd.org/changeset/base/303017

Log:
  Implement crashdump support on NVME
  
  MFC after:3 days
  Sponsored by: Netflix, Inc.

Modified:
  head/sys/dev/nvd/nvd.c
  head/sys/dev/nvme/nvme.h
  head/sys/dev/nvme/nvme_ns_cmd.c

Modified: head/sys/dev/nvd/nvd.c
==
--- head/sys/dev/nvd/nvd.c  Tue Jul 19 00:47:00 2016(r303016)
+++ head/sys/dev/nvd/nvd.c  Tue Jul 19 03:13:51 2016(r303017)
@@ -47,6 +47,7 @@ struct nvd_disk;
 
 static disk_ioctl_t nvd_ioctl;
 static disk_strategy_t nvd_strategy;
+static dumper_t nvd_dump;
 
 static void nvd_done(void *arg, const struct nvme_completion *cpl);
 
@@ -226,6 +227,26 @@ nvd_ioctl(struct disk *ndisk, u_long cmd
return (ret);
 }
 
+static int
+nvd_dump(void *arg, void *virt, vm_offset_t phys, off_t offset, size_t len)
+{
+   struct nvd_disk *ndisk;
+   struct disk *dp;
+   int error;
+
+   dp = arg;
+   ndisk = dp->d_drv1;
+
+   if (len > 0) {
+   if ((error = nvme_ns_dump(ndisk->ns, virt, offset, len)) != 0)
+   return (error);
+   } else {
+   /* XXX sync to stable storage */
+   }
+
+   return (0);
+}
+
 static void
 nvd_done(void *arg, const struct nvme_completion *cpl)
 {
@@ -302,6 +323,7 @@ nvd_new_disk(struct nvme_namespace *ns, 
disk = disk_alloc();
disk->d_strategy = nvd_strategy;
disk->d_ioctl = nvd_ioctl;
+   disk->d_dump = nvd_dump;
disk->d_name = NVD_STR;
disk->d_drv1 = ndisk;
 

Modified: head/sys/dev/nvme/nvme.h
==
--- head/sys/dev/nvme/nvme.hTue Jul 19 00:47:00 2016(r303016)
+++ head/sys/dev/nvme/nvme.hTue Jul 19 03:13:51 2016(r303017)
@@ -876,6 +876,8 @@ int nvme_ns_cmd_deallocate(struct nvme_n
   void *cb_arg);
 intnvme_ns_cmd_flush(struct nvme_namespace *ns, nvme_cb_fn_t cb_fn,
  void *cb_arg);
+intnvme_ns_dump(struct nvme_namespace *ns, void *virt, off_t offset,
+size_t len);
 
 /* Registration functions */
 struct nvme_consumer * nvme_register_consumer(nvme_cons_ns_fn_tns_fn,

Modified: head/sys/dev/nvme/nvme_ns_cmd.c
==
--- head/sys/dev/nvme/nvme_ns_cmd.c Tue Jul 19 00:47:00 2016
(r303016)
+++ head/sys/dev/nvme/nvme_ns_cmd.c Tue Jul 19 03:13:51 2016
(r303017)
@@ -151,3 +151,47 @@ nvme_ns_cmd_flush(struct nvme_namespace 
 
return (0);
 }
+
+/* Timeout = 1 sec */
+#define NVD_DUMP_TIMEOUT   10
+
+int
+nvme_ns_dump(struct nvme_namespace *ns, void *virt, off_t offset, size_t len)
+{
+   struct nvme_completion_poll_status status;
+   struct nvme_request *req;
+   struct nvme_command *cmd;
+   uint64_t lba, lba_count;
+   int i;
+
+   status.done = FALSE;
+   req = nvme_allocate_request_vaddr(virt, len, nvme_completion_poll_cb,
+   );
+   if (req == NULL)
+   return (ENOMEM);
+
+   cmd = >cmd;
+   cmd->opc = NVME_OPC_WRITE;
+   cmd->nsid = ns->id;
+
+   lba = offset / nvme_ns_get_sector_size(ns);
+   lba_count = len / nvme_ns_get_sector_size(ns);
+
+   *(uint64_t *)>cdw10 = lba;
+   cmd->cdw12 = lba_count - 1;
+
+   nvme_ctrlr_submit_io_request(ns->ctrlr, req);
+   if (req->qpair == NULL)
+   return (ENXIO);
+
+   i = 0;
+   while ((i++ < NVD_DUMP_TIMEOUT) && (status.done == FALSE)) {
+   DELAY(10);
+   nvme_qpair_process_completions(req->qpair);
+   }
+
+   if (status.done == FALSE)
+   return (ETIMEDOUT);
+
+   return (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"


svn commit: r303016 - head/contrib/llvm/projects/libunwind/include

2016-07-18 Thread Ed Maste
Author: emaste
Date: Tue Jul 19 00:47:00 2016
New Revision: 303016
URL: https://svnweb.freebsd.org/changeset/base/303016

Log:
  llvm-libunwind: use conventional (non-Darwin) X86 register numbers
  
  For historical reasons Darwin/i386 has ebp and esp swapped in the
  eh_frame register numbering.  That is:
  
   Darwin  Other
  Reg #eh_frameeh_frameDWARF
  ==
4ebp espesp
5esp ebpebp
  
  Although the UNW_X86_* constants are not supposed to be coupled to
  DWARF / eh_frame numbering they are currently conflated in LLVM
  libunwind, and thus we require the non-Darwin numbering.
  
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation

Modified:
  head/contrib/llvm/projects/libunwind/include/libunwind.h

Modified: head/contrib/llvm/projects/libunwind/include/libunwind.h
==
--- head/contrib/llvm/projects/libunwind/include/libunwind.hTue Jul 19 
00:27:17 2016(r303015)
+++ head/contrib/llvm/projects/libunwind/include/libunwind.hTue Jul 19 
00:47:00 2016(r303016)
@@ -151,8 +151,8 @@ enum {
   UNW_X86_ECX = 1,
   UNW_X86_EDX = 2,
   UNW_X86_EBX = 3,
-  UNW_X86_EBP = 4,
-  UNW_X86_ESP = 5,
+  UNW_X86_ESP = 4,
+  UNW_X86_EBP = 5,
   UNW_X86_ESI = 6,
   UNW_X86_EDI = 7
 };
___
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: r302897 - head/usr.sbin/bsdinstall/scripts

2016-07-18 Thread Nathan Whitehorn



On 07/15/16 08:07, Bartek Rutkowski wrote:

Author: robak (ports committer)
Date: Fri Jul 15 15:07:24 2016
New Revision: 302897
URL: https://svnweb.freebsd.org/changeset/base/302897

Log:
   Add new System Hardening menu and options to bsdinstall.
   
   This patch add new 'hardening' file responsible for new bsdinstall

   'System Hardening' menu allowing users to set some sane and carefully
   picked system security options (like random process id's, hiding
   other users/groups processes and others).
   
   All options are OFF by default in this patch due to POLA principle

   with intention to turn change some of them to ON by default in future.
   
   Reviewed by:	adrian, allanjude, bdrewery, nwhitehorn

   Approved by: adrian, allanjude
   MFC after:   7 days


Thanks for this! One nit below.

Modified: head/usr.sbin/bsdinstall/scripts/auto
==
--- head/usr.sbin/bsdinstall/scripts/auto   Fri Jul 15 13:25:47 2016
(r302896)
+++ head/usr.sbin/bsdinstall/scripts/auto   Fri Jul 15 15:07:24 2016
(r302897)
@@ -385,6 +385,7 @@ if [ "$NETCONFIG_DONE" != yes ]; then
  fi
  bsdinstall time
  bsdinstall services
+bsdinstall hardening


As discussed in the review, I'd prefer it if this were not here and only 
the part below (in the final menu) were present in the auto script, in 
particular for 11.0-RELEASE. This keeps the installer flow and avoids 
preventing the user with a new menu of optional off-by-default things 
that you have to get through to finish the installation (Handbook 
installation is in the same category). Would it be possible to change that?

-Nathan


  dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
  "Would you like to add users to the installed system now?" 0 0 && \
@@ -401,6 +402,7 @@ finalconfig() {
"Hostname" "Set system hostname" \
"Network" "Networking configuration" \
"Services" "Set daemons to run on startup" \
+   "System Hardening" "Set security options" \
"Time Zone" "Set system timezone" \
"Handbook" "Install FreeBSD Handbook (requires network)" 2>&1 
1>&3)
exec 3>&-
@@ -426,6 +428,10 @@ finalconfig() {
bsdinstall services
finalconfig
;;
+   "System Hardening")
+   bsdinstall hardening
+   finalconfig
+   ;;
"Time Zone")
bsdinstall time
finalconfig



___
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"


svn commit: r303015 - head/sys/dev/ath

2016-07-18 Thread Adrian Chadd
Author: adrian
Date: Tue Jul 19 00:27:17 2016
New Revision: 303015
URL: https://svnweb.freebsd.org/changeset/base/303015

Log:
  [ath] don't do LDPC, STBC or short-gi for locationing frames.
  
  The 11n duration calculation function in net80211 and the HAL round /up/
  the duration calculation for short-gi, so we can't use that.
  
  The 11n duration calculation doesn't know about the extra symbol time
  needed for STBC, nor the LDPC encoding duration, so we can't use
  that.
  
  This (along with other, local hacks) allow the locationing services to
  get down to around 200nS (yes, nanoseconds) of variance when speaking
  to a "good" AP.
  
  Tested:
  
  * AR9380, STA mode, local locationing frame hacks

Modified:
  head/sys/dev/ath/if_ath_tx_ht.c

Modified: head/sys/dev/ath/if_ath_tx_ht.c
==
--- head/sys/dev/ath/if_ath_tx_ht.c Tue Jul 19 00:25:27 2016
(r303014)
+++ head/sys/dev/ath/if_ath_tx_ht.c Tue Jul 19 00:27:17 2016
(r303015)
@@ -242,6 +242,14 @@ ath_tx_rate_fill_rcflags(struct ath_soft
if ((ni->ni_vap->iv_htcaps & IEEE80211_HTCAP_LDPC) &&
(ni->ni_htcap & IEEE80211_HTCAP_LDPC))
do_ldpc = 1;
+
+   /*
+* The 11n duration calculation doesn't know about LDPC,
+* so don't enable it for positioning.
+*/
+   if (bf->bf_flags & ATH_BUF_TOA_PROBE)
+   do_ldpc = 0;
+
do_stbc = 0;
 
for (i = 0; i < ATH_RC_NUM; i++) {
@@ -279,29 +287,43 @@ ath_tx_rate_fill_rcflags(struct ath_soft
if (ni->ni_chw == 40)
rc[i].flags |= ATH_RC_CW40_FLAG;
 
+   /*
+* NOTE: Don't do short-gi for positioning frames.
+*
+* For now, the ath_hal and net80211 HT duration
+* calculation rounds up the 11n data txtime
+* to the nearest multiple of 3.6 microseconds
+* and doesn't return the fractional part, so
+* we are always "out" by some amount.
+*/
if (ni->ni_chw == 40 &&
ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI40 &&
ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40 &&
-   vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40)
+   vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40 &&
+   (bf->bf_flags & ATH_BUF_TOA_PROBE) == 0) {
rc[i].flags |= ATH_RC_SGI_FLAG;
+   }
 
if (ni->ni_chw == 20 &&
ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI20 &&
ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20 &&
-   vap->iv_flags_ht & IEEE80211_FHT_SHORTGI20)
+   vap->iv_flags_ht & IEEE80211_FHT_SHORTGI20 &&
+   (bf->bf_flags & ATH_BUF_TOA_PROBE) == 0) {
rc[i].flags |= ATH_RC_SGI_FLAG;
+   }
 
/*
 * If we have STBC TX enabled and the receiver
 * can receive (at least) 1 stream STBC, AND it's
 * MCS 0-7, AND we have at least two chains enabled,
-* enable STBC.
+* and we're not doing positioning, enable STBC.
 */
if (ic->ic_htcaps & IEEE80211_HTCAP_TXSTBC &&
ni->ni_vap->iv_flags_ht & IEEE80211_FHT_STBC_TX &&
ni->ni_htcap & IEEE80211_HTCAP_RXSTBC_1STREAM &&
(sc->sc_cur_txchainmask > 1) &&
-   HT_RC_2_STREAMS(rate) == 1) {
+   (HT_RC_2_STREAMS(rate) == 1) &&
+   (bf->bf_flags & ATH_BUF_TOA_PROBE) == 0) {
rc[i].flags |= ATH_RC_STBC_FLAG;
do_stbc = 1;
}
___
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"


svn commit: r303014 - head/lib/libc/gen

2016-07-18 Thread Andrey A. Chernov
Author: ache
Date: Tue Jul 19 00:25:27 2016
New Revision: 303014
URL: https://svnweb.freebsd.org/changeset/base/303014

Log:
  1) Don't protect \/ and \. even if user say so. They are not special chars
  in any case and needed for further processing. For ~ expansion too.
  
  2) Don't terminate *pathend with / when GLOB_LIMIT_STAT is reached, it will
  be not visible outside in any case since error is returned.
  
  3) Cosmetic: change if expression to better reflect its semantic.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cMon Jul 18 20:24:13 2016(r303013)
+++ head/lib/libc/gen/glob.cTue Jul 19 00:25:27 2016(r303014)
@@ -244,7 +244,8 @@ glob(const char * __restrict pattern, in
return (GLOB_NOMATCH);
else if (clen == 0)
break;
-   *bufnext++ = wc | prot;
+   *bufnext++ = wc | ((wc != DOT && wc != SEP) ?
+   prot : 0);
patnext += clen;
}
}
@@ -478,8 +479,8 @@ globtilde(const Char *pattern, Char *pat
return (NULL);
 
dc = wbuf;
-   for (b = patbuf; b < eb && *dc != EOS; *b++ = *dc++ | M_PROTECT)
-   continue;
+   for (b = patbuf; b < eb && *dc != EOS; b++, dc++)
+   *b = *dc | ((*dc != DOT && *dc != SEP) ? M_PROTECT : 0);
if (*dc != EOS)
return (NULL);
 
@@ -642,10 +643,6 @@ glob2(Char *pathbuf, Char *pathend, Char
if ((pglob->gl_flags & GLOB_LIMIT) &&
limit->l_stat_cnt++ >= GLOB_LIMIT_STAT) {
errno = 0;
-   if (pathend + 1 > pathend_last)
-   return (GLOB_NOSPACE);
-   *pathend++ = SEP;
-   *pathend = EOS;
return (GLOB_NOSPACE);
}
if (((pglob->gl_flags & GLOB_MARK) &&
@@ -886,7 +883,7 @@ match(Char *name, Char *pat, Char *paten
ok = 0;
if ((k = *name++) == EOS)
return (0);
-   if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
+   if ((negate_range = ((*pat & M_MASK) == M_NOT)) != 0)
++pat;
while (((c = *pat++) & M_MASK) != M_END)
if ((*pat & M_MASK) == M_RNG) {
___
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: r301453 - in head/sys: arm/arm arm64/arm64 dev/fdt dev/gpio dev/iicbus dev/ofw dev/pci dev/vnic kern mips/mips sys

2016-07-18 Thread Nathan Whitehorn

Could you please describe what this change is in more detail?

It breaks a lot of encapsulations we have worked very hard to maintain, 
moves ARM code into MI parts of the kernel, and the OFW parts violate 
IEEE 1275 (the Open Firmware standard). In particular, there is no 
guarantee that the interrupts for a newbus (or OF) device are encoded in 
a property called "interrupts" (or, indeed, in any property at all) on 
that node and there are many, many device trees where that is not the 
case (e.g. ones with interrupt maps, as well as Apple hardware). By 
putting that knowledge into the OF root bus device, which we have tried 
to keep it out of, this enforces a standard that doesn't actually exist.


I'm hesitant to ask for reversion on something that landed 6 weeks ago 
without me noticing, but this needs a lot more architectural work before 
any parts of the kernel should use it.

-Nathan

On 06/05/16 09:20, Svatopluk Kraus wrote:

Author: skra
Date: Sun Jun  5 16:20:12 2016
New Revision: 301453
URL: https://svnweb.freebsd.org/changeset/base/301453

Log:
   INTRNG - change the way how an interrupt mapping data are provided
   to the framework in OFW (FDT) case.
   
   This is a follow-up to r301451.
   
   Differential Revision:	https://reviews.freebsd.org/D6634


Modified:
   head/sys/arm/arm/nexus.c
   head/sys/arm64/arm64/gic_v3.c
   head/sys/arm64/arm64/nexus.c
   head/sys/dev/fdt/simplebus.c
   head/sys/dev/gpio/ofw_gpiobus.c
   head/sys/dev/iicbus/ofw_iicbus.c
   head/sys/dev/ofw/ofw_bus_subr.c
   head/sys/dev/ofw/ofw_bus_subr.h
   head/sys/dev/ofw/ofwbus.c
   head/sys/dev/pci/pci_host_generic.c
   head/sys/dev/vnic/mrml_bridge.c
   head/sys/dev/vnic/thunder_mdio_fdt.c
   head/sys/kern/subr_intr.c
   head/sys/mips/mips/nexus.c
   head/sys/sys/intr.h

Modified: head/sys/arm/arm/nexus.c
==
--- head/sys/arm/arm/nexus.cSun Jun  5 16:09:31 2016(r301452)
+++ head/sys/arm/arm/nexus.cSun Jun  5 16:20:12 2016(r301453)
@@ -412,6 +412,10 @@ nexus_ofw_map_intr(device_t dev, device_
  pcell_t *intr)
  {
  
+#ifdef INTRNG

+   return (INTR_IRQ_INVALID);
+#else
return (intr_fdt_map_irq(iparent, intr, icells));
+#endif
  }
  #endif

Modified: head/sys/arm64/arm64/gic_v3.c
==
--- head/sys/arm64/arm64/gic_v3.c   Sun Jun  5 16:09:31 2016
(r301452)
+++ head/sys/arm64/arm64/gic_v3.c   Sun Jun  5 16:20:12 2016
(r301453)
@@ -58,6 +58,10 @@ __FBSDID("$FreeBSD$");
  #include 
  #include 
  
+#ifdef FDT

+#include 
+#endif
+
  #include "pic_if.h"
  
  #include "gic_v3_reg.h"


Modified: head/sys/arm64/arm64/nexus.c
==
--- head/sys/arm64/arm64/nexus.cSun Jun  5 16:09:31 2016
(r301452)
+++ head/sys/arm64/arm64/nexus.cSun Jun  5 16:20:12 2016
(r301453)
@@ -448,7 +448,7 @@ nexus_ofw_map_intr(device_t dev, device_
  pcell_t *intr)
  {
  #ifdef INTRNG
-   return (intr_fdt_map_irq(iparent, intr, icells));
+   return (INTR_IRQ_INVALID);
  #else
int irq;
  


Modified: head/sys/dev/fdt/simplebus.c
==
--- head/sys/dev/fdt/simplebus.cSun Jun  5 16:09:31 2016
(r301452)
+++ head/sys/dev/fdt/simplebus.cSun Jun  5 16:20:12 2016
(r301453)
@@ -251,7 +251,9 @@ simplebus_setup_dinfo(device_t dev, phan
  
  	resource_list_init(>rl);

ofw_bus_reg_to_rl(dev, node, sc->acells, sc->scells, >rl);
+#ifndef INTRNG
ofw_bus_intr_to_rl(dev, node, >rl, NULL);
+#endif
  
  	return (ndi);

  }

Modified: head/sys/dev/gpio/ofw_gpiobus.c
==
--- head/sys/dev/gpio/ofw_gpiobus.c Sun Jun  5 16:09:31 2016
(r301452)
+++ head/sys/dev/gpio/ofw_gpiobus.c Sun Jun  5 16:20:12 2016
(r301453)
@@ -321,11 +321,13 @@ ofw_gpiobus_setup_devinfo(device_t bus,
devi->pins[i] = pins[i].pin;
}
free(pins, M_DEVBUF);
+#ifndef INTRNG
/* Parse the interrupt resources. */
if (ofw_bus_intr_to_rl(bus, node, >opd_dinfo.rl, NULL) != 0) {
ofw_gpiobus_destroy_devinfo(bus, dinfo);
return (NULL);
}
+#endif
device_set_ivars(child, dinfo);
  
  	return (dinfo);


Modified: head/sys/dev/iicbus/ofw_iicbus.c
==
--- head/sys/dev/iicbus/ofw_iicbus.cSun Jun  5 16:09:31 2016
(r301452)
+++ head/sys/dev/iicbus/ofw_iicbus.cSun Jun  5 16:20:12 2016
(r301453)
@@ -187,8 +187,10 @@ ofw_iicbus_attach(device_t dev)
  
  		childdev = device_add_child(dev, NULL, -1);

resource_list_init(>opd_dinfo.rl);
+#ifndef INTRNG

Re: svn commit: r302985 - head/sys/geom/label

2016-07-18 Thread Maxim Sobolev
Andrey, would you mind leaving your comments in the phabricator so that the
Mikhail (original contributor of the patch) could work on an improved
version? You might be correct about the abs(), I've overlooked that, but
the fs_fsize math is just copied over the previous code as far as I can
tell. So if it worked with the strict comparison, it should also work with
relaxed bound one.

https://reviews.freebsd.org/D6208

Thanks!

-Max

On Mon, Jul 18, 2016 at 1:18 PM, Andrey V. Elsukov 
wrote:

> On 18.07.16 22:37, Maxim Sobolev wrote:
> > Well, this looks to me exactly what I am talking about. With this change
> > we are only allowing underlying provider to be *slighly* bigger than the
> > UFS size. So as I said it's pretty harmless to do so, or at least I
>
> So, this isn't true.
> 1. You use abs() in the macro - it can be less or bigger.
> 2. fs_fsize is size of frag blocks, so use it as divider looks incorrect.
>
> --
> WBR, Andrey V. Elsukov
>
>
___
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"


svn commit: r303013 - head/lib/libc/gen

2016-07-18 Thread Andrey A. Chernov
Author: ache
Date: Mon Jul 18 20:24:13 2016
New Revision: 303013
URL: https://svnweb.freebsd.org/changeset/base/303013

Log:
  g_Ctoc() conversion buffers are smaller than needed up to MB_CUR_MAX - 1
  since whole conversion needs a room for (len >= MB_CUR_MAX). It is no
  difference when MB_CUR_MAX == 1, but for multi-byte locales last few chars
  ('\0' and before) may need just one byte, and the rest of MB_CUR_MAX - 1
  space becomes unavailable in the MAXPATHLEN-sized buffer, which cause
  conversion error on near MAXPATHLEN long pathes.
  
  Increase g_Ctoc() conversion buffers to MB_LEN_MAX - 1.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cMon Jul 18 19:46:31 2016(r303012)
+++ head/lib/libc/gen/glob.cMon Jul 18 20:24:13 2016(r303013)
@@ -702,7 +702,7 @@ glob3(Char *pathbuf, Char *pathend, Char
struct dirent *dp;
DIR *dirp;
int err;
-   char buf[MAXPATHLEN];
+   char buf[MAXPATHLEN + MB_LEN_MAX - 1];
 
struct dirent *(*readdirfunc)(DIR *);
 
@@ -933,7 +933,7 @@ globfree(glob_t *pglob)
 static DIR *
 g_opendir(Char *str, glob_t *pglob)
 {
-   char buf[MAXPATHLEN];
+   char buf[MAXPATHLEN + MB_LEN_MAX - 1];
 
if (*str == EOS)
strcpy(buf, ".");
@@ -953,7 +953,7 @@ g_opendir(Char *str, glob_t *pglob)
 static int
 g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
 {
-   char buf[MAXPATHLEN];
+   char buf[MAXPATHLEN + MB_LEN_MAX - 1];
 
if (g_Ctoc(fn, buf, sizeof(buf))) {
errno = ENAMETOOLONG;
@@ -967,7 +967,7 @@ g_lstat(Char *fn, struct stat *sb, glob_
 static int
 g_stat(Char *fn, struct stat *sb, glob_t *pglob)
 {
-   char buf[MAXPATHLEN];
+   char buf[MAXPATHLEN + MB_LEN_MAX - 1];
 
if (g_Ctoc(fn, buf, sizeof(buf))) {
errno = ENAMETOOLONG;
___
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: r302985 - head/sys/geom/label

2016-07-18 Thread Andrey V. Elsukov
On 18.07.16 22:37, Maxim Sobolev wrote:
> Well, this looks to me exactly what I am talking about. With this change
> we are only allowing underlying provider to be *slighly* bigger than the
> UFS size. So as I said it's pretty harmless to do so, or at least I

So, this isn't true.
1. You use abs() in the macro - it can be less or bigger.
2. fs_fsize is size of frag blocks, so use it as divider looks incorrect.

-- 
WBR, Andrey V. Elsukov



signature.asc
Description: OpenPGP digital signature


svn commit: r303012 - in head: sbin/ipfw sys/conf sys/modules sys/modules/ipfw_nptv6 sys/netinet sys/netinet6 sys/netpfil/ipfw/nptv6

2016-07-18 Thread Andrey V. Elsukov
Author: ae
Date: Mon Jul 18 19:46:31 2016
New Revision: 303012
URL: https://svnweb.freebsd.org/changeset/base/303012

Log:
  Add ipfw_nptv6 module that implements Network Prefix Translation for IPv6
  as defined in RFC 6296. The module works together with ipfw(4) and
  implemented as its external action module. When it is loaded, it registers
  as eaction and can be used in rules. The usage pattern is similar to
  ipfw_nat(4). All matched by rule traffic goes to the NPT module.
  
  Reviewed by:  hrs
  Obtained from:Yandex LLC
  MFC after:1 month
  Relnotes: yes
  Sponsored by: Yandex LLC
  Differential Revision:https://reviews.freebsd.org/D6420

Added:
  head/sbin/ipfw/nptv6.c   (contents, props changed)
  head/sys/modules/ipfw_nptv6/
  head/sys/modules/ipfw_nptv6/Makefile   (contents, props changed)
  head/sys/netinet6/ip_fw_nptv6.h   (contents, props changed)
  head/sys/netpfil/ipfw/nptv6/
  head/sys/netpfil/ipfw/nptv6/ip_fw_nptv6.c   (contents, props changed)
  head/sys/netpfil/ipfw/nptv6/nptv6.c   (contents, props changed)
  head/sys/netpfil/ipfw/nptv6/nptv6.h   (contents, props changed)
Modified:
  head/sbin/ipfw/Makefile
  head/sbin/ipfw/ipfw.8
  head/sbin/ipfw/ipfw2.c
  head/sbin/ipfw/ipfw2.h
  head/sbin/ipfw/main.c
  head/sys/conf/NOTES
  head/sys/conf/files
  head/sys/conf/options
  head/sys/modules/Makefile
  head/sys/netinet/ip_fw.h

Modified: head/sbin/ipfw/Makefile
==
--- head/sbin/ipfw/Makefile Mon Jul 18 19:20:49 2016(r303011)
+++ head/sbin/ipfw/Makefile Mon Jul 18 19:46:31 2016(r303012)
@@ -5,6 +5,7 @@
 PACKAGE=ipfw
 PROG=  ipfw
 SRCS=  ipfw2.c dummynet.c ipv6.c main.c nat.c tables.c
+SRCS+= nptv6.c
 WARNS?=2
 
 .if ${MK_PF} != "no"

Modified: head/sbin/ipfw/ipfw.8
==
--- head/sbin/ipfw/ipfw.8   Mon Jul 18 19:20:49 2016(r303011)
+++ head/sbin/ipfw/ipfw.8   Mon Jul 18 19:46:31 2016(r303012)
@@ -1,7 +1,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 26, 2016
+.Dd July 18, 2016
 .Dt IPFW 8
 .Os
 .Sh NAME
@@ -113,6 +113,19 @@ in-kernel NAT.
 .Oc
 .Oc
 .Ar pathname
+.Ss IPv6-to-IPv6 NETWORK PREFIX TRANSLATION
+.Nm
+.Oo Cm set Ar N Oc Cm nptv6 Ar name Cm create Ar create-options
+.Nm
+.Oo Cm set Ar N Oc Cm nptv6
+.Brq Ar name | all
+.Brq Cm list | show
+.Nm
+.Oo Cm set Ar N Oc Cm nptv6
+.Brq Ar name | all
+.Cm destroy
+.Nm
+.Oo Cm set Ar N Oc Cm nptv6 Ar name Cm stats
 .Ss INTERNAL DIAGNOSTICS
 .Nm
 .Cm internal iflist
@@ -813,6 +826,11 @@ nat instance
 see the
 .Sx NETWORK ADDRESS TRANSLATION (NAT)
 Section for further information.
+.It Cm nptv6 Ar name
+Pass packet to a NPTv6 instance (for IPv6-to-IPv6 network prefix translation):
+see the
+.Sx IPv6-to-IPv6 NETWORK PREFIX TRANSLATION (NPTv6)
+Section for further information.
 .It Cm pipe Ar pipe_nr
 Pass packet to a
 .Nm dummynet
@@ -2885,6 +2903,47 @@ instances.
 See
 .Sx SYSCTL VARIABLES
 for more info.
+.Sh IPv6-to-IPv6 NETWORK PREFIX TRANSLATION (NPTv6)
+.Nm
+support in-kernel IPv6-to-IPv6 network prefix translation as described
+in RFC6296.
+The kernel module
+.Cm ipfw_nptv6
+should be loaded or kernel should has
+.Cm options IPFIREWALL_NPTV6
+to be able use NPTv6 translator.
+.Pp
+The NPTv6 configuration command is the following:
+.Bd -ragged -offset indent
+.Bk -words
+.Cm nptv6
+.Ar name
+.Cm create
+.Ar create-options
+.Ek
+.Ed
+.Pp
+The following parameters can be configured:
+.Bl -tag -width indent
+.It Cm int_prefix Ar ipv6_prefix
+IPv6 prefix used in internal network.
+NPTv6 module translates source address when it matches this prefix.
+.It Cm ext_prefix Ar ipv6_prefix
+IPv6 prefix used in external network.
+NPTv6 module translates destination address when it matches this prefix.
+.It Cm prefixlen Ar length
+The length of specified IPv6 prefixes. It must be in range from 8 to 64.
+.El
+.Pp
+Note that the prefix translation rules are silently ignored when IPv6 packet
+forwarding is disabled.
+To enable the packet forwarding, set the sysctl variable
+.Va net.inet6.ip6.forwarding
+to 1.
+.Pp
+To let the packet continue after being translated, set the sysctl variable
+.Va net.inet.ip.fw.one_pass
+to 0.
 .Sh LOADER TUNABLES
 Tunables can be set in
 .Xr loader 8

Modified: head/sbin/ipfw/ipfw2.c
==
--- head/sbin/ipfw/ipfw2.c  Mon Jul 18 19:20:49 2016(r303011)
+++ head/sbin/ipfw/ipfw2.c  Mon Jul 18 19:46:31 2016(r303012)
@@ -235,6 +235,7 @@ static struct _s_x ether_types[] = {
 };
 
 static struct _s_x rule_eactions[] = {
+   { "nptv6",  TOK_NPTV6 },
{ NULL, 0 } /* terminator */
 };
 

Modified: head/sbin/ipfw/ipfw2.h
==
--- head/sbin/ipfw/ipfw2.h  Mon Jul 18 19:20:49 2016(r303011)
+++ 

Re: svn commit: r302985 - head/sys/geom/label

2016-07-18 Thread Maxim Sobolev
Well, this looks to me exactly what I am talking about. With this change we
are only allowing underlying provider to be *slighly* bigger than the UFS
size. So as I said it's pretty harmless to do so, or at least I think it
is. In general I think this case is underlying some missing design feature
of GEOM framework, which basically gives provider to a first bidder that
likes the taste of it. What needs to be happening instead is to have some
rank in there, so if consumer A and consumer B both "like" the taste, but
provider A has bigger rank it would be given a preference. Then "whole
disk" partitioning schemes (mbr, gpt) could be given biggest rank, BSD
label and friends slightly smaller, encryption/compression yet smaller and
providers that just "decorate" things, like LABEL the lowest possible.

-Max

On Mon, Jul 18, 2016 at 12:13 PM, Andrey V. Elsukov 
wrote:

> On 18.07.16 17:24, Maxim Sobolev wrote:
> > Andrey, are you talking about this:
> >
> > ---
> > r156299 | pjd | 2006-03-04 11:41:54 -0800 (сб, 04 мар 2006) | 11 lines
> >
> > We need to check if file system size is equal to provider's size, because
> > sysinstall(8) still bogusly puts first partition at offset 0 instead of
> 16,
> > so glabel/ufs will find file system on slice instead of partition.
> >
> > Before sysinstall is fixed, we must keep this code, which means that we
> > wont't be able to detect UFS file systems created with 'newfs -s ...'.
> >
> > PS. bsdlabel(8) creates partitions properly.
> >
> > MFC after:  3 days
> > ---
> >
> > In which case this particular change has a better chance of working
> > since it's not removing this check but making it less strict. Therefore
> > it might attach to a wrong provider only if first UFS slice is the only
> > one slice on partition (or if the other partition is very small - less
> > than 256 blocks in size). In either of those cases I don't think it
> > makes much difference if we are attaching to a slice or a partition.
>
> No, I mean r235918, that was reverted after several complains.
> UFS label is a special label. It always had the same size that provider.
> Now it will attach to first provider that will be tasted. It can be
> gmirror, generic glabel, geli, gpart, mbr, whole disk.
>
> https://lists.freebsd.org/pipermail/freebsd-geom/2009-April/003473.html
>
> --
> WBR, Andrey V. Elsukov
>
>
___
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"

svn commit: r303011 - head/lib/libc/gen

2016-07-18 Thread Andrey A. Chernov
Author: ache
Date: Mon Jul 18 19:20:49 2016
New Revision: 303011
URL: https://svnweb.freebsd.org/changeset/base/303011

Log:
  Change patch from r303004 case 3. According to POSIX gl_errfunc should be
  called first, then GLOB_ERR should be considered.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cMon Jul 18 18:24:31 2016(r303010)
+++ head/lib/libc/gen/glob.cMon Jul 18 19:20:49 2016(r303011)
@@ -714,9 +714,7 @@ glob3(Char *pathbuf, Char *pathend, Char
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
if (errno == ENOENT || errno == ENOTDIR)
return (0);
-   if (pglob->gl_flags & GLOB_ERR)
-   return (GLOB_ABORTED);
-   if (pglob->gl_errfunc) {
+   if (pglob->gl_errfunc != NULL) {
if (g_Ctoc(pathbuf, buf, sizeof(buf))) {
errno = 0;
return (GLOB_NOSPACE);
@@ -724,6 +722,8 @@ glob3(Char *pathbuf, Char *pathend, Char
if (pglob->gl_errfunc(buf, errno))
return (GLOB_ABORTED);
}
+   if (pglob->gl_flags & GLOB_ERR)
+   return (GLOB_ABORTED);
return (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: r302985 - head/sys/geom/label

2016-07-18 Thread Andrey V. Elsukov
On 18.07.16 17:24, Maxim Sobolev wrote:
> Andrey, are you talking about this:
> 
> ---
> r156299 | pjd | 2006-03-04 11:41:54 -0800 (сб, 04 мар 2006) | 11 lines
> 
> We need to check if file system size is equal to provider's size, because
> sysinstall(8) still bogusly puts first partition at offset 0 instead of 16,
> so glabel/ufs will find file system on slice instead of partition.
> 
> Before sysinstall is fixed, we must keep this code, which means that we
> wont't be able to detect UFS file systems created with 'newfs -s ...'.
> 
> PS. bsdlabel(8) creates partitions properly.
> 
> MFC after:  3 days
> ---
> 
> In which case this particular change has a better chance of working
> since it's not removing this check but making it less strict. Therefore
> it might attach to a wrong provider only if first UFS slice is the only
> one slice on partition (or if the other partition is very small - less
> than 256 blocks in size). In either of those cases I don't think it
> makes much difference if we are attaching to a slice or a partition.

No, I mean r235918, that was reverted after several complains.
UFS label is a special label. It always had the same size that provider.
Now it will attach to first provider that will be tasted. It can be
gmirror, generic glabel, geli, gpart, mbr, whole disk.

https://lists.freebsd.org/pipermail/freebsd-geom/2009-April/003473.html

-- 
WBR, Andrey V. Elsukov



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r302985 - head/sys/geom/label

2016-07-18 Thread Maxim Sobolev
I think people might be worried about existing deployed systems that might
stop booting if geom label obscures the whole disk making one or more
slices unavailable via geom_label mechanism.

-Max

On Mon, Jul 18, 2016 at 10:09 AM, Devin Teske  wrote:

>
> > On Jul 18, 2016, at 7:24 AM, Maxim Sobolev  wrote:
> >
> > Andrey, are you talking about this:
> >
> > ---
> > r156299 | pjd | 2006-03-04 11:41:54 -0800 (сб, 04 мар 2006) | 11 lines
> >
> > We need to check if file system size is equal to provider's size, because
> > sysinstall(8)
>
>
> ?? sysinstall ?? in head ??
>
> --
> Devin
>
>
___
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"

svn commit: r303010 - head/lib/libc/gen

2016-07-18 Thread Andrey A. Chernov
Author: ache
Date: Mon Jul 18 18:24:31 2016
New Revision: 303010
URL: https://svnweb.freebsd.org/changeset/base/303010

Log:
  1) Add all characters from ~ expansion as protected to be not interpreted
  as pattern meta chars.
  
  2) GLOB_ERR and gl_errfunc are supposed to work only for real directories
  per POSIX, so don't act on missing or plain files, for ENOENT or ENOTDIR
  (as TODO in the code suggested).
  
  3) Remove the hack in the manpage describing how to skip ENOENT and ENOTDIR
  in gl_errfunc, it is unneeded now.
  
  4) Set errno to ENAMETOOLONG if g_Ctoc() expansion fails in g_opendir(),
  as in other places in the code which are wrappers around system functions.

Modified:
  head/lib/libc/gen/glob.3
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.3
==
--- head/lib/libc/gen/glob.3Mon Jul 18 16:58:47 2016(r303009)
+++ head/lib/libc/gen/glob.3Mon Jul 18 18:24:31 2016(r303010)
@@ -275,24 +275,10 @@ is
 .Pf non- Dv NULL ,
 .Fn glob
 calls
-.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) .
-This may be unintuitive: a pattern like
-.Ql */Makefile
-will try to
-.Xr stat 2
-.Ql foo/Makefile
-even if
-.Ql foo
-is not a directory, resulting in a
-call to
-.Fa errfunc .
-The error routine can suppress this action by testing for
-.Er ENOENT
-and
-.Er ENOTDIR ;
+.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) ,
 however, the
 .Dv GLOB_ERR
-flag will still cause an immediate
+flag will cause an immediate
 return when this happens.
 .Pp
 If

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cMon Jul 18 16:58:47 2016(r303009)
+++ head/lib/libc/gen/glob.cMon Jul 18 18:24:31 2016(r303010)
@@ -478,7 +478,7 @@ globtilde(const Char *pattern, Char *pat
return (NULL);
 
dc = wbuf;
-   for (b = patbuf; b < eb && *dc != EOS; *b++ = *dc++)
+   for (b = patbuf; b < eb && *dc != EOS; *b++ = *dc++ | M_PROTECT)
continue;
if (*dc != EOS)
return (NULL);
@@ -712,7 +712,8 @@ glob3(Char *pathbuf, Char *pathend, Char
*pathend = EOS;
 
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
-   /* TODO: don't call for ENOENT or ENOTDIR? */
+   if (errno == ENOENT || errno == ENOTDIR)
+   return (0);
if (pglob->gl_flags & GLOB_ERR)
return (GLOB_ABORTED);
if (pglob->gl_errfunc) {
@@ -937,8 +938,10 @@ g_opendir(Char *str, glob_t *pglob)
if (*str == EOS)
strcpy(buf, ".");
else {
-   if (g_Ctoc(str, buf, sizeof(buf)))
+   if (g_Ctoc(str, buf, sizeof(buf))) {
+   errno = ENAMETOOLONG;
return (NULL);
+   }
}
 
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
___
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: r302985 - head/sys/geom/label

2016-07-18 Thread Devin Teske

> On Jul 18, 2016, at 7:24 AM, Maxim Sobolev  wrote:
> 
> Andrey, are you talking about this:
> 
> ---
> r156299 | pjd | 2006-03-04 11:41:54 -0800 (сб, 04 мар 2006) | 11 lines
> 
> We need to check if file system size is equal to provider's size, because
> sysinstall(8)


?? sysinstall ?? in head ??

-- 
Devin

___
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"

svn commit: r303009 - head/sys/net

2016-07-18 Thread Alexander Motin
Author: mav
Date: Mon Jul 18 16:58:47 2016
New Revision: 303009
URL: https://svnweb.freebsd.org/changeset/base/303009

Log:
  Negotiate/disable TXCSUM_IPV6 same as TXCSUM.

Modified:
  head/sys/net/if_bridge.c

Modified: head/sys/net/if_bridge.c
==
--- head/sys/net/if_bridge.cMon Jul 18 16:39:53 2016(r303008)
+++ head/sys/net/if_bridge.cMon Jul 18 16:58:47 2016(r303009)
@@ -166,7 +166,8 @@ __FBSDID("$FreeBSD$");
 /*
  * List of capabilities to possibly mask on the member interface.
  */
-#defineBRIDGE_IFCAPS_MASK  
(IFCAP_TOE|IFCAP_TSO|IFCAP_TXCSUM)
+#defineBRIDGE_IFCAPS_MASK  
(IFCAP_TOE|IFCAP_TSO|IFCAP_TXCSUM|\
+IFCAP_TXCSUM_IPV6)
 
 /*
  * List of capabilities to strip
___
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"


svn commit: r303008 - stable/11/sys/conf

2016-07-18 Thread Dmitry Chagin
Author: dchagin
Date: Mon Jul 18 16:39:53 2016
New Revision: 303008
URL: https://svnweb.freebsd.org/changeset/base/303008

Log:
  MFC r302518, r302626:
  
  Add linux_mmap.c to the appropriate conf/files.
  
  Approved by:  re (gjb)

Modified:
  stable/11/sys/conf/files.amd64
  stable/11/sys/conf/files.i386
  stable/11/sys/conf/files.pc98
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/conf/files.amd64
==
--- stable/11/sys/conf/files.amd64  Mon Jul 18 16:38:06 2016
(r303007)
+++ stable/11/sys/conf/files.amd64  Mon Jul 18 16:39:53 2016
(r303008)
@@ -530,6 +530,7 @@ compat/linux/linux_ioctl.c  optionalcomp
 compat/linux/linux_ipc.c   optionalcompat_linux32
 compat/linux/linux_mib.c   optionalcompat_linux32
 compat/linux/linux_misc.c  optionalcompat_linux32
+compat/linux/linux_mmap.c  optionalcompat_linux32
 compat/linux/linux_signal.coptionalcompat_linux32
 compat/linux/linux_socket.coptionalcompat_linux32
 compat/linux/linux_stats.c optionalcompat_linux32

Modified: stable/11/sys/conf/files.i386
==
--- stable/11/sys/conf/files.i386   Mon Jul 18 16:38:06 2016
(r303007)
+++ stable/11/sys/conf/files.i386   Mon Jul 18 16:39:53 2016
(r303008)
@@ -96,6 +96,7 @@ compat/linux/linux_ioctl.coptional comp
 compat/linux/linux_ipc.c   optional compat_linux
 compat/linux/linux_mib.c   optional compat_linux
 compat/linux/linux_misc.c  optional compat_linux
+compat/linux/linux_mmap.c  optional compat_linux
 compat/linux/linux_signal.coptional compat_linux
 compat/linux/linux_socket.coptional compat_linux
 compat/linux/linux_stats.c optional compat_linux

Modified: stable/11/sys/conf/files.pc98
==
--- stable/11/sys/conf/files.pc98   Mon Jul 18 16:38:06 2016
(r303007)
+++ stable/11/sys/conf/files.pc98   Mon Jul 18 16:39:53 2016
(r303008)
@@ -63,6 +63,7 @@ compat/linux/linux_ioctl.coptional comp
 compat/linux/linux_ipc.c   optional compat_linux
 compat/linux/linux_mib.c   optional compat_linux
 compat/linux/linux_misc.c  optional compat_linux
+compat/linux/linux_mmap.c  optional compat_linux
 compat/linux/linux_signal.coptional compat_linux
 compat/linux/linux_socket.coptional compat_linux
 compat/linux/linux_stats.c optional compat_linux
___
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"


svn commit: r303007 - in stable/11/sys: amd64/linux amd64/linux32 compat/linux i386/linux modules/linux modules/linux_common

2016-07-18 Thread Dmitry Chagin
Author: dchagin
Date: Mon Jul 18 16:38:06 2016
New Revision: 303007
URL: https://svnweb.freebsd.org/changeset/base/303007

Log:
  MFC r302517:
  
  Fix a copy/paste bug introduced during X86_64 Linuxulator work.
  FreeBSD support NX bit on X86_64 processors out of the box, for i386 emulation
  use READ_IMPLIES_EXEC flag, introduced in r302515.
  
  While here move common part of mmap() and mprotect() code to the files in 
compat/linux
  to reduce code dupcliation between Linuxulator's
  
  Approved by:  re (gjb)

Added:
  stable/11/sys/compat/linux/linux_mmap.c
 - copied unchanged from r302517, head/sys/compat/linux/linux_mmap.c
  stable/11/sys/compat/linux/linux_mmap.h
 - copied unchanged from r302517, head/sys/compat/linux/linux_mmap.h
Modified:
  stable/11/sys/amd64/linux/linux.h
  stable/11/sys/amd64/linux/linux_machdep.c
  stable/11/sys/amd64/linux32/linux.h
  stable/11/sys/amd64/linux32/linux32_machdep.c
  stable/11/sys/i386/linux/linux.h
  stable/11/sys/i386/linux/linux_machdep.c
  stable/11/sys/modules/linux/Makefile
  stable/11/sys/modules/linux_common/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/linux/linux.h
==
--- stable/11/sys/amd64/linux/linux.h   Mon Jul 18 16:35:44 2016
(r303006)
+++ stable/11/sys/amd64/linux/linux.h   Mon Jul 18 16:38:06 2016
(r303007)
@@ -139,13 +139,6 @@ struct l_rlimit {
l_ulong rlim_max;
 };
 
-/* mmap options */
-#defineLINUX_MAP_SHARED0x0001
-#defineLINUX_MAP_PRIVATE   0x0002
-#defineLINUX_MAP_FIXED 0x0010
-#defineLINUX_MAP_ANON  0x0020
-#defineLINUX_MAP_GROWSDOWN 0x0100
-
 /*
  * stat family of syscalls
  */

Modified: stable/11/sys/amd64/linux/linux_machdep.c
==
--- stable/11/sys/amd64/linux/linux_machdep.c   Mon Jul 18 16:35:44 2016
(r303006)
+++ stable/11/sys/amd64/linux/linux_machdep.c   Mon Jul 18 16:38:06 2016
(r303007)
@@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -122,181 +123,19 @@ linux_set_upcall_kse(struct thread *td, 
return (0);
 }
 
-#define STACK_SIZE  (2 * 1024 * 1024)
-#define GUARD_SIZE  (4 * PAGE_SIZE)
-
 int
 linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
 {
-   struct proc *p = td->td_proc;
-   struct mmap_args /* {
-   caddr_t addr;
-   size_t len;
-   int prot;
-   int flags;
-   int fd;
-   long pad;
-   off_t pos;
-   } */ bsd_args;
-   int error;
-   struct file *fp;
-   cap_rights_t rights;
-
-   LINUX_CTR6(mmap2, "0x%lx, %ld, %ld, 0x%08lx, %ld, 0x%lx",
-   args->addr, args->len, args->prot,
-   args->flags, args->fd, args->pgoff);
-
-   error = 0;
-   bsd_args.flags = 0;
-   fp = NULL;
-
-   /*
-* Linux mmap(2):
-* You must specify exactly one of MAP_SHARED and MAP_PRIVATE
-*/
-   if (! ((args->flags & LINUX_MAP_SHARED) ^
-   (args->flags & LINUX_MAP_PRIVATE)))
-   return (EINVAL);
-
-   if (args->flags & LINUX_MAP_SHARED)
-   bsd_args.flags |= MAP_SHARED;
-   if (args->flags & LINUX_MAP_PRIVATE)
-   bsd_args.flags |= MAP_PRIVATE;
-   if (args->flags & LINUX_MAP_FIXED)
-   bsd_args.flags |= MAP_FIXED;
-   if (args->flags & LINUX_MAP_ANON)
-   bsd_args.flags |= MAP_ANON;
-   else
-   bsd_args.flags |= MAP_NOSYNC;
-   if (args->flags & LINUX_MAP_GROWSDOWN)
-   bsd_args.flags |= MAP_STACK;
-
-   /*
-* PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC
-* on Linux/i386. We do this to ensure maximum compatibility.
-* Linux/ia64 does the same in i386 emulation mode.
-*/
-   bsd_args.prot = args->prot;
-   if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
-   bsd_args.prot |= PROT_READ | PROT_EXEC;
-
-   /* Linux does not check file descriptor when MAP_ANONYMOUS is set. */
-   bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : args->fd;
-   if (bsd_args.fd != -1) {
-   /*
-* Linux follows Solaris mmap(2) description:
-* The file descriptor fildes is opened with
-* read permission, regardless of the
-* protection options specified.
-*/
-
-   error = fget(td, bsd_args.fd,
-   cap_rights_init(, CAP_MMAP), );
-   if (error != 0 )
-   return (error);
-   if (fp->f_type != DTYPE_VNODE) {
-   fdrop(fp, td);
-   return (EINVAL);
-   }
-
- 

svn commit: r303006 - in stable/11/sys: amd64/linux amd64/linux32 i386/linux

2016-07-18 Thread Dmitry Chagin
Author: dchagin
Date: Mon Jul 18 16:35:44 2016
New Revision: 303006
URL: https://svnweb.freebsd.org/changeset/base/303006

Log:
  MFC r302516:
  
  Regen for r302515 (Linux personality).
  
  Approved by:  re (gjb)

Modified:
  stable/11/sys/amd64/linux/linux_proto.h
  stable/11/sys/amd64/linux/linux_syscall.h
  stable/11/sys/amd64/linux/linux_syscalls.c
  stable/11/sys/amd64/linux/linux_sysent.c
  stable/11/sys/amd64/linux/linux_systrace_args.c
  stable/11/sys/amd64/linux32/linux32_proto.h
  stable/11/sys/amd64/linux32/linux32_syscall.h
  stable/11/sys/amd64/linux32/linux32_syscalls.c
  stable/11/sys/amd64/linux32/linux32_sysent.c
  stable/11/sys/amd64/linux32/linux32_systrace_args.c
  stable/11/sys/i386/linux/linux_proto.h
  stable/11/sys/i386/linux/linux_syscall.h
  stable/11/sys/i386/linux/linux_syscalls.c
  stable/11/sys/i386/linux/linux_sysent.c
  stable/11/sys/i386/linux/linux_systrace_args.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/linux/linux_proto.h
==
--- stable/11/sys/amd64/linux/linux_proto.h Mon Jul 18 16:34:11 2016
(r303005)
+++ stable/11/sys/amd64/linux/linux_proto.h Mon Jul 18 16:35:44 2016
(r303006)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux/syscalls.master 300359 
2016-05-21 08:01:14Z dchagin 
+ * created from FreeBSD: head/sys/amd64/linux/syscalls.master 302515 
2016-07-10 08:15:50Z dchagin 
  */
 
 #ifndef _LINUX_SYSPROTO_H_
@@ -499,7 +499,7 @@ struct linux_mknod_args {
char dev_l_[PADL_(l_dev_t)]; l_dev_t dev; char dev_r_[PADR_(l_dev_t)];
 };
 struct linux_personality_args {
-   char per_l_[PADL_(l_ulong)]; l_ulong per; char per_r_[PADR_(l_ulong)];
+   char per_l_[PADL_(l_uint)]; l_uint per; char per_r_[PADR_(l_uint)];
 };
 struct linux_ustat_args {
char dev_l_[PADL_(l_dev_t)]; l_dev_t dev; char dev_r_[PADR_(l_dev_t)];
@@ -1397,6 +1397,13 @@ int  linux_finit_module(struct thread *, 
 
 #endif /* COMPAT_FREEBSD7 */
 
+
+#ifdef COMPAT_FREEBSD10
+
+#definenosys   linux_nosys
+
+#endif /* COMPAT_FREEBSD10 */
+
 #defineLINUX_SYS_AUE_linux_openAUE_OPEN_RWTC
 #defineLINUX_SYS_AUE_linux_newstat AUE_STAT
 #defineLINUX_SYS_AUE_linux_newfstatAUE_FSTAT

Modified: stable/11/sys/amd64/linux/linux_syscall.h
==
--- stable/11/sys/amd64/linux/linux_syscall.h   Mon Jul 18 16:34:11 2016
(r303005)
+++ stable/11/sys/amd64/linux/linux_syscall.h   Mon Jul 18 16:35:44 2016
(r303006)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux/syscalls.master 300359 
2016-05-21 08:01:14Z dchagin 
+ * created from FreeBSD: head/sys/amd64/linux/syscalls.master 302515 
2016-07-10 08:15:50Z dchagin 
  */
 
 #defineLINUX_SYS_read  0

Modified: stable/11/sys/amd64/linux/linux_syscalls.c
==
--- stable/11/sys/amd64/linux/linux_syscalls.c  Mon Jul 18 16:34:11 2016
(r303005)
+++ stable/11/sys/amd64/linux/linux_syscalls.c  Mon Jul 18 16:35:44 2016
(r303006)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux/syscalls.master 300359 
2016-05-21 08:01:14Z dchagin 
+ * created from FreeBSD: head/sys/amd64/linux/syscalls.master 302515 
2016-07-10 08:15:50Z dchagin 
  */
 
 const char *linux_syscallnames[] = {

Modified: stable/11/sys/amd64/linux/linux_sysent.c
==
--- stable/11/sys/amd64/linux/linux_sysent.cMon Jul 18 16:34:11 2016
(r303005)
+++ stable/11/sys/amd64/linux/linux_sysent.cMon Jul 18 16:35:44 2016
(r303006)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux/syscalls.master 300359 
2016-05-21 08:01:14Z dchagin 
+ * created from FreeBSD: head/sys/amd64/linux/syscalls.master 302515 
2016-07-10 08:15:50Z dchagin 
  */
 
 #include 

Modified: stable/11/sys/amd64/linux/linux_systrace_args.c
==
--- stable/11/sys/amd64/linux/linux_systrace_args.c Mon Jul 18 16:34:11 
2016(r303005)
+++ stable/11/sys/amd64/linux/linux_systrace_args.c Mon Jul 18 16:35:44 
2016(r303006)
@@ -1120,7 +1120,7 @@ systrace_args(int sysnum, void *params, 
/* linux_personality */
case 135: {
struct linux_personality_args *p = params;
-   iarg[0] = p->per; /* l_ulong */
+   iarg[0] = p->per; /* l_uint */
*n_args = 1;
break;

svn commit: r303005 - in stable/11/sys: amd64/linux amd64/linux32 compat/linux i386/linux

2016-07-18 Thread Dmitry Chagin
Author: dchagin
Date: Mon Jul 18 16:34:11 2016
New Revision: 303005
URL: https://svnweb.freebsd.org/changeset/base/303005

Log:
  MFC r302515:
  
  Implement Linux personality() system call mainly due to READ_IMPLIES_EXEC 
flag.
  In Linux if this flag is set, PROT_READ implies PROT_EXEC for mmap().
  Linux/i386 set this flag automatically if the binary requires executable 
stack.
  
  READ_IMPLIES_EXEC flag will be used in the next Linux mmap() commit.
  
  Approved by:  re (gjb)

Added:
  stable/11/sys/compat/linux/linux_persona.h
 - copied unchanged from r302515, head/sys/compat/linux/linux_persona.h
Modified:
  stable/11/sys/amd64/linux/syscalls.master
  stable/11/sys/amd64/linux32/syscalls.master
  stable/11/sys/compat/linux/linux_emul.c
  stable/11/sys/compat/linux/linux_emul.h
  stable/11/sys/compat/linux/linux_misc.c
  stable/11/sys/i386/linux/syscalls.master
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/linux/syscalls.master
==
--- stable/11/sys/amd64/linux/syscalls.master   Mon Jul 18 16:06:21 2016
(r303004)
+++ stable/11/sys/amd64/linux/syscalls.master   Mon Jul 18 16:34:11 2016
(r303005)
@@ -270,7 +270,7 @@
 133AUE_MKNOD   STD { int linux_mknod(char *path, l_int mode, \
l_dev_t dev); }
 134AUE_USELIB  UNIMPL  uselib
-135AUE_PERSONALITY STD { int linux_personality(l_ulong per); }
+135AUE_PERSONALITY STD { int linux_personality(l_uint per); }
 136AUE_NULLSTD { int linux_ustat(l_dev_t dev, \
struct l_ustat *ubuf); }
 137AUE_STATFS  STD { int linux_statfs(char *path, \

Modified: stable/11/sys/amd64/linux32/syscalls.master
==
--- stable/11/sys/amd64/linux32/syscalls.master Mon Jul 18 16:06:21 2016
(r303004)
+++ stable/11/sys/amd64/linux32/syscalls.master Mon Jul 18 16:34:11 2016
(r303005)
@@ -238,7 +238,7 @@
 134AUE_BDFLUSH STD { int linux_bdflush(void); }
 135AUE_NULLSTD { int linux_sysfs(l_int option, \
l_ulong arg1, l_ulong arg2); }
-136AUE_PERSONALITY STD { int linux_personality(l_ulong per); }
+136AUE_PERSONALITY STD { int linux_personality(l_uint per); }
 137AUE_NULLUNIMPL  afs_syscall
 138AUE_SETFSUIDSTD { int linux_setfsuid16(l_uid16_t uid); }
 139AUE_SETFSGIDSTD { int linux_setfsgid16(l_gid16_t gid); }

Modified: stable/11/sys/compat/linux/linux_emul.c
==
--- stable/11/sys/compat/linux/linux_emul.c Mon Jul 18 16:06:21 2016
(r303004)
+++ stable/11/sys/compat/linux/linux_emul.c Mon Jul 18 16:34:11 2016
(r303005)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 
 
@@ -127,7 +128,7 @@ linux_proc_init(struct thread *td, struc
 /* epoll should be destroyed in a case of exec. */
pem = pem_find(p);
KASSERT(pem != NULL, ("proc_exit: proc emuldata not found.\n"));
-
+   pem->persona = 0;
if (pem->epoll != NULL) {
emd = pem->epoll;
pem->epoll = NULL;
@@ -220,6 +221,9 @@ linux_proc_exec(void *arg __unused, stru
 {
struct thread *td = curthread;
struct thread *othertd;
+#if defined(__amd64__)
+   struct linux_pemuldata *pem;
+#endif
 
/*
 * In a case of execing from linux binary properly detach
@@ -243,6 +247,17 @@ linux_proc_exec(void *arg __unused, stru
linux_proc_init(td, NULL, 0);
else
linux_proc_init(td, td, 0);
+#if defined(__amd64__)
+   /*
+* An IA32 executable which has executable stack will have the
+* READ_IMPLIES_EXEC personality flag set automatically.
+*/
+   if (SV_PROC_FLAG(td->td_proc, SV_ILP32) &&
+   imgp->stack_prot & VM_PROT_EXECUTE) {
+   pem = pem_find(p);
+   pem->persona |= LINUX_READ_IMPLIES_EXEC;
+   }
+#endif
}
 }
 

Modified: stable/11/sys/compat/linux/linux_emul.h
==
--- stable/11/sys/compat/linux/linux_emul.h Mon Jul 18 16:06:21 2016
(r303004)
+++ stable/11/sys/compat/linux/linux_emul.h Mon Jul 18 16:34:11 2016
(r303005)
@@ -67,6 +67,7 @@ struct linux_pemuldata {
uint32_tflags;  /* process emuldata flags */
struct sx   pem_sx; /* lock for this struct */
void*epoll; /* epoll data */
+   uint32_tpersona;/* process 

Re: svn commit: r302998 - head/sys/kern

2016-07-18 Thread Randall Stewart via svn-src-all
I have worked out a fix of this in Netflix code base (I have the same code 
running there). I
will get that tested tonight I will get the fixes in to restore the behavior.

I will setup a phabricator shortly.. most likely I will update the one I already
have on the one problem your earlier patch did not fix.

R
> On Jul 18, 2016, at 5:44 PM, Randall Stewart  wrote:
> 
> Gleb:
> 
> This now leaks TCP-PCB’s since you have broken the return codes with all your
> fixes that used to be in here.
> 
> It was
> 
> return 1 — You stopped the callout
> return 0 — The callout could not be stopped
> return -1 — The callout was not running.
> 
> The LLRef code that was crashing in in.c depended on this to know to free
> the memory.. i.e. if was > 0 then they needed to free the memory.
> 
> TCP depends on a return 0 to indicate the async-drain function will be called 
> back and
> thus increments a refcnt and waits for the callback.
> 
> You now return 0 when no timer was active.. which makes the stack then wait
> for the not forth coming async-drain call.
> 
> R
>> On Jul 18, 2016, at 11:29 AM, Gleb Smirnoff  wrote:
>> 
>> Author: glebius
>> Date: Mon Jul 18 09:29:08 2016
>> New Revision: 302998
>> URL: https://svnweb.freebsd.org/changeset/base/302998
>> 
>> Log:
>> Revert the last commit. It must get more review and testing first.
>> 
>> Modified:
>> head/sys/kern/kern_timeout.c
>> 
>> Modified: head/sys/kern/kern_timeout.c
>> ==
>> --- head/sys/kern/kern_timeout.c Mon Jul 18 09:26:06 2016
>> (r302997)
>> +++ head/sys/kern/kern_timeout.c Mon Jul 18 09:29:08 2016
>> (r302998)
>> @@ -1381,7 +1381,7 @@ again:
>>  CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p",
>>  c, c->c_func, c->c_arg);
>>  CC_UNLOCK(cc);
>> -return (-1);
>> +return (0);
>>  }
>> 
>>  c->c_iflags &= ~CALLOUT_PENDING;
>> 
> 
> 
> Randall Stewart
> r...@netflix.com
> 803-317-4952
> 
> 
> 
> 
> 


Randall Stewart
r...@netflix.com
803-317-4952





___
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"

svn commit: r303004 - head/lib/libc/gen

2016-07-18 Thread Andrey A. Chernov
Author: ache
Date: Mon Jul 18 16:06:21 2016
New Revision: 303004
URL: https://svnweb.freebsd.org/changeset/base/303004

Log:
  1) POSIX defines well when GLOB_ABORTED can be returned (only for directory
  open/read errors and with GLOB_ERR and gl_errfunc processing), so we can't
  blindly return it on any MAXPATHLEN overflow. Even our manpage disagrees
  with such GLOB_ABORTED usage. Use GLOB_NOSPACE for that now with errno is
  set to 0 as for limits.
  
  2) Return GLOB_NOSPACE when valid ~ expansion can't happens due to
  MAXPATHLEN overflow too.
  
  3) POSIX (and our manpage) says, if GLOB_ERR is set, GLOB_ABORTED should
  be returned immediatelly, without using gl_errfunc. Implement it now.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cMon Jul 18 15:50:54 2016(r303003)
+++ head/lib/libc/gen/glob.cMon Jul 18 16:06:21 2016(r303004)
@@ -421,7 +421,7 @@ globtilde(const Char *pattern, Char *pat
continue;
 
if (*p != EOS && *p != SLASH)
-   return (pattern);
+   return (NULL);
 
*b = EOS;
h = NULL;
@@ -446,8 +446,9 @@ globtilde(const Char *pattern, Char *pat
/*
 * Expand a ~user
 */
-   if (g_Ctoc(patbuf, (char *)wbuf, sizeof(wbuf)) ||
-   (pwd = getpwnam((char *)wbuf)) == NULL)
+   if (g_Ctoc(patbuf, (char *)wbuf, sizeof(wbuf)))
+   return (NULL);
+   if ((pwd = getpwnam((char *)wbuf)) == NULL)
return (pattern);
else
h = pwd->pw_dir;
@@ -474,13 +475,13 @@ globtilde(const Char *pattern, Char *pat
sc += clen;
}
if (too_long)
-   return (pattern);
+   return (NULL);
 
dc = wbuf;
for (b = patbuf; b < eb && *dc != EOS; *b++ = *dc++)
continue;
if (*dc != EOS)
-   return (pattern);
+   return (NULL);
 
/* Append the rest of the pattern */
if (*p != EOS) {
@@ -492,7 +493,7 @@ globtilde(const Char *pattern, Char *pat
}
}
if (too_long)
-   return (pattern);
+   return (NULL);
} else
*b = EOS;
 
@@ -515,6 +516,10 @@ glob0(const Char *pattern, glob_t *pglob
Char *bufnext, c, patbuf[MAXPATHLEN];
 
qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
+   if (qpatnext == NULL) {
+   errno = 0;
+   return (GLOB_NOSPACE);
+   }
oldpathc = pglob->gl_pathc;
bufnext = patbuf;
 
@@ -638,7 +643,7 @@ glob2(Char *pathbuf, Char *pathend, Char
limit->l_stat_cnt++ >= GLOB_LIMIT_STAT) {
errno = 0;
if (pathend + 1 > pathend_last)
-   return (GLOB_ABORTED);
+   return (GLOB_NOSPACE);
*pathend++ = SEP;
*pathend = EOS;
return (GLOB_NOSPACE);
@@ -648,8 +653,10 @@ glob2(Char *pathbuf, Char *pathend, Char
|| (S_ISLNK(sb.st_mode) &&
(g_stat(pathbuf, , pglob) == 0) &&
S_ISDIR(sb.st_mode {
-   if (pathend + 1 > pathend_last)
-   return (GLOB_ABORTED);
+   if (pathend + 1 > pathend_last) {
+   errno = 0;
+   return (GLOB_NOSPACE);
+   }
*pathend++ = SEP;
*pathend = EOS;
}
@@ -663,8 +670,10 @@ glob2(Char *pathbuf, Char *pathend, Char
while (*p != EOS && *p != SEP) {
if (ismeta(*p))
anymeta = 1;
-   if (q + 1 > pathend_last)
-   return (GLOB_ABORTED);
+   if (q + 1 > pathend_last) {
+   errno = 0;
+   return (GLOB_NOSPACE);
+   }
*q++ = *p++;
}
 
@@ -672,8 +681,10 @@ glob2(Char *pathbuf, Char *pathend, Char
pathend = q;
pattern = p;
while (*pattern == SEP) {
-   if (pathend + 1 > pathend_last)
-   return (GLOB_ABORTED);
+   if (pathend + 1 > pathend_last) {
+   

svn commit: r303003 - head/release

2016-07-18 Thread Glen Barber
Author: gjb
Date: Mon Jul 18 15:50:54 2016
New Revision: 303003
URL: https://svnweb.freebsd.org/changeset/base/303003

Log:
  Make sure we clean up the rdoc and reldoc directories if NODOC
  is not set.
  
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation

Modified:
  head/release/Makefile

Modified: head/release/Makefile
==
--- head/release/Makefile   Mon Jul 18 15:14:23 2016(r303002)
+++ head/release/Makefile   Mon Jul 18 15:50:54 2016(r303003)
@@ -119,6 +119,9 @@ CLEANFILES+=${I}.xz
 CLEANFILES+=   pkg-stage
 .endif
 CLEANDIRS= dist ftp disc1 bootonly dvd
+.if !defined(NODOC)
+CLEANDIRS+=reldoc rdoc
+.endif
 beforeclean:
chflags -R noschg .
 .include 
___
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: r302998 - head/sys/kern

2016-07-18 Thread Randall Stewart via svn-src-all
Gleb:

This now leaks TCP-PCB’s since you have broken the return codes with all your
fixes that used to be in here.

It was

return 1 — You stopped the callout
return 0 — The callout could not be stopped
return -1 — The callout was not running.

The LLRef code that was crashing in in.c depended on this to know to free
the memory.. i.e. if was > 0 then they needed to free the memory.

TCP depends on a return 0 to indicate the async-drain function will be called 
back and
thus increments a refcnt and waits for the callback.

You now return 0 when no timer was active.. which makes the stack then wait
for the not forth coming async-drain call.

R
> On Jul 18, 2016, at 11:29 AM, Gleb Smirnoff  wrote:
> 
> Author: glebius
> Date: Mon Jul 18 09:29:08 2016
> New Revision: 302998
> URL: https://svnweb.freebsd.org/changeset/base/302998
> 
> Log:
>  Revert the last commit. It must get more review and testing first.
> 
> Modified:
>  head/sys/kern/kern_timeout.c
> 
> Modified: head/sys/kern/kern_timeout.c
> ==
> --- head/sys/kern/kern_timeout.c  Mon Jul 18 09:26:06 2016
> (r302997)
> +++ head/sys/kern/kern_timeout.c  Mon Jul 18 09:29:08 2016
> (r302998)
> @@ -1381,7 +1381,7 @@ again:
>   CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p",
>   c, c->c_func, c->c_arg);
>   CC_UNLOCK(cc);
> - return (-1);
> + return (0);
>   }
> 
>   c->c_iflags &= ~CALLOUT_PENDING;
> 


Randall Stewart
r...@netflix.com
803-317-4952





___
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"

svn commit: r303002 - in head: sys/kern sys/sys usr.bin/gcore

2016-07-18 Thread John Baldwin
Author: jhb
Date: Mon Jul 18 15:14:23 2016
New Revision: 303002
URL: https://svnweb.freebsd.org/changeset/base/303002

Log:
  Include process IDs in core dumps.
  
  When threads were added to the kernel, the pr_pid member of the
  NT_PRSTATUS note was repurposed to store LWP IDs instead of process
  IDs.  However, the process ID was no longer recorded in core dumps.
  This change adds a pr_pid field to prpsinfo (NT_PRSINFO).  Rather than
  bumping the prpsinfo version number, note parsers can use the note's
  payload size to determine if pr_pid is present.
  
  Reviewed by:  kib, emaste (older version)
  MFC after:2 months
  Differential Revision:https://reviews.freebsd.org/D7117

Modified:
  head/sys/kern/imgact_elf.c
  head/sys/sys/procfs.h
  head/usr.bin/gcore/elfcore.c

Modified: head/sys/kern/imgact_elf.c
==
--- head/sys/kern/imgact_elf.c  Mon Jul 18 14:53:55 2016(r303001)
+++ head/sys/kern/imgact_elf.c  Mon Jul 18 15:14:23 2016(r303002)
@@ -1874,6 +1874,7 @@ __elfN(note_prpsinfo)(void *arg, struct 
*cp = ' ';
}
}
+   psinfo->pr_pid = p->p_pid;
sbuf_bcat(sb, psinfo, sizeof(*psinfo));
free(psinfo, M_TEMP);
}

Modified: head/sys/sys/procfs.h
==
--- head/sys/sys/procfs.h   Mon Jul 18 14:53:55 2016(r303001)
+++ head/sys/sys/procfs.h   Mon Jul 18 15:14:23 2016(r303002)
@@ -49,7 +49,10 @@ typedef struct fpreg fpregset_t;
 
 /*
  * The parenthsized numbers like (1) indicate the minimum version number
- * for which each element exists in the structure.
+ * for which each element exists in the structure.  The version number is
+ * not bumped when adding new fields to the end, only if the meaning of
+ * an existing field changes.  Additional fields are annotated as (1a),
+ * (1b), etc. to indicate the groupings of additions.
  */
 
 #define PRSTATUS_VERSION   1   /* Current version of prstatus_t */
@@ -61,7 +64,7 @@ typedef struct prstatus {
 size_t pr_fpregsetsz;  /* sizeof(fpregset_t) (1) */
 intpr_osreldate;   /* Kernel version (1) */
 intpr_cursig;  /* Current signal (1) */
-pid_t  pr_pid; /* Process ID (1) */
+pid_t  pr_pid; /* LWP (Thread) ID (1) */
 gregset_t  pr_reg; /* General purpose registers (1) */
 } prstatus_t;
 
@@ -78,6 +81,7 @@ typedef struct prpsinfo {
 size_t pr_psinfosz;/* sizeof(prpsinfo_t) (1) */
 char   pr_fname[PRFNAMESZ+1];  /* Command name, null terminated (1) */
 char   pr_psargs[PRARGSZ+1];   /* Arguments, null terminated (1) */
+pid_t  pr_pid; /* Process ID (1a) */
 } prpsinfo_t;
 
 typedef struct thrmisc {
@@ -104,6 +108,7 @@ typedef struct prpsinfo32 {
uint32_t pr_psinfosz;
charpr_fname[PRFNAMESZ+1];
charpr_psargs[PRARGSZ+1];
+   int32_t pr_pid;
 } prpsinfo32_t;
 
 struct thrmisc32 {

Modified: head/usr.bin/gcore/elfcore.c
==
--- head/usr.bin/gcore/elfcore.cMon Jul 18 14:53:55 2016
(r303001)
+++ head/usr.bin/gcore/elfcore.cMon Jul 18 15:14:23 2016
(r303002)
@@ -586,6 +586,7 @@ elf_note_prpsinfo(void *arg, size_t *siz
} else
strlcpy(psinfo->pr_psargs, kip.ki_comm,
sizeof(psinfo->pr_psargs));
+   psinfo->pr_pid = pid;
 
*sizep = sizeof(*psinfo);
return (psinfo);
___
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"


svn commit: r303001 - in head: lib/libc/sys sys/kern sys/sys tests/sys/kern

2016-07-18 Thread John Baldwin
Author: jhb
Date: Mon Jul 18 14:53:55 2016
New Revision: 303001
URL: https://svnweb.freebsd.org/changeset/base/303001

Log:
  Add PTRACE_VFORK to trace vfork events.
  
  First, PL_FLAG_FORKED events now also set a PL_FLAG_VFORKED flag when
  the new child was created via vfork() rather than fork().  Second, a
  new PL_FLAG_VFORK_DONE event can now be enabled via the PTRACE_VFORK
  event mask.  This new stop is reported after the vfork parent resumes
  due to the child calling exit or exec.  Debuggers can use this stop to
  reinsert breakpoints in the vfork parent process before it resumes.
  
  Reviewed by:  kib
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D7045

Modified:
  head/lib/libc/sys/ptrace.2
  head/sys/kern/kern_fork.c
  head/sys/kern/subr_syscall.c
  head/sys/kern/sys_process.c
  head/sys/sys/proc.h
  head/sys/sys/ptrace.h
  head/tests/sys/kern/ptrace_test.c

Modified: head/lib/libc/sys/ptrace.2
==
--- head/lib/libc/sys/ptrace.2  Mon Jul 18 14:40:13 2016(r303000)
+++ head/lib/libc/sys/ptrace.2  Mon Jul 18 14:53:55 2016(r303001)
@@ -2,7 +2,7 @@
 .\"$NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $
 .\"
 .\" This file is in the public domain.
-.Dd July 15, 2016
+.Dd July 18, 2016
 .Dt PTRACE 2
 .Os
 .Sh NAME
@@ -141,6 +141,11 @@ The process ID of the new child process 
 .Va pl_child_pid
 member of
 .Vt "struct ptrace_lwpinfo" .
+If the new child process was created via
+.Xr vfork 2 ,
+the traced process's stop will also include the
+.Dv PL_FLAG_VFORKED
+flag.
 Note that new child processes will be attached with the default
 tracing event mask;
 they do not inherit the event mask of the traced process.
@@ -163,6 +168,33 @@ Note that new processes do not report an
 initial thread,
 and exiting processes do not report an event for the termination of the
 last thread.
+.It Dv PTRACE_VFORK
+Report a stop event when a parent process resumes after a
+.Xr vfork 2 .
+.Pp
+When a thread in the traced process creates a new child process via
+.Xr vfork 2 ,
+the stop that reports
+.Dv PL_FLAG_FORKED
+and
+.Dv PL_FLAG_SCX
+occurs just after the child process is created,
+but before the thread waits for the child process to stop sharing process
+memory.
+If a debugger is not tracing the new child process,
+it must ensure that no breakpoints are enabled in the shared process
+memory before detaching from the new child process.
+This means that no breakpoints are enabled in the parent process either.
+.Pp
+The
+.Dv PTRACE_VFORK
+flag enables a new stop that indicates when the new child process stops
+sharing the process memory of the parent process.
+A debugger can reinsert breakpoints in the parent process and resume it
+in response to this event.
+This event is indicated by setting the
+.Dv PL_FLAG_VFORK_DONE
+flag.
 .El
 .Pp
 The default tracing event mask when attaching to a process via
@@ -491,6 +523,16 @@ is enabled.
 Note that this event is not reported when the last LWP in a process exits.
 The termination of the last thread is reported via a normal process exit
 event.
+.It PL_FLAG_VFORKED
+Indicates that the thread is returning from a call to
+.Xr vfork 2
+that created a new child process.
+This flag is set in addition to
+.Dv PL_FLAG_FORKED .
+.It PL_FLAG_VFORK_DONE
+Indicates that the thread has resumed after a child process created via
+.Xr vfork 2
+has stopped sharing its address space with the traced process.
 .El
 .It pl_sigmask
 The current signal mask of the LWP

Modified: head/sys/kern/kern_fork.c
==
--- head/sys/kern/kern_fork.c   Mon Jul 18 14:40:13 2016(r303000)
+++ head/sys/kern/kern_fork.c   Mon Jul 18 14:53:55 2016(r303001)
@@ -735,6 +735,7 @@ do_fork(struct thread *td, struct fork_r
if (fr->fr_flags & RFPPWAIT) {
td->td_pflags |= TDP_RFPPWAIT;
td->td_rfppwait_p = p2;
+   td->td_dbgflags |= TDB_VFORK;
}
PROC_UNLOCK(p2);
 

Modified: head/sys/kern/subr_syscall.c
==
--- head/sys/kern/subr_syscall.cMon Jul 18 14:40:13 2016
(r303000)
+++ head/sys/kern/subr_syscall.cMon Jul 18 14:53:55 2016
(r303001)
@@ -242,5 +242,13 @@ again:
cv_timedwait(>p_pwait, >p_mtx, hz);
}
PROC_UNLOCK(p2);
+
+   if (td->td_dbgflags & TDB_VFORK) {
+   PROC_LOCK(p);
+   if (p->p_ptevents & PTRACE_VFORK)
+   ptracestop(td, SIGTRAP);
+   td->td_dbgflags &= ~TDB_VFORK;
+   PROC_UNLOCK(p);
+   }
}
 }

Modified: head/sys/kern/sys_process.c
==
--- 

svn commit: r303000 - head/sys/dev/vmware/vmxnet3

2016-07-18 Thread Alexander Motin
Author: mav
Date: Mon Jul 18 14:40:13 2016
New Revision: 303000
URL: https://svnweb.freebsd.org/changeset/base/303000

Log:
  Update if_hwassist when interface options are changed.
  
  In particular for me this fixes checksum problem when if_bridge attached
  to the interface requests TXCSUM to be disabled, but effectively ignored.
  
  MFC after:3 days
  Sponsored by: iXsystems, Inc.

Modified:
  head/sys/dev/vmware/vmxnet3/if_vmx.c

Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c
==
--- head/sys/dev/vmware/vmxnet3/if_vmx.cMon Jul 18 10:53:47 2016
(r302999)
+++ head/sys/dev/vmware/vmxnet3/if_vmx.cMon Jul 18 14:40:13 2016
(r303000)
@@ -130,6 +130,7 @@ static int  vmxnet3_alloc_queue_data(stru
 static voidvmxnet3_free_queue_data(struct vmxnet3_softc *);
 static int vmxnet3_alloc_mcast_table(struct vmxnet3_softc *);
 static voidvmxnet3_init_shared_data(struct vmxnet3_softc *);
+static voidvmxnet3_init_hwassist(struct vmxnet3_softc *);
 static voidvmxnet3_reinit_interface(struct vmxnet3_softc *);
 static voidvmxnet3_reinit_rss_shared_data(struct vmxnet3_softc *);
 static voidvmxnet3_reinit_shared_data(struct vmxnet3_softc *);
@@ -1583,6 +1584,24 @@ vmxnet3_init_shared_data(struct vmxnet3_
 }
 
 static void
+vmxnet3_init_hwassist(struct vmxnet3_softc *sc)
+{
+   struct ifnet *ifp = sc->vmx_ifp;
+   uint64_t hwassist;
+
+   hwassist = 0;
+   if (ifp->if_capenable & IFCAP_TXCSUM)
+   hwassist |= VMXNET3_CSUM_OFFLOAD;
+   if (ifp->if_capenable & IFCAP_TXCSUM_IPV6)
+   hwassist |= VMXNET3_CSUM_OFFLOAD_IPV6;
+   if (ifp->if_capenable & IFCAP_TSO4)
+   hwassist |= CSUM_IP_TSO;
+   if (ifp->if_capenable & IFCAP_TSO6)
+   hwassist |= CSUM_IP6_TSO;
+   ifp->if_hwassist = hwassist;
+}
+
+static void
 vmxnet3_reinit_interface(struct vmxnet3_softc *sc)
 {
struct ifnet *ifp;
@@ -1593,15 +1612,7 @@ vmxnet3_reinit_interface(struct vmxnet3_
bcopy(IF_LLADDR(sc->vmx_ifp), sc->vmx_lladdr, ETHER_ADDR_LEN);
vmxnet3_set_lladdr(sc);
 
-   ifp->if_hwassist = 0;
-   if (ifp->if_capenable & IFCAP_TXCSUM)
-   ifp->if_hwassist |= VMXNET3_CSUM_OFFLOAD;
-   if (ifp->if_capenable & IFCAP_TXCSUM_IPV6)
-   ifp->if_hwassist |= VMXNET3_CSUM_OFFLOAD_IPV6;
-   if (ifp->if_capenable & IFCAP_TSO4)
-   ifp->if_hwassist |= CSUM_IP_TSO;
-   if (ifp->if_capenable & IFCAP_TSO6)
-   ifp->if_hwassist |= CSUM_IP6_TSO;
+   vmxnet3_init_hwassist(sc);
 }
 
 static void
@@ -3284,6 +3295,8 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long 
if (reinit && (ifp->if_drv_flags & IFF_DRV_RUNNING)) {
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
vmxnet3_init_locked(sc);
+   } else {
+   vmxnet3_init_hwassist(sc);
}
 
VMXNET3_CORE_UNLOCK(sc);
___
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: r302985 - head/sys/geom/label

2016-07-18 Thread Maxim Sobolev
Andrey, are you talking about this:

---
r156299 | pjd | 2006-03-04 11:41:54 -0800 (сб, 04 мар 2006) | 11 lines

We need to check if file system size is equal to provider's size, because
sysinstall(8) still bogusly puts first partition at offset 0 instead of 16,
so glabel/ufs will find file system on slice instead of partition.

Before sysinstall is fixed, we must keep this code, which means that we
wont't be able to detect UFS file systems created with 'newfs -s ...'.

PS. bsdlabel(8) creates partitions properly.

MFC after:  3 days
---

In which case this particular change has a better chance of working since
it's not removing this check but making it less strict. Therefore it might
attach to a wrong provider only if first UFS slice is the only one slice on
partition (or if the other partition is very small - less than 256 blocks
in size). In either of those cases I don't think it makes much difference
if we are attaching to a slice or a partition.

-Maxim

On Sun, Jul 17, 2016 at 10:37 PM, Andrey V. Elsukov 
wrote:

> On 18.07.16 08:00, Maxim Sobolev wrote:
> > Author: sobomax
> > Date: Mon Jul 18 05:00:01 2016
> > New Revision: 302985
> > URL: https://svnweb.freebsd.org/changeset/base/302985
> >
> > Log:
> >   Relax checking if the privider size matches size recorded in the
> >   superblock, allowing provider to be bit bigger, i.e. have some
> >   extra padding after the FS image. That in some cases might be
> >   a side-effect of using CLOOP format which enforces certain block
> >   size and trying to compress image that is not exactly the number
> >   of those blocks in size. The UFS itself does not have any issues
> >   mounting such padded file systems, so it's what GEOM_LABEL should
> >   do.
>
> While you are thinking this is good fix, I expect that this change will
> break many installations. This is not first time when this check was
> changed.
>
> --
> WBR, Andrey V. Elsukov
>
>
___
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"

svn commit: r302999 - head/sys/kern

2016-07-18 Thread Konstantin Belousov
Author: kib
Date: Mon Jul 18 10:53:47 2016
New Revision: 302999
URL: https://svnweb.freebsd.org/changeset/base/302999

Log:
  The assertion re-added in r302614 was triggered when stopping signal
  is delivered to vforked child.  Issue is that we avoid stopping such
  children in issignal() to not block parents.  But executed AST, which
  ignored stops, leaves the child with the signal pending but no AST
  pending.
  
  On first exec after vfork(), call signotify() to handle pending
  reenabled signals.  Adjust the assert to not check vfork children
  until exec.
  
  Reported and tested by:   pho
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks

Modified:
  head/sys/kern/kern_exec.c
  head/sys/kern/subr_trap.c

Modified: head/sys/kern/kern_exec.c
==
--- head/sys/kern/kern_exec.c   Mon Jul 18 09:29:08 2016(r302998)
+++ head/sys/kern/kern_exec.c   Mon Jul 18 10:53:47 2016(r302999)
@@ -760,6 +760,8 @@ interpret:
if (p->p_flag & P_PPWAIT) {
p->p_flag &= ~(P_PPWAIT | P_PPTRACE);
cv_broadcast(>p_pwait);
+   /* STOPs are no longer ignored, arrange for AST */
+   signotify(td);
}
 
/*

Modified: head/sys/kern/subr_trap.c
==
--- head/sys/kern/subr_trap.c   Mon Jul 18 09:29:08 2016(r302998)
+++ head/sys/kern/subr_trap.c   Mon Jul 18 10:53:47 2016(r302999)
@@ -107,15 +107,20 @@ userret(struct thread *td, struct trapfr
 * multi-threaded processes, where signal distribution might
 * change due to other threads changing sigmask, the check is
 * racy and cannot be performed reliably.
+* If current process is vfork child, indicated by P_PPWAIT, then
+* issignal() ignores stops, so we block the check to avoid
+* classifying pending signals.
 */
if (p->p_numthreads == 1) {
PROC_LOCK(p);
thread_lock(td);
-   KASSERT(!SIGPENDING(td) ||
-   (td->td_flags & (TDF_NEEDSIGCHK | TDF_ASTPENDING)) ==
-   (TDF_NEEDSIGCHK | TDF_ASTPENDING),
-   ("failed to set signal flags for ast p %p td %p fl %x",
-   p, td, td->td_flags));
+   if ((p->p_flag & P_PPWAIT) == 0) {
+   KASSERT(!SIGPENDING(td) || (td->td_flags &
+   (TDF_NEEDSIGCHK | TDF_ASTPENDING)) ==
+   (TDF_NEEDSIGCHK | TDF_ASTPENDING),
+   ("failed to set signal flags for ast p %p "
+   "td %p fl %x", p, td, td->td_flags));
+   }
thread_unlock(td);
PROC_UNLOCK(p);
}
@@ -281,12 +286,15 @@ ast(struct trapframe *framep)
 * td_flags, since signal might have been delivered
 * after we cleared td_flags above.  This is one of
 * the reason for looping check for AST condition.
+* See comment in userret() about P_PPWAIT.
 */
-   KASSERT(!SIGPENDING(td) ||
-   (td->td_flags & (TDF_NEEDSIGCHK | TDF_ASTPENDING)) ==
-   (TDF_NEEDSIGCHK | TDF_ASTPENDING),
-   ("failed2 to set signal flags for ast p %p td %p fl %x %x",
-   p, td, flags, td->td_flags));
+   if ((p->p_flag & P_PPWAIT) == 0) {
+   KASSERT(!SIGPENDING(td) || (td->td_flags &
+   (TDF_NEEDSIGCHK | TDF_ASTPENDING)) ==
+   (TDF_NEEDSIGCHK | TDF_ASTPENDING),
+   ("failed2 to set signal flags for ast p %p td %p "
+   "fl %x %x", p, td, flags, td->td_flags));
+   }
thread_unlock(td);
PROC_UNLOCK(p);
}
___
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"


svn commit: r302998 - head/sys/kern

2016-07-18 Thread Gleb Smirnoff
Author: glebius
Date: Mon Jul 18 09:29:08 2016
New Revision: 302998
URL: https://svnweb.freebsd.org/changeset/base/302998

Log:
  Revert the last commit. It must get more review and testing first.

Modified:
  head/sys/kern/kern_timeout.c

Modified: head/sys/kern/kern_timeout.c
==
--- head/sys/kern/kern_timeout.cMon Jul 18 09:26:06 2016
(r302997)
+++ head/sys/kern/kern_timeout.cMon Jul 18 09:29:08 2016
(r302998)
@@ -1381,7 +1381,7 @@ again:
CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p",
c, c->c_func, c->c_arg);
CC_UNLOCK(cc);
-   return (-1);
+   return (0);
}
 
c->c_iflags &= ~CALLOUT_PENDING;
___
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"


svn commit: r302997 - head/sys/kern

2016-07-18 Thread Gleb Smirnoff
Author: glebius
Date: Mon Jul 18 09:26:06 2016
New Revision: 302997
URL: https://svnweb.freebsd.org/changeset/base/302997

Log:
  Redo the r302894: the very new value for a non-scheduled callout is -1.
  This was recently added in r290664.
  
  Noticed by:   hselasky
  PR:   210884

Modified:
  head/sys/kern/kern_timeout.c

Modified: head/sys/kern/kern_timeout.c
==
--- head/sys/kern/kern_timeout.cMon Jul 18 09:19:45 2016
(r302996)
+++ head/sys/kern/kern_timeout.cMon Jul 18 09:26:06 2016
(r302997)
@@ -1381,7 +1381,7 @@ again:
CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p",
c, c->c_func, c->c_arg);
CC_UNLOCK(cc);
-   return (0);
+   return (-1);
}
 
c->c_iflags &= ~CALLOUT_PENDING;
___
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: r302894 - head/sys/kern

2016-07-18 Thread Gleb Smirnoff
On Fri, Jul 15, 2016 at 04:29:45PM +0200, Hans Petter Selasky wrote:
H> On 07/15/16 11:28, Gleb Smirnoff wrote:
H> > Author: glebius
H> > Date: Fri Jul 15 09:28:32 2016
H> > New Revision: 302894
H> > URL: https://svnweb.freebsd.org/changeset/base/302894
H> >
H> > Log:
H> >   Fix regression introduced by r302350. The change of return value for a
H> >   callout that wasn't scheduled at all was unintentional and yielded in
H> >   several panics.
H> >
H> >   PR:  210884
H> >
H> > Modified:
H> >   head/sys/kern/kern_timeout.c
H> >
H> > Modified: head/sys/kern/kern_timeout.c
H> > 
==
H> > --- head/sys/kern/kern_timeout.c   Fri Jul 15 09:23:18 2016
(r302893)
H> > +++ head/sys/kern/kern_timeout.c   Fri Jul 15 09:28:32 2016
(r302894)
H> > @@ -1381,7 +1381,7 @@ again:
H> >CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p",
H> >c, c->c_func, c->c_arg);
H> >CC_UNLOCK(cc);
H> > -  return (cancelled);
H> > +  return (0);
H> >}
H> >
H> >c->c_iflags &= ~CALLOUT_PENDING;
H> >
H> >
H> 
H> Hi,
H> 
H> I think r302894 and r302350 changes the return value of the following 
H> case, which is not described in the commit message? Is this also a 
H> regression?
H> 
H> In this revision:
H> > 
https://svnweb.freebsd.org/base/head/sys/kern/kern_timeout.c?view=markup=296320
H> 
H> Assume we enter _callout_stop_safe() having the following assertions:
H> 
H> (c->c_iflags & CALLOUT_PENDING) == 0 (satisfied)
H> cc_exec_curr(cc, direct) != c (satisfied)
H> 
H> Then we exit returning (-1).
H> 
H> In this revision:
H> > 
https://svnweb.freebsd.org/base/head/sys/kern/kern_timeout.c?view=markup=296320#l1253
H> 
H> After your changes, entering the same function under the same conditions:
H> 
H> cc_exec_curr(cc, direct) == c (not satisifed)
H> (c->c_iflags & CALLOUT_PENDING) == 0 (satisfied)
H> 
H> Then we exit returning (0).
H> 
H> > 
https://svnweb.freebsd.org/base/head/sys/kern/kern_timeout.c?revision=302894=markup#l1384
H> 
H> If we call callout_stop() on a never scheduled callout, we now get a 
H> return value of 0 instead of -1, which by manual page definition is 
H> wrong 
H> 
H> Am I wrong? Do others see this too?

You are right, the new -1 value was introduced by you and rrs@ in the
commit:


r290664 | rrs | 2015-11-10 06:49:32 -0800 (вт, 10 нояб. 2015) | 6 lines

Add new async_drain to the callout system. This is so-far not used but
should be used by TCP for sure in its cleanup of the IN-PCB (will be coming 
shortly).

Sponsored by:   Netflix Inc.
Differential Revision:  https://reviews.freebsd.org/D4076



So commit not only extended the KPI, but also changed it. And I missed that,
using stable/10 version as reference.

-- 
Totus tuus, Glebius.
___
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"

svn commit: r302995 - stable/10/sys/netinet

2016-07-18 Thread Julien Charbon
Author: jch
Date: Mon Jul 18 08:20:31 2016
New Revision: 302995
URL: https://svnweb.freebsd.org/changeset/base/302995

Log:
  MFC r261242:
  
  Decrease lock contention within the TCP accept case by removing
  the INP_INFO lock from tcp_usr_accept.  As the PR/patch states
  this was following the advice already in the code.
  See the PR below for a full discussion of this change and its
  measured effects.
  
  PR:   183659
  Submitted by: Julien Charbon
  Reviewed by:  jhb

Modified:
  stable/10/sys/netinet/tcp_syncache.c
  stable/10/sys/netinet/tcp_usrreq.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet/tcp_syncache.c
==
--- stable/10/sys/netinet/tcp_syncache.cMon Jul 18 07:06:44 2016
(r302994)
+++ stable/10/sys/netinet/tcp_syncache.cMon Jul 18 08:20:31 2016
(r302995)
@@ -683,7 +683,7 @@ syncache_socket(struct syncache *sc, str
 * connection when the SYN arrived.  If we can't create
 * the connection, abort it.
 */
-   so = sonewconn(lso, SS_ISCONNECTED);
+   so = sonewconn(lso, 0);
if (so == NULL) {
/*
 * Drop the connection; we will either send a RST or
@@ -922,6 +922,8 @@ syncache_socket(struct syncache *sc, str
 
INP_WUNLOCK(inp);
 
+   soisconnected(so);
+
TCPSTAT_INC(tcps_accepts);
return (so);
 

Modified: stable/10/sys/netinet/tcp_usrreq.c
==
--- stable/10/sys/netinet/tcp_usrreq.c  Mon Jul 18 07:06:44 2016
(r302994)
+++ stable/10/sys/netinet/tcp_usrreq.c  Mon Jul 18 08:20:31 2016
(r302995)
@@ -643,13 +643,6 @@ out:
 /*
  * Accept a connection.  Essentially all the work is done at higher levels;
  * just return the address of the peer, storing through addr.
- *
- * The rationale for acquiring the tcbinfo lock here is somewhat complicated,
- * and is described in detail in the commit log entry for r175612.  Acquiring
- * it delays an accept(2) racing with sonewconn(), which inserts the socket
- * before the inpcb address/port fields are initialized.  A better fix would
- * prevent the socket from being placed in the listen queue until all fields
- * are fully initialized.
  */
 static int
 tcp_usr_accept(struct socket *so, struct sockaddr **nam)
@@ -666,7 +659,6 @@ tcp_usr_accept(struct socket *so, struct
 
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("tcp_usr_accept: inp == NULL"));
-   INP_INFO_RLOCK(_tcbinfo);
INP_WLOCK(inp);
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
error = ECONNABORTED;
@@ -686,7 +678,6 @@ tcp_usr_accept(struct socket *so, struct
 out:
TCPDEBUG2(PRU_ACCEPT);
INP_WUNLOCK(inp);
-   INP_INFO_RUNLOCK(_tcbinfo);
if (error == 0)
*nam = in_sockaddr(port, );
return error;
___
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"


svn commit: r302994 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-07-18 Thread Andriy Gapon
Author: avg
Date: Mon Jul 18 07:06:44 2016
New Revision: 302994
URL: https://svnweb.freebsd.org/changeset/base/302994

Log:
  MFC r302772: re-apply r299908: zfsctl_snapdir_lookup: clear VV_ROOT of
  snapshot's root
  
  The change has been undone in r301275 on the assumption that it was no
  longer required.  But that was incorrect, because in this case (and only
  in this case) the snapshot root vnode is looked up before z_parent is
  fixed up.
  
  Approved by:  re (delphij)

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c   
Mon Jul 18 07:03:39 2016(r302993)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c   
Mon Jul 18 07:06:44 2016(r302994)
@@ -1125,6 +1125,7 @@ domount:
 */
ASSERT(VTOZ(*vpp)->z_zfsvfs != zfsvfs);
VTOZ(*vpp)->z_zfsvfs->z_parent = zfsvfs;
+   (*vpp)->v_flag &= ~VROOT;
}
ZFS_EXIT(zfsvfs);
 
___
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"


svn commit: r302993 - in vendor-sys/illumos/dist/uts/common: fs/zfs fs/zfs/sys sys/fs

2016-07-18 Thread Andriy Gapon
Author: avg
Date: Mon Jul 18 07:03:39 2016
New Revision: 302993
URL: https://svnweb.freebsd.org/changeset/base/302993

Log:
  7104 increase indirect block size
  
  illumos/illumos-gate@4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1c
  
https://github.com/illumos/illumos-gate/commit/4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1c
  
  https://www.illumos.org/issues/7104
The current default indirect block size is 16KB. We can improve
performance by increasing it to 128KB. This is especially helpful for
any workload that needs to read most of the metadata, e.g.
scrub/resilver, file deletion, filesystem deletion, and zfs send.
We also need to fix a few space estimation errors to make the tests
pass.
  
  Reviewed by: George Wilson 
  Reviewed by: Paul Dagnelie 
  Reviewed by: Dan McDonald 
  Approved by: Robert Mustacchi 
  Author: Matthew Ahrens 

Modified:
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_objset.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/spa_misc.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/dnode.h
  vendor-sys/illumos/dist/uts/common/sys/fs/zfs.h

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_objset.c
==
--- vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_objset.c  Mon Jul 18 
06:58:39 2016(r302992)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_objset.c  Mon Jul 18 
07:03:39 2016(r302993)
@@ -787,11 +787,17 @@ dmu_objset_create_impl(spa_t *spa, dsl_d
 
/*
 * Determine the number of levels necessary for the meta-dnode
-* to contain DN_MAX_OBJECT dnodes.
+* to contain DN_MAX_OBJECT dnodes.  Note that in order to
+* ensure that we do not overflow 64 bits, there has to be
+* a nlevels that gives us a number of blocks > DN_MAX_OBJECT
+* but < 2^64.  Therefore,
+* (mdn->dn_indblkshift - SPA_BLKPTRSHIFT) (10) must be
+* less than (64 - log2(DN_MAX_OBJECT)) (16).
 */
-   while ((uint64_t)mdn->dn_nblkptr << (mdn->dn_datablkshift +
+   while ((uint64_t)mdn->dn_nblkptr <<
+   (mdn->dn_datablkshift - DNODE_SHIFT +
(levels - 1) * (mdn->dn_indblkshift - SPA_BLKPTRSHIFT)) <
-   DN_MAX_OBJECT * sizeof (dnode_phys_t))
+   DN_MAX_OBJECT)
levels++;
 
mdn->dn_next_nlevels[tx->tx_txg & TXG_MASK] =

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/spa_misc.c
==
--- vendor-sys/illumos/dist/uts/common/fs/zfs/spa_misc.cMon Jul 18 
06:58:39 2016(r302992)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/spa_misc.cMon Jul 18 
07:03:39 2016(r302993)
@@ -341,9 +341,14 @@ int spa_asize_inflation = 24;
  * it is possible to run the pool completely out of space, causing it to
  * be permanently read-only.
  *
+ * Note that on very small pools, the slop space will be larger than
+ * 3.2%, in an effort to have it be at least spa_min_slop (128MB),
+ * but we never allow it to be more than half the pool size.
+ *
  * See also the comments in zfs_space_check_t.
  */
 int spa_slop_shift = 5;
+uint64_t spa_min_slop = 128 * 1024 * 1024;
 
 /*
  * ==
@@ -1637,14 +1642,16 @@ spa_get_asize(spa_t *spa, uint64_t lsize
 
 /*
  * Return the amount of slop space in bytes.  It is 1/32 of the pool (3.2%),
- * or at least 32MB.
+ * or at least 128MB, unless that would cause it to be more than half the
+ * pool size.
  *
  * See the comment above spa_slop_shift for details.
  */
 uint64_t
-spa_get_slop_space(spa_t *spa) {
+spa_get_slop_space(spa_t *spa)
+{
uint64_t space = spa_get_dspace(spa);
-   return (MAX(space >> spa_slop_shift, SPA_MINDEVSIZE >> 1));
+   return (MAX(space >> spa_slop_shift, MIN(space >> 1, spa_min_slop)));
 }
 
 uint64_t

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/sys/dnode.h
==
--- vendor-sys/illumos/dist/uts/common/fs/zfs/sys/dnode.h   Mon Jul 18 
06:58:39 2016(r302992)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/sys/dnode.h   Mon Jul 18 
07:03:39 2016(r302993)
@@ -58,7 +58,7 @@ extern "C" {
  */
 #defineDNODE_SHIFT 9   /* 512 bytes */
 #defineDN_MIN_INDBLKSHIFT  12  /* 4k */
-#defineDN_MAX_INDBLKSHIFT  14  /* 16k */
+#defineDN_MAX_INDBLKSHIFT  17  /* 128k */
 #defineDNODE_BLOCK_SHIFT   14  /* 16k */
 #defineDNODE_CORE_SIZE 64  /* 64 bytes for dnode sans 
blkptrs */
 #define

svn commit: r302992 - vendor-sys/illumos/dist/uts/common/fs/zfs

2016-07-18 Thread Andriy Gapon
Author: avg
Date: Mon Jul 18 06:58:39 2016
New Revision: 302992
URL: https://svnweb.freebsd.org/changeset/base/302992

Log:
  7071 lzc_snapshot does not fill in errlist on ENOENT
  
  illumos/illumos-gate@25f7d993adbfb3452ac4625b3791670746d35ae3
  
https://github.com/illumos/illumos-gate/commit/25f7d993adbfb3452ac4625b3791670746d35ae3
  
  https://www.illumos.org/issues/7071
upstream
DLPX-40482 lzc_snapshot does not fill in errlist on ENOENT
  
  Reviewed by: Igor Kozhukhov 
  Reviewed by: George Wilson 
  Reviewed by: Dan Kimmel 
  Approved by: Robert Mustacchi 
  Author: Matthew Ahrens 

Modified:
  vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_ioctl.c

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_ioctl.c
==
--- vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_ioctl.c   Mon Jul 18 
06:57:24 2016(r302991)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_ioctl.c   Mon Jul 18 
06:58:39 2016(r302992)
@@ -491,6 +491,14 @@ zfs_secpolicy_write_perms(const char *na
dsl_dataset_t *ds;
dsl_pool_t *dp;
 
+   /*
+* First do a quick check for root in the global zone, which
+* is allowed to do all write_perms.  This ensures that zfs_ioc_*
+* will get to handle nonexistent datasets.
+*/
+   if (INGLOBALZONE(curproc) && secpolicy_zfs(cr) == 0)
+   return (0);
+
error = dsl_pool_hold(name, FTAG, );
if (error != 0)
return (error);
___
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"


svn commit: r302991 - vendor-sys/illumos/dist/uts/common/fs/zfs vendor-sys/illumos/dist/uts/common/fs/zfs/sys vendor/illumos/dist/cmd/zdb vendor/illumos/dist/cmd/ztest

2016-07-18 Thread Andriy Gapon
Author: avg
Date: Mon Jul 18 06:57:24 2016
New Revision: 302991
URL: https://svnweb.freebsd.org/changeset/base/302991

Log:
  6950 ARC should cache compressed data
  
  illumos/illumos-gate@dcbf3bd6a1f1360fc1afcee9e22c6dcff7844bf2
  
https://github.com/illumos/illumos-gate/commit/dcbf3bd6a1f1360fc1afcee9e22c6dcff7844bf2
  
  https://www.illumos.org/issues/6950
When reading compressed data from disk, the ARC should keep the compressed
block cached and only decompress it when consumers access the block. The
uncompressed data should be short-lived allowing the ARC to cache a much 
larger
amount of data. The DMU would also maintain a smaller cache of uncompressed
blocks to minimize the impact of decompressing frequently accessed blocks.
  
  Reviewed by: Prakash Surya 
  Reviewed by: Dan Kimmel 
  Reviewed by: Matt Ahrens 
  Reviewed by: Paul Dagnelie 
  Reviewed by: Don Brady 
  Reviewed by: Richard Elling 
  Approved by: Richard Lowe 
  Author: George Wilson 

Modified:
  vendor/illumos/dist/cmd/zdb/zdb.c
  vendor/illumos/dist/cmd/ztest/ztest.c

Changes in other areas also in this revision:
Modified:
  vendor-sys/illumos/dist/uts/common/fs/zfs/arc.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dbuf.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_diff.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_objset.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_send.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_traverse.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dnode.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dnode_sync.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dsl_scan.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/refcount.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/arc.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/dbuf.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/refcount.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/spa.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zio.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zio_checksum.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/zil.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/zio.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/zio_checksum.c

Modified: vendor/illumos/dist/cmd/zdb/zdb.c
==
--- vendor/illumos/dist/cmd/zdb/zdb.c   Mon Jul 18 06:47:08 2016
(r302990)
+++ vendor/illumos/dist/cmd/zdb/zdb.c   Mon Jul 18 06:57:24 2016
(r302991)
@@ -1262,7 +1262,7 @@ visit_indirect(spa_t *spa, const dnode_p
}
if (!err)
ASSERT3U(fill, ==, BP_GET_FILL(bp));
-   (void) arc_buf_remove_ref(buf, );
+   arc_buf_destroy(buf, );
}
 
return (err);

Modified: vendor/illumos/dist/cmd/ztest/ztest.c
==
--- vendor/illumos/dist/cmd/ztest/ztest.c   Mon Jul 18 06:47:08 2016
(r302990)
+++ vendor/illumos/dist/cmd/ztest/ztest.c   Mon Jul 18 06:57:24 2016
(r302991)
@@ -187,6 +187,7 @@ extern uint64_t metaslab_gang_bang;
 extern uint64_t metaslab_df_alloc_threshold;
 extern uint64_t zfs_deadman_synctime_ms;
 extern int metaslab_preload_limit;
+extern boolean_t zfs_compressed_arc_enabled;
 
 static ztest_shared_opts_t *ztest_shared_opts;
 static ztest_shared_opts_t ztest_opts;
@@ -5353,6 +5354,12 @@ ztest_resume_thread(void *arg)
if (spa_suspended(spa))
ztest_resume(spa);
(void) poll(NULL, 0, 100);
+
+   /*
+* Periodically change the zfs_compressed_arc_enabled setting.
+*/
+   if (ztest_random(10) == 0)
+   zfs_compressed_arc_enabled = ztest_random(2);
}
return (NULL);
 }
___
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"


svn commit: r302991 - vendor-sys/illumos/dist/uts/common/fs/zfs vendor-sys/illumos/dist/uts/common/fs/zfs/sys vendor/illumos/dist/cmd/zdb vendor/illumos/dist/cmd/ztest

2016-07-18 Thread Andriy Gapon
Author: avg
Date: Mon Jul 18 06:57:24 2016
New Revision: 302991
URL: https://svnweb.freebsd.org/changeset/base/302991

Log:
  6950 ARC should cache compressed data
  
  illumos/illumos-gate@dcbf3bd6a1f1360fc1afcee9e22c6dcff7844bf2
  
https://github.com/illumos/illumos-gate/commit/dcbf3bd6a1f1360fc1afcee9e22c6dcff7844bf2
  
  https://www.illumos.org/issues/6950
When reading compressed data from disk, the ARC should keep the compressed
block cached and only decompress it when consumers access the block. The
uncompressed data should be short-lived allowing the ARC to cache a much 
larger
amount of data. The DMU would also maintain a smaller cache of uncompressed
blocks to minimize the impact of decompressing frequently accessed blocks.
  
  Reviewed by: Prakash Surya 
  Reviewed by: Dan Kimmel 
  Reviewed by: Matt Ahrens 
  Reviewed by: Paul Dagnelie 
  Reviewed by: Don Brady 
  Reviewed by: Richard Elling 
  Approved by: Richard Lowe 
  Author: George Wilson 

Modified:
  vendor-sys/illumos/dist/uts/common/fs/zfs/arc.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dbuf.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_diff.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_objset.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_send.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_traverse.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dnode.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dnode_sync.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dsl_scan.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/refcount.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/arc.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/dbuf.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/refcount.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/spa.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zio.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zio_checksum.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/zil.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/zio.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/zio_checksum.c

Changes in other areas also in this revision:
Modified:
  vendor/illumos/dist/cmd/zdb/zdb.c
  vendor/illumos/dist/cmd/ztest/ztest.c

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/arc.c
==
--- vendor-sys/illumos/dist/uts/common/fs/zfs/arc.c Mon Jul 18 06:47:08 
2016(r302990)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/arc.c Mon Jul 18 06:57:24 
2016(r302991)
@@ -120,9 +120,134 @@
  * - ARC header release, as it removes from L2ARC buflists
  */
 
+/*
+ * ARC operation:
+ *
+ * Every block that is in the ARC is tracked by an arc_buf_hdr_t structure.
+ * This structure can point either to a block that is still in the cache or to
+ * one that is only accessible in an L2 ARC device, or it can provide
+ * information about a block that was recently evicted. If a block is
+ * only accessible in the L2ARC, then the arc_buf_hdr_t only has enough
+ * information to retrieve it from the L2ARC device. This information is
+ * stored in the l2arc_buf_hdr_t sub-structure of the arc_buf_hdr_t. A block
+ * that is in this state cannot access the data directly.
+ *
+ * Blocks that are actively being referenced or have not been evicted
+ * are cached in the L1ARC. The L1ARC (l1arc_buf_hdr_t) is a structure within
+ * the arc_buf_hdr_t that will point to the data block in memory. A block can
+ * only be read by a consumer if it has an l1arc_buf_hdr_t. The L1ARC
+ * caches data in two ways -- in a list of arc buffers (arc_buf_t) and
+ * also in the arc_buf_hdr_t's private physical data block pointer (b_pdata).
+ * Each arc buffer (arc_buf_t) is being actively accessed by a specific ARC
+ * consumer, and always contains uncompressed data. The ARC will provide
+ * references to this data and will keep it cached until it is no longer in
+ * use. Typically, the arc will try to cache only the L1ARC's physical data
+ * block and will aggressively evict any arc_buf_t that is no longer 
referenced.
+ * The amount of memory consumed by the arc_buf_t's can be seen via the
+ * "overhead_size" kstat.
+ *
+ *
+ *arc_buf_hdr_t
+ *+---+
+ *|   |
+ *|   |
+ *|   |
+ *+---+
+ * l2arc_buf_hdr_t|   |
+ *|   |
+ *+---+
+ * l1arc_buf_hdr_t|   |
+ *|   | arc_buf_t
+ *|b_buf  +>+-+  arc_buf_t
+ *|   | |b_next   +>+-+
+ *|  b_pdata  +-+   

svn commit: r302990 - stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-07-18 Thread Andriy Gapon
Author: avg
Date: Mon Jul 18 06:47:08 2016
New Revision: 302990
URL: https://svnweb.freebsd.org/changeset/base/302990

Log:
  MFC r302772: re-apply r299908: zfsctl_snapdir_lookup: clear VV_ROOT of
  snapshot's root

Modified:
  stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)

Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
==
--- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
Mon Jul 18 06:46:49 2016(r302989)
+++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
Mon Jul 18 06:47:08 2016(r302990)
@@ -1125,6 +1125,7 @@ domount:
 */
ASSERT(VTOZ(*vpp)->z_zfsvfs != zfsvfs);
VTOZ(*vpp)->z_zfsvfs->z_parent = zfsvfs;
+   (*vpp)->v_flag &= ~VROOT;
}
ZFS_EXIT(zfsvfs);
 
___
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"


svn commit: r302989 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-07-18 Thread Andriy Gapon
Author: avg
Date: Mon Jul 18 06:46:49 2016
New Revision: 302989
URL: https://svnweb.freebsd.org/changeset/base/302989

Log:
  MFC r302772: re-apply r299908: zfsctl_snapdir_lookup: clear VV_ROOT of
  snapshot's root

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c   
Mon Jul 18 06:35:40 2016(r302988)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c   
Mon Jul 18 06:46:49 2016(r302989)
@@ -1125,6 +1125,7 @@ domount:
 */
ASSERT(VTOZ(*vpp)->z_zfsvfs != zfsvfs);
VTOZ(*vpp)->z_zfsvfs->z_parent = zfsvfs;
+   (*vpp)->v_flag &= ~VROOT;
}
ZFS_EXIT(zfsvfs);
 
___
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"


svn commit: r302988 - head/sys/arm/ti/am335x

2016-07-18 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Jul 18 06:35:40 2016
New Revision: 302988
URL: https://svnweb.freebsd.org/changeset/base/302988

Log:
  Fix a random memory overwrite at boot time, simplebus_init() and
  simplebus_add_device() expect a simplebus_softc structure associated with
  the device.
  
  Add the simplebus_softc as first member in am335x_pwmss_softc structure.
  
  Sponsored by: Rubicon Communications (Netgate)

Modified:
  head/sys/arm/ti/am335x/am335x_pwmss.c

Modified: head/sys/arm/ti/am335x/am335x_pwmss.c
==
--- head/sys/arm/ti/am335x/am335x_pwmss.c   Mon Jul 18 06:09:52 2016
(r302987)
+++ head/sys/arm/ti/am335x/am335x_pwmss.c   Mon Jul 18 06:35:40 2016
(r302988)
@@ -65,6 +65,7 @@ static device_attach_t am335x_pwmss_atta
 static device_detach_t am335x_pwmss_detach;
 
 struct am335x_pwmss_softc {
+   struct simplebus_softc  sc_simplebus;
device_tsc_dev;
clk_ident_t sc_clk;
 };
___
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"


svn commit: r302987 - stable/10/sys/netpfil/ipfw

2016-07-18 Thread Don Lewis
Author: truckman
Date: Mon Jul 18 06:09:52 2016
New Revision: 302987
URL: https://svnweb.freebsd.org/changeset/base/302987

Log:
  MFC r302667
  
  Fix problems in the FQ-PIE AQM cleanup code that could leak memory or
  cause a crash.
  
  Because dummynet calls pie_cleanup() while holding a mutex, pie_cleanup()
  is not able to use callout_drain() to make sure that all callouts are
  finished before it returns, and callout_stop() is not sufficient to make
  that guarantee.  After pie_cleanup() returns, dummynet will free a
  structure that any remaining callouts will want to access.
  
  Fix these problems by allocating a separate structure to contain the
  data used by the callouts.  In pie_cleanup(), call callout_reset_sbt()
  to replace the normal callout with a cleanup callout that does the cleanup
  work for each sub-queue.  The instance of the cleanup callout that
  destroys the last flow will also free the extra allocated block of memory.
  Protect the reference count manipulation in the cleanup callout with
  DN_BH_WLOCK() to be consistent with all of the other usage of the reference
  count where this lock is held by the dummynet code.
  
  Submitted by: Rasool Al-Saadi 
  Differential Revision:https://reviews.freebsd.org/D7174

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

Modified: stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.cMon Jul 18 05:36:31 
2016(r302986)
+++ stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.cMon Jul 18 06:09:52 
2016(r302987)
@@ -111,7 +111,7 @@ struct fq_pie_flow {
int deficit;
int active; /* 1: flow is active (in a list) */
struct pie_status pst;  /* pie status variables */
-   struct fq_pie_si *psi;  /* parent scheduler instance */
+   struct fq_pie_si_extra *psi_extra;
STAILQ_ENTRY(fq_pie_flow) flowchain;
 };
 
@@ -120,23 +120,30 @@ struct fq_pie_schk {
struct dn_sch_fq_pie_parms cfg;
 };
 
+
+/* fq_pie scheduler instance extra state vars.
+ * The purpose of separation this structure is to preserve number of active
+ * sub-queues and the flows array pointer even after the scheduler instance
+ * is destroyed.
+ * Preserving these varaiables allows freeing the allocated memory by
+ * fqpie_callout_cleanup() independently from fq_pie_free_sched().
+ */
+struct fq_pie_si_extra {
+   uint32_t nr_active_q;   /* number of active queues */
+   struct fq_pie_flow *flows;  /* array of flows (queues) */
+   };
+
 /* fq_pie scheduler instance */
 struct fq_pie_si {
-   struct dn_sch_inst _si; /* standard scheduler instance */
+   struct dn_sch_inst _si; /* standard scheduler instance. SHOULD BE FIRST 
*/ 
struct dn_queue main_q; /* main queue is after si directly */
-   uint32_t nr_active_q;
-   struct fq_pie_flow *flows;  /* array of flows (queues) */
uint32_t perturbation;  /* random value */
struct fq_pie_list newflows;/* list of new queues */
struct fq_pie_list oldflows;/* list of old queues */
+   struct fq_pie_si_extra *si_extra; /* extra state vars*/
 };
 
 
-struct mem_to_free {
-   void *mem_flows;
-   void *mem_callout;
-};
-static struct mtx freemem_mtx;
 static struct dn_alg fq_pie_desc;
 
 /*  Default FQ-PIE parameters including PIE */
@@ -371,22 +378,6 @@ fq_calculate_drop_prob(void *x)
int64_t p, prob, oldprob;
aqm_time_t now;
 
-   /* dealing with race condition */
-   if (callout_pending(>aqm_pie_callout)) {
-   /* callout was reset */
-   mtx_unlock(>lock_mtx);
-   return;
-   }
-
-   if (!callout_active(>aqm_pie_callout)) {
-   /* callout was stopped */
-   mtx_unlock(>lock_mtx);
-   mtx_destroy(>lock_mtx);
-   q->psi->nr_active_q--;
-   return;
-   }
-   callout_deactivate(>aqm_pie_callout);
-
now = AQM_UNOW;
pprms = pst->parms;
prob = pst->drop_prob;
@@ -524,20 +515,17 @@ fq_deactivate_pie(struct pie_status *pst
   * Initialize PIE for sub-queue 'q'
   */
 static int
-pie_init(struct fq_pie_flow *q)
+pie_init(struct fq_pie_flow *q, struct fq_pie_schk *fqpie_schk)
 {
struct pie_status *pst=>pst;
struct dn_aqm_pie_parms *pprms = pst->parms;
-   struct fq_pie_schk *fqpie_schk;
-   
-   fqpie_schk = (struct fq_pie_schk *)(q->psi->_si.sched+1);
-   int err = 0;
 
+   int err = 0;
if (!pprms){
D("AQM_PIE is not configured");
err = EINVAL;
} else {
-   q->psi->nr_active_q++;
+   q->psi_extra->nr_active_q++;
 
/* For speed optimization, we caculate 1/3 queue size once here 
*/
// XXX