Intel i219 network card support

2016-02-08 Thread Christian Ehrhardt

Hi everyone,

based on the latest release of the Intel driver for FreeBSD (em-7.5.2),
I've adapted the em(4) driver to support the skylake based i219
onboard ethernet chips.

I do not have access to relevant specs, everything below is
based on reading the Intel code referenced above.

The diff was initially done for 5.7, bluhm@ did the forward port
to current. The resulting diff is below.

The major differences are:
- The NVRAM access registers are no longer in a separate BAR. Instead
  they are at offset 0xe000 in the MMIO bar. As a consequence the
  BAR access registers must be accessed with 32-Bit memory operations.
- There are several quirks where the i219 chips need special handling.

The most suspicious one of the quirks is where we need to flush the
tx desc ring. We use the pointer list of the tx ring as a send buffer
for a dummy packet that must be sent to flush the tx ring.

Here's a list of functions that have special handling for the
SPT based cards in the uptream intel code that I did not port
for various reasons:
- The link check code in OpenBSD differs significantly from upstream
  code. Special cases for SPT based chips in em_check_for_link have
  been ignored.
- e1000_check_for_copper_link_ich8lan has been ignored.
- e1000_suspend_workaroudns_ich8lan has been ignored. Suspend does
  seem to work on my I219_V chip, though.
- NVRAM write is not supported for I217 based chips in OpenBSD and
  the code is missing for I219 chips, too.

The patch works nicely on my I219_V chip, the other chips are
untested. I may be able to do tests with I219_LM withhin the next
few days, though.

If you own a skylake based onboard NIC, please give this diff a try.

Who should I ask for oks?

 regardsChristian

Index: dev/pci/if_em.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_em.c,v
retrieving revision 1.329
diff -u -p -r1.329 if_em.c
--- dev/pci/if_em.c 12 Jan 2016 00:05:21 -  1.329
+++ dev/pci/if_em.c 4 Feb 2016 20:33:26 -
@@ -145,6 +145,10 @@ const struct pci_matchid em_devices[] = 
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I218_V },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I218_V_2 },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I218_V_3 },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_LM2 },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I219_V2 },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82580_COPPER },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82580_FIBER },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82580_SERDES },
@@ -253,6 +257,9 @@ int  em_dma_malloc(struct em_softc *, bu
 void em_dma_free(struct em_softc *, struct em_dma_alloc *);
 u_int32_t em_fill_descriptors(u_int64_t address, u_int32_t length,
  PDESC_ARRAY desc_array);
+void em_flush_tx_ring(struct em_softc *);
+void em_flush_rx_ring(struct em_softc *);
+void em_flush_desc_rings(struct em_softc *);
 
 /*
  *  OpenBSD Device Interface Entry Points
@@ -435,6 +442,7 @@ em_attach(struct device *parent, struct 
case em_ich10lan:
case em_pch2lan:
case em_pch_lpt:
+   case em_pch_spt:
case em_80003es2lan:
/* 9K Jumbo Frame size */
sc->hw.max_frame_size = 9234;
@@ -844,6 +852,7 @@ em_init(void *arg)
case em_pchlan:
case em_pch2lan:
case em_pch_lpt:
+   case em_pch_spt:
pba = E1000_PBA_26K;
break;
default:
@@ -1506,10 +1515,12 @@ em_stop(void *arg, int softonly)
timeout_del(&sc->timer_handle);
timeout_del(&sc->tx_fifo_timer_handle);
 
-   if (!softonly) {
+   if (!softonly)
em_disable_intr(sc);
+   if (sc->hw.mac_type == em_pch_spt)
+   em_flush_desc_rings(sc);
+   if (!softonly)
em_reset_hw(&sc->hw);
-   }
 
intr_barrier(sc->sc_intrhand);
ifq_barrier(&ifp->if_snd);
@@ -1563,6 +1574,27 @@ em_identify_hardware(struct em_softc *sc
sc->hw.phy_init_script = TRUE;
 }
 
+void
+em_legacy_irq_quirk_spt(struct em_softc *sc)
+{
+   uint32_treg;
+
+   /* Legacy interrupt: SPT needs a quirk. */
+   if (sc->hw.mac_type != em_pch_spt)
+   return;
+   if (sc->legacy_irq == 0)
+   return;
+
+   reg = EM_READ_REG(&sc->hw, E1000_FEXTNVM7);
+   reg |= E1000_FEXTNVM7_SIDE_CLK_UNGATE;
+   EM_WRITE_REG(&sc->hw, E1000_FEXTNVM7, reg);
+
+   reg = EM_READ_REG(&sc->hw, E1000_FEXTNVM9);
+   reg |= E1000_FEXTNVM9_IOSFSB_CLKGATE_DIS |
+   E1000_FEXTNVM9_IOSFSB_CLKREQ_DIS;
+   EM_WRITE_REG(&sc->hw, E1000_FEXTNVM9, reg);
+}
+
 int
 em_allocate_pci_resources(struct em_softc

hexdump(1) - bug when skip == sb.st_size

2016-02-08 Thread Michal Mazurek
When running
hexdump -s $NUM file
where NUM is the size of the file, hexdump will print the entire file,
instead of skipping over the content.

"od -j $NUM" has the same issue.

Index: display.c
===
RCS file: /cvs/src/usr.bin/hexdump/display.c,v
retrieving revision 1.21
diff -u -p -r1.21 display.c
--- display.c   16 Jan 2015 06:40:08 -  1.21
+++ display.c   8 Feb 2016 12:39:12 -
@@ -329,7 +326,7 @@ doskip(const char *fname, int statok)
if (fstat(fileno(stdin), &sb))
err(1, "fstat %s", fname);
if (S_ISREG(sb.st_mode)) {
-   if (skip >= sb.st_size) {
+   if (skip > sb.st_size) {
address += sb.st_size;
skip -= sb.st_size;
} else {

This bug was discovered by tdm.

-- 
Michal Mazurek



hexdump(1) - unneeded headers

2016-02-08 Thread Michal Mazurek
These headers appear to be unneeded:

Index: conv.c
===
RCS file: /cvs/src/usr.bin/hexdump/conv.c,v
retrieving revision 1.10
diff -u -p -r1.10 conv.c
--- conv.c  19 Apr 2014 09:28:20 -  1.10
+++ conv.c  8 Feb 2016 12:59:43 -
@@ -30,10 +30,8 @@
  * SUCH DAMAGE.
  */
 
-#include 
-
-#include 
 #include 
+#include 
 
 #include "hexdump.h"
 
Index: display.c
===
RCS file: /cvs/src/usr.bin/hexdump/display.c,v
retrieving revision 1.21
diff -u -p -r1.21 display.c
--- display.c   16 Jan 2015 06:40:08 -  1.21
+++ display.c   8 Feb 2016 12:59:43 -
@@ -34,11 +34,9 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-#include 
 
 #include "hexdump.h"
 
Index: hexdump.c
===
RCS file: /cvs/src/usr.bin/hexdump/hexdump.c,v
retrieving revision 1.19
diff -u -p -r1.19 hexdump.c
--- hexdump.c   9 Oct 2015 01:37:07 -   1.19
+++ hexdump.c   8 Feb 2016 12:59:43 -
@@ -31,10 +31,10 @@
  */
 
 #include 
-#include 
 #include 
-#include 
 #include 
+#include 
+
 #include "hexdump.h"
 
 #define MINIMUM(a, b)  (((a) < (b)) ? (a) : (b))
Index: hexsyntax.c
===
RCS file: /cvs/src/usr.bin/hexdump/hexsyntax.c,v
retrieving revision 1.12
diff -u -p -r1.12 hexsyntax.c
--- hexsyntax.c 6 May 2011 15:46:29 -   1.12
+++ hexsyntax.c 8 Feb 2016 12:59:43 -
@@ -30,13 +30,10 @@
  * SUCH DAMAGE.
  */
 
-#include 
-
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "hexdump.h"
Index: odsyntax.c
===
RCS file: /cvs/src/usr.bin/hexdump/odsyntax.c,v
retrieving revision 1.26
diff -u -p -r1.26 odsyntax.c
--- odsyntax.c  16 Sep 2015 08:47:26 -  1.26
+++ odsyntax.c  8 Feb 2016 12:59:43 -
@@ -30,8 +30,6 @@
  * SUCH DAMAGE.
  */
 
-#include 
-
 #include 
 #include 
 #include 
Index: parse.c
===
RCS file: /cvs/src/usr.bin/hexdump/parse.c,v
retrieving revision 1.17
diff -u -p -r1.17 parse.c
--- parse.c 27 Oct 2009 23:59:39 -  1.17
+++ parse.c 8 Feb 2016 12:59:43 -
@@ -30,13 +30,8 @@
  * SUCH DAMAGE.
  */
 
-#include 
-#include 
-
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 

-- 
Michal Mazurek



hexdump(1) - don't declare main

2016-02-08 Thread Michal Mazurek
main() doesn't need to be declared.

Index: hexdump.c
===
RCS file: /cvs/src/usr.bin/hexdump/hexdump.c,v
retrieving revision 1.19
diff -u -p -r1.19 hexdump.c
--- hexdump.c   9 Oct 2015 01:37:07 -   1.19
+++ hexdump.c   8 Feb 2016 12:39:12 -
@@ -45,8 +45,6 @@ int exitval;  /* final exit value */
 long length = -1;  /* max bytes to read */
 char *iobuf;   /* stdio I/O buffer */
 size_t iobufsiz;   /* size of stdio I/O buffer */
-
-intmain(int, char **);
 
 int
 main(int argc, char *argv[])

-- 
Michal Mazurek



hexdump(1) - tidy declarations

2016-02-08 Thread Michal Mazurek
Move some declarations out of hexdump.h
Mark some declarations as __dead or static
Remove a commented out declaration
Convert some spaces to tabs

Index: display.c
===
RCS file: /cvs/src/usr.bin/hexdump/display.c,v
retrieving revision 1.21
diff -u -p -r1.21 display.c
--- display.c   16 Jan 2015 06:40:08 -  1.21
+++ display.c   8 Feb 2016 13:56:10 -
@@ -49,7 +49,10 @@ enum _vflag vflag = FIRST;
 static off_t address;  /* address/offset in stream */
 static off_t eaddress; /* end address */
 
-static __inline void print(PR *, u_char *);
+static void bpad(PR *);
+static void doskip(const char *, int);
+static __inline voidprint(PR *, u_char *);
+static u_char  *get(void);
 
 void
 display(void)
@@ -196,7 +199,7 @@ print(PR *pr, u_char *bp)
}
 }
 
-void
+static void
 bpad(PR *pr)
 {
static const char *spec = " -0+#";
@@ -216,7 +219,7 @@ bpad(PR *pr)
 
 static char **_argv;
 
-u_char *
+static u_char *
 get(void)
 {
static int ateof = 1;
@@ -319,7 +322,7 @@ next(char **argv)
/* NOTREACHED */
 }
 
-void
+static void
 doskip(const char *fname, int statok)
 {
off_t cnt;
Index: hexdump.h
===
RCS file: /cvs/src/usr.bin/hexdump/hexdump.h,v
retrieving revision 1.10
diff -u -p -r1.10 hexdump.h
--- hexdump.h   19 Apr 2014 09:28:20 -  1.10
+++ hexdump.h   8 Feb 2016 13:56:10 -
@@ -78,30 +78,19 @@ extern int exitval; /* final exit valu
 extern FS *fshead; /* head of format strings list */
 extern long length;/* max bytes to read */
 extern off_t skip; /* bytes to skip */
-extern char *iobuf;/* stdio I/O buffer */
-extern size_t iobufsiz;/* size of stdio I/O buffer */
+extern char *iobuf;/* stdio I/O buffer */
+extern size_t iobufsiz;/* size of stdio I/O buffer */
 extern enum _vflag vflag;
 
 voidadd(const char *);
 voidaddfile(char *);
-voidbadcnt(char *);
-voidbadconv(char *);
-voidbadfmt(const char *);
-voidbadsfmt(void);
-voidbpad(PR *);
 voidconv_c(PR *, u_char *);
 voidconv_u(PR *, u_char *);
 voiddisplay(void);
-voiddoskip(const char *, int);
-/*void  err(const char *, ...);*/
 void   *emalloc(int);
-voidescape(char *);
-u_char *get(void);
 voidnewsyntax(int, char ***);
 int next(char **);
 voidnomem(void);
 voidoldsyntax(int, char ***);
 voidrewrite(FS *);
 int size(FS *);
-voidusage(void);
-voidoldusage(void);
Index: hexsyntax.c
===
RCS file: /cvs/src/usr.bin/hexdump/hexsyntax.c,v
retrieving revision 1.12
diff -u -p -r1.12 hexsyntax.c
--- hexsyntax.c 6 May 2011 15:46:29 -   1.12
+++ hexsyntax.c 8 Feb 2016 13:56:10 -
@@ -43,6 +43,8 @@
 
 off_t skip;/* bytes to skip */
 
+static __dead void  usage(void);
+
 void
 newsyntax(int argc, char ***argvp)
 {
@@ -121,7 +123,7 @@ newsyntax(int argc, char ***argvp)
*argvp += optind;
 }
 
-void
+static __dead void
 usage(void)
 {
extern char *__progname;
Index: odsyntax.c
===
RCS file: /cvs/src/usr.bin/hexdump/odsyntax.c,v
retrieving revision 1.26
diff -u -p -r1.26 odsyntax.c
--- odsyntax.c  16 Sep 2015 08:47:26 -  1.26
+++ odsyntax.c  8 Feb 2016 13:56:10 -
@@ -44,10 +44,10 @@
 
 int odmode;
 
-static void odoffset(int, char ***);
-static void posixtypes(char *);
-static void odadd(const char *);
-
+static void odadd(const char *);
+static void odoffset(int, char ***);
+static __dead void  oldusage(void);
+static void posixtypes(char *);
 
 /*
  * formats used for -t
@@ -293,7 +293,7 @@ posixtypes(char *type_string)
}
 }
 
-void
+static __dead void
 oldusage(void)
 {
extern char *__progname;
Index: parse.c
===
RCS file: /cvs/src/usr.bin/hexdump/parse.c,v
retrieving revision 1.17
diff -u -p -r1.17 parse.c
--- parse.c 27 Oct 2009 23:59:39 -  1.17
+++ parse.c 8 Feb 2016 13:56:10 -
@@ -45,6 +45,12 @@
 
 FU *endfu; /* format at end-of-data */
 
+static __dead void  badcnt(char *);
+static __dead void  badconv(char *);
+static __dead void  badfmt(const char *);
+static __dead void  badsfmt(void);
+static void escape(char *);
+
 void
 addfile(char *name)
 {
@@ -453,7 +459,7 @@ rewrite(FS *fs)
 #endif
 }
 
-void
+static void
 escape(char *p1)
 {
char *p2;
@@ -501,25 +507,25 @@ escape(char *p1)
}
 }
 
-void
+static __dead void
 badcnt(char *s)
 {
errx(1, "%s: bad 

df(1) - unneeded headers

2016-02-08 Thread Michal Mazurek
This was ok tb@ but never commited.


Remove uneeded includes, and sort those that can be sorted (some can't):

Index: df.c
===
RCS file: /cvs/src/bin/df/df.c,v
retrieving revision 1.54
diff -u -p -r1.54 df.c
--- df.c9 Oct 2015 01:37:06 -   1.54
+++ df.c1 Feb 2016 09:43:38 -
@@ -41,7 +41,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
Index: ext2fs_df.c
===
RCS file: /cvs/src/bin/df/ext2fs_df.c,v
retrieving revision 1.14
diff -u -p -r1.14 ext2fs_df.c
--- ext2fs_df.c 27 Nov 2015 13:49:41 -  1.14
+++ ext2fs_df.c 1 Feb 2016 09:43:38 -
@@ -42,11 +42,8 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+
 #include 
-#include 
-#include 
 
 inte2fs_df(int, char *, struct statfs *);
 
Index: ffs_df.c
===
RCS file: /cvs/src/bin/df/ffs_df.c,v
retrieving revision 1.17
diff -u -p -r1.17 ffs_df.c
--- ffs_df.c27 Nov 2015 13:49:41 -  1.17
+++ ffs_df.c1 Feb 2016 09:43:38 -
@@ -36,13 +36,10 @@
 
 #include 
 #include 
-#include 
 #include 
+#include 
 
-#include 
-#include 
 #include 
-#include 
 
 intffs_df(int, char *, struct statfs *);

-- 
Michal Mazurek



Re: Intel i219 network card support

2016-02-08 Thread Stuart Henderson
On 2016/02/08 13:53, Christian Ehrhardt wrote:
> If you own a skylake based onboard NIC, please give this diff a try.

The most important bit, especially at this point in the release cycle,
is whether it makes any changes that cause problems with other chips.
I don't have time to look closely now but the question is "does
the diff change anything for existing chips, or does it *only* change
things for new chips"?

> Index: dev/pci/pcidevs
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/pcidevs,v
> retrieving revision 1.1786
> diff -u -p -r1.1786 pcidevs
> --- dev/pci/pcidevs   30 Jan 2016 01:02:04 -  1.1786
> +++ dev/pci/pcidevs   4 Feb 2016 16:04:31 -
> @@ -3353,6 +3353,10 @@ product INTEL I218_LM_20x15a0  I218-LM
>  product INTEL I218_V_2   0x15a1  I218-V
>  product INTEL I218_LM_3  0x15a2  I218-LM
>  product INTEL I218_V_3   0x15a3  I218-V
> +product INTEL I219_LM0x156F  I219_LM
> +product INTEL I219_V 0x1570  I219_V
> +product INTEL I219_LM2   0x15B7  I219_LM2
> +product INTEL I219_V20x15B8  I219_V2
>  product INTEL X557_AT2   0x15ad  X557-AT2
>  product INTEL CORE5G_H_PCIE_X16  0x1601  Core 5G PCIE
>  product INTEL CORE5G_M_GT1_1 0x1602  HD Graphics

Please maintain numerical order of pid (0x156f/0x1570 are out of place),
and like the other entries use lowercase for pid and s/_/-/ in the text
version of the device name on the right-hand column.

(When committing the pcidevs parts, pcidevs itself needs to be done
first, then "make" to update the generated files before committing
those, so the generated files show the correct RCS ID in comments).



Re: Ntpd log message readably tweak.

2016-02-08 Thread Otto Moerbeek
On Sun, Feb 07, 2016 at 02:18:46PM +, Gerald Hanuer wrote:

>  Hello tech@,
> 
>  https://marc.info/?l=openbsd-misc&m=145479483809799&w=2
>  > ntpd[9279]: adjusting local clock by 9.096751s
>  > ntpd[9279]: adjusting local clock by 7.971861s
>  > ntpd[9279]: adjusting local clock by 6.838999s
>  > I don't think that clock is adjusted "by" that values.
>  > If that would be the case, I guess clock would be far faster synced.
> 
>  Wording of the logged messages seems to imply that \
>  the clock has been adjusted by the displayed number of \
>  seconds each time the message is printed.
> 
>  What I beleive is trying to be conveyed to the "sysadmin" \
>  is, the current offset of the local clock \
>  relative to the time server.
> 
>  This is the output with the included patch applied.
>  ntpd[17167]: adjusting local clock (offset -15.877748s)
>  ntpd[17167]: adjusting local clock (offset -14.532992s)
>  ntpd[17167]: adjusting local clock (offset -14.216236s)
> 
>  The patch takes cues from code else where in ntpd.c
>  strftime(buf, sizeof(buf), "%a %b %e %H:%M:%S %Z %Y",
> localtime(&tval));
> log_info("set local clock to %s (offset %fs)", buf, d);
> 
>  This is the output of that existing code.
>  ntpd[20576]: set local clock to Sun Feb  7 01:38:35 UTC 2016 (offset
> -0.262911s)
> 
>  Regards,
>Gerald Hanuer

This has been discussed before. The -ing form here means the action is
"in progress". This is called "progressive aspect" in linguistic
terms. 

Adjusting the clock isn't done instantaneously. It's done by speeding
up or slowing down the running of the clock and thus takes a while.
This is different from "setting" the clock. 

-Otto

> 
> Index: ntpd.c
> ===
> RCS file: /cvs/src/usr.sbin/ntpd/ntpd.c,v
> retrieving revision 1.106
> diff -u -p -r1.106 ntpd.c
> --- ntpd.c 2 Feb 2016 17:51:11 - 1.106
> +++ ntpd.c 7 Feb 2016 08:52:34 -
> @@ -443,9 +443,9 @@ ntpd_adjtime(double d)
>   d += getoffset();
>   if (d >= (double)LOG_NEGLIGIBLE_ADJTIME / 1000 ||
>  d <= -1 * (double)LOG_NEGLIGIBLE_ADJTIME / 1000)
> - log_info("adjusting local clock by %fs", d);
> + log_info("adjusting local clock (offset %fs)", d);
>   else
> - log_debug("adjusting local clock by %fs", d);
> + log_debug("adjusting local clock (offset %fs)", d);
>   d_to_tv(d, &tv);
>   if (adjtime(&tv, &olddelta) == -1)
>   log_warn("adjtime failed");



Re: Intel i219 network card support

2016-02-08 Thread Christian Ehrhardt

Hi,

On Mon, Feb 08, 2016 at 02:35:32PM +, Stuart Henderson wrote:
> On 2016/02/08 13:53, Christian Ehrhardt wrote:
> > If you own a skylake based onboard NIC, please give this diff a try.
> 
> The most important bit, especially at this point in the release cycle,
> is whether it makes any changes that cause problems with other chips.
> I don't have time to look closely now but the question is "does
> the diff change anything for existing chips, or does it *only* change
> things for new chips"?

It's not supposed to change anything for existing chips. If it does
I'd consider this a bug in the diff.

> > Index: dev/pci/pcidevs
> > ===
> > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/pcidevs,v
> > retrieving revision 1.1786
> > diff -u -p -r1.1786 pcidevs
> > --- dev/pci/pcidevs 30 Jan 2016 01:02:04 -  1.1786
> > +++ dev/pci/pcidevs 4 Feb 2016 16:04:31 -
> > @@ -3353,6 +3353,10 @@ product INTEL I218_LM_2  0x15a0  I218-LM
> >  product INTEL I218_V_2 0x15a1  I218-V
> >  product INTEL I218_LM_30x15a2  I218-LM
> >  product INTEL I218_V_3 0x15a3  I218-V
> > +product INTEL I219_LM  0x156F  I219_LM
> > +product INTEL I219_V   0x1570  I219_V
> > +product INTEL I219_LM2 0x15B7  I219_LM2
> > +product INTEL I219_V2  0x15B8  I219_V2
> >  product INTEL X557_AT2 0x15ad  X557-AT2
> >  product INTEL CORE5G_H_PCIE_X160x1601  Core 5G PCIE
> >  product INTEL CORE5G_M_GT1_1   0x1602  HD Graphics
> 
> Please maintain numerical order of pid (0x156f/0x1570 are out of place),
> and like the other entries use lowercase for pid and s/_/-/ in the text
> version of the device name on the right-hand column.

Ok.regards   Christian



signature.asc
Description: Digital signature


Re: df(1) - unneeded headers

2016-02-08 Thread Michael McConville
Michal Mazurek wrote:
> This was ok tb@ but never commited.
> 
> Remove uneeded includes, and sort those that can be sorted (some can't):

Committed (mostly). Thanks!

I left stdlib.h and unistd.h because I think that C99 requires that
those be included when using libc, although failing to do so is
non-fatal. You'll see warnings for this if you use a newer compiler and
build with -Wall.

> Index: df.c
> ===
> RCS file: /cvs/src/bin/df/df.c,v
> retrieving revision 1.54
> diff -u -p -r1.54 df.c
> --- df.c  9 Oct 2015 01:37:06 -   1.54
> +++ df.c  1 Feb 2016 09:43:38 -
> @@ -41,7 +41,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> Index: ext2fs_df.c
> ===
> RCS file: /cvs/src/bin/df/ext2fs_df.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 ext2fs_df.c
> --- ext2fs_df.c   27 Nov 2015 13:49:41 -  1.14
> +++ ext2fs_df.c   1 Feb 2016 09:43:38 -
> @@ -42,11 +42,8 @@
>  #include 
>  #include 
>  #include 
> -#include 
> -#include 
> +
>  #include 
> -#include 
> -#include 
>  
>  int  e2fs_df(int, char *, struct statfs *);
>  
> Index: ffs_df.c
> ===
> RCS file: /cvs/src/bin/df/ffs_df.c,v
> retrieving revision 1.17
> diff -u -p -r1.17 ffs_df.c
> --- ffs_df.c  27 Nov 2015 13:49:41 -  1.17
> +++ ffs_df.c  1 Feb 2016 09:43:38 -
> @@ -36,13 +36,10 @@
>  
>  #include 
>  #include 
> -#include 
>  #include 
> +#include 
>  
> -#include 
> -#include 
>  #include 
> -#include 
>  
>  int  ffs_df(int, char *, struct statfs *);
> 
> -- 
> Michal Mazurek
> 



Re: hexdump(1) - bug when skip == sb.st_size

2016-02-08 Thread Ingo Schwarze
Hi,

Michal Mazurek wrote on Mon, Feb 08, 2016 at 02:11:19PM +0100:

> When running
>   hexdump -s $NUM file
> where NUM is the size of the file, hexdump will print the entire file,
> instead of skipping over the content.

This looks correct and works for me.

OK to commit?
  Ingo


> "od -j $NUM" has the same issue.
> 
> Index: display.c
> ===
> RCS file: /cvs/src/usr.bin/hexdump/display.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 display.c
> --- display.c 16 Jan 2015 06:40:08 -  1.21
> +++ display.c 8 Feb 2016 12:39:12 -
> @@ -329,7 +326,7 @@ doskip(const char *fname, int statok)
>   if (fstat(fileno(stdin), &sb))
>   err(1, "fstat %s", fname);
>   if (S_ISREG(sb.st_mode)) {
> - if (skip >= sb.st_size) {
> + if (skip > sb.st_size) {
>   address += sb.st_size;
>   skip -= sb.st_size;
>   } else {
> 
> This bug was discovered by tdm.



Re: Ntpd log message readably tweak.

2016-02-08 Thread Gerald Hanuer
Hello tech@,

 Otto thanks for the clarification.

 https://marc.info/?l=openbsd-misc&m=145480059910903&w=2

 I had not seen Naddy's comment before firing off the diff.

 The explanations given are clear and helpfull.

  Regards,
 Gerald Hanuer



Re: pkg_add.1

2016-02-08 Thread Marc Espie
On Sun, Feb 07, 2016 at 09:42:32AM -0600, joshua stein wrote:
> We don't recommend FTP mirrors anymore, installing a package via a
> pipe doesn't seem to work anymore, and packages have to be signed to
> be installed so the advice about miscreants is not very relevant.
> 
> 
installing packages thru pipes should still work.
surprised it got broken.

you can still install non-signed packages if you really try.



Re: pkg_add.1

2016-02-08 Thread Edgar Pettijohn


Sent from my iPhone

> On Feb 8, 2016, at 12:28 PM, Marc Espie  wrote:
> 
>> On Sun, Feb 07, 2016 at 09:42:32AM -0600, joshua stein wrote:
>> We don't recommend FTP mirrors anymore, installing a package via a
>> pipe doesn't seem to work anymore, and packages have to be signed to
>> be installed so the advice about miscreants is not very relevant.
> installing packages thru pipes should still work.
> surprised it got broken.
> 

I usually do install thru pipes and I haven't seen it broken. I haven't tried 
with the latest snapshot though.

> you can still install non-signed packages if you really try.
> 



Re: ufs/ffs/ext2fs uiomove() conversion

2016-02-08 Thread Stefan Kempf
Martin Natano wrote:
> Below the conversion to uiomovei() for ufs. While there I changed all
> instances of 'blkoffset', 'size' and 'xfersize' that where declared as
> long integers to be plain integers instead for consistency with the
> surrounding code. These variables are limited by fs_bsize and e2fs_bsize
> respectively, which are int32_t. So, no overflow should be introduced bu
> that change. Also, 'size' is passed to bread(), which expects an integer
> parameter.

These all look good. It's easy to see that these variables have all
small max. values.
 
One unrelated thing noted while reviewing:

ufs/ext2fs/ext2fs_readwrite.c:
static int
ext2_ind_read(struct vnode *vp, struct inode *ip, struct m_ext2fs *fs,
struct uio *uio)
{
...

if (vp->v_type == VLNK) {
if ((int)ext2fs_size(ip) < vp->v_mount->mnt_maxsymlinklen ||
^

(vp->v_mount->mnt_maxsymlinklen == 0 &&
ip->i_e2fs_nblock == 0))
panic("%s: short symlink", "ext2fs_read");

ufs/ffs/ffs_vnops.c:
int
ffs_read(void *v)
{
...
if (vp->v_type == VLNK) {
if ((int)DIP(ip, size) < vp->v_mount->mnt_maxsymlinklen ||

(vp->v_mount->mnt_maxsymlinklen == 0 &&
 DIP(ip, blocks) == 0))
panic("ffs_read: short symlink");

This code checks that the filesystem read routines are not invoked on
symlinks where the destination path fits into the inode itself.
We should get rid of these truncating casts in a separate diff.

> Index: ufs/ext2fs/ext2fs_lookup.c
> ===
> RCS file: /cvs/src/sys/ufs/ext2fs/ext2fs_lookup.c,v
> retrieving revision 1.39
> diff -u -p -u -r1.39 ext2fs_lookup.c
> --- ufs/ext2fs/ext2fs_lookup.c14 Mar 2015 03:38:52 -  1.39
> +++ ufs/ext2fs/ext2fs_lookup.c7 Feb 2016 17:48:03 -
> @@ -177,7 +177,7 @@ ext2fs_readdir(void *v)
>   break;
>   }
>   dstd.d_off = off + e2d_reclen;
> - if ((error = uiomovei((caddr_t)&dstd, dstd.d_reclen, 
> uio)) != 0) {
> + if ((error = uiomove((caddr_t)&dstd, dstd.d_reclen, 
> uio)) != 0) {
>   break;
>   }
>   off = off + e2d_reclen;
> Index: ufs/ext2fs/ext2fs_readwrite.c
> ===
> RCS file: /cvs/src/sys/ufs/ext2fs/ext2fs_readwrite.c,v
> retrieving revision 1.36
> diff -u -p -u -r1.36 ext2fs_readwrite.c
> --- ufs/ext2fs/ext2fs_readwrite.c 12 Jan 2016 11:44:21 -  1.36
> +++ ufs/ext2fs/ext2fs_readwrite.c 7 Feb 2016 17:48:03 -
> @@ -87,7 +87,7 @@ ext2_ind_read(struct vnode *vp, struct i
>   struct buf *bp;
>   daddr_t lbn, nextlbn;
>   off_t bytesinfile;
> - long size, xfersize, blkoffset;
> + int size, xfersize, blkoffset;
>   int error;
>  
>  #ifdef DIAGNOSTIC
> @@ -145,7 +145,7 @@ ext2_ind_read(struct vnode *vp, struct i
>   break;
>   xfersize = size;
>   }
> - error = uiomovei((char *)bp->b_data + blkoffset, xfersize, uio);
> + error = uiomove((char *)bp->b_data + blkoffset, xfersize, uio);
>   if (error)
>   break;
>   brelse(bp);
> @@ -168,7 +168,7 @@ ext4_ext_read(struct vnode *vp, struct i
>   size_t orig_resid;
>   daddr_t lbn, pos;
>   off_t bytesinfile;
> - long size, xfersize, blkoffset;
> + int size, xfersize, blkoffset;
>   int error, cache_type;
>  
>   memset(&path, 0, sizeof path);
> @@ -225,7 +225,7 @@ ext4_ext_read(struct vnode *vp, struct i
>   }
>   xfersize = size;
>   }
> - error = uiomovei(bp->b_data + blkoffset, xfersize, uio);
> + error = uiomove(bp->b_data + blkoffset, xfersize, uio);
>   brelse(bp);
>   if (error)
>   return (error);
> @@ -248,7 +248,8 @@ ext2fs_write(void *v)
>   int32_t lbn;
>   off_t osize;
>   int blkoffset, error, flags, ioflag, size, xfersize;
> - ssize_t resid, overrun;
> + size_t resid;
> + ssize_t overrun;
>  
>   ioflag = ap->a_ioflag;
>   uio = ap->a_uio;
> @@ -324,8 +325,7 @@ ext2fs_write(void *v)
>   if (size < xfersize)
>   xfersize = size;
>  
> - error =
> - uiomovei((char *)bp->b_data + blkoffset, (int)xfersize, 
> uio);
> + error = uiomove((char *)bp->b_data + blkoffset, xfersize, uio);
>  #if 0
>   if (ioflag & IO_NOCACHE)
>   bp->b_flags |= B_NOCACHE;
> Index: ufs/ext2fs/ext2fs_vnops.c
> ==

Re: ufs/ffs/ext2fs uiomove() conversion

2016-02-08 Thread Martin Natano
> One unrelated thing noted while reviewing:
> 
> ufs/ext2fs/ext2fs_readwrite.c:
> static int
> ext2_ind_read(struct vnode *vp, struct inode *ip, struct m_ext2fs *fs,
> struct uio *uio)
> {
>   ...
> 
>   if (vp->v_type == VLNK) {
>   if ((int)ext2fs_size(ip) < vp->v_mount->mnt_maxsymlinklen ||
> ^
> 
>   (vp->v_mount->mnt_maxsymlinklen == 0 &&
>   ip->i_e2fs_nblock == 0))
>   panic("%s: short symlink", "ext2fs_read");
> 
> ufs/ffs/ffs_vnops.c:
> int
> ffs_read(void *v)
> {
>   ...
>   if (vp->v_type == VLNK) {
>   if ((int)DIP(ip, size) < vp->v_mount->mnt_maxsymlinklen ||
>   
>   (vp->v_mount->mnt_maxsymlinklen == 0 &&
>DIP(ip, blocks) == 0))
>   panic("ffs_read: short symlink");
> 
> This code checks that the filesystem read routines are not invoked on
> symlinks where the destination path fits into the inode itself.
> We should get rid of these truncating casts in a separate diff.

I agree, the casts are wrong. Removing them would cause the compare to
be performed with u_int64_t parameters, which is IMHO the right thing to
do.



vi.1: remove more predefined strings

2016-02-08 Thread Michael Reed

Done for the same reason as rev.  1.57[1].  I observed no diff in the
generated output for terminals, but I'm unsure if these strings are
wanted for prettier pdf/ps/html/... output.

Regards,
  Michael Reed

[1]: 
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/vi/docs/USD.doc/vi.man/vi.1?rev=1.57&content-type=text/x-cvsweb-markup


Index: vi.1
===
RCS file: /cvs/src/usr.bin/vi/docs/USD.doc/vi.man/vi.1,v
retrieving revision 1.63
diff -u -p -r1.63 vi.1
--- vi.16 Jan 2016 22:41:53 -   1.63
+++ vi.18 Feb 2016 18:20:05 -
@@ -354,7 +354,7 @@ matches the beginning of the word.
 .Sq \e>
 matches the end of the word.
 .It
-.Sq \(a~
+.Sq ~
 matches the replacement part of the last
 .Cm substitute
 command.
@@ -2059,9 +2059,9 @@ If this is the entire
 pattern, the replacement part of the previous
 .Cm substitute
 command.
-.It Sq \e\(sh
+.It Sq \e#
 Where
-.Sq \(sh
+.Sq #
 is an integer from 1 to 9, the text matched by the #'th subexpression in
 .Ar pattern .
 .It Sq \eL
@@ -2350,9 +2350,9 @@ Display lines in an unambiguous fashion.
 Attempt to get an exclusive lock on any file being edited, read or written.
 .It Cm magic Bq on
 When turned off, all regular expression characters except for
-.Sq \(ha
+.Sq ^
 and
-.Sq \(Do
+.Sq $
 are treated as ordinary characters.
 Preceding individual characters by
 .Sq \e



doas do CR before printing challenge

2016-02-08 Thread Martijn van Duren
Hello tech@,

The following patch adds a carriage return before printing the regular
challenge.

If you're like me and you sometimes forget to wait before the prompt
comes up before typing your password it might be a little less stressful
if the message returns to the start of the line instead of after the
first few characters of your password and you have to rush to clear(1).

I don't know the impact of prepending this to auth_userchallenge(3), so
I left this one alone for now.

Any OKs or objections?

martijn@

Index: doas.c
===
RCS file: /cvs/src/usr.bin/doas/doas.c,v
retrieving revision 1.50
diff -u -p -r1.50 doas.c
--- doas.c  7 Feb 2016 20:01:58 -   1.50
+++ doas.c  8 Feb 2016 20:30:48 -
@@ -425,7 +425,7 @@ main(int argc, char **argv, char **envp)
if (gethostname(host, sizeof(host)))
snprintf(host, sizeof(host), "?");
snprintf(cbuf, sizeof(cbuf),
-   "doas (%.32s@%.32s) password: ", myname, host);
+   "\rdoas (%.32s@%.32s) password: ", myname, host);
challenge = cbuf;
}
response = readpassphrase(challenge, rbuf, sizeof(rbuf),



Re: Intel i219 network card support

2016-02-08 Thread Alexander Bluhm
On Mon, Feb 08, 2016 at 01:53:20PM +0100, Christian Ehrhardt wrote:
> The diff was initially done for 5.7, bluhm@ did the forward port
> to current. The resulting diff is below.

I am running this diff with my Thinkpad T430s, no problems so far.

em0 at pci0 dev 25 function 0 "Intel 82579LM" rev 0x04: msi, address 3c:97:...

bluhm



Re: pkg_add.1

2016-02-08 Thread patrick keshishian
On Mon, Feb 08, 2016 at 07:28:24PM +0100, Marc Espie wrote:
> On Sun, Feb 07, 2016 at 09:42:32AM -0600, joshua stein wrote:
> > We don't recommend FTP mirrors anymore, installing a package via a
> > pipe doesn't seem to work anymore, and packages have to be signed to
> > be installed so the advice about miscreants is not very relevant.
> > 
> > 
> installing packages thru pipes should still work.
> surprised it got broken.
> 
> you can still install non-signed packages if you really try.

I haven't build ports in a while, but does this comment mean
that if I'm building my own ports (moving forward), the
resulting packages must be signed?

--patrick



Re: rtadvd unicast

2016-02-08 Thread Jérémie Courrèges-Anglas

> rtadvd contains code to send unicast replies, RFC4861 mentions this
> possibility (section 6.2.6) but I'm having a hard time thinking how it
> could be useful.
>
> Since the sending part is commented out since it was introduced, I doubt
> that anyone will miss it.  This removes pointless memory allocations.
>
> ok?

Updated patch:

Index: config.c
===
RCS file: /cvs/src/usr.sbin/rtadvd/config.c,v
retrieving revision 1.49
diff -u -p -r1.49 config.c
--- config.c8 Feb 2016 23:19:00 -   1.49
+++ config.c8 Feb 2016 23:22:13 -
@@ -111,7 +111,6 @@ getconfig(char *intface)
TAILQ_INIT(&tmp->rtinfos);
TAILQ_INIT(&tmp->rdnsss);
TAILQ_INIT(&tmp->dnssls);
-   SLIST_INIT(&tmp->soliciters);
 
/* check if we are allowed to forward packets (if not determined) */
if (forwarding < 0) {
Index: rtadvd.c
===
RCS file: /cvs/src/usr.sbin/rtadvd/rtadvd.c,v
retrieving revision 1.66
diff -u -p -r1.66 rtadvd.c
--- rtadvd.c8 Feb 2016 23:19:00 -   1.66
+++ rtadvd.c8 Feb 2016 23:22:14 -
@@ -690,18 +690,6 @@ rs_input(int len, struct nd_router_solic
{
long delay; /* must not be greater than 100 */
struct timeval interval, now, min_delay, tm_tmp, *rest;
-   struct soliciter *sol;
-
-   /*
-* record sockaddr waiting for RA, if possible
-*/
-   sol = malloc(sizeof(*sol));
-   if (sol) {
-   sol->addr = *from;
-   /*XXX RFC2553 need clarification on flowinfo */
-   sol->addr.sin6_flowinfo = 0;
-   SLIST_INSERT_HEAD(&ra->soliciters, sol, entry);
-   }
 
/*
 * If there is already a waiting RS packet, don't
@@ -1280,7 +1268,6 @@ ra_output(struct rainfo *rainfo)
int i;
struct cmsghdr *cm;
struct in6_pktinfo *pi;
-   struct soliciter *sol;
 
if ((iflist[rainfo->ifindex]->ifm_flags & IFF_UP) == 0) {
log_debug("%s is not up, skip sending RA", rainfo->ifname);
@@ -1321,25 +1308,6 @@ ra_output(struct rainfo *rainfo)
if (i < 0 || i != rainfo->ra_datalen)
if (i < 0)
log_warn("sendmsg on %s", rainfo->ifname);
-
-   /*
-* unicast advertisements
-* XXX commented out.  reason: though spec does not forbit it, unicast
-* advert does not really help
-*/
-   while (!SLIST_EMPTY(&rainfo->soliciters)) {
-   sol = SLIST_FIRST(&rainfo->soliciters);
-   SLIST_REMOVE_HEAD(&rainfo->soliciters, entry);
-#if 0
-   sndmhdr.msg_name = (caddr_t)&sol->addr;
-   i = sendmsg(sock, &sndmhdr, 0);
-   if (i < 0 || i != rainfo->ra_datalen)
-   if (i < 0)
-   log_warn("unicast sendmsg on %s",
-   rainfo->ifname);
-#endif
-   free(sol);
-   }
 
/* update counter */
if (rainfo->initcounter < MAX_INITIAL_RTR_ADVERTISEMENTS)
Index: rtadvd.h
===
RCS file: /cvs/src/usr.sbin/rtadvd/rtadvd.h,v
retrieving revision 1.20
diff -u -p -r1.20 rtadvd.h
--- rtadvd.h8 Feb 2016 23:19:00 -   1.20
+++ rtadvd.h8 Feb 2016 23:22:14 -
@@ -117,11 +117,6 @@ struct dnssl {
TAILQ_HEAD(dnssldomlist, dnssldom) dnssldoms;
 };
 
-struct soliciter {
-   SLIST_ENTRY(soliciter) entry;
-   struct sockaddr_in6 addr;
-};
-
 struct rainfo {
/* pointer for list */
SLIST_ENTRY(rainfo) entry;
@@ -170,9 +165,6 @@ struct  rainfo {
u_quad_t rainput;   /* number of RAs received */
u_quad_t rainconsistent; /* number of RAs inconsistent with ours */
u_quad_t rsinput;   /* number of RSs received */
-
-   /* info about soliciter */
-   SLIST_HEAD(, soliciter) soliciters; /* recent solicitation source */
 };
 SLIST_HEAD(ralist, rainfo);
 


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: pkg_add.1

2016-02-08 Thread Marc Espie
On Mon, Feb 08, 2016 at 03:05:00PM -0800, patrick keshishian wrote:
> On Mon, Feb 08, 2016 at 07:28:24PM +0100, Marc Espie wrote:
> > On Sun, Feb 07, 2016 at 09:42:32AM -0600, joshua stein wrote:
> > > We don't recommend FTP mirrors anymore, installing a package via a
> > > pipe doesn't seem to work anymore, and packages have to be signed to
> > > be installed so the advice about miscreants is not very relevant.
> > > 
> > > 
> > installing packages thru pipes should still work.
> > surprised it got broken.
> > 
> > you can still install non-signed packages if you really try.
> 
> I haven't build ports in a while, but does this comment mean
> that if I'm building my own ports (moving forward), the
> resulting packages must be signed?

Nope, just be careful not mixing your packages with other stuff, and how
you move them around.   Signing with your personal key is not hard.

Specifically,
- you can use -Dunsigned to install your own unsigned packages
- beware of mixing up your unsigned packages AND official packages for
dependencies (e.g., the later should be signed). Note that even with 
-Dunsigned, packages with a signature will *still* have their signature
checked for tampering.
- be careful of taking care of your unsigned packages properly. Getting
them around insecure networks obviously allows tampering.  You can use scp://
urls to prevent that.

Automatically Signing is reasonably easy. You need to generate a couple of
public/private key using signify, have them be of the form
XXX-pkg.sec and  XXX-pkg.pub, put at least the pubkey under /etc,
then set SIGNING_PARAMETERS properly in /etc/mk.conf, e.g., 
SIGNING_PARAMETERS=-s signify -s /etc/XXX-pkg.sec

(there's no pki. the bootstrap part means getting the pub key under the
correct directory manually)


Admittedly, it's safe if you trust your ports building system, and you have
to take extra care (as usual) to not let /etc/XXX-pkg.sec out of your sight...

You can also build packages normally and sign later off-site using pkg_sign.
More cumbersome, but somewhat safer...

In my opinion, there's nothing in there that's not glaringly obvious if
you have a background in the use of public key cryptography.   We went out
of our way to make the design of the package signing system fairly
intuitive and the possible security trade-offs highly visible (as far as 
public key cryptography can be, of course).



Re: [patch] vi enable -pedantic

2016-02-08 Thread Martijn van Duren
And of course you find out way to late that format=flowed was still on...
Here's a new diff.

Any OKs for this?

On 02/01/16 23:34, Martijn van Duren wrote:
> Hello tech@,
> 
> This patch enables -pedantic and does the appropriate cleanup that comes 
> with it. It's mostly a CHAR_T->char conversion, which should be quite 
> harmless, but edge-cases can be missed.
> 
> I'd like to have multiple OKs for this one as well as testing on 
> multiple architectures, just to be sure.
> 
> The B1LEN, SKIP_PAST_NEWLINE, and PRIu32 are to silence clang with 
> -pedantic.
> 
> Build and tested on amd64 with gcc, egcc and clang.
> 
> This drops the places CHAR_t can be found from 224 to 93.
> 
> martijn@

Index: build/Makefile
===
RCS file: /cvs/src/usr.bin/vi/build/Makefile,v
retrieving revision 1.23
diff -u -p -r1.23 Makefile
--- build/Makefile  6 Jan 2016 22:34:45 -   1.23
+++ build/Makefile  8 Feb 2016 21:35:59 -
@@ -4,7 +4,7 @@
 PROG=  vi
 
 # Modern curses (ncurses)
-CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../include
+CFLAGS+=-pedantic -Werror -I${.CURDIR} -I${.CURDIR}/../include
 LDADD+=-lcurses
 DPADD+= ${LIBCURSES}
 
Index: cl/cl_term.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_term.c,v
retrieving revision 1.21
diff -u -p -r1.21 cl_term.c
--- cl/cl_term.c6 Jan 2016 22:28:52 -   1.21
+++ cl/cl_term.c8 Feb 2016 21:35:59 -
@@ -30,7 +30,7 @@
 #include "../common/common.h"
 #include "cl.h"
 
-static int cl_pfmap(SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t);
+static int cl_pfmap(SCR *, seq_t, char *, size_t, char *, size_t);
 
 /*
  * XXX
@@ -170,10 +170,10 @@ cl_term_end(GS *gp)
  * cl_fmap --
  * Map a function key.
  *
- * PUBLIC: int cl_fmap(SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t);
+ * PUBLIC: int cl_fmap(SCR *, seq_t, char *, size_t, char *, size_t);
  */
 int
-cl_fmap(SCR *sp, seq_t stype, CHAR_T *from, size_t flen, CHAR_T *to,
+cl_fmap(SCR *sp, seq_t stype, char *from, size_t flen, char *to,
 size_t tlen)
 {
/* Ignore until the screen is running, do the real work then. */
@@ -190,7 +190,7 @@ cl_fmap(SCR *sp, seq_t stype, CHAR_T *fr
  * Map a function key (private version).
  */
 static int
-cl_pfmap(SCR *sp, seq_t stype, CHAR_T *from, size_t flen, CHAR_T *to,
+cl_pfmap(SCR *sp, seq_t stype, char *from, size_t flen, char *to,
 size_t tlen)
 {
size_t nlen;
Index: common/args.h
===
RCS file: /cvs/src/usr.bin/vi/common/args.h,v
retrieving revision 1.3
diff -u -p -r1.3 args.h
--- common/args.h   29 Jan 2001 01:58:28 -  1.3
+++ common/args.h   8 Feb 2016 21:35:59 -
@@ -22,7 +22,7 @@
  * is found.
  */
 typedef struct _args {
-   CHAR_T  *bp;/* Argument. */
+   char*bp;/* Argument. */
size_t   blen;  /* Buffer length. */
size_t   len;   /* Argument length. */
 
Index: common/exf.c
===
RCS file: /cvs/src/usr.bin/vi/common/exf.c,v
retrieving revision 1.41
diff -u -p -r1.41 exf.c
--- common/exf.c6 Jan 2016 22:29:38 -   1.41
+++ common/exf.c8 Feb 2016 21:35:59 -
@@ -54,10 +54,10 @@ static int  file_spath(SCR *, FREF *, str
  * vi now remembers the last location in any file that it has ever edited,
  * not just the previously edited file.
  *
- * PUBLIC: FREF *file_add(SCR *, CHAR_T *);
+ * PUBLIC: FREF *file_add(SCR *, char *);
  */
 FREF *
-file_add(SCR *sp, CHAR_T *name)
+file_add(SCR *sp, char *name)
 {
GS *gp;
FREF *frp, *tfrp;
@@ -922,7 +922,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, 
case OLDFILE:
msgstr = LF_ISSET(FS_APPEND) ?
"%s: appended: %lu lines, %lu characters" :
-   "%s: %lu lines, %lu characters", NULL;
+   "%s: %lu lines, %lu characters";
len = snprintf(buf, sizeof(buf), msgstr, p, nlno, nch);
if (len >= sizeof(buf))
len = sizeof(buf) - 1;
Index: common/gs.h
===
RCS file: /cvs/src/usr.bin/vi/common/gs.h,v
retrieving revision 1.16
diff -u -p -r1.16 gs.h
--- common/gs.h 30 Jan 2016 21:23:50 -  1.16
+++ common/gs.h 8 Feb 2016 21:35:59 -
@@ -118,7 +118,7 @@ struct _gs {
(sp)->gp->cname[(unsigned char)(ch)].name : \
v_key_name((sp), (ch)))
struct {
-   CHAR_T   name[MAX_CHARACTER_COLUMNS + 1];
+   char name[MAX_CHARACTER_COLUMNS + 1];
u_int8_t len;
} cname[MAX_FAST_KEY + 1];  /* Fast lookup table. */
 
@@ -165,7 +165,7 @@ struct _gs {
/* Ex: screen adjustment routine. */
int (*scr_ex_

Re: rtadvd unicast

2016-02-08 Thread Alexander Bluhm
On Tue, Feb 09, 2016 at 12:23:51AM +0100, J??r??mie Courr??ges-Anglas wrote:
> 
> > rtadvd contains code to send unicast replies, RFC4861 mentions this
> > possibility (section 6.2.6) but I'm having a hard time thinking how it
> > could be useful.
> >
> > Since the sending part is commented out since it was introduced, I doubt
> > that anyone will miss it.  This removes pointless memory allocations.
> >
> > ok?

OK bluhm@

> 
> Updated patch:
> 
> Index: config.c
> ===
> RCS file: /cvs/src/usr.sbin/rtadvd/config.c,v
> retrieving revision 1.49
> diff -u -p -r1.49 config.c
> --- config.c  8 Feb 2016 23:19:00 -   1.49
> +++ config.c  8 Feb 2016 23:22:13 -
> @@ -111,7 +111,6 @@ getconfig(char *intface)
>   TAILQ_INIT(&tmp->rtinfos);
>   TAILQ_INIT(&tmp->rdnsss);
>   TAILQ_INIT(&tmp->dnssls);
> - SLIST_INIT(&tmp->soliciters);
>  
>   /* check if we are allowed to forward packets (if not determined) */
>   if (forwarding < 0) {
> Index: rtadvd.c
> ===
> RCS file: /cvs/src/usr.sbin/rtadvd/rtadvd.c,v
> retrieving revision 1.66
> diff -u -p -r1.66 rtadvd.c
> --- rtadvd.c  8 Feb 2016 23:19:00 -   1.66
> +++ rtadvd.c  8 Feb 2016 23:22:14 -
> @@ -690,18 +690,6 @@ rs_input(int len, struct nd_router_solic
>   {
>   long delay; /* must not be greater than 100 */
>   struct timeval interval, now, min_delay, tm_tmp, *rest;
> - struct soliciter *sol;
> -
> - /*
> -  * record sockaddr waiting for RA, if possible
> -  */
> - sol = malloc(sizeof(*sol));
> - if (sol) {
> - sol->addr = *from;
> - /*XXX RFC2553 need clarification on flowinfo */
> - sol->addr.sin6_flowinfo = 0;
> - SLIST_INSERT_HEAD(&ra->soliciters, sol, entry);
> - }
>  
>   /*
>* If there is already a waiting RS packet, don't
> @@ -1280,7 +1268,6 @@ ra_output(struct rainfo *rainfo)
>   int i;
>   struct cmsghdr *cm;
>   struct in6_pktinfo *pi;
> - struct soliciter *sol;
>  
>   if ((iflist[rainfo->ifindex]->ifm_flags & IFF_UP) == 0) {
>   log_debug("%s is not up, skip sending RA", rainfo->ifname);
> @@ -1321,25 +1308,6 @@ ra_output(struct rainfo *rainfo)
>   if (i < 0 || i != rainfo->ra_datalen)
>   if (i < 0)
>   log_warn("sendmsg on %s", rainfo->ifname);
> -
> - /*
> -  * unicast advertisements
> -  * XXX commented out.  reason: though spec does not forbit it, unicast
> -  * advert does not really help
> -  */
> - while (!SLIST_EMPTY(&rainfo->soliciters)) {
> - sol = SLIST_FIRST(&rainfo->soliciters);
> - SLIST_REMOVE_HEAD(&rainfo->soliciters, entry);
> -#if 0
> - sndmhdr.msg_name = (caddr_t)&sol->addr;
> - i = sendmsg(sock, &sndmhdr, 0);
> - if (i < 0 || i != rainfo->ra_datalen)
> - if (i < 0)
> - log_warn("unicast sendmsg on %s",
> - rainfo->ifname);
> -#endif
> - free(sol);
> - }
>  
>   /* update counter */
>   if (rainfo->initcounter < MAX_INITIAL_RTR_ADVERTISEMENTS)
> Index: rtadvd.h
> ===
> RCS file: /cvs/src/usr.sbin/rtadvd/rtadvd.h,v
> retrieving revision 1.20
> diff -u -p -r1.20 rtadvd.h
> --- rtadvd.h  8 Feb 2016 23:19:00 -   1.20
> +++ rtadvd.h  8 Feb 2016 23:22:14 -
> @@ -117,11 +117,6 @@ struct dnssl {
>   TAILQ_HEAD(dnssldomlist, dnssldom) dnssldoms;
>  };
>  
> -struct soliciter {
> - SLIST_ENTRY(soliciter) entry;
> - struct sockaddr_in6 addr;
> -};
> -
>  struct   rainfo {
>   /* pointer for list */
>   SLIST_ENTRY(rainfo) entry;
> @@ -170,9 +165,6 @@ structrainfo {
>   u_quad_t rainput;   /* number of RAs received */
>   u_quad_t rainconsistent; /* number of RAs inconsistent with ours */
>   u_quad_t rsinput;   /* number of RSs received */
> -
> - /* info about soliciter */
> - SLIST_HEAD(, soliciter) soliciters; /* recent solicitation source */
>  };
>  SLIST_HEAD(ralist, rainfo);
>  
> 
> 
> -- 
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: [patch] vi enable -pedantic

2016-02-08 Thread Jonathan Gray
I don't think we should enable -pedantic anywhere in the tree.  Different
versions of gcc are going to have different ideas of what pedantic is.

I'm not sold on the value of all these patches to nvi when it is possibly
hindering people who may be looking to add utf-8 support (via nvi2 or
otherwise).

On Tue, Feb 09, 2016 at 12:57:37AM +0100, Martijn van Duren wrote:
> And of course you find out way to late that format=flowed was still on...
> Here's a new diff.
> 
> Any OKs for this?
> 
> On 02/01/16 23:34, Martijn van Duren wrote:
> > Hello tech@,
> > 
> > This patch enables -pedantic and does the appropriate cleanup that comes 
> > with it. It's mostly a CHAR_T->char conversion, which should be quite 
> > harmless, but edge-cases can be missed.
> > 
> > I'd like to have multiple OKs for this one as well as testing on 
> > multiple architectures, just to be sure.
> > 
> > The B1LEN, SKIP_PAST_NEWLINE, and PRIu32 are to silence clang with 
> > -pedantic.
> > 
> > Build and tested on amd64 with gcc, egcc and clang.
> > 
> > This drops the places CHAR_t can be found from 224 to 93.
> > 
> > martijn@
> 
> Index: build/Makefile
> ===
> RCS file: /cvs/src/usr.bin/vi/build/Makefile,v
> retrieving revision 1.23
> diff -u -p -r1.23 Makefile
> --- build/Makefile6 Jan 2016 22:34:45 -   1.23
> +++ build/Makefile8 Feb 2016 21:35:59 -
> @@ -4,7 +4,7 @@
>  PROG=vi
>  
>  # Modern curses (ncurses)
> -CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../include
> +CFLAGS+=-pedantic -Werror -I${.CURDIR} -I${.CURDIR}/../include
>  LDADD+=-lcurses
>  DPADD+= ${LIBCURSES}
>  
> Index: cl/cl_term.c
> ===
> RCS file: /cvs/src/usr.bin/vi/cl/cl_term.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 cl_term.c
> --- cl/cl_term.c  6 Jan 2016 22:28:52 -   1.21
> +++ cl/cl_term.c  8 Feb 2016 21:35:59 -
> @@ -30,7 +30,7 @@
>  #include "../common/common.h"
>  #include "cl.h"
>  
> -static int cl_pfmap(SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t);
> +static int cl_pfmap(SCR *, seq_t, char *, size_t, char *, size_t);
>  
>  /*
>   * XXX
> @@ -170,10 +170,10 @@ cl_term_end(GS *gp)
>   * cl_fmap --
>   *   Map a function key.
>   *
> - * PUBLIC: int cl_fmap(SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t);
> + * PUBLIC: int cl_fmap(SCR *, seq_t, char *, size_t, char *, size_t);
>   */
>  int
> -cl_fmap(SCR *sp, seq_t stype, CHAR_T *from, size_t flen, CHAR_T *to,
> +cl_fmap(SCR *sp, seq_t stype, char *from, size_t flen, char *to,
>  size_t tlen)
>  {
>   /* Ignore until the screen is running, do the real work then. */
> @@ -190,7 +190,7 @@ cl_fmap(SCR *sp, seq_t stype, CHAR_T *fr
>   *   Map a function key (private version).
>   */
>  static int
> -cl_pfmap(SCR *sp, seq_t stype, CHAR_T *from, size_t flen, CHAR_T *to,
> +cl_pfmap(SCR *sp, seq_t stype, char *from, size_t flen, char *to,
>  size_t tlen)
>  {
>   size_t nlen;
> Index: common/args.h
> ===
> RCS file: /cvs/src/usr.bin/vi/common/args.h,v
> retrieving revision 1.3
> diff -u -p -r1.3 args.h
> --- common/args.h 29 Jan 2001 01:58:28 -  1.3
> +++ common/args.h 8 Feb 2016 21:35:59 -
> @@ -22,7 +22,7 @@
>   * is found.
>   */
>  typedef struct _args {
> - CHAR_T  *bp;/* Argument. */
> + char*bp;/* Argument. */
>   size_t   blen;  /* Buffer length. */
>   size_t   len;   /* Argument length. */
>  
> Index: common/exf.c
> ===
> RCS file: /cvs/src/usr.bin/vi/common/exf.c,v
> retrieving revision 1.41
> diff -u -p -r1.41 exf.c
> --- common/exf.c  6 Jan 2016 22:29:38 -   1.41
> +++ common/exf.c  8 Feb 2016 21:35:59 -
> @@ -54,10 +54,10 @@ static intfile_spath(SCR *, FREF *, str
>   * vi now remembers the last location in any file that it has ever edited,
>   * not just the previously edited file.
>   *
> - * PUBLIC: FREF *file_add(SCR *, CHAR_T *);
> + * PUBLIC: FREF *file_add(SCR *, char *);
>   */
>  FREF *
> -file_add(SCR *sp, CHAR_T *name)
> +file_add(SCR *sp, char *name)
>  {
>   GS *gp;
>   FREF *frp, *tfrp;
> @@ -922,7 +922,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, 
>   case OLDFILE:
>   msgstr = LF_ISSET(FS_APPEND) ?
>   "%s: appended: %lu lines, %lu characters" :
> - "%s: %lu lines, %lu characters", NULL;
> + "%s: %lu lines, %lu characters";
>   len = snprintf(buf, sizeof(buf), msgstr, p, nlno, nch);
>   if (len >= sizeof(buf))
>   len = sizeof(buf) - 1;
> Index: common/gs.h
> ===
> RCS file: /cvs/src/usr.bin/vi/common/gs.h,v
> retrieving revision 1.16
> diff -u -p -r1.16 gs.h
> --- common/gs.h

Re: multicast, ETOOMANYREFS and intro(2)

2016-02-08 Thread Jérémie Courrèges-Anglas
"Todd C. Miller"  writes:

> On Fri, 05 Feb 2016 17:17:30 +0100, Martin Pieuchot wrote:
>
>> > > We could also return ENOBUFS in this case instead.  That would
>> > > correspond to the errors described in ip(4) (sadly setsockopt(2) is not
>> > > really reflecting the code).
>> > >
>> > > Jérémie what other OSes report as errors for IP_ADD_MEMBERSHIP?  
>> > 
>> > I only looked at loonix-4.5-rc2 so far: ENOBUFS in this error case.
>> 
>> Then I think it's the way to go.
>
> Works for me.

Hmm, FreeBSD and NetBSD still return ETOOMANYREFS in such a situation.
But the only piece of software out there that seems to actively check
for ETOOMANYREFS is D-Bus.  Not relevant here since multicast isn't
involved. (https://bugs.freedesktop.org/show_bug.cgi?id=80163)

ok?

Index: sys/netinet/ip_output.c
===
RCS file: /cvs/src/sys/netinet/ip_output.c,v
retrieving revision 1.317
diff -u -p -r1.317 ip_output.c
--- sys/netinet/ip_output.c 21 Jan 2016 11:23:48 -  1.317
+++ sys/netinet/ip_output.c 5 Feb 2016 17:46:08 -
@@ -1496,7 +1496,7 @@ ip_setmoptions(int optname, struct ip_mo
}
}
if (nmships == NULL) {
-   error = ETOOMANYREFS;
+   error = ENOBUFS;
if_put(ifp);
break;
}


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: [patch] vi enable -pedantic

2016-02-08 Thread Michael McConville
Jonathan Gray wrote:
> I don't think we should enable -pedantic anywhere in the tree.
> Different versions of gcc are going to have different ideas of what
> pedantic is.

This was my reaction too. I like the approach of keeping few to no
warnings in default builds. It's easy to "env CFLAGS='-Wextra -pedantic'
make" when you're auditing.

> I'm not sold on the value of all these patches to nvi when it is
> possibly hindering people who may be looking to add utf-8 support (via
> nvi2 or otherwise).

I think that vi is enough of a mess to warrant this. Most of these
patches are getting accepted upstream, too. I'm no longer actively
upstreaming, but I think Martijn and Michael Reed are.



rtadvd: remove more dead code

2016-02-08 Thread Jérémie Courrèges-Anglas

- a few *cnt members of struct rainfo aren't used for anything
- the SIOCGIFPREFIX_IN6 ioctl has been deprecated since June 2002
- prefix_match() and in6a_site_allrouters are remnants from the
  Renumbering code (now in the Attic)

ok?

Index: config.c
===
RCS file: /cvs/src/usr.sbin/rtadvd/config.c,v
retrieving revision 1.50
diff -u -p -r1.50 config.c
--- config.c9 Feb 2016 00:39:13 -   1.50
+++ config.c9 Feb 2016 00:54:13 -
@@ -323,7 +323,6 @@ getconfig(char *intface)
if (tmp->pfxs == 0 && !agetflag("noifprefix"))
get_prefix(tmp);
 
-   tmp->rtinfocnt = 0;
for (i = -1; i < MAXRTINFO; i++) {
struct rtinfo *rti;
char entbuf[256];
@@ -391,10 +390,8 @@ getconfig(char *intface)
rti->lifetime = (uint32_t)val64;
 
TAILQ_INSERT_TAIL(&tmp->rtinfos, rti, entry);
-   tmp->rtinfocnt++;
}
 
-   tmp->rdnsscnt = 0;
for (i = -1; i < MAXRDNSS; ++i) {
struct rdnss *rds;
char entbuf[256];
@@ -417,7 +414,6 @@ getconfig(char *intface)
fatal("malloc");
 
TAILQ_INSERT_TAIL(&tmp->rdnsss, rds, entry);
-   tmp->rdnsscnt++;
 
rds->servercnt = val;
 
@@ -441,7 +437,6 @@ getconfig(char *intface)
}
}
 
-   tmp->dnsslcnt = 0;
for (i = -1; i < MAXDNSSL; ++i) {
struct dnssl *dsl;
char entbuf[256];
@@ -481,7 +476,6 @@ getconfig(char *intface)
}
 
TAILQ_INSERT_TAIL(&tmp->dnssls, dsl, entry);
-   tmp->dnsslcnt++;
 
makeentry(entbuf, sizeof(entbuf), i, "dnsslltime");
MAYHAVE(val, entbuf, (tmp->maxinterval * 3) / 2);
@@ -692,44 +686,11 @@ delete_prefix(struct rainfo *rai, struct
 static int
 init_prefix(struct in6_prefixreq *ipr)
 {
-#if 0
-   int s;
-
-   if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-   log_warn("socket");
-   exit(1);
-   }
-
-   if (ioctl(s, SIOCGIFPREFIX_IN6, (caddr_t)ipr) < 0) {
-   log_warn("ioctl:SIOCGIFFLAGS: failed for %s", ifr.ifr_name);
-
-   ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
-   ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME;
-   ipr->ipr_raf_onlink = 1;
-   ipr->ipr_raf_auto = 1;
-   /* omit other field initialization */
-   }
-   else if (ipr->ipr_origin < PR_ORIG_RR) {
-   u_char ntopbuf[INET6_ADDRSTRLEN];
-
-   log_warn("Added prefix(%s)'s origin %d is"
-   " lower than PR_ORIG_RR(router renumbering)."
-   " This should not happen if I am router",
-   inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr, ntopbuf,
-   sizeof(ntopbuf)), ipr->ipr_origin);
-   close(s);
-   return 1;
-   }
-
-   close(s);
-   return 0;
-#else
ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME;
ipr->ipr_raf_onlink = 1;
ipr->ipr_raf_auto = 1;
return 0;
-#endif
 }
 
 void
Index: rtadvd.c
===
RCS file: /cvs/src/usr.sbin/rtadvd/rtadvd.c,v
retrieving revision 1.68
diff -u -p -r1.68 rtadvd.c
--- rtadvd.c9 Feb 2016 00:40:00 -   1.68
+++ rtadvd.c9 Feb 2016 00:54:13 -
@@ -1009,30 +1009,6 @@ find_prefix(struct rainfo *rai, struct i
return(NULL);
 }
 
-/* check if p0/plen0 matches p1/plen1; return 1 if matches, otherwise 0. */
-int
-prefix_match(struct in6_addr *p0, int plen0,
-struct in6_addr *p1, int plen1)
-{
-   int bytelen, bitlen;
-   u_char bitmask;
-
-   if (plen0 < plen1)
-   return(0);
-   bytelen = plen1 / 8;
-   bitlen = plen1 % 8;
-   bitmask = 0xff << (8 - bitlen);
-   if (memcmp((void *)p0, (void *)p1, bytelen))
-   return(0);
-   if (bitlen == 0 ||
-   ((p0->s6_addr[bytelen] & bitmask) ==
-(p1->s6_addr[bytelen] & bitmask))) {
-   return(1);
-   }
-
-   return(0);
-}
-
 static int
 nd6_options(struct nd_opt_hdr *hdr, int limit,
union nd_opts *ndopts, u_int32_t optflags)
Index: rtadvd.h
===
RCS file: /cvs/src/usr.sbin/rtadvd/rtadvd.h,v
retrieving revision 1.21
diff -u -p -r1.21 rtadvd.h
--- rtadvd.h9 Feb 2016 00:39:13 -   1.21
+++ rtadvd.h9 Feb 2016 00:54:13 -
@@ -148,11 +148,8 @@ struct rainfo {
TAILQ_HEAD(prefixlist, prefix) prefixes; /* AdvPrefixList(link head) */
int pfxs;   /* number of prefixes */
TAILQ_HEAD(rtinfolist, rtinfo) rtinfos;
-   int rtinfocnt;
TAILQ_HEAD(rdnsslist, rdnss) rdnsss; /* advertised recur

OpenSMTPD and mask-source flag.

2016-02-08 Thread Peter Bisroev
Dear OpenSMTPD Developers!

I think there is a little "bug/feature" with respect to handling "mask-source"
parameter with "listen on" directive in smtpd.conf. The behavior makes perfect
sense from the perspective of documentation. Unfortunately it is not uniform
from the perspective of the client.

Basically, if the message is handled through smtp_accept() in smtp.c then
everything works as expected. If the message is enqueued from localhost (for
example through sendmail), the message is handled by smtp_enqueue() in smtp.c,
and at this point the behavior starts to get non-uniform. The local listener
is created upon the first invocation of smtp_enqeue(), and the listener->flags
are set to 0. Because there is no way to specify the flags for the "local"
listener, the behavior is not intuative if the client specified "mask-source"
option for the "listen on" loopback interface directive. I suspect that if
mask-source is on for lo0, the client would probably want the same behavior
for the messages submited through the local queue.

I think this situation can be handled in one of three ways. A new special
directive can be created to influence the creation of this listener, however,
this feels a little messy. Another approach, is to create support for
"listen on local" or similar, which makes everything a bit more uniform. And
the last approach could mimick what "listen on lo0" or any other loopback
device does and apply the same policy to the "local" listener. For example,
this can be implemented by searching through env->sc_listeners for loopback
listeners, and if any of them have F_MASK_SOURCE flag, apply it to the local
listener as well.

What are your thoughts? I am more than happy to provide the patch for any of
the above described scenarios assuming they would provide an adequate solution.

Thank you for your time!

Regards,
--peter



Re: [patch] vi enable -pedantic

2016-02-08 Thread Martijn van Duren
On 02/09/16 01:18, Jonathan Gray wrote:
> I don't think we should enable -pedantic anywhere in the tree.  Different
> versions of gcc are going to have different ideas of what pedantic is.

That's why I tested this on all the compilers at my direct disposal.
What about the changes in general, without enabling the flag in the Makefile?
> 
> I'm not sold on the value of all these patches to nvi when it is possibly
> hindering people who may be looking to add utf-8 support (via nvi2 or
> otherwise).

I've been looking into adding UTF-8 support myself and getting rid of CHAR_T
actually makes it easier to do so, since the the mb* family is based around
char * instead of unsigned char.
The nvi2 implementation for utf-8 is not the approach we want to follow, and
I'm not aware of any other nvi based implementation with utf-8 support.
> 
> On Tue, Feb 09, 2016 at 12:57:37AM +0100, Martijn van Duren wrote:
>> And of course you find out way to late that format=flowed was still on...
>> Here's a new diff.
>>
>> Any OKs for this?
>>
>> On 02/01/16 23:34, Martijn van Duren wrote:
>>> Hello tech@,
>>>
>>> This patch enables -pedantic and does the appropriate cleanup that comes 
>>> with it. It's mostly a CHAR_T->char conversion, which should be quite 
>>> harmless, but edge-cases can be missed.
>>>
>>> I'd like to have multiple OKs for this one as well as testing on 
>>> multiple architectures, just to be sure.
>>>
>>> The B1LEN, SKIP_PAST_NEWLINE, and PRIu32 are to silence clang with 
>>> -pedantic.
>>>
>>> Build and tested on amd64 with gcc, egcc and clang.
>>>
>>> This drops the places CHAR_t can be found from 224 to 93.
>>>
>>> martijn@
>>
>> Index: build/Makefile
>> ===
>> RCS file: /cvs/src/usr.bin/vi/build/Makefile,v
>> retrieving revision 1.23
>> diff -u -p -r1.23 Makefile
>> --- build/Makefile   6 Jan 2016 22:34:45 -   1.23
>> +++ build/Makefile   8 Feb 2016 21:35:59 -
>> @@ -4,7 +4,7 @@
>>  PROG=   vi
>>  
>>  # Modern curses (ncurses)
>> -CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../include
>> +CFLAGS+=-pedantic -Werror -I${.CURDIR} -I${.CURDIR}/../include
>>  LDADD+=-lcurses
>>  DPADD+= ${LIBCURSES}
>>  
>> Index: cl/cl_term.c
>> ===
>> RCS file: /cvs/src/usr.bin/vi/cl/cl_term.c,v
>> retrieving revision 1.21
>> diff -u -p -r1.21 cl_term.c
>> --- cl/cl_term.c 6 Jan 2016 22:28:52 -   1.21
>> +++ cl/cl_term.c 8 Feb 2016 21:35:59 -
>> @@ -30,7 +30,7 @@
>>  #include "../common/common.h"
>>  #include "cl.h"
>>  
>> -static int cl_pfmap(SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t);
>> +static int cl_pfmap(SCR *, seq_t, char *, size_t, char *, size_t);
>>  
>>  /*
>>   * XXX
>> @@ -170,10 +170,10 @@ cl_term_end(GS *gp)
>>   * cl_fmap --
>>   *  Map a function key.
>>   *
>> - * PUBLIC: int cl_fmap(SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t);
>> + * PUBLIC: int cl_fmap(SCR *, seq_t, char *, size_t, char *, size_t);
>>   */
>>  int
>> -cl_fmap(SCR *sp, seq_t stype, CHAR_T *from, size_t flen, CHAR_T *to,
>> +cl_fmap(SCR *sp, seq_t stype, char *from, size_t flen, char *to,
>>  size_t tlen)
>>  {
>>  /* Ignore until the screen is running, do the real work then. */
>> @@ -190,7 +190,7 @@ cl_fmap(SCR *sp, seq_t stype, CHAR_T *fr
>>   *  Map a function key (private version).
>>   */
>>  static int
>> -cl_pfmap(SCR *sp, seq_t stype, CHAR_T *from, size_t flen, CHAR_T *to,
>> +cl_pfmap(SCR *sp, seq_t stype, char *from, size_t flen, char *to,
>>  size_t tlen)
>>  {
>>  size_t nlen;
>> Index: common/args.h
>> ===
>> RCS file: /cvs/src/usr.bin/vi/common/args.h,v
>> retrieving revision 1.3
>> diff -u -p -r1.3 args.h
>> --- common/args.h29 Jan 2001 01:58:28 -  1.3
>> +++ common/args.h8 Feb 2016 21:35:59 -
>> @@ -22,7 +22,7 @@
>>   * is found.
>>   */
>>  typedef struct _args {
>> -CHAR_T  *bp;/* Argument. */
>> +char*bp;/* Argument. */
>>  size_t   blen;  /* Buffer length. */
>>  size_t   len;   /* Argument length. */
>>  
>> Index: common/exf.c
>> ===
>> RCS file: /cvs/src/usr.bin/vi/common/exf.c,v
>> retrieving revision 1.41
>> diff -u -p -r1.41 exf.c
>> --- common/exf.c 6 Jan 2016 22:29:38 -   1.41
>> +++ common/exf.c 8 Feb 2016 21:35:59 -
>> @@ -54,10 +54,10 @@ static int   file_spath(SCR *, FREF *, str
>>   * vi now remembers the last location in any file that it has ever edited,
>>   * not just the previously edited file.
>>   *
>> - * PUBLIC: FREF *file_add(SCR *, CHAR_T *);
>> + * PUBLIC: FREF *file_add(SCR *, char *);
>>   */
>>  FREF *
>> -file_add(SCR *sp, CHAR_T *name)
>> +file_add(SCR *sp, char *name)
>>  {
>>  GS *gp;
>>  FREF *frp, *tfrp;
>> @@ -922,7 +922,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, 
>

Re: OpenSMTPD and mask-source flag.

2016-02-08 Thread Gilles Chehade
On Mon, Feb 08, 2016 at 08:32:31PM -0500, Peter Bisroev wrote:
> Dear OpenSMTPD Developers!
> 

Dear Peter,


> I think there is a little "bug/feature" with respect to handling "mask-source"
> parameter with "listen on" directive in smtpd.conf. The behavior makes perfect
> sense from the perspective of documentation. Unfortunately it is not uniform
> from the perspective of the client.
>

You are right, the feature will apply to network connections only.


> Basically, if the message is handled through smtp_accept() in smtp.c then
> everything works as expected. If the message is enqueued from localhost (for
> example through sendmail), the message is handled by smtp_enqueue() in smtp.c,
> [...]
> option for the "listen on" loopback interface directive. I suspect that if
> mask-source is on for lo0, the client would probably want the same behavior
> for the messages submited through the local queue.
>

You are correct.


> I think this situation can be handled in one of three ways. A new special
> directive can be created to influence the creation of this listener, however,
> this feels a little messy. Another approach, is to create support for
> "listen on local" or similar, which makes everything a bit more uniform. And
> the last approach could mimick what "listen on lo0" or any other loopback
> device does and apply the same policy to the "local" listener. For example,
> this can be implemented by searching through env->sc_listeners for loopback
> listeners, and if any of them have F_MASK_SOURCE flag, apply it to the local
> listener as well.
> 
> What are your thoughts? I am more than happy to provide the patch for any of
> the above described scenarios assuming they would provide an adequate 
> solution.
> 

We have faced a similar issue with filters and my thoughts are that we need a
listen on socket of some kind, similar to your listen on local.

This has several benefits over "listen on local", both in ambiguity and it
new ways the ruleset can match sessions.

If you're interested to work on it, I'd be happy to discuss this with you
so you can come up with a diff :-)

-- 
Gilles Chehade

https://www.poolp.org  @poolpOrg



Re: vi.1: remove more predefined strings

2016-02-08 Thread Jason McIntyre
On Mon, Feb 08, 2016 at 01:28:40PM -0500, Michael Reed wrote:
> Done for the same reason as rev.  1.57[1].  I observed no diff in the
> generated output for terminals, but I'm unsure if these strings are
> wanted for prettier pdf/ps/html/... output.
> 
> Regards,
>   Michael Reed
> 
> [1]: 
> http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/vi/docs/USD.doc/vi.man/vi.1?rev=1.57&content-type=text/x-cvsweb-markup
> 

fixed, thanks.
jmc

> 
> Index: vi.1
> ===
> RCS file: /cvs/src/usr.bin/vi/docs/USD.doc/vi.man/vi.1,v
> retrieving revision 1.63
> diff -u -p -r1.63 vi.1
> --- vi.1  6 Jan 2016 22:41:53 -   1.63
> +++ vi.1  8 Feb 2016 18:20:05 -
> @@ -354,7 +354,7 @@ matches the beginning of the word.
>  .Sq \e>
>  matches the end of the word.
>  .It
> -.Sq \(a~
> +.Sq ~
>  matches the replacement part of the last
>  .Cm substitute
>  command.
> @@ -2059,9 +2059,9 @@ If this is the entire
>  pattern, the replacement part of the previous
>  .Cm substitute
>  command.
> -.It Sq \e\(sh
> +.It Sq \e#
>  Where
> -.Sq \(sh
> +.Sq #
>  is an integer from 1 to 9, the text matched by the #'th subexpression in
>  .Ar pattern .
>  .It Sq \eL
> @@ -2350,9 +2350,9 @@ Display lines in an unambiguous fashion.
>  Attempt to get an exclusive lock on any file being edited, read or written.
>  .It Cm magic Bq on
>  When turned off, all regular expression characters except for
> -.Sq \(ha
> +.Sq ^
>  and
> -.Sq \(Do
> +.Sq $
>  are treated as ordinary characters.
>  Preceding individual characters by
>  .Sq \e
>