makefs: malloc -> emalloc

2017-10-31 Thread Michael W. Bombardieri
Hello,

makefs has an xmalloc.c with emalloc() function, but one thing
was still using malloc() directly. This patch makes malloc()
always happen through emalloc().

- Michael


Index: msdos/mkfs_msdos.c
===
RCS file: /cvs/src/usr.sbin/makefs/msdos/mkfs_msdos.c,v
retrieving revision 1.4
diff -u -p -u -r1.4 mkfs_msdos.c
--- msdos/mkfs_msdos.c  28 Mar 2017 00:08:39 -  1.4
+++ msdos/mkfs_msdos.c  1 Nov 2017 02:58:21 -
@@ -592,8 +592,7 @@ mkfs_msdos(const char *fname, const char
 gettimeofday(&tv, NULL);
 now = tv.tv_sec;
 tm = localtime(&now);
-if (!(img = malloc(bpb.bps)))
-err(1, NULL);
+img = emalloc(bpb.bps);
 dir = bpb.res + (bpb.spf ? bpb.spf : bpb.bspf) * bpb.nft;
 signal(SIGINFO, infohandler);
 for (lsn = 0; lsn < dir + (o.fat_type == 32 ? bpb.spc : rds); lsn++) {



wsconscfg(8): ioctl request macros

2017-10-31 Thread Anton Lindqvist
Hi,
Use the actual ioctl request macros instead of relying on compatibility
indirection.

Looks like wsconscfg(8) is the last consumer of the compat macros
defined in dev/wscons/wsconsio.h. Assuming there's no usage in ports,
now might be the time to zap them?

Comments? OK?

Index: wsconscfg.c
===
RCS file: /cvs/src/usr.sbin/wsconscfg/wsconscfg.c,v
retrieving revision 1.15
diff -u -p -r1.15 wsconscfg.c
--- wsconscfg.c 23 Aug 2017 09:15:33 -  1.15
+++ wsconscfg.c 31 Oct 2017 11:16:47 -
@@ -125,13 +125,13 @@ main(int argc, char *argv[])
wmd.type = WSMUX_KBD;
wmd.idx = idx;
if (delete) {
-   res = ioctl(wsfd, WSMUX_REMOVE_DEVICE, &wmd);
+   res = ioctl(wsfd, WSMUXIO_REMOVE_DEVICE, &wmd);
if (res < 0)
-   err(3, "WSMUX_REMOVE_DEVICE");
+   err(3, "WSMUXIO_REMOVE_DEVICE");
} else {
-   res = ioctl(wsfd, WSMUX_ADD_DEVICE, &wmd);
+   res = ioctl(wsfd, WSMUXIO_ADD_DEVICE, &wmd);
if (res < 0)
-   err(3, "WSMUX_ADD_DEVICE");
+   err(3, "WSMUXIO_ADD_DEVICE");
}
} else if (delete) {
dsd.idx = idx;



Re: add one more softnet taskq

2017-10-31 Thread Peter Hessler
reads fine, and works for me in light testing.

OK phessler@


On 2017 Oct 30 (Mon) at 08:36:34 +0100 (+0100), Alexandr Nedvedicky wrote:
:Hello,
:
:patch below adds additional softnet taskq. This will allow certain degree of
:parallelism for packet processing in pf_test(). The current plan is to let
:packets received by even NICs (even ifindex) to be processed by task0, packets
:received by odd NICs (odd ifindex) by task1.
:
:big thanks should go to mpi@, who 'programmed' me to program the patch below.
:
:OK?
:
:thanks and
:regards
:sasha
:
:8<---8<---8<--8<
:diff --git a/sys/net/if.c b/sys/net/if.c
:index e9e9f07add1..d688456b677 100644
:--- a/sys/net/if.c
:+++ b/sys/net/if.c
:@@ -224,7 +224,9 @@ intnet_livelocked(void);
: int   ifq_congestion;
: 
: intnetisr;
:-struct taskq  *softnettq;
:+
:+#define   SOFTNET_TASKS   2
:+struct taskq  *softnettq[SOFTNET_TASKS];
: 
: struct task if_input_task_locked = TASK_INITIALIZER(if_netisr, NULL);
: 
:@@ -240,6 +242,8 @@ struct rwlock netlock = RWLOCK_INITIALIZER("netlock");
: void
: ifinit(void)
: {
:+  unsigned inti;
:+
:   /*
:* most machines boot with 4 or 5 interfaces, so size the initial map
:* to accomodate this
:@@ -248,9 +252,11 @@ ifinit(void)
: 
:   timeout_set(&net_tick_to, net_tick, &net_tick_to);
: 
:-  softnettq = taskq_create("softnet", 1, IPL_NET, TASKQ_MPSAFE);
:-  if (softnettq == NULL)
:-  panic("unable to create softnet taskq");
:+  for (i = 0; i < SOFTNET_TASKS; i++) {
:+  softnettq[i] = taskq_create("softnet", 1, IPL_NET, 
TASKQ_MPSAFE);
:+  if (softnettq[i] == NULL)
:+  panic("unable to create softnet taskq");
:+  }
: 
:   net_tick(&net_tick_to);
: }
:@@ -725,7 +731,7 @@ if_input(struct ifnet *ifp, struct mbuf_list *ml)
: #endif
: 
:   if (mq_enlist(&ifp->if_inputqueue, ml) == 0)
:-  task_add(softnettq, ifp->if_inputtask);
:+  task_add(net_tq(ifp->if_index), ifp->if_inputtask);
: }
: 
: int
:@@ -1025,15 +1031,15 @@ if_detach(struct ifnet *ifp)
:   ifp->if_watchdog = NULL;
: 
:   /* Remove the input task */
:-  task_del(softnettq, ifp->if_inputtask);
:+  task_del(net_tq(ifp->if_index), ifp->if_inputtask);
:   mq_purge(&ifp->if_inputqueue);
: 
:   /* Remove the watchdog timeout & task */
:   timeout_del(ifp->if_slowtimo);
:-  task_del(softnettq, ifp->if_watchdogtask);
:+  task_del(net_tq(ifp->if_index), ifp->if_watchdogtask);
: 
:   /* Remove the link state task */
:-  task_del(softnettq, ifp->if_linkstatetask);
:+  task_del(net_tq(ifp->if_index), ifp->if_linkstatetask);
: 
: #if NBPFILTER > 0
:   bpfdetach(ifp);
:@@ -1583,7 +1589,7 @@ if_linkstate(struct ifnet *ifp)
: void
: if_link_state_change(struct ifnet *ifp)
: {
:-  task_add(softnettq, ifp->if_linkstatetask);
:+  task_add(net_tq(ifp->if_index), ifp->if_linkstatetask);
: }
: 
: /*
:@@ -1599,7 +1605,7 @@ if_slowtimo(void *arg)
: 
:   if (ifp->if_watchdog) {
:   if (ifp->if_timer > 0 && --ifp->if_timer == 0)
:-  task_add(softnettq, ifp->if_watchdogtask);
:+  task_add(net_tq(ifp->if_index), ifp->if_watchdogtask);
:   timeout_add(ifp->if_slowtimo, hz / IFNET_SLOWHZ);
:   }
:   splx(s);
:@@ -2881,3 +2887,13 @@ unhandled_af(int af)
: {
:   panic("unhandled af %d", af);
: }
:+
:+struct taskq *
:+net_tq(unsigned int ifindex)
:+{
:+  struct taskq *t = NULL;
:+
:+  t = softnettq[ifindex % SOFTNET_TASKS];
:+
:+  return (t);
:+}
:diff --git a/sys/net/if.h b/sys/net/if.h
:index 89867eac340..6a0770a8ea0 100644
:--- a/sys/net/if.h
:+++ b/sys/net/if.h
:@@ -489,6 +489,7 @@ void   if_congestion(void);
: int   if_congested(void);
: __dead void   unhandled_af(int);
: int   if_setlladdr(struct ifnet *, const uint8_t *);
:+struct taskq * net_tq(unsigned int);
: 
: #endif /* _KERNEL */
: 
:diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
:index 277e7f966a2..e9f58a4ee52 100644
:--- a/sys/net/if_loop.c
:+++ b/sys/net/if_loop.c
:@@ -244,7 +244,7 @@ looutput(struct ifnet *ifp, struct mbuf *m, struct 
sockaddr *dst,
:   m->m_pkthdr.ph_family = dst->sa_family;
:   if (mq_enqueue(&ifp->if_inputqueue, m))
:   return ENOBUFS;
:-  task_add(softnettq, ifp->if_inputtask);
:+  task_add(net_tq(ifp->if_index), ifp->if_inputtask);
: 
:   return (0);
: }
:diff --git a/sys/net/if_pflow.c b/sys/net/if_pflow.c
:index 38efb02be7e..91a61fe4c15 100644
:--- a/sys/net/if_pflow.c
:+++ b/sys/net/if_pflow.c
:@@ -286,7 +286,7 @@ pflow_clone_destroy(struct ifnet *ifp)
:   if (timeout_initialized(&sc->sc_tmo_tmpl))
:   timeout_del(&sc->sc_tmo_tmpl);
:   pflow_flush(sc);
:-  task_del(softnettq, &sc->sc_outputtask);
:+  task_del(net_tq(ifp->if_index), &sc->sc_outputtask);
:   mq_purge(&sc->sc_outputqueue);
:  

Re: document capability dc in remote(5)

2017-10-31 Thread Nicholas Marriott
IIRC dc was removed and then added back.

ok nicm



On Mon, Oct 30, 2017 at 11:44:28PM +0100, Remi Locherer wrote:
> Hi,
> 
> in 2015 remote(5) was trimmed down when tip was removed. It looks like
> documentation for capability "dc" was also removed by accident. cu(1) still
> supports this (src/usr.bin/cu/cu.c):
> 
> 381 if (is_direct == -1 && cgetcap(cp, "dc", ':') != NULL)
> 382 is_direct = 1;
> 
> Below patch brings back documentation for "dc".
> 
> ok?
> 
> Remi
> 
> 
> Index: remote.5
> ===
> RCS file: /cvs/src/share/man/man5/remote.5,v
> retrieving revision 1.26
> diff -u -p -r1.26 remote.5
> --- remote.5  21 Sep 2017 07:51:43 -  1.26
> +++ remote.5  30 Oct 2017 22:39:44 -
> @@ -75,6 +75,12 @@ The baud rate used in establishing
>  a connection to the remote host.
>  This is a decimal number.
>  The default baud rate is 9600 baud.
> +.It Sy \&dc
> +(bool)
> +This host is directly connected, and
> +.Xr cu 1
> +should not expect carrier detect to be high, nor should it exit if
> +carrier detect drops.
>  .It Sy \&dv
>  (str)
>  Device to open to establish a connection.



Re: add one more softnet taskq

2017-10-31 Thread Martin Pieuchot
On 31/10/17(Tue) 06:56, Alexandr Nedvedicky wrote:
> Hello,
> 
> just in case there is yet another brave soul running the diff below:
> 
> Hrvoje has managed to trip the ASSERT() in ip_send() function at
> line 1843. I assume the ip6_send() is prone to same error.
> 
> I'll try to figure out what's going on and send updated diff shortly.
> 
> Big thanks to Hrvoje for hitting the problem before the change made it to 
> tree.

Could you please revert that to the original version you sent?  Using
net_tq(0)?  Then we have all the time we want to figure out.



Re: add one more softnet taskq

2017-10-31 Thread Alexandr Nedvedicky
Hello,

On Tue, Oct 31, 2017 at 09:29:10AM +0100, Martin Pieuchot wrote:
> On 31/10/17(Tue) 06:56, Alexandr Nedvedicky wrote:
> > Hello,
> > 
> > just in case there is yet another brave soul running the diff below:
> > 
> > Hrvoje has managed to trip the ASSERT() in ip_send() function at
> > line 1843. I assume the ip6_send() is prone to same error.
> > 
> > I'll try to figure out what's going on and send updated diff shortly.
> > 
> > Big thanks to Hrvoje for hitting the problem before the change made it to 
> > tree.
> 
> Could you please revert that to the original version you sent?  Using
> net_tq(0)?  Then we have all the time we want to figure out.

O.K. I'll commit the original diff later today, once I'll be back home.

regards
sasha