filtering routing socket messages by flags

2020-08-05 Thread Jonathan Matthew
Most (all?) of our routing daemons don't care about layer 2 or broadcast
routing entries, so they do something like this after reading a message
off the socket:

/* Skip ARP/ND cache and broadcast routes. */
if (rtm->rtm_flags & (RTF_LLINFO|RTF_BROADCAST))
continue;

ARP can generate a lot of routing messages during an address space scan,
and then again when the entries expire, and this can cause routing daemons
to desync.  To reduce the impact of this, we'd like to filter these out on
the kernel side.  There's another issue we need to fix to make this work
properly, but that can be done separately.

This adds a new type of filter on the routing socket, specifying a flag
bitmask, which filters out messages for routes with flags matching the mask.

ok?


Index: route.h
===
RCS file: /cvs/src/sys/net/route.h,v
retrieving revision 1.181
diff -u -p -u -p -r1.181 route.h
--- route.h 10 Mar 2020 21:35:41 -  1.181
+++ route.h 6 Aug 2020 01:47:11 -
@@ -297,6 +297,8 @@ struct rt_msghdr {
 #define ROUTE_PRIOFILTER 3 /* only pass updates with a priority higher or
   equal (actual value lower) to the specified
   priority. */
+#define ROUTE_FLAGFILTER 4 /* do not pass updates for routes with flags
+  in this bitmask. */
 
 #define ROUTE_FILTER(m)(1 << (m))
 #define RTABLE_ANY 0x
Index: rtsock.c
===
RCS file: /cvs/src/sys/net/rtsock.c,v
retrieving revision 1.299
diff -u -p -u -p -r1.299 rtsock.c
--- rtsock.c24 Jun 2020 22:03:42 -  1.299
+++ rtsock.c6 Aug 2020 01:47:11 -
@@ -145,6 +145,7 @@ struct rtpcb {
struct refcnt   rop_refcnt;
struct timeout  rop_timeout;
unsigned introp_msgfilter;
+   unsigned introp_flagfilter;
unsigned introp_flags;
u_int   rop_rtableid;
unsigned short  rop_proto;
@@ -402,6 +403,12 @@ route_ctloutput(int op, struct socket *s
else
rop->rop_priority = prio;
break;
+   case ROUTE_FLAGFILTER:
+   if (m == NULL || m->m_len != sizeof(unsigned int))
+   error = EINVAL;
+   else
+   rop->rop_flagfilter = *mtod(m, unsigned int *);
+   break;
default:
error = ENOPROTOOPT;
break;
@@ -421,6 +428,10 @@ route_ctloutput(int op, struct socket *s
m->m_len = sizeof(unsigned int);
*mtod(m, unsigned int *) = rop->rop_priority;
break;
+   case ROUTE_FLAGFILTER:
+   m->m_len = sizeof(unsigned int);
+   *mtod(m, unsigned int *) = rop->rop_flagfilter;
+   break;
default:
error = ENOPROTOOPT;
break;
@@ -516,9 +527,13 @@ next:
/* filter messages that the process does not want */
rtm = mtod(m, struct rt_msghdr *);
/* but RTM_DESYNC can't be filtered */
-   if (rtm->rtm_type != RTM_DESYNC && rop->rop_msgfilter != 0 &&
-   !(rop->rop_msgfilter & (1 << rtm->rtm_type)))
-   goto next;
+   if (rtm->rtm_type != RTM_DESYNC) {
+   if (rop->rop_msgfilter != 0 &&
+   !(rop->rop_msgfilter & (1 << rtm->rtm_type)))
+   goto next;
+   if (ISSET(rop->rop_flagfilter, rtm->rtm_flags))
+   goto next;
+   }
switch (rtm->rtm_type) {
case RTM_IFANNOUNCE:
case RTM_DESYNC:



exar XR17V35x (again)

2020-08-05 Thread joshua stein
In 2018 I added support for Exar XR17V35x serial ports:

The Exar XR17V354 has 4 com ports that have a 256-byte FIFO, use a
frequency of 125Mhz, and have a unique sleep register.  A custom
interrupt handler is setup in puc for these ports so it can check a
register which reports which ports triggered the interrupt, rather
than having to run comintr for every port every time.

https://github.com/openbsd/src/commit/21514470a28cb3682074159e69358d924e73f5f1

This was backed out shortly after:

Revert previous commit; the XR17V35X probe that was added accesses registers
that aren't guaranteed to be there and may even belong to a different 
device.
This triggers a fault on hppa machines like the C3000 for example.

https://github.com/openbsd/src/commit/9f2c39383ee470c5b76fb828f64ea58341b214e9
https://github.com/openbsd/src/commit/b40f90ead5d17e757784d1aa91d0d0406ce61d20

I needed this again, so this version sets the sc_uarttype in 
com_puc_attach ahead of time because the type of port is already 
known (from pucdata.c).  This avoids any probe in com_attach_subr 
which previously tried to upgrade from COM_UART_16550A to 
COM_UART_XR17V35X.

puc0 at pci4 dev 0 function 0 "Exar XR17V354" rev 0x03: ports: 16 com
com4 at puc0 port 0 apic 5 int 16: xr17v35x, 256 byte fifo
com5 at puc0 port 1 apic 5 int 16: xr17v35x, 256 byte fifo
com6 at puc0 port 2 apic 5 int 16: xr17v35x, 256 byte fifo
com7 at puc0 port 3 apic 5 int 16: xr17v35x, 256 byte fifo


Index: sys/dev/ic/com.c
===
RCS file: /cvs/src/sys/dev/ic/com.c,v
retrieving revision 1.172
diff -u -p -u -p -r1.172 com.c
--- sys/dev/ic/com.c9 Mar 2020 04:38:46 -   1.172
+++ sys/dev/ic/com.c5 Aug 2020 21:35:02 -
@@ -306,6 +306,9 @@ comopen(dev_t dev, int flag, int mode, s
case COM_UART_TI16750:
com_write_reg(sc, com_ier, 0);
break;
+   case COM_UART_XR17V35X:
+   com_write_reg(sc, UART_EXAR_SLEEP, 0);
+   break;
}
}
 
@@ -498,6 +501,9 @@ compwroff(struct com_softc *sc)
case COM_UART_TI16750:
com_write_reg(sc, com_ier, IER_SLEEP);
break;
+   case COM_UART_XR17V35X:
+   com_write_reg(sc, UART_EXAR_SLEEP, 0xff);
+   break;
}
}
 }
@@ -533,6 +539,9 @@ com_resume(struct com_softc *sc)
case COM_UART_TI16750:
com_write_reg(sc, com_ier, 0);
break;
+   case COM_UART_XR17V35X:
+   com_write_reg(sc, UART_EXAR_SLEEP, 0);
+   break;
}
}
 
@@ -919,7 +928,7 @@ comstart(struct tty *tp)
}
 
if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) {
-   u_char buffer[128]; /* largest fifo */
+   u_char buffer[256]; /* largest fifo */
int i, n;
 
n = q_to_b(>t_outq, buffer,
@@ -1466,6 +1475,11 @@ com_attach_subr(struct com_softc *sc)
break;
 #endif
 #endif
+   case COM_UART_XR17V35X:
+   printf(": xr17v35x, 256 byte fifo\n");
+   SET(sc->sc_hwflags, COM_HW_FIFO);
+   sc->sc_fifolen = 256;
+   break;
default:
panic("comattach: bad fifo type");
}
@@ -1473,7 +1487,8 @@ com_attach_subr(struct com_softc *sc)
 #ifdef COM_CONSOLE
if (!ISSET(sc->sc_hwflags, COM_HW_CONSOLE))
 #endif
-   com_fifo_probe(sc);
+   if (sc->sc_fifolen < 256)
+   com_fifo_probe(sc);
 
if (sc->sc_fifolen == 0) {
CLR(sc->sc_hwflags, COM_HW_FIFO);
Index: sys/dev/ic/comreg.h
===
RCS file: /cvs/src/sys/dev/ic/comreg.h,v
retrieving revision 1.19
diff -u -p -u -p -r1.19 comreg.h
--- sys/dev/ic/comreg.h 2 May 2018 13:20:12 -   1.19
+++ sys/dev/ic/comreg.h 5 Aug 2020 21:35:02 -
@@ -182,6 +182,11 @@
 
 #defineCOM_NPORTS  8
 
+/* Exar XR17V35X */
+#define UART_EXAR_INT0 0x80
+#define UART_EXAR_SLEEP0x8b/* Sleep mode */
+#define UART_EXAR_DVID 0x8d/* Device identification */
+
 /*
  * WARNING: Serial console is assumed to be at COM1 address
  */
Index: sys/dev/ic/comvar.h
===
RCS file: /cvs/src/sys/dev/ic/comvar.h,v
retrieving revision 1.57
diff -u -p -u -p -r1.57 comvar.h
--- sys/dev/ic/comvar.h 14 May 2018 19:25:54 -  1.57
+++ sys/dev/ic/comvar.h 5 Aug 2020 21:35:02 -
@@ -103,6 +103,7 @@ struct com_softc {
 #defineCOM_UART_ST16C654   0x08/* 64 bytes fifo */
 #defineCOM_UART_XR168500x10  

Remove unused netisr defines

2020-08-05 Thread Vitaliy Makkoveev
Remove defines for netisr bits which are not used anymore. 

Index: sys/net/netisr.h
===
RCS file: /cvs/src/sys/net/netisr.h,v
retrieving revision 1.52
diff -u -p -r1.52 netisr.h
--- sys/net/netisr.h4 Aug 2020 09:32:05 -   1.52
+++ sys/net/netisr.h5 Aug 2020 21:07:41 -
@@ -41,12 +41,8 @@
  * interrupt used for scheduling the network code to calls
  * on the lowest level routine of each protocol.
  */
-#defineNETISR_IP   2   /* same as AF_INET */
-#defineNETISR_TX   3   /* for if_snd processing */
 #defineNETISR_PFSYNC   5   /* for pfsync "immediate" tx */
 #defineNETISR_ARP  18  /* same as AF_LINK */
-#defineNETISR_IPV6 24  /* same as AF_INET6 */
-#defineNETISR_ISDN 26  /* same as AF_E164 */
 #defineNETISR_PPP  28  /* for PPP processing */
 #defineNETISR_BRIDGE   29  /* for bridge processing */
 #defineNETISR_PPPOE30  /* for pppoe processing */



Re: Don't check pointers against 0

2020-08-05 Thread Vitaliy Makkoveev
ok mvs

> On 5 Aug 2020, at 23:49, Marcus Glocker  wrote:
> 
> Reported by Peter J. Philipp.
> 
> OK?
> 
> 
> Index: sys/netinet/udp_usrreq.c
> ===
> RCS file: /cvs/src/sys/netinet/udp_usrreq.c,v
> retrieving revision 1.260
> diff -u -p -u -p -r1.260 udp_usrreq.c
> --- sys/netinet/udp_usrreq.c  1 Aug 2020 23:41:56 -   1.260
> +++ sys/netinet/udp_usrreq.c  5 Aug 2020 20:49:02 -
> @@ -486,7 +486,7 @@ udp_input(struct mbuf **mp, int *offp, i
>   inp = in_pcbhashlookup(, ip->ip_src, uh->uh_sport,
>   ip->ip_dst, uh->uh_dport, m->m_pkthdr.ph_rtableid);
>   }
> - if (inp == 0) {
> + if (inp == NULL) {
>   udpstat_inc(udps_pcbhashmiss);
> #ifdef INET6
>   if (ip6) {
> @@ -519,7 +519,7 @@ udp_input(struct mbuf **mp, int *offp, i
>   }
> #endif /*IPSEC */
> 
> - if (inp == 0) {
> + if (inp == NULL) {
>   udpstat_inc(udps_noport);
>   if (m->m_flags & (M_BCAST | M_MCAST)) {
>   udpstat_inc(udps_noportbcast);
> 



Don't check pointers against 0

2020-08-05 Thread Marcus Glocker
Reported by Peter J. Philipp.

OK?


Index: sys/netinet/udp_usrreq.c
===
RCS file: /cvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.260
diff -u -p -u -p -r1.260 udp_usrreq.c
--- sys/netinet/udp_usrreq.c1 Aug 2020 23:41:56 -   1.260
+++ sys/netinet/udp_usrreq.c5 Aug 2020 20:49:02 -
@@ -486,7 +486,7 @@ udp_input(struct mbuf **mp, int *offp, i
inp = in_pcbhashlookup(, ip->ip_src, uh->uh_sport,
ip->ip_dst, uh->uh_dport, m->m_pkthdr.ph_rtableid);
}
-   if (inp == 0) {
+   if (inp == NULL) {
udpstat_inc(udps_pcbhashmiss);
 #ifdef INET6
if (ip6) {
@@ -519,7 +519,7 @@ udp_input(struct mbuf **mp, int *offp, i
}
 #endif /*IPSEC */
 
-   if (inp == 0) {
+   if (inp == NULL) {
udpstat_inc(udps_noport);
if (m->m_flags & (M_BCAST | M_MCAST)) {
udpstat_inc(udps_noportbcast);



video -c: showing auto white balance temperature

2020-08-05 Thread Laurence Tratt
Following Marcus's commit of video(1) changes, the attached patch crudely
solves the "-c output is misleading for white_balance_temperature" because
we conflate auto_white_balance_temperature and white_balance_temperature
(which are two separate UVC controls) into one control in video(1).

With this patch we can tell people if white_balance_temperature is being
automatically controlled or not:

  $ video white_balance_temperature=6500
  white_balance_temperature: 4000 -> 6500
  $ obj/video -c
  brightness=128
  contrast=32
  saturation=64
  hue=0
  gamma=120
  sharpness=2
  white_balance_temperature=6500
  $ obj/video -d
  $ obj/video -c
  brightness=128
  contrast=32
  saturation=64
  hue=0
  gamma=120
  sharpness=2
  white_balance_temperature=auto

This patch raises several questions:

  1) At the moment the only "auto" control we have is
 white_balance_temperature. If we gain control of zoom/pan/exposure
 (etc), it might be worth breaking out the common "auto" functionality?

  2) Arguably the first command should look like:
   $ video white_balance_temperature=6500
   white_balance_temperature: auto -> 6500

  3) The output of "video -dv" is very different to "video -c": I suspect
 the former should look more like the latter for consistency.

  4) "video -dc" doesn't seem to reset auto_white_balance_temperature?


Laurie



Index: video.c
===
RCS file: /cvs/xenocara/app/video/video.c,v
retrieving revision 1.33
diff -u -r1.33 video.c
--- video.c 5 Aug 2020 11:34:00 -   1.33
+++ video.c 5 Aug 2020 20:33:56 -
@@ -1187,6 +1187,8 @@
 void
 dev_dump_query_ctrls(struct video *vid)
 {
+   struct dev *d = >dev;
+   struct v4l2_control control;
int i;
 
if (!dev_check_caps(vid))
@@ -1195,8 +1197,21 @@
return;
 
for (i = 0; i < CTRL_LAST; i++) {
-   if (ctrls[i].supported)
-   fprintf(stderr, "%s=%d\n", ctrls[i].name, ctrls[i].cur);
+   if (!ctrls[i].supported)
+   continue;
+
+   if (i == CTRL_WHITE_BALANCE_TEMPERATURE) {
+   control.id = V4L2_CID_AUTO_WHITE_BALANCE;
+   if (ioctl(d->fd, VIDIOC_G_CTRL, ) != 0) {
+   warn("VIDIOC_G_CTRL");
+   return;
+   }
+   if (control.value == 1) {
+   fprintf(stderr, "%s=auto\n", ctrls[i].name);
+   continue;
+   }
+   }
+   fprintf(stderr, "%s=%d\n", ctrls[i].name, ctrls[i].cur);
}
 }
 



Re: pppac(4) move ifnet out of KERNEL_LOCK()

2020-08-05 Thread Vitaliy Makkoveev
A little update.

I use `ifq' passed to pppac_start() instead of `ifp->if_snd' for
consistency reason.

Index: sys/net/if_pppx.c
===
RCS file: /cvs/src/sys/net/if_pppx.c,v
retrieving revision 1.98
diff -u -p -r1.98 if_pppx.c
--- sys/net/if_pppx.c   28 Jul 2020 09:53:36 -  1.98
+++ sys/net/if_pppx.c   5 Aug 2020 20:09:19 -
@@ -1058,7 +1058,7 @@ static intpppac_ioctl(struct ifnet *, u
 
 static int pppac_output(struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *);
-static voidpppac_start(struct ifnet *);
+static voidpppac_qstart(struct ifqueue *);
 
 static inline struct pppac_softc *
 pppac_lookup(dev_t dev)
@@ -1107,13 +1107,11 @@ pppacopen(dev_t dev, int flags, int mode
ifp->if_hdrlen = sizeof(uint32_t); /* for BPF */;
ifp->if_mtu = MAXMCLBYTES - sizeof(uint32_t);
ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST;
-   ifp->if_xflags = IFXF_CLONED;
+   ifp->if_xflags = IFXF_CLONED | IFXF_MPSAFE;
ifp->if_rtrequest = p2p_rtrequest; /* XXX */
ifp->if_output = pppac_output;
-   ifp->if_start = pppac_start;
+   ifp->if_qstart = pppac_qstart;
ifp->if_ioctl = pppac_ioctl;
-   /* XXXSMP: be sure pppac_start() called under NET_LOCK() */
-   ifq_set_maxlen(>if_snd, 1);
 
if_counters_alloc(ifp);
if_attach(ifp);
@@ -1382,10 +1380,10 @@ pppacclose(dev_t dev, int flags, int mod
klist_invalidate(>sc_wsel.si_note);
splx(s);
 
-   pipex_iface_fini(>sc_pipex_iface);
-
if_detach(ifp);
 
+   pipex_iface_fini(>sc_pipex_iface);
+
LIST_REMOVE(sc, sc_entry);
free(sc, M_DEVBUF, sizeof(*sc));
 
@@ -1459,15 +1457,13 @@ drop:
 }
 
 static void
-pppac_start(struct ifnet *ifp)
+pppac_qstart(struct ifqueue *ifq)
 {
+   struct ifnet *ifp = ifq->ifq_if;
struct pppac_softc *sc = ifp->if_softc;
struct mbuf *m;
 
-   if (!ISSET(ifp->if_flags, IFF_RUNNING))
-   return;
-
-   while ((m = ifq_dequeue(>if_snd)) != NULL) {
+   while ((m = ifq_dequeue(ifq)) != NULL) {
 #if NBPFILTER > 0
if (ifp->if_bpf) {
bpf_mtap_af(ifp->if_bpf, m->m_pkthdr.ph_family, m,
@@ -1475,8 +1471,10 @@ pppac_start(struct ifnet *ifp)
}
 #endif
 
+   NET_LOCK();
m = pipex_output(m, m->m_pkthdr.ph_family, 0,
>sc_pipex_iface);
+   NET_UNLOCK();
if (m == NULL)
continue;
 
@@ -1491,7 +1489,6 @@ pppac_start(struct ifnet *ifp)
}
 
if (!mq_empty(>sc_mq)) {
-   KERNEL_ASSERT_LOCKED();
wakeup(sc);
selwakeup(>sc_rsel);
}



Re: bugs in bridge ( netlock ? )

2020-08-05 Thread Vitaliy Makkoveev
I guess it’s know issue caused by ifioctl() races.


> On 5 Aug 2020, at 19:06, Sven F.  wrote:
> 
> On Wed, Aug 5, 2020 at 9:14 AM Sven F.  wrote:
>> 
>> Never seen before crash ( 6. 7 stable )
>> 
>> My devices run a lot of things in, load is easily 4
>> which is good for breaking lock code ?
>> 
>> uvm_fault(0xfd820a916cc0, 0x8, 0, 1) -> e
>> kernel: page fault trap, code=0
>> Stopped at  bridge_brlconf+0x24:movq0x8(%rdi),%rax
>> ddb{1}> bridge_brlconf(0,800022e482b0) at bridge_brlconf+0x24
>> bridge_ioctl(80524000,c030694f,800022e482b0) at 
>> bridge_ioctl+0x34f
>> ifioctl(fd8118f33c98,c030694f,800022e482b0,800022895510)
>> at ifioctl+0xa03
>> soo_ioctl(fd814c9cf2e8,c030694f,800022e482b0,800022895510)
>> at soo_ioctl+0x171
>> sys_ioctl(800022895510,800022e483c0,800022e48420) at 
>> sys_ioctl+0x2df
>> syscall(800022e48490) at syscall+0x389
>> Xsyscall() at Xsyscall+0x128
>> end of kernel
>> end trace frame: 0x7f7d2c30, count: -7
>> ddb{1}>PID TID   PPIDUID  S   FLAGS  WAIT  COMMAND
>> 93583  108149190  0  3 0x2  smrbarifconfig
>> 91803  290614  22775  0  2   0perl
>> 10793  382902  22775  0  2   0perl
>> 83906   60674  57936  0  2 0x2ifconfig
>> *80202  204044  63585  0  7 0x2ifconfig
>> 635857414  22775  0  30x80  piperdperl
>> 57936  439878  22775  0  30x80  piperdperl
>> 70874   88156  22775  0  7   0perl
>> 72682  513697  1  0  30x80  poll  openvpn
>> 84518  279046  22775  0  2   0perl
>> 55262   52512  22775  0  2   0perl
>> 36158  256298  22775  0  2   0perl
>> 84969  398264  1  0  30x80  poll  openvpn
>> 31484  239479  1  0  30x80  poll  openvpn
>>  7902   84087  60669  0  30x82  netio sshd
>> 25285  366282  1  0  30x80  poll  openvpn
>> 96838  424361  1  0  30x80  poll  openvpn
>> 42763  368876  1  0  30x80  poll  openvpn
>> 92032  243887  1  0  30x80  poll  openvpn
>> 22775  200805  21119  0  2 0x2perl
>> 21119  407468  75737  0  30x10008a  pause sh
>> ddb{1}> rebooting...
>> OpenBSD 6.7-stable (GENERIC.MP) #43: Tue Jul 28 21:46:24 EDT 2020
>>root@builder:/sys/arch/amd64/compile/GENERIC.MP
>> real mem = 8371683328 (7983MB)
>> avail mem = 8105316352 (7729MB)
>> mpath0 at root
>> scsibus0 at mpath0: 256 targets
>> mainbus0 at root
>> bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xf6830 (11 entries)
>> bios0: vendor SeaBIOS version "2:1.10.2-58953eb7" date 04/01/2014
>> bios0: OpenStack Foundation OpenStack Nova
>> acpi0 at bios0: ACPI 1.0
>> acpi0: sleep states S3 S4 S5
>> acpi0: tables DSDT FACP APIC
>> acpi0: wakeup devices
>> acpitimer0 at acpi0: 3579545 Hz, 24 bits
>> acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
>> cpu0 at mainbus0: apid 0 (boot processor)
>> cpu0: Intel Core Processor (Haswell, no TSX), 2394.80 MHz, 06-3c-01
>> cpu0: 
>> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,VMX,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,RDTSCP,LONG,LAHF,ABM,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MD_CLEAR,ARAT,XSAVEOPT,MELTDOWN
>> cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB
>> 64b/line 16-way L2 cache
>> cpu0: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
>> cpu0: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
>> cpu0: smt 0, core 0, package 0
>> mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
>> cpu0: apic clock running at 1000MHz
>> cpu1 at mainbus0: apid 1 (application processor)
>> cpu1: Intel Core Processor (Haswell, no TSX), 2394.56 MHz, 06-3c-01
>> cpu1: 
>> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,VMX,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,RDTSCP,LONG,LAHF,ABM,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MD_CLEAR,ARAT,XSAVEOPT,MELTDOWN
>> cpu1: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB
>> 64b/line 16-way L2 cache
>> cpu1: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
>> cpu1: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
>> cpu1: smt 0, core 0, package 1
>> ioapic0 at mainbus0: apid 0 pa 0xfec0, version 11, 24 pins
>> acpiprt0 at acpi0: bus 0 (PCI0)
>> acpicpu0 at acpi0: C1(@1 halt!)
>> acpicpu1 at acpi0: C1(@1 halt!)
>> "ACPI0006" at acpi0 not configured
>> acpipci0 at acpi0 PCI0: _OSC failed
>> 

Re: bugs in bridge ( netlock ? )

2020-08-05 Thread Sven F.
On Wed, Aug 5, 2020 at 9:14 AM Sven F.  wrote:
>
> Never seen before crash ( 6. 7 stable )
>
> My devices run a lot of things in, load is easily 4
> which is good for breaking lock code ?
>
> uvm_fault(0xfd820a916cc0, 0x8, 0, 1) -> e
> kernel: page fault trap, code=0
> Stopped at  bridge_brlconf+0x24:movq0x8(%rdi),%rax
> ddb{1}> bridge_brlconf(0,800022e482b0) at bridge_brlconf+0x24
> bridge_ioctl(80524000,c030694f,800022e482b0) at bridge_ioctl+0x34f
> ifioctl(fd8118f33c98,c030694f,800022e482b0,800022895510)
> at ifioctl+0xa03
> soo_ioctl(fd814c9cf2e8,c030694f,800022e482b0,800022895510)
> at soo_ioctl+0x171
> sys_ioctl(800022895510,800022e483c0,800022e48420) at 
> sys_ioctl+0x2df
> syscall(800022e48490) at syscall+0x389
> Xsyscall() at Xsyscall+0x128
> end of kernel
> end trace frame: 0x7f7d2c30, count: -7
> ddb{1}>PID TID   PPIDUID  S   FLAGS  WAIT  COMMAND
>  93583  108149190  0  3 0x2  smrbarifconfig
>  91803  290614  22775  0  2   0perl
>  10793  382902  22775  0  2   0perl
>  83906   60674  57936  0  2 0x2ifconfig
> *80202  204044  63585  0  7 0x2ifconfig
>  635857414  22775  0  30x80  piperdperl
>  57936  439878  22775  0  30x80  piperdperl
>  70874   88156  22775  0  7   0perl
>  72682  513697  1  0  30x80  poll  openvpn
>  84518  279046  22775  0  2   0perl
>  55262   52512  22775  0  2   0perl
>  36158  256298  22775  0  2   0perl
>  84969  398264  1  0  30x80  poll  openvpn
>  31484  239479  1  0  30x80  poll  openvpn
>   7902   84087  60669  0  30x82  netio sshd
>  25285  366282  1  0  30x80  poll  openvpn
>  96838  424361  1  0  30x80  poll  openvpn
>  42763  368876  1  0  30x80  poll  openvpn
>  92032  243887  1  0  30x80  poll  openvpn
>  22775  200805  21119  0  2 0x2perl
>  21119  407468  75737  0  30x10008a  pause sh
>  ddb{1}> rebooting...
> OpenBSD 6.7-stable (GENERIC.MP) #43: Tue Jul 28 21:46:24 EDT 2020
> root@builder:/sys/arch/amd64/compile/GENERIC.MP
> real mem = 8371683328 (7983MB)
> avail mem = 8105316352 (7729MB)
> mpath0 at root
> scsibus0 at mpath0: 256 targets
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xf6830 (11 entries)
> bios0: vendor SeaBIOS version "2:1.10.2-58953eb7" date 04/01/2014
> bios0: OpenStack Foundation OpenStack Nova
> acpi0 at bios0: ACPI 1.0
> acpi0: sleep states S3 S4 S5
> acpi0: tables DSDT FACP APIC
> acpi0: wakeup devices
> acpitimer0 at acpi0: 3579545 Hz, 24 bits
> acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
> cpu0 at mainbus0: apid 0 (boot processor)
> cpu0: Intel Core Processor (Haswell, no TSX), 2394.80 MHz, 06-3c-01
> cpu0: 
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,VMX,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,RDTSCP,LONG,LAHF,ABM,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MD_CLEAR,ARAT,XSAVEOPT,MELTDOWN
> cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB
> 64b/line 16-way L2 cache
> cpu0: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
> cpu0: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
> cpu0: smt 0, core 0, package 0
> mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
> cpu0: apic clock running at 1000MHz
> cpu1 at mainbus0: apid 1 (application processor)
> cpu1: Intel Core Processor (Haswell, no TSX), 2394.56 MHz, 06-3c-01
> cpu1: 
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,VMX,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,RDTSCP,LONG,LAHF,ABM,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MD_CLEAR,ARAT,XSAVEOPT,MELTDOWN
> cpu1: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB
> 64b/line 16-way L2 cache
> cpu1: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
> cpu1: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
> cpu1: smt 0, core 0, package 1
> ioapic0 at mainbus0: apid 0 pa 0xfec0, version 11, 24 pins
> acpiprt0 at acpi0: bus 0 (PCI0)
> acpicpu0 at acpi0: C1(@1 halt!)
> acpicpu1 at acpi0: C1(@1 halt!)
> "ACPI0006" at acpi0 not configured
> acpipci0 at acpi0 PCI0: _OSC failed
> acpicmos0 at acpi0
> "PNP0A06" at acpi0 not configured
> "PNP0A06" at acpi0 not configured
> "PNP0A06" at acpi0 not configured
> "QEMU0002" at acpi0 not configured
> 

Re: tpmr.4, ifconfig.8: document tpmr ioctls and synopsis

2020-08-05 Thread Klemens Nanni
On Wed, Aug 05, 2020 at 03:24:57PM +0100, Jason McIntyre wrote:
> this is in line with all our other pages, so ok. while you're poking
> around in there, the first example in tpmr.4 EXAMPLES would be a whole
> lot nicer with -indent on the display. care to fix that too?
Sure, I'll commit with `.Bd -literal -offset indent'.



Re: tpmr.4, ifconfig.8: document tpmr ioctls and synopsis

2020-08-05 Thread Jason McIntyre
On Wed, Aug 05, 2020 at 09:03:20AM +0200, Klemens Nanni wrote:
> Add missing TPMR section to ifconfig(8) by moving the commands from
> the driver's manual to it (copy/paste) and document the ioctl(2)
> interface in tpmr(4).
> 
> Feedback? OK?
> 
> 

this is in line with all our other pages, so ok. while you're poking
around in there, the first example in tpmr.4 EXAMPLES would be a whole
lot nicer with -indent on the display. care to fix that too?

thanks,
jmc

> Index: sbin/ifconfig/ifconfig.8
> ===
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v
> retrieving revision 1.353
> diff -u -p -r1.353 ifconfig.8
> --- sbin/ifconfig/ifconfig.8  26 Jul 2020 18:34:10 -  1.353
> +++ sbin/ifconfig/ifconfig.8  5 Aug 2020 06:48:38 -
> @@ -204,6 +204,7 @@ At least the following devices can be cr
>  .Xr svlan 4 ,
>  .Xr switch 4 ,
>  .Xr tap 4 ,
> +.Xr tpmr 4 ,
>  .Xr trunk 4 ,
>  .Xr tun 4 ,
>  .Xr vether 4 ,
> @@ -830,6 +831,51 @@ If
>  is set to zero, then entries will not be expired.
>  .It Cm up
>  Start the bridge forwarding packets.
> +.El
> +.Sh TPMR
> +.nr nS 1
> +.Bk -words
> +.Nm ifconfig
> +.Ar tpmr-interface
> +.Op Cm add Ar child-iface
> +.Op Cm del Ar child-iface
> +.Op Oo Fl Oc Ns Cm link0
> +.Op Oo Fl Oc Ns Cm link1
> +.Op Oo Fl Oc Ns Cm link2
> +.Ek
> +The following options are available for a
> +.Xr tpmr 4
> +interface:
> +.Bl -tag -width Ds
> +.It Cm add Ar child-iface
> +Add
> +.Ar child-iface
> +as a member.
> +.It Cm del Ar child-iface
> +Remove the member
> +.Ar child-iface .
> +.It Cm link0
> +Disable the filtering of Ethernet frames destined for the TPMR
> +component reserved addresses, as specified by IEEE 802.1Q.
> +.It Cm -link0
> +Enable the filtering of Ethernet frames destined for the TPMR
> +component reserved addresses, as specified by IEEE 802.1Q.
> +This is the default.
> +.It Cm link1
> +Disable the filtering of IPv4 and IPv6 packets with
> +.Xr pf 4 .
> +.It Cm -link1
> +Enable the filtering of IPv4 and IPv6 packets with
> +.Xr pf 4 .
> +Packets will appear to enter or leave the member port interfaces.
> +This is the default.
> +.It Cm link2
> +Disable the filtering of 802.1Q VLAN and QinQ SVLAN packets.
> +.It Cm -link2
> +Enable the filtering of 802.1Q VLAN and QinQ SVLAN packets.
> +.Xr pf 4 .
> +Packets will appear to enter or leave the member port interfaces.
> +This is the default.
>  .El
>  .Sh CARP
>  .nr nS 1
> Index: share/man/man4/tpmr.4
> ===
> RCS file: /cvs/src/share/man/man4/tpmr.4,v
> retrieving revision 1.6
> diff -u -p -r1.6 tpmr.4
> --- share/man/man4/tpmr.4 22 Jul 2020 04:08:46 -  1.6
> +++ share/man/man4/tpmr.4 5 Aug 2020 06:58:58 -
> @@ -40,48 +40,6 @@ command or by setting up a
>  .Xr hostname.if 5
>  configuration file for
>  .Xr netstart 8 .
> -The interface itself can be configured with
> -.Xr ifconfig 8 ;
> -see its manual page for more information.
> -.Pp
> -.Nm
> -interfaces may be configured with
> -.Xr ifconfig 8
> -and
> -.Xr netstart 8
> -using the following options:
> -.Bl -tag -width Ds
> -.It Cm add Ar child-iface
> -Add
> -.Ar child-iface
> -as a member.
> -.It Cm del Ar child-iface
> -Remove the member
> -.Ar child-iface .
> -.It Cm link0
> -Disable the filtering of Ethernet frames destined for the TPMR
> -component reserved addresses, as specified by IEEE 802.1Q.
> -.It Cm -link0
> -Enable the filtering of Ethernet frames destined for the TPMR
> -component reserved addresses, as specified by IEEE 802.1Q.
> -This is the default.
> -.It Cm link1
> -Disable the filtering of IPv4 and IPv6 packets with
> -.Xr pf 4 .
> -.It Cm -link1
> -Enable the filtering of IPv4 and IPv6 packets with
> -.Xr pf 4 .
> -Packets will appear to enter or leave the member port interfaces.
> -This is the default.
> -.It Cm link2
> -Disable the filtering of 802.1Q VLAN and QinQ SVLAN packets.
> -.It Cm -link2
> -Enable the filtering of 802.1Q VLAN and QinQ SVLAN packets.
> -.Xr pf 4 .
> -Packets will appear to enter or leave the member port interfaces.
> -This is the default.
> -.El
> -.\" document the ioctls?
>  .Pp
>  Other forms of Ethernet bridging are available using the
>  .Xr bridge 4
> @@ -92,6 +50,20 @@ using the
>  and
>  .Xr trunk 4
>  drivers.
> +.Sh IOCTLS
> +The following
> +.Xr ioctl 2
> +calls and their structures are commonly use by
> +.Nm
> +and
> +.Xr bridge 4 :
> +.Pp
> +.Bl -bullet -offset indent -compact
> +.It
> +.Dv SIOCBRDGADD
> +.It
> +.Dv SIOCBRDGDEL
> +.El
>  .Sh EXAMPLES
>  .Nm
>  can be used to cross-connect Ethernet devices that support different
> 



pppac(4) move ifnet out of KERNEL_LOCK()

2020-08-05 Thread Vitaliy Makkoveev
The same as for pppx(4).

pipex(4) and pppac(4) are ready to became a little bit more MP capable.
Diff below moves pppac(4) related `ifnet' out of KERNEL_LOCK().

The wakeup(9) and selwakeup() are not require KERNEL_LOCK() so this
assertion was wrong and can be dropped. Also we detach `ifnet' before
pipex_iface_fini().

Index: sys/net/if_pppx.c
===
RCS file: /cvs/src/sys/net/if_pppx.c,v
retrieving revision 1.98
diff -u -p -r1.98 if_pppx.c
--- sys/net/if_pppx.c   28 Jul 2020 09:53:36 -  1.98
+++ sys/net/if_pppx.c   5 Aug 2020 13:53:33 -
@@ -1058,7 +1058,7 @@ static intpppac_ioctl(struct ifnet *, u
 
 static int pppac_output(struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *);
-static voidpppac_start(struct ifnet *);
+static voidpppac_qstart(struct ifqueue *);
 
 static inline struct pppac_softc *
 pppac_lookup(dev_t dev)
@@ -1107,13 +1107,11 @@ pppacopen(dev_t dev, int flags, int mode
ifp->if_hdrlen = sizeof(uint32_t); /* for BPF */;
ifp->if_mtu = MAXMCLBYTES - sizeof(uint32_t);
ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST;
-   ifp->if_xflags = IFXF_CLONED;
+   ifp->if_xflags = IFXF_CLONED | IFXF_MPSAFE;
ifp->if_rtrequest = p2p_rtrequest; /* XXX */
ifp->if_output = pppac_output;
-   ifp->if_start = pppac_start;
+   ifp->if_qstart = pppac_qstart;
ifp->if_ioctl = pppac_ioctl;
-   /* XXXSMP: be sure pppac_start() called under NET_LOCK() */
-   ifq_set_maxlen(>if_snd, 1);
 
if_counters_alloc(ifp);
if_attach(ifp);
@@ -1382,10 +1380,10 @@ pppacclose(dev_t dev, int flags, int mod
klist_invalidate(>sc_wsel.si_note);
splx(s);
 
-   pipex_iface_fini(>sc_pipex_iface);
-
if_detach(ifp);
 
+   pipex_iface_fini(>sc_pipex_iface);
+
LIST_REMOVE(sc, sc_entry);
free(sc, M_DEVBUF, sizeof(*sc));
 
@@ -1459,14 +1457,12 @@ drop:
 }
 
 static void
-pppac_start(struct ifnet *ifp)
+pppac_qstart(struct ifqueue *ifq)
 {
+   struct ifnet *ifp = ifq->ifq_if;
struct pppac_softc *sc = ifp->if_softc;
struct mbuf *m;
 
-   if (!ISSET(ifp->if_flags, IFF_RUNNING))
-   return;
-
while ((m = ifq_dequeue(>if_snd)) != NULL) {
 #if NBPFILTER > 0
if (ifp->if_bpf) {
@@ -1475,8 +1471,10 @@ pppac_start(struct ifnet *ifp)
}
 #endif
 
+   NET_LOCK();
m = pipex_output(m, m->m_pkthdr.ph_family, 0,
>sc_pipex_iface);
+   NET_UNLOCK();
if (m == NULL)
continue;
 
@@ -1491,7 +1489,6 @@ pppac_start(struct ifnet *ifp)
}
 
if (!mq_empty(>sc_mq)) {
-   KERNEL_ASSERT_LOCKED();
wakeup(sc);
selwakeup(>sc_rsel);
}



bugs in bridge ( netlock ? )

2020-08-05 Thread Sven F.
Never seen before crash ( 6. 7 stable )

My devices run a lot of things in, load is easily 4
which is good for breaking lock code ?

uvm_fault(0xfd820a916cc0, 0x8, 0, 1) -> e
kernel: page fault trap, code=0
Stopped at  bridge_brlconf+0x24:movq0x8(%rdi),%rax
ddb{1}> bridge_brlconf(0,800022e482b0) at bridge_brlconf+0x24
bridge_ioctl(80524000,c030694f,800022e482b0) at bridge_ioctl+0x34f
ifioctl(fd8118f33c98,c030694f,800022e482b0,800022895510)
at ifioctl+0xa03
soo_ioctl(fd814c9cf2e8,c030694f,800022e482b0,800022895510)
at soo_ioctl+0x171
sys_ioctl(800022895510,800022e483c0,800022e48420) at sys_ioctl+0x2df
syscall(800022e48490) at syscall+0x389
Xsyscall() at Xsyscall+0x128
end of kernel
end trace frame: 0x7f7d2c30, count: -7
ddb{1}>PID TID   PPIDUID  S   FLAGS  WAIT  COMMAND
 93583  108149190  0  3 0x2  smrbarifconfig
 91803  290614  22775  0  2   0perl
 10793  382902  22775  0  2   0perl
 83906   60674  57936  0  2 0x2ifconfig
*80202  204044  63585  0  7 0x2ifconfig
 635857414  22775  0  30x80  piperdperl
 57936  439878  22775  0  30x80  piperdperl
 70874   88156  22775  0  7   0perl
 72682  513697  1  0  30x80  poll  openvpn
 84518  279046  22775  0  2   0perl
 55262   52512  22775  0  2   0perl
 36158  256298  22775  0  2   0perl
 84969  398264  1  0  30x80  poll  openvpn
 31484  239479  1  0  30x80  poll  openvpn
  7902   84087  60669  0  30x82  netio sshd
 25285  366282  1  0  30x80  poll  openvpn
 96838  424361  1  0  30x80  poll  openvpn
 42763  368876  1  0  30x80  poll  openvpn
 92032  243887  1  0  30x80  poll  openvpn
 22775  200805  21119  0  2 0x2perl
 21119  407468  75737  0  30x10008a  pause sh
 ddb{1}> rebooting...
OpenBSD 6.7-stable (GENERIC.MP) #43: Tue Jul 28 21:46:24 EDT 2020
root@builder:/sys/arch/amd64/compile/GENERIC.MP
real mem = 8371683328 (7983MB)
avail mem = 8105316352 (7729MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xf6830 (11 entries)
bios0: vendor SeaBIOS version "2:1.10.2-58953eb7" date 04/01/2014
bios0: OpenStack Foundation OpenStack Nova
acpi0 at bios0: ACPI 1.0
acpi0: sleep states S3 S4 S5
acpi0: tables DSDT FACP APIC
acpi0: wakeup devices
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel Core Processor (Haswell, no TSX), 2394.80 MHz, 06-3c-01
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,VMX,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,RDTSCP,LONG,LAHF,ABM,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MD_CLEAR,ARAT,XSAVEOPT,MELTDOWN
cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB
64b/line 16-way L2 cache
cpu0: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu0: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 1000MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel Core Processor (Haswell, no TSX), 2394.56 MHz, 06-3c-01
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,VMX,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,RDTSCP,LONG,LAHF,ABM,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MD_CLEAR,ARAT,XSAVEOPT,MELTDOWN
cpu1: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB
64b/line 16-way L2 cache
cpu1: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu1: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu1: smt 0, core 0, package 1
ioapic0 at mainbus0: apid 0 pa 0xfec0, version 11, 24 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpicpu0 at acpi0: C1(@1 halt!)
acpicpu1 at acpi0: C1(@1 halt!)
"ACPI0006" at acpi0 not configured
acpipci0 at acpi0 PCI0: _OSC failed
acpicmos0 at acpi0
"PNP0A06" at acpi0 not configured
"PNP0A06" at acpi0 not configured
"PNP0A06" at acpi0 not configured
"QEMU0002" at acpi0 not configured
"ACPI0010" at acpi0 not configured
cpu0: using VERW MDS workaround
pvbus0 at mainbus0: KVM
pvclock0 at pvbus0
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel 82441FX" rev 0x02
pcib0 at pci0 dev 1 function 0 "Intel 82371SB ISA" 

Re: macppc G5 pmap fix

2020-08-05 Thread Olivier Cherrier
On Sun, Jul 12, 2020 at 11:33:33AM +0200, mark.kette...@xs4all.nl wrote:
> 
> While working on the OpenBSD/powerpc64 pmap I noticed that the code we
> use for the G5 machines has a bug and doesn't remove execute
> permission from mappings when it should.
> 
> Since I don't have a G5 machine readily available, can somebody test
> this diff for me?
 
Hello Mark,

I'm running with it on my G5 and it seems happy.

$ sysctl hw.{machine,model,vendor,product} 
hw.machine=macppc
hw.model=970FX (Revision 0x300)
hw.vendor=Apple Computer, Inc.
hw.product=PowerMac8,1

Thanks,
Best.

-- 
Olivier Cherrier
Phone: +352691570680
mailto:o...@symacx.com



Re: acpicpu: remove acpicpu_sc array

2020-08-05 Thread Mark Kettenis
> Date: Wed, 5 Aug 2020 17:10:37 +1000
> From: Jonathan Matthew 
> 
> This came out of the work on supporting ACPI0007 devices in acpicpu(4), but
> it's independent of that and I'd like to get it in the tree separately.
> 
> Since it was first added, acpicpu stores instances of itself in an array, 
> which it uses to find the acpicpu device for a cpu.  This runs into problems
> when there are more than MAXCPUS acpicpu devices.  Currently it overwrites
> whatever's after the array, leading to varying crashes and hangs depending
> on kernel link order.
> 
> More recently, we've added a pointer to struct cpu_info that does this more
> directly, and also has the advantage that it actually matches up the cpu ids
> rather than assuming cpu3 maps to acpicpu3.
> 
> This diff removes the acpicpu_sc array and uses the pointer from struct
> cpu_info instead.  Most of the accesses are just looking for the first 
> acpicpu,
> so we can use cpu_info_primary to find that.
> 
> I've tested this on a few different machines (including one with 128 acpicpu
> devices) and everything still works.
> 
> ok?

ok kettenis@

> Index: acpicpu.c
> ===
> RCS file: /cvs/src/sys/dev/acpi/acpicpu.c,v
> retrieving revision 1.85
> diff -u -p -r1.85 acpicpu.c
> --- acpicpu.c 27 May 2020 05:02:21 -  1.85
> +++ acpicpu.c 3 Aug 2020 05:10:45 -
> @@ -188,8 +188,6 @@ struct cfdriver acpicpu_cd = {
>  
>  extern int setperf_prio;
>  
> -struct acpicpu_softc *acpicpu_sc[MAXCPUS];
> -
>  #if 0
>  void
>  acpicpu_set_throttle(struct acpicpu_softc *sc, int level)
> @@ -672,7 +670,6 @@ acpicpu_attach(struct device *parent, st
>  
>   sc->sc_acpi = (struct acpi_softc *)parent;
>   sc->sc_devnode = aa->aaa_node;
> - acpicpu_sc[sc->sc_dev.dv_unit] = sc;
>  
>   SLIST_INIT(>sc_cstates);
>  
> @@ -979,7 +976,7 @@ acpicpu_fetch_pss(struct acpicpu_pss **p
>* the bios ensures this...
>*/
>  
> - sc = acpicpu_sc[0];
> + sc = (struct acpicpu_softc *)cpu_info_primary.ci_acpicpudev;
>   if (!sc)
>   return 0;
>   *pss = sc->sc_pss;
> @@ -1024,7 +1021,7 @@ acpicpu_set_notify(void (*func)(struct a
>  {
>   struct acpicpu_softc*sc;
>  
> - sc = acpicpu_sc[0];
> + sc = (struct acpicpu_softc *)cpu_info_primary.ci_acpicpudev;
>   if (sc != NULL)
>   sc->sc_notify = func;
>  }
> @@ -1034,7 +1031,7 @@ acpicpu_setperf_ppc_change(struct acpicp
>  {
>   struct acpicpu_softc*sc;
>  
> - sc = acpicpu_sc[0];
> + sc = (struct acpicpu_softc *)cpu_info_primary.ci_acpicpudev;
>  
>   if (sc != NULL)
>   cpu_setperf(sc->sc_level);
> @@ -1048,7 +1045,7 @@ acpicpu_setperf(int level)
>   int idx, len;
>   uint32_tstatus = 0;
>  
> - sc = acpicpu_sc[cpu_number()];
> + sc = (struct acpicpu_softc *)curcpu()->ci_acpicpudev;
>  
>   dnprintf(10, "%s: acpicpu setperf level %d\n",
>   sc->sc_devnode->name, level);
> 
> 



pppx(4): move ifnet out of KERNEL_LOCK()

2020-08-05 Thread Vitaliy Makkoveev
pipex(4) and pppx(4) are ready to became a little bit more MP capable.
Diff below moves pppx(4) related `ifnet' out of KERNEL_LOCK().

Index: sys/net/if_pppx.c
===
RCS file: /cvs/src/sys/net/if_pppx.c,v
retrieving revision 1.98
diff -u -p -r1.98 if_pppx.c
--- sys/net/if_pppx.c   28 Jul 2020 09:53:36 -  1.98
+++ sys/net/if_pppx.c   5 Aug 2020 09:34:50 -
@@ -191,7 +191,7 @@ int pppx_set_session_descr(struct pppx_
struct pipex_session_descr_req *);
 
 void   pppx_if_destroy(struct pppx_dev *, struct pppx_if *);
-void   pppx_if_start(struct ifnet *);
+void   pppx_if_qstart(struct ifqueue *);
 intpppx_if_output(struct ifnet *, struct mbuf *,
struct sockaddr *, struct rtentry *);
 intpppx_if_ioctl(struct ifnet *, u_long, caddr_t);
@@ -683,13 +683,12 @@ pppx_add_session(struct pppx_dev *pxd, s
snprintf(ifp->if_xname, sizeof(ifp->if_xname), "%s%d", "pppx", unit);
ifp->if_mtu = req->pr_peer_mru; /* XXX */
ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST | IFF_UP;
-   ifp->if_xflags = IFXF_CLONED;
-   ifp->if_start = pppx_if_start;
+   ifp->if_xflags = IFXF_CLONED | IFXF_MPSAFE;
+   ifp->if_qstart = pppx_if_qstart;
ifp->if_output = pppx_if_output;
ifp->if_ioctl = pppx_if_ioctl;
ifp->if_rtrequest = p2p_rtrequest;
ifp->if_type = IFT_PPP;
-   ifq_set_maxlen(>if_snd, 1);
ifp->if_softc = pxi;
/* ifp->if_rdomain = req->pr_rdomain; */
 
@@ -864,28 +863,23 @@ pppx_if_destroy(struct pppx_dev *pxd, st
 }
 
 void
-pppx_if_start(struct ifnet *ifp)
+pppx_if_qstart(struct ifqueue *ifq)
 {
+   struct ifnet *ifp = ifq->ifq_if;
struct pppx_if *pxi = (struct pppx_if *)ifp->if_softc;
struct mbuf *m;
int proto;
 
-   if (!ISSET(ifp->if_flags, IFF_RUNNING))
-   return;
-
-   for (;;) {
-   m = ifq_dequeue(>if_snd);
-
-   if (m == NULL)
-   break;
-
+   while ((m = ifq_dequeue(ifq)) != NULL) {
proto = *mtod(m, int *);
m_adj(m, sizeof(proto));
 
ifp->if_obytes += m->m_pkthdr.len;
ifp->if_opackets++;
 
+   NET_LOCK();
pipex_ppp_output(m, pxi->pxi_session, proto);
+   NET_UNLOCK();
}
 }
 



acpicpu: remove acpicpu_sc array

2020-08-05 Thread Jonathan Matthew
This came out of the work on supporting ACPI0007 devices in acpicpu(4), but
it's independent of that and I'd like to get it in the tree separately.

Since it was first added, acpicpu stores instances of itself in an array, 
which it uses to find the acpicpu device for a cpu.  This runs into problems
when there are more than MAXCPUS acpicpu devices.  Currently it overwrites
whatever's after the array, leading to varying crashes and hangs depending
on kernel link order.

More recently, we've added a pointer to struct cpu_info that does this more
directly, and also has the advantage that it actually matches up the cpu ids
rather than assuming cpu3 maps to acpicpu3.

This diff removes the acpicpu_sc array and uses the pointer from struct
cpu_info instead.  Most of the accesses are just looking for the first acpicpu,
so we can use cpu_info_primary to find that.

I've tested this on a few different machines (including one with 128 acpicpu
devices) and everything still works.

ok?


Index: acpicpu.c
===
RCS file: /cvs/src/sys/dev/acpi/acpicpu.c,v
retrieving revision 1.85
diff -u -p -r1.85 acpicpu.c
--- acpicpu.c   27 May 2020 05:02:21 -  1.85
+++ acpicpu.c   3 Aug 2020 05:10:45 -
@@ -188,8 +188,6 @@ struct cfdriver acpicpu_cd = {
 
 extern int setperf_prio;
 
-struct acpicpu_softc *acpicpu_sc[MAXCPUS];
-
 #if 0
 void
 acpicpu_set_throttle(struct acpicpu_softc *sc, int level)
@@ -672,7 +670,6 @@ acpicpu_attach(struct device *parent, st
 
sc->sc_acpi = (struct acpi_softc *)parent;
sc->sc_devnode = aa->aaa_node;
-   acpicpu_sc[sc->sc_dev.dv_unit] = sc;
 
SLIST_INIT(>sc_cstates);
 
@@ -979,7 +976,7 @@ acpicpu_fetch_pss(struct acpicpu_pss **p
 * the bios ensures this...
 */
 
-   sc = acpicpu_sc[0];
+   sc = (struct acpicpu_softc *)cpu_info_primary.ci_acpicpudev;
if (!sc)
return 0;
*pss = sc->sc_pss;
@@ -1024,7 +1021,7 @@ acpicpu_set_notify(void (*func)(struct a
 {
struct acpicpu_softc*sc;
 
-   sc = acpicpu_sc[0];
+   sc = (struct acpicpu_softc *)cpu_info_primary.ci_acpicpudev;
if (sc != NULL)
sc->sc_notify = func;
 }
@@ -1034,7 +1031,7 @@ acpicpu_setperf_ppc_change(struct acpicp
 {
struct acpicpu_softc*sc;
 
-   sc = acpicpu_sc[0];
+   sc = (struct acpicpu_softc *)cpu_info_primary.ci_acpicpudev;
 
if (sc != NULL)
cpu_setperf(sc->sc_level);
@@ -1048,7 +1045,7 @@ acpicpu_setperf(int level)
int idx, len;
uint32_tstatus = 0;
 
-   sc = acpicpu_sc[cpu_number()];
+   sc = (struct acpicpu_softc *)curcpu()->ci_acpicpudev;
 
dnprintf(10, "%s: acpicpu setperf level %d\n",
sc->sc_devnode->name, level);



tpmr.4, ifconfig.8: document tpmr ioctls and synopsis

2020-08-05 Thread Klemens Nanni
Add missing TPMR section to ifconfig(8) by moving the commands from
the driver's manual to it (copy/paste) and document the ioctl(2)
interface in tpmr(4).

Feedback? OK?


Index: sbin/ifconfig/ifconfig.8
===
RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v
retrieving revision 1.353
diff -u -p -r1.353 ifconfig.8
--- sbin/ifconfig/ifconfig.826 Jul 2020 18:34:10 -  1.353
+++ sbin/ifconfig/ifconfig.85 Aug 2020 06:48:38 -
@@ -204,6 +204,7 @@ At least the following devices can be cr
 .Xr svlan 4 ,
 .Xr switch 4 ,
 .Xr tap 4 ,
+.Xr tpmr 4 ,
 .Xr trunk 4 ,
 .Xr tun 4 ,
 .Xr vether 4 ,
@@ -830,6 +831,51 @@ If
 is set to zero, then entries will not be expired.
 .It Cm up
 Start the bridge forwarding packets.
+.El
+.Sh TPMR
+.nr nS 1
+.Bk -words
+.Nm ifconfig
+.Ar tpmr-interface
+.Op Cm add Ar child-iface
+.Op Cm del Ar child-iface
+.Op Oo Fl Oc Ns Cm link0
+.Op Oo Fl Oc Ns Cm link1
+.Op Oo Fl Oc Ns Cm link2
+.Ek
+The following options are available for a
+.Xr tpmr 4
+interface:
+.Bl -tag -width Ds
+.It Cm add Ar child-iface
+Add
+.Ar child-iface
+as a member.
+.It Cm del Ar child-iface
+Remove the member
+.Ar child-iface .
+.It Cm link0
+Disable the filtering of Ethernet frames destined for the TPMR
+component reserved addresses, as specified by IEEE 802.1Q.
+.It Cm -link0
+Enable the filtering of Ethernet frames destined for the TPMR
+component reserved addresses, as specified by IEEE 802.1Q.
+This is the default.
+.It Cm link1
+Disable the filtering of IPv4 and IPv6 packets with
+.Xr pf 4 .
+.It Cm -link1
+Enable the filtering of IPv4 and IPv6 packets with
+.Xr pf 4 .
+Packets will appear to enter or leave the member port interfaces.
+This is the default.
+.It Cm link2
+Disable the filtering of 802.1Q VLAN and QinQ SVLAN packets.
+.It Cm -link2
+Enable the filtering of 802.1Q VLAN and QinQ SVLAN packets.
+.Xr pf 4 .
+Packets will appear to enter or leave the member port interfaces.
+This is the default.
 .El
 .Sh CARP
 .nr nS 1
Index: share/man/man4/tpmr.4
===
RCS file: /cvs/src/share/man/man4/tpmr.4,v
retrieving revision 1.6
diff -u -p -r1.6 tpmr.4
--- share/man/man4/tpmr.4   22 Jul 2020 04:08:46 -  1.6
+++ share/man/man4/tpmr.4   5 Aug 2020 06:58:58 -
@@ -40,48 +40,6 @@ command or by setting up a
 .Xr hostname.if 5
 configuration file for
 .Xr netstart 8 .
-The interface itself can be configured with
-.Xr ifconfig 8 ;
-see its manual page for more information.
-.Pp
-.Nm
-interfaces may be configured with
-.Xr ifconfig 8
-and
-.Xr netstart 8
-using the following options:
-.Bl -tag -width Ds
-.It Cm add Ar child-iface
-Add
-.Ar child-iface
-as a member.
-.It Cm del Ar child-iface
-Remove the member
-.Ar child-iface .
-.It Cm link0
-Disable the filtering of Ethernet frames destined for the TPMR
-component reserved addresses, as specified by IEEE 802.1Q.
-.It Cm -link0
-Enable the filtering of Ethernet frames destined for the TPMR
-component reserved addresses, as specified by IEEE 802.1Q.
-This is the default.
-.It Cm link1
-Disable the filtering of IPv4 and IPv6 packets with
-.Xr pf 4 .
-.It Cm -link1
-Enable the filtering of IPv4 and IPv6 packets with
-.Xr pf 4 .
-Packets will appear to enter or leave the member port interfaces.
-This is the default.
-.It Cm link2
-Disable the filtering of 802.1Q VLAN and QinQ SVLAN packets.
-.It Cm -link2
-Enable the filtering of 802.1Q VLAN and QinQ SVLAN packets.
-.Xr pf 4 .
-Packets will appear to enter or leave the member port interfaces.
-This is the default.
-.El
-.\" document the ioctls?
 .Pp
 Other forms of Ethernet bridging are available using the
 .Xr bridge 4
@@ -92,6 +50,20 @@ using the
 and
 .Xr trunk 4
 drivers.
+.Sh IOCTLS
+The following
+.Xr ioctl 2
+calls and their structures are commonly use by
+.Nm
+and
+.Xr bridge 4 :
+.Pp
+.Bl -bullet -offset indent -compact
+.It
+.Dv SIOCBRDGADD
+.It
+.Dv SIOCBRDGDEL
+.El
 .Sh EXAMPLES
 .Nm
 can be used to cross-connect Ethernet devices that support different



Re: switch: allow datapath_id and maxflow ioctls for non-root

2020-08-05 Thread Klemens Nanni
On Wed, Aug 05, 2020 at 11:00:00AM +1000, David Gwynne wrote:
> can't they be caught by the default case now?
Obviously...


Index: net/if.c
===
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.617
diff -u -p -r1.617 if.c
--- net/if.c4 Aug 2020 09:32:05 -   1.617
+++ net/if.c5 Aug 2020 06:24:33 -
@@ -2163,9 +2163,7 @@ ifioctl(struct socket *so, u_long cmd, c
case SIOCBRDGSIFCOST:
case SIOCBRDGSTXHC:
case SIOCBRDGSPROTO:
-   case SIOCSWGDPID:
case SIOCSWSPORTNO:
-   case SIOCSWGMAXFLOW:
 #endif
if ((error = suser(p)) != 0)
break;