Re: [PATCH] Add IOMMU support for Intel VT-d and AMD-Vi

2020-10-07 Thread Jordan Hargrave
Ok updated the new changes.

On Mon, Oct 05, 2020 at 09:54:02PM +0200, Mark Kettenis wrote:
> > Date: Thu, 17 Sep 2020 20:54:51 -0500
> > From: Jordan Hargrave 
> > Cc: ma...@peereboom.org, kette...@openbsd.org, tech@openbsd.org,
> > d...@openbsd.org, j...@openbsd.org
> > Content-Type: text/plain; charset=us-ascii
> > Content-Disposition: inline
> > 
> > Ok made more changes
> > 
> > > 
> > > Should be handled by that activate function as well.
> > >
> 
> So there are quite a few style issues.  I can point them out to you,
> or I could fix them after this is committed, which is probably more
> efficient.
> 
> Also, there seems to be lot of debug code left in here that should be
> removed or at least hidden before this gets committed.
> 
> > 
> > diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC
> > index 1d6397391..a69c72c26 100644
> > --- a/sys/arch/amd64/conf/GENERIC
> > +++ b/sys/arch/amd64/conf/GENERIC
> > @@ -45,6 +45,7 @@ acpibtn*  at acpi?
> >  acpicpu*   at acpi?
> >  acpicmos*  at acpi?
> >  acpidock*  at acpi?
> > +acpidmar0  at acpi?
> >  acpiec*at acpi?
> >  acpipci*   at acpi?
> >  acpiprt*   at acpi?
> > diff --git a/sys/arch/amd64/include/pci_machdep.h 
> > b/sys/arch/amd64/include/pci_machdep.h
> > index bc295cc22..ea09f1abc 100644
> > --- a/sys/arch/amd64/include/pci_machdep.h
> > +++ b/sys/arch/amd64/include/pci_machdep.h
> > @@ -91,7 +91,12 @@ void 
> > *pci_intr_establish_cpu(pci_chipset_tag_t, pci_intr_handle_t,
> > int, struct cpu_info *,
> > int (*)(void *), void *, const char *);
> >  void   pci_intr_disestablish(pci_chipset_tag_t, void *);
> > +#if NACPIDMAR > 0
> > +intpci_probe_device_hook(pci_chipset_tag_t,
> > +   struct pci_attach_args *);
> > +#else
> >  #definepci_probe_device_hook(c, a) (0)
> > +#endif
> 
> This is probably a bad idea.  You don't include "acpidmar.h" in this
> file, and doing so is probaly undesireable.  But that means the
> definition of the hook function depends on whether the file that
> includes this does that or not.
> 
> Better just unconditionally provide the prototype and use a #if
> NACPIDMAR > 0 in the implementation.
>

Ok changed to that method

> > +#include "acpidmar.h"
> > +#include "amd_iommu.h"
> > +
> > +//#define IOMMU_DEBUG
> 
> No C++-style comments please.  Make this an #undef or use /* */.
> 
> > +
> > +#ifdef IOMMU_DEBUG
> > +#define dprintf(x...) printf(x)
> > +#else
> > +#define dprintf(x...)
> > +#endif
> > +
> > +#ifdef DDB
> > +intacpidmar_ddb = 0;
> > +#endif
> > +
> > +intintel_iommu_gfx_mapped = 0;
> 
> Unused variable.
> 
> > +intforce_cm = 1;
> 
> Rename to "acpidmar_force_cm"?
> 
> > +
> > +void showahci(void *);
> 
> Unused prototype.
> 
> > +
> > +/* Page Table Entry per domain */
> > +struct iommu_softc;
> > +
> > +static inline int
> > +mksid(int b, int d, int f)
> > +{
> > +   return (b << 8) + (d << 3) + f;
> > +}
> > +
> > +static inline int
> > +sid_devfn(int sid)
> > +{
> > +   return sid & 0xff;
> > +}
> > +
> > +static inline int
> > +sid_bus(int sid)
> > +{
> > +   return (sid >> 8) & 0xff;
> > +}
> > +
> > +static inline int
> > +sid_dev(int sid)
> > +{
> > +   return (sid >> 3) & 0x1f;
> > +}
> > +
> > +static inline int
> > +sid_fun(int sid)
> > +{
> > +   return (sid >> 0) & 0x7;
> > +}
> > +
> > +/* Alias mapping */
> > +#define SID_INVALID 0x8000L
> > +static uint32_t sid_flag[65536];
> > +
> > +struct domain_dev {
> > +   int sid;
> > +   int sec;
> > +   int sub;
> > +   TAILQ_ENTRY(domain_dev) link;
> > +};
> > +
> > +struct domain {
> > +   struct iommu_softc  *iommu;
> > +   int did;
> > +   int gaw;
> > +   struct pte_entry*pte;
> > +   paddr_t ptep;
> > +   struct bus_dma_tag  dmat;
> > +   int flag;
> > +
> > +   struct mutexexlck;
> > +   charexname[32];
> > +   struct extent   *iovamap;
> > +   TAILQ_HEAD(,domain_dev) devices;
> > +   TAILQ_ENTRY(domain) link;
> > +};
> > +
> > +#define DOM_DEBUG 0x1
> > +#define DOM_NOMAP 0x2
> > +
> > +struct dmar_devlist {
> > +   int type;
> > +   int bus;
> > +   int ndp;
> > +   struct acpidmar_devpath *dp;
> > +   TAILQ_ENTRY(dmar_devlist)   link;
> > +};
> > +
> > +TAILQ_HEAD(devlist_head, dmar_devlist);
> > +
> > +struct ivhd_devlist {
> > +   int start_id;
> > +   int end_id;
> > +   int cfg;
> > +   TAILQ_ENTRY(ivhd_devlist)   link;
> > +};
> > +
> > +struct rmrr_softc {
> > +   TAILQ_ENTRY(rmrr_softc) link;
> > +   struct devlist_head devices;
> > +   int segment;
> > +   uint64_t

[PATCH] Fix a bug where GDB could not display symbols

2020-10-07 Thread Masato Asou
I refferd to the core of static linked in GDB.  However, the backtrace
command did not display the symbols correctly.

$ cat main.c
#include 

void
sub2(int argc, char *argv[])
{
int i;
for (int i = 0; i <= argc; i++)
argv[i][0] = '\0';
}

void
sub1(int argc, char *argv[])
{
sub2(argc, argv);
}

int
main(int argc, char *argv[])
{
sub1(argc, argv);
return (0);
}
$ cc -g -static main.c
$ ./a.out
Segmentation fault (core dumped)
$ /usr/bin/gdb a.out a.out.core
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-unknown-openbsd6.8"...
Core was generated by `a.out'.
Program terminated with signal 11, Segmentation fault.
#0  0x060eed558f45 in ?? ()
(gdb) bt
#0  0x060eed558f45 in ?? ()
#1  0x7f7e3480 in ?? ()
#2  0x060eed558f98 in ?? ()
#3  0x in ?? ()
(gdb) quit
$ 

The patch is below.
ok?

diff --git a/gnu/usr.bin/binutils/gdb/solib-svr4.c 
b/gnu/usr.bin/binutils/gdb/solib-svr4.c
index eebeddd..7428bda 100644
--- a/gnu/usr.bin/binutils/gdb/solib-svr4.c
+++ b/gnu/usr.bin/binutils/gdb/solib-svr4.c
@@ -619,7 +619,40 @@ svr4_current_sos (void)
   /* If we can't find the dynamic linker's base structure, this
 must not be a dynamically linked executable.  Hmm.  */
   if (! debug_base)
-   return 0;
+   {
+ if (exec_bfd != NULL &&
+ bfd_get_section_by_name (exec_bfd, ".interp") == NULL &&
+ (bfd_get_file_flags (exec_bfd) & DYNAMIC) != 0 &&
+ bfd_get_start_address (exec_bfd) != entry_point_address ())
+   {
+ /* this is relocatable static link.
+cf. svr4_relocate_main_executable() */
+ struct cleanup *old_chain;
+ struct section_offsets *new_offsets;
+ int i, changed;
+ CORE_ADDR displacement;
+
+ displacement = entry_point_address () - bfd_get_start_address 
(exec_bfd);
+ changed = 0;
+
+ new_offsets = xcalloc (symfile_objfile->num_sections,
+sizeof (struct section_offsets));
+ old_chain = make_cleanup (xfree, new_offsets);
+
+ for (i = 0; i < symfile_objfile->num_sections; i++)
+   {
+ if (displacement != ANOFFSET 
(symfile_objfile->section_offsets, i))
+   changed = 1;
+ new_offsets->offsets[i] = displacement;
+   }
+
+ if (changed)
+   objfile_relocate (symfile_objfile, new_offsets);
+
+ do_cleanups (old_chain);
+   }
+ return 0;
+   }
 }
 
   /* Walk the inferior's link map list, and build our list of
--
ASOU Masato



Re: timeout(9): add clock-based timeouts (attempt 2)

2020-10-07 Thread 内藤 祐一郎
Hi.

I'm looking forward to this patch is committed.
Because this patch solves my problem about CARP timeout.

IIJ, a company that I am working for, is using carp(4) on VMware ESXi hosts
for VPN and web gateway services.

One is master and the other is backup of carp(4).
Active host sometimes failover to backup when the ESXi host gets high cpu usage.
And also CPU ready of OpenBSD machine seems high average on ESXi monitor.

High CPU ready machine delays sending carp advertisement for 3 or 4 seconds.
It is enough to failover to backup.

In my investigation, OpenBSD machine does not always get CPU under high CPU 
ready condition.
Although it is needed for interrupt handler.
The delay of calling hardclock() causes tick count up delay.
One delay is small but will never be resolved.
So total delay can reach 3 or 4 seconds while tick counts up to 100.
The tickless patch can solve the delay.

I have tried to adapt in_carp.c to the tickless attempt 2.
Delay of carp advertisement reduced to about 2 seconds.


> 2020/09/09 4:00、Mark Kettenis のメール:
> The diff looks reasonable to me, but I'd like to discuss the path
> forward with some people during the hackathon next week.

Is there any discussion in the hackathon?

—
Yuichiro NAITO
naito.yuich...@gmail.com





diff: refactor MCLGETI() macro

2020-10-07 Thread Jan Klemkow
Hi,

The name of the macro MCLGETI obsolete.  It was made to use a network
interface pointer inside.  But, now it is just used to define a special
length and the interface pointer is discarded.

Thus, the following diff renames the macro to MCLGETL and removes the
dead parameter ifp.

OK?

Bye,
Jan

Index: share/man/man9/mbuf.9
===
RCS file: /cvs/src/share/man/man9/mbuf.9,v
retrieving revision 1.119
diff -u -p -r1.119 mbuf.9
--- share/man/man9/mbuf.9   8 Aug 2020 07:42:31 -   1.119
+++ share/man/man9/mbuf.9   7 Oct 2020 19:24:48 -
@@ -58,7 +58,7 @@
 .Nm m_devget ,
 .Nm m_apply ,
 .Nm MCLGET ,
-.Nm MCLGETI ,
+.Nm MCLGETL ,
 .Nm MEXTADD ,
 .Nm m_align ,
 .Nm M_READONLY ,
@@ -126,7 +126,7 @@
 "int (*func)(caddr_t, caddr_t, unsigned int)" "caddr_t fstate"
 .Fn MCLGET "struct mbuf *m" "int how"
 .Ft struct mbuf *
-.Fn MCLGETI "struct mbuf *m" "int how" "struct ifnet *ifp" "int len"
+.Fn MCLGETL "struct mbuf *m" "int how" "int len"
 .Fn MEXTADD "struct mbuf *m" "caddr_t buf" "u_int size" "int flags" \
 "void (*free)(caddr_t, u_int, void *)" "void *arg"
 .Ft void
@@ -721,7 +721,7 @@ See
 .Fn m_get
 for a description of
 .Fa how .
-.It Fn MCLGETI "struct mbuf *m" "int how" "struct ifnet *ifp" "int len"
+.It Fn MCLGETL "struct mbuf *m" "int how" "int len"
 If
 .Fa m
 is NULL, allocate it.
Index: sys/arch/octeon/dev/if_cnmac.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/if_cnmac.c,v
retrieving revision 1.79
diff -u -p -r1.79 if_cnmac.c
--- sys/arch/octeon/dev/if_cnmac.c  4 Sep 2020 15:18:05 -   1.79
+++ sys/arch/octeon/dev/if_cnmac.c  7 Oct 2020 19:27:08 -
@@ -1106,7 +1106,7 @@ cnmac_mbuf_alloc(int n)
paddr_t pktbuf;
 
while (n > 0) {
-   m = MCLGETI(NULL, M_NOWAIT, NULL,
+   m = MCLGETL(NULL, M_NOWAIT,
OCTEON_POOL_SIZE_PKT + CACHELINESIZE);
if (m == NULL || !ISSET(m->m_flags, M_EXT)) {
m_freem(m);
Index: sys/arch/octeon/dev/if_ogx.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/if_ogx.c,v
retrieving revision 1.2
diff -u -p -r1.2 if_ogx.c
--- sys/arch/octeon/dev/if_ogx.c9 Sep 2020 15:53:25 -   1.2
+++ sys/arch/octeon/dev/if_ogx.c7 Oct 2020 19:27:25 -
@@ -1147,7 +1147,7 @@ ogx_load_mbufs(struct ogx_softc *sc, uns
paddr_t pktbuf;
 
for ( ; n > 0; n--) {
-   m = MCLGETI(NULL, M_NOWAIT, NULL, MCLBYTES);
+   m = MCLGETL(NULL, M_NOWAIT, MCLBYTES);
if (m == NULL)
break;
 
Index: sys/arch/sparc64/dev/vnet.c
===
RCS file: /cvs/src/sys/arch/sparc64/dev/vnet.c,v
retrieving revision 1.62
diff -u -p -r1.62 vnet.c
--- sys/arch/sparc64/dev/vnet.c 10 Jul 2020 13:26:36 -  1.62
+++ sys/arch/sparc64/dev/vnet.c 7 Oct 2020 19:27:41 -
@@ -834,7 +834,7 @@ vnet_rx_vio_dring_data(struct vnet_softc
goto skip;
}
 
-   m = MCLGETI(NULL, M_DONTWAIT, NULL, desc.nbytes);
+   m = MCLGETL(NULL, M_DONTWAIT, desc.nbytes);
if (!m)
break;
m->m_len = m->m_pkthdr.len = desc.nbytes;
Index: sys/dev/fdt/if_dwge.c
===
RCS file: /cvs/src/sys/dev/fdt/if_dwge.c,v
retrieving revision 1.6
diff -u -p -r1.6 if_dwge.c
--- sys/dev/fdt/if_dwge.c   13 Sep 2020 01:54:05 -  1.6
+++ sys/dev/fdt/if_dwge.c   7 Oct 2020 19:28:00 -
@@ -1283,7 +1283,7 @@ dwge_alloc_mbuf(struct dwge_softc *sc, b
 {
struct mbuf *m = NULL;
 
-   m = MCLGETI(NULL, M_DONTWAIT, NULL, MCLBYTES);
+   m = MCLGETL(NULL, M_DONTWAIT, MCLBYTES);
if (!m)
return (NULL);
m->m_len = m->m_pkthdr.len = MCLBYTES;
Index: sys/dev/fdt/if_dwxe.c
===
RCS file: /cvs/src/sys/dev/fdt/if_dwxe.c,v
retrieving revision 1.17
diff -u -p -r1.17 if_dwxe.c
--- sys/dev/fdt/if_dwxe.c   10 Jul 2020 13:26:36 -  1.17
+++ sys/dev/fdt/if_dwxe.c   7 Oct 2020 19:28:28 -
@@ -1342,7 +1342,7 @@ dwxe_alloc_mbuf(struct dwxe_softc *sc, b
 {
struct mbuf *m = NULL;
 
-   m = MCLGETI(NULL, M_DONTWAIT, NULL, MCLBYTES);
+   m = MCLGETL(NULL, M_DONTWAIT, MCLBYTES);
if (!m)
return (NULL);
m->m_len = m->m_pkthdr.len = MCLBYTES;
Index: sys/dev/fdt/if_fec.c
===
RCS file: /cvs/src/sys/dev/fdt/if_fec.c,v
retrieving revision 1.10
diff -u -p -r1.10 if_fec.c
--- sys/dev/fdt/if_fec.c10 Jul 2020 13:26:36 -  1.10
+++ sys/dev/fdt/if_fec.c7 

Re: setitimer(2): ITIMER_REAL: simplify realitexpire()

2020-10-07 Thread Scott Cheloha
> On Oct 7, 2020, at 15:51, Klemens Nanni  wrote:
> 
> On Wed, Oct 07, 2020 at 03:34:36PM -0500, Scott Cheloha wrote:
>> kn@ wanted to clean it up a while ago but I wan't far enough along
>> with hi-res timeouts to change the code yet.
> That was not me.

I am thinking of this:

https://marc.info/?l=openbsd-tech=156367664207978=2



Re: setitimer(2): ITIMER_REAL: simplify realitexpire()

2020-10-07 Thread Klemens Nanni
On Wed, Oct 07, 2020 at 03:34:36PM -0500, Scott Cheloha wrote:
> kn@ wanted to clean it up a while ago but I wan't far enough along
> with hi-res timeouts to change the code yet.
That was not me.



setitimer(2): ITIMER_REAL: simplify realitexpire()

2020-10-07 Thread Scott Cheloha
Hi,

The code in realitexpire(), the ITIMER_REAL timeout callback, is
needlessly complicated.

kn@ wanted to clean it up a while ago but I wan't far enough along
with hi-res timeouts to change the code yet.

Hi-res timeouts are now imminent, and setitimer(2) will probably be
the first guinnea pig I use to demonstrate that they Actually Work.
This cleanup will make employing a hi-res timeout here in a later diff
a lot simpler.

So, the cleanup:

- No need to call getnanouptime(9) more than once.  timespecadd(3) is
  very fast, and it_interval is at least 1/hz seconds wide, so we expect
  to "catch up" to the uptime after a couple iterations at most.

  When we switch to a hi-res timeout this will be important.  We will
  need to switch to nanouptime(9), which is much more expensive than
  getnanouptime(9).

- The for-loop and indentation here is really peculiar.  Use a while-loop
  to increment it_value and pull the rest of the code out of the loop.

- Collapse intermediate assignments.  tstohz(9) cannot return 0 in
  this case as it_interval is non-zero, so the check for timo < 0 is
  pointless.  With that out of the way, all we want to do is round
  back up to 1 if (tstohz(9) - 1 == 0), which we can do with MAX().

I am leaving the PS_EXITING check in place.  I am *pretty* sure it is
superfluous: realitexpire() runs under the kernel lock, and _exit(2)
runs under the kernel lock, so we aren't racing _exit(2)... but I will
leave it in-place until I can confirm my suspicions with the right
people.

ok?

Index: kern_time.c
===
RCS file: /cvs/src/sys/kern/kern_time.c,v
retrieving revision 1.144
diff -u -p -r1.144 kern_time.c
--- kern_time.c 7 Oct 2020 17:53:44 -   1.144
+++ kern_time.c 7 Oct 2020 20:19:15 -
@@ -644,31 +644,25 @@ sys_setitimer(struct proc *p, void *v, r
 void
 realitexpire(void *arg)
 {
+   struct timespec cts, nts;
struct process *pr = arg;
struct itimerspec *tp = >ps_timer[ITIMER_REAL];
 
prsignal(pr, SIGALRM);
+
+   /* If it was a one-shot timer we're done. */
if (!timespecisset(>it_interval)) {
timespecclear(>it_value);
return;
}
-   for (;;) {
-   struct timespec cts, nts;
-   int timo;
 
+   /* Find the nearest future expiration point and reload the timer. */
+   getnanouptime();
+   while (timespeccmp(>it_value, , <=))
timespecadd(>it_value, >it_interval, >it_value);
-   getnanouptime();
-   if (timespeccmp(>it_value, , >)) {
-   nts = tp->it_value;
-   timespecsub(, , );
-   timo = tstohz() - 1;
-   if (timo <= 0)
-   timo = 1;
-   if ((pr->ps_flags & PS_EXITING) == 0)
-   timeout_add(>ps_realit_to, timo);
-   return;
-   }
-   }
+   timespecsub(>it_value, , );
+   if ((pr->ps_flags & PS_EXITING) == 0)
+   timeout_add(>ps_realit_to, MAX(1, tstohz() - 1));
 }
 
 /*



diff: remove dead code in a{rm,md}64/a{rm,md}/conf.c

2020-10-07 Thread Jan Klemkow
Hi,

the cdev_joy_init makro is just used in i386.

OK?

Bye,
Jan

Index: amd64/amd64/conf.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/conf.c,v
retrieving revision 1.71
diff -u -p -r1.71 conf.c
--- amd64/amd64/conf.c  6 Jul 2020 04:32:25 -   1.71
+++ amd64/amd64/conf.c  7 Oct 2020 13:10:57 -
@@ -75,13 +75,6 @@ struct bdevswbdevsw[] =
 };
 intnblkdev = nitems(bdevsw);
 
-/* open, close, read, ioctl */
-#define cdev_joy_init(c,n) { \
-   dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
-   (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
-   (dev_type_stop((*))) enodev, 0, seltrue, \
-   (dev_type_mmap((*))) enodev, 0, 0, seltrue_kqfilter }
-
 /* open, close, ioctl */
 #define cdev_ocis_init(c,n) { \
 dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
Index: arm64/arm64/conf.c
===
RCS file: /cvs/src/sys/arch/arm64/arm64/conf.c,v
retrieving revision 1.15
diff -u -p -r1.15 conf.c
--- arm64/arm64/conf.c  6 Jul 2020 04:32:25 -   1.15
+++ arm64/arm64/conf.c  7 Oct 2020 13:10:57 -
@@ -72,13 +72,6 @@ struct bdevswbdevsw[] =
 };
 intnblkdev = nitems(bdevsw);
 
-/* open, close, read, ioctl */
-#define cdev_joy_init(c,n) { \
-   dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
-   (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
-   (dev_type_stop((*))) enodev, 0, seltrue, \
-   (dev_type_mmap((*))) enodev, 0, 0, seltrue_kqfilter }
-
 /* open, close, ioctl, select -- XXX should be a generic device */
 #define cdev_ocis_init(c,n) { \
 dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \



Re: ls: match historic behavior listing empty directories

2020-10-07 Thread Klemens Nanni
On Sat, Oct 03, 2020 at 09:21:21AM -0600, Todd C. Miller wrote:
> This is adapted from FreeBSD revs 130236 and 130237 which have the
> following log message:
> 
> If we are asked to print the total number of blocks, do so even if we
> have no entries to print (either due to an empty directory or an
> error).  This makes the -l and -s options more consistent, like
> Solaris and (Debian) Linux.  To make this happen, tweak two
> optimizations on the second call to display():
> 
> - Don't skip display() altogether, even if list == NULL.
> - Don't skip the call to the printfn in display() if we
>   need to print the total.
> 
> I've verified that both historic AT ls and GNU ls behave this
> way.
OK kn



Re: ls: match historic behavior listing empty directories

2020-10-07 Thread Todd C . Miller
Anyone?

 - todd

> This is adapted from FreeBSD revs 130236 and 130237 which have the
> following log message:
>
> If we are asked to print the total number of blocks, do so even if we
> have no entries to print (either due to an empty directory or an
> error).  This makes the -l and -s options more consistent, like
> Solaris and (Debian) Linux.  To make this happen, tweak two
> optimizations on the second call to display():
>
> - Don't skip display() altogether, even if list == NULL.
> - Don't skip the call to the printfn in display() if we
>   need to print the total.
>
> I've verified that both historic AT ls and GNU ls behave this
> way.
>
>  - todd
>
> Index: bin/ls/ls.c
> ===
> RCS file: /cvs/src/bin/ls/ls.c,v
> retrieving revision 1.53
> diff -u -p -u -r1.53 ls.c
> --- bin/ls/ls.c   6 Jul 2020 00:55:05 -   1.53
> +++ bin/ls/ls.c   3 Oct 2020 15:18:01 -
> @@ -355,7 +355,13 @@ traverse(int argc, char *argv[], int opt
>   fts_open(argv, options, f_nosort ? NULL : mastercmp)) == NULL)
>   err(1, NULL);
>  
> - display(NULL, fts_children(ftsp, 0));
> + /*
> +  * We ignore errors from fts_children here since they will be
> +  * replicated and signalled on the next call to fts_read() below.
> +  */
> + chp = fts_children(ftsp, 0);
> + if (chp != NULL)
> + display(NULL, chp);
>   if (f_listdir)
>   return;
>  
> @@ -438,16 +444,6 @@ display(FTSENT *p, FTSENT *list)
>   char buf[21];   /* 64 bits == 20 digits */
>   char *flags = NULL;
>  
> - /*
> -  * If list is NULL there are two possibilities: that the parent
> -  * directory p has no children, or that fts_children() returned an
> -  * error.  We ignore the error case since it will be replicated
> -  * on the next call to fts_read() on the post-order visit to the
> -  * directory p, and will be signalled in traverse().
> -  */
> - if (list == NULL)
> - return;
> -
>   needstats = f_inode || f_longform || f_size;
>   flen = 0;
>   btotal = maxblock = maxinode = maxlen = maxnlink = 0;
> @@ -542,7 +538,13 @@ display(FTSENT *p, FTSENT *list)
>   ++entries;
>   }
>  
> - if (!entries)
> + /*
> +  * If there are no entries to display, we normally stop right
> +  * here.  However, we must continue if we have to display the
> +  * total block count.  In this case, we display the total only
> +  * on the second (p != NULL) pass.
> +  */
> + if (!entries && (!(f_longform || f_size) || p == NULL))
>   return;
>  
>   d.list = list;
> Index: bin/ls/print.c
> ===
> RCS file: /cvs/src/bin/ls/print.c,v
> retrieving revision 1.38
> diff -u -p -u -r1.38 print.c
> --- bin/ls/print.c5 Feb 2019 02:17:32 -   1.38
> +++ bin/ls/print.c3 Oct 2020 15:13:14 -
> @@ -87,7 +87,8 @@ printlong(DISPLAY *dp)
>   NAMES *np;
>   char buf[20];
>  
> - if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
> + if ((dp->list == NULL || dp->list->fts_level != FTS_ROOTLEVEL) &&
> + (f_longform || f_size))
>   (void)printf("total %llu\n", howmany(dp->btotal, blocksize));
>  
>   for (p = dp->list; p; p = p->fts_link) {
> @@ -198,7 +199,8 @@ printcol(DISPLAY *dp)
>   if (num % numcols)
>   ++numrows;
>  
> - if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
> + if ((dp->list == NULL || dp->list->fts_level != FTS_ROOTLEVEL) &&
> + (f_longform || f_size))
>   (void)printf("total %llu\n", howmany(dp->btotal, blocksize));
>   for (row = 0; row < numrows; ++row) {
>   for (base = row, col = 0;;) {
> @@ -271,7 +273,8 @@ printacol(DISPLAY *dp)
>   if ( (colwidth = compute_columns(dp, )) == 0)
>   return;
>  
> - if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
> + if ((dp->list == NULL || dp->list->fts_level != FTS_ROOTLEVEL) &&
> + (f_longform || f_size))
>   (void)printf("total %llu\n", howmany(dp->btotal, blocksize));
>   col = 0;
>   for (p = dp->list; p; p = p->fts_link) {
>



libexec/security: don't prune mount points

2020-10-07 Thread Todd C . Miller
The recent changes to the daily security script will result in it
not traversing file systems where the parent mount point is mounted
with options nodev,nosuid but the child is mounted with setuid
enabled.

For example, if /var/www is a separate file system that allows
setuid but /var is mounted with nodev and nosuid, security will not
traverse /var/www.

198976b83d9da70f.e /var ffs rw,nodev,nosuid 1 2
198976b83d9da70f.f /var/www ffs rw 1 2

The simplest solution is to pass the list of file systems to traverse
to File::Find and use the equivalent of find's -xdev option.

Anyone want to double-check my logic? :-)

 - todd

Index: libexec/security/security
===
RCS file: /cvs/src/libexec/security/security,v
retrieving revision 1.40
diff -u -p -u -r1.40 security
--- libexec/security/security   17 Sep 2020 06:51:06 -  1.40
+++ libexec/security/security   7 Oct 2020 15:34:14 -
@@ -530,6 +530,7 @@ sub strmode {
 
 sub find_special_files {
my %skip;
+   my @fs;
 
%skip = map { $_ => 1 } split ' ', $ENV{SUIDSKIP}
if $ENV{SUIDSKIP};
@@ -541,11 +542,11 @@ sub find_special_files {
and return;
while (<$fh>) {
my ($path, $opt) = /\son\s+(.*?)\s+type\s+\w+(.*)/;
-   $skip{$path} = 1 if $path &&
-   ($opt !~ /local/ ||
-($opt =~ /nodev/ && $opt =~ /nosuid/));
+   push(@fs, $path) if $path && $opt =~ /local/ &&
+   !($opt =~ /nodev/ && $opt =~ /nosuid/);
}
close_or_nag $fh, "mount" or return;
+   return unless @fs;
 
my $setuid_files = {};
my $device_files = {};
@@ -554,14 +555,19 @@ sub find_special_files {
File::Find::find({no_chdir => 1, wanted => sub {
 
if ($skip{$_}) {
-   no warnings 'once';
$File::Find::prune = 1;
return;
}
 
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
$atime, $mtime, $ctime, $blksize, $blocks) = lstat;
-   unless (defined $dev) {
+   if (defined $dev) {
+   no warnings 'once';
+   if ($dev != $File::Find::topdev) {
+   $File::Find::prune = 1;
+   return;
+   }
+   } else {
nag !$!{ENOENT}, "stat: $_: $!";
return;
}
@@ -592,7 +598,7 @@ sub find_special_files {
$file->{size}= $size;
@$file{qw(wday mon day time year)} =
split ' ', localtime $mtime;
-   }}, '/');
+   }}, @fs);
 
nag $uudecode_is_setuid, 'Uudecode is setuid.';
return $setuid_files, $device_files;



Re: amap: KASSERT()s and local variables

2020-10-07 Thread Martin Pieuchot
On 01/10/20(Thu) 14:18, Martin Pieuchot wrote:
> Use more KASSERT()s instead of the "if (x) panic()" idiom for sanity
> checks and add a couple of local variables to reduce the difference
> with NetBSD and help for upcoming locking.

deraadt@ mentioned that KASSERT()s are not effective in RAMDISK kernels.

So the revisited diff below only converts checks that are redundant with
NULL dereferences.

ok?

Index: uvm/uvm_amap.c
===
RCS file: /cvs/src/sys/uvm/uvm_amap.c,v
retrieving revision 1.84
diff -u -p -r1.84 uvm_amap.c
--- uvm/uvm_amap.c  25 Sep 2020 08:04:48 -  1.84
+++ uvm/uvm_amap.c  7 Oct 2020 14:40:53 -
@@ -669,9 +669,7 @@ ReStart:
pg = anon->an_page;
 
/* page must be resident since parent is wired */
-   if (pg == NULL)
-   panic("amap_cow_now: non-resident wired page"
-   " in anon %p", anon);
+   KASSERT(pg != NULL);
 
/*
 * if the anon ref count is one, we are safe (the child
@@ -740,6 +738,7 @@ ReStart:
 void
 amap_splitref(struct vm_aref *origref, struct vm_aref *splitref, vaddr_t 
offset)
 {
+   struct vm_amap *amap = origref->ar_amap;
int leftslots;
 
AMAP_B2SLOT(leftslots, offset);
@@ -747,17 +746,18 @@ amap_splitref(struct vm_aref *origref, s
panic("amap_splitref: split at zero offset");
 
/* now: we have a valid am_mapped array. */
-   if (origref->ar_amap->am_nslot - origref->ar_pageoff - leftslots <= 0)
+   if (amap->am_nslot - origref->ar_pageoff - leftslots <= 0)
panic("amap_splitref: map size check failed");
 
 #ifdef UVM_AMAP_PPREF
-/* establish ppref before we add a duplicate reference to the amap */
-   if (origref->ar_amap->am_ppref == NULL)
-   amap_pp_establish(origref->ar_amap);
+/* Establish ppref before we add a duplicate reference to the amap. */
+   if (amap->am_ppref == NULL)
+   amap_pp_establish(amap);
 #endif
 
-   splitref->ar_amap = origref->ar_amap;
-   splitref->ar_amap->am_ref++;/* not a share reference */
+   /* Note: not a share reference. */
+   amap->am_ref++;
+   splitref->ar_amap = amap;
splitref->ar_pageoff = origref->ar_pageoff + leftslots;
 }
 
@@ -1104,12 +1104,11 @@ amap_add(struct vm_aref *aref, vaddr_t o
 
slot = UVM_AMAP_SLOTIDX(slot);
if (replace) {
-   if (chunk->ac_anon[slot] == NULL)
-   panic("amap_add: replacing null anon");
-   if (chunk->ac_anon[slot]->an_page != NULL &&
-   (amap->am_flags & AMAP_SHARED) != 0) {
-   pmap_page_protect(chunk->ac_anon[slot]->an_page,
-   PROT_NONE);
+   struct vm_anon *oanon  = chunk->ac_anon[slot];
+
+   KASSERT(oanon != NULL);
+   if (oanon->an_page && (amap->am_flags & AMAP_SHARED) != 0) {
+   pmap_page_protect(oanon->an_page, PROT_NONE);
/*
 * XXX: suppose page is supposed to be wired somewhere?
 */
@@ -1138,14 +1137,13 @@ amap_unadd(struct vm_aref *aref, vaddr_t
 
AMAP_B2SLOT(slot, offset);
slot += aref->ar_pageoff;
-   KASSERT(slot < amap->am_nslot);
+   if (chunk->ac_anon[slot] == NULL)
+   panic("amap_unadd: nothing there");
chunk = amap_chunk_get(amap, slot, 0, PR_NOWAIT);
-   if (chunk == NULL)
-   panic("amap_unadd: chunk for slot %d not present", slot);
+   KASSERT(chunk != NULL);
 
slot = UVM_AMAP_SLOTIDX(slot);
-   if (chunk->ac_anon[slot] == NULL)
-   panic("amap_unadd: nothing there");
+   KASSERT(chunk->ac_anon[slot] != NULL);
 
chunk->ac_anon[slot] = NULL;
chunk->ac_usedmap &= ~(1 << slot);



kqueue_scan() refactoring

2020-10-07 Thread Martin Pieuchot
The diff below has already been presented in August [0].  It is the
first step at splitting the kqueue refactoring required for the poll
and select rewrite.

This first iteration introduces the new API with only minimal changes.
The only change in behavior is that the markers' `kn_filter' and
`kn_status' are now initialized only once.

Ok?

[0] https://marc.info/?l=openbsd-tech=159740120705383=2

Index: kern/kern_event.c
===
RCS file: /cvs/src/sys/kern/kern_event.c,v
retrieving revision 1.142
diff -u -p -r1.142 kern_event.c
--- kern/kern_event.c   12 Aug 2020 13:49:24 -  1.142
+++ kern/kern_event.c   7 Oct 2020 13:42:36 -
@@ -64,9 +64,6 @@ void  KQREF(struct kqueue *);
 void   KQRELE(struct kqueue *);
 
 intkqueue_sleep(struct kqueue *, struct timespec *);
-intkqueue_scan(struct kqueue *kq, int maxevents,
-   struct kevent *ulistp, struct timespec *timeout,
-   struct kevent *kev, struct proc *p, int *retval);
 
 intkqueue_read(struct file *, struct uio *, int);
 intkqueue_write(struct file *, struct uio *, int);
@@ -554,6 +551,7 @@ out:
 int
 sys_kevent(struct proc *p, void *v, register_t *retval)
 {
+   struct kqueue_scan_state scan;
struct filedesc* fdp = p->p_fd;
struct sys_kevent_args /* {
syscallarg(int) fd;
@@ -635,11 +633,12 @@ sys_kevent(struct proc *p, void *v, regi
goto done;
}
 
-   KQREF(kq);
+   kqueue_scan_setup(, kq);
FRELE(fp, p);
-   error = kqueue_scan(kq, SCARG(uap, nevents), SCARG(uap, eventlist),
+   error = kqueue_scan(, SCARG(uap, nevents), SCARG(uap, eventlist),
tsp, kev, p, );
-   KQRELE(kq);
+   kqueue_scan_finish();
+
*retval = n;
return (error);
 
@@ -895,11 +894,13 @@ kqueue_sleep(struct kqueue *kq, struct t
 }
 
 int
-kqueue_scan(struct kqueue *kq, int maxevents, struct kevent *ulistp,
-struct timespec *tsp, struct kevent *kev, struct proc *p, int *retval)
+kqueue_scan(struct kqueue_scan_state *scan, int maxevents,
+struct kevent *ulistp, struct timespec *tsp, struct kevent *kev,
+struct proc *p, int *retval)
 {
+   struct kqueue *kq = scan->kqs_kq;
struct kevent *kevp;
-   struct knote mend, mstart, *kn;
+   struct knote *kn;
int s, count, nkev, error = 0;
 
nkev = 0;
@@ -909,9 +910,6 @@ kqueue_scan(struct kqueue *kq, int maxev
if (count == 0)
goto done;
 
-   memset(, 0, sizeof(mstart));
-   memset(, 0, sizeof(mend));
-
 retry:
KASSERT(count == maxevents);
KASSERT(nkev == 0);
@@ -939,18 +937,16 @@ retry:
goto done;
}
 
-   mstart.kn_filter = EVFILT_MARKER;
-   mstart.kn_status = KN_PROCESSING;
-   TAILQ_INSERT_HEAD(>kq_head, , kn_tqe);
-   mend.kn_filter = EVFILT_MARKER;
-   mend.kn_status = KN_PROCESSING;
-   TAILQ_INSERT_TAIL(>kq_head, , kn_tqe);
+   TAILQ_INSERT_TAIL(>kq_head, >kqs_end, kn_tqe);
+   TAILQ_INSERT_HEAD(>kq_head, >kqs_start, kn_tqe);
while (count) {
-   kn = TAILQ_NEXT(, kn_tqe);
+   kn = TAILQ_NEXT(>kqs_start, kn_tqe);
if (kn->kn_filter == EVFILT_MARKER) {
-   if (kn == ) {
-   TAILQ_REMOVE(>kq_head, , kn_tqe);
-   TAILQ_REMOVE(>kq_head, , kn_tqe);
+   if (kn == >kqs_end) {
+   TAILQ_REMOVE(>kq_head, >kqs_end,
+   kn_tqe);
+   TAILQ_REMOVE(>kq_head, >kqs_start,
+   kn_tqe);
splx(s);
if (count == maxevents)
goto retry;
@@ -958,8 +954,9 @@ retry:
}
 
/* Move start marker past another thread's marker. */
-   TAILQ_REMOVE(>kq_head, , kn_tqe);
-   TAILQ_INSERT_AFTER(>kq_head, kn, , kn_tqe);
+   TAILQ_REMOVE(>kq_head, >kqs_start, kn_tqe);
+   TAILQ_INSERT_AFTER(>kq_head, kn, >kqs_start,
+   kn_tqe);
continue;
}
 
@@ -1029,8 +1026,8 @@ retry:
break;
}
}
-   TAILQ_REMOVE(>kq_head, , kn_tqe);
-   TAILQ_REMOVE(>kq_head, , kn_tqe);
+   TAILQ_REMOVE(>kq_head, >kqs_end, kn_tqe);
+   TAILQ_REMOVE(>kq_head, >kqs_start, kn_tqe);
splx(s);
 done:
if (nkev != 0) {
@@ -1044,6 +1041,33 @@ done:
*retval = maxevents - count;
return (error);
 }
+
+void
+kqueue_scan_setup(struct kqueue_scan_state *scan, struct kqueue *kq)
+{
+   memset(scan, 0, sizeof(*scan));
+
+   KQREF(kq);
+   scan->kqs_kq = kq;
+   

Re: diff: remove dead code in a{rm,md}64/a{rm,md}/conf.c

2020-10-07 Thread Mark Kettenis
> Date: Wed, 7 Oct 2020 15:14:32 +0200
> From: Jan Klemkow 
> 
> Hi,
> 
> the cdev_joy_init makro is just used in i386.
> 
> OK?

ok kettenis@

> Index: amd64/amd64/conf.c
> ===
> RCS file: /cvs/src/sys/arch/amd64/amd64/conf.c,v
> retrieving revision 1.71
> diff -u -p -r1.71 conf.c
> --- amd64/amd64/conf.c6 Jul 2020 04:32:25 -   1.71
> +++ amd64/amd64/conf.c7 Oct 2020 13:10:57 -
> @@ -75,13 +75,6 @@ struct bdevsw  bdevsw[] =
>  };
>  int  nblkdev = nitems(bdevsw);
>  
> -/* open, close, read, ioctl */
> -#define cdev_joy_init(c,n) { \
> - dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
> - (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
> - (dev_type_stop((*))) enodev, 0, seltrue, \
> - (dev_type_mmap((*))) enodev, 0, 0, seltrue_kqfilter }
> -
>  /* open, close, ioctl */
>  #define cdev_ocis_init(c,n) { \
>  dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) 
> enodev, \
> Index: arm64/arm64/conf.c
> ===
> RCS file: /cvs/src/sys/arch/arm64/arm64/conf.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 conf.c
> --- arm64/arm64/conf.c6 Jul 2020 04:32:25 -   1.15
> +++ arm64/arm64/conf.c7 Oct 2020 13:10:57 -
> @@ -72,13 +72,6 @@ struct bdevsw  bdevsw[] =
>  };
>  int  nblkdev = nitems(bdevsw);
>  
> -/* open, close, read, ioctl */
> -#define cdev_joy_init(c,n) { \
> - dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
> - (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
> - (dev_type_stop((*))) enodev, 0, seltrue, \
> - (dev_type_mmap((*))) enodev, 0, 0, seltrue_kqfilter }
> -
>  /* open, close, ioctl, select -- XXX should be a generic device */
>  #define cdev_ocis_init(c,n) { \
>  dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) 
> enodev, \
> 
> 



uvm/uvm_map.h header cleanup

2020-10-07 Thread Martin Pieuchot
Now that all architectures have been fixed, it's time to remove this...

ok?

Index: uvm/uvm_map.h
===
RCS file: /cvs/src/sys/uvm/uvm_map.h,v
retrieving revision 1.67
diff -u -p -r1.67 uvm_map.h
--- uvm/uvm_map.h   18 Dec 2019 13:33:29 -  1.67
+++ uvm/uvm_map.h   17 Sep 2020 12:25:12 -
@@ -409,13 +409,6 @@ intuvm_map_fill_vmmap(struct vm_map *,
  *
  */
 
-/*
- * XXX: clean up later
- * Half the kernel seems to depend on them being included here.
- */
-#include 
-#include   /* for panic() */
-
 boolean_t  vm_map_lock_try_ln(struct vm_map*, char*, int);
 void   vm_map_lock_ln(struct vm_map*, char*, int);
 void   vm_map_lock_read_ln(struct vm_map*, char*, int);



Re: ifconfig: consistent display of P2P link

2020-10-07 Thread Denis Fondras
On Wed, Oct 07, 2020 at 01:01:29PM +0200, Claudio Jeker wrote:
> On Wed, Oct 07, 2020 at 12:27:04PM +0200, Denis Fondras wrote:
> > All tunnels & point-to-point addresses are separated by "->" but inet.
> > 
> > Before :
> > gre0: flags=8051 mtu 1476
> > index 6 priority 0 llprio 6
> > encap: vnetid none txprio payload rxprio packet
> > groups: gre
> > tunnel: inet 192.0.2.1 -> 198.51.100.1 ttl 64 nodf ecn
> > inet 172.16.0.1 --> 172.16.0.2 netmask 0x
> > inet6 fe80::c23f:d5ff:fe63:ffe3%gre0 ->  prefixlen 64 scopeid 0x6
> > inet6 2001:db8::1 -> 2001:db8::2 prefixlen 128
> > 
> > After :
> > gre0: flags=8051 mtu 1476
> > index 6 priority 0 llprio 6
> > encap: vnetid none txprio payload rxprio packet
> > groups: gre
> > tunnel: inet 192.0.2.1 -> 198.51.100.1 ttl 64 nodf ecn
> > inet 172.16.0.1 -> 172.16.0.2 netmask 0x
> > inet6 fe80::c23f:d5ff:fe63:ffe3%gre0 ->  prefixlen 64 scopeid 0x6
> > inet6 2001:db8::1 -> 2001:db8::2 prefixlen 128
> > 
> > OK ?
> 
> Isn't it the other way around, that originally --> was used but then IPv6
> came and introduced -> which was copied around?
> 
> I like --> a bit better since it stands a bit more out.
> 

I am totally fine with going for "-->"


Index: ifconfig.c
===
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.426
diff -u -p -r1.426 ifconfig.c
--- ifconfig.c  15 Sep 2020 15:23:11 -  1.426
+++ ifconfig.c  7 Oct 2020 11:54:12 -
@@ -3219,7 +3219,7 @@ print_tunnel(const struct if_laddrreq *r
0, 0, niflag) != 0)
strlcpy(pdstaddr, "", sizeof(pdstaddr));
 
-   printf(" -> %s", pdstaddr);
+   printf(" --> %s", pdstaddr);
 
switch (req->dstaddr.ss_family) {
case AF_INET:
@@ -3635,7 +3635,7 @@ in6_alias(struct in6_ifreq *creq)
if (getnameinfo((struct sockaddr *)sin6, sin6->sin6_len,
hbuf, sizeof(hbuf), NULL, 0, niflag) != 0)
strlcpy(hbuf, "", sizeof hbuf);
-   printf(" -> %s", hbuf);
+   printf(" --> %s", hbuf);
}
 
(void) memset(, 0, sizeof(ifr6));



Re: ifconfig: consistent display of P2P link

2020-10-07 Thread Claudio Jeker
On Wed, Oct 07, 2020 at 12:27:04PM +0200, Denis Fondras wrote:
> All tunnels & point-to-point addresses are separated by "->" but inet.
> 
> Before :
> gre0: flags=8051 mtu 1476
> index 6 priority 0 llprio 6
>   encap: vnetid none txprio payload rxprio packet
>   groups: gre
>   tunnel: inet 192.0.2.1 -> 198.51.100.1 ttl 64 nodf ecn
>   inet 172.16.0.1 --> 172.16.0.2 netmask 0x
>   inet6 fe80::c23f:d5ff:fe63:ffe3%gre0 ->  prefixlen 64 scopeid 0x6
>   inet6 2001:db8::1 -> 2001:db8::2 prefixlen 128
> 
> After :
> gre0: flags=8051 mtu 1476
> index 6 priority 0 llprio 6
>   encap: vnetid none txprio payload rxprio packet
>   groups: gre
>   tunnel: inet 192.0.2.1 -> 198.51.100.1 ttl 64 nodf ecn
>   inet 172.16.0.1 -> 172.16.0.2 netmask 0x
>   inet6 fe80::c23f:d5ff:fe63:ffe3%gre0 ->  prefixlen 64 scopeid 0x6
>   inet6 2001:db8::1 -> 2001:db8::2 prefixlen 128
> 
> OK ?

Isn't it the other way around, that originally --> was used but then IPv6
came and introduced -> which was copied around?

I like --> a bit better since it stands a bit more out.

E.g.
gre0: flags=8051 mtu 1476
index 6 priority 0 llprio 6
encap: vnetid none txprio payload rxprio packet
groups: gre
tunnel: inet 192.0.2.1 --> 198.51.100.1 ttl 64 nodf ecn
inet 172.16.0.1 --> 172.16.0.2 netmask 0x
inet6 fe80::c23f:d5ff:fe63:ffe3%gre0 -->  prefixlen 64 scopeid 0x6
inet6 2001:db8::1 --> 2001:db8::2 prefixlen 128
 
> Denis
> 
> Index: ifconfig.c
> ===
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
> retrieving revision 1.426
> diff -u -p -r1.426 ifconfig.c
> --- ifconfig.c15 Sep 2020 15:23:11 -  1.426
> +++ ifconfig.c17 Sep 2020 14:41:34 -
> @@ -3552,7 +3552,7 @@ in_status(int force)
>   }
>   (void) strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
>   sin = (struct sockaddr_in *)_dstaddr;
> - printf(" --> %s", inet_ntoa(sin->sin_addr));
> + printf(" -> %s", inet_ntoa(sin->sin_addr));
>   }
>   printf(" netmask 0x%x", ntohl(netmask.sin_addr.s_addr));
>   if (flags & IFF_BROADCAST) {
> 

-- 
:wq Claudio



ifconfig: consistent display of P2P link

2020-10-07 Thread Denis Fondras
All tunnels & point-to-point addresses are separated by "->" but inet.

Before :
gre0: flags=8051 mtu 1476
index 6 priority 0 llprio 6
encap: vnetid none txprio payload rxprio packet
groups: gre
tunnel: inet 192.0.2.1 -> 198.51.100.1 ttl 64 nodf ecn
inet 172.16.0.1 --> 172.16.0.2 netmask 0x
inet6 fe80::c23f:d5ff:fe63:ffe3%gre0 ->  prefixlen 64 scopeid 0x6
inet6 2001:db8::1 -> 2001:db8::2 prefixlen 128

After :
gre0: flags=8051 mtu 1476
index 6 priority 0 llprio 6
encap: vnetid none txprio payload rxprio packet
groups: gre
tunnel: inet 192.0.2.1 -> 198.51.100.1 ttl 64 nodf ecn
inet 172.16.0.1 -> 172.16.0.2 netmask 0x
inet6 fe80::c23f:d5ff:fe63:ffe3%gre0 ->  prefixlen 64 scopeid 0x6
inet6 2001:db8::1 -> 2001:db8::2 prefixlen 128

OK ?

Denis

Index: ifconfig.c
===
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.426
diff -u -p -r1.426 ifconfig.c
--- ifconfig.c  15 Sep 2020 15:23:11 -  1.426
+++ ifconfig.c  17 Sep 2020 14:41:34 -
@@ -3552,7 +3552,7 @@ in_status(int force)
}
(void) strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
sin = (struct sockaddr_in *)_dstaddr;
-   printf(" --> %s", inet_ntoa(sin->sin_addr));
+   printf(" -> %s", inet_ntoa(sin->sin_addr));
}
printf(" netmask 0x%x", ntohl(netmask.sin_addr.s_addr));
if (flags & IFF_BROADCAST) {