Re: relayd(8): transparent forward

2019-11-06 Thread mp1009




On 2019-11-06 08:25, Stuart Henderson wrote:

On 2019/11/05 20:46, Mischa Peters wrote:

When you are using transparent (Direct Server Return) you have to make sure you 
disable ARP on the servers you are load balancing.


Transparent is not "direct server return", that is done with "route to".


What happens with transparant is that the server gets the client IP as source, 
not the IP of relayd, and will respond directly to the client from its own IP 
address. The client is expecting a response from the relayd IP address and 
doesn’t respond to the server.


The client is expecting a response from the address it sent packets to,
"transparent" doesn't interfere with this.

There is something fiddly with the config for "transparent" but it should
be possible to do what OP wants if relayd is on a machine on the network
path between client and destination (e.g. on a firewall/router).




relayd is on the same machine (on lo0:8443) as the destination (httpd on
re0:443). Any ideas what might be missing?



un-boolean_t ddb(4) for arm64 & mips64

2019-11-06 Thread Martin Pieuchot
Ok?

Index: arch/arm64/arm64/db_disasm.c
===
RCS file: /cvs/src/sys/arch/arm64/arm64/db_disasm.c,v
retrieving revision 1.1
diff -u -p -r1.1 db_disasm.c
--- arch/arm64/arm64/db_disasm.c17 Dec 2016 23:38:33 -  1.1
+++ arch/arm64/arm64/db_disasm.c5 Nov 2019 16:09:20 -
@@ -23,7 +23,7 @@
 #include 
 
 vaddr_t
-db_disasm(vaddr_t loc, boolean_t altfmt)
+db_disasm(vaddr_t loc, int altfmt)
 {
return loc + 4;
 }
Index: arch/arm64/arm64/db_interface.c
===
RCS file: /cvs/src/sys/arch/arm64/arm64/db_interface.c,v
retrieving revision 1.6
diff -u -p -r1.6 db_interface.c
--- arch/arm64/arm64/db_interface.c 23 Mar 2019 05:47:22 -  1.6
+++ arch/arm64/arm64/db_interface.c 5 Nov 2019 16:10:14 -
@@ -105,7 +105,7 @@ struct db_variable db_regs[] = {
 struct db_mutex ddb_mp_mutex = DB_MUTEX_INITIALIZER;
 volatile int ddb_state = DDB_STATE_NOT_RUNNING;
 volatile cpuid_t ddb_active_cpu;
-boolean_tdb_switch_cpu;
+int db_switch_cpu;
 long db_switch_to_cpu;
 
 void db_cpuinfo_cmd(db_expr_t, int, db_expr_t, char *);
@@ -156,9 +156,9 @@ kdb_trap(int type, db_regs_t *regs)
 
s = splhigh();
db_active++;
-   cnpollc(TRUE);
+   cnpollc(1);
db_trap(type, 0/*code*/);
-   cnpollc(FALSE);
+   cnpollc(0);
db_active--;
splx(s);
 
@@ -189,7 +189,7 @@ db_validate_address(vaddr_t addr)
else
pmap = p->p_vmspace->vm_map.pmap;
 
-   return (pmap_extract(pmap, addr, NULL) == FALSE);
+   return (pmap_extract(pmap, addr, NULL) == 0);
 }
 
 /*
Index: arch/arm64/arm64/db_trace.c
===
RCS file: /cvs/src/sys/arch/arm64/arm64/db_trace.c,v
retrieving revision 1.6
diff -u -p -r1.6 db_trace.c
--- arch/arm64/arm64/db_trace.c 4 May 2018 15:43:34 -   1.6
+++ arch/arm64/arm64/db_trace.c 5 Nov 2019 16:09:47 -
@@ -68,15 +68,15 @@ db_stack_trace_print(db_expr_t addr, int
db_expr_t   offset;
Elf_Sym *   sym;
char*name;
-   boolean_t   kernel_only = TRUE;
-   boolean_t   trace_thread = FALSE;
+   int kernel_only = 1;
+   int trace_thread = 0;
//db_addr_t scp = 0;
 
while ((c = *cp++) != 0) {
if (c == 'u')
-   kernel_only = FALSE;
+   kernel_only = 0;
if (c == 't')
-   trace_thread = TRUE;
+   trace_thread = 1;
}
 
if (!have_addr) {
Index: arch/mips64/include/db_machdep.h
===
RCS file: /cvs/src/sys/arch/mips64/include/db_machdep.h,v
retrieving revision 1.18
diff -u -p -r1.18 db_machdep.h
--- arch/mips64/include/db_machdep.h23 Mar 2019 05:47:23 -  1.18
+++ arch/mips64/include/db_machdep.h6 Nov 2019 07:38:29 -
@@ -43,7 +43,7 @@ typedef vaddr_t   db_addr_t;
 
 #defineSOFTWARE_SSTEP  /* Need software single step */
 #defineSOFTWARE_SSTEP_EMUL /* next_instr_address() emulates 100% */
-db_addr_t  next_instr_address(db_addr_t, boolean_t);
+db_addr_t  next_instr_address(db_addr_t, int);
 #defineBKPT_SIZE   (4)
 #defineBKPT_SET(ins)   (BREAK_DDB)
 #defineDB_VALID_BREAKPOINT(addr)   (((addr) & 3) == 0)
Index: arch/mips64/mips64/db_disasm.c
===
RCS file: /cvs/src/sys/arch/mips64/mips64/db_disasm.c,v
retrieving revision 1.17
diff -u -p -r1.17 db_disasm.c
--- arch/mips64/mips64/db_disasm.c  23 Sep 2015 17:03:27 -  1.17
+++ arch/mips64/mips64/db_disasm.c  6 Nov 2019 07:39:47 -
@@ -1016,7 +1016,7 @@ loadstore:
 
 #ifdef _KERNEL
 db_addr_t
-db_disasm(db_addr_t loc, boolean_t altfmt)
+db_disasm(db_addr_t loc, int altfmt)
 {
extern uint32_t kdbpeek(vaddr_t);
 
Index: arch/mips64/mips64/db_machdep.c
===
RCS file: /cvs/src/sys/arch/mips64/mips64/db_machdep.c,v
retrieving revision 1.53
diff -u -p -r1.53 db_machdep.c
--- arch/mips64/mips64/db_machdep.c 2 Sep 2019 02:35:33 -   1.53
+++ arch/mips64/mips64/db_machdep.c 6 Nov 2019 07:39:48 -
@@ -72,7 +72,7 @@ void db_dump_tlb_cmd(db_expr_t, int, db_
 struct db_mutex ddb_mp_mutex = DB_MUTEX_INITIALIZER;
 volatile int ddb_state = DDB_STATE_NOT_RUNNING;
 volatile cpuid_t ddb_active_cpu;
-boolean_tdb_switch_cpu;
+int db_switch_cpu;
 long db_switch_to_cpu;
 #endif
 
@@ -133,7 +133,7 @@ db_ktrap(int type, struct trapframe *fp)
 {
switch(type) {
case T_BREAK:   /* breakpoint */
-   if (db_get_value((fp)->pc, sizeof(int), FALSE) == BREAK_SOVER) {
+ 

ANSIfy & un-boolean_t alpha ddb(4)

2019-11-06 Thread Martin Pieuchot
ok?

Index: arch/alpha/alpha/db_disasm.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/db_disasm.c,v
retrieving revision 1.23
diff -u -p -r1.23 db_disasm.c
--- arch/alpha/alpha/db_disasm.c27 Apr 2016 11:03:24 -  1.23
+++ arch/alpha/alpha/db_disasm.c6 Nov 2019 07:46:53 -
@@ -823,12 +823,10 @@ register_name (ireg)
  * (optional) alternate format.  Return address of start of
  * next instruction.
  */
-intalpha_print_instruction(db_addr_t, alpha_instruction, boolean_t);
+intalpha_print_instruction(db_addr_t, alpha_instruction, int);
 
 db_addr_t
-db_disasm(loc, altfmt)
-   db_addr_t   loc;
-   boolean_t   altfmt;
+db_disasm(db_addr_t loc, int altfmt)
 {
alpha_instruction inst;
 
@@ -839,20 +837,17 @@ db_disasm(loc, altfmt)
 }
 
 int
-alpha_print_instruction(iadr, i, showregs)
-   db_addr_t   iadr;
-   alpha_instruction i;
-   boolean_t   showregs;
+alpha_print_instruction(db_addr_t iadr, alpha_instruction i, int showregs)
 {
const char  *opcode;
int ireg;
longsigned_immediate;
-   boolean_t   fstore;
+   int fstore;
pal_instruction p;
chartmpfmt[28];
 
regcount = 0;
-   fstore = FALSE;
+   fstore = 0;
opcode = op_name[i.mem_format.opcode];
 
/*
@@ -1021,7 +1016,7 @@ foperate:
case op_stg:
case op_sts:
case op_stt:
-   fstore = TRUE;
+   fstore = 1;
/* FALLTHROUGH */
case op_ldl:
case op_ldq:
Index: arch/alpha/alpha/db_interface.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/db_interface.c,v
retrieving revision 1.24
diff -u -p -r1.24 db_interface.c
--- arch/alpha/alpha/db_interface.c 20 Mar 2018 15:45:32 -  1.24
+++ arch/alpha/alpha/db_interface.c 6 Nov 2019 07:46:34 -
@@ -167,11 +167,11 @@ ddb_trap(a0, a1, a2, entry, regs)
s = splhigh();
 
db_active++;
-   cnpollc(TRUE);  /* Set polling mode, unblank video */
+   cnpollc(1); /* Set polling mode, unblank video */
 
db_trap(entry, a0); /* Where the work happens */
 
-   cnpollc(FALSE); /* Resume interrupt mode */
+   cnpollc(0); /* Resume interrupt mode */
db_active--;
 
splx(s);
@@ -286,9 +286,8 @@ db_register_value(regs, regno)
  * Support functions for software single-step.
  */
 
-boolean_t
-db_inst_call(ins)
-   int ins;
+int
+db_inst_call(int ins)
 {
alpha_instruction insn;
 
@@ -298,9 +297,8 @@ db_inst_call(ins)
 (insn.jump_format.action & 1)));
 }
 
-boolean_t
-db_inst_return(ins)
-   int ins;
+int
+db_inst_return(int ins)
 {
alpha_instruction insn;
 
@@ -309,9 +307,8 @@ db_inst_return(ins)
(insn.jump_format.action == op_ret));
 }
 
-boolean_t
-db_inst_trap_return(ins)
-   int ins;
+int
+db_inst_trap_return(int ins)
 {
alpha_instruction insn;
 
@@ -320,9 +317,8 @@ db_inst_trap_return(ins)
(insn.pal_format.function == PAL_OSF1_rti));
 }
 
-boolean_t
-db_inst_branch(ins)
-   int ins;
+int
+db_inst_branch(int ins)
 {
alpha_instruction insn;
 
@@ -344,15 +340,14 @@ db_inst_branch(ins)
case op_bne:
case op_bge:
case op_bgt:
-   return (TRUE);
+   return 1;
}
 
-   return (FALSE);
+   return 0;
 }
 
-boolean_t
-db_inst_unconditional_flow_transfer(ins)
-   int ins;
+int
+db_inst_unconditional_flow_transfer(int ins)
 {
alpha_instruction insn;
 
@@ -360,62 +355,48 @@ db_inst_unconditional_flow_transfer(ins)
switch (insn.branch_format.opcode) {
case op_j:
case op_br:
-   return (TRUE);
+   return 1;
 
case op_pal:
switch (insn.pal_format.function) {
case PAL_OSF1_retsys:
case PAL_OSF1_rti:
case PAL_OSF1_callsys:
-   return (TRUE);
+   return 1;
}
}
 
-   return (FALSE);
+   return 0;
 }
 
-#if 0
-boolean_t
-db_inst_spill(ins, regn)
-   int ins, regn;
+int
+db_inst_load(int ins)
 {
alpha_instruction insn;
 
insn.bits = ins;
-   return ((insn.mem_format.opcode == op_stq) &&
-   (insn.mem_format.rd == regn));
-}
-#endif
 
-boolean_t
-db_inst_load(ins)
-   int ins;
-{
-   alpha_instruction insn;
-
-   insn.bits = ins;
-   
/* Loads. */
if (insn.mem_format.opcode == op_ldbu ||
insn.mem_format.opcode == op_ldq_u ||
insn.mem_format.opcode == op_ldwu)
-   return (TRUE);
+   return 1;
if ((insn.mem_format.opcode >= op_ldf) &&
(insn.mem_format.opcode <= op_ldt))
-

Re: [rpki-client] Patch submission (tal.c)

2019-11-06 Thread Claudio Jeker
On Tue, Nov 05, 2019 at 01:57:09PM -0300, Alexandre Hamada wrote:
> Hi Claudio.
> 
> FYI, I've added some support for https. Not sure if this might be useful,
> but here is the code for ta_parse_buffer.
> 
> I´ve also modified tal_parse to display a warn message instead of exiting on
> invalid basename.

I decided to currently ignore https URI and just print a warn message.
The code needs some major change so that multiple URI are correclty
supported (which is currently not the case) and that https:// would be
preferred. First of all the process responsible for fetching repos needs
to learn about https://. Then I think rsync_uri_parse() needs to be
reworked. At that point it may be possible to add https:// support to that
function and make it a generic URI parser.

Thanks for the diff anyway.
-- 
:wq Claudio
 
> Regards,
> Alexandre Hamada
> 
> static int
> https_uri_parse(const char **hostp, size_t *hostsz,
>     const char **pathp, size_t *pathsz,
>     enum rtype *rtypep, const char *uri)
> {
>     const char    *host, *path;
>     size_t         sz;
> 
>     /* Initialise all output values to NULL or 0. */
> 
>     if (hostsz != NULL)
>         *hostsz = 0;
>     if (pathsz != NULL)
>         *pathsz = 0;
>     if (hostp != NULL)
>         *hostp = 0;
>     if (pathp != NULL)
>         *pathp = 0;
>     if (rtypep != NULL)
>         *rtypep = RTYPE_EOF;
> 
>     /* Case-insensitive https URI. */
>     if (strncasecmp(uri, "https://";, 8)) {
>         warnx("%s: not using https schema", uri);
>         return 0;
>     }
> 
>     /* Parse the non-zero-length hostname. */
> 
>     host = uri + 8;
> 
>     if ((path = strchr(host, '/')) == NULL) {
>         warnx("%s: missing https path", uri);
>         return 0;
>     } else if (path == host) {
>         warnx("%s: zero-length https path", uri);
>         return 0;
>     }
> 
>     if (hostp != NULL)
>         *hostp = host;
>     if (hostsz != NULL)
>         *hostsz = path - host;
> 
>     path++;
>     sz = strlen(path);
> 
>     if (pathp != NULL)
>         *pathp = path;
>     if (pathsz != NULL)
>         *pathsz = sz;
> 
>     if (rtypep != NULL && sz > 4) {
>         if (strcasecmp(path + sz - 4, ".roa") == 0)
>             *rtypep = RTYPE_ROA;
>         else if (strcasecmp(path + sz - 4, ".mft") == 0)
>             *rtypep = RTYPE_MFT;
>         else if (strcasecmp(path + sz - 4, ".cer") == 0)
>             *rtypep = RTYPE_CER;
>         else if (strcasecmp(path + sz - 4, ".crl") == 0)
>             *rtypep = RTYPE_CRL;
>     }
> 
>     return 1;
> }
> 
> /*
>  * Inner function for parsing RFC 7730 from a buffer.
>  * Returns a valid pointer on success, NULL otherwise.
>  * The pointer must be freed with tal_free().
>  */
> static struct tal *
> tal_parse_buffer(const char *fn, char *buf)
> {
>     char        *nl, *line;
>     unsigned char    *b64 = NULL;
>     size_t         sz;
>     int         rc = 0, b64sz;
>     struct tal    *tal = NULL;
>     enum rtype     rp;
>     EVP_PKEY    *pkey = NULL;
> 
>     if ((tal = calloc(1, sizeof(struct tal))) == NULL)
>         err(EXIT_FAILURE, NULL);
> 
>     /* Begin with the URI section, comment section already removed. */
>     while ((nl = strchr(buf, '\n')) != NULL) {
>         line = buf;
>         *nl = '\0';
> 
>         /* advance buffer to next line */
>         buf = nl + 1;
> 
>         /* Zero-length line is end of section. */
>         if (*line == '\0')
>             break;
> 
>         /* Append to list of URIs. */
>         tal->uri = reallocarray(tal->uri,
>             tal->urisz + 1, sizeof(char *));
>         if (tal->uri == NULL)
>             err(EXIT_FAILURE, NULL);
> 
>         tal->uri[tal->urisz] = strdup(line);
>         if (tal->uri[tal->urisz] == NULL)
>             err(EXIT_FAILURE, NULL);
>         tal->urisz++;
> 
>         /* Make sure we're a proper rsync/https URI. */
>         if (strncasecmp(line, "https://";, 8) == 0) {
>             if (!https_uri_parse(NULL, NULL, NULL, NULL, &rp, line)) {
>                 warnx("%s: RFC 8630 section 2.2: "
>                     "failed to parse URL: %s", fn, line);
>                 goto out;
>             }
>         } else if (!rsync_uri_parse(NULL, NULL, NULL, NULL, NULL, NULL, &rp,
> line)) {
>             warnx("%s: RFC 8630 section 2.2: "
>                 "failed to parse URL: %s", fn, line);
>             goto out;
>         }
>         if (rp != RTYPE_CER) {
>             warnx("%s: RFC 7730 section 2.1: "
>                 "not a certificate URL: %s", fn, line);
>             goto out;
>         }
> 
>     }
> 
>     if (tal->urisz == 0) {
>         warnx("%s: no URIs in manifest part", fn);
>         goto out;
>     } else if (tal->urisz > 1)
>         warnx("%s: multiple URIs: using the first", fn);
> 
>     sz = strlen(buf);
>     if (sz == 0) {
>         warnx("%s: RFC 7730 section 2.1: subjectPublicKeyInfo: "
>             "zero-length public key", fn);
>         goto out;
>     }
> 
>     /* Now the BASE64-en

Re: ntpd is too noisy about 'DNS lookup tempfail' on IPv6 only hosts

2019-11-06 Thread Florian Obser
On Wed, Nov 06, 2019 at 08:46:16AM +0100, Peter J. Philipp wrote:
> Hi,
> 
> I have an IPv6 only host arrowhead.ip6.centroid.eu, that has very noisy:
>  
> Oct 29 09:12:48 arrowhead ntpd[18744]: DNS lookup tempfail
> Oct 29 09:21:45 arrowhead last message repeated 2 times
> 
> in fact:
> 
> arrowhead# grep 'DNS lookup tempfail' /var/log/daemon | wc -l
> 1354
> 
> This is because the pool.ntp.org servers as configured don't give back 
> answers.  I'm trying to streamline this a little and only ask for  queries
> if there is no v4 connectivity.  With change of the 'stdio dns' pledge to
> 'stdio inet dns' this is possible, when using another constraint from google.
> There is no network traffic, just a route lookup if IPv4 is possible at all.
> 
> Here is my patch, under my sig.
> 
> -peter
> 
> Index: config.c
> ===
> RCS file: /cvs/src/usr.sbin/ntpd/config.c,v
> retrieving revision 1.32
> diff -u -p -u -r1.32 config.c
> --- config.c  7 Jul 2019 07:14:57 -   1.32
> +++ config.c  6 Nov 2019 07:36:07 -
> @@ -30,8 +30,9 @@
>  
>  #include "ntpd.h"
>  
> -struct ntp_addr  *host_ip(const char *);
> -int   host_dns1(const char *, struct ntp_addr **, int);
> +struct ntp_addr  *host_ip(const char *);
> +int  host_dns1(const char *, struct ntp_addr **, int);
> +static int   test_v4_gw(void);
>  
>  static u_int32_t  maxid = 0;
>  static u_int32_t  constraint_maxid = 0;
> @@ -59,7 +60,7 @@ host_ip(const char *s)
>   struct ntp_addr *h = NULL;
>  
>   memset(&hints, 0, sizeof(hints));
> - hints.ai_family = AF_UNSPEC;
> + hints.ai_family = (test_v4_gw() == 0) ? AF_UNSPEC : AF_INET6;
>   hints.ai_socktype = SOCK_DGRAM; /*dummy*/
>   hints.ai_flags = AI_NUMERICHOST;
>   if (getaddrinfo(s, "0", &hints, &res) == 0) {
> @@ -94,7 +95,7 @@ host_dns1(const char *s, struct ntp_addr
>   struct ntp_addr *h, *hh = NULL;
>  
>   memset(&hints, 0, sizeof(hints));
> - hints.ai_family = AF_UNSPEC;
> + hints.ai_family = (test_v4_gw() == 0) ? AF_UNSPEC : AF_INET6;
>   hints.ai_socktype = SOCK_DGRAM; /* DUMMY */
>   hints.ai_flags = AI_ADDRCONFIG;

you just implemented a variation of AI_ADDRCONFIG

>   error = getaddrinfo(s, NULL, &hints, &res0);
> @@ -181,3 +182,28 @@ new_constraint(void)
>   return (p);
>  }
>  
> +static int
> +test_v4_gw(void)
> +{
> + struct sockaddr_in sin;
> + socklen_t st = sizeof(struct sockaddr_in);
> + int so;
> +
> + so = socket(AF_INET, SOCK_DGRAM, 0);
> + if (so < 0) {
> + return 0;
> + }
> +
> + memset(&sin, 0, sizeof(sin));
> + sin.sin_family = AF_INET;
> + sin.sin_addr.s_addr = inet_addr(CONN_CONSTRAINT);
> + sin.sin_port = htons(53);
> + 
> + if (connect(so, (struct sockaddr *)&sin, st) < 0) {
> + close(so);
> + return 0;
> + }
> +
> + close(so);
> + return 1;
> +}
> Index: ntp_dns.c
> ===
> RCS file: /cvs/src/usr.sbin/ntpd/ntp_dns.c,v
> retrieving revision 1.24
> diff -u -p -u -r1.24 ntp_dns.c
> --- ntp_dns.c 27 Jun 2019 15:18:42 -  1.24
> +++ ntp_dns.c 6 Nov 2019 07:36:07 -
> @@ -98,7 +98,7 @@ ntp_dns(struct ntpd_conf *nconf, struct 
>   fatal(NULL);
>   imsg_init(ibuf_dns, PARENT_SOCK_FILENO);
>  
> - if (pledge("stdio dns", NULL) == -1)
> + if (pledge("stdio inet dns", NULL) == -1)
>   err(1, "pledge");
>  
>   probe_root();
> @@ -170,7 +170,7 @@ dns_dispatch_imsg(struct ntpd_conf *ncon
>   strlen(name) != len)
>   fatalx("invalid %s received", str);
>   if ((cnt = host_dns(name, nconf->status.synced,
> - &hn)) == -1)
> + &hn)) <= 0)

... and this change silences your warnings.

>   break;
>   buf = imsg_create(ibuf_dns, imsg.hdr.type,
>   imsg.hdr.peerid, 0,
> Index: ntpd.h
> ===
> RCS file: /cvs/src/usr.sbin/ntpd/ntpd.h,v
> retrieving revision 1.146
> diff -u -p -u -r1.146 ntpd.h
> --- ntpd.h16 Jul 2019 14:15:40 -  1.146
> +++ ntpd.h6 Nov 2019 07:36:07 -
> @@ -40,6 +40,7 @@
>  #define  CONFFILE"/etc/ntpd.conf"
>  #define DRIFTFILE"/var/db/ntpd.drift"
>  #define  CTLSOCKET   "/var/run/ntpd.sock"
> +#define CONN_CONSTRAINT  "8.8.8.8"   /* to test connectivity */
>  
>  #define  INTERVAL_QUERY_NORMAL   30  /* sync to peers every 
> n secs */
>  #define  INTERVAL_QUERY_PATHETIC 60
> 

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



Re: ntpd is too noisy about 'DNS lookup tempfail' on IPv6 only hosts

2019-11-06 Thread Peter J. Philipp
On Wed, Nov 06, 2019 at 11:30:32AM +0100, Florian Obser wrote:
> > @@ -94,7 +95,7 @@ host_dns1(const char *s, struct ntp_addr
> > struct ntp_addr *h, *hh = NULL;
> >  
> > memset(&hints, 0, sizeof(hints));
> > -   hints.ai_family = AF_UNSPEC;
> > +   hints.ai_family = (test_v4_gw() == 0) ? AF_UNSPEC : AF_INET6;
> > hints.ai_socktype = SOCK_DGRAM; /* DUMMY */
> > hints.ai_flags = AI_ADDRCONFIG;
> 
> you just implemented a variation of AI_ADDRCONFIG

Oh you're right!  Good you're looking over me Florian! So here is the
right patch then that I want OpenBSD to consider, with it I don't see 
the timeouts messages (are they needed?):

Best Regards,

-peter


Index: ntp_dns.c
===
RCS file: /cvs/src/usr.sbin/ntpd/ntp_dns.c,v
retrieving revision 1.24
diff -u -p -u -r1.24 ntp_dns.c
--- ntp_dns.c   27 Jun 2019 15:18:42 -  1.24
+++ ntp_dns.c   6 Nov 2019 10:39:36 -
@@ -170,7 +170,7 @@ dns_dispatch_imsg(struct ntpd_conf *ncon
strlen(name) != len)
fatalx("invalid %s received", str);
if ((cnt = host_dns(name, nconf->status.synced,
-   &hn)) == -1)
+   &hn)) <= 0)
break;
buf = imsg_create(ibuf_dns, imsg.hdr.type,
imsg.hdr.peerid, 0,



Re: use tasks and a task_list to manage if_linkstatehooks

2019-11-06 Thread David Gwynne
On Wed, Nov 06, 2019 at 03:12:27PM +1000, David Gwynne wrote:
> this is a follow-up to "use tasks and a task_list to manage
> if_detachhooks" and converts the link state hooks to a task_list
> with pre-allocated tasks.
> 
> it's mostly mechanical, except for carp. each carp interface has a link
> state hook it registers on its parent, but each hook then runs against
> every carp device on that parent. the diff changes it so the link state
> hook is only run for the relevant carp interface.
> 
> it also reorders the addition of the carp link state hook till after the
> old link state hook is removed.
> 
> unless anyone objects i am going to commit this around 10am GMT+10
> tomorrow (7th nov).

hrvoje points out i missed a file in my diff.

Index: net/bridgestp.c
===
RCS file: /cvs/src/sys/net/bridgestp.c,v
retrieving revision 1.72
diff -u -p -r1.72 bridgestp.c
--- net/bridgestp.c 13 May 2019 18:20:13 -  1.72
+++ net/bridgestp.c 6 Nov 2019 11:13:24 -
@@ -1986,9 +1986,8 @@ bstp_add(struct bstp_state *bs, struct i
bstp_update_roles(bs, bp);
 
/* Register callback for physical link state changes */
-   if (ifp->if_linkstatehooks != NULL)
-   bp->bp_lhcookie = hook_establish(ifp->if_linkstatehooks, 1,
-   bstp_ifstate, ifp);
+   task_set(&bp->bp_ltask, bstp_ifstate, ifp);
+   if_linkstatehook_add(ifp, &bp->bp_ltask);
 
return (bp);
 }
@@ -2002,8 +2001,7 @@ bstp_delete(struct bstp_port *bp)
if (!bp->bp_active)
panic("not a bstp member");
 
-   if (ifp != NULL && ifp->if_linkstatehooks != NULL)
-   hook_disestablish(ifp->if_linkstatehooks, bp->bp_lhcookie);
+   if_linkstatehook_del(ifp, &bp->bp_ltask);
 
LIST_REMOVE(bp, bp_next);
free(bp, M_DEVBUF, sizeof *bp);
Index: net/if.c
===
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.589
diff -u -p -r1.589 if.c
--- net/if.c6 Nov 2019 03:51:26 -   1.589
+++ net/if.c6 Nov 2019 11:13:24 -
@@ -629,9 +629,7 @@ if_attach_common(struct ifnet *ifp)
ifp->if_addrhooks = malloc(sizeof(*ifp->if_addrhooks),
M_TEMP, M_WAITOK);
TAILQ_INIT(ifp->if_addrhooks);
-   ifp->if_linkstatehooks = malloc(sizeof(*ifp->if_linkstatehooks),
-   M_TEMP, M_WAITOK);
-   TAILQ_INIT(ifp->if_linkstatehooks);
+   TAILQ_INIT(&ifp->if_linkstatehooks);
TAILQ_INIT(&ifp->if_detachhooks);
 
if (ifp->if_rtrequest == NULL)
@@ -1055,8 +1053,6 @@ if_deactivate(struct ifnet *ifp)
NET_LOCK();
TAILQ_FOREACH_SAFE(t, &ifp->if_detachhooks, t_entry, nt)
(*t->t_func)(t->t_arg);
-
-   KASSERT(TAILQ_EMPTY(&ifp->if_detachhooks));
NET_UNLOCK();
 }
 
@@ -1148,7 +1144,8 @@ if_detach(struct ifnet *ifp)
}
 
free(ifp->if_addrhooks, M_TEMP, sizeof(*ifp->if_addrhooks));
-   free(ifp->if_linkstatehooks, M_TEMP, sizeof(*ifp->if_linkstatehooks));
+   KASSERT(TAILQ_EMPTY(&ifp->if_linkstatehooks));
+   KASSERT(TAILQ_EMPTY(&ifp->if_detachhooks));
 
for (i = 0; (dp = domains[i]) != NULL; i++) {
if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family])
@@ -1646,11 +1643,29 @@ if_linkstate_task(void *xifidx)
 void
 if_linkstate(struct ifnet *ifp)
 {
+   struct task *t, *nt;
+
NET_ASSERT_LOCKED();
 
rtm_ifchg(ifp);
rt_if_track(ifp);
-   dohooks(ifp->if_linkstatehooks, 0);
+
+   TAILQ_FOREACH_SAFE(t, &ifp->if_linkstatehooks, t_entry, nt)
+   (*t->t_func)(t->t_arg);
+}
+
+void
+if_linkstatehook_add(struct ifnet *ifp, struct task *t)
+{
+   NET_ASSERT_LOCKED();
+   TAILQ_INSERT_TAIL(&ifp->if_linkstatehooks, t, t_entry);
+}
+
+void
+if_linkstatehook_del(struct ifnet *ifp, struct task *t)
+{
+   NET_ASSERT_LOCKED();
+   TAILQ_REMOVE(&ifp->if_linkstatehooks, t, t_entry);
 }
 
 /*
Index: net/if_aggr.c
===
RCS file: /cvs/src/sys/net/if_aggr.c,v
retrieving revision 1.20
diff -u -p -r1.20 if_aggr.c
--- net/if_aggr.c   6 Nov 2019 03:51:26 -   1.20
+++ net/if_aggr.c   6 Nov 2019 11:13:24 -
@@ -335,7 +335,7 @@ struct aggr_port {
int (*p_output)(struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *);
 
-   void*p_lcookie;
+   struct task  p_lhook;
struct task  p_dhook;
 
struct aggr_softc   *p_aggr;
@@ -1135,8 +1135,8 @@ aggr_add_port(struct aggr_softc *sc, con
}
}
 
-   p->p_lcookie = hook_establish(ifp0->if_linkstatehooks, 1,
-   aggr_p_linkch, p);
+   task_set(&p->p_lhook, aggr_p_linkch, p);
+   if_linkstatehook_add(ifp0, &p->p_lhook);
 
task_set(&p->p_dhook, aggr_p_detach, p);
if_detachhook_add(ifp

tcpdump(8) mention USB interfaces in -i

2019-11-06 Thread Stuart Henderson
Found this diff when updating an old tree, ok?


Index: usr.sbin/tcpdump/tcpdump.8
===
RCS file: /cvs/src/usr.sbin/tcpdump/tcpdump.8,v
retrieving revision 1.108
diff -u -p -r1.108 tcpdump.8
--- usr.sbin/tcpdump/tcpdump.8  31 Oct 2019 18:10:22 -  1.108
+++ usr.sbin/tcpdump/tcpdump.8  6 Nov 2019 12:12:54 -
@@ -146,6 +146,9 @@ searches the system interface list for t
 interface
 .Pq excluding loopback .
 Ties are broken by choosing the earliest match.
+.Ar interface
+may be either a network interface or a USB interface, for example
+.Ar usb0 .
 .It Fl L
 List the supported data link types for the interface and exit.
 .It Fl l



sysupgrade: Allow to use another directory for the sets

2019-11-06 Thread Renaud Allard

Hello,

Given the amount of people which encrypt /home directory on their 
servers, it might be useful to be able to define another directory for 
the sets in sysupgrade as /home_sysupgrade will not be available in that 
case.

Here is a patch for this.

Regards
Index: sysupgrade.8
===
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.8,v
retrieving revision 1.10
diff -u -p -r1.10 sysupgrade.8
--- sysupgrade.8	3 Oct 2019 12:43:58 -	1.10
+++ sysupgrade.8	6 Nov 2019 12:36:48 -
@@ -22,6 +22,7 @@
 .Nd upgrade system to the next release or a new snapshot
 .Sh SYNOPSIS
 .Nm
+.Op Fl d Ar directory
 .Op Fl fkn
 .Op Fl r | s
 .Op Ar installurl
@@ -48,6 +49,12 @@ triggering a one-shot upgrade using the 
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
+.It Fl d Ar directory
+Choose the 
+.Ar directory
+in which the sets will be downloaded.
+Default is
+.Pa /home/_sysupgrade .
 .It Fl f
 Force an already applied upgrade.
 The default is to upgrade to latest snapshot only if available.
Index: sysupgrade.sh
===
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
retrieving revision 1.30
diff -u -p -r1.30 sysupgrade.sh
--- sysupgrade.sh	3 Nov 2019 18:22:45 -	1.30
+++ sysupgrade.sh	6 Nov 2019 12:36:48 -
@@ -25,7 +25,6 @@ umask 0022
 export PATH=/usr/bin:/bin:/usr/sbin:/sbin
 
 ARCH=$(uname -m)
-SETSDIR=/home/_sysupgrade
 
 ug_err()
 {
@@ -73,14 +72,16 @@ rmel() {
 	echo -n "$_c"
 }
 
+SETSDIR=/home/_sysupgrade
 RELEASE=false
 SNAP=false
 FORCE=false
 KEEP=false
 REBOOT=true
 
-while getopts fknrs arg; do
+while getopts d:fknrs arg; do
 	case ${arg} in
+	d)	SETSDIR=${OPTARG};;
 	f)	FORCE=true;;
 	k)	KEEP=true;;
 	n)	REBOOT=false;;
@@ -192,7 +193,7 @@ ${KEEP} && > keep
 
 cat <<__EOT >/auto_upgrade.conf
 Location of sets = disk
-Pathname to the sets = /home/_sysupgrade/
+Pathname to the sets = ${SETSDIR}
 Set name(s) = done
 Directory does not contain SHA256.sig. Continue without verification = yes
 __EOT
@@ -200,7 +201,7 @@ __EOT
 if ! ${KEEP}; then
 	CLEAN=$(echo SHA256 ${SETS} | sed -e 's/ /,/g')
 	cat <<__EOT > /etc/rc.firsttime
-rm -f /home/_sysupgrade/{${CLEAN}}
+rm -f ${SETSDIR}/{${CLEAN}}
 __EOT
 fi
 


smime.p7s
Description: S/MIME Cryptographic Signature


Re: _pbuild user to have priority=5

2019-11-06 Thread Marc Espie
On Sat, Nov 02, 2019 at 02:35:28PM +0100, Solene Rapenne wrote:
> On Sat, Nov 02, 2019 at 01:18:53PM +, Stuart Henderson wrote:
> > On 2019/11/01 19:16, Theo de Raadt wrote:
> > > Ted Unangst  wrote:
> > > 
> > > > Theo de Raadt wrote:
> > > > > What about all the other users who aren't in staff?
> > > > > 
> > > > > I think the approach is right.  Push non-interactive down.
> > > > 
> > > > The same then for src build user?
> > > 
> > > Well, that's different.  Most of us building the src tree are waiting
> > > eagerly for it to finish aren't we?
> > 
> > That's the same for ports building!
> > 
> 
> if you don't do anything else than compiling ports, that shouldn't be
> slower.
> If you are doing something else (GUI user, web server, community server
> with people connected doing IRC) , then you don't get angry due to
> unresponsive system.
> 
> Lowering staff priority would only help the one user case.

I agree with solene on that one.

This is actually useful even if you're just building ports, because
you get a more responsive text-editor and stuff like that which is useful
when you're fixing things that broke while dpb is still going.

I see a noticeable difference in vim showing me syntax coloring correctly
while dpb is running.

Source is somewhat different. make build/release is sequential by nature,
as you can't really fix a part while something else is still building.



Re: slaacd(8): remove address / default route proposals

2019-11-06 Thread Tobias Heider
Great! I will run some tests with the diff.

One thing I noticed:

> @@ -1982,11 +1941,8 @@ gen_address_proposal(struct slaacd_iface *iface, 
> struct radv *ra, struct
>  
>   gen_addr(iface, prefix, addr_proposal, privacy);
>  
> - tv.tv_sec = 0;
> - tv.tv_usec = 0;
> - evtimer_add(&addr_proposal->timer, &tv);
> -
>   LIST_INSERT_HEAD(&iface->addr_proposals, addr_proposal, entries);
> + configure_address(addr_proposal);
>  
>   hbuf = sin6_to_str(&addr_proposal->addr);
>   log_debug("%s: iface %d: %s: %lld s", __func__,
> @@ -2047,11 +2003,8 @@ gen_dfr_proposal(struct slaacd_iface *iface, struct 
> radv *ra)
>   dfr_proposal->router_lifetime = ra->router_lifetime;
>   dfr_proposal->rpref = ra->rpref;
>  
> - tv.tv_sec = 0;
> - tv.tv_usec = 0;
> - evtimer_add(&dfr_proposal->timer, &tv);
> -
>   LIST_INSERT_HEAD(&iface->dfr_proposals, dfr_proposal, entries);
> + configure_dfr(dfr_proposal);
>  
>   hbuf = sin6_to_str(&dfr_proposal->addr);
>   log_debug("%s: iface %d: %s: %lld s", __func__,

I think the tv variable should be deleted in both gen_addr_proposal
and gen_dfr_rpoposal. Right now it is unitialized and (only) used
in log_debug.



ctfconv/DWARF & clang static variables

2019-11-06 Thread Martin Pieuchot
When a static variable is defined in a function, clang(1) emits the
following DWARF:

 <1><90>: Abbrev Number: 9 (DW_TAG_subprogram)
  DW_AT_name: (indirect string, offset: 0x213b): pageflttrap
  [...]
 <2>: Abbrev Number: 10 (DW_TAG_variable)
  DW_AT_name: (indirect string, offset: 0xc9): faultbuf
  [...]
 <2>: Abbrev Number: 11 (DW_TAG_formal_parameter)
 DW_AT_name: (indirect string, offset: 0x217d): frame
  [...]
 <2>: Abbrev Number: 11 (DW_TAG_formal_parameter)
 DW_AT_name: (indirect string, offset: 0x2183): usermode
  [...]

As you can see the function arguments are placed *after* the local static
variable.  ctfconv(1) currently stops parsing a `DW_TAG_subprogram' section
as soon as it find a variable definition.  That means with modern clang(1)
functions like panic(9) or pageflttrap() are incorrectly identified as having
no argument.

Diff below fixes that, ok?

Index: parse.c
===
RCS file: /cvs/src/usr.bin/ctfconv/parse.c,v
retrieving revision 1.11
diff -u -p -r1.11 parse.c
--- parse.c 31 Jan 2018 14:47:13 -  1.11
+++ parse.c 6 Nov 2019 13:43:32 -
@@ -1138,12 +1142,19 @@ subparse_arguments(struct dwdie *die, si
 * Nested declaration.
 *
 * This matches the case where a ``struct'', ``union'',
-* ``enum'' or ``typedef'' is first declared "inside" a
-* function declaration.
+* ``enum'', ``typedef'' or ``static'' variable is first
+* declared inside a function declaration.
 */
-   if (tag == DW_TAG_structure_type || tag == DW_TAG_union_type ||
-   tag == DW_TAG_enumeration_type || tag == DW_TAG_typedef)
+   switch (tag) {
+   case DW_TAG_structure_type:
+   case DW_TAG_union_type:
+   case DW_TAG_enumeration_type:
+   case DW_TAG_typedef:
+   case DW_TAG_variable:
continue;
+   default:
+   break;
+   }
 
if (tag != DW_TAG_formal_parameter)
break;



db_addr_t -> vaddr_t

2019-11-06 Thread Martin Pieuchot
This type is just another way to write 'vaddr_t' and requires pulling a
ddb-specific MD header for that, can't we just use vaddr_t everywhere?

Diff below does the conversion in sys/kern and sys/ddb, ok?

Index: kern/kern_timeout.c
===
RCS file: /cvs/src/sys/kern/kern_timeout.c,v
retrieving revision 1.61
diff -u -p -r1.61 kern_timeout.c
--- kern/kern_timeout.c 3 Nov 2019 17:01:46 -   1.61
+++ kern/kern_timeout.c 6 Nov 2019 14:03:58 -
@@ -627,7 +627,7 @@ db_show_callout_bucket(struct circq *buc
 
for (p = CIRCQ_FIRST(bucket); p != bucket; p = CIRCQ_FIRST(p)) {
to = timeout_from_circq(p);
-   db_find_sym_and_offset((db_addr_t)to->to_func, &name, &offset);
+   db_find_sym_and_offset((vaddr_t)to->to_func, &name, &offset);
name = name ? name : "?";
if (bucket == &timeout_todo)
where = "softint";
Index: ddb/db_access.c
===
RCS file: /cvs/src/sys/ddb/db_access.c,v
retrieving revision 1.15
diff -u -p -r1.15 db_access.c
--- ddb/db_access.c 19 Apr 2016 10:24:42 -  1.15
+++ ddb/db_access.c 6 Nov 2019 13:56:49 -
@@ -42,7 +42,7 @@
  * boundaries.
  */
 db_expr_t
-db_get_value(db_addr_t addr, size_t size, int is_signed)
+db_get_value(vaddr_t addr, size_t size, int is_signed)
 {
char data[sizeof(db_expr_t)];
db_expr_t value, extend;
@@ -70,7 +70,7 @@ db_get_value(db_addr_t addr, size_t size
 }
 
 void
-db_put_value(db_addr_t addr, size_t size, db_expr_t value)
+db_put_value(vaddr_t addr, size_t size, db_expr_t value)
 {
char data[sizeof(db_expr_t)];
int i;
Index: ddb/db_access.h
===
RCS file: /cvs/src/sys/ddb/db_access.h,v
retrieving revision 1.9
diff -u -p -r1.9 db_access.h
--- ddb/db_access.h 7 May 2018 15:52:46 -   1.9
+++ ddb/db_access.h 6 Nov 2019 13:57:02 -
@@ -33,17 +33,17 @@
 /*
  * Data access functions for debugger.
  */
-db_expr_t db_get_value(db_addr_t, size_t, int);
-void db_put_value(db_addr_t, size_t, db_expr_t);
+db_expr_t db_get_value(vaddr_t, size_t, int);
+void db_put_value(vaddr_t, size_t, db_expr_t);
 
-void db_read_bytes(db_addr_t, size_t, char *);
-void db_write_bytes(db_addr_t, size_t, char *);
+void db_read_bytes(vaddr_t, size_t, char *);
+void db_write_bytes(vaddr_t, size_t, char *);
 
 #define DB_STACK_TRACE_MAX 19
 
 struct db_stack_trace {
unsigned intst_count;
-   db_addr_t   st_pc[DB_STACK_TRACE_MAX];
+   vaddr_t st_pc[DB_STACK_TRACE_MAX];
 };
 
 void db_print_stack_trace(struct db_stack_trace *, int (*)(const char *, ...));
Index: ddb/db_break.c
===
RCS file: /cvs/src/sys/ddb/db_break.c,v
retrieving revision 1.20
diff -u -p -r1.20 db_break.c
--- ddb/db_break.c  19 Apr 2016 12:23:25 -  1.20
+++ ddb/db_break.c  6 Nov 2019 13:56:54 -
@@ -51,8 +51,8 @@ db_breakpoint_t   db_breakpoint_list = 0;
 
 db_breakpoint_t db_breakpoint_alloc(void);
 void db_breakpoint_free(db_breakpoint_t);
-void db_set_breakpoint(db_addr_t, int);
-void db_delete_breakpoint(db_addr_t);
+void db_set_breakpoint(vaddr_t, int);
+void db_delete_breakpoint(vaddr_t);
 void db_list_breakpoints(void);
 
 db_breakpoint_t
@@ -82,7 +82,7 @@ db_breakpoint_free(db_breakpoint_t bkpt)
 }
 
 void
-db_set_breakpoint(db_addr_t addr, int count)
+db_set_breakpoint(vaddr_t addr, int count)
 {
db_breakpoint_t bkpt;
 
@@ -114,7 +114,7 @@ db_set_breakpoint(db_addr_t addr, int co
 }
 
 void
-db_delete_breakpoint(db_addr_t addr)
+db_delete_breakpoint(vaddr_t addr)
 {
db_breakpoint_t bkpt;
db_breakpoint_t *prev;
@@ -135,7 +135,7 @@ db_delete_breakpoint(db_addr_t addr)
 }
 
 db_breakpoint_t
-db_find_breakpoint(db_addr_t addr)
+db_find_breakpoint(vaddr_t addr)
 {
db_breakpoint_t bkpt;
 
@@ -182,7 +182,7 @@ db_clear_breakpoints(void)
  * so the breakpoint does not have to be on the breakpoint list.
  */
 db_breakpoint_t
-db_set_temp_breakpoint(db_addr_t addr)
+db_set_temp_breakpoint(vaddr_t addr)
 {
db_breakpoint_t bkpt;
 
@@ -242,7 +242,7 @@ db_list_breakpoints(void)
 void
 db_delete_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif)
 {
-   db_delete_breakpoint((db_addr_t)addr);
+   db_delete_breakpoint((vaddr_t)addr);
 }
 
 /* Set breakpoint with skip count */
@@ -253,7 +253,7 @@ db_breakpoint_cmd(db_expr_t addr, int ha
if (count == -1)
count = 1;
 
-   db_set_breakpoint((db_addr_t)addr, count);
+   db_set_breakpoint((vaddr_t)addr, count);
 }
 
 /* list breakpoints */
Index: ddb/db_break.h
===
RCS file: /cvs/src/sys/ddb/db_break.h,v
retrieving revision 1.11
diff -u -p -r1.11 db_break.h
--- d

Re: slaacd(8): remove address / default route proposals

2019-11-06 Thread Florian Obser
On Wed, Nov 06, 2019 at 02:47:33PM +0100, Tobias Heider wrote:

> I think the tv variable should be deleted in both gen_addr_proposal
> and gen_dfr_rpoposal. Right now it is unitialized and (only) used
> in log_debug.

thanks, fixed! 

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



diff: simplify MGETHDR error handling in tcp_output

2019-11-06 Thread Jan Klemkow
Hi,

the following diff simplifies the error handling of MGETHDR() in
tcp_output().  Jumps earlier to out, prevents a double check of NULL and
makes the code more readable.

OK?

Bye,
Jan

Index: netinet/tcp_output.c
===
RCS file: /cvs/src/sys/netinet/tcp_output.c,v
retrieving revision 1.128
diff -u -p -r1.128 tcp_output.c
--- netinet/tcp_output.c10 Nov 2018 18:40:34 -  1.128
+++ netinet/tcp_output.c6 Nov 2019 14:34:40 -
@@ -652,17 +652,17 @@ send:
m->m_data -= hdrlen;
 #else
MGETHDR(m, M_DONTWAIT, MT_HEADER);
-   if (m != NULL && max_linkhdr + hdrlen > MHLEN) {
+   if (m == NULL) {
+   error = ENOBUFS;
+   goto out;
+   }
+   if (max_linkhdr + hdrlen > MHLEN) {
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
m = NULL;
}
}
-   if (m == NULL) {
-   error = ENOBUFS;
-   goto out;
-   }
m->m_data += max_linkhdr;
m->m_len = hdrlen;
if (len <= m_trailingspace(m)) {
@@ -701,16 +701,16 @@ send:
tcpstat_inc(tcps_sndwinup);
 
MGETHDR(m, M_DONTWAIT, MT_HEADER);
-   if (m != NULL && max_linkhdr + hdrlen > MHLEN) {
+   if (m == NULL) {
+   error = ENOBUFS;
+   goto out;
+   }
+   if (max_linkhdr + hdrlen > MHLEN) {
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
m = NULL;
}
-   }
-   if (m == NULL) {
-   error = ENOBUFS;
-   goto out;
}
m->m_data += max_linkhdr;
m->m_len = hdrlen;



Re: db_addr_t -> vaddr_t

2019-11-06 Thread Theo de Raadt
Makes sense.  Some strange CMUism. 

Martin Pieuchot  wrote:

> This type is just another way to write 'vaddr_t' and requires pulling a
> ddb-specific MD header for that, can't we just use vaddr_t everywhere?
> 
> Diff below does the conversion in sys/kern and sys/ddb, ok?
> 
> Index: kern/kern_timeout.c
> ===
> RCS file: /cvs/src/sys/kern/kern_timeout.c,v
> retrieving revision 1.61
> diff -u -p -r1.61 kern_timeout.c
> --- kern/kern_timeout.c   3 Nov 2019 17:01:46 -   1.61
> +++ kern/kern_timeout.c   6 Nov 2019 14:03:58 -
> @@ -627,7 +627,7 @@ db_show_callout_bucket(struct circq *buc
>  
>   for (p = CIRCQ_FIRST(bucket); p != bucket; p = CIRCQ_FIRST(p)) {
>   to = timeout_from_circq(p);
> - db_find_sym_and_offset((db_addr_t)to->to_func, &name, &offset);
> + db_find_sym_and_offset((vaddr_t)to->to_func, &name, &offset);
>   name = name ? name : "?";
>   if (bucket == &timeout_todo)
>   where = "softint";
> Index: ddb/db_access.c
> ===
> RCS file: /cvs/src/sys/ddb/db_access.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 db_access.c
> --- ddb/db_access.c   19 Apr 2016 10:24:42 -  1.15
> +++ ddb/db_access.c   6 Nov 2019 13:56:49 -
> @@ -42,7 +42,7 @@
>   * boundaries.
>   */
>  db_expr_t
> -db_get_value(db_addr_t addr, size_t size, int is_signed)
> +db_get_value(vaddr_t addr, size_t size, int is_signed)
>  {
>   char data[sizeof(db_expr_t)];
>   db_expr_t value, extend;
> @@ -70,7 +70,7 @@ db_get_value(db_addr_t addr, size_t size
>  }
>  
>  void
> -db_put_value(db_addr_t addr, size_t size, db_expr_t value)
> +db_put_value(vaddr_t addr, size_t size, db_expr_t value)
>  {
>   char data[sizeof(db_expr_t)];
>   int i;
> Index: ddb/db_access.h
> ===
> RCS file: /cvs/src/sys/ddb/db_access.h,v
> retrieving revision 1.9
> diff -u -p -r1.9 db_access.h
> --- ddb/db_access.h   7 May 2018 15:52:46 -   1.9
> +++ ddb/db_access.h   6 Nov 2019 13:57:02 -
> @@ -33,17 +33,17 @@
>  /*
>   * Data access functions for debugger.
>   */
> -db_expr_t db_get_value(db_addr_t, size_t, int);
> -void db_put_value(db_addr_t, size_t, db_expr_t);
> +db_expr_t db_get_value(vaddr_t, size_t, int);
> +void db_put_value(vaddr_t, size_t, db_expr_t);
>  
> -void db_read_bytes(db_addr_t, size_t, char *);
> -void db_write_bytes(db_addr_t, size_t, char *);
> +void db_read_bytes(vaddr_t, size_t, char *);
> +void db_write_bytes(vaddr_t, size_t, char *);
>  
>  #define DB_STACK_TRACE_MAX   19
>  
>  struct db_stack_trace {
>   unsigned intst_count;
> - db_addr_t   st_pc[DB_STACK_TRACE_MAX];
> + vaddr_t st_pc[DB_STACK_TRACE_MAX];
>  };
>  
>  void db_print_stack_trace(struct db_stack_trace *, int (*)(const char *, 
> ...));
> Index: ddb/db_break.c
> ===
> RCS file: /cvs/src/sys/ddb/db_break.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 db_break.c
> --- ddb/db_break.c19 Apr 2016 12:23:25 -  1.20
> +++ ddb/db_break.c6 Nov 2019 13:56:54 -
> @@ -51,8 +51,8 @@ db_breakpoint_t db_breakpoint_list = 0;
>  
>  db_breakpoint_t db_breakpoint_alloc(void);
>  void db_breakpoint_free(db_breakpoint_t);
> -void db_set_breakpoint(db_addr_t, int);
> -void db_delete_breakpoint(db_addr_t);
> +void db_set_breakpoint(vaddr_t, int);
> +void db_delete_breakpoint(vaddr_t);
>  void db_list_breakpoints(void);
>  
>  db_breakpoint_t
> @@ -82,7 +82,7 @@ db_breakpoint_free(db_breakpoint_t bkpt)
>  }
>  
>  void
> -db_set_breakpoint(db_addr_t addr, int count)
> +db_set_breakpoint(vaddr_t addr, int count)
>  {
>   db_breakpoint_t bkpt;
>  
> @@ -114,7 +114,7 @@ db_set_breakpoint(db_addr_t addr, int co
>  }
>  
>  void
> -db_delete_breakpoint(db_addr_t addr)
> +db_delete_breakpoint(vaddr_t addr)
>  {
>   db_breakpoint_t bkpt;
>   db_breakpoint_t *prev;
> @@ -135,7 +135,7 @@ db_delete_breakpoint(db_addr_t addr)
>  }
>  
>  db_breakpoint_t
> -db_find_breakpoint(db_addr_t addr)
> +db_find_breakpoint(vaddr_t addr)
>  {
>   db_breakpoint_t bkpt;
>  
> @@ -182,7 +182,7 @@ db_clear_breakpoints(void)
>   * so the breakpoint does not have to be on the breakpoint list.
>   */
>  db_breakpoint_t
> -db_set_temp_breakpoint(db_addr_t addr)
> +db_set_temp_breakpoint(vaddr_t addr)
>  {
>   db_breakpoint_t bkpt;
>  
> @@ -242,7 +242,7 @@ db_list_breakpoints(void)
>  void
>  db_delete_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif)
>  {
> - db_delete_breakpoint((db_addr_t)addr);
> + db_delete_breakpoint((vaddr_t)addr);
>  }
>  
>  /* Set breakpoint with skip count */
> @@ -253,7 +253,7 @@ db_breakpoint_cmd(db_expr_t addr, int ha
>   if (count == -1)
>   count = 1;
>  
> - db_set_br

make 'ifconfig scan' trigger a background scan

2019-11-06 Thread Stefan Sperling
This diff allows the root user to trigger a background scan with:

ifconfig iwm0 scan

It supports two use cases which are currently not supported:

1) It will force an attempt at finding a better AP, even if the
current AP is above the signal level threshold which will usually
trigger a background scan.

2) It will update the list of cached APs. The updated list will be
shown by subsequent invocations of 'ifconfig scan'. This allows the
root user to view an up-to-date list of available networks without
disassociating from the current AP. Currently, the list is updated only
if a background scan is triggered via the signal strength threshold.

Suggested by sthen@

ok?

diff 1bc5f745876be1d7923afca9b40fb6641254e697 /usr/src (staged changes)
blob - b7b2ea6d631958b607ffdee06d272cd56320bf2e
blob + d4c2a0ba6b1893af9652837998c759a6c0857048
--- sys/net80211/ieee80211_ioctl.c
+++ sys/net80211/ieee80211_ioctl.c
@@ -906,6 +906,8 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t
na->na_nodes++;
ni = RBT_NEXT(ieee80211_tree, ni);
}
+   if (suser(curproc) == 0)
+   ieee80211_begin_bgscan(ifp);
break;
case SIOCG80211FLAGS:
flags = ic->ic_userflags;
blob - b493ff0a5362fa11d7824fd8bd0ae0d57462d6c4
blob + 501cbca0b9b8422fc9384ffbb9fb2c36b16cd2c0
--- sys/net80211/ieee80211_var.h
+++ sys/net80211/ieee80211_var.h
@@ -460,6 +460,7 @@ voidieee80211_del_ess(struct ieee80211com *, char 
*, 
 void   ieee80211_set_ess(struct ieee80211com *, struct ieee80211_ess *,
struct ieee80211_node *);
 struct ieee80211_ess *ieee80211_get_ess(struct ieee80211com *, const char *, 
int);
+void   ieee80211_begin_bgscan(struct ifnet *);
 
 extern int ieee80211_cache_size;
 



[patch] ftp: improve SMALL and NOSSL #ifdefs

2019-11-06 Thread Hiltjo Posthuma
Hi,

The below patch fixes the #ifndef's for usr.bin/ftp so any combination of SMALL
and NOSSL will compile again.

Patch:


diff --git usr.bin/ftp/fetch.c usr.bin/ftp/fetch.c
index 4c7e14b04bd..15927471f1a 100644
--- usr.bin/ftp/fetch.c
+++ usr.bin/ftp/fetch.c
@@ -201,14 +201,14 @@ url_get(const char *origline, const char *proxyenv, const 
char *outfile, int las
char *proxyhost = NULL;
 #ifndef NOSSL
char *sslpath = NULL, *sslhost = NULL;
-   char *full_host = NULL;
-   const char *scheme;
int ishttpurl = 0, ishttpsurl = 0;
 #endif /* !NOSSL */
 #ifndef SMALL
+   char *full_host = NULL;
+   const char *scheme;
char *locbase;
struct addrinfo *ares = NULL;
-#endif
+#endif /* !SMALL */
struct tls *tls = NULL;
int status;
int save_errno;
@@ -221,8 +221,10 @@ url_get(const char *origline, const char *proxyenv, const 
char *outfile, int las
errx(1, "Can't allocate memory to parse URL");
if (strncasecmp(newline, HTTP_URL, sizeof(HTTP_URL) - 1) == 0) {
host = newline + sizeof(HTTP_URL) - 1;
-#ifndef SMALL
+#ifndef NOSSL
ishttpurl = 1;
+#endif /* !NOSSL */
+#ifndef SMALL
scheme = HTTP_URL;
 #endif /* !SMALL */
} else if (strncasecmp(newline, FTP_URL, sizeof(FTP_URL) - 1) == 0) {
@@ -234,13 +236,17 @@ url_get(const char *origline, const char *proxyenv, const 
char *outfile, int las
} else if (strncasecmp(newline, FILE_URL, sizeof(FILE_URL) - 1) == 0) {
host = newline + sizeof(FILE_URL) - 1;
isfileurl = 1;
-#ifndef NOSSL
+#ifndef SMALL
scheme = FILE_URL;
+#endif /* !SMALL */
+#ifndef NOSSL
} else if (strncasecmp(newline, HTTPS_URL, sizeof(HTTPS_URL) - 1) == 0) 
{
host = newline + sizeof(HTTPS_URL) - 1;
ishttpsurl = 1;
-   scheme = HTTPS_URL;
 #endif /* !NOSSL */
+#ifndef SMALL
+   scheme = HTTPS_URL;
+#endif /* !SMALL */
} else
errx(1, "url_get: Invalid URL '%s'", newline);
 
@@ -1066,8 +1072,10 @@ improper:
warnx("Improper response from %s", host);
 
 cleanup_url_get:
-#ifndef NOSSL
+#ifndef SMALL
free(full_host);
+#endif /* !SMALL */
+#ifndef NOSSL
free(sslhost);
 #endif /* !NOSSL */
ftp_close(&fin, &tls, &fd);


-- 
Kind regards,
Hiltjo



Re: [patch] ftp: improve SMALL and NOSSL #ifdefs

2019-11-06 Thread Jan Klemkow
Hi Hiltjo,

On Wed, Nov 06, 2019 at 07:53:02PM +0100, Hiltjo Posthuma wrote:
> The below patch fixes the #ifndef's for usr.bin/ftp so any combination of 
> SMALL
> and NOSSL will compile again.

Diff looks good for me and works in all ifdef combinations without any
warning or error.

OK jan@

Thanks,
Jan

> diff --git usr.bin/ftp/fetch.c usr.bin/ftp/fetch.c
> index 4c7e14b04bd..15927471f1a 100644
> --- usr.bin/ftp/fetch.c
> +++ usr.bin/ftp/fetch.c
> @@ -201,14 +201,14 @@ url_get(const char *origline, const char *proxyenv, 
> const char *outfile, int las
>   char *proxyhost = NULL;
>  #ifndef NOSSL
>   char *sslpath = NULL, *sslhost = NULL;
> - char *full_host = NULL;
> - const char *scheme;
>   int ishttpurl = 0, ishttpsurl = 0;
>  #endif /* !NOSSL */
>  #ifndef SMALL
> + char *full_host = NULL;
> + const char *scheme;
>   char *locbase;
>   struct addrinfo *ares = NULL;
> -#endif
> +#endif /* !SMALL */
>   struct tls *tls = NULL;
>   int status;
>   int save_errno;
> @@ -221,8 +221,10 @@ url_get(const char *origline, const char *proxyenv, 
> const char *outfile, int las
>   errx(1, "Can't allocate memory to parse URL");
>   if (strncasecmp(newline, HTTP_URL, sizeof(HTTP_URL) - 1) == 0) {
>   host = newline + sizeof(HTTP_URL) - 1;
> -#ifndef SMALL
> +#ifndef NOSSL
>   ishttpurl = 1;
> +#endif /* !NOSSL */
> +#ifndef SMALL
>   scheme = HTTP_URL;
>  #endif /* !SMALL */
>   } else if (strncasecmp(newline, FTP_URL, sizeof(FTP_URL) - 1) == 0) {
> @@ -234,13 +236,17 @@ url_get(const char *origline, const char *proxyenv, 
> const char *outfile, int las
>   } else if (strncasecmp(newline, FILE_URL, sizeof(FILE_URL) - 1) == 0) {
>   host = newline + sizeof(FILE_URL) - 1;
>   isfileurl = 1;
> -#ifndef NOSSL
> +#ifndef SMALL
>   scheme = FILE_URL;
> +#endif /* !SMALL */
> +#ifndef NOSSL
>   } else if (strncasecmp(newline, HTTPS_URL, sizeof(HTTPS_URL) - 1) == 0) 
> {
>   host = newline + sizeof(HTTPS_URL) - 1;
>   ishttpsurl = 1;
> - scheme = HTTPS_URL;
>  #endif /* !NOSSL */
> +#ifndef SMALL
> + scheme = HTTPS_URL;
> +#endif /* !SMALL */
>   } else
>   errx(1, "url_get: Invalid URL '%s'", newline);
>  
> @@ -1066,8 +1072,10 @@ improper:
>   warnx("Improper response from %s", host);
>  
>  cleanup_url_get:
> -#ifndef NOSSL
> +#ifndef SMALL
>   free(full_host);
> +#endif /* !SMALL */
> +#ifndef NOSSL
>   free(sslhost);
>  #endif /* !NOSSL */
>   ftp_close(&fin, &tls, &fd);



Re: [patch] ftp: improve SMALL and NOSSL #ifdefs

2019-11-06 Thread Hiltjo Posthuma
On Wed, Nov 06, 2019 at 08:33:09PM +0100, Jan Klemkow wrote:
> Hi Hiltjo,
> 
> On Wed, Nov 06, 2019 at 07:53:02PM +0100, Hiltjo Posthuma wrote:
> > The below patch fixes the #ifndef's for usr.bin/ftp so any combination of 
> > SMALL
> > and NOSSL will compile again.
> 
> Diff looks good for me and works in all ifdef combinations without any
> warning or error.
> 
> OK jan@
> 
> Thanks,
> Jan
> 
> > diff --git usr.bin/ftp/fetch.c usr.bin/ftp/fetch.c
> > index 4c7e14b04bd..15927471f1a 100644
> > --- usr.bin/ftp/fetch.c
> > +++ usr.bin/ftp/fetch.c
> > @@ -201,14 +201,14 @@ url_get(const char *origline, const char *proxyenv, 
> > const char *outfile, int las
> > char *proxyhost = NULL;
> >  #ifndef NOSSL
> > char *sslpath = NULL, *sslhost = NULL;
> > -   char *full_host = NULL;
> > -   const char *scheme;
> > int ishttpurl = 0, ishttpsurl = 0;
> >  #endif /* !NOSSL */
> >  #ifndef SMALL
> > +   char *full_host = NULL;
> > +   const char *scheme;
> > char *locbase;
> > struct addrinfo *ares = NULL;
> > -#endif
> > +#endif /* !SMALL */
> > struct tls *tls = NULL;
> > int status;
> > int save_errno;
> > @@ -221,8 +221,10 @@ url_get(const char *origline, const char *proxyenv, 
> > const char *outfile, int las
> > errx(1, "Can't allocate memory to parse URL");
> > if (strncasecmp(newline, HTTP_URL, sizeof(HTTP_URL) - 1) == 0) {
> > host = newline + sizeof(HTTP_URL) - 1;
> > -#ifndef SMALL
> > +#ifndef NOSSL
> > ishttpurl = 1;
> > +#endif /* !NOSSL */
> > +#ifndef SMALL
> > scheme = HTTP_URL;
> >  #endif /* !SMALL */
> > } else if (strncasecmp(newline, FTP_URL, sizeof(FTP_URL) - 1) == 0) {
> > @@ -234,13 +236,17 @@ url_get(const char *origline, const char *proxyenv, 
> > const char *outfile, int las
> > } else if (strncasecmp(newline, FILE_URL, sizeof(FILE_URL) - 1) == 0) {
> > host = newline + sizeof(FILE_URL) - 1;
> > isfileurl = 1;
> > -#ifndef NOSSL
> > +#ifndef SMALL
> > scheme = FILE_URL;
> > +#endif /* !SMALL */
> > +#ifndef NOSSL
> > } else if (strncasecmp(newline, HTTPS_URL, sizeof(HTTPS_URL) - 1) == 0) 
> > {
> > host = newline + sizeof(HTTPS_URL) - 1;
> > ishttpsurl = 1;
> > -   scheme = HTTPS_URL;
> >  #endif /* !NOSSL */
> > +#ifndef SMALL
> > +   scheme = HTTPS_URL;
> > +#endif /* !SMALL */
> > } else
> > errx(1, "url_get: Invalid URL '%s'", newline);
> >  
> > @@ -1066,8 +1072,10 @@ improper:
> > warnx("Improper response from %s", host);
> >  
> >  cleanup_url_get:
> > -#ifndef NOSSL
> > +#ifndef SMALL
> > free(full_host);
> > +#endif /* !SMALL */
> > +#ifndef NOSSL
> > free(sslhost);
> >  #endif /* !NOSSL */
> > ftp_close(&fin, &tls, &fd);
> 

Thanks for reviewing the patch. Sadly I noticed and made a stupid mistake. When
NOSSL is set, but SMALL is not set.  It will set scheme = HTTPS_URL for the
file handler.

Below is the full updated patch:


diff --git usr.bin/ftp/fetch.c usr.bin/ftp/fetch.c
index 4c7e14b04bd..4511fb29fa1 100644
--- usr.bin/ftp/fetch.c
+++ usr.bin/ftp/fetch.c
@@ -201,14 +201,14 @@ url_get(const char *origline, const char *proxyenv, const 
char *outfile, int las
char *proxyhost = NULL;
 #ifndef NOSSL
char *sslpath = NULL, *sslhost = NULL;
-   char *full_host = NULL;
-   const char *scheme;
int ishttpurl = 0, ishttpsurl = 0;
 #endif /* !NOSSL */
 #ifndef SMALL
+   char *full_host = NULL;
+   const char *scheme;
char *locbase;
struct addrinfo *ares = NULL;
-#endif
+#endif /* !SMALL */
struct tls *tls = NULL;
int status;
int save_errno;
@@ -221,8 +221,10 @@ url_get(const char *origline, const char *proxyenv, const 
char *outfile, int las
errx(1, "Can't allocate memory to parse URL");
if (strncasecmp(newline, HTTP_URL, sizeof(HTTP_URL) - 1) == 0) {
host = newline + sizeof(HTTP_URL) - 1;
-#ifndef SMALL
+#ifndef NOSSL
ishttpurl = 1;
+#endif /* !NOSSL */
+#ifndef SMALL
scheme = HTTP_URL;
 #endif /* !SMALL */
} else if (strncasecmp(newline, FTP_URL, sizeof(FTP_URL) - 1) == 0) {
@@ -234,12 +236,16 @@ url_get(const char *origline, const char *proxyenv, const 
char *outfile, int las
} else if (strncasecmp(newline, FILE_URL, sizeof(FILE_URL) - 1) == 0) {
host = newline + sizeof(FILE_URL) - 1;
isfileurl = 1;
-#ifndef NOSSL
+#ifndef SMALL
scheme = FILE_URL;
+#endif /* !SMALL */
+#ifndef NOSSL
} else if (strncasecmp(newline, HTTPS_URL, sizeof(HTTPS_URL) - 1) == 0) 
{
host = newline + sizeof(HTTPS_URL) - 1;
ishttpsurl = 1;
+#ifndef SMALL
scheme = HTTPS_URL;
+#endif /* !SMALL */
 #endif /* !NOSSL */
} else
errx(1, "url_get: Invalid URL '%s'", newline);
@@ -1066,8 +1072,10 @@ improper:
warnx("Imprope

Re: diff: simplify MGETHDR error handling in tcp_output

2019-11-06 Thread Lucas
Hello Jan,

Jan Klemkow  wrote:
> Hi,
> 
> the following diff simplifies the error handling of MGETHDR() in
> tcp_output().  Jumps earlier to out, prevents a double check of NULL and
> makes the code more readable.
> 
> OK?
> 
> Bye,
> Jan
> 
> Index: netinet/tcp_output.c
> ===
> RCS file: /cvs/src/sys/netinet/tcp_output.c,v
> retrieving revision 1.128
> diff -u -p -r1.128 tcp_output.c
> --- netinet/tcp_output.c  10 Nov 2018 18:40:34 -  1.128
> +++ netinet/tcp_output.c  6 Nov 2019 14:34:40 -
> @@ -652,17 +652,17 @@ send:
>   m->m_data -= hdrlen;
>  #else
>   MGETHDR(m, M_DONTWAIT, MT_HEADER);
> - if (m != NULL && max_linkhdr + hdrlen > MHLEN) {
> + if (m == NULL) {
> + error = ENOBUFS;
> + goto out;
> + }
> + if (max_linkhdr + hdrlen > MHLEN) {
>   MCLGET(m, M_DONTWAIT);
>   if ((m->m_flags & M_EXT) == 0) {
>   m_freem(m);
>   m = NULL;
>   }
>   }
> - if (m == NULL) {
> - error = ENOBUFS;
> - goto out;
> - }
>   m->m_data += max_linkhdr;
>   m->m_len = hdrlen;

I might be missing something, but m can be NULL here, if (m->m_flags &
M_EXT) == 0.

>   if (len <= m_trailingspace(m)) {
> @@ -701,16 +701,16 @@ send:
>   tcpstat_inc(tcps_sndwinup);
>  
>   MGETHDR(m, M_DONTWAIT, MT_HEADER);
> - if (m != NULL && max_linkhdr + hdrlen > MHLEN) {
> + if (m == NULL) {
> + error = ENOBUFS;
> + goto out;
> + }
> + if (max_linkhdr + hdrlen > MHLEN) {
>   MCLGET(m, M_DONTWAIT);
>   if ((m->m_flags & M_EXT) == 0) {
>   m_freem(m);
>   m = NULL;
>   }
> - }
> - if (m == NULL) {
> - error = ENOBUFS;
> - goto out;
>   }
>   m->m_data += max_linkhdr;
>   m->m_len = hdrlen;

And same here.

-Lucas



Re: slaacd(8): remove address / default route proposals

2019-11-06 Thread Tobias Heider
Testing hasn't shown any regressions and the diff makes sense,
ok tobhe@

On Wed, Nov 06, 2019 at 04:00:34PM +0100, Florian Obser wrote:
> On Wed, Nov 06, 2019 at 02:47:33PM +0100, Tobias Heider wrote:
> 
> > I think the tv variable should be deleted in both gen_addr_proposal
> > and gen_dfr_rpoposal. Right now it is unitialized and (only) used
> > in log_debug.
> 
> thanks, fixed! 
> 
> -- 
> I'm not entirely sure you are real.
> 



Re: diff: simplify MGETHDR error handling in tcp_output

2019-11-06 Thread Jan Klemkow
Hi Lucas,

On Wed, Nov 06, 2019 at 08:28:43PM +, Lucas wrote:
> Jan Klemkow  wrote:
> > the following diff simplifies the error handling of MGETHDR() in
> > tcp_output().  Jumps earlier to out, prevents a double check of NULL and
> > makes the code more readable.
> > 
> > OK?
> > 
> > Bye,
> > Jan
> > 
> > Index: netinet/tcp_output.c
> > ===
> > RCS file: /cvs/src/sys/netinet/tcp_output.c,v
> > retrieving revision 1.128
> > diff -u -p -r1.128 tcp_output.c
> > --- netinet/tcp_output.c10 Nov 2018 18:40:34 -  1.128
> > +++ netinet/tcp_output.c6 Nov 2019 14:34:40 -
> > @@ -652,17 +652,17 @@ send:
> > m->m_data -= hdrlen;
> >  #else
> > MGETHDR(m, M_DONTWAIT, MT_HEADER);
> > -   if (m != NULL && max_linkhdr + hdrlen > MHLEN) {
> > +   if (m == NULL) {
> > +   error = ENOBUFS;
> > +   goto out;
> > +   }
> > +   if (max_linkhdr + hdrlen > MHLEN) {
> > MCLGET(m, M_DONTWAIT);
> > if ((m->m_flags & M_EXT) == 0) {
> > m_freem(m);
> > m = NULL;
> > }
> > }
> > -   if (m == NULL) {
> > -   error = ENOBUFS;
> > -   goto out;
> > -   }
> > m->m_data += max_linkhdr;
> > m->m_len = hdrlen;
> 
> I might be missing something, but m can be NULL here, if (m->m_flags &
> M_EXT) == 0.

Yes, you are right.  I missed that.

Thank,
Jan