Re: nsd 4.1.19

2018-01-26 Thread Florian Obser
On Fri, Jan 26, 2018 at 05:38:46PM +, Stuart Henderson wrote:
> On 2018/01/26 18:12, Florian Obser wrote:
> > anyone else?
> > Got around to read the diff, not too much insanity in there, going to
> > commit soon.
> 
> ok with me.
> 
> > diff --git nsd.c nsd.c
> > index f2cf6ccf0cb..dfbc58696b3 100644
> > --- nsd.c
> > +++ nsd.c
> > @@ -579,6 +579,7 @@ main(int argc, char *argv[])
> > case 'v':
> > version();
> > /* version exits */
> > +   break;
> >  #ifndef NDEBUG
> > case 'F':
> > sscanf(optarg, "%x", _debug_facilities);
> > @@ -980,6 +981,7 @@ main(int argc, char *argv[])
> > break;
> > case -1:
> > error("fork() failed: %s", strerror(errno));
> > +   break;
> > default:
> > /* Parent is done */
> > server_close_all_sockets(nsd.udp, nsd.ifs);
> 
> that gcc lint thing doesn't seem particularly clever if those are needed!
> 

Indeed, there is also some comment spam that's not relevant for us, I
left that in to not create conflicts for future updates.

I like this one :D

/** Fallthrough: AXFR over UDP queries are discarded. */
+   /* fallthrough */


I dropped this though:

+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"

Don't want to find out in two weeks time what gcc on the luna88k
thinks about that...

-- 
I'm not entirely sure you are real.



Re: nsd 4.1.19

2018-01-26 Thread Stuart Henderson
On 2018/01/26 18:12, Florian Obser wrote:
> anyone else?
> Got around to read the diff, not too much insanity in there, going to
> commit soon.

ok with me.

> diff --git nsd.c nsd.c
> index f2cf6ccf0cb..dfbc58696b3 100644
> --- nsd.c
> +++ nsd.c
> @@ -579,6 +579,7 @@ main(int argc, char *argv[])
>   case 'v':
>   version();
>   /* version exits */
> + break;
>  #ifndef NDEBUG
>   case 'F':
>   sscanf(optarg, "%x", _debug_facilities);
> @@ -980,6 +981,7 @@ main(int argc, char *argv[])
>   break;
>   case -1:
>   error("fork() failed: %s", strerror(errno));
> + break;
>   default:
>   /* Parent is done */
>   server_close_all_sockets(nsd.udp, nsd.ifs);

that gcc lint thing doesn't seem particularly clever if those are needed!



Re: nsd 4.1.19

2018-01-26 Thread Florian Obser
anyone else?
Got around to read the diff, not too much insanity in there, going to
commit soon.

rebased on top of millert@'s autohell fix:

diff --git Makefile.in Makefile.in
index 495160c0826..3468101c19d 100644
--- Makefile.in
+++ Makefile.in
@@ -286,9 +286,6 @@ qtest.o:$(srcdir)/tpkg/cutest/qtest.c
 udb-inspect.o: $(srcdir)/tpkg/cutest/udb-inspect.c
$(COMPILE) -c $(srcdir)/tpkg/cutest/udb-inspect.c
 
-xfr-inspect.o: $(srcdir)/tpkg/cutest/xfr-inspect.c
-   $(COMPILE) -c $(srcdir)/tpkg/cutest/xfr-inspect.c
-
 zlexer.c:  $(srcdir)/zlexer.lex
if test "$(LEX)" != ":"; then rm -f $@ ;\
echo '#include "config.h"' > $@ ;\
@@ -516,7 +513,7 @@ udb-inspect.o: $(srcdir)/tpkg/cutest/udb-inspect.c config.h 
$(srcdir)/udb.h $(sr
  $(srcdir)/udb.h $(srcdir)/udbzone.h $(srcdir)/dns.h $(srcdir)/udbradtree.h 
$(srcdir)/util.h $(srcdir)/buffer.h $(srcdir)/region-allocator.h \
  $(srcdir)/util.h $(srcdir)/packet.h $(srcdir)/namedb.h $(srcdir)/dname.h 
$(srcdir)/buffer.h $(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/rdata.h \
  $(srcdir)/namedb.h $(srcdir)/difffile.h $(srcdir)/options.h config.h
-xfr-inspect.o: $(srcdir)/tpkg/cutest/xfr-inspect.c config.h 
$(srcdir)/udbzone.h $(srcdir)/udb.h $(srcdir)/dns.h \
+xfr-inspect.o: $(srcdir)/xfr-inspect.c config.h $(srcdir)/udbzone.h 
$(srcdir)/udb.h $(srcdir)/dns.h \
  $(srcdir)/udbradtree.h $(srcdir)/util.h $(srcdir)/buffer.h 
$(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/packet.h 
$(srcdir)/namedb.h \
  $(srcdir)/dname.h $(srcdir)/buffer.h $(srcdir)/radtree.h $(srcdir)/rbtree.h 
$(srcdir)/rdata.h $(srcdir)/namedb.h $(srcdir)/difffile.h \
  $(srcdir)/options.h config.h
diff --git axfr.c axfr.c
index 6f6b0957e99..dd34c0c3cee 100644
--- axfr.c
+++ axfr.c
@@ -201,6 +201,7 @@ answer_axfr_ixfr(struct nsd *nsd, struct query *q)
return query_axfr(nsd, q);
}
/** Fallthrough: AXFR over UDP queries are discarded. */
+   /* fallthrough */
case TYPE_IXFR:
RCODE_SET(q->packet, RCODE_IMPL);
return QUERY_PROCESSED;
diff --git config.h.in config.h.in
index 6c44616432f..3cc7d4e546d 100644
--- config.h.in
+++ config.h.in
@@ -73,6 +73,9 @@
 /* Define to 1 if you have the `endpwent' function. */
 #undef HAVE_ENDPWENT
 
+/* Define to 1 if you have the `ERR_load_crypto_strings' function. */
+#undef HAVE_ERR_LOAD_CRYPTO_STRINGS
+
 /* Define to 1 if you have the `event_base_free' function. */
 #undef HAVE_EVENT_BASE_FREE
 
@@ -88,6 +91,9 @@
 /* Define to 1 if you have the  header file. */
 #undef HAVE_EVENT_H
 
+/* Define to 1 if you have the `EVP_cleanup' function. */
+#undef HAVE_EVP_CLEANUP
+
 /* Define to 1 if you have the `ev_default_loop' function. */
 #undef HAVE_EV_DEFAULT_LOOP
 
@@ -194,6 +200,12 @@
 /* Define to 1 if you have the  header file. */
 #undef HAVE_OPENSSL_ERR_H
 
+/* Define to 1 if you have the `OPENSSL_init_crypto' function. */
+#undef HAVE_OPENSSL_INIT_CRYPTO
+
+/* Define to 1 if you have the `OPENSSL_init_ssl' function. */
+#undef HAVE_OPENSSL_INIT_SSL
+
 /* Define to 1 if you have the  header file. */
 #undef HAVE_OPENSSL_RAND_H
 
@@ -426,6 +438,9 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
+/* Define this to use packed structure alignment. */
+#undef PACKED_STRUCTS
+
 /* Pathname to the NSD pidfile */
 #undef PIDFILE
 
@@ -483,6 +498,9 @@
 /* Define this to enable mmap instead of malloc. Experimental. */
 #undef USE_MMAP_ALLOC
 
+/* Define this to configure to use the radix tree. */
+#undef USE_RADIX_TREE
+
 /* Enable extensions on AIX 3, Interix.  */
 #ifndef _ALL_SOURCE
 # undef _ALL_SOURCE
@@ -659,6 +677,29 @@
 
 
 
+
+/* provide timespec def if not available */
+#ifndef CONFIG_DEFINES
+#define CONFIG_DEFINES
+#ifndef HAVE_STRUCT_TIMESPEC
+#ifndef __timespec_defined
+#define __timespec_defined 1
+   struct timespec {
+   longtv_sec; /* seconds */
+   longtv_nsec;/* nanoseconds */
+   };
+#endif /* !__timespec_defined */
+#endif /* !HAVE_STRUCT_TIMESPEC */
+#endif /* !CONFIG_DEFINES */
+
+#ifdef PACKED_STRUCTS
+#define ATTR_PACKED __attribute__((packed))
+#else
+#define ATTR_PACKED
+#endif
+
+
+
 #ifdef HAVE_VA_LIST_DOUBLE_DEF
 /* workaround double va_list definition on some platforms */
 #  ifndef _VA_LIST_DEFINED
@@ -736,13 +777,12 @@
 
 
 
-#ifndef HAVE_B64_NTOP
-int b64_ntop(uint8_t const *src, size_t srclength,
+int __b64_ntop(uint8_t const *src, size_t srclength,
 char *target, size_t targsize);
-#endif /* !HAVE_B64_NTOP */
-#ifndef HAVE_B64_PTON
-int b64_pton(char const *src, uint8_t *target, size_t targsize);
-#endif /* !HAVE_B64_PTON */
+int __b64_pton(char const *src, uint8_t *target, size_t targsize);
+
+
+
 #ifndef HAVE_FSEEKO
 #define fseeko fseek
 #define ftello ftell
@@ -800,22 +840,3 @@ int memcmp(const void *x, const void *y, size_t n);
 #endif
 
 
-
-
-
-/* provide timespec def if not available 

Re: drm: DP update that fixes T460 external monitors through docks

2018-01-26 Thread Paul Irofti
Master branch. I tried trimming down the diff further but without any success. 

If you want I can make a list of commits. Note that I have not applied full 
commit trees so that I can minimize the size of the diff and the files, areas, 
it touches.



Re: drm: DP update that fixes T460 external monitors through docks

2018-01-26 Thread Jonathan Gray
On Fri, Jan 26, 2018 at 10:39:39AM +0200, Paul Irofti wrote:
> Hi,
> 
> I have a T460 Lenovo model that, when connected to an external monitor
> via a docking station, freezes the machine and produces the "snowflake"
> effect on the monitor. Last time I saw this was in 2010 when working on
> suspend-resume :)
> 
> After a month of fighting to fix the issue I came up with this drm
> update. The code bellow includes commits taken directly from the Linux
> kernel, no local modifications.

Which commits?  From which tree/branch?

Diverging from linux-4.4.y like this makes it harder to see local
changes and increases the chance of breaking things.

This does not look like the smallest possible diff.

> 
> Notable changes are:
>   - improved DP link training by renegotiating with different rates and
> lane values
>   - caching of source, sink and common rates
>   - max link rate limiting and related calculation changes
>   - switch to long and short pulse interrupts
> 
> I have been running succesfully with this on both the affected model and
> on the x250 that I used with a dozen monitors, projectors and the like
> at uni. No problems so far, but would appreciate test repaorts on a
> wider range of hardware.
> 
> Comments? Mistakes? How should we proceed to get this in the tree?
> 
> Paul
> 
> diff --git sys/dev/pci/drm/drm_crtc.c sys/dev/pci/drm/drm_crtc.c
> index 874388fdd23..97ada314533 100644
> --- sys/dev/pci/drm/drm_crtc.c
> +++ sys/dev/pci/drm/drm_crtc.c
> @@ -80,6 +80,11 @@ static const struct drm_prop_enum_list 
> drm_plane_type_enum_list[] = {
>   { DRM_PLANE_TYPE_CURSOR, "Cursor" },
>  };
>  
> +static const struct drm_prop_enum_list drm_link_status_enum_list[] = {
> + { DRM_MODE_LINK_STATUS_GOOD, "Good" },
> + { DRM_MODE_LINK_STATUS_BAD, "Bad" },
> +};
> +
>  /*
>   * Optional properties
>   */
> @@ -1394,6 +1399,13 @@ static int drm_mode_create_standard_properties(struct 
> drm_device *dev)
>   return -ENOMEM;
>   dev->mode_config.tile_property = prop;
>  
> + prop = drm_property_create_enum(dev, 0, "link-status",
> + drm_link_status_enum_list,
> + ARRAY_SIZE(drm_link_status_enum_list));
> + if (!prop)
> + return -ENOMEM;
> + dev->mode_config.link_status_property = prop;
> +
>   prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
>   "type", drm_plane_type_enum_list,
>   ARRAY_SIZE(drm_plane_type_enum_list));
> @@ -4845,6 +4857,35 @@ int drm_mode_connector_property_set_ioctl(struct 
> drm_device *dev,
>   return drm_mode_obj_set_property_ioctl(dev, _set_prop, file_priv);
>  }
>  
> +/**
> + * drm_mode_connector_set_link_status_property - Set link status property of 
> a connector
> + * @connector: drm connector
> + * @link_status: new value of link status property (0: Good, 1: Bad)
> + *
> + * In usual working scenario, this link status property will always be set to
> + * "GOOD". If something fails during or after a mode set, the kernel driver
> + * may set this link status property to "BAD". The caller then needs to send 
> a
> + * hotplug uevent for userspace to re-check the valid modes through
> + * GET_CONNECTOR_IOCTL and retry modeset.
> + *
> + * Note: Drivers cannot rely on userspace to support this property and
> + * issue a modeset. As such, they may choose to handle issues (like
> + * re-training a link) without userspace's intervention.
> + *
> + * The reason for adding this property is to handle link training failures, 
> but
> + * it is not limited to DP or link training. For example, if we implement
> + * asynchronous setcrtc, this property can be used to report any failures in 
> that.
> + */
> +void drm_mode_connector_set_link_status_property(struct drm_connector 
> *connector,
> +  uint64_t link_status)
> +{
> + struct drm_device *dev = connector->dev;
> +
> + drm_modeset_lock(>mode_config.connection_mutex, NULL);
> + connector->state->link_status = link_status;
> + drm_modeset_unlock(>mode_config.connection_mutex);
> +}
> +
>  static int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
>  struct drm_property *property,
>  uint64_t value)
> diff --git sys/dev/pci/drm/drm_crtc.h sys/dev/pci/drm/drm_crtc.h
> index bc5474cb422..480100d6c9e 100644
> --- sys/dev/pci/drm/drm_crtc.h
> +++ sys/dev/pci/drm/drm_crtc.h
> @@ -126,6 +126,12 @@ enum subpixel_order {
>   SubPixelNone,
>  };
>  
> +enum drm_link_status {
> + DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD,
> + DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD,
> +};
> +
> +
>  #define DRM_COLOR_FORMAT_RGB444  (1<<0)
>  #define DRM_COLOR_FORMAT_YCRCB444(1<<1)
>  #define DRM_COLOR_FORMAT_YCRCB422(1<<2)
> @@ -497,6 

Re: ksh: bug with quoted parameter expansion

2018-01-26 Thread Theo Buehler
On Fri, Jan 26, 2018 at 11:31:40AM +0100, Klemens Nanni wrote:
> On Fri, Jan 26, 2018 at 09:41:45AM +0100, Klemens Nanni wrote:
> > On Wed, Jan 24, 2018 at 04:15:24PM +0100, m...@josuah.net wrote:
> > > I found a bug in ksh's parameter expansion on an edge case:
> > > 
> > >   true $(true "${USER#'"'}")
> > > 
> > >   /home/sh[4]: no closing quote
> > > 
> > > The problem seems to occurs when all of these conditions are present:
> > > 
> > > 1. On ${var#pattern} or ${var%pattern} parameter expansion
> > > 2. When the pattern contains a singly quoted double quote: '"'
> > > 3. While expansion occurs withing $(...), (but not `...`)
> > > 4. While the expansion is quoted: "${var#pattern}".
> > As anton@ pointed out, this is known behaviour. The following will work:
> > 
> > true $(true "${USER#\"}")
> > true $(true "${USER#"\""}")
> > 
> Forgot to mention: `` are not subject to this, the bug lives in $() alone.

>From the end of ksh(1)

BUGS
 $(command) expressions are currently parsed by finding the closest
 matching (unquoted) parenthesis.  Thus constructs inside $(command) may
 produce an error.  For example, the parenthesis in ‘x);;’ is interpreted
 as the closing parenthesis in ‘$(case x in x);; *);; esac)’.



Re: ksh: bug with quoted parameter expansion

2018-01-26 Thread Klemens Nanni
On Fri, Jan 26, 2018 at 09:41:45AM +0100, Klemens Nanni wrote:
> On Wed, Jan 24, 2018 at 04:15:24PM +0100, m...@josuah.net wrote:
> > I found a bug in ksh's parameter expansion on an edge case:
> > 
> > true $(true "${USER#'"'}")
> > 
> > /home/sh[4]: no closing quote
> > 
> > The problem seems to occurs when all of these conditions are present:
> > 
> > 1. On ${var#pattern} or ${var%pattern} parameter expansion
> > 2. When the pattern contains a singly quoted double quote: '"'
> > 3. While expansion occurs withing $(...), (but not `...`)
> > 4. While the expansion is quoted: "${var#pattern}".
> As anton@ pointed out, this is known behaviour. The following will work:
> 
>   true $(true "${USER#\"}")
>   true $(true "${USER#"\""}")
> 
Forgot to mention: `` are not subject to this, the bug lives in $() alone.



Re: ksh: bug with quoted parameter expansion

2018-01-26 Thread Klemens Nanni
On Wed, Jan 24, 2018 at 04:15:24PM +0100, m...@josuah.net wrote:
> I found a bug in ksh's parameter expansion on an edge case:
> 
>   true $(true "${USER#'"'}")
> 
>   /home/sh[4]: no closing quote
> 
> The problem seems to occurs when all of these conditions are present:
> 
> 1. On ${var#pattern} or ${var%pattern} parameter expansion
> 2. When the pattern contains a singly quoted double quote: '"'
> 3. While expansion occurs withing $(...), (but not `...`)
> 4. While the expansion is quoted: "${var#pattern}".
As anton@ pointed out, this is known behaviour. The following will work:

true $(true "${USER#\"}")
true $(true "${USER#"\""}")



drm: DP update that fixes T460 external monitors through docks

2018-01-26 Thread Paul Irofti
Hi,

I have a T460 Lenovo model that, when connected to an external monitor
via a docking station, freezes the machine and produces the "snowflake"
effect on the monitor. Last time I saw this was in 2010 when working on
suspend-resume :)

After a month of fighting to fix the issue I came up with this drm
update. The code bellow includes commits taken directly from the Linux
kernel, no local modifications.

Notable changes are:
- improved DP link training by renegotiating with different rates and
  lane values
- caching of source, sink and common rates
- max link rate limiting and related calculation changes
- switch to long and short pulse interrupts

I have been running succesfully with this on both the affected model and
on the x250 that I used with a dozen monitors, projectors and the like
at uni. No problems so far, but would appreciate test repaorts on a
wider range of hardware.

Comments? Mistakes? How should we proceed to get this in the tree?

Paul

diff --git sys/dev/pci/drm/drm_crtc.c sys/dev/pci/drm/drm_crtc.c
index 874388fdd23..97ada314533 100644
--- sys/dev/pci/drm/drm_crtc.c
+++ sys/dev/pci/drm/drm_crtc.c
@@ -80,6 +80,11 @@ static const struct drm_prop_enum_list 
drm_plane_type_enum_list[] = {
{ DRM_PLANE_TYPE_CURSOR, "Cursor" },
 };
 
+static const struct drm_prop_enum_list drm_link_status_enum_list[] = {
+   { DRM_MODE_LINK_STATUS_GOOD, "Good" },
+   { DRM_MODE_LINK_STATUS_BAD, "Bad" },
+};
+
 /*
  * Optional properties
  */
@@ -1394,6 +1399,13 @@ static int drm_mode_create_standard_properties(struct 
drm_device *dev)
return -ENOMEM;
dev->mode_config.tile_property = prop;
 
+   prop = drm_property_create_enum(dev, 0, "link-status",
+   drm_link_status_enum_list,
+   ARRAY_SIZE(drm_link_status_enum_list));
+   if (!prop)
+   return -ENOMEM;
+   dev->mode_config.link_status_property = prop;
+
prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
"type", drm_plane_type_enum_list,
ARRAY_SIZE(drm_plane_type_enum_list));
@@ -4845,6 +4857,35 @@ int drm_mode_connector_property_set_ioctl(struct 
drm_device *dev,
return drm_mode_obj_set_property_ioctl(dev, _set_prop, file_priv);
 }
 
+/**
+ * drm_mode_connector_set_link_status_property - Set link status property of a 
connector
+ * @connector: drm connector
+ * @link_status: new value of link status property (0: Good, 1: Bad)
+ *
+ * In usual working scenario, this link status property will always be set to
+ * "GOOD". If something fails during or after a mode set, the kernel driver
+ * may set this link status property to "BAD". The caller then needs to send a
+ * hotplug uevent for userspace to re-check the valid modes through
+ * GET_CONNECTOR_IOCTL and retry modeset.
+ *
+ * Note: Drivers cannot rely on userspace to support this property and
+ * issue a modeset. As such, they may choose to handle issues (like
+ * re-training a link) without userspace's intervention.
+ *
+ * The reason for adding this property is to handle link training failures, but
+ * it is not limited to DP or link training. For example, if we implement
+ * asynchronous setcrtc, this property can be used to report any failures in 
that.
+ */
+void drm_mode_connector_set_link_status_property(struct drm_connector 
*connector,
+uint64_t link_status)
+{
+   struct drm_device *dev = connector->dev;
+
+   drm_modeset_lock(>mode_config.connection_mutex, NULL);
+   connector->state->link_status = link_status;
+   drm_modeset_unlock(>mode_config.connection_mutex);
+}
+
 static int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
   struct drm_property *property,
   uint64_t value)
diff --git sys/dev/pci/drm/drm_crtc.h sys/dev/pci/drm/drm_crtc.h
index bc5474cb422..480100d6c9e 100644
--- sys/dev/pci/drm/drm_crtc.h
+++ sys/dev/pci/drm/drm_crtc.h
@@ -126,6 +126,12 @@ enum subpixel_order {
SubPixelNone,
 };
 
+enum drm_link_status {
+   DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD,
+   DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD,
+};
+
+
 #define DRM_COLOR_FORMAT_RGB444(1<<0)
 #define DRM_COLOR_FORMAT_YCRCB444  (1<<1)
 #define DRM_COLOR_FORMAT_YCRCB422  (1<<2)
@@ -497,6 +503,8 @@ struct drm_connector_state {
 
struct drm_encoder *best_encoder;
 
+   enum drm_link_status link_status;
+
struct drm_atomic_state *state;
 };
 
@@ -1112,6 +1120,7 @@ struct drm_mode_config {
struct drm_property *dpms_property;
struct drm_property *path_property;
struct drm_property *tile_property;
+   struct drm_property *link_status_property;
struct drm_property *plane_type_property;