svn commit: r345741 - head/sys/compat/freebsd32

2019-03-30 Thread Jason A. Harmening
Author: jah
Date: Sat Mar 30 23:43:58 2019
New Revision: 345741
URL: https://svnweb.freebsd.org/changeset/base/345741

Log:
  freebsd32: fix padding of computed control message length for recvmsg()
  
  Each control message region must be aligned on a 4-byte boundary on 32-bit
  architectures. The 32-bit compat shim for recvmsg() gets the actual layout
  right, but doesn't pad the payload length when computing msg_controllen for
  the output message header. If a control message contains an unaligned
  payload, such as the 1-byte TTL field in the example attached to PR 236737,
  this can produce control message payload boundaries that extend beyond
  the boundary reported by msg_controllen.
  
  PR:   236737
  Reported by:  Yuval Pavel Zholkover 
  Reviewed by:  markj
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D19768

Modified:
  head/sys/compat/freebsd32/freebsd32_misc.c

Modified: head/sys/compat/freebsd32/freebsd32_misc.c
==
--- head/sys/compat/freebsd32/freebsd32_misc.c  Sat Mar 30 21:04:08 2019
(r345740)
+++ head/sys/compat/freebsd32/freebsd32_misc.c  Sat Mar 30 23:43:58 2019
(r345741)
@@ -1160,8 +1160,8 @@ freebsd32_copy_msg_out(struct msghdr *msg, struct mbuf
cm = NULL;
}
 
-   msg->msg_controllen += FREEBSD32_ALIGN(sizeof(*cm)) +
-   datalen_out;
+   msg->msg_controllen +=
+   FREEBSD32_CMSG_SPACE(datalen_out);
}
}
if (len == 0 && m != NULL) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345739 - in head/sys: net netinet6

2019-03-30 Thread Mark Johnston
Author: markj
Date: Sat Mar 30 18:00:44 2019
New Revision: 345739
URL: https://svnweb.freebsd.org/changeset/base/345739

Log:
  Do not perform DAD on stf(4) interfaces.
  
  stf(4) interfaces are not multicast-capable so they can't perform DAD.
  They also did not set IFF_DRV_RUNNING when an address was assigned, so
  the logic in nd6_timer() would periodically flag such an address as
  tentative, resulting in interface flapping.
  
  Fix the problem by setting IFF_DRV_RUNNING when an address is assigned,
  and do some related cleanup:
  - In in6if_do_dad(), remove a redundant check for !UP || !RUNNING.
There is only one caller in the tree, and it only looks at whether
the return value is non-zero.
  - Have in6if_do_dad() return false if the interface is not
multicast-capable.
  - Set ND6_IFF_NO_DAD when an address is assigned to an stf(4) interface
and the interface goes UP as a result. Note that this is not
sufficient to fix the problem because the new address is marked as
tentative and DAD is started before in6_ifattach() is called.
However, setting no_dad is formally correct.
  - Change nd6_timer() to not flag addresses as tentative if no_dad is
set.
  
  This is based on a patch from Viktor Dukhovni.
  
  Reported by:  Viktor Dukhovni 
  Reviewed by:  ae
  MFC after:3 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D19751

Modified:
  head/sys/net/if_stf.c
  head/sys/netinet6/in6.c
  head/sys/netinet6/in6_ifattach.c
  head/sys/netinet6/nd6.c

Modified: head/sys/net/if_stf.c
==
--- head/sys/net/if_stf.c   Sat Mar 30 17:42:27 2019(r345738)
+++ head/sys/net/if_stf.c   Sat Mar 30 18:00:44 2019(r345739)
@@ -724,6 +724,7 @@ stf_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
}
 
ifp->if_flags |= IFF_UP;
+   ifp->if_drv_flags |= IFF_DRV_RUNNING;
break;
 
case SIOCADDMULTI:

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Sat Mar 30 17:42:27 2019(r345738)
+++ head/sys/netinet6/in6.c Sat Mar 30 18:00:44 2019(r345739)
@@ -1951,26 +1951,14 @@ in6_if_up(struct ifnet *ifp)
 int
 in6if_do_dad(struct ifnet *ifp)
 {
+
if ((ifp->if_flags & IFF_LOOPBACK) != 0)
return (0);
-
-   if ((ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) ||
-   (ND_IFINFO(ifp)->flags & ND6_IFF_NO_DAD))
+   if ((ifp->if_flags & IFF_MULTICAST) == 0)
return (0);
-
-   /*
-* Our DAD routine requires the interface up and running.
-* However, some interfaces can be up before the RUNNING
-* status.  Additionally, users may try to assign addresses
-* before the interface becomes up (or running).
-* This function returns EAGAIN in that case.
-* The caller should mark "tentative" on the address instead of
-* performing DAD immediately.
-*/
-   if (!((ifp->if_flags & IFF_UP) &&
-   (ifp->if_drv_flags & IFF_DRV_RUNNING)))
-   return (EAGAIN);
-
+   if ((ND_IFINFO(ifp)->flags &
+   (ND6_IFF_IFDISABLED | ND6_IFF_NO_DAD)) != 0)
+   return (0);
return (1);
 }
 

Modified: head/sys/netinet6/in6_ifattach.c
==
--- head/sys/netinet6/in6_ifattach.cSat Mar 30 17:42:27 2019
(r345738)
+++ head/sys/netinet6/in6_ifattach.cSat Mar 30 18:00:44 2019
(r345739)
@@ -692,6 +692,7 @@ in6_ifattach(struct ifnet *ifp, struct ifnet *altifp)
 * it is rather harmful to have one.
 */
ND_IFINFO(ifp)->flags &= ~ND6_IFF_AUTO_LINKLOCAL;
+   ND_IFINFO(ifp)->flags |= ND6_IFF_NO_DAD;
break;
default:
break;

Modified: head/sys/netinet6/nd6.c
==
--- head/sys/netinet6/nd6.c Sat Mar 30 17:42:27 2019(r345738)
+++ head/sys/netinet6/nd6.c Sat Mar 30 18:00:44 2019(r345739)
@@ -900,6 +900,7 @@ nd6_timer(void *arg)
struct nd_prhead prl;
struct nd_defrouter *dr, *ndr;
struct nd_prefix *pr, *npr;
+   struct ifnet *ifp;
struct in6_ifaddr *ia6, *nia6;
uint64_t genid;
 
@@ -996,14 +997,15 @@ nd6_timer(void *arg)
 * Check status of the interface.  If it is down,
 * mark the address as tentative for future DAD.
 */
-   if ((ia6->ia_ifp->if_flags & IFF_UP) == 0 ||
-   (ia6->ia_ifp->if_drv_flags & IFF_DRV_RUNNING)
-   == 0 ||
-   (ND_IFINFO(ia6->ia_ifp)->flags 

svn commit: r345735 - head/share/mk

2019-03-30 Thread Enji Cooper
Author: ngie
Date: Sat Mar 30 17:23:15 2019
New Revision: 345735
URL: https://svnweb.freebsd.org/changeset/base/345735

Log:
  Allow programs to set `NO_SHARED` on a per-PROG basis
  
  This is particularly useful when installing programs for tests that need to be
  linked statically, e.g., mini-me from capsicum-test, which is linked 
statically
  to avoid the dynamic library lookup in the upstream project.
  
  Reviewed by:  emaste
  Approved by:  emaste (mentor)
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D19756

Modified:
  head/share/mk/bsd.progs.mk

Modified: head/share/mk/bsd.progs.mk
==
--- head/share/mk/bsd.progs.mk  Sat Mar 30 16:58:51 2019(r345734)
+++ head/share/mk/bsd.progs.mk  Sat Mar 30 17:23:15 2019(r345735)
@@ -23,7 +23,7 @@ PROGS += ${PROGS_CXX}
 .if defined(PROG)
 # just one of many
 PROG_OVERRIDE_VARS +=  BINDIR BINGRP BINOWN BINMODE CSTD CXXSTD DPSRCS MAN \
-   NO_WERROR PROGNAME SRCS STRIP WARNS
+   NO_SHARED NO_WERROR PROGNAME SRCS STRIP WARNS
 PROG_VARS +=   CFLAGS CXXFLAGS DEBUG_FLAGS DPADD INTERNALPROG LDADD LIBADD \
LINKS LDFLAGS MLINKS ${PROG_OVERRIDE_VARS}
 .for v in ${PROG_VARS:O:u}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345734 - head/sys/kern

2019-03-30 Thread Konstantin Belousov
Author: kib
Date: Sat Mar 30 16:58:51 2019
New Revision: 345734
URL: https://svnweb.freebsd.org/changeset/base/345734

Log:
  Fix branding after r345661.
  
  In particular, elf32 FreeBSD binaries were not executed on LP64 hosts.
  The interp_name_len value should account for the nul terminator.  This
  is needed for strncmp()s in brand checking code to work.
  
  Reported by:  andreast
  Sponsored by: The FreeBSD Foundation
  MFC after:12 days (together with r345661)

Modified:
  head/sys/kern/imgact_elf.c

Modified: head/sys/kern/imgact_elf.c
==
--- head/sys/kern/imgact_elf.c  Sat Mar 30 13:59:02 2019(r345733)
+++ head/sys/kern/imgact_elf.c  Sat Mar 30 16:58:51 2019(r345734)
@@ -279,7 +279,7 @@ __elfN(get_brandinfo)(struct image_params *imgp, const
boolean_t ret;
int i, interp_name_len;
 
-   interp_name_len = interp != NULL ? strlen(interp) : 0;
+   interp_name_len = interp != NULL ? strlen(interp) + 1 : 0;
 
/*
 * We support four types of branding -- (1) the ELF EI_OSABI field
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r345696 - head/lib/libvgl

2019-03-30 Thread Konstantin Belousov
On Sat, Mar 30, 2019 at 03:24:40PM +1100, Bruce Evans wrote:
> On Fri, 29 Mar 2019, Konstantin Belousov wrote:
> 
> > On Fri, Mar 29, 2019 at 03:57:09PM +, Bruce Evans wrote:
> >> Author: bde
> >> Date: Fri Mar 29 15:57:08 2019
> >> New Revision: 345696
> >> URL: https://svnweb.freebsd.org/changeset/base/345696
> >>
> >> Log:
> >>   Fix endless loops for handling SIGBUS and SIGSEGV.
> >>
> >>   r80270 has the usual wrong fix for unsafe signal handling -- just set
> >>   a flag and return to let an event loop check the flag and do safe
> >>   handling.  This never works for signals like SIGBUS and SIGSEGV that
> >>   repeat and works poorly for others unless the application has an event
> >>   loop designed to support this.
> >>
> >>   For these signals, clean up unsafely as before, except for arranging that
> >>   nested signals are fatal and forcing a nested signal if the cleanup 
> >> doesn't
> >>   cause one.
> >>
> >> Modified:
> >>   head/lib/libvgl/main.c
> >>
> >> Modified: head/lib/libvgl/main.c
> >> ==
> >> --- head/lib/libvgl/main.c Fri Mar 29 15:20:48 2019(r345695)
> >> +++ head/lib/libvgl/main.c Fri Mar 29 15:57:08 2019(r345696)
> >> ...
> >> @@ -107,14 +107,22 @@ struct vt_mode smode;
> >>  }
> >>
> >>  static void
> >> -VGLAbort(int arg __unused)
> >> +VGLAbort(int arg)
> >>  {
> >> +  sigset_t mask;
> >> +
> >>VGLAbortPending = 1;
> >>signal(SIGINT, SIG_IGN);
> >>signal(SIGTERM, SIG_IGN);
> >> -  signal(SIGSEGV, SIG_IGN);
> >> -  signal(SIGBUS, SIG_IGN);
> >>signal(SIGUSR2, SIG_IGN);
> >> +  if (arg == SIGBUS || arg == SIGSEGV) {
> >> +signal(arg, SIG_DFL);
> >> +sigemptyset(&mask);
> >> +sigaddset(&mask, arg);
> >> +sigprocmask(SIG_UNBLOCK, &mask, NULL);
> >> +VGLEnd();
> >> +kill(getpid(), arg);
> > This of course misses the siginfo information from the real fault.
> 
> It is in the nested signal frame.
> 
> > Why SIGBUS/SIGSEGV are caught at all ?
> 
> Otherwise, the screen is left in an application mode that the kernel
> doesn't support (except to not write to the screen, so that the
> application has full control).
> 
> Of course, it is bad for libraries to catch signals.  The man page warns
> about installing signal handlers and trying to call VGLEnd() and exit(3)
> [from the signal handler] to end the program, although it is important
> to use VGLEnd() to end the program.  I haven't tried installing signal
> handlers in programs, but my main application is another graphics library
> that wraps libvgl, and it installs an atexit() handler which calls its
> cleanup function which calls VGLEnd().  libvgl should do the same.  The
> cleanup is safe in exit() provided calling exit() is safe.
> 
> The man page has general nonsense recommending setting a flag and not
> terminating the program in signal handlers.  This was added in the same
> commit that completely broke the SIGBUS and SIGSEGV handling using this
> method.  A much longer lesson is needed to describe how to use this
> method correctly.  SA_RESTART must be turned off for all signals, and
> this gives the complexity of handling EINTR returns from all syscalls
> affected by SA_RESTART ...
> 
> The man page has almost enough details about which signals the library
> catches.  It doesn't mention SIGUSR1 (used for screen switches) or
> SIGUSR2 (used for mouse signals).  I plan to add use of SIGIO to fix
> busy-waiting for keyboard events.  select() might work for the keyboard,
> but I doubt that it works for the mouse.
> 
> What should happen is if the application installs signal handlers and
> does unsafe things not including calling VGLEnd(), then nested SIGBUS's
> and SIGSEGV's should reach the above cleanup.  Applications should not
> catch SIGBUS or SIGSEGV unless they can clean up better than the above.
> It is possible to clean up better than the above, but not in applications.
> The above can check a soft signal mask flag like the one set by INTOFF()
> and not do so much when it is set.  When it is not set, I think restoring
> the screen mode is safe in signal handlers, and only things like free()
> and printf() are not safe in signal handlers.

I am more about not doing kill(2) from the handler, instead do plain
return to the context which caused the original signal.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345729 - head/sys/dev/usb/wlan

2019-03-30 Thread Andriy Voskoboinyk
Author: avos
Date: Sat Mar 30 09:24:06 2019
New Revision: 345729
URL: https://svnweb.freebsd.org/changeset/base/345729

Log:
  urtw(4): export TSF timestamp for received frames via radiotap
  
  Tested with Netgear WG111 v3 (RTL8187B), STA mode.
  
  MFC after:1 week

Modified:
  head/sys/dev/usb/wlan/if_urtw.c
  head/sys/dev/usb/wlan/if_urtwvar.h

Modified: head/sys/dev/usb/wlan/if_urtw.c
==
--- head/sys/dev/usb/wlan/if_urtw.c Sat Mar 30 07:29:20 2019
(r345728)
+++ head/sys/dev/usb/wlan/if_urtw.c Sat Mar 30 09:24:06 2019
(r345729)
@@ -3932,6 +3932,7 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *da
struct urtw_softc *sc = data->sc;
struct ieee80211com *ic = &sc->sc_ic;
uint8_t noise = 0, rate;
+   uint64_t mactime;
 
usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
 
@@ -3951,6 +3952,9 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *da
/* XXX correct? */
rssi = rx->rssi & URTW_RX_RSSI_MASK;
noise = rx->noise;
+
+   if (ieee80211_radiotap_active(ic))
+   mactime = rx->mactime;
} else {
struct urtw_8187l_rxhdr *rx;
 
@@ -3967,6 +3971,9 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *da
/* XXX correct? */
rssi = rx->rssi & URTW_RX_8187L_RSSI_MASK;
noise = rx->noise;
+
+   if (ieee80211_radiotap_active(ic))
+   mactime = rx->mactime;
}
 
if (flen < IEEE80211_ACK_LEN)
@@ -3986,6 +3993,7 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *da
if (ieee80211_radiotap_active(ic)) {
struct urtw_rx_radiotap_header *tap = &sc->sc_rxtap;
 
+   tap->wr_tsf = mactime;
tap->wr_flags = 0;
tap->wr_dbm_antsignal = (int8_t)rssi;
}

Modified: head/sys/dev/usb/wlan/if_urtwvar.h
==
--- head/sys/dev/usb/wlan/if_urtwvar.h  Sat Mar 30 07:29:20 2019
(r345728)
+++ head/sys/dev/usb/wlan/if_urtwvar.h  Sat Mar 30 09:24:06 2019
(r345729)
@@ -55,6 +55,7 @@ typedef STAILQ_HEAD(, urtw_data) urtw_datahead;
 
 struct urtw_rx_radiotap_header {
struct ieee80211_radiotap_header wr_ihdr;
+   uint64_twr_tsf;
uint8_t wr_flags;
uint8_t wr_pad;
uint16_twr_chan_freq;
@@ -63,7 +64,8 @@ struct urtw_rx_radiotap_header {
 } __packed __aligned(8);
 
 #define URTW_RX_RADIOTAP_PRESENT   \
-   ((1 << IEEE80211_RADIOTAP_FLAGS) |  \
+   ((1 << IEEE80211_RADIOTAP_TSFT) |   \
+(1 << IEEE80211_RADIOTAP_FLAGS) |  \
 (1 << IEEE80211_RADIOTAP_CHANNEL) |\
 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL))
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345728 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2019-03-30 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Mar 30 07:29:20 2019
New Revision: 345728
URL: https://svnweb.freebsd.org/changeset/base/345728

Log:
  If the autoexpand pool property is turned on and vdev is healthy try to
  expand the pool automatically when we detect underlying GEOM provider
  size change.
  
  Obtained from:Fudo Security
  Tested in:AWS

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Sat Mar 
30 07:24:34 2019(r345727)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Sat Mar 
30 07:29:20 2019(r345728)
@@ -158,6 +158,29 @@ vdev_geom_attrchanged(struct g_consumer *cp, const cha
 }
 
 static void
+vdev_geom_resize(struct g_consumer *cp)
+{
+   struct consumer_priv_t *priv;
+   struct consumer_vdev_elem *elem;
+   spa_t *spa;
+   vdev_t *vd;
+
+   priv = (struct consumer_priv_t *)&cp->private;
+   if (SLIST_EMPTY(priv))
+   return;
+
+   SLIST_FOREACH(elem, priv, elems) {
+   vd = elem->vd;
+   if (vd->vdev_state != VDEV_STATE_HEALTHY)
+   continue;
+   spa = vd->vdev_spa;
+   if (!spa->spa_autoexpand)
+   continue;
+   vdev_online(spa, vd->vdev_guid, ZFS_ONLINE_EXPAND, NULL);
+   }
+}
+
+static void
 vdev_geom_orphan(struct g_consumer *cp)
 {
struct consumer_priv_t *priv;
@@ -229,6 +252,7 @@ vdev_geom_attach(struct g_provider *pp, vdev_t *vd, bo
gp = g_new_geomf(&zfs_vdev_class, "zfs::vdev");
gp->orphan = vdev_geom_orphan;
gp->attrchanged = vdev_geom_attrchanged;
+   gp->resize = vdev_geom_resize;
cp = g_new_consumer(gp);
error = g_attach(cp, pp);
if (error != 0) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345727 - in head: sbin/devd sys/geom

2019-03-30 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Mar 30 07:24:34 2019
New Revision: 345727
URL: https://svnweb.freebsd.org/changeset/base/345727

Log:
  Introduce new event SIZECHANGE within GEOM system to inform about GEOM
  providers mediasize changes.
  
  While here, use GEOM nomenclature to describe providers instead of calling
  them device nodes.
  
  Obtained from:Fudo Security
  Tested in:AWS

Modified:
  head/sbin/devd/devd.conf.5
  head/sys/geom/geom_dev.c

Modified: head/sbin/devd/devd.conf.5
==
--- head/sbin/devd/devd.conf.5  Sat Mar 30 07:20:28 2019(r345726)
+++ head/sbin/devd/devd.conf.5  Sat Mar 30 07:24:34 2019(r345727)
@@ -41,7 +41,7 @@
 .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 .\" SOFTWARE.
 .\"
-.Dd July 20, 2018
+.Dd March 29, 2019
 .Dt DEVD.CONF 5
 .Os
 .Sh NAME
@@ -432,15 +432,19 @@ only includes disk-like devices.
 .It Li CREATE
 A
 .Xr geom 4
-device node is created.
+provider is created.
 .It Li DESTROY
 A
 .Xr geom 4
-device node is destroyed.
+provider is destroyed.
 .It Li GEOM::physpath
 The physical path of a device has changed.
 .It Li MEDIACHANGE
 Physical media has changed.
+.It Li SIZECHANGE
+A
+.Xr geom 4
+provider size has changed.
 .El
 .El
 .Pp

Modified: head/sys/geom/geom_dev.c
==
--- head/sys/geom/geom_dev.cSat Mar 30 07:20:28 2019(r345726)
+++ head/sys/geom/geom_dev.cSat Mar 30 07:24:34 2019(r345727)
@@ -92,6 +92,7 @@ static g_fini_t g_dev_fini;
 static g_taste_t g_dev_taste;
 static g_orphan_t g_dev_orphan;
 static g_attrchanged_t g_dev_attrchanged;
+static g_resize_t g_dev_resize;
 
 static struct g_class g_dev_class  = {
.name = "DEV",
@@ -100,7 +101,8 @@ static struct g_class g_dev_class   = {
.fini = g_dev_fini,
.taste = g_dev_taste,
.orphan = g_dev_orphan,
-   .attrchanged = g_dev_attrchanged
+   .attrchanged = g_dev_attrchanged,
+   .resize = g_dev_resize
 };
 
 /*
@@ -300,6 +302,15 @@ g_dev_attrchanged(struct g_consumer *cp, const char *a
g_dev_set_physpath(cp);
return;
}
+}
+
+static void
+g_dev_resize(struct g_consumer *cp)
+{
+   char buf[SPECNAMELEN + 6];
+
+   snprintf(buf, sizeof(buf), "cdev=%s", cp->provider->name);
+   devctl_notify_f("GEOM", "DEV", "SIZECHANGE", buf, M_WAITOK);
 }
 
 struct g_provider *
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345726 - head/sys/dev/xen/blkfront

2019-03-30 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Mar 30 07:20:28 2019
New Revision: 345726
URL: https://svnweb.freebsd.org/changeset/base/345726

Log:
  Implement support for online disk capacity changes.
  
  Obtained from:Fudo Security
  Tested in:AWS

Modified:
  head/sys/dev/xen/blkfront/blkfront.c

Modified: head/sys/dev/xen/blkfront/blkfront.c
==
--- head/sys/dev/xen/blkfront/blkfront.cSat Mar 30 01:56:53 2019
(r345725)
+++ head/sys/dev/xen/blkfront/blkfront.cSat Mar 30 07:20:28 2019
(r345726)
@@ -1227,11 +1227,40 @@ xbd_connect(struct xbd_softc *sc)
int err, feature_barrier, feature_flush;
int i, j;
 
-   if (sc->xbd_state == XBD_STATE_CONNECTED || 
-   sc->xbd_state == XBD_STATE_SUSPENDED)
+   DPRINTK("blkfront.c:connect:%s.\n", xenbus_get_otherend_path(dev));
+
+   if (sc->xbd_state == XBD_STATE_SUSPENDED) {
return;
+   }
 
-   DPRINTK("blkfront.c:connect:%s.\n", xenbus_get_otherend_path(dev));
+   if (sc->xbd_state == XBD_STATE_CONNECTED) {
+   struct disk *disk;
+
+   disk = sc->xbd_disk;
+   if (disk == NULL) {
+   return;
+   }
+   err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev),
+   "sectors", "%lu", §ors, NULL);
+   if (err != 0) {
+   xenbus_dev_error(dev, err,
+   "reading sectors at %s",
+   xenbus_get_otherend_path(dev));
+   return;
+   }
+   disk->d_mediasize = disk->d_sectorsize * sectors;
+   err = disk_resize(disk, M_NOWAIT);
+   if (err) {
+   xenbus_dev_error(dev, err,
+   "unable to resize disk %s%u",
+   disk->d_name, disk->d_unit);
+   return;
+   }
+   device_printf(sc->xbd_dev,
+   "changed capacity to %jd\n",
+   (intmax_t)disk->d_mediasize);
+   return;
+   }
 
err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev),
"sectors", "%lu", §ors,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"