Re: svn commit: r340511 - stable/12/sys/kern

2018-11-17 Thread Rodney W. Grimes
> On Sat, Nov 17, 2018 at 03:47:16PM -0800, Rodney W. Grimes wrote:
> > > Author: markj
> > > Date: Sat Nov 17 20:01:35 2018
> > > New Revision: 340511
> > > URL: https://svnweb.freebsd.org/changeset/base/340511
> > > 
> > > Log:
> > >   MFC r339731:
> > >   Add FALLTHROUGH comments to appease Coverity.
> > > 
> > > Modified:
> > >   stable/12/sys/kern/kern_environment.c
> > >   stable/12/sys/kern/vfs_mount.c
> > > Directory Properties:
> > >   stable/12/   (props changed)
> > > 
> > > Modified: stable/12/sys/kern/kern_environment.c
> > > ==
> > > --- stable/12/sys/kern/kern_environment.c Sat Nov 17 20:00:10 2018
> > > (r340510)
> > > +++ stable/12/sys/kern/kern_environment.c Sat Nov 17 20:01:35 2018
> > > (r340511)
> > > @@ -839,10 +839,13 @@ getenv_quad(const char *name, quad_t *data)
> > >   switch (vtp[0]) {
> > >   case 't': case 'T':
> > >   iv *= 1024;
> > > + /* FALLTHROUGH */
> > >   case 'g': case 'G':
> > >   iv *= 1024;
> > > + /* FALLTHROUGH */
> > >   case 'm': case 'M':
> > >   iv *= 1024;
> > > + /* FALLTHROUGH */
> > >   case 'k': case 'K':
> > >   iv *= 1024;
> > Missing /* FALLTHROUGH */ ??
> 
> The statement following "case '\0':" is a break.
> 
> > 
> > >   case '\0':
> > 
> > And a refactor:
> > 
> > case 't': case 'T':
> > case 'g': case 'G':
> > case 'm': case 'M':
> > case 'k': case 'K':
> > iv *= 1024;
> > /* FALLTHROUGH */
> > case '\0':
> > 
> > Isnt that the same functionality?
> 
> No, it isn't.
Gag, for some reason I was reading iv *=1024 as *iv = 1024,
I need more sleep :-(

-- 
Rod Grimes rgri...@freebsd.org
___
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: r340547 - head/sbin/dumpon

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sun Nov 18 01:58:48 2018
New Revision: 340547
URL: https://svnweb.freebsd.org/changeset/base/340547

Log:
  Change dumpon(8)'s handling of -g.
  
  Rather than using a special value to denote "use the default router",
  treat the absence of the -g option to mean the same thing.  The
  in-kernel netdump client will always attempt to reach the server
  directly before falling back to the configured gateway anyway.  This
  change makes it cleaner to support a hostname value for -g.
  
  Reviewed by:  cem
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D18025

Modified:
  head/sbin/dumpon/dumpon.8
  head/sbin/dumpon/dumpon.c

Modified: head/sbin/dumpon/dumpon.8
==
--- head/sbin/dumpon/dumpon.8   Sun Nov 18 01:27:17 2018(r340546)
+++ head/sbin/dumpon/dumpon.8   Sun Nov 18 01:58:48 2018(r340547)
@@ -28,7 +28,7 @@
 .\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93
 .\" $FreeBSD$
 .\"
-.Dd October 26, 2018
+.Dd November 17, 2018
 .Dt DUMPON 8
 .Os
 .Sh NAME
@@ -46,7 +46,7 @@
 .Op Fl k Ar pubkey
 .Op Fl Z
 .Op Fl z
-.Op Fl g Ar gateway | Li default
+.Op Fl g Ar gateway
 .Fl s Ar server
 .Fl c Ar client
 .Ar iface
@@ -140,21 +140,22 @@ The local IP address of the
 .Xr netdump 4
 client.
 .It Fl g Ar gateway
-Optional.
-If not specified, it is assumed that the
-.Ar server
-is on the same link as the
-.Ar client .
-.Pp
-If specified,
-.Ar gateway
-is the address of the first-hop router between the
+The first-hop router between
 .Ar client
-and the
+and
 .Ar server .
-The special value
-.Dv Dq default
-indicates that the currently configured system default route should be used.
+If the
+.Fl g
+option is not specified and the system has a default route, the default
+router is used as the
+.Xr netdump 4
+gateway.
+If the
+.Fl g
+option is not specified and the system does not have a default route,
+.Ar server
+is assumed to be on the same link as
+.Ar client .
 .It Fl s Ar server
 The IP address of the
 .Xr netdumpd 8

Modified: head/sbin/dumpon/dumpon.c
==
--- head/sbin/dumpon/dumpon.c   Sun Nov 18 01:27:17 2018(r340546)
+++ head/sbin/dumpon/dumpon.c   Sun Nov 18 01:58:48 2018(r340547)
@@ -88,7 +88,7 @@ usage(void)
fprintf(stderr,
 "usage: dumpon [-v] [-k ] [-Zz] \n"
 "   dumpon [-v] [-k ] [-Zz]\n"
-"  [-g |default] -s  -c  \n"
+"  [-g ] -s  -c  \n"
 "   dumpon [-v] off\n"
 "   dumpon [-v] -l\n");
exit(EX_USAGE);
@@ -109,8 +109,6 @@ find_gateway(const char *ifname)
size_t sz;
int error, i, ifindex, mib[7];
 
-   ret = NULL;
-
/* First look up the interface index. */
if (getifaddrs() != 0)
err(EX_OSERR, "getifaddrs");
@@ -148,6 +146,7 @@ find_gateway(const char *ifname)
free(buf);
}
 
+   ret = NULL;
for (next = buf; next < buf + sz; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)(void *)next;
if (rtm->rtm_version != RTM_VERSION)
@@ -476,12 +475,13 @@ main(int argc, char *argv[])
if (inet_aton(client, _client) == 0)
errx(EX_USAGE, "invalid client address '%s'", client);
 
-   if (gateway == NULL)
+   gateway = find_gateway(argv[0]);
+   if (gateway == NULL) {
+   if (verbose)
+   printf("failed to look up gateway for %s\n",
+   server);
gateway = server;
-   else if (strcmp(gateway, "default") == 0 &&
-   (gateway = find_gateway(argv[0])) == NULL)
-   errx(EX_NOHOST,
-   "failed to look up next-hop router for %s", server);
+   }
if (inet_aton(gateway, _gateway) == 0)
errx(EX_USAGE, "invalid gateway address '%s'", gateway);
 
___
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: r340546 - head/sys/vm

2018-11-17 Thread Alan Cox
Author: alc
Date: Sun Nov 18 01:27:17 2018
New Revision: 340546
URL: https://svnweb.freebsd.org/changeset/base/340546

Log:
  Tidy up vm_map_simplify_entry() and its recently introduced helper
  functions.  Notably, reflow the text of some comments so that they
  occupy fewer lines, and introduce an assertion in one of the new
  helper functions so that it is not misused by a future caller.
  
  In collaboration with:Doug Moore 
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D17635

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cSun Nov 18 01:07:36 2018(r340545)
+++ head/sys/vm/vm_map.cSun Nov 18 01:27:17 2018(r340546)
@@ -1644,16 +1644,25 @@ vm_map_find_min(vm_map_t map, vm_object_t object, vm_o
}
 }
 
+/*
+ * A map entry with any of the following flags set must not be merged with
+ * another entry.
+ */
+#defineMAP_ENTRY_NOMERGE_MASK  (MAP_ENTRY_GROWS_DOWN | 
MAP_ENTRY_GROWS_UP | \
+   MAP_ENTRY_IN_TRANSITION | MAP_ENTRY_IS_SUB_MAP)
+
 static bool
 vm_map_mergeable_neighbors(vm_map_entry_t prev, vm_map_entry_t entry)
 {
-   vm_size_t prevsize;
 
-   prevsize = prev->end - prev->start;
+   KASSERT((prev->eflags & MAP_ENTRY_NOMERGE_MASK) == 0 ||
+   (entry->eflags & MAP_ENTRY_NOMERGE_MASK) == 0,
+   ("vm_map_mergeable_neighbors: neither %p nor %p are mergeable",
+   prev, entry));
return (prev->end == entry->start &&
prev->object.vm_object == entry->object.vm_object &&
(prev->object.vm_object == NULL ||
-   prev->offset + prevsize == entry->offset) &&
+   prev->offset + (prev->end - prev->start) == entry->offset) &&
prev->eflags == entry->eflags &&
prev->protection == entry->protection &&
prev->max_protection == entry->max_protection &&
@@ -1667,18 +1676,14 @@ vm_map_merged_neighbor_dispose(vm_map_t map, vm_map_en
 {
 
/*
-* If the backing object is a vnode object,
-* vm_object_deallocate() calls vrele().
-* However, vrele() does not lock the vnode
-* because the vnode has additional
-* references.  Thus, the map lock can be kept
-* without causing a lock-order reversal with
-* the vnode lock.
+* If the backing object is a vnode object, vm_object_deallocate()
+* calls vrele().  However, vrele() does not lock the vnode because
+* the vnode has additional references.  Thus, the map lock can be
+* kept without causing a lock-order reversal with the vnode lock.
 *
-* Since we count the number of virtual page
-* mappings in object->un_pager.vnp.writemappings,
-* the writemappings value should not be adjusted
-* when the entry is disposed of.
+* Since we count the number of virtual page mappings in
+* object->un_pager.vnp.writemappings, the writemappings value
+* should not be adjusted when the entry is disposed of.
 */
if (entry->object.vm_object != NULL)
vm_object_deallocate(entry->object.vm_object);
@@ -1704,10 +1709,8 @@ vm_map_simplify_entry(vm_map_t map, vm_map_entry_t ent
 {
vm_map_entry_t next, prev;
 
-   if ((entry->eflags & (MAP_ENTRY_GROWS_DOWN | MAP_ENTRY_GROWS_UP |
-   MAP_ENTRY_IN_TRANSITION | MAP_ENTRY_IS_SUB_MAP)) != 0)
+   if ((entry->eflags & MAP_ENTRY_NOMERGE_MASK) != 0)
return;
-
prev = entry->prev;
if (vm_map_mergeable_neighbors(prev, entry)) {
vm_map_entry_unlink(map, prev);
@@ -1717,7 +1720,6 @@ vm_map_simplify_entry(vm_map_t map, vm_map_entry_t ent
vm_map_entry_resize_free(map, entry->prev);
vm_map_merged_neighbor_dispose(map, prev);
}
-
next = entry->next;
if (vm_map_mergeable_neighbors(entry, next)) {
vm_map_entry_unlink(map, next);
@@ -1726,6 +1728,7 @@ vm_map_simplify_entry(vm_map_t map, vm_map_entry_t ent
vm_map_merged_neighbor_dispose(map, next);
}
 }
+
 /*
  * vm_map_clip_start:  [ internal use only ]
  *
___
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: r340545 - in stable/11/sys/amd64: include vmm/amd vmm/intel

2018-11-17 Thread John Baldwin
Author: jhb
Date: Sun Nov 18 01:07:36 2018
New Revision: 340545
URL: https://svnweb.freebsd.org/changeset/base/340545

Log:
  MFC 339312,339364: Restore more descriptors during VM exits.
  
  339312:
  Fully restore the GDTR, IDTR, and LDTR after VT-x VM exits.
  
  The VT-x VMCS only stores the base address of the GDTR and IDTR.  As a
  result, VM exits use a fixed limit of 0x for the host GDTR and
  IDTR losing the smaller limits set in when the initial GDT is loaded
  on each CPU during boot.  Explicitly save and restore the full GDTR
  and IDTR contents around VM entries and exits to restore the correct
  limit.
  
  Similarly, explicitly save and restore the LDT selector.  VM exits
  always clear the host LDTR as if the LDT was loaded with a NULL
  selector and a userspace hypervisor is probably using a NULL selector
  anyway, but save and restore the LDT explicitly just to be safe.
  
  339364:
  Reload the LDT selector after an AMD-v #VMEXIT.
  
  cpu_switch() always reloads the LDT, so this can only affect the
  hypervisor process itself.  Fix this by explicitly reloading the host
  LDT selector after each #VMEXIT.  The stock bhyve process on FreeBSD
  never uses a custom LDT, so this change is cosmetic.
  
  PR:   230773

Modified:
  stable/11/sys/amd64/include/cpufunc.h
  stable/11/sys/amd64/vmm/amd/svm.c
  stable/11/sys/amd64/vmm/intel/vmx.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/include/cpufunc.h
==
--- stable/11/sys/amd64/include/cpufunc.h   Sun Nov 18 01:04:53 2018
(r340544)
+++ stable/11/sys/amd64/include/cpufunc.h   Sun Nov 18 01:07:36 2018
(r340545)
@@ -726,6 +726,15 @@ lldt(u_short sel)
__asm __volatile("lldt %0" : : "r" (sel));
 }
 
+static __inline u_short
+sldt(void)
+{
+   u_short sel;
+
+   __asm __volatile("sldt %0" : "=r" (sel));
+   return (sel);
+}
+
 static __inline void
 ltr(u_short sel)
 {

Modified: stable/11/sys/amd64/vmm/amd/svm.c
==
--- stable/11/sys/amd64/vmm/amd/svm.c   Sun Nov 18 01:04:53 2018
(r340544)
+++ stable/11/sys/amd64/vmm/amd/svm.c   Sun Nov 18 01:07:36 2018
(r340545)
@@ -1940,6 +1940,7 @@ svm_vmrun(void *arg, int vcpu, register_t rip, pmap_t 
struct vm *vm;
uint64_t vmcb_pa;
int handled;
+   uint16_t ldt_sel;
 
svm_sc = arg;
vm = svm_sc->vm;
@@ -2018,6 +2019,15 @@ svm_vmrun(void *arg, int vcpu, register_t rip, pmap_t 
break;
}
 
+   /*
+* #VMEXIT resumes the host with the guest LDTR, so
+* save the current LDT selector so it can be restored
+* after an exit.  The userspace hypervisor probably
+* doesn't use a LDT, but save and restore it to be
+* safe.
+*/
+   ldt_sel = sldt();
+
svm_inj_interrupts(svm_sc, vcpu, vlapic);
 
/* Activate the nested pmap on 'curcpu' */
@@ -2047,6 +2057,9 @@ svm_vmrun(void *arg, int vcpu, register_t rip, pmap_t 
 * to be restored explicitly.
 */
restore_host_tss();
+
+   /* Restore host LDTR. */
+   lldt(ldt_sel);
 
/* #VMEXIT disables interrupts so re-enable them here. */ 
enable_gintr();

Modified: stable/11/sys/amd64/vmm/intel/vmx.c
==
--- stable/11/sys/amd64/vmm/intel/vmx.c Sun Nov 18 01:04:53 2018
(r340544)
+++ stable/11/sys/amd64/vmm/intel/vmx.c Sun Nov 18 01:07:36 2018
(r340545)
@@ -2701,6 +2701,8 @@ vmx_run(void *arg, int vcpu, register_t rip, pmap_t pm
struct vm_exit *vmexit;
struct vlapic *vlapic;
uint32_t exit_reason;
+   struct region_descriptor gdtr, idtr;
+   uint16_t ldt_sel;
 
vmx = arg;
vm = vmx->vm;
@@ -2786,10 +2788,30 @@ vmx_run(void *arg, int vcpu, register_t rip, pmap_t pm
break;
}
 
+   /*
+* VM exits restore the base address but not the
+* limits of GDTR and IDTR.  The VMCS only stores the
+* base address, so VM exits set the limits to 0x.
+* Save and restore the full GDTR and IDTR to restore
+* the limits.
+*
+* The VMCS does not save the LDTR at all, and VM
+* exits clear LDTR as if a NULL selector were loaded.
+* The userspace hypervisor probably doesn't use a
+* LDT, but save and restore it to be safe.
+*/
+   sgdt();
+   sidt();
+   ldt_sel = sldt();
+
vmx_run_trace(vmx, vcpu);

svn commit: r340544 - in stable/11: sbin/ipfw sys/conf sys/modules/ipfw_nat64 sys/netpfil/ipfw/nat64

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 01:04:53 2018
New Revision: 340544
URL: https://svnweb.freebsd.org/changeset/base/340544

Log:
  Revert r340541. It requires VNET_DEFINE_STATIC() macro that is not yet
  merged into stable/11.

Modified:
  stable/11/sbin/ipfw/ipfw.8
  stable/11/sys/conf/options
  stable/11/sys/modules/ipfw_nat64/Makefile
  stable/11/sys/netpfil/ipfw/nat64/ip_fw_nat64.c
  stable/11/sys/netpfil/ipfw/nat64/nat64_translate.c
  stable/11/sys/netpfil/ipfw/nat64/nat64_translate.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/ipfw/ipfw.8
==
--- stable/11/sbin/ipfw/ipfw.8  Sun Nov 18 00:52:27 2018(r340543)
+++ stable/11/sbin/ipfw/ipfw.8  Sun Nov 18 01:04:53 2018(r340544)
@@ -1,7 +1,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 21, 2018
+.Dd September 27, 2018
 .Dt IPFW 8
 .Os
 .Sh NAME
@@ -3284,14 +3284,9 @@ Make sure that ND6 neighbor solicitation (ICMPv6 type 
 advertisement (ICMPv6 type 136) messages will not be handled by translation
 rules.
 .Pp
-After translation NAT64 translator by default sends packets through
-corresponding netisr queue.
+After translation NAT64 translator sends packets through corresponding netisr
+queue.
 Thus translator host should be configured as IPv4 and IPv6 router.
-Also this means, that a packet is handled by firewall twice.
-First time an original packet is handled and consumed by translator,
-and then it is handled again as translated packet.
-This behavior can be changed by sysctl variable 
-.Va net.inet.ip.fw.nat64_direct_output .
 .Pp
 The stateful NAT64 configuration command is the following:
 .Bd -ragged -offset indent
@@ -3914,41 +3909,6 @@ Default is no.
 Controls whether bridged packets are passed to
 .Nm .
 Default is no.
-.It Va net.inet.ip.fw.nat64_allow_private : No 0
-Defines how
-.Nm nat64
-handles private IPv4 addresses:
-.Bl -tag -width indent
-.It Cm 0
-Packets with private IPv4 will not be handled by translator
-.It Cm 1
-Translator will accept and process packets with private IPv4 addresses.
-.El
-.It Va net.inet.ip.fw.nat64_debug : No 0
-Controls debugging messages produced by
-.Nm ipfw_nat64
-module.
-.It Va net.inet.ip.fw.nat64_direct_output : No 0
-Controls the output method used by
-.Nm ipfw_nat64
-module:
-.Bl -tag -width indent
-.It Cm 0
-A packet is handled by 
-.Nm ipfw
-twice.
-First time an original packet is handled by
-.Nm ipfw
-and consumed by
-.Nm ipfw_nat64
-translator.
-Then translated packet is queued via netisr to input processing again.
-.It Cm 1
-A packet is handled by
-.Nm ipfw
-only once, and after translation it will be pushed directly to outgoing
-interface.
-.El
 .El
 .Sh INTERNAL DIAGNOSTICS
 There are some commands that may be useful to understand current state

Modified: stable/11/sys/conf/options
==
--- stable/11/sys/conf/options  Sun Nov 18 00:52:27 2018(r340543)
+++ stable/11/sys/conf/options  Sun Nov 18 01:04:53 2018(r340544)
@@ -422,6 +422,7 @@ IPFIREWALL  opt_ipfw.h
 IPFIREWALL_DEFAULT_TO_ACCEPT   opt_ipfw.h
 IPFIREWALL_NAT opt_ipfw.h
 IPFIREWALL_NAT64   opt_ipfw.h
+IPFIREWALL_NAT64_DIRECT_OUTPUT opt_ipfw.h
 IPFIREWALL_NPTV6   opt_ipfw.h
 IPFIREWALL_VERBOSE opt_ipfw.h
 IPFIREWALL_VERBOSE_LIMIT   opt_ipfw.h

Modified: stable/11/sys/modules/ipfw_nat64/Makefile
==
--- stable/11/sys/modules/ipfw_nat64/Makefile   Sun Nov 18 00:52:27 2018
(r340543)
+++ stable/11/sys/modules/ipfw_nat64/Makefile   Sun Nov 18 01:04:53 2018
(r340544)
@@ -6,5 +6,8 @@ KMOD=   ipfw_nat64
 SRCS=  ip_fw_nat64.c nat64_translate.c
 SRCS+= nat64lsn.c nat64lsn_control.c
 SRCS+= nat64stl.c nat64stl_control.c
+SRCS+= opt_ipfw.h
+
+#CFLAGS+=  -DIPFIREWALL_NAT64_DIRECT_OUTPUT
 
 .include 

Modified: stable/11/sys/netpfil/ipfw/nat64/ip_fw_nat64.c
==
--- stable/11/sys/netpfil/ipfw/nat64/ip_fw_nat64.c  Sun Nov 18 00:52:27 
2018(r340543)
+++ stable/11/sys/netpfil/ipfw/nat64/ip_fw_nat64.c  Sun Nov 18 01:04:53 
2018(r340544)
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include "ip_fw_nat64.h"
-#include "nat64_translate.h"
 
 VNET_DEFINE(int, nat64_debug) = 0;
 VNET_DEFINE(int, nat64_allow_private) = 0;
@@ -57,26 +56,8 @@ SYSCTL_DECL(_net_inet_ip_fw);
 SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, nat64_debug, CTLFLAG_VNET | CTLFLAG_RW,
 _NAME(nat64_debug), 0, "Debug level for NAT64 module");
 SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, nat64_allow_private,
-CTLFLAG_VNET | CTLFLAG_RW, _NAME(nat64_allow_private), 0,
+CTLFLAG_VNET |CTLFLAG_RW, _NAME(nat64_allow_private), 0,
 "Allow use of non-global IPv4 addresses with NAT64");
-
-static int
-sysctl_direct_output(SYSCTL_HANDLER_ARGS)
-{
-   uint32_t value;
- 

svn commit: r340543 - head/sys/dev/sdhci

2018-11-17 Thread Marius Strobl
Author: marius
Date: Sun Nov 18 00:52:27 2018
New Revision: 340543
URL: https://svnweb.freebsd.org/changeset/base/340543

Log:
  Add a quirk handling for AMDI0040 controllers allowing them to do HS400.
  
  Submitted by: Shreyank Amartya (original version)

Modified:
  head/sys/dev/sdhci/sdhci.c
  head/sys/dev/sdhci/sdhci.h
  head/sys/dev/sdhci/sdhci_acpi.c

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Sun Nov 18 00:35:36 2018(r340542)
+++ head/sys/dev/sdhci/sdhci.c  Sun Nov 18 00:52:27 2018(r340543)
@@ -898,6 +898,9 @@ sdhci_init_slot(device_t dev, struct sdhci_slot *slot,
if (slot->quirks & SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 &&
caps2 & SDHCI_CAN_MMC_HS400)
host_caps |= MMC_CAP_MMC_HS400;
+   if (slot->quirks & SDHCI_QUIRK_MMC_HS400_IF_CAN_SDR104 &&
+   caps2 & SDHCI_CAN_SDR104)
+   host_caps |= MMC_CAP_MMC_HS400;
 
/*
 * Disable UHS-I and eMMC modes if the set_uhs_timing method is the

Modified: head/sys/dev/sdhci/sdhci.h
==
--- head/sys/dev/sdhci/sdhci.h  Sun Nov 18 00:35:36 2018(r340542)
+++ head/sys/dev/sdhci/sdhci.h  Sun Nov 18 00:52:27 2018(r340543)
@@ -93,6 +93,8 @@
 #defineSDHCI_QUIRK_PRESET_VALUE_BROKEN (1 << 27)
 /* Controller does not support or the support for ACMD12 is broken. */
 #defineSDHCI_QUIRK_BROKEN_AUTO_STOP(1 << 28)
+/* Controller supports eMMC HS400 mode if SDHCI_CAN_SDR104 is set. */
+#defineSDHCI_QUIRK_MMC_HS400_IF_CAN_SDR104 (1 << 29)
 
 /*
  * Controller registers

Modified: head/sys/dev/sdhci/sdhci_acpi.c
==
--- head/sys/dev/sdhci/sdhci_acpi.c Sun Nov 18 00:35:36 2018
(r340542)
+++ head/sys/dev/sdhci/sdhci_acpi.c Sun Nov 18 00:52:27 2018
(r340543)
@@ -45,12 +45,15 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 
 #include 
 
 #include "mmcbr_if.h"
 #include "sdhci_if.h"
 
+#defineSDHCI_AMD_RESET_DLL_REG 0x908
+
 static const struct sdhci_acpi_device {
const char* hid;
int uid;
@@ -80,7 +83,8 @@ static const struct sdhci_acpi_device {
SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ "AMDI0040",   0, "AMD eMMC 5.0 Controller",
-   SDHCI_QUIRK_32BIT_DMA_SIZE },
+   SDHCI_QUIRK_32BIT_DMA_SIZE |
+   SDHCI_QUIRK_MMC_HS400_IF_CAN_SDR104 },
{ NULL, 0, NULL, 0}
 };
 
@@ -94,12 +98,11 @@ static char *sdhci_ids[] = {
 };
 
 struct sdhci_acpi_softc {
-   u_int   quirks; /* Chip specific quirks */
-   struct resource *irq_res;   /* IRQ resource */
-   void*intrhand;  /* Interrupt handle */
-
struct sdhci_slot slot;
struct resource *mem_res;   /* Memory resource */
+   struct resource *irq_res;   /* IRQ resource */
+   void*intrhand;  /* Interrupt handle */
+   const struct sdhci_acpi_device *acpi_dev;
 };
 
 static void sdhci_acpi_intr(void *arg);
@@ -189,6 +192,52 @@ sdhci_acpi_write_multi_4(device_t dev, struct sdhci_sl
bus_write_multi_stream_4(sc->mem_res, off, data, count);
 }
 
+static void
+sdhci_acpi_set_uhs_timing(device_t dev, struct sdhci_slot *slot)
+{
+   const struct sdhci_acpi_softc *sc;
+   const struct sdhci_acpi_device *acpi_dev;
+   const struct mmc_ios *ios;
+   device_t bus;
+   uint16_t old_timing;
+   enum mmc_bus_timing timing;
+
+   bus = slot->bus;
+   old_timing = sdhci_acpi_read_2(bus, slot, SDHCI_HOST_CONTROL2);
+   old_timing &= SDHCI_CTRL2_UHS_MASK;
+   sdhci_generic_set_uhs_timing(dev, slot);
+
+   sc = device_get_softc(dev);
+   acpi_dev = sc->acpi_dev;
+   /*
+* AMDI0040 controllers require SDHCI_CTRL2_SAMPLING_CLOCK to be
+* disabled when switching from HS200 to high speed and to always
+* be turned on again when tuning for HS400.  In the later case,
+* an AMD-specific DLL reset additionally is needed.
+*/
+   if (strcmp(acpi_dev->hid, "AMDI0040") == 0 && acpi_dev->uid == 0) {
+   ios = >host.ios;
+   timing = ios->timing;
+   if (old_timing == SDHCI_CTRL2_UHS_SDR104 &&
+   timing == bus_timing_hs)
+   sdhci_acpi_write_2(bus, slot, SDHCI_HOST_CONTROL2,
+   sdhci_acpi_read_2(bus, slot, SDHCI_HOST_CONTROL2) &
+   ~SDHCI_CTRL2_SAMPLING_CLOCK);
+   if (ios->clock > SD_SDR50_MAX &&
+   old_timing != SDHCI_CTRL2_MMC_HS400 &&
+   timing == bus_timing_mmc_hs400) {
+   

svn commit: r340542 - stable/11/sys/netpfil/ipfw/nat64

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 00:35:36 2018
New Revision: 340542
URL: https://svnweb.freebsd.org/changeset/base/340542

Log:
  MFC r339544:
Call inet_ntop() only when its result is needed.
  
Obtained from:  Yandex LLC
Sponsored by:   Yandex LLC

Modified:
  stable/11/sys/netpfil/ipfw/nat64/nat64lsn.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netpfil/ipfw/nat64/nat64lsn.c
==
--- stable/11/sys/netpfil/ipfw/nat64/nat64lsn.c Sun Nov 18 00:34:24 2018
(r340541)
+++ stable/11/sys/netpfil/ipfw/nat64/nat64lsn.c Sun Nov 18 00:35:36 2018
(r340542)
@@ -643,7 +643,6 @@ static NAT64NOINLINE int
 nat64lsn_periodic_chkhost(struct nat64lsn_host *nh,
 struct nat64lsn_periodic_data *d)
 {
-   char a[INET6_ADDRSTRLEN];
struct nat64lsn_portgroup *pg;
struct nat64lsn_job_item *ji;
uint64_t delmask[NAT64LSN_PGPTRNMASK];
@@ -652,9 +651,13 @@ nat64lsn_periodic_chkhost(struct nat64lsn_host *nh,
delcount = 0;
memset(delmask, 0, sizeof(delmask));
 
-   inet_ntop(AF_INET6, >addr, a, sizeof(a));
-   DPRINTF(DP_JQUEUE, "Checking %s host %s on cpu %d",
-   stale_nh(d->cfg, nh) ? "stale" : "non-stale", a, curcpu);
+   if (V_nat64_debug & DP_JQUEUE) {
+   char a[INET6_ADDRSTRLEN];
+
+   inet_ntop(AF_INET6, >addr, a, sizeof(a));
+   DPRINTF(DP_JQUEUE, "Checking %s host %s on cpu %d",
+   stale_nh(d->cfg, nh) ? "stale" : "non-stale", a, curcpu);
+   }
if (!stale_nh(d->cfg, nh)) {
/* Non-stale host. Inspect internals */
NAT64_LOCK(nh);
@@ -1527,9 +1530,9 @@ nat64lsn_translate6(struct nat64lsn_cfg *cfg, struct i
if (k++ > 1000) {
DPRINTF(DP_ALL, "XXX: too long %d/%d %d/%d\n",
sidx.idx, sidx.off, st->next.idx, st->next.off);
-   inet_ntop(AF_INET6, >addr, a, sizeof(a));
DPRINTF(DP_GENERIC, "TR host %s %p on cpu %d",
-   a, nh, curcpu);
+   inet_ntop(AF_INET6, >addr, a, sizeof(a)),
+   nh, curcpu);
k = 0;
}
sidx = st->next;
@@ -1542,10 +1545,10 @@ nat64lsn_translate6(struct nat64lsn_cfg *cfg, struct i
/* No free states. Request more if we can */
if (nh->pg_used >= cfg->max_chunks) {
/* Limit reached */
-   inet_ntop(AF_INET6, >addr, a, sizeof(a));
DPRINTF(DP_DROPS, "PG limit reached "
" for host %s (used %u, allocated %u, "
-   "limit %u)", a,
+   "limit %u)", inet_ntop(AF_INET6,
+   >addr, a, sizeof(a)),
nh->pg_used * NAT64_CHUNK_SIZE,
nh->pg_allocated * NAT64_CHUNK_SIZE,
cfg->max_chunks * NAT64_CHUNK_SIZE);
___
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: r340541 - in stable/11: sbin/ipfw sys/conf sys/modules/ipfw_nat64 sys/netpfil/ipfw/nat64

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 00:34:24 2018
New Revision: 340541
URL: https://svnweb.freebsd.org/changeset/base/340541

Log:
  MFC r339542:
Retire IPFIREWALL_NAT64_DIRECT_OUTPUT kernel option. And add ability
to switch the output method in run-time. Also document some sysctl
variables that can by changed for NAT64 module.
  
NAT64 had compile time option IPFIREWALL_NAT64_DIRECT_OUTPUT to use
if_output directly from nat64 module. By default is used netisr based
output method. Now both methods can be used, but they require different
handling by rules.
  
Obtained from:  Yandex LLC
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D16647

Modified:
  stable/11/sbin/ipfw/ipfw.8
  stable/11/sys/conf/options
  stable/11/sys/modules/ipfw_nat64/Makefile
  stable/11/sys/netpfil/ipfw/nat64/ip_fw_nat64.c
  stable/11/sys/netpfil/ipfw/nat64/nat64_translate.c
  stable/11/sys/netpfil/ipfw/nat64/nat64_translate.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/ipfw/ipfw.8
==
--- stable/11/sbin/ipfw/ipfw.8  Sun Nov 18 00:31:09 2018(r340540)
+++ stable/11/sbin/ipfw/ipfw.8  Sun Nov 18 00:34:24 2018(r340541)
@@ -1,7 +1,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 27, 2018
+.Dd October 21, 2018
 .Dt IPFW 8
 .Os
 .Sh NAME
@@ -3284,9 +3284,14 @@ Make sure that ND6 neighbor solicitation (ICMPv6 type 
 advertisement (ICMPv6 type 136) messages will not be handled by translation
 rules.
 .Pp
-After translation NAT64 translator sends packets through corresponding netisr
-queue.
+After translation NAT64 translator by default sends packets through
+corresponding netisr queue.
 Thus translator host should be configured as IPv4 and IPv6 router.
+Also this means, that a packet is handled by firewall twice.
+First time an original packet is handled and consumed by translator,
+and then it is handled again as translated packet.
+This behavior can be changed by sysctl variable 
+.Va net.inet.ip.fw.nat64_direct_output .
 .Pp
 The stateful NAT64 configuration command is the following:
 .Bd -ragged -offset indent
@@ -3909,6 +3914,41 @@ Default is no.
 Controls whether bridged packets are passed to
 .Nm .
 Default is no.
+.It Va net.inet.ip.fw.nat64_allow_private : No 0
+Defines how
+.Nm nat64
+handles private IPv4 addresses:
+.Bl -tag -width indent
+.It Cm 0
+Packets with private IPv4 will not be handled by translator
+.It Cm 1
+Translator will accept and process packets with private IPv4 addresses.
+.El
+.It Va net.inet.ip.fw.nat64_debug : No 0
+Controls debugging messages produced by
+.Nm ipfw_nat64
+module.
+.It Va net.inet.ip.fw.nat64_direct_output : No 0
+Controls the output method used by
+.Nm ipfw_nat64
+module:
+.Bl -tag -width indent
+.It Cm 0
+A packet is handled by 
+.Nm ipfw
+twice.
+First time an original packet is handled by
+.Nm ipfw
+and consumed by
+.Nm ipfw_nat64
+translator.
+Then translated packet is queued via netisr to input processing again.
+.It Cm 1
+A packet is handled by
+.Nm ipfw
+only once, and after translation it will be pushed directly to outgoing
+interface.
+.El
 .El
 .Sh INTERNAL DIAGNOSTICS
 There are some commands that may be useful to understand current state

Modified: stable/11/sys/conf/options
==
--- stable/11/sys/conf/options  Sun Nov 18 00:31:09 2018(r340540)
+++ stable/11/sys/conf/options  Sun Nov 18 00:34:24 2018(r340541)
@@ -422,7 +422,6 @@ IPFIREWALL  opt_ipfw.h
 IPFIREWALL_DEFAULT_TO_ACCEPT   opt_ipfw.h
 IPFIREWALL_NAT opt_ipfw.h
 IPFIREWALL_NAT64   opt_ipfw.h
-IPFIREWALL_NAT64_DIRECT_OUTPUT opt_ipfw.h
 IPFIREWALL_NPTV6   opt_ipfw.h
 IPFIREWALL_VERBOSE opt_ipfw.h
 IPFIREWALL_VERBOSE_LIMIT   opt_ipfw.h

Modified: stable/11/sys/modules/ipfw_nat64/Makefile
==
--- stable/11/sys/modules/ipfw_nat64/Makefile   Sun Nov 18 00:31:09 2018
(r340540)
+++ stable/11/sys/modules/ipfw_nat64/Makefile   Sun Nov 18 00:34:24 2018
(r340541)
@@ -6,8 +6,5 @@ KMOD=   ipfw_nat64
 SRCS=  ip_fw_nat64.c nat64_translate.c
 SRCS+= nat64lsn.c nat64lsn_control.c
 SRCS+= nat64stl.c nat64stl_control.c
-SRCS+= opt_ipfw.h
-
-#CFLAGS+=  -DIPFIREWALL_NAT64_DIRECT_OUTPUT
 
 .include 

Modified: stable/11/sys/netpfil/ipfw/nat64/ip_fw_nat64.c
==
--- stable/11/sys/netpfil/ipfw/nat64/ip_fw_nat64.c  Sun Nov 18 00:31:09 
2018(r340540)
+++ stable/11/sys/netpfil/ipfw/nat64/ip_fw_nat64.c  Sun Nov 18 00:34:24 
2018(r340541)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include "ip_fw_nat64.h"
+#include "nat64_translate.h"
 
 VNET_DEFINE(int, nat64_debug) = 0;
 VNET_DEFINE(int, nat64_allow_private) = 0;
@@ -56,8 +57,26 @@ 

svn commit: r340540 - stable/11/sys/netipsec

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 00:31:09 2018
New Revision: 340540
URL: https://svnweb.freebsd.org/changeset/base/340540

Log:
  MFC r339533:
Add sadb_x_sa2 extension to SADB_ACQUIRE requests.
  
SADB_ACQUIRE requests are send by kernel, when security policy doesn't
have corresponding security association for outbound packet. IKE daemon
usually registers its handler for such messages and when the kernel asks
for SA it can handle this request. Now such requests will contain
additional fields that can help IKE daemon to create SA. And IKE now
can create SAs using only information from SADB_ACQUIRE request, this
is useful when many if_ipsec(4) interfaces are in use and IKE doesn track
security policies that was installed by kernel.
  
Obtained from:  Yandex LLC
Sponsored by:   Yandex LLC

Modified:
  stable/11/sys/netipsec/key.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netipsec/key.c
==
--- stable/11/sys/netipsec/key.cSun Nov 18 00:28:56 2018
(r340539)
+++ stable/11/sys/netipsec/key.cSun Nov 18 00:31:09 2018
(r340540)
@@ -6552,7 +6552,9 @@ key_acquire(const struct secasindex *saidx, struct sec
 
/* XXX proxy address (optional) */
 
-   /* set sadb_x_policy */
+   /*
+* Set sadb_x_policy. This is KAME extension to RFC2367.
+*/
if (sp != NULL) {
m = key_setsadbxpolicy(sp->policy, sp->spidx.dir, sp->id,
sp->priority);
@@ -6563,6 +6565,18 @@ key_acquire(const struct secasindex *saidx, struct sec
m_cat(result, m);
}
 
+   /*
+* Set sadb_x_sa2 extension if saidx->reqid is not zero.
+* This is FreeBSD extension to RFC2367.
+*/
+   if (saidx->reqid != 0) {
+   m = key_setsadbxsa2(saidx->mode, 0, saidx->reqid);
+   if (m == NULL) {
+   error = ENOBUFS;
+   goto fail;
+   }
+   m_cat(result, m);
+   }
/* XXX identity (optional) */
 #if 0
if (idexttype && fqdn) {
___
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: r340539 - in stable/11: sbin/ipfw sys/netinet

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 00:28:56 2018
New Revision: 340539
URL: https://svnweb.freebsd.org/changeset/base/340539

Log:
  MFC r339539:
Add IPFW_RULE_JUSTOPTS flag, that is used by ipfw(8) to mark rule,
that was added using "new rule format". And then, when the kernel
returns rule with this flag, ipfw(8) can correctly show it.
  
Reported by:lev
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D17373

Modified:
  stable/11/sbin/ipfw/ipfw2.c
  stable/11/sys/netinet/ip_fw.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/ipfw/ipfw2.c
==
--- stable/11/sbin/ipfw/ipfw2.c Sun Nov 18 00:27:47 2018(r340538)
+++ stable/11/sbin/ipfw/ipfw2.c Sun Nov 18 00:28:56 2018(r340539)
@@ -2207,6 +2207,12 @@ show_static_rule(struct cmdline_opts *co, struct forma
 */
if (co->comment_only != 0)
goto end;
+
+   if (rule->flags & IPFW_RULE_JUSTOPTS) {
+   state.flags |= HAVE_PROTO | HAVE_SRCIP | HAVE_DSTIP;
+   goto justopts;
+   }
+
print_proto(bp, fo, );
 
/* Print source */
@@ -2219,6 +2225,7 @@ show_static_rule(struct cmdline_opts *co, struct forma
print_address(bp, fo, , dst_opcodes, nitems(dst_opcodes),
O_IP_DSTPORT, HAVE_DSTIP);
 
+justopts:
/* Print the rest of options */
while (print_opcode(bp, fo, , -1))
;
@@ -4340,8 +4347,10 @@ chkarg:
}
} else if (first_cmd != cmd) {
errx(EX_DATAERR, "invalid protocol ``%s''", *av);
-   } else
+   } else {
+   rule->flags |= IPFW_RULE_JUSTOPTS;
goto read_options;
+   }
 OR_BLOCK(get_proto);
 
/*

Modified: stable/11/sys/netinet/ip_fw.h
==
--- stable/11/sys/netinet/ip_fw.h   Sun Nov 18 00:27:47 2018
(r340538)
+++ stable/11/sys/netinet/ip_fw.h   Sun Nov 18 00:28:56 2018
(r340539)
@@ -613,6 +613,7 @@ struct ip_fw_rule {
ipfw_insn   cmd[1]; /* storage for commands */
 };
 #defineIPFW_RULE_NOOPT 0x01/* Has no options in body   
*/
+#defineIPFW_RULE_JUSTOPTS  0x02/* new format of rule body  
*/
 
 /* Unaligned version */
 
___
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: r340538 - stable/11/sys/netpfil/ipfw

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 00:27:47 2018
New Revision: 340538
URL: https://svnweb.freebsd.org/changeset/base/340538

Log:
  MFC r339545:
Do not decrement RST life time if keep_alive is not turned on.
  
This allows use differen values configured by user for sysctl variable
net.inet.ip.fw.dyn_rst_lifetime.
  
Obtained from:  Yandex LLC
Sponsored by:   Yandex LLC

Modified:
  stable/11/sys/netpfil/ipfw/ip_fw_dynamic.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netpfil/ipfw/ip_fw_dynamic.c
==
--- stable/11/sys/netpfil/ipfw/ip_fw_dynamic.c  Sun Nov 18 00:26:09 2018
(r340537)
+++ stable/11/sys/netpfil/ipfw/ip_fw_dynamic.c  Sun Nov 18 00:27:47 2018
(r340538)
@@ -978,7 +978,8 @@ dyn_update_tcp_state(struct dyn_data *data, const stru
break;
 
default:
-   if (V_dyn_rst_lifetime >= V_dyn_keepalive_period)
+   if (V_dyn_keepalive != 0 &&
+   V_dyn_rst_lifetime >= V_dyn_keepalive_period)
V_dyn_rst_lifetime = V_dyn_keepalive_period - 1;
expire = time_uptime + V_dyn_rst_lifetime;
}
___
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: r340537 - stable/11/sbin/ifconfig

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 00:26:09 2018
New Revision: 340537
URL: https://svnweb.freebsd.org/changeset/base/340537

Log:
  MFC r339535:
Do not allow use `create` keyword as hostname when ifconfig(8) is invoked
for already existing interface.
  
It appeared, that ifconfig(8) assumes `create` keyword as hostname and
tries to resolve it, when `ifconfig ifname create` invoked for already
existing interface. This can produce some unexpected results, when hostname
resolving has successfully happened. This patch adds check for such case.
When an interface is already exists, and create is only one argument,
return error message. But when there are some other arguments, just remove
create keyword from the arguments list.
  
Obtained from:  Yandex LLC
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D17171
  
  MFC r339536:
Fix grammar.

Modified:
  stable/11/sbin/ifconfig/ifconfig.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/ifconfig/ifconfig.c
==
--- stable/11/sbin/ifconfig/ifconfig.c  Sun Nov 18 00:22:01 2018
(r340536)
+++ stable/11/sbin/ifconfig/ifconfig.c  Sun Nov 18 00:26:09 2018
(r340537)
@@ -501,6 +501,18 @@ main(int argc, char *argv[])
}
 #endif
errx(1, "interface %s does not exist", ifname);
+   } else {
+   /*
+* Do not allow use `create` command as hostname if
+* address family is not specified.
+*/
+   if (argc > 0 && (strcmp(argv[0], "create") == 0 ||
+   strcmp(argv[0], "plumb") == 0)) {
+   if (argc == 1)
+   errx(1, "interface %s already exists",
+   ifname);
+   argc--, argv++;
+   }
}
}
 
___
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: r340536 - stable/12/sys/net

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 00:22:01 2018
New Revision: 340536
URL: https://svnweb.freebsd.org/changeset/base/340536

Log:
  MFC r339554:
Rework if_ipsec(4) to use epoch(9) instead of rmlock.
  
* use CK_LIST and FNV hash to keep chains of softc;
* read access to softc is protected by epoch();
* write access is protected by ipsec_ioctl_sx. Changing of softc fields
  is allowed only when softc is unlinked from CK_LIST chains.
* linking/unlinking of softc is allowed only when ipsec_ioctl_sx is
  exclusive locked.
* the plain LIST of all softc is replaced by hash table that uses ingress
  address of tunnels as a key.
* added support for appearing/disappearing of ingress address handling.
  Now it is allowed configure non-local ingress IP address, and thus the
  problem with if_ipsec(4) configuration that happens on boot, when
  ingress address is not yet configured, is solved.
  
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D17190
  
  MFC r339555:
Follow the fix in r339532 (by glebius):
  Fix exiting an epoch(9) we never entered. May happen only with MAC.
  
  MFC r339642:
Remove softc from idhash when interface is destroyed.
  
  MFC r339646:
Add the check that current VNET is ready and access to srchash is
allowed.
  
ipsec_srcaddr() callback can be called during VNET teardown, since
ingress address checking subsystem isn't VNET specific. And thus
callback can make access to already freed memory. To prevent this,
use V_ipsec_idhtbl pointer as indicator of VNET readiness. And make
epoch_wait() after resetting it to NULL in vnet_ipsec_uninit() to
be sure that ipsec_srcaddr() is finished its work.
  
Reported by:kp

Modified:
  stable/12/sys/net/if_ipsec.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/net/if_ipsec.c
==
--- stable/12/sys/net/if_ipsec.cSun Nov 18 00:17:06 2018
(r340535)
+++ stable/12/sys/net/if_ipsec.cSun Nov 18 00:22:01 2018
(r340536)
@@ -1,6 +1,6 @@
 /*-
- * Copyright (c) 2016 Yandex LLC
- * Copyright (c) 2016 Andrey V. Elsukov 
+ * Copyright (c) 2016-2018 Yandex LLC
+ * Copyright (c) 2016-2018 Andrey V. Elsukov 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -61,6 +60,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -87,58 +87,72 @@ static const char ipsecname[] = "ipsec";
 
 struct ipsec_softc {
struct ifnet*ifp;
-
-   struct rmlock   lock;
struct secpolicy*sp[IPSEC_SPCOUNT];
-
uint32_treqid;
u_int   family;
u_int   fibnum;
-   LIST_ENTRY(ipsec_softc) chain;
-   LIST_ENTRY(ipsec_softc) hash;
+
+   CK_LIST_ENTRY(ipsec_softc) idhash;
+   CK_LIST_ENTRY(ipsec_softc) srchash;
 };
 
-#defineIPSEC_LOCK_INIT(sc) rm_init(&(sc)->lock, "if_ipsec softc")
-#defineIPSEC_LOCK_DESTROY(sc)  rm_destroy(&(sc)->lock)
-#defineIPSEC_RLOCK_TRACKER struct rm_priotracker ipsec_tracker
-#defineIPSEC_RLOCK(sc) rm_rlock(&(sc)->lock, _tracker)
-#defineIPSEC_RUNLOCK(sc)   rm_runlock(&(sc)->lock, _tracker)
-#defineIPSEC_RLOCK_ASSERT(sc)  rm_assert(&(sc)->lock, RA_RLOCKED)
-#defineIPSEC_WLOCK(sc) rm_wlock(&(sc)->lock)
-#defineIPSEC_WUNLOCK(sc)   rm_wunlock(&(sc)->lock)
-#defineIPSEC_WLOCK_ASSERT(sc)  rm_assert(&(sc)->lock, RA_WLOCKED)
+#defineIPSEC_RLOCK_TRACKER struct epoch_tracker ipsec_et
+#defineIPSEC_RLOCK()   epoch_enter_preempt(net_epoch_preempt, 
_et)
+#defineIPSEC_RUNLOCK() epoch_exit_preempt(net_epoch_preempt, _et)
+#defineIPSEC_WAIT()epoch_wait_preempt(net_epoch_preempt)
 
-static struct rmlock ipsec_sc_lock;
-RM_SYSINIT(ipsec_sc_lock, _sc_lock, "if_ipsec softc list");
+#ifndef IPSEC_HASH_SIZE
+#defineIPSEC_HASH_SIZE (1 << 5)
+#endif
 
-#defineIPSEC_SC_RLOCK_TRACKER  struct rm_priotracker ipsec_sc_tracker
-#defineIPSEC_SC_RLOCK()rm_rlock(_sc_lock, 
_sc_tracker)
-#defineIPSEC_SC_RUNLOCK()  rm_runlock(_sc_lock, 
_sc_tracker)
-#defineIPSEC_SC_RLOCK_ASSERT() rm_assert(_sc_lock, RA_RLOCKED)
-#defineIPSEC_SC_WLOCK()rm_wlock(_sc_lock)
-#defineIPSEC_SC_WUNLOCK()  rm_wunlock(_sc_lock)
-#defineIPSEC_SC_WLOCK_ASSERT() rm_assert(_sc_lock, RA_WLOCKED)
+CK_LIST_HEAD(ipsec_iflist, ipsec_softc);
+VNET_DEFINE_STATIC(struct ipsec_iflist *, ipsec_idhtbl) = NULL;
+#defineV_ipsec_idhtbl  VNET(ipsec_idhtbl)
 
-LIST_HEAD(ipsec_iflist, 

svn commit: r340535 - in stable/12: share/man/man4 sys/net sys/netinet sys/netinet6

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 00:17:06 2018
New Revision: 340535
URL: https://svnweb.freebsd.org/changeset/base/340535

Log:
  MFC r339551:
Add handling for appearing/disappearing of ingress addresses to if_gif(4).
  
* register handler for ingress address appearing/disappearing;
* add new srcaddr hash table for fast softc lookup by srcaddr;
* when srcaddr disappears, clear IFF_DRV_RUNNING flag from interface,
  and set it otherwise;
* remove the note about ingress address from BUGS section.
  
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D17134
  
  MFC r339552:
Add handling for appearing/disappearing of ingress addresses to if_gre(4).
  
* register handler for ingress address appearing/disappearing;
* add new srcaddr hash table for fast softc lookup by srcaddr;
* when srcaddr disappears, clear IFF_DRV_RUNNING flag from interface,
  and set it otherwise;
  
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D17214
  
  MFC r339553:
Add handling for appearing/disappearing of ingress addresses to if_me(4).
  
* register handler for ingress address appearing/disappearing;
* add new srcaddr hash table for fast softc lookup by srcaddr;
* when srcaddr disappears, clear IFF_DRV_RUNNING flag from interface,
  and set it otherwise;
  
Sponsored by:   Yandex LLC
  
  MFC r339649:
Add the check that current VNET is ready and access to srchash is allowed.
  
This change is similar to r339646. The callback that checks for appearing
and disappearing of tunnel ingress address can be called during VNET
teardown. To prevent access to already freed memory, add check to the
callback and epoch_wait() call to be sure that callback has finished its
work.

Modified:
  stable/12/share/man/man4/gif.4
  stable/12/sys/net/if_gif.c
  stable/12/sys/net/if_gif.h
  stable/12/sys/net/if_gre.c
  stable/12/sys/net/if_gre.h
  stable/12/sys/net/if_me.c
  stable/12/sys/netinet/in_gif.c
  stable/12/sys/netinet/ip_gre.c
  stable/12/sys/netinet6/in6_gif.c
  stable/12/sys/netinet6/ip6_gre.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/gif.4
==
--- stable/12/share/man/man4/gif.4  Sun Nov 18 00:11:19 2018
(r340534)
+++ stable/12/share/man/man4/gif.4  Sun Nov 18 00:17:06 2018
(r340535)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 5, 2018
+.Dd October 21, 2018
 .Dt GIF 4
 .Os
 .Sh NAME
@@ -206,15 +206,6 @@ and are picky about outer header fields.
 For example, you cannot usually use
 .Nm
 to talk with IPsec devices that use IPsec tunnel mode.
-.Pp
-The current code does not check if the ingress address
-(outer source address)
-configured in the
-.Nm
-interface makes sense.
-Make sure to specify an address which belongs to your node.
-Otherwise, your node will not be able to receive packets from the peer,
-and it will generate packets with a spoofed source address.
 .Pp
 If the outer protocol is IPv4,
 .Nm

Modified: stable/12/sys/net/if_gif.c
==
--- stable/12/sys/net/if_gif.c  Sun Nov 18 00:11:19 2018(r340534)
+++ stable/12/sys/net/if_gif.c  Sun Nov 18 00:17:06 2018(r340535)
@@ -284,6 +284,7 @@ gif_transmit(struct ifnet *ifp, struct mbuf *m)
sc = ifp->if_softc;
if ((ifp->if_flags & IFF_MONITOR) != 0 ||
(ifp->if_flags & IFF_UP) == 0 ||
+   (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
sc->gif_family == 0 ||
(error = if_tunnel_check_nesting(ifp, m, MTAG_GIF,
V_max_gif_nesting)) != 0) {
@@ -674,7 +675,6 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
cmd == SIOCSIFPHYADDR_IN6 ||
 #endif
0) {
-   ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_link_state_change(ifp, LINK_STATE_UP);
}
}
@@ -689,6 +689,7 @@ gif_delete_tunnel(struct gif_softc *sc)
 
sx_assert(_ioctl_sx, SA_XLOCKED);
if (sc->gif_family != 0) {
+   CK_LIST_REMOVE(sc, srchash);
CK_LIST_REMOVE(sc, chain);
/* Wait until it become safe to free gif_hdr */
GIF_WAIT();

Modified: stable/12/sys/net/if_gif.h
==
--- stable/12/sys/net/if_gif.h  Sun Nov 18 00:11:19 2018(r340534)
+++ stable/12/sys/net/if_gif.h  Sun Nov 18 00:17:06 2018(r340535)
@@ -63,6 +63,7 @@ struct gif_softc {
} gif_uhdr;
 
CK_LIST_ENTRY(gif_softc) chain;
+   CK_LIST_ENTRY(gif_softc) srchash;
 };
 CK_LIST_HEAD(gif_list, gif_softc);
 MALLOC_DECLARE(M_GIF);

Modified: stable/12/sys/net/if_gre.c

svn commit: r340534 - stable/11/lib/libvmmapi

2018-11-17 Thread John Baldwin
Author: jhb
Date: Sun Nov 18 00:11:19 2018
New Revision: 340534
URL: https://svnweb.freebsd.org/changeset/base/340534

Log:
  MFC 338511: bhyve: Use MAP_GUARD when mapping guest memory ranges.
  
  Instead of relying on PROT_NONE mappings with MAP_ANON, use MAP_GUARD
  to reserve address space around guest memory ranges including the
  guard ranges of address space around mappings.

Modified:
  stable/11/lib/libvmmapi/vmmapi.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libvmmapi/vmmapi.c
==
--- stable/11/lib/libvmmapi/vmmapi.cSun Nov 18 00:09:33 2018
(r340533)
+++ stable/11/lib/libvmmapi/vmmapi.cSun Nov 18 00:11:19 2018
(r340534)
@@ -360,7 +360,7 @@ vm_setup_memory(struct vmctx *ctx, size_t memsize, enu
size_t objsize, len;
vm_paddr_t gpa;
char *baseaddr, *ptr;
-   int error, flags;
+   int error;
 
assert(vms == VM_MMAP_ALL);
 
@@ -387,8 +387,7 @@ vm_setup_memory(struct vmctx *ctx, size_t memsize, enu
 * and the adjoining guard regions.
 */
len = VM_MMAP_GUARD_SIZE + objsize + VM_MMAP_GUARD_SIZE;
-   flags = MAP_PRIVATE | MAP_ANON | MAP_NOCORE | MAP_ALIGNED_SUPER;
-   ptr = mmap(NULL, len, PROT_NONE, flags, -1, 0);
+   ptr = mmap(NULL, len, PROT_NONE, MAP_GUARD | MAP_ALIGNED_SUPER, -1, 0);
if (ptr == MAP_FAILED)
return (-1);
 
@@ -490,8 +489,8 @@ vm_create_devmem(struct vmctx *ctx, int segid, const c
 * adjoining guard regions.
 */
len2 = VM_MMAP_GUARD_SIZE + len + VM_MMAP_GUARD_SIZE;
-   flags = MAP_PRIVATE | MAP_ANON | MAP_NOCORE | MAP_ALIGNED_SUPER;
-   base = mmap(NULL, len2, PROT_NONE, flags, -1, 0);
+   base = mmap(NULL, len2, PROT_NONE, MAP_GUARD | MAP_ALIGNED_SUPER, -1,
+   0);
if (base == MAP_FAILED)
goto done;
 
___
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: r340533 - in stable/12/sys: net netinet

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 00:09:33 2018
New Revision: 340533
URL: https://svnweb.freebsd.org/changeset/base/340533

Log:
  MFC r339550,339556:
Add KPI that can be used by tunneling interfaces to handle IP addresses
appearing and disappearing on the host system.
  
Such handling is need, because tunneling interfaces must use addresses,
that are configured on the host as ingress addresses for tunnels.
Otherwise the system can send spoofed packets with source address, that
belongs to foreign host.
  
The KPI uses ifaddr_event_ext event to implement addresses tracking.
Tunneling interfaces register event handlers and then they are
notified by the kernel, when an address disappears or appears.
  
ifaddr_event_compat() handler from if.c replaced by srcaddr_change_event()
in the ip_encap.c
  
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D17134

Modified:
  stable/12/sys/net/if.c
  stable/12/sys/netinet/ip_encap.c
  stable/12/sys/netinet/ip_encap.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/net/if.c
==
--- stable/12/sys/net/if.c  Sun Nov 18 00:04:03 2018(r340532)
+++ stable/12/sys/net/if.c  Sun Nov 18 00:09:33 2018(r340533)
@@ -328,18 +328,6 @@ static MALLOC_DEFINE(M_IFNET, "ifnet", "interface inte
 MALLOC_DEFINE(M_IFADDR, "ifaddr", "interface address");
 MALLOC_DEFINE(M_IFMADDR, "ether_multi", "link-level multicast address");
 
-/*
- * Support for old ifaddr_event.
- */
-static void
-ifaddr_event_compat(void *arg __unused, struct ifnet *ifp,
-struct ifaddr *ifa __unused, int event __unused)
-{
-
-   EVENTHANDLER_INVOKE(ifaddr_event, ifp);
-}
-EVENTHANDLER_DEFINE(ifaddr_event_ext, ifaddr_event_compat, NULL, 0);
-
 struct ifnet *
 ifnet_byindex_locked(u_short idx)
 {

Modified: stable/12/sys/netinet/ip_encap.c
==
--- stable/12/sys/netinet/ip_encap.cSun Nov 18 00:04:03 2018
(r340532)
+++ stable/12/sys/netinet/ip_encap.cSun Nov 18 00:09:33 2018
(r340533)
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -100,22 +101,139 @@ struct encaptab {
encap_input_t   input;
 };
 
+struct srcaddrtab {
+   CK_LIST_ENTRY(srcaddrtab) chain;
+
+   encap_srcaddr_t srcaddr;
+   void*arg;
+};
+
 CK_LIST_HEAD(encaptab_head, encaptab);
+CK_LIST_HEAD(srcaddrtab_head, srcaddrtab);
 #ifdef INET
 static struct encaptab_head ipv4_encaptab = CK_LIST_HEAD_INITIALIZER();
+static struct srcaddrtab_head ipv4_srcaddrtab = CK_LIST_HEAD_INITIALIZER();
 #endif
 #ifdef INET6
 static struct encaptab_head ipv6_encaptab = CK_LIST_HEAD_INITIALIZER();
+static struct srcaddrtab_head ipv6_srcaddrtab = CK_LIST_HEAD_INITIALIZER();
 #endif
 
-static struct mtx encapmtx;
+static struct mtx encapmtx, srcaddrmtx;
 MTX_SYSINIT(encapmtx, , "encapmtx", MTX_DEF);
+MTX_SYSINIT(srcaddrmtx, , "srcaddrmtx", MTX_DEF);
 #defineENCAP_WLOCK()   mtx_lock()
 #defineENCAP_WUNLOCK() mtx_unlock()
-#defineENCAP_RLOCK()   struct epoch_tracker encap_et; 
epoch_enter_preempt(net_epoch_preempt, _et)
-#defineENCAP_RUNLOCK() epoch_exit_preempt(net_epoch_preempt, 
_et)
+#defineENCAP_RLOCK_TRACKER struct epoch_tracker encap_et
+#defineENCAP_RLOCK()   \
+epoch_enter_preempt(net_epoch_preempt, _et)
+#defineENCAP_RUNLOCK() \
+epoch_exit_preempt(net_epoch_preempt, _et)
 #defineENCAP_WAIT()epoch_wait_preempt(net_epoch_preempt)
 
+#defineSRCADDR_WLOCK() mtx_lock()
+#defineSRCADDR_WUNLOCK()   mtx_unlock()
+#defineSRCADDR_RLOCK_TRACKER   struct epoch_tracker srcaddr_et
+#defineSRCADDR_RLOCK() \
+epoch_enter_preempt(net_epoch_preempt, _et)
+#defineSRCADDR_RUNLOCK()   \
+epoch_exit_preempt(net_epoch_preempt, _et)
+#defineSRCADDR_WAIT()  epoch_wait_preempt(net_epoch_preempt)
+
+/*
+ * ifaddr_event_ext handler.
+ *
+ * Tunnelling interfaces may request the kernel to notify when
+ * some interface addresses appears or disappears. Usually tunnelling
+ * interface must use an address configured on the local machine as
+ * ingress address to be able receive datagramms and do not send
+ * spoofed packets.
+ */
+static void
+srcaddr_change_event(void *arg __unused, struct ifnet *ifp,
+struct ifaddr *ifa, int event)
+{
+   SRCADDR_RLOCK_TRACKER;
+   struct srcaddrtab_head *head;
+   struct srcaddrtab *p;
+
+   /* Support for old ifaddr_event. */
+   EVENTHANDLER_INVOKE(ifaddr_event, ifp);
+
+   switch (ifa->ifa_addr->sa_family) {
+#ifdef INET
+   case AF_INET:
+   head = _srcaddrtab;
+   break;
+#endif

svn commit: r340532 - in stable/12: share/man/man9 sys/net sys/netinet sys/netinet6

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 00:04:03 2018
New Revision: 340532
URL: https://svnweb.freebsd.org/changeset/base/340532

Log:
  MFC r339537:
Add ifaddr_event_ext event. It is similar to ifaddr_event, but the
handler receives the type of event IFADDR_EVENT_ADD/IFADDR_EVENT_DEL,
and the pointer to ifaddr. Also ifaddr_event now is implemented using
ifaddr_event_ext handler.
  
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D17100

Modified:
  stable/12/share/man/man9/EVENTHANDLER.9
  stable/12/sys/net/if.c
  stable/12/sys/net/if_var.h
  stable/12/sys/netinet/in.c
  stable/12/sys/netinet6/in6.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man9/EVENTHANDLER.9
==
--- stable/12/share/man/man9/EVENTHANDLER.9 Sun Nov 18 00:00:39 2018
(r340531)
+++ stable/12/share/man/man9/EVENTHANDLER.9 Sun Nov 18 00:04:03 2018
(r340532)
@@ -23,7 +23,7 @@
 .\" SUCH DAMAGE.
 .\" $FreeBSD$
 .\"
-.Dd September 6, 2018
+.Dd October 21, 2018
 .Dt EVENTHANDLER 9
 .Os
 .Sh NAME
@@ -298,6 +298,8 @@ Callback invoked when an change has been made to an in
 Callback invoked when an interfance has been removed from an interface group.
 .It Vt ifaddr_event
 Callbacks invoked when an address is set up on a network interface.
+.It Vt ifaddr_event_ext
+Callback invoked when an address has been added or removed from an interface. 
 .It Vt if_clone_event
 Callbacks invoked when an interface is cloned.
 .It Vt iflladdr_event

Modified: stable/12/sys/net/if.c
==
--- stable/12/sys/net/if.c  Sun Nov 18 00:00:39 2018(r340531)
+++ stable/12/sys/net/if.c  Sun Nov 18 00:04:03 2018(r340532)
@@ -328,6 +328,18 @@ static MALLOC_DEFINE(M_IFNET, "ifnet", "interface inte
 MALLOC_DEFINE(M_IFADDR, "ifaddr", "interface address");
 MALLOC_DEFINE(M_IFMADDR, "ether_multi", "link-level multicast address");
 
+/*
+ * Support for old ifaddr_event.
+ */
+static void
+ifaddr_event_compat(void *arg __unused, struct ifnet *ifp,
+struct ifaddr *ifa __unused, int event __unused)
+{
+
+   EVENTHANDLER_INVOKE(ifaddr_event, ifp);
+}
+EVENTHANDLER_DEFINE(ifaddr_event_ext, ifaddr_event_compat, NULL, 0);
+
 struct ifnet *
 ifnet_byindex_locked(u_short idx)
 {

Modified: stable/12/sys/net/if_var.h
==
--- stable/12/sys/net/if_var.h  Sun Nov 18 00:00:39 2018(r340531)
+++ stable/12/sys/net/if_var.h  Sun Nov 18 00:04:03 2018(r340532)
@@ -432,6 +432,11 @@ EVENTHANDLER_DECLARE(iflladdr_event, iflladdr_event_ha
 /* interface address change event */
 typedef void (*ifaddr_event_handler_t)(void *, struct ifnet *);
 EVENTHANDLER_DECLARE(ifaddr_event, ifaddr_event_handler_t);
+typedef void (*ifaddr_event_ext_handler_t)(void *, struct ifnet *,
+struct ifaddr *, int);
+EVENTHANDLER_DECLARE(ifaddr_event_ext, ifaddr_event_ext_handler_t);
+#defineIFADDR_EVENT_ADD0
+#defineIFADDR_EVENT_DEL1
 /* new interface arrival event */
 typedef void (*ifnet_arrival_event_handler_t)(void *, struct ifnet *);
 EVENTHANDLER_DECLARE(ifnet_arrival_event, ifnet_arrival_event_handler_t);

Modified: stable/12/sys/netinet/in.c
==
--- stable/12/sys/netinet/in.c  Sun Nov 18 00:00:39 2018(r340531)
+++ stable/12/sys/netinet/in.c  Sun Nov 18 00:04:03 2018(r340532)
@@ -520,7 +520,12 @@ in_aifaddr_ioctl(u_long cmd, caddr_t data, struct ifne
>ii_allhosts);
}
 
-   EVENTHANDLER_INVOKE(ifaddr_event, ifp);
+   /*
+* Note: we don't need extra reference for ifa, since we called
+* with sx lock held, and ifaddr can not be deleted in concurrent
+* thread.
+*/
+   EVENTHANDLER_INVOKE(ifaddr_event_ext, ifp, ifa, IFADDR_EVENT_ADD);
 
return (error);
 
@@ -643,7 +648,8 @@ in_difaddr_ioctl(u_long cmd, caddr_t data, struct ifne
}
IF_ADDR_WUNLOCK(ifp);
 
-   EVENTHANDLER_INVOKE(ifaddr_event, ifp);
+   EVENTHANDLER_INVOKE(ifaddr_event_ext, ifp, >ia_ifa,
+   IFADDR_EVENT_DEL);
ifa_free(>ia_ifa);  /* in_ifaddrhead */
 
return (0);

Modified: stable/12/sys/netinet6/in6.c
==
--- stable/12/sys/netinet6/in6.cSun Nov 18 00:00:39 2018
(r340531)
+++ stable/12/sys/netinet6/in6.cSun Nov 18 00:04:03 2018
(r340532)
@@ -712,7 +712,8 @@ aifaddr_out:
ND6_WUNLOCK();
nd6_prefix_del(pr);
}
-   EVENTHANDLER_INVOKE(ifaddr_event, ifp);
+   EVENTHANDLER_INVOKE(ifaddr_event_ext, ifp, >ia_ifa,
+   

svn commit: r340531 - stable/12/sys/netpfil/ipfw/nat64

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sun Nov 18 00:00:39 2018
New Revision: 340531
URL: https://svnweb.freebsd.org/changeset/base/340531

Log:
  MFC r339544:
Call inet_ntop() only when its result is needed.
  
Obtained from:  Yandex LLC
Sponsored by:   Yandex LLC

Modified:
  stable/12/sys/netpfil/ipfw/nat64/nat64lsn.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netpfil/ipfw/nat64/nat64lsn.c
==
--- stable/12/sys/netpfil/ipfw/nat64/nat64lsn.c Sat Nov 17 23:58:55 2018
(r340530)
+++ stable/12/sys/netpfil/ipfw/nat64/nat64lsn.c Sun Nov 18 00:00:39 2018
(r340531)
@@ -643,7 +643,6 @@ static NAT64NOINLINE int
 nat64lsn_periodic_chkhost(struct nat64lsn_host *nh,
 struct nat64lsn_periodic_data *d)
 {
-   char a[INET6_ADDRSTRLEN];
struct nat64lsn_portgroup *pg;
struct nat64lsn_job_item *ji;
uint64_t delmask[NAT64LSN_PGPTRNMASK];
@@ -652,9 +651,13 @@ nat64lsn_periodic_chkhost(struct nat64lsn_host *nh,
delcount = 0;
memset(delmask, 0, sizeof(delmask));
 
-   inet_ntop(AF_INET6, >addr, a, sizeof(a));
-   DPRINTF(DP_JQUEUE, "Checking %s host %s on cpu %d",
-   stale_nh(d->cfg, nh) ? "stale" : "non-stale", a, curcpu);
+   if (V_nat64_debug & DP_JQUEUE) {
+   char a[INET6_ADDRSTRLEN];
+
+   inet_ntop(AF_INET6, >addr, a, sizeof(a));
+   DPRINTF(DP_JQUEUE, "Checking %s host %s on cpu %d",
+   stale_nh(d->cfg, nh) ? "stale" : "non-stale", a, curcpu);
+   }
if (!stale_nh(d->cfg, nh)) {
/* Non-stale host. Inspect internals */
NAT64_LOCK(nh);
@@ -1527,9 +1530,9 @@ nat64lsn_translate6(struct nat64lsn_cfg *cfg, struct i
if (k++ > 1000) {
DPRINTF(DP_ALL, "XXX: too long %d/%d %d/%d\n",
sidx.idx, sidx.off, st->next.idx, st->next.off);
-   inet_ntop(AF_INET6, >addr, a, sizeof(a));
DPRINTF(DP_GENERIC, "TR host %s %p on cpu %d",
-   a, nh, curcpu);
+   inet_ntop(AF_INET6, >addr, a, sizeof(a)),
+   nh, curcpu);
k = 0;
}
sidx = st->next;
@@ -1542,10 +1545,10 @@ nat64lsn_translate6(struct nat64lsn_cfg *cfg, struct i
/* No free states. Request more if we can */
if (nh->pg_used >= cfg->max_chunks) {
/* Limit reached */
-   inet_ntop(AF_INET6, >addr, a, sizeof(a));
DPRINTF(DP_DROPS, "PG limit reached "
" for host %s (used %u, allocated %u, "
-   "limit %u)", a,
+   "limit %u)", inet_ntop(AF_INET6,
+   >addr, a, sizeof(a)),
nh->pg_used * NAT64_CHUNK_SIZE,
nh->pg_allocated * NAT64_CHUNK_SIZE,
cfg->max_chunks * NAT64_CHUNK_SIZE);
___
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: r340530 - stable/12/sys/netpfil/ipfw

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sat Nov 17 23:58:55 2018
New Revision: 340530
URL: https://svnweb.freebsd.org/changeset/base/340530

Log:
  MFC r339545:
Do not decrement RST life time if keep_alive is not turned on.
  
This allows use differen values configured by user for sysctl variable
net.inet.ip.fw.dyn_rst_lifetime.
  
Obtained from:  Yandex LLC
Sponsored by:   Yandex LLC

Modified:
  stable/12/sys/netpfil/ipfw/ip_fw_dynamic.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netpfil/ipfw/ip_fw_dynamic.c
==
--- stable/12/sys/netpfil/ipfw/ip_fw_dynamic.c  Sat Nov 17 23:57:46 2018
(r340529)
+++ stable/12/sys/netpfil/ipfw/ip_fw_dynamic.c  Sat Nov 17 23:58:55 2018
(r340530)
@@ -979,7 +979,8 @@ dyn_update_tcp_state(struct dyn_data *data, const stru
break;
 
default:
-   if (V_dyn_rst_lifetime >= V_dyn_keepalive_period)
+   if (V_dyn_keepalive != 0 &&
+   V_dyn_rst_lifetime >= V_dyn_keepalive_period)
V_dyn_rst_lifetime = V_dyn_keepalive_period - 1;
expire = time_uptime + V_dyn_rst_lifetime;
}
___
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: r340529 - in stable/12: sbin/ipfw sys/netinet

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sat Nov 17 23:57:46 2018
New Revision: 340529
URL: https://svnweb.freebsd.org/changeset/base/340529

Log:
  MFC r339539:
Add IPFW_RULE_JUSTOPTS flag, that is used by ipfw(8) to mark rule,
that was added using "new rule format". And then, when the kernel
returns rule with this flag, ipfw(8) can correctly show it.
  
Reported by:lev
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D17373

Modified:
  stable/12/sbin/ipfw/ipfw2.c
  stable/12/sys/netinet/ip_fw.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/ipfw/ipfw2.c
==
--- stable/12/sbin/ipfw/ipfw2.c Sat Nov 17 23:56:25 2018(r340528)
+++ stable/12/sbin/ipfw/ipfw2.c Sat Nov 17 23:57:46 2018(r340529)
@@ -2207,6 +2207,12 @@ show_static_rule(struct cmdline_opts *co, struct forma
 */
if (co->comment_only != 0)
goto end;
+
+   if (rule->flags & IPFW_RULE_JUSTOPTS) {
+   state.flags |= HAVE_PROTO | HAVE_SRCIP | HAVE_DSTIP;
+   goto justopts;
+   }
+
print_proto(bp, fo, );
 
/* Print source */
@@ -2219,6 +2225,7 @@ show_static_rule(struct cmdline_opts *co, struct forma
print_address(bp, fo, , dst_opcodes, nitems(dst_opcodes),
O_IP_DSTPORT, HAVE_DSTIP);
 
+justopts:
/* Print the rest of options */
while (print_opcode(bp, fo, , -1))
;
@@ -4340,8 +4347,10 @@ chkarg:
}
} else if (first_cmd != cmd) {
errx(EX_DATAERR, "invalid protocol ``%s''", *av);
-   } else
+   } else {
+   rule->flags |= IPFW_RULE_JUSTOPTS;
goto read_options;
+   }
 OR_BLOCK(get_proto);
 
/*

Modified: stable/12/sys/netinet/ip_fw.h
==
--- stable/12/sys/netinet/ip_fw.h   Sat Nov 17 23:56:25 2018
(r340528)
+++ stable/12/sys/netinet/ip_fw.h   Sat Nov 17 23:57:46 2018
(r340529)
@@ -615,6 +615,7 @@ struct ip_fw_rule {
ipfw_insn   cmd[1]; /* storage for commands */
 };
 #defineIPFW_RULE_NOOPT 0x01/* Has no options in body   
*/
+#defineIPFW_RULE_JUSTOPTS  0x02/* new format of rule body  
*/
 
 /* Unaligned version */
 
___
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: r340528 - stable/12/sbin/ifconfig

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sat Nov 17 23:56:25 2018
New Revision: 340528
URL: https://svnweb.freebsd.org/changeset/base/340528

Log:
  MFC r339535:
Do not allow use `create` keyword as hostname when ifconfig(8) is invoked
for already existing interface.
  
It appeared, that ifconfig(8) assumes `create` keyword as hostname and
tries to resolve it, when `ifconfig ifname create` invoked for already
existing interface. This can produce some unexpected results, when hostname
resolving has successfully happened. This patch adds check for such case.
When an interface is already exists, and create is only one argument,
return error message. But when there are some other arguments, just remove
create keyword from the arguments list.
  
Obtained from:  Yandex LLC
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D17171
  
  MFC r339536:
Fix grammar.

Modified:
  stable/12/sbin/ifconfig/ifconfig.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/ifconfig/ifconfig.c
==
--- stable/12/sbin/ifconfig/ifconfig.c  Sat Nov 17 23:54:19 2018
(r340527)
+++ stable/12/sbin/ifconfig/ifconfig.c  Sat Nov 17 23:56:25 2018
(r340528)
@@ -504,6 +504,18 @@ main(int argc, char *argv[])
}
 #endif
errx(1, "interface %s does not exist", ifname);
+   } else {
+   /*
+* Do not allow use `create` command as hostname if
+* address family is not specified.
+*/
+   if (argc > 0 && (strcmp(argv[0], "create") == 0 ||
+   strcmp(argv[0], "plumb") == 0)) {
+   if (argc == 1)
+   errx(1, "interface %s already exists",
+   ifname);
+   argc--, argv++;
+   }
}
}
 
___
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: r340527 - stable/12/sys/netipsec

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sat Nov 17 23:54:19 2018
New Revision: 340527
URL: https://svnweb.freebsd.org/changeset/base/340527

Log:
  MFC r339533:
Add sadb_x_sa2 extension to SADB_ACQUIRE requests.
  
SADB_ACQUIRE requests are send by kernel, when security policy doesn't
have corresponding security association for outbound packet. IKE daemon
usually registers its handler for such messages and when the kernel asks
for SA it can handle this request. Now such requests will contain
additional fields that can help IKE daemon to create SA. And IKE now
can create SAs using only information from SADB_ACQUIRE request, this
is useful when many if_ipsec(4) interfaces are in use and IKE doesn track
security policies that was installed by kernel.
  
Obtained from:  Yandex LLC
Sponsored by:   Yandex LLC

Modified:
  stable/12/sys/netipsec/key.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netipsec/key.c
==
--- stable/12/sys/netipsec/key.cSat Nov 17 23:52:56 2018
(r340526)
+++ stable/12/sys/netipsec/key.cSat Nov 17 23:54:19 2018
(r340527)
@@ -6685,7 +6685,9 @@ key_acquire(const struct secasindex *saidx, struct sec
 
/* XXX proxy address (optional) */
 
-   /* set sadb_x_policy */
+   /*
+* Set sadb_x_policy. This is KAME extension to RFC2367.
+*/
if (sp != NULL) {
m = key_setsadbxpolicy(sp->policy, sp->spidx.dir, sp->id,
sp->priority);
@@ -6696,6 +6698,18 @@ key_acquire(const struct secasindex *saidx, struct sec
m_cat(result, m);
}
 
+   /*
+* Set sadb_x_sa2 extension if saidx->reqid is not zero.
+* This is FreeBSD extension to RFC2367.
+*/
+   if (saidx->reqid != 0) {
+   m = key_setsadbxsa2(saidx->mode, 0, saidx->reqid);
+   if (m == NULL) {
+   error = ENOBUFS;
+   goto fail;
+   }
+   m_cat(result, m);
+   }
/* XXX identity (optional) */
 #if 0
if (idexttype && fqdn) {
___
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: r340526 - in stable/12: sbin/ipfw sys/conf sys/modules/ipfw_nat64 sys/netpfil/ipfw/nat64

2018-11-17 Thread Andrey V. Elsukov
Author: ae
Date: Sat Nov 17 23:52:56 2018
New Revision: 340526
URL: https://svnweb.freebsd.org/changeset/base/340526

Log:
  MFC r339542:
Retire IPFIREWALL_NAT64_DIRECT_OUTPUT kernel option. And add ability
to switch the output method in run-time. Also document some sysctl
variables that can by changed for NAT64 module.
  
NAT64 had compile time option IPFIREWALL_NAT64_DIRECT_OUTPUT to use
if_output directly from nat64 module. By default is used netisr based
output method. Now both methods can be used, but they require different
handling by rules.
  
Obtained from:  Yandex LLC
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D16647

Modified:
  stable/12/sbin/ipfw/ipfw.8
  stable/12/sys/conf/options
  stable/12/sys/modules/ipfw_nat64/Makefile
  stable/12/sys/netpfil/ipfw/nat64/ip_fw_nat64.c
  stable/12/sys/netpfil/ipfw/nat64/nat64_translate.c
  stable/12/sys/netpfil/ipfw/nat64/nat64_translate.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/ipfw/ipfw.8
==
--- stable/12/sbin/ipfw/ipfw.8  Sat Nov 17 21:35:01 2018(r340525)
+++ stable/12/sbin/ipfw/ipfw.8  Sat Nov 17 23:52:56 2018(r340526)
@@ -1,7 +1,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 27, 2018
+.Dd October 21, 2018
 .Dt IPFW 8
 .Os
 .Sh NAME
@@ -3289,9 +3289,14 @@ Make sure that ND6 neighbor solicitation (ICMPv6 type 
 advertisement (ICMPv6 type 136) messages will not be handled by translation
 rules.
 .Pp
-After translation NAT64 translator sends packets through corresponding netisr
-queue.
+After translation NAT64 translator by default sends packets through
+corresponding netisr queue.
 Thus translator host should be configured as IPv4 and IPv6 router.
+Also this means, that a packet is handled by firewall twice.
+First time an original packet is handled and consumed by translator,
+and then it is handled again as translated packet.
+This behavior can be changed by sysctl variable 
+.Va net.inet.ip.fw.nat64_direct_output .
 .Pp
 The stateful NAT64 configuration command is the following:
 .Bd -ragged -offset indent
@@ -3914,6 +3919,41 @@ Default is no.
 Controls whether bridged packets are passed to
 .Nm .
 Default is no.
+.It Va net.inet.ip.fw.nat64_allow_private : No 0
+Defines how
+.Nm nat64
+handles private IPv4 addresses:
+.Bl -tag -width indent
+.It Cm 0
+Packets with private IPv4 will not be handled by translator
+.It Cm 1
+Translator will accept and process packets with private IPv4 addresses.
+.El
+.It Va net.inet.ip.fw.nat64_debug : No 0
+Controls debugging messages produced by
+.Nm ipfw_nat64
+module.
+.It Va net.inet.ip.fw.nat64_direct_output : No 0
+Controls the output method used by
+.Nm ipfw_nat64
+module:
+.Bl -tag -width indent
+.It Cm 0
+A packet is handled by 
+.Nm ipfw
+twice.
+First time an original packet is handled by
+.Nm ipfw
+and consumed by
+.Nm ipfw_nat64
+translator.
+Then translated packet is queued via netisr to input processing again.
+.It Cm 1
+A packet is handled by
+.Nm ipfw
+only once, and after translation it will be pushed directly to outgoing
+interface.
+.El
 .El
 .Sh INTERNAL DIAGNOSTICS
 There are some commands that may be useful to understand current state

Modified: stable/12/sys/conf/options
==
--- stable/12/sys/conf/options  Sat Nov 17 21:35:01 2018(r340525)
+++ stable/12/sys/conf/options  Sat Nov 17 23:52:56 2018(r340526)
@@ -439,7 +439,6 @@ IPFIREWALL  opt_ipfw.h
 IPFIREWALL_DEFAULT_TO_ACCEPT   opt_ipfw.h
 IPFIREWALL_NAT opt_ipfw.h
 IPFIREWALL_NAT64   opt_ipfw.h
-IPFIREWALL_NAT64_DIRECT_OUTPUT opt_ipfw.h
 IPFIREWALL_NPTV6   opt_ipfw.h
 IPFIREWALL_VERBOSE opt_ipfw.h
 IPFIREWALL_VERBOSE_LIMIT   opt_ipfw.h

Modified: stable/12/sys/modules/ipfw_nat64/Makefile
==
--- stable/12/sys/modules/ipfw_nat64/Makefile   Sat Nov 17 21:35:01 2018
(r340525)
+++ stable/12/sys/modules/ipfw_nat64/Makefile   Sat Nov 17 23:52:56 2018
(r340526)
@@ -6,8 +6,5 @@ KMOD=   ipfw_nat64
 SRCS=  ip_fw_nat64.c nat64_translate.c
 SRCS+= nat64lsn.c nat64lsn_control.c
 SRCS+= nat64stl.c nat64stl_control.c
-SRCS+= opt_ipfw.h
-
-#CFLAGS+=  -DIPFIREWALL_NAT64_DIRECT_OUTPUT
 
 .include 

Modified: stable/12/sys/netpfil/ipfw/nat64/ip_fw_nat64.c
==
--- stable/12/sys/netpfil/ipfw/nat64/ip_fw_nat64.c  Sat Nov 17 21:35:01 
2018(r340525)
+++ stable/12/sys/netpfil/ipfw/nat64/ip_fw_nat64.c  Sat Nov 17 23:52:56 
2018(r340526)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include "ip_fw_nat64.h"
+#include "nat64_translate.h"
 
 VNET_DEFINE(int, nat64_debug) = 0;
 VNET_DEFINE(int, nat64_allow_private) = 0;
@@ -56,8 +57,26 @@ 

Re: svn commit: r340511 - stable/12/sys/kern

2018-11-17 Thread Mark Johnston
On Sat, Nov 17, 2018 at 03:47:16PM -0800, Rodney W. Grimes wrote:
> > Author: markj
> > Date: Sat Nov 17 20:01:35 2018
> > New Revision: 340511
> > URL: https://svnweb.freebsd.org/changeset/base/340511
> > 
> > Log:
> >   MFC r339731:
> >   Add FALLTHROUGH comments to appease Coverity.
> > 
> > Modified:
> >   stable/12/sys/kern/kern_environment.c
> >   stable/12/sys/kern/vfs_mount.c
> > Directory Properties:
> >   stable/12/   (props changed)
> > 
> > Modified: stable/12/sys/kern/kern_environment.c
> > ==
> > --- stable/12/sys/kern/kern_environment.c   Sat Nov 17 20:00:10 2018
> > (r340510)
> > +++ stable/12/sys/kern/kern_environment.c   Sat Nov 17 20:01:35 2018
> > (r340511)
> > @@ -839,10 +839,13 @@ getenv_quad(const char *name, quad_t *data)
> > switch (vtp[0]) {
> > case 't': case 'T':
> > iv *= 1024;
> > +   /* FALLTHROUGH */
> > case 'g': case 'G':
> > iv *= 1024;
> > +   /* FALLTHROUGH */
> > case 'm': case 'M':
> > iv *= 1024;
> > +   /* FALLTHROUGH */
> > case 'k': case 'K':
> > iv *= 1024;
> Missing /* FALLTHROUGH */ ??

The statement following "case '\0':" is a break.

> 
> > case '\0':
> 
> And a refactor:
> 
>   case 't': case 'T':
>   case 'g': case 'G':
>   case 'm': case 'M':
>   case 'k': case 'K':
>   iv *= 1024;
>   /* FALLTHROUGH */
>   case '\0':
> 
> Isnt that the same functionality?

No, it isn't.
___
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: r339618 - head/sys/compat/linuxkpi/common/include/linux

2018-11-17 Thread Matthew Macy
When looking at powerpc io.h raw and relaxed are not aliases, but it
appears that on x86, they are:
https://github.com/torvalds/linux/blob/master/arch/x86/include/asm/io.h

Sorry for the noise. But let's starting moving the x86 specific
atomic.h and io.h under asm/x86.

Thanks.



On Sat, Nov 17, 2018 at 2:01 PM Matthew Macy  wrote:
>
> You should probably revert this. The implied understanding of the _relaxed 
> version is incorrect. compiler_membar is there to prevent instruction 
> reordering which is possible on FreeBSD because the accesses are done in C. 
> The relaxed variants still do not permit instruction reordering. On Linux 
> __compiler_member (referred to as barrier there) isn’t necessary in the mmio 
> accessors because they always use volatile asm which can’t be reordered. The 
> distinction between the relaxed and non relaxed variants is that the relaxed 
> variant lacks memory barriers (sync / lwsync / eieio on ppc, membar on sparc, 
> etc). Most of the time we don’t run in to problems on x86 because with TSO 
> the only reordering possible is writes that happen before reads can become 
> visible in memory after they occur in the instruction stream.
>
> Thanks.
> -M
>
> On Mon, Oct 22, 2018 at 13:55 Tijl Coosemans  wrote:
>>
>> Author: tijl
>> Date: Mon Oct 22 20:55:35 2018
>> New Revision: 339618
>> URL: https://svnweb.freebsd.org/changeset/base/339618
>>
>> Log:
>>   Define linuxkpi readq for 64-bit architectures.  It is used by drm-kmod.
>>   Currently the compiler picks up the definition in machine/cpufunc.h.
>>
>>   Add compiler memory barriers to read* and write*.  The Linux x86
>>   implementation of these functions uses inline asm with "memory" clobber.
>>   The Linux x86 implementation of read_relaxed* and write_relaxed* uses the
>>   same inline asm without "memory" clobber.
>>
>>   Implement ioread* and iowrite* in terms of read* and write* so they also
>>   have memory barriers.
>>
>>   Qualify the addr parameter in write* as volatile.
>>
>>   Like Linux, define macros with the same name as the inline functions.
>>
>>   Only define 64-bit versions on 64-bit architectures because generally
>>   32-bit architectures can't do atomic 64-bit loads and stores.
>>
>>   Regroup the functions a bit and add brief comments explaining what they do:
>>   - __raw_read*, __raw_write*: atomic, no barriers, no byte swapping
>>   - read_relaxed*, write_relaxed*: atomic, no barriers, little-endian
>>   - read*, write*: atomic, with barriers, little-endian
>>
>>   Add a comment that says our implementation of ioread* and iowrite*
>>   only handles MMIO and does not support port IO.
>>
>>   Reviewed by:  hselasky
>>   MFC after:3 days
>>
>> Modified:
>>   head/sys/compat/linuxkpi/common/include/linux/io.h
>>
>> Modified: head/sys/compat/linuxkpi/common/include/linux/io.h
>> ==
>> --- head/sys/compat/linuxkpi/common/include/linux/io.h  Mon Oct 22 20:22:33 
>> 2018(r339617)
>> +++ head/sys/compat/linuxkpi/common/include/linux/io.h  Mon Oct 22 20:55:35 
>> 2018(r339618)
>> @@ -38,153 +38,309 @@
>>  #include 
>>  #include 
>>
>> +/*
>> + * XXX This is all x86 specific.  It should be bus space access.
>> + */
>> +
>> +/* Access MMIO registers atomically without barriers and byte swapping. */
>> +
>> +static inline uint8_t
>> +__raw_readb(const volatile void *addr)
>> +{
>> +   return (*(const volatile uint8_t *)addr);
>> +}
>> +#define__raw_readb(addr)   __raw_readb(addr)
>> +
>> +static inline void
>> +__raw_writeb(uint8_t v, volatile void *addr)
>> +{
>> +   *(volatile uint8_t *)addr = v;
>> +}
>> +#define__raw_writeb(v, addr)   __raw_writeb(v, addr)
>> +
>> +static inline uint16_t
>> +__raw_readw(const volatile void *addr)
>> +{
>> +   return (*(const volatile uint16_t *)addr);
>> +}
>> +#define__raw_readw(addr)   __raw_readw(addr)
>> +
>> +static inline void
>> +__raw_writew(uint16_t v, volatile void *addr)
>> +{
>> +   *(volatile uint16_t *)addr = v;
>> +}
>> +#define__raw_writew(v, addr)   __raw_writew(v, addr)
>> +
>>  static inline uint32_t
>>  __raw_readl(const volatile void *addr)
>>  {
>> -   return *(const volatile uint32_t *)addr;
>> +   return (*(const volatile uint32_t *)addr);
>>  }
>> +#define__raw_readl(addr)   __raw_readl(addr)
>>
>>  static inline void
>> -__raw_writel(uint32_t b, volatile void *addr)
>> +__raw_writel(uint32_t v, volatile void *addr)
>>  {
>> -   *(volatile uint32_t *)addr = b;
>> +   *(volatile uint32_t *)addr = v;
>>  }
>> +#define__raw_writel(v, addr)   __raw_writel(v, addr)
>>
>> +#ifdef __LP64__
>>  static inline uint64_t
>>  __raw_readq(const volatile void *addr)
>>  {
>> -   return *(const volatile uint64_t *)addr;
>> +   return (*(const volatile uint64_t *)addr);
>>  }
>> +#define__raw_readq(addr)   __raw_readq(addr)
>>
>>  static inline void
>> 

Re: svn commit: r339618 - head/sys/compat/linuxkpi/common/include/linux

2018-11-17 Thread Matthew Macy
You should probably revert this. The implied understanding of the _relaxed
version is incorrect. compiler_membar is there to prevent instruction
reordering which is possible on FreeBSD because the accesses are done in C.
The relaxed variants still do not permit instruction reordering. On Linux
__compiler_member (referred to as barrier there) isn’t necessary in the
mmio accessors because they always use volatile asm which can’t be
reordered. The distinction between the relaxed and non relaxed variants is
that the relaxed variant lacks memory barriers (sync / lwsync / eieio on
ppc, membar on sparc, etc). Most of the time we don’t run in to problems on
x86 because with TSO the only reordering possible is writes that happen
before reads can become visible in memory after they occur in the
instruction stream.

Thanks.
-M

On Mon, Oct 22, 2018 at 13:55 Tijl Coosemans  wrote:

> Author: tijl
> Date: Mon Oct 22 20:55:35 2018
> New Revision: 339618
> URL: https://svnweb.freebsd.org/changeset/base/339618
>
> Log:
>   Define linuxkpi readq for 64-bit architectures.  It is used by drm-kmod.
>   Currently the compiler picks up the definition in machine/cpufunc.h.
>
>   Add compiler memory barriers to read* and write*.  The Linux x86
>   implementation of these functions uses inline asm with "memory" clobber.
>   The Linux x86 implementation of read_relaxed* and write_relaxed* uses the
>   same inline asm without "memory" clobber.
>
>   Implement ioread* and iowrite* in terms of read* and write* so they also
>   have memory barriers.
>
>   Qualify the addr parameter in write* as volatile.
>
>   Like Linux, define macros with the same name as the inline functions.
>
>   Only define 64-bit versions on 64-bit architectures because generally
>   32-bit architectures can't do atomic 64-bit loads and stores.
>
>   Regroup the functions a bit and add brief comments explaining what they
> do:
>   - __raw_read*, __raw_write*: atomic, no barriers, no byte swapping
>   - read_relaxed*, write_relaxed*: atomic, no barriers, little-endian
>   - read*, write*: atomic, with barriers, little-endian
>
>   Add a comment that says our implementation of ioread* and iowrite*
>   only handles MMIO and does not support port IO.
>
>   Reviewed by:  hselasky
>   MFC after:3 days
>
> Modified:
>   head/sys/compat/linuxkpi/common/include/linux/io.h
>
> Modified: head/sys/compat/linuxkpi/common/include/linux/io.h
>
> ==
> --- head/sys/compat/linuxkpi/common/include/linux/io.h  Mon Oct 22
> 20:22:33 2018(r339617)
> +++ head/sys/compat/linuxkpi/common/include/linux/io.h  Mon Oct 22
> 20:55:35 2018(r339618)
> @@ -38,153 +38,309 @@
>  #include 
>  #include 
>
> +/*
> + * XXX This is all x86 specific.  It should be bus space access.
> + */
> +
> +/* Access MMIO registers atomically without barriers and byte swapping. */
> +
> +static inline uint8_t
> +__raw_readb(const volatile void *addr)
> +{
> +   return (*(const volatile uint8_t *)addr);
> +}
> +#define__raw_readb(addr)   __raw_readb(addr)
> +
> +static inline void
> +__raw_writeb(uint8_t v, volatile void *addr)
> +{
> +   *(volatile uint8_t *)addr = v;
> +}
> +#define__raw_writeb(v, addr)   __raw_writeb(v, addr)
> +
> +static inline uint16_t
> +__raw_readw(const volatile void *addr)
> +{
> +   return (*(const volatile uint16_t *)addr);
> +}
> +#define__raw_readw(addr)   __raw_readw(addr)
> +
> +static inline void
> +__raw_writew(uint16_t v, volatile void *addr)
> +{
> +   *(volatile uint16_t *)addr = v;
> +}
> +#define__raw_writew(v, addr)   __raw_writew(v, addr)
> +
>  static inline uint32_t
>  __raw_readl(const volatile void *addr)
>  {
> -   return *(const volatile uint32_t *)addr;
> +   return (*(const volatile uint32_t *)addr);
>  }
> +#define__raw_readl(addr)   __raw_readl(addr)
>
>  static inline void
> -__raw_writel(uint32_t b, volatile void *addr)
> +__raw_writel(uint32_t v, volatile void *addr)
>  {
> -   *(volatile uint32_t *)addr = b;
> +   *(volatile uint32_t *)addr = v;
>  }
> +#define__raw_writel(v, addr)   __raw_writel(v, addr)
>
> +#ifdef __LP64__
>  static inline uint64_t
>  __raw_readq(const volatile void *addr)
>  {
> -   return *(const volatile uint64_t *)addr;
> +   return (*(const volatile uint64_t *)addr);
>  }
> +#define__raw_readq(addr)   __raw_readq(addr)
>
>  static inline void
> -__raw_writeq(uint64_t b, volatile void *addr)
> +__raw_writeq(uint64_t v, volatile void *addr)
>  {
> -   *(volatile uint64_t *)addr = b;
> +   *(volatile uint64_t *)addr = v;
>  }
> +#define__raw_writeq(v, addr)   __raw_writeq(v, addr)
> +#endif
>
> -/*
> - * XXX This is all x86 specific.  It should be bus space access.
> - */
>  #definemmiowb()barrier()
>
> -#undef writel
> +/* Access little-endian MMIO registers atomically with memory barriers. */
> +
> 

svn commit: r340525 - head/sbin/mount_fusefs

2018-11-17 Thread Alan Somers
Author: asomers
Date: Sat Nov 17 21:35:01 2018
New Revision: 340525
URL: https://svnweb.freebsd.org/changeset/base/340525

Log:
  mount_fusefs.8: expand HISTORY section
  
  Note that fuse was available from ports long before joining the base system.
  Also, update the upstream URL.
  
  MFC after:2 weeks

Modified:
  head/sbin/mount_fusefs/mount_fusefs.8

Modified: head/sbin/mount_fusefs/mount_fusefs.8
==
--- head/sbin/mount_fusefs/mount_fusefs.8   Sat Nov 17 20:59:50 2018
(r340524)
+++ head/sbin/mount_fusefs/mount_fusefs.8   Sat Nov 17 21:35:01 2018
(r340525)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 3, 2016
+.Dd November 17, 2018
 .Dt MOUNT_FUSEFS 8
 .Os
 .Sh NAME
@@ -339,12 +339,16 @@ does not call any external utility and also provides a
 .Xr umount 8
 .Sh HISTORY
 .Nm
-appeared in
-.Fx 10.0
-as the part of the
+was written as the part of the
 .Fx
-implementation of the Fuse userspace filesystem
-framework (see http://fuse.sourceforge.net).
+implementation of the Fuse userspace filesystem framework (see
+.Xr https://github.com/libfuse/libfuse )
+and first appeared in the
+.Pa sysutils/fusefs-kmod
+port, supporting
+.Fx 6.0 .
+It was added to the base system in
+.Fx 10.0 .
 .Sh CAVEATS
 This user interface is
 .Fx
___
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: r340524 - stable/12/bin/setfacl

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:59:50 2018
New Revision: 340524
URL: https://svnweb.freebsd.org/changeset/base/340524

Log:
  MFC r339780:
  Avoid leaking memory in error paths.

Modified:
  stable/12/bin/setfacl/setfacl.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/bin/setfacl/setfacl.c
==
--- stable/12/bin/setfacl/setfacl.c Sat Nov 17 20:58:35 2018
(r340523)
+++ stable/12/bin/setfacl/setfacl.c Sat Nov 17 20:59:50 2018
(r340524)
@@ -307,6 +307,8 @@ handle_file(FTS *ftsp, FTSENT *file)
break;
}
 
+   ret = 0;
+
/*
 * Don't try to set an empty default ACL; it will always fail.
 * Use acl_delete_def_file(3) instead.
@@ -316,34 +318,33 @@ handle_file(FTS *ftsp, FTSENT *file)
if (acl_delete_def_file(file->fts_accpath) == -1) {
warn("%s: acl_delete_def_file() failed",
file->fts_path);
-   return (1);
+   ret = 1;
}
-   return (0);
+   goto out;
}
 
/* Don't bother setting the ACL if something is broken. */
if (local_error) {
-   return (1);
-   }
-
-   if (acl_type != ACL_TYPE_NFS4 && need_mask &&
+   ret = 1;
+   } else if (acl_type != ACL_TYPE_NFS4 && need_mask &&
set_acl_mask(, file->fts_path) == -1) {
warnx("%s: failed to set ACL mask", file->fts_path);
-   return (1);
+   ret = 1;
} else if (follow_symlink) {
if (acl_set_file(file->fts_accpath, acl_type, acl) == -1) {
warn("%s: acl_set_file() failed", file->fts_path);
-   return (1);
+   ret = 1;
}
} else {
if (acl_set_link_np(file->fts_accpath, acl_type, acl) == -1) {
warn("%s: acl_set_link_np() failed", file->fts_path);
-   return (1);
+   ret = 1;
}
}
 
+out:
acl_free(acl);
-   return (0);
+   return (ret);
 }
 
 int
___
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: r340522 - in stable/12/sys: amd64/amd64 i386/i386

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:55:11 2018
New Revision: 340522
URL: https://svnweb.freebsd.org/changeset/base/340522

Log:
  MFC r339490:
  Add an assertion to pmap_enter().

Modified:
  stable/12/sys/amd64/amd64/pmap.c
  stable/12/sys/i386/i386/pmap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/amd64/pmap.c
==
--- stable/12/sys/amd64/amd64/pmap.cSat Nov 17 20:54:24 2018
(r340521)
+++ stable/12/sys/amd64/amd64/pmap.cSat Nov 17 20:55:11 2018
(r340522)
@@ -5141,6 +5141,8 @@ retry:
vm_page_aflag_set(om, PGA_REFERENCED);
CHANGE_PV_LIST_LOCK_TO_PHYS(, opa);
pv = pmap_pvh_remove(>md, pmap, va);
+   KASSERT(pv != NULL,
+   ("pmap_enter: no PV entry for %#lx", va));
if ((newpte & PG_MANAGED) == 0)
free_pv_entry(pmap, pv);
if ((om->aflags & PGA_WRITEABLE) != 0 &&

Modified: stable/12/sys/i386/i386/pmap.c
==
--- stable/12/sys/i386/i386/pmap.c  Sat Nov 17 20:54:24 2018
(r340521)
+++ stable/12/sys/i386/i386/pmap.c  Sat Nov 17 20:55:11 2018
(r340522)
@@ -3820,6 +3820,8 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, v
if ((origpte & PG_A) != 0)
vm_page_aflag_set(om, PGA_REFERENCED);
pv = pmap_pvh_remove(>md, pmap, va);
+   KASSERT(pv != NULL,
+   ("pmap_enter: no PV entry for %#x", va));
if ((newpte & PG_MANAGED) == 0)
free_pv_entry(pmap, pv);
if ((om->aflags & PGA_WRITEABLE) != 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: r340523 - in stable/12: bin/setfacl tests/sys/acl

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:58:35 2018
New Revision: 340523
URL: https://svnweb.freebsd.org/changeset/base/340523

Log:
  MFC r339781:
  Don't print pathconf() errors if the target file doesn't exist.
  
  MFC r339782:
  Update and re-enable ACL tests.
  
  PR:   229930

Modified:
  stable/12/bin/setfacl/setfacl.c
  stable/12/tests/sys/acl/Makefile
  stable/12/tests/sys/acl/tools-nfs4-psarc.test
  stable/12/tests/sys/acl/tools-nfs4.test
  stable/12/tests/sys/acl/tools-posix.test
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/bin/setfacl/setfacl.c
==
--- stable/12/bin/setfacl/setfacl.c Sat Nov 17 20:55:11 2018
(r340522)
+++ stable/12/bin/setfacl/setfacl.c Sat Nov 17 20:58:35 2018
(r340523)
@@ -220,8 +220,8 @@ handle_file(FTS *ftsp, FTSENT *file)
} else if (ret == 0) {
if (acl_type == ACL_TYPE_NFS4)
acl_type = ACL_TYPE_ACCESS;
-   } else if (ret < 0 && errno != EINVAL) {
-   warn("%s: pathconf(..., _PC_ACL_NFS4) failed",
+   } else if (ret < 0 && errno != EINVAL && errno != ENOENT) {
+   warn("%s: pathconf(_PC_ACL_NFS4) failed",
file->fts_path);
}
 

Modified: stable/12/tests/sys/acl/Makefile
==
--- stable/12/tests/sys/acl/MakefileSat Nov 17 20:55:11 2018
(r340522)
+++ stable/12/tests/sys/acl/MakefileSat Nov 17 20:58:35 2018
(r340523)
@@ -14,11 +14,9 @@ ${PACKAGE}FILES+=tools-posix.test
 
 SCRIPTS+=  run
 
-# Disable 00 and 02 until they've been updated for setfacl's new behavior
-# PR 229930 tests/sys/acl/00:main fails in CI due to unexpected error message
-# TAP_TESTS_SH+=   00
-# TAP_TESTS_SH+=   02
+TAP_TESTS_SH+= 00
 TAP_TESTS_SH+= 01
+TAP_TESTS_SH+= 02
 TAP_TESTS_SH+= 03
 TAP_TESTS_SH+= 04
 

Modified: stable/12/tests/sys/acl/tools-nfs4-psarc.test
==
--- stable/12/tests/sys/acl/tools-nfs4-psarc.test   Sat Nov 17 20:55:11 
2018(r340522)
+++ stable/12/tests/sys/acl/tools-nfs4-psarc.test   Sat Nov 17 20:58:35 
2018(r340523)
@@ -186,7 +186,7 @@ $ ls -l xxx yyy zzz | cut -d' ' -f1
 > -rw-r--r--
 
 $ setfacl -m u:42:x:allow,g:43:w:allow nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory
@@ -215,7 +215,7 @@ $ getfacl -nq nnn xxx yyy zzz
 >  everyone@:r-a-R-c--s:---:allow
 
 $ setfacl -b nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory

Modified: stable/12/tests/sys/acl/tools-nfs4.test
==
--- stable/12/tests/sys/acl/tools-nfs4.test Sat Nov 17 20:55:11 2018
(r340522)
+++ stable/12/tests/sys/acl/tools-nfs4.test Sat Nov 17 20:58:35 2018
(r340523)
@@ -214,7 +214,7 @@ $ ls -l xxx yyy zzz | cut -d' ' -f1
 > -rw-r--r--
 
 $ setfacl -m u:42:x:allow,g:43:w:allow nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory
@@ -252,7 +252,7 @@ $ getfacl -nq nnn xxx yyy zzz
 >  everyone@:r-a-R-c--s:---:allow
 
 $ setfacl -b nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory

Modified: stable/12/tests/sys/acl/tools-posix.test
==
--- stable/12/tests/sys/acl/tools-posix.testSat Nov 17 20:55:11 2018
(r340522)
+++ stable/12/tests/sys/acl/tools-posix.testSat Nov 17 20:58:35 2018
(r340523)
@@ -226,7 +226,7 @@ $ ls -l xxx yyy zzz | cut -d' ' -f1
 > -rw-r--r--
 
 $ setfacl -m u:42:x,g:43:w nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory
@@ -258,7 +258,7 @@ $ getfacl -nq nnn xxx yyy zzz
 > other::r--
 
 $ setfacl -b nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory
@@ -267,7 +267,7 @@ $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > -rw-r--r--+
 
 $ setfacl -bn nnn 

svn commit: r340521 - stable/12/usr.sbin/rtsold

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:54:24 2018
New Revision: 340521
URL: https://svnweb.freebsd.org/changeset/base/340521

Log:
  MFC r339453, r339455, r339456, r339460, r339687, r339745, r339747:
  Miscellaneous cleanups of rtsol(d).

Modified:
  stable/12/usr.sbin/rtsold/if.c
  stable/12/usr.sbin/rtsold/rtsock.c
  stable/12/usr.sbin/rtsold/rtsol.c
  stable/12/usr.sbin/rtsold/rtsold.8
  stable/12/usr.sbin/rtsold/rtsold.c
  stable/12/usr.sbin/rtsold/rtsold.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/rtsold/if.c
==
--- stable/12/usr.sbin/rtsold/if.c  Sat Nov 17 20:47:41 2018
(r340520)
+++ stable/12/usr.sbin/rtsold/if.c  Sat Nov 17 20:54:24 2018
(r340521)
@@ -332,37 +332,6 @@ if_nametosdl(char *name)
return (ret_sdl);
 }
 
-int
-getinet6sysctl(int code)
-{
-   int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, 0 };
-   int value;
-   size_t size;
-
-   mib[3] = code;
-   size = sizeof(value);
-   if (sysctl(mib, nitems(mib), , , NULL, 0) < 0)
-   return (-1);
-   else
-   return (value);
-}
-
-int
-setinet6sysctl(int code, int newval)
-{
-   int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, 0 };
-   int value;
-   size_t size;
-
-   mib[3] = code;
-   size = sizeof(value);
-   if (sysctl(mib, nitems(mib), , ,
-   , sizeof(newval)) < 0)
-   return (-1);
-   else
-   return (value);
-}
-
 /**/
 
 /* get ia6_flags for link-local addr on if.  returns -1 on error. */

Modified: stable/12/usr.sbin/rtsold/rtsock.c
==
--- stable/12/usr.sbin/rtsold/rtsock.c  Sat Nov 17 20:47:41 2018
(r340520)
+++ stable/12/usr.sbin/rtsold/rtsock.c  Sat Nov 17 20:54:24 2018
(r340521)
@@ -57,27 +57,15 @@
 #include 
 #include "rtsold.h"
 
-#define ROUNDUP(a, size) \
-   (((a) & ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a))
-
-#define NEXT_SA(ap) (ap) = (struct sockaddr *) \
-   ((caddr_t)(ap) + \
-((ap)->sa_len ? ROUNDUP((ap)->sa_len, sizeof(u_long)) \
-  : sizeof(u_long)))
-
-#ifdef RTM_IFANNOUNCE  /*NetBSD 1.5 or later*/
 static int rtsock_input_ifannounce(int, struct rt_msghdr *, char *);
-#endif
 
 static struct {
u_char type;
size_t minlen;
int (*func)(int, struct rt_msghdr *, char *);
 } rtsock_dispatch[] = {
-#ifdef RTM_IFANNOUNCE  /*NetBSD 1.5 or later*/
{ RTM_IFANNOUNCE, sizeof(struct if_announcemsghdr),
  rtsock_input_ifannounce },
-#endif
{ 0, 0, NULL },
 };
 
@@ -135,7 +123,6 @@ rtsock_input(int s)
return (ret);
 }
 
-#ifdef RTM_IFANNOUNCE  /*NetBSD 1.5 or later*/
 static int
 rtsock_input_ifannounce(int s __unused, struct rt_msghdr *rtm, char *lim)
 {
@@ -174,4 +161,3 @@ rtsock_input_ifannounce(int s __unused, struct rt_msgh
 
return (0);
 }
-#endif

Modified: stable/12/usr.sbin/rtsold/rtsol.c
==
--- stable/12/usr.sbin/rtsold/rtsol.c   Sat Nov 17 20:47:41 2018
(r340520)
+++ stable/12/usr.sbin/rtsold/rtsol.c   Sat Nov 17 20:54:24 2018
(r340521)
@@ -98,22 +98,20 @@ static char *make_rsid(const char *, const char *, str
 #define_ARGS_RESADDresolvconf_script, "-a", rsid
 #define_ARGS_RESDELresolvconf_script, "-d", rsid
 
-#defineCALL_SCRIPT(name, sm_head)  
\
-   do {\
-   const char *const sarg[] = { _ARGS_##name, NULL };  \
-   call_script(sizeof(sarg), sarg, sm_head);   \
-   } while(0)
+#defineCALL_SCRIPT(name, sm_head) do { \
+   const char *const sarg[] = { _ARGS_##name, NULL };  \
+   call_script(sizeof(sarg), sarg, sm_head);   \
+} while (0)
 
-#defineELM_MALLOC(p,error_action)  
\
-   do {\
-   p = malloc(sizeof(*p)); \
-   if (p == NULL) {\
-   warnmsg(LOG_ERR, __func__, "malloc failed: %s", \
-   strerror(errno));   \
-   error_action;   \
-   }   \
-   memset(p, 0, sizeof(*p));   \
-   } while(0)
+#defineELM_MALLOC(p, error_action) do {\
+   p = malloc(sizeof(*p)); \
+   if (p == NULL) {   

svn commit: r340520 - releng/12.0/share/man/man4

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:47:41 2018
New Revision: 340520
URL: https://svnweb.freebsd.org/changeset/base/340520

Log:
  MFstable/12 r340498:
  Hook mac_ntpd.4 up to the build.
  
  PR:   232757
  Approved by:  re (gjb)

Modified:
  releng/12.0/share/man/man4/Makefile
Directory Properties:
  releng/12.0/   (props changed)

Modified: releng/12.0/share/man/man4/Makefile
==
--- releng/12.0/share/man/man4/Makefile Sat Nov 17 20:27:06 2018
(r340519)
+++ releng/12.0/share/man/man4/Makefile Sat Nov 17 20:47:41 2018
(r340520)
@@ -269,6 +269,7 @@ MAN=aac.4 \
mac_lomac.4 \
mac_mls.4 \
mac_none.4 \
+   mac_ntpd.4 \
mac_partition.4 \
mac_portacl.4 \
mac_seeotheruids.4 \
___
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: r340519 - stable/12/sys/conf

2018-11-17 Thread Kyle Evans
Author: kevans
Date: Sat Nov 17 20:27:06 2018
New Revision: 340519
URL: https://svnweb.freebsd.org/changeset/base/340519

Log:
  MFC r340372: dtb.mk: Fix passing of ECHO to make_dtb{,o}.sh

Modified:
  stable/12/sys/conf/dtb.mk
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/conf/dtb.mk
==
--- stable/12/sys/conf/dtb.mk   Sat Nov 17 20:18:15 2018(r340518)
+++ stable/12/sys/conf/dtb.mk   Sat Nov 17 20:27:06 2018(r340519)
@@ -55,21 +55,21 @@ DTBO=${DTSO:R:S/$/.dtbo/}
 all: ${DTB} ${DTBO}
 
 .if defined(DTS)
-.export DTC
+.export DTC ECHO
 .for _dts in ${DTS}
 ${_dts:R:S/$/.dtb/}:   ${_dts} ${OP_META}
@${ECHO} Generating ${.TARGET} from ${_dts}
-   @env ECHO=${ECHO} ${SYSDIR}/tools/fdt/make_dtb.sh ${SYSDIR} ${_dts} 
${.OBJDIR}
+   @${SYSDIR}/tools/fdt/make_dtb.sh ${SYSDIR} ${_dts} ${.OBJDIR}
 CLEANFILES+=${_dts:R:S/$/.dtb/}
 .endfor
 .endif
 
 .if defined(DTSO)
-.export DTC
+.export DTC ECHO
 .for _dtso in ${DTSO}
 ${_dtso:R:S/$/.dtbo/}: ${_dtso} ${OP_META}
@${ECHO} Generating ${.TARGET} from ${_dtso}
-   @env ECHO=${ECHO} ${SYSDIR}/tools/fdt/make_dtbo.sh ${SYSDIR} 
overlays/${_dtso} ${.OBJDIR}
+   @${SYSDIR}/tools/fdt/make_dtbo.sh ${SYSDIR} overlays/${_dtso} ${.OBJDIR}
 CLEANFILES+=${_dtso:R:S/$/.dtbo/}
 .endfor
 .endif
___
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: r340518 - in stable/12/sys/dev: atkbdc evdev kbdmux usb/input

2018-11-17 Thread Vladimir Kondratyev
Author: wulf
Date: Sat Nov 17 20:18:15 2018
New Revision: 340518
URL: https://svnweb.freebsd.org/changeset/base/340518

Log:
  MFC r339823:
  
  evdev: Use console lock as evdev lock for all supported keyboard drivers.
  
  Now evdev part of keyboard drivers does not take any locks if corresponding
  input/eventN device node is not opened by userland consumers.
  
  Do not assert console lock inside evdev to handle the cases when keyboard
  driver is called from some special single-threaded context like shutdown
  thread.
  
  MFC r339824:
  
  evdev: disable evdev if it is invoked from KDB or panic context
  
  This allow to prevent deadlock on entering KDB if one of evdev locks is
  already taken by userspace process.
  
  Also this change discards all but LED console events produced by KDB as
  unrelated to userspace.

Modified:
  stable/12/sys/dev/atkbdc/atkbd.c
  stable/12/sys/dev/evdev/cdev.c
  stable/12/sys/dev/evdev/evdev.c
  stable/12/sys/dev/evdev/evdev_private.h
  stable/12/sys/dev/kbdmux/kbdmux.c
  stable/12/sys/dev/usb/input/ukbd.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/atkbdc/atkbd.c
==
--- stable/12/sys/dev/atkbdc/atkbd.cSat Nov 17 20:14:02 2018
(r340517)
+++ stable/12/sys/dev/atkbdc/atkbd.cSat Nov 17 20:18:15 2018
(r340518)
@@ -484,7 +484,7 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int
evdev_support_led(evdev, LED_CAPSL);
evdev_support_led(evdev, LED_SCROLLL);
 
-   if (evdev_register(evdev))
+   if (evdev_register_mtx(evdev, ))
evdev_free(evdev);
else
state->ks_evdev = evdev;

Modified: stable/12/sys/dev/evdev/cdev.c
==
--- stable/12/sys/dev/evdev/cdev.c  Sat Nov 17 20:14:02 2018
(r340517)
+++ stable/12/sys/dev/evdev/cdev.c  Sat Nov 17 20:18:15 2018
(r340518)
@@ -349,6 +349,19 @@ evdev_ioctl(struct cdev *dev, u_long cmd, caddr_t data
if (client->ec_revoked || evdev == NULL)
return (ENODEV);
 
+   /*
+* Fix evdev state corrupted with discarding of kdb events.
+* EVIOCGKEY and EVIOCGLED ioctls can suffer from this.
+*/
+   if (evdev->ev_kdb_active) {
+   EVDEV_LOCK(evdev);
+   if (evdev->ev_kdb_active) {
+   evdev->ev_kdb_active = false;
+   evdev_restore_after_kdb(evdev);
+   }
+   EVDEV_UNLOCK(evdev);
+   }
+
/* file I/O ioctl handling */
switch (cmd) {
case FIOSETOWN:

Modified: stable/12/sys/dev/evdev/evdev.c
==
--- stable/12/sys/dev/evdev/evdev.c Sat Nov 17 20:14:02 2018
(r340517)
+++ stable/12/sys/dev/evdev/evdev.c Sat Nov 17 20:18:15 2018
(r340518)
@@ -32,9 +32,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -763,6 +765,30 @@ evdev_send_event(struct evdev_dev *evdev, uint16_t typ
}
 }
 
+void
+evdev_restore_after_kdb(struct evdev_dev *evdev)
+{
+   int code;
+
+   EVDEV_LOCK_ASSERT(evdev);
+
+   /* Report postponed leds */
+   for (code = 0; code < LED_CNT; code++)
+   if (bit_test(evdev->ev_kdb_led_states, code))
+   evdev_send_event(evdev, EV_LED, code,
+   !bit_test(evdev->ev_led_states, code));
+   bit_nclear(evdev->ev_kdb_led_states, 0, LED_MAX);
+
+   /* Release stuck keys (CTRL + ALT + ESC) */
+   evdev_stop_repeat(evdev);
+   for (code = 0; code < KEY_CNT; code++) {
+   if (bit_test(evdev->ev_key_states, code)) {
+   evdev_send_event(evdev, EV_KEY, code, KEY_EVENT_UP);
+   evdev_send_event(evdev, EV_SYN, SYN_REPORT, 1);
+   }
+   }
+}
+
 int
 evdev_push_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
 int32_t value)
@@ -771,7 +797,25 @@ evdev_push_event(struct evdev_dev *evdev, uint16_t typ
if (evdev_check_event(evdev, type, code, value) != 0)
return (EINVAL);
 
+   /*
+* Discard all but LEDs kdb events as unrelated to userspace.
+* Aggregate LED updates and postpone reporting until kdb deactivation.
+*/
+   if (kdb_active || SCHEDULER_STOPPED()) {
+   evdev->ev_kdb_active = true;
+   if (type == EV_LED)
+   bit_set(evdev->ev_kdb_led_states,
+   bit_test(evdev->ev_led_states, code) != value);
+   return (0);
+   }
+
EVDEV_ENTER(evdev);
+
+   /* Fix evdev state corrupted with discarding of 

svn commit: r340517 - stable/12/lib/libcasper/libcasper

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:14:02 2018
New Revision: 340517
URL: https://svnweb.freebsd.org/changeset/base/340517

Log:
  MFC r339675:
  Fix comments.

Modified:
  stable/12/lib/libcasper/libcasper/libcasper.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libcasper/libcasper/libcasper.c
==
--- stable/12/lib/libcasper/libcasper/libcasper.c   Sat Nov 17 20:11:39 
2018(r340516)
+++ stable/12/lib/libcasper/libcasper/libcasper.c   Sat Nov 17 20:14:02 
2018(r340517)
@@ -100,12 +100,12 @@ cap_init(void)
 
pid = pdfork(, 0);
if (pid == 0) {
-   /* Parent. */
+   /* Child. */
close(sock[0]);
casper_main_loop(sock[1]);
/* NOTREACHED. */
} else if (pid > 0) {
-   /* Child. */
+   /* Parent. */
close(sock[1]);
chan = cap_wrap(sock[0], 0);
if (chan == 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: r340516 - stable/12/lib/libc/sys

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:11:39 2018
New Revision: 340516
URL: https://svnweb.freebsd.org/changeset/base/340516

Log:
  MFC r339692:
  Clarify slightly the interaction between wait*() and pdfork().

Modified:
  stable/12/lib/libc/sys/wait.2
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/sys/wait.2
==
--- stable/12/lib/libc/sys/wait.2   Sat Nov 17 20:11:20 2018
(r340515)
+++ stable/12/lib/libc/sys/wait.2   Sat Nov 17 20:11:39 2018
(r340516)
@@ -28,7 +28,7 @@
 .\" @(#)wait.2 8.2 (Berkeley) 4/19/94
 .\" $FreeBSD$
 .\"
-.Dd December 1, 2017
+.Dd October 24, 2018
 .Dt WAIT 2
 .Os
 .Sh NAME
@@ -597,11 +597,11 @@ fields of
 .Fa infop
 must be checked against zero to determine if a process reported status.
 .Pp
+The
 .Fn wait
-called with -1 to wait for any child process will ignore a child that is
-referenced by a process descriptor (see
-.Xr pdfork 2 ) .
-Specific processes can still be waited on by specifying the process ID.
+family of functions will not return a child process created with
+.Xr pdfork 2
+unless specifically directed to do so by specifying its process ID.
 .Sh ERRORS
 The
 .Fn wait
___
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: r340515 - releng/12.0/sys/arm/conf

2018-11-17 Thread Glen Barber
Author: gjb
Date: Sat Nov 17 20:11:20 2018
New Revision: 340515
URL: https://svnweb.freebsd.org/changeset/base/340515

Log:
  MFS12 r340503:
   Remove debugging options from arm, armv6, armv7 files included by
   GENERIC.  This should have been turned off when stable/12 branched.
  
  Submitted by:   thompsa
  Approved by:  re (rgrimes)
  Sponsored by: The FreeBSD Foundation

Modified:
  releng/12.0/sys/arm/conf/std.arm
  releng/12.0/sys/arm/conf/std.armv6
  releng/12.0/sys/arm/conf/std.armv7
Directory Properties:
  releng/12.0/   (props changed)

Modified: releng/12.0/sys/arm/conf/std.arm
==
--- releng/12.0/sys/arm/conf/std.armSat Nov 17 20:07:37 2018
(r340514)
+++ releng/12.0/sys/arm/conf/std.armSat Nov 17 20:11:20 2018
(r340515)
@@ -10,17 +10,6 @@ makeoptions  DEBUG=-g# Build kernel with 
gdb(1) debug
 optionsKDB # Enable kernel debugger support.
 optionsKDB_TRACE   # Print a stack trace for a panic.
 
-# For full debugger support use (turn off in stable branch):
-optionsDDB # Support DDB
-#options   DEADLKRES   # Enable the deadlock resolver
-optionsINVARIANTS  # Enable calls of extra sanity checking
-optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
-optionsWITNESS # Enable checks to detect deadlocks and 
cycles
-optionsWITNESS_SKIPSPIN# Don't run witness on spinlocks for 
speed
-#options   MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
-optionsALT_BREAK_TO_DEBUGGER   # Enter debugger on keyboard escape 
sequence
-optionsUSB_DEBUG   # Enable usb debug support code
-
 # Optional extras, never enabled by default:
 #options   BOOTVERBOSE
 #options   DEBUG   # May result in extreme spewage

Modified: releng/12.0/sys/arm/conf/std.armv6
==
--- releng/12.0/sys/arm/conf/std.armv6  Sat Nov 17 20:07:37 2018
(r340514)
+++ releng/12.0/sys/arm/conf/std.armv6  Sat Nov 17 20:11:20 2018
(r340515)
@@ -60,17 +60,6 @@ makeoptions  DEBUG=-g# Build kernel with 
gdb(1) debug
 optionsKDB # Enable kernel debugger support.
 optionsKDB_TRACE   # Print a stack trace for a panic.
 
-# For full debugger support use (turn off in stable branch):
-optionsDDB # Support DDB
-#options   DEADLKRES   # Enable the deadlock resolver
-optionsINVARIANTS  # Enable calls of extra sanity checking
-optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
-optionsWITNESS # Enable checks to detect deadlocks and 
cycles
-optionsWITNESS_SKIPSPIN# Don't run witness on spinlocks for 
speed
-optionsMALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
-optionsALT_BREAK_TO_DEBUGGER   # Enter debugger on keyboard escape 
sequence
-optionsUSB_DEBUG   # Enable usb debug support code
-
 # Optional extras, never enabled by default:
 #options   BOOTVERBOSE
 #options   DEBUG   # May result in extreme spewage

Modified: releng/12.0/sys/arm/conf/std.armv7
==
--- releng/12.0/sys/arm/conf/std.armv7  Sat Nov 17 20:07:37 2018
(r340514)
+++ releng/12.0/sys/arm/conf/std.armv7  Sat Nov 17 20:11:20 2018
(r340515)
@@ -60,17 +60,6 @@ makeoptions  DEBUG=-g# Build kernel with 
gdb(1) debug
 optionsKDB # Enable kernel debugger support.
 optionsKDB_TRACE   # Print a stack trace for a panic.
 
-# For full debugger support use (turn off in stable branch):
-optionsDDB # Support DDB
-#options   DEADLKRES   # Enable the deadlock resolver
-optionsINVARIANTS  # Enable calls of extra sanity checking
-optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
-optionsWITNESS # Enable checks to detect deadlocks and 
cycles
-optionsWITNESS_SKIPSPIN# Don't run witness on spinlocks for 
speed
-optionsMALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
-optionsALT_BREAK_TO_DEBUGGER   # Enter debugger on keyboard escape 
sequence
-optionsUSB_DEBUG   # Enable usb debug support code
-
 # Optional extras, never enabled by default:
 #options   BOOTVERBOSE
 #options   DEBUG   # May result in extreme spewage
___
svn-src-all@freebsd.org mailing list

svn commit: r340514 - stable/12/sys/kern

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:07:37 2018
New Revision: 340514
URL: https://svnweb.freebsd.org/changeset/base/340514

Log:
  MFC r339737:
  Remove a dead store.

Modified:
  stable/12/sys/kern/vfs_mountroot.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/vfs_mountroot.c
==
--- stable/12/sys/kern/vfs_mountroot.c  Sat Nov 17 20:04:38 2018
(r340513)
+++ stable/12/sys/kern/vfs_mountroot.c  Sat Nov 17 20:07:37 2018
(r340514)
@@ -579,7 +579,7 @@ parse_dir_md(char **conf)
 
if (root_mount_mddev != -1) {
mdio->md_unit = root_mount_mddev;
-   error = kern_ioctl(td, fd, MDIOCDETACH, (void *)mdio);
+   (void)kern_ioctl(td, fd, MDIOCDETACH, (void *)mdio);
/* Ignore errors. We don't care. */
root_mount_mddev = -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: r340513 - in stable/12/sys: kern sys

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:04:38 2018
New Revision: 340513
URL: https://svnweb.freebsd.org/changeset/base/340513

Log:
  MFC r339599:
  Don't import 0 into vmem quantum caches.

Modified:
  stable/12/sys/kern/subr_vmem.c
  stable/12/sys/sys/vmem.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/subr_vmem.c
==
--- stable/12/sys/kern/subr_vmem.c  Sat Nov 17 20:02:57 2018
(r340512)
+++ stable/12/sys/kern/subr_vmem.c  Sat Nov 17 20:04:38 2018
(r340513)
@@ -504,6 +504,9 @@ bt_insfree(vmem_t *vm, bt_t *bt)
 
 /*
  * Import from the arena into the quantum cache in UMA.
+ *
+ * We use VMEM_ADDR_QCACHE_MIN instead of 0: uma_zalloc() returns 0 to indicate
+ * failure, so UMA can't be used to cache a resource with value 0.
  */
 static int
 qc_import(void *arg, void **store, int cnt, int domain, int flags)
@@ -512,19 +515,16 @@ qc_import(void *arg, void **store, int cnt, int domain
vmem_addr_t addr;
int i;
 
+   KASSERT((flags & M_WAITOK) == 0, ("blocking allocation"));
+
qc = arg;
-   if ((flags & VMEM_FITMASK) == 0)
-   flags |= M_BESTFIT;
for (i = 0; i < cnt; i++) {
if (vmem_xalloc(qc->qc_vmem, qc->qc_size, 0, 0, 0,
-   VMEM_ADDR_MIN, VMEM_ADDR_MAX, flags, ) != 0)
+   VMEM_ADDR_QCACHE_MIN, VMEM_ADDR_MAX, flags, ) != 0)
break;
store[i] = (void *)addr;
-   /* Only guarantee one allocation. */
-   flags &= ~M_WAITOK;
-   flags |= M_NOWAIT;
}
-   return i;
+   return (i);
 }
 
 /*
@@ -1123,15 +1123,20 @@ vmem_alloc(vmem_t *vm, vmem_size_t size, int flags, vm
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "vmem_alloc");
 
if (size <= vm->vm_qcache_max) {
+   /*
+* Resource 0 cannot be cached, so avoid a blocking allocation
+* in qc_import() and give the vmem_xalloc() call below a chance
+* to return 0.
+*/
qc = >vm_qcache[(size - 1) >> vm->vm_quantum_shift];
-   *addrp = (vmem_addr_t)uma_zalloc(qc->qc_cache, flags);
-   if (*addrp == 0)
-   return (ENOMEM);
-   return (0);
+   *addrp = (vmem_addr_t)uma_zalloc(qc->qc_cache,
+   (flags & ~M_WAITOK) | M_NOWAIT);
+   if (__predict_true(*addrp != 0))
+   return (0);
}
 
-   return vmem_xalloc(vm, size, 0, 0, 0, VMEM_ADDR_MIN, VMEM_ADDR_MAX,
-   flags, addrp);
+   return (vmem_xalloc(vm, size, 0, 0, 0, VMEM_ADDR_MIN, VMEM_ADDR_MAX,
+   flags, addrp));
 }
 
 int
@@ -1263,7 +1268,8 @@ vmem_free(vmem_t *vm, vmem_addr_t addr, vmem_size_t si
qcache_t *qc;
MPASS(size > 0);
 
-   if (size <= vm->vm_qcache_max) {
+   if (size <= vm->vm_qcache_max &&
+   __predict_true(addr >= VMEM_ADDR_QCACHE_MIN)) {
qc = >vm_qcache[(size - 1) >> vm->vm_quantum_shift];
uma_zfree(qc->qc_cache, (void *)addr);
} else

Modified: stable/12/sys/sys/vmem.h
==
--- stable/12/sys/sys/vmem.hSat Nov 17 20:02:57 2018(r340512)
+++ stable/12/sys/sys/vmem.hSat Nov 17 20:04:38 2018(r340513)
@@ -41,8 +41,9 @@ typedef struct vmem vmem_t;
 typedef uintptr_t  vmem_addr_t;
 typedef size_t vmem_size_t;
 
-#defineVMEM_ADDR_MIN   0
-#defineVMEM_ADDR_MAX   (~(vmem_addr_t)0)
+#defineVMEM_ADDR_MIN   0
+#defineVMEM_ADDR_QCACHE_MIN1
+#defineVMEM_ADDR_MAX   (~(vmem_addr_t)0)
 
 typedef int (vmem_import_t)(void *, vmem_size_t, int, vmem_addr_t *);
 typedef void (vmem_release_t)(void *, vmem_addr_t, vmem_size_t);
___
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: r340512 - stable/12/sys/netinet6

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:02:57 2018
New Revision: 340512
URL: https://svnweb.freebsd.org/changeset/base/340512

Log:
  MFC r339598:
  Fix style bugs in in6_pcblookup_lbgroup().

Modified:
  stable/12/sys/netinet6/in6_pcb.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet6/in6_pcb.c
==
--- stable/12/sys/netinet6/in6_pcb.cSat Nov 17 20:01:35 2018
(r340511)
+++ stable/12/sys/netinet6/in6_pcb.cSat Nov 17 20:02:57 2018
(r340512)
@@ -873,10 +873,9 @@ in6_pcblookup_lbgroup(const struct inpcbinfo *pcbinfo,
 const struct in6_addr *laddr, uint16_t lport, const struct in6_addr *faddr,
 uint16_t fport, int lookupflags)
 {
-   struct inpcb *local_wild = NULL;
+   struct inpcb *local_wild;
const struct inpcblbgrouphead *hdr;
struct inpcblbgroup *grp;
-   struct inpcblbgroup *grp_local_wild;
uint32_t idx;
 
INP_HASH_LOCK_ASSERT(pcbinfo);
@@ -893,33 +892,24 @@ in6_pcblookup_lbgroup(const struct inpcbinfo *pcbinfo,
 * - Load balanced group does not contain jailed sockets.
 * - Load balanced does not contain IPv4 mapped INET6 wild sockets.
 */
+   local_wild = NULL;
CK_LIST_FOREACH(grp, hdr, il_list) {
 #ifdef INET
if (!(grp->il_vflag & INP_IPV6))
continue;
 #endif
-   if (grp->il_lport == lport) {
-   idx = 0;
-   int pkt_hash = INP_PCBLBGROUP_PKTHASH(
-   INP6_PCBHASHKEY(faddr), lport, fport);
+   if (grp->il_lport != lport)
+   continue;
 
-   idx = pkt_hash % grp->il_inpcnt;
-
-   if (IN6_ARE_ADDR_EQUAL(>il6_laddr, laddr)) {
-   return (grp->il_inp[idx]);
-   } else {
-   if (IN6_IS_ADDR_UNSPECIFIED(>il6_laddr) &&
-   (lookupflags & INPLOOKUP_WILDCARD)) {
-   local_wild = grp->il_inp[idx];
-   grp_local_wild = grp;
-   }
-   }
-   }
+   idx = INP_PCBLBGROUP_PKTHASH(INP6_PCBHASHKEY(faddr), lport,
+   fport) % grp->il_inpcnt;
+   if (IN6_ARE_ADDR_EQUAL(>il6_laddr, laddr))
+   return (grp->il_inp[idx]);
+   if (IN6_IS_ADDR_UNSPECIFIED(>il6_laddr) &&
+   (lookupflags & INPLOOKUP_WILDCARD) != 0)
+   local_wild = grp->il_inp[idx];
}
-   if (local_wild != NULL) {
-   return (local_wild);
-   }
-   return (NULL);
+   return (local_wild);
 }
 
 #ifdef PCBGROUP
___
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: r340511 - stable/12/sys/kern

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:01:35 2018
New Revision: 340511
URL: https://svnweb.freebsd.org/changeset/base/340511

Log:
  MFC r339731:
  Add FALLTHROUGH comments to appease Coverity.

Modified:
  stable/12/sys/kern/kern_environment.c
  stable/12/sys/kern/vfs_mount.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/kern_environment.c
==
--- stable/12/sys/kern/kern_environment.c   Sat Nov 17 20:00:10 2018
(r340510)
+++ stable/12/sys/kern/kern_environment.c   Sat Nov 17 20:01:35 2018
(r340511)
@@ -839,10 +839,13 @@ getenv_quad(const char *name, quad_t *data)
switch (vtp[0]) {
case 't': case 'T':
iv *= 1024;
+   /* FALLTHROUGH */
case 'g': case 'G':
iv *= 1024;
+   /* FALLTHROUGH */
case 'm': case 'M':
iv *= 1024;
+   /* FALLTHROUGH */
case 'k': case 'K':
iv *= 1024;
case '\0':

Modified: stable/12/sys/kern/vfs_mount.c
==
--- stable/12/sys/kern/vfs_mount.c  Sat Nov 17 20:00:10 2018
(r340510)
+++ stable/12/sys/kern/vfs_mount.c  Sat Nov 17 20:01:35 2018
(r340511)
@@ -1643,17 +1643,16 @@ vfs_getopt_size(struct vfsoptlist *opts, const char *n
if (iv < 0)
return (EINVAL);
switch (vtp[0]) {
-   case 't':
-   case 'T':
+   case 't': case 'T':
iv *= 1024;
-   case 'g':
-   case 'G':
+   /* FALLTHROUGH */
+   case 'g': case 'G':
iv *= 1024;
-   case 'm':
-   case 'M':
+   /* FALLTHROUGH */
+   case 'm': case 'M':
iv *= 1024;
-   case 'k':
-   case 'K':
+   /* FALLTHROUGH */
+   case 'k': case 'K':
iv *= 1024;
case '\0':
break;
___
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: r340510 - stable/12/sys/kern

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 20:00:10 2018
New Revision: 340510
URL: https://svnweb.freebsd.org/changeset/base/340510

Log:
  MFC r339728:
  Remove a redundant check.

Modified:
  stable/12/sys/kern/subr_vmem.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/subr_vmem.c
==
--- stable/12/sys/kern/subr_vmem.c  Sat Nov 17 19:58:34 2018
(r340509)
+++ stable/12/sys/kern/subr_vmem.c  Sat Nov 17 20:00:10 2018
(r340510)
@@ -283,7 +283,7 @@ bt_fill(vmem_t *vm, int flags)
VMEM_UNLOCK(vm);
bt = uma_zalloc(vmem_bt_zone, flags);
VMEM_LOCK(vm);
-   if (bt == NULL && (flags & M_NOWAIT) != 0)
+   if (bt == NULL)
break;
}
LIST_INSERT_HEAD(>vm_freetags, bt, bt_freelist);
___
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: r340509 - in stable/12: lib/libc/stdio share/man/man4 sys/netinet/netdump

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 19:58:34 2018
New Revision: 340509
URL: https://svnweb.freebsd.org/changeset/base/340509

Log:
  MFC r339883:
  Expose some netdump configuration parameters through sysctl.

Modified:
  stable/12/lib/libc/stdio/fopen.3
  stable/12/share/man/man4/netdump.4
  stable/12/sys/netinet/netdump/netdump_client.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/stdio/fopen.3
==
--- stable/12/lib/libc/stdio/fopen.3Sat Nov 17 19:19:37 2018
(r340508)
+++ stable/12/lib/libc/stdio/fopen.3Sat Nov 17 19:58:34 2018
(r340509)
@@ -119,8 +119,8 @@ or the first letter.
 This is strictly for compatibility with
 .St -isoC
 and has effect only for
-.Fn fmemopen
-; otherwise
+.Fn fmemopen ;
+otherwise
 .Dq Li b
 is ignored.
 .Pp

Modified: stable/12/share/man/man4/netdump.4
==
--- stable/12/share/man/man4/netdump.4  Sat Nov 17 19:19:37 2018
(r340508)
+++ stable/12/share/man/man4/netdump.4  Sat Nov 17 19:58:34 2018
(r340509)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 8, 2018
+.Dd October 29, 2018
 .Dt NETDUMP 4
 .Os
 .Sh NAME
@@ -130,6 +130,19 @@ a path of
 will cause the server to attempt to store dumps from the client in
 .Pa /var/crash/foo .
 The server will not automatically create the relative directory.
+.It Va net.netdump.polls
+The client will poll the configured network interface while waiting for
+acknowledgements.
+This parameter controls the maximum number of poll attempts before giving
+up, which typically results in a re-transmit.
+Each poll attempt takes 0.5ms.
+.It Va net.netdump.retries
+The number of times the client will re-transmit a packet before aborting
+a dump due to a lack of acknowledgement.
+The default may be too small in environments with lots of packet loss.
+.It Va net.netdump.arp_retries
+The number of times the client will attempt to learn the MAC address of
+the configured gateway or server before giving up and aborting the dump.
 .El
 .Sh SEE ALSO
 .Xr decryptcore 8 ,

Modified: stable/12/sys/netinet/netdump/netdump_client.c
==
--- stable/12/sys/netinet/netdump/netdump_client.c  Sat Nov 17 19:19:37 
2018(r340508)
+++ stable/12/sys/netinet/netdump/netdump_client.c  Sat Nov 17 19:58:34 
2018(r340509)
@@ -117,18 +117,6 @@ static int restore_gw_addr;
 static uint64_t rcvd_acks;
 CTASSERT(sizeof(rcvd_acks) * NBBY == NETDUMP_MAX_IN_FLIGHT);
 
-/*
- * Times to poll the NIC (0.5ms each poll) before assuming packetloss
- * occurred (default to 1s).
- */
-static int nd_polls = 2000;
-
-/* Times to retransmit lost packets. */
-static int nd_retries = 10;
-
-/* Number of ARP retries. */
-static int nd_arp_retries = 3;
-
 /* Configuration parameters. */
 static struct netdump_conf nd_conf;
 #definend_server   nd_conf.ndc_server
@@ -157,6 +145,18 @@ static char nd_path[MAXPATHLEN];
 SYSCTL_STRING(_net_netdump, OID_AUTO, path, CTLFLAG_RW,
 nd_path, sizeof(nd_path),
 "Server path for output files");
+static int nd_polls = 2000;
+SYSCTL_INT(_net_netdump, OID_AUTO, polls, CTLFLAG_RWTUN,
+_polls, 0,
+"Number of times to poll before assuming packet loss (0.5ms per poll)");
+static int nd_retries = 10;
+SYSCTL_INT(_net_netdump, OID_AUTO, retries, CTLFLAG_RWTUN,
+_retries, 0,
+"Number of retransmit attempts before giving up");
+static int nd_arp_retries = 3;
+SYSCTL_INT(_net_netdump, OID_AUTO, arp_retries, CTLFLAG_RWTUN,
+_arp_retries, 0,
+"Number of ARP attempts before giving up");
 
 /*
  * Checks for netdump support on a network interface
___
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: r340508 - head/lib/libbe

2018-11-17 Thread Kyle Evans
Author: kevans
Date: Sat Nov 17 19:19:37 2018
New Revision: 340508
URL: https://svnweb.freebsd.org/changeset/base/340508

Log:
  libbe(3): Rewrite be_unmount to stop mucking with getmntinfo(2)
  
  Go through the ZFS layer instead; given a BE, we can derive the dataset,
  zfs_open it, then zfs_unmount. ZFS takes care of the dirty details and
  likely gets it more correct than we did for more interesting setups.
  
  MFC after:3 days

Modified:
  head/lib/libbe/be_access.c

Modified: head/lib/libbe/be_access.c
==
--- head/lib/libbe/be_access.c  Sat Nov 17 19:15:29 2018(r340507)
+++ head/lib/libbe/be_access.c  Sat Nov 17 19:19:37 2018(r340508)
@@ -164,37 +164,18 @@ be_unmount(libbe_handle_t *lbh, char *bootenv, int fla
 {
int err, mntflags;
char be[BE_MAXPATHLEN];
-   struct statfs *mntbuf;
-   int mntsize;
-   char *mntpath;
+   zfs_handle_t *root_hdl;
 
if ((err = be_root_concat(lbh, bootenv, be)) != 0)
return (set_error(lbh, err));
 
-   if ((mntsize = getmntinfo(, MNT_NOWAIT)) == 0) {
-   if (errno == EIO)
-   return (set_error(lbh, BE_ERR_IO));
-   return (set_error(lbh, BE_ERR_NOMOUNT));
-   }
+   if ((root_hdl = zfs_open(lbh->lzh, be, ZFS_TYPE_FILESYSTEM)) == NULL)
+   return (set_error(lbh, BE_ERR_ZFSOPEN));
 
-   mntpath = NULL;
-   for (int i = 0; i < mntsize; ++i) {
-   /* 0x00de is the type number of zfs */
-   if (mntbuf[i].f_type != 0x00de)
-   continue;
+   mntflags = (flags & BE_MNT_FORCE) ? MS_FORCE : 0;
 
-   if (strcmp(mntbuf[i].f_mntfromname, be) == 0) {
-   mntpath = mntbuf[i].f_mntonname;
-   break;
-   }
-   }
-
-   if (mntpath == NULL)
-   return (set_error(lbh, BE_ERR_NOMOUNT));
-
-   mntflags = (flags & BE_MNT_FORCE) ? MNT_FORCE : 0;
-
-   if ((err = unmount(mntpath, mntflags)) != 0) {
+   if (zfs_unmount(root_hdl, NULL, mntflags) != 0) {
+   zfs_close(root_hdl);
switch (errno) {
case ENAMETOOLONG:
return (set_error(lbh, BE_ERR_PATHLEN));
@@ -210,6 +191,7 @@ be_unmount(libbe_handle_t *lbh, char *bootenv, int fla
return (set_error(lbh, BE_ERR_UNKNOWN));
}
}
+   zfs_close(root_hdl);
 
-   return (set_error(lbh, BE_ERR_SUCCESS));
+   return (BE_ERR_SUCCESS);
 }
___
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: r340507 - head/lib/libbe

2018-11-17 Thread Kyle Evans
Author: kevans
Date: Sat Nov 17 19:15:29 2018
New Revision: 340507
URL: https://svnweb.freebsd.org/changeset/base/340507

Log:
  libbe(3): rewrite init to support chroot usage
  
  libbe(3) currently uses zfs_be_root and locates which of its children is
  currently mounted at "/". This is reasonable, but not correct in the case of
  a chroot, for two reasons:
  
  - chroot root may be of a different zpool than zfs_be_root
  - chroot root will not show up as mounted at "/"
  
  Fix both of these by rewriting libbe_init to work from the rootfs down.
  zfs_path_to_zhandle on / will resolve to the dataset mounted at the new
  root, rather than the real root. From there, we can derive the BE root/pool
  and grab the bootfs off of the new pool. This does no harm in the average
  case, and opens up bectl to operating on different pools for scenarios where
  one may be, for instance, updating a pool that generally gets re-rooted into
  from a separate UFS root or zfs bootpool.
  
  While here, I've also:
  - Eliminated the check for /boot and / to be on the same partition. This
leaves one open to a setup where /boot (and consequently, kernel/modules)
are not included in the boot environment. This may very well be an
intentional setup done by someone that knows what they're doing, we should
not kill BE usage because of it.
  
  - Eliminated the validation bits of BEs and snapshots that enforced
'mountpoint' to be "/" -- this broke when trying to operate on an imported
pool with an altroot, but we need not be this picky.
  
  Reported by:  philip
  Reviewed by:  philip, allanjude (previous version)
  Tested by:philip
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D18012

Modified:
  head/lib/libbe/be.c
  head/lib/libbe/be_info.c

Modified: head/lib/libbe/be.c
==
--- head/lib/libbe/be.c Sat Nov 17 19:02:50 2018(r340506)
+++ head/lib/libbe/be.c Sat Nov 17 19:15:29 2018(r340507)
@@ -29,11 +29,12 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
+#include 
 #include 
-#include 
+#include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -55,23 +56,16 @@ static int be_create_child_cloned(libbe_handle_t *lbh,
  * zfs_be_root set by loader(8).  data is expected to be a libbe_handle_t *.
  */
 static int
-be_locate_rootfs(zfs_handle_t *chkds, void *data)
+be_locate_rootfs(libbe_handle_t *lbh)
 {
-   libbe_handle_t *lbh;
-   char *mntpoint;
+   zfs_handle_t *zfs;
 
-   lbh = (libbe_handle_t *)data;
-   if (lbh == NULL)
+   zfs = zfs_path_to_zhandle(lbh->lzh, "/", ZFS_TYPE_FILESYSTEM);
+   if (zfs == NULL)
return (1);
 
-   mntpoint = NULL;
-   if (zfs_is_mounted(chkds, ) && strcmp(mntpoint, "/") == 0) {
-   strlcpy(lbh->rootfs, zfs_get_name(chkds), sizeof(lbh->rootfs));
-   free(mntpoint);
-   return (1);
-   } else if(mntpoint != NULL)
-   free(mntpoint);
-
+   strlcpy(lbh->rootfs, zfs_get_name(zfs), sizeof(lbh->rootfs));
+   zfs_close(zfs);
return (0);
 }
 
@@ -82,49 +76,29 @@ be_locate_rootfs(zfs_handle_t *chkds, void *data)
 libbe_handle_t *
 libbe_init(void)
 {
-   struct stat sb;
-   dev_t root_dev, boot_dev;
libbe_handle_t *lbh;
-   zfs_handle_t *rootds;
char *poolname, *pos;
int pnamelen;
 
lbh = NULL;
poolname = pos = NULL;
-   rootds = NULL;
 
-   /* Verify that /boot and / are mounted on the same filesystem */
-   /* TODO: use errno here?? */
-   if (stat("/", ) != 0)
-   goto err;
-
-   root_dev = sb.st_dev;
-
-   if (stat("/boot", ) != 0)
-   goto err;
-
-   boot_dev = sb.st_dev;
-
-   if (root_dev != boot_dev) {
-   fprintf(stderr, "/ and /boot not on same device, quitting\n");
-   goto err;
-   }
-
if ((lbh = calloc(1, sizeof(libbe_handle_t))) == NULL)
goto err;
 
if ((lbh->lzh = libzfs_init()) == NULL)
goto err;
 
-   /* Obtain path to boot environment root */
-   if ((kenv(KENV_GET, "zfs_be_root", lbh->root,
-   sizeof(lbh->root))) == -1)
+   /* Grab rootfs, we'll work backwards from there */
+   if (be_locate_rootfs(lbh) != 0)
goto err;
 
-   /* Remove leading 'zfs:' if present, otherwise use value as-is */
-   if (strcmp(lbh->root, "zfs:") == 0)
-   strlcpy(lbh->root, strchr(lbh->root, ':') + sizeof(char),
-   sizeof(lbh->root));
+   /* Strip off the final slash from the rootfs to get the be root */
+   strlcpy(lbh->root, lbh->rootfs, sizeof(lbh->root));
+   pos = strrchr(lbh->root, '/');
+   if (pos == NULL)
+   goto err;
+   *pos = '\0';
 
if ((pos = strchr(lbh->root, '/')) == NULL)
goto err;
@@ -144,17 +118,6 

svn commit: r340506 - stable/12/sys/vm

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 19:02:50 2018
New Revision: 340506
URL: https://svnweb.freebsd.org/changeset/base/340506

Log:
  MFC r340174:
  Initialize last_target in the laundry thread control loop.

Modified:
  stable/12/sys/vm/vm_pageout.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/vm/vm_pageout.c
==
--- stable/12/sys/vm/vm_pageout.c   Sat Nov 17 19:01:40 2018
(r340505)
+++ stable/12/sys/vm/vm_pageout.c   Sat Nov 17 19:02:50 2018
(r340506)
@@ -973,7 +973,7 @@ vm_pageout_laundry_worker(void *arg)
shortfall = 0;
in_shortfall = false;
shortfall_cycle = 0;
-   target = 0;
+   last_target = target = 0;
nfreed = 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: r340505 - in stable/12/sys: netinet netinet6

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 19:01:40 2018
New Revision: 340505
URL: https://svnweb.freebsd.org/changeset/base/340505

Log:
  MFC r340005:
  Remove redundant checks for a NULL lbgroup table.

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

Modified: stable/12/sys/netinet/in_pcb.c
==
--- stable/12/sys/netinet/in_pcb.c  Sat Nov 17 19:00:44 2018
(r340504)
+++ stable/12/sys/netinet/in_pcb.c  Sat Nov 17 19:01:40 2018
(r340505)
@@ -322,9 +322,6 @@ in_pcbinslbgrouphash(struct inpcb *inp)
INP_WLOCK_ASSERT(inp);
INP_HASH_WLOCK_ASSERT(pcbinfo);
 
-   if (pcbinfo->ipi_lbgrouphashbase == NULL)
-   return (0);
-
/*
 * Don't allow jailed socket to join local group.
 */
@@ -399,9 +396,6 @@ in_pcbremlbgrouphash(struct inpcb *inp)
INP_WLOCK_ASSERT(inp);
INP_HASH_WLOCK_ASSERT(pcbinfo);
 
-   if (pcbinfo->ipi_lbgrouphashbase == NULL)
-   return;
-
hdr = >ipi_lbgrouphashbase[
INP_PCBLBGROUP_PORTHASH(inp->inp_lport,
pcbinfo->ipi_lbgrouphashmask)];
@@ -2276,13 +2270,11 @@ in_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, st
/*
 * Then look in lb group (for wildcard match).
 */
-   if (pcbinfo->ipi_lbgrouphashbase != NULL &&
-   (lookupflags & INPLOOKUP_WILDCARD)) {
+   if ((lookupflags & INPLOOKUP_WILDCARD) != 0) {
inp = in_pcblookup_lbgroup(pcbinfo, , lport, ,
fport, lookupflags);
-   if (inp != NULL) {
+   if (inp != NULL)
return (inp);
-   }
}
 
/*

Modified: stable/12/sys/netinet6/in6_pcb.c
==
--- stable/12/sys/netinet6/in6_pcb.cSat Nov 17 19:00:44 2018
(r340504)
+++ stable/12/sys/netinet6/in6_pcb.cSat Nov 17 19:01:40 2018
(r340505)
@@ -1171,13 +1171,11 @@ in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, s
/*
 * Then look in lb group (for wildcard match).
 */
-   if (pcbinfo->ipi_lbgrouphashbase != NULL &&
-   (lookupflags & INPLOOKUP_WILDCARD)) {
+   if ((lookupflags & INPLOOKUP_WILDCARD) != 0) {
inp = in6_pcblookup_lbgroup(pcbinfo, laddr, lport, faddr,
fport, lookupflags);
-   if (inp != NULL) {
+   if (inp != NULL)
return (inp);
-   }
}
 
/*
___
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: r340504 - stable/12/sys/netinet

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 19:00:44 2018
New Revision: 340504
URL: https://svnweb.freebsd.org/changeset/base/340504

Log:
  MFC r340004:
  Improve style in in_pcbinslbgrouphash() and related subroutines.

Modified:
  stable/12/sys/netinet/in_pcb.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet/in_pcb.c
==
--- stable/12/sys/netinet/in_pcb.c  Sat Nov 17 18:58:06 2018
(r340503)
+++ stable/12/sys/netinet/in_pcb.c  Sat Nov 17 19:00:44 2018
(r340504)
@@ -266,7 +266,7 @@ in_pcblbgroup_resize(struct inpcblbgrouphead *hdr,
 
grp = in_pcblbgroup_alloc(hdr, old_grp->il_vflag,
old_grp->il_lport, _grp->il_dependladdr, size);
-   if (!grp)
+   if (grp == NULL)
return (NULL);
 
KASSERT(old_grp->il_inpcnt < grp->il_inpsiz,
@@ -288,21 +288,20 @@ static void
 in_pcblbgroup_reorder(struct inpcblbgrouphead *hdr, struct inpcblbgroup **grpp,
 int i)
 {
-   struct inpcblbgroup *grp = *grpp;
+   struct inpcblbgroup *grp, *new_grp;
 
+   grp = *grpp;
for (; i + 1 < grp->il_inpcnt; ++i)
grp->il_inp[i] = grp->il_inp[i + 1];
grp->il_inpcnt--;
 
if (grp->il_inpsiz > INPCBLBGROUP_SIZMIN &&
-   grp->il_inpcnt <= (grp->il_inpsiz / 4)) {
+   grp->il_inpcnt <= grp->il_inpsiz / 4) {
/* Shrink this group. */
-   struct inpcblbgroup *new_grp =
-   in_pcblbgroup_resize(hdr, grp, grp->il_inpsiz / 2);
-   if (new_grp)
+   new_grp = in_pcblbgroup_resize(hdr, grp, grp->il_inpsiz / 2);
+   if (new_grp != NULL)
*grpp = new_grp;
}
-   return;
 }
 
 /*
@@ -316,9 +315,7 @@ in_pcbinslbgrouphash(struct inpcb *inp)
struct inpcbinfo *pcbinfo;
struct inpcblbgrouphead *hdr;
struct inpcblbgroup *grp;
-   uint16_t hashmask, lport;
-   uint32_t group_index;
-   struct ucred *cred;
+   uint32_t idx;
 
pcbinfo = inp->inp_pcbinfo;
 
@@ -328,19 +325,10 @@ in_pcbinslbgrouphash(struct inpcb *inp)
if (pcbinfo->ipi_lbgrouphashbase == NULL)
return (0);
 
-   hashmask = pcbinfo->ipi_lbgrouphashmask;
-   lport = inp->inp_lport;
-   group_index = INP_PCBLBGROUP_PORTHASH(lport, hashmask);
-   hdr = >ipi_lbgrouphashbase[group_index];
-
/*
 * Don't allow jailed socket to join local group.
 */
-   if (inp->inp_socket != NULL)
-   cred = inp->inp_socket->so_cred;
-   else
-   cred = NULL;
-   if (cred != NULL && jailed(cred))
+   if (inp->inp_socket != NULL && jailed(inp->inp_socket->so_cred))
return (0);
 
 #ifdef INET6
@@ -354,24 +342,23 @@ in_pcbinslbgrouphash(struct inpcb *inp)
}
 #endif
 
-   hdr = >ipi_lbgrouphashbase[
-   INP_PCBLBGROUP_PORTHASH(inp->inp_lport,
-   pcbinfo->ipi_lbgrouphashmask)];
+   idx = INP_PCBLBGROUP_PORTHASH(inp->inp_lport,
+   pcbinfo->ipi_lbgrouphashmask);
+   hdr = >ipi_lbgrouphashbase[idx];
CK_LIST_FOREACH(grp, hdr, il_list) {
if (grp->il_vflag == inp->inp_vflag &&
grp->il_lport == inp->inp_lport &&
memcmp(>il_dependladdr,
-   >inp_inc.inc_ie.ie_dependladdr,
-   sizeof(grp->il_dependladdr)) == 0) {
+   >inp_inc.inc_ie.ie_dependladdr,
+   sizeof(grp->il_dependladdr)) == 0)
break;
-   }
}
if (grp == NULL) {
/* Create new load balance group. */
grp = in_pcblbgroup_alloc(hdr, inp->inp_vflag,
inp->inp_lport, >inp_inc.inc_ie.ie_dependladdr,
INPCBLBGROUP_SIZMIN);
-   if (!grp)
+   if (grp == NULL)
return (ENOBUFS);
} else if (grp->il_inpcnt == grp->il_inpsiz) {
if (grp->il_inpsiz >= INPCBLBGROUP_SIZMAX) {
@@ -383,13 +370,13 @@ in_pcbinslbgrouphash(struct inpcb *inp)
 
/* Expand this local group. */
grp = in_pcblbgroup_resize(hdr, grp, grp->il_inpsiz * 2);
-   if (!grp)
+   if (grp == NULL)
return (ENOBUFS);
}
 
KASSERT(grp->il_inpcnt < grp->il_inpsiz,
-   ("invalid local group size %d and count %d",
-grp->il_inpsiz, grp->il_inpcnt));
+   ("invalid local group size %d and count %d", grp->il_inpsiz,
+   grp->il_inpcnt));
 
grp->il_inp[grp->il_inpcnt] = inp;
grp->il_inpcnt++;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to 

svn commit: r340503 - stable/12/sys/arm/conf

2018-11-17 Thread Glen Barber
Author: gjb
Date: Sat Nov 17 18:58:06 2018
New Revision: 340503
URL: https://svnweb.freebsd.org/changeset/base/340503

Log:
  Remove debugging options from arm, armv6, armv7 files included by
  GENERIC.  This should have been turned off when stable/12 branched.
  
  This is a direct commit to stable/12.
  
  Submitted by: thompsa
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/arm/conf/std.arm
  stable/12/sys/arm/conf/std.armv6
  stable/12/sys/arm/conf/std.armv7

Modified: stable/12/sys/arm/conf/std.arm
==
--- stable/12/sys/arm/conf/std.arm  Sat Nov 17 18:55:53 2018
(r340502)
+++ stable/12/sys/arm/conf/std.arm  Sat Nov 17 18:58:06 2018
(r340503)
@@ -10,17 +10,6 @@ makeoptions  DEBUG=-g# Build kernel with 
gdb(1) debug
 optionsKDB # Enable kernel debugger support.
 optionsKDB_TRACE   # Print a stack trace for a panic.
 
-# For full debugger support use (turn off in stable branch):
-optionsDDB # Support DDB
-#options   DEADLKRES   # Enable the deadlock resolver
-optionsINVARIANTS  # Enable calls of extra sanity checking
-optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
-optionsWITNESS # Enable checks to detect deadlocks and 
cycles
-optionsWITNESS_SKIPSPIN# Don't run witness on spinlocks for 
speed
-#options   MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
-optionsALT_BREAK_TO_DEBUGGER   # Enter debugger on keyboard escape 
sequence
-optionsUSB_DEBUG   # Enable usb debug support code
-
 # Optional extras, never enabled by default:
 #options   BOOTVERBOSE
 #options   DEBUG   # May result in extreme spewage

Modified: stable/12/sys/arm/conf/std.armv6
==
--- stable/12/sys/arm/conf/std.armv6Sat Nov 17 18:55:53 2018
(r340502)
+++ stable/12/sys/arm/conf/std.armv6Sat Nov 17 18:58:06 2018
(r340503)
@@ -60,17 +60,6 @@ makeoptions  DEBUG=-g# Build kernel with 
gdb(1) debug
 optionsKDB # Enable kernel debugger support.
 optionsKDB_TRACE   # Print a stack trace for a panic.
 
-# For full debugger support use (turn off in stable branch):
-optionsDDB # Support DDB
-#options   DEADLKRES   # Enable the deadlock resolver
-optionsINVARIANTS  # Enable calls of extra sanity checking
-optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
-optionsWITNESS # Enable checks to detect deadlocks and 
cycles
-optionsWITNESS_SKIPSPIN# Don't run witness on spinlocks for 
speed
-optionsMALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
-optionsALT_BREAK_TO_DEBUGGER   # Enter debugger on keyboard escape 
sequence
-optionsUSB_DEBUG   # Enable usb debug support code
-
 # Optional extras, never enabled by default:
 #options   BOOTVERBOSE
 #options   DEBUG   # May result in extreme spewage

Modified: stable/12/sys/arm/conf/std.armv7
==
--- stable/12/sys/arm/conf/std.armv7Sat Nov 17 18:55:53 2018
(r340502)
+++ stable/12/sys/arm/conf/std.armv7Sat Nov 17 18:58:06 2018
(r340503)
@@ -60,17 +60,6 @@ makeoptions  DEBUG=-g# Build kernel with 
gdb(1) debug
 optionsKDB # Enable kernel debugger support.
 optionsKDB_TRACE   # Print a stack trace for a panic.
 
-# For full debugger support use (turn off in stable branch):
-optionsDDB # Support DDB
-#options   DEADLKRES   # Enable the deadlock resolver
-optionsINVARIANTS  # Enable calls of extra sanity checking
-optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
-optionsWITNESS # Enable checks to detect deadlocks and 
cycles
-optionsWITNESS_SKIPSPIN# Don't run witness on spinlocks for 
speed
-optionsMALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
-optionsALT_BREAK_TO_DEBUGGER   # Enter debugger on keyboard escape 
sequence
-optionsUSB_DEBUG   # Enable usb debug support code
-
 # Optional extras, never enabled by default:
 #options   BOOTVERBOSE
 #options   DEBUG   # May result in extreme spewage
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, 

svn commit: r340502 - stable/12/lib/libcasper/libcasper

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 18:55:53 2018
New Revision: 340502
URL: https://svnweb.freebsd.org/changeset/base/340502

Log:
  MFC r340160;
  Document the fact that cap_limit_set() always frees the input nvlist.

Modified:
  stable/12/lib/libcasper/libcasper/libcasper.3
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libcasper/libcasper/libcasper.3
==
--- stable/12/lib/libcasper/libcasper/libcasper.3   Sat Nov 17 18:54:34 
2018(r340501)
+++ stable/12/lib/libcasper/libcasper/libcasper.3   Sat Nov 17 18:55:53 
2018(r340502)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 6, 2018
+.Dd November 5, 2018
 .Dt LIBCASPER 3
 .Os
 .Sh NAME
@@ -161,9 +161,11 @@ it means there are no limits set.
 The
 .Fn cap_limit_set
 function sets limits for the given capability.
-The limits are provided as
+The limits are provided as a
 .Xr nvlist 9 .
 The exact format depends on the service the capability represents.
+.Fn cap_limit_set
+frees the limits regardless of whether the operation succeeds or fails.
 .Pp
 The
 .Fn cap_send_nvlist
___
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: r340501 - stable/12/sys/kern

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 18:54:34 2018
New Revision: 340501
URL: https://svnweb.freebsd.org/changeset/base/340501

Log:
  MFC r339820:
  Use M_WAITOK in init_hwpmc().

Modified:
  stable/12/sys/kern/kern_pmc.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/kern_pmc.c
==
--- stable/12/sys/kern/kern_pmc.c   Sat Nov 17 18:53:28 2018
(r340500)
+++ stable/12/sys/kern/kern_pmc.c   Sat Nov 17 18:54:34 2018
(r340501)
@@ -345,9 +345,8 @@ init_hwpmc(void *dummy __unused)
"range.\n", pmc_softevents);
pmc_softevents = PMC_EV_DYN_COUNT;
}
-   pmc_softs = malloc(pmc_softevents * sizeof(struct pmc_soft *), 
M_PMCHOOKS, M_NOWAIT|M_ZERO);
-   KASSERT(pmc_softs != NULL, ("cannot allocate soft events table"));
-
+   pmc_softs = malloc(pmc_softevents * sizeof(*pmc_softs), M_PMCHOOKS,
+   M_WAITOK | M_ZERO);
 
for (domain = 0; domain < vm_ndomains; domain++) {
pmc_dom_hdrs[domain] = malloc_domainset(
___
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: r340500 - stable/12/bin/getfacl

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 18:53:28 2018
New Revision: 340500
URL: https://svnweb.freebsd.org/changeset/base/340500

Log:
  MFC r340014:
  Avoid copying a struct stat for acl_from_stat() calls.

Modified:
  stable/12/bin/getfacl/getfacl.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/bin/getfacl/getfacl.c
==
--- stable/12/bin/getfacl/getfacl.c Sat Nov 17 18:51:22 2018
(r340499)
+++ stable/12/bin/getfacl/getfacl.c Sat Nov 17 18:53:28 2018
(r340500)
@@ -88,7 +88,7 @@ getgname(gid_t gid)
  * contained in struct stat
  */
 static acl_t
-acl_from_stat(struct stat sb)
+acl_from_stat(const struct stat *sb)
 {
acl_t acl;
acl_entry_t entry;
@@ -111,13 +111,13 @@ acl_from_stat(struct stat sb)
return NULL;
 
/* calculate user mode */
-   if (sb.st_mode & S_IRUSR)
+   if (sb->st_mode & S_IRUSR)
if (acl_add_perm(perms, ACL_READ) == -1)
return NULL;
-   if (sb.st_mode & S_IWUSR)
+   if (sb->st_mode & S_IWUSR)
if (acl_add_perm(perms, ACL_WRITE) == -1)
return NULL;
-   if (sb.st_mode & S_IXUSR)
+   if (sb->st_mode & S_IXUSR)
if (acl_add_perm(perms, ACL_EXECUTE) == -1)
return NULL;
if (acl_set_permset(entry, perms) == -1)
@@ -135,13 +135,13 @@ acl_from_stat(struct stat sb)
return NULL;
 
/* calculate group mode */
-   if (sb.st_mode & S_IRGRP)
+   if (sb->st_mode & S_IRGRP)
if (acl_add_perm(perms, ACL_READ) == -1)
return NULL;
-   if (sb.st_mode & S_IWGRP)
+   if (sb->st_mode & S_IWGRP)
if (acl_add_perm(perms, ACL_WRITE) == -1)
return NULL;
-   if (sb.st_mode & S_IXGRP)
+   if (sb->st_mode & S_IXGRP)
if (acl_add_perm(perms, ACL_EXECUTE) == -1)
return NULL;
if (acl_set_permset(entry, perms) == -1)
@@ -159,13 +159,13 @@ acl_from_stat(struct stat sb)
return NULL;
 
/* calculate other mode */
-   if (sb.st_mode & S_IROTH)
+   if (sb->st_mode & S_IROTH)
if (acl_add_perm(perms, ACL_READ) == -1)
return NULL;
-   if (sb.st_mode & S_IWOTH)
+   if (sb->st_mode & S_IWOTH)
if (acl_add_perm(perms, ACL_WRITE) == -1)
return NULL;
-   if (sb.st_mode & S_IXOTH)
+   if (sb->st_mode & S_IXOTH)
if (acl_add_perm(perms, ACL_EXECUTE) == -1)
return NULL;
if (acl_set_permset(entry, perms) == -1)
@@ -229,7 +229,7 @@ print_acl(char *path, acl_type_t type, int hflag, int 
errno = 0;
if (type == ACL_TYPE_DEFAULT)
return(0);
-   acl = acl_from_stat(sb);
+   acl = acl_from_stat();
if (!acl) {
warn("%s: acl_from_stat() failed", path);
return(-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: r340499 - stable/12

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 18:51:22 2018
New Revision: 340499
URL: https://svnweb.freebsd.org/changeset/base/340499

Log:
  MFC r340437:
  Fix the path to malloc_domain.9.

Modified:
  stable/12/ObsoleteFiles.inc
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/ObsoleteFiles.inc
==
--- stable/12/ObsoleteFiles.inc Sat Nov 17 18:49:52 2018(r340498)
+++ stable/12/ObsoleteFiles.inc Sat Nov 17 18:51:22 2018(r340499)
@@ -39,7 +39,7 @@
 # done
 
 # 20181030: malloc_domain(9) KPI change
-OLD_FILES+=share/man/man9/malloc_domain.9.gz
+OLD_FILES+=usr/share/man/man9/malloc_domain.9.gz
 # 20181025: OpenSSL libraries version bump to avoid conflict with ports
 OLD_LIBS+=lib/libcrypto.so.9
 OLD_LIBS+=usr/lib/libssl.so.9
___
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: r340498 - stable/12/share/man/man4

2018-11-17 Thread Mark Johnston
Author: markj
Date: Sat Nov 17 18:49:52 2018
New Revision: 340498
URL: https://svnweb.freebsd.org/changeset/base/340498

Log:
  MFC r340438:
  Hook mac_ntpd.4 up to the build.
  
  PR:   232757

Modified:
  stable/12/share/man/man4/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/Makefile
==
--- stable/12/share/man/man4/Makefile   Sat Nov 17 18:39:09 2018
(r340497)
+++ stable/12/share/man/man4/Makefile   Sat Nov 17 18:49:52 2018
(r340498)
@@ -269,6 +269,7 @@ MAN=aac.4 \
mac_lomac.4 \
mac_mls.4 \
mac_none.4 \
+   mac_ntpd.4 \
mac_partition.4 \
mac_portacl.4 \
mac_seeotheruids.4 \
___
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: r340497 - stable/12/sbin/ipfw

2018-11-17 Thread Eugene Grosbein
Author: eugen
Date: Sat Nov 17 18:39:09 2018
New Revision: 340497
URL: https://svnweb.freebsd.org/changeset/base/340497

Log:
  MFC r340249: ipfw.8: fix small syntax error in an example

Modified:
  stable/12/sbin/ipfw/ipfw.8
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/ipfw/ipfw.8
==
--- stable/12/sbin/ipfw/ipfw.8  Sat Nov 17 18:27:23 2018(r340496)
+++ stable/12/sbin/ipfw/ipfw.8  Sat Nov 17 18:39:09 2018(r340497)
@@ -4224,7 +4224,7 @@ In the following example per-interface firewall is cre
 .Pp
 The following example illustrate usage of flow tables:
 .Pp
-.Dl "ipfw table fl create type flow:flow:src-ip,proto,dst-ip,dst-port"
+.Dl "ipfw table fl create type flow:src-ip,proto,dst-ip,dst-port"
 .Dl "ipfw table fl add 2a02:6b8:77::88,tcp,2a02:6b8:77::99,80 11"
 .Dl "ipfw table fl add 10.0.0.1,udp,10.0.0.2,53 12"
 .Dl ".."
___
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: r340496 - svnadmin/conf

2018-11-17 Thread Glen Barber
Author: gjb
Date: Sat Nov 17 18:27:23 2018
New Revision: 340496
URL: https://svnweb.freebsd.org/changeset/base/340496

Log:
  Thaw stable/12 after releng/12.0 has branched.
  
  Committers are requested to excercise caution for the duration
  of the 12.0-RELEASE cycle, especially regarding changes that
  are eligible (or proposed) for MFC to releng/12.0.
  
  Approved by:  re (implicit)
  Sponsored by: The FreeBSD Foundation

Modified:
  svnadmin/conf/approvers

Modified: svnadmin/conf/approvers
==
--- svnadmin/conf/approvers Sat Nov 17 17:21:36 2018(r340495)
+++ svnadmin/conf/approvers Sat Nov 17 18:27:23 2018(r340496)
@@ -17,7 +17,7 @@
 # $FreeBSD$
 #
 #^head/re
-^stable/12/re
+#^stable/12/   re
 #^stable/11/   re
 ^release/  re
 ^releng/12.0/  re
___
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: r340495 - head/sys/dev/mmc

2018-11-17 Thread Marius Strobl
Author: marius
Date: Sat Nov 17 17:21:36 2018
New Revision: 340495
URL: https://svnweb.freebsd.org/changeset/base/340495

Log:
  - Restore setting the clock for devices which support the default/legacy
transfer mode only (lost with r321385). [1]
  - Similarly, don't try to set the power class on MMC devices that comply
to version 4.0 of the system specification but are operated in default/
legacy transfer or 1-bit bus mode as no power class is specified for
these cases. Trying to set a power class nevertheless resulted in an -
albeit harmless - error message.
  
  PR:   231713 [1]

Modified:
  head/sys/dev/mmc/mmc.c

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Sat Nov 17 16:13:09 2018(r340494)
+++ head/sys/dev/mmc/mmc.c  Sat Nov 17 17:21:36 2018(r340495)
@@ -830,9 +830,14 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_i
const uint8_t *ext_csd;
uint32_t clock;
uint8_t value;
+   enum mmc_bus_timing timing;
+   enum mmc_bus_width bus_width;
 
dev = sc->dev;
-   if (mmcbr_get_mode(dev) != mode_mmc || ivar->csd.spec_vers < 4)
+   timing = mmcbr_get_timing(dev);
+   bus_width = ivar->bus_width;
+   if (mmcbr_get_mode(dev) != mode_mmc || ivar->csd.spec_vers < 4 ||
+   timing == bus_timing_normal || bus_width == bus_width_1)
return (MMC_ERR_NONE);
 
value = 0;
@@ -843,8 +848,8 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_i
if (clock <= MMC_TYPE_HS_26_MAX)
value = ext_csd[EXT_CSD_PWR_CL_26_195];
else if (clock <= MMC_TYPE_HS_52_MAX) {
-   if (mmcbr_get_timing(dev) >= bus_timing_mmc_ddr52 &&
-   ivar->bus_width >= bus_width_4)
+   if (timing >= bus_timing_mmc_ddr52 &&
+   bus_width >= bus_width_4)
value = ext_csd[EXT_CSD_PWR_CL_52_195_DDR];
else
value = ext_csd[EXT_CSD_PWR_CL_52_195];
@@ -863,13 +868,13 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_i
if (clock <= MMC_TYPE_HS_26_MAX)
value = ext_csd[EXT_CSD_PWR_CL_26_360];
else if (clock <= MMC_TYPE_HS_52_MAX) {
-   if (mmcbr_get_timing(dev) == bus_timing_mmc_ddr52 &&
-   ivar->bus_width >= bus_width_4)
+   if (timing == bus_timing_mmc_ddr52 &&
+   bus_width >= bus_width_4)
value = ext_csd[EXT_CSD_PWR_CL_52_360_DDR];
else
value = ext_csd[EXT_CSD_PWR_CL_52_360];
} else if (clock <= MMC_TYPE_HS200_HS400ES_MAX) {
-   if (ivar->bus_width == bus_width_8)
+   if (bus_width == bus_width_8)
value = ext_csd[EXT_CSD_PWR_CL_200_360_DDR];
else
value = ext_csd[EXT_CSD_PWR_CL_200_360];
@@ -881,7 +886,7 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_i
return (MMC_ERR_INVALID);
}
 
-   if (ivar->bus_width == bus_width_8)
+   if (bus_width == bus_width_8)
value = (value & EXT_CSD_POWER_CLASS_8BIT_MASK) >>
EXT_CSD_POWER_CLASS_8BIT_SHIFT;
else
@@ -2164,7 +2169,7 @@ mmc_calculate_clock(struct mmc_softc *sc)
for (i = 0; i < sc->child_count; i++) {
ivar = device_get_ivars(sc->child_list[i]);
if ((ivar->timings & ~(1 << bus_timing_normal)) == 0)
-   continue;
+   goto clock;
 
rca = ivar->rca;
if (mmc_select_card(sc, rca) != MMC_ERR_NONE) {
@@ -2230,6 +2235,7 @@ mmc_calculate_clock(struct mmc_softc *sc)
}
}
 
+clock:
/* Set clock (must be done before initial tuning). */
mmcbr_set_clock(dev, max_dtr);
mmcbr_update_ios(dev);
___
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: r340494 - head/sys/netinet

2018-11-17 Thread Bjoern A. Zeeb
Author: bz
Date: Sat Nov 17 16:13:09 2018
New Revision: 340494
URL: https://svnweb.freebsd.org/changeset/base/340494

Log:
  Improve the comment for arpresolve_full() in if_ether.c.
  No functional changes.
  
  MFC after:6 weeks

Modified:
  head/sys/netinet/if_ether.c

Modified: head/sys/netinet/if_ether.c
==
--- head/sys/netinet/if_ether.c Sat Nov 17 16:08:36 2018(r340493)
+++ head/sys/netinet/if_ether.c Sat Nov 17 16:13:09 2018(r340494)
@@ -433,10 +433,10 @@ arprequest(struct ifnet *ifp, const struct in_addr *si
 /*
  * Resolve an IP address into an ethernet address - heavy version.
  * Used internally by arpresolve().
- * We have already checked than  we can't use existing lle without
- * modification so we have to acquire LLE_EXCLUSIVE lle lock.
+ * We have already checked that we can't use an existing lle without
+ * modification so we have to acquire an LLE_EXCLUSIVE lle lock.
  *
- * On success, desten and flags are filled in and the function returns 0;
+ * On success, desten and pflags are filled in and the function returns 0;
  * If the packet must be held pending resolution, we return EWOULDBLOCK
  * On other errors, we return the corresponding error code.
  * Note that m_freem() handles 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: r340493 - head/sys/netinet

2018-11-17 Thread Bjoern A. Zeeb
Author: bz
Date: Sat Nov 17 16:08:36 2018
New Revision: 340493
URL: https://svnweb.freebsd.org/changeset/base/340493

Log:
  Retire arpresolve_addr(), which is not used anywhere, from if_ether.c.

Modified:
  head/sys/netinet/if_ether.c
  head/sys/netinet/if_ether.h

Modified: head/sys/netinet/if_ether.c
==
--- head/sys/netinet/if_ether.c Sat Nov 17 12:59:59 2018(r340492)
+++ head/sys/netinet/if_ether.c Sat Nov 17 16:08:36 2018(r340493)
@@ -573,21 +573,6 @@ arpresolve_full(struct ifnet *ifp, int is_gw, int flag
 }
 
 /*
- * Resolve an IP address into an ethernet address.
- */
-int
-arpresolve_addr(struct ifnet *ifp, int flags, const struct sockaddr *dst,
-char *desten, uint32_t *pflags, struct llentry **plle)
-{
-   int error;
-
-   flags |= LLE_ADDRONLY;
-   error = arpresolve_full(ifp, 0, flags, NULL, dst, desten, pflags, plle);
-   return (error);
-}
-
-
-/*
  * Lookups link header based on an IP address.
  * On input:
  *ifp is the interface we use

Modified: head/sys/netinet/if_ether.h
==
--- head/sys/netinet/if_ether.h Sat Nov 17 12:59:59 2018(r340492)
+++ head/sys/netinet/if_ether.h Sat Nov 17 16:08:36 2018(r340493)
@@ -117,9 +117,6 @@ extern u_char   ether_ipmulticast_max[ETHER_ADDR_LEN];
 struct ifaddr;
 struct llentry;
 
-intarpresolve_addr(struct ifnet *ifp, int flags,
-   const struct sockaddr *dst, char *desten, uint32_t *pflags,
-   struct llentry **plle);
 intarpresolve(struct ifnet *ifp, int is_gw, struct mbuf *m,
const struct sockaddr *dst, u_char *desten, uint32_t *pflags,
struct llentry **plle);
___
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: r340492 - head/contrib/netbsd-tests/lib/libc/locale

2018-11-17 Thread Yuri Pankov
Author: yuripv
Date: Sat Nov 17 12:59:59 2018
New Revision: 340492
URL: https://svnweb.freebsd.org/changeset/base/340492

Log:
  Make mbstowcs_basic test pass, now that we have more ctype definitions.
  
  Reported by:  jenkins
  Approved by:  kib (mentor, implicit)

Modified:
  head/contrib/netbsd-tests/lib/libc/locale/t_mbstowcs.c

Modified: head/contrib/netbsd-tests/lib/libc/locale/t_mbstowcs.c
==
--- head/contrib/netbsd-tests/lib/libc/locale/t_mbstowcs.c  Sat Nov 17 
10:36:00 2018(r340491)
+++ head/contrib/netbsd-tests/lib/libc/locale/t_mbstowcs.c  Sat Nov 17 
12:59:59 2018(r340492)
@@ -88,7 +88,7 @@ static struct test {
0x, 0x5D, 0x5B, 0x1, 0x10, 0x5D, 0x0A
},
 #ifdef __FreeBSD__
-   {1, -1, -1,  1,  1, -1, -1,  1,  1, 1, -1,  1,  1, -1, -1,
+   {1, -1, -1,  1,  1, -1,  1,  1,  1,  1, -1,  1,  1,  1, -1,
 #else
{1, -1, -1,  1,  1, -1, -1,  1,  1, -1, -1,  1,  1, -1, -1,
 #endif
___
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: r340491 - in head: share/ctypedef tools/tools/locale tools/tools/locale/etc tools/tools/locale/tools

2018-11-17 Thread Yuri Pankov
Author: yuripv
Date: Sat Nov 17 10:36:00 2018
New Revision: 340491
URL: https://svnweb.freebsd.org/changeset/base/340491

Log:
  Use UnicodeData.txt to create UTF-8 ctype map.
  
  This should provide more complete coverage of currently defined Unicode
  characters as compared to manually assembled one we use currently.
  
  Comparison of original and new UTF-8 ctype maps by character class:
  
  TYPEORIGNEW
  alnum   94229   126029
  alpha   93557   125419
  blank   4   2
  cntrl   73  137685
  digit   469 622
  graph   109615  137203
  lower   14782145
  print   109641  137222
  punct   3428797
  rune110481  274907
  space   33  24
  upper   983 1781
  xdigit  469 622
  
  Large number of added cntrl definitions is due to the fact that private-use
  planes are currently defined as such, this can change in the future.
  
  Discussed with:   bapt
  Approved by:  kib (mentor, implicit)
  MFC after:1 month
  Differential revision:https://reviews.freebsd.org/D17842

Deleted:
  head/tools/tools/locale/etc/common.UTF-8.src
  head/tools/tools/locale/etc/manual-input.UTF-8
Modified:
  head/share/ctypedef/C.UTF-8.src
  head/tools/tools/locale/Makefile
  head/tools/tools/locale/tools/utf8-rollup.pl

Modified: head/share/ctypedef/C.UTF-8.src
==
--- head/share/ctypedef/C.UTF-8.src Sat Nov 17 00:03:04 2018
(r340490)
+++ head/share/ctypedef/C.UTF-8.src Sat Nov 17 10:36:00 2018
(r340491)
@@ -7,386 +7,27606 @@ comment_char *
 escape_char /
 
 LC_CTYPE
-
-**
-* 0x - 0x007F Basic Latin
-* 0x0080 - 0x00FF Latin-1 Supplement
-* 0x0100 - 0x017F Latin Extended-A
-* 0x0180 - 0x024F Latin Extended-B
-* 0x0250 - 0x02AF IPA Extensions
-* 0x1D00 - 0x1D7F Phonetic Extensions
-* 0x1D80 - 0x1DBF Phonetic Extensions Supplement
-* 0x1E00 - 0x1EFF Latin Extended Additional
-* 0x2150 - 0x218F Number Forms (partial - Roman Numerals)
-* 0x2C60 - 0x2C7F Latin Extended-C
-* 0xA720 - 0xA7FF Latin Extended-D
-* 0xAB30 - 0xAB6F Latin Extended-E
-* 0xFB00 - 0xFF4F Alphabetic Presentation Forms (partial)
-* 0xFF00 - 0xFFEF Halfwidth and Fullwidth Forms (partial)
-**
-upper  ;...;;/
-   
;...;;/
-   ;...;;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   
;...;;/
-   
;...;;/
-   ;/
-   ;/
-   ;...;;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;...;;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;...;;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   
;...;;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-   ;/
-