Re: syslogd UDP EADDRNOTAVAIL

2017-10-02 Thread Todd C. Miller
On Mon, 02 Oct 2017 23:00:01 +0200, Alexander Bluhm wrote:

> I think it should be like this.  Our kernel errnos are a bit
> inconsistent, but I think main cause for EADDRNOTAVAIL is when a
> local address is missing.

OK millert@ for after the unlock.

 - todd



Re: syslogd UDP EADDRNOTAVAIL

2017-10-02 Thread Alexander Bluhm
On Mon, Oct 02, 2017 at 11:54:19AM -0600, Todd C. Miller wrote:
> On Mon, 02 Oct 2017 19:05:37 +0200, Alexander Bluhm wrote:
> 
> > Although I think the bug that syslogd was running into was failure
> > in source address selection.  Then the temporary bind failed as
> > there was no suitable address.  There is no "specified address".
> 
> But the source address was specified in the sockaddr passed to
> sendto(2), no?

No, sendto(2) gets the destination address from user land and the
kernel tries to find a suitable source address.  The automatic
source address selection is the problem here.  sendmsg(2) with
IP_SENDSRCADDR could be used to specify the source address, but
that is a very special new feature and syslogd(8) does not use it.

> > Perhaps "No suitable address is available..." for both sendto(2)
> > and connect(2) is more precise.  And bind(2) talks about "the local
> > machine".
> > 
> > So I guess we should say "No suitable address is available on the
> > local machine."
> 
> If you think that is better, I have no real objection.

I think it should be like this.  Our kernel errnos are a bit
inconsistent, but I think main cause for EADDRNOTAVAIL is when a
local address is missing.

ok?  (after unlock)

bluhm

Index: lib/libc/sys/connect.2
===
RCS file: /data/mirror/openbsd/cvs/src/lib/libc/sys/connect.2,v
retrieving revision 1.32
diff -u -p -r1.32 connect.2
--- lib/libc/sys/connect.2  2 Mar 2017 22:12:02 -   1.32
+++ lib/libc/sys/connect.2  2 Oct 2017 20:41:39 -
@@ -162,7 +162,7 @@ is not a valid descriptor.
 .Fa s
 is not a socket.
 .It Bq Er EADDRNOTAVAIL
-The specified address is not available on this machine.
+No suitable address is available on the local machine.
 .It Bq Er EAFNOSUPPORT
 Addresses in the specified address family cannot be used with this socket.
 .It Bq Er EISCONN
Index: lib/libc/sys/send.2
===
RCS file: /data/mirror/openbsd/cvs/src/lib/libc/sys/send.2,v
retrieving revision 1.31
diff -u -p -r1.31 send.2
--- lib/libc/sys/send.2 9 Sep 2014 06:32:37 -   1.31
+++ lib/libc/sys/send.2 2 Oct 2017 20:39:34 -
@@ -207,6 +207,8 @@ and
 .Fn sendmsg
 may return the following errors:
 .Bl -tag -width Er
+.It Bq Er EADDRNOTAVAIL
+No suitable address is available on the local machine.
 .It Bq Er EAFNOSUPPORT
 Addresses in the specified address family cannot be used with this socket.
 .It Bq Er EISCONN



Re: syslogd UDP EADDRNOTAVAIL

2017-10-02 Thread Todd C. Miller
On Mon, 02 Oct 2017 19:05:37 +0200, Alexander Bluhm wrote:

> Although I think the bug that syslogd was running into was failure
> in source address selection.  Then the temporary bind failed as
> there was no suitable address.  There is no "specified address".

But the source address was specified in the sockaddr passed to
sendto(2), no?

> Perhaps "No suitable address is available..." for both sendto(2)
> and connect(2) is more precise.  And bind(2) talks about "the local
> machine".
> 
> So I guess we should say "No suitable address is available on the
> local machine."

If you think that is better, I have no real objection.

 - todd



Re: syslogd UDP EADDRNOTAVAIL

2017-10-02 Thread Alexander Bluhm
On Fri, Sep 29, 2017 at 11:00:44AM -0600, Todd C. Miller wrote:
> ... let's also update send(2) to document EADDRNOTAVAIL
> as a possible error.  The description is lifted from connect(2).
> 
> OK?

Yes, we should document the additional case.

Although I think the bug that syslogd was running into was failure
in source address selection.  Then the temporary bind failed as
there was no suitable address.  There is no "specified address".

Perhaps "No suitable address is available..." for both sendto(2)
and connect(2) is more precise.  And bind(2) talks about "the local
machine".

So I guess we should say "No suitable address is available on the
local machine."

Unfortunately there is another EADDRNOTAVAIL in udp_output() if the
foreign port is 0.  This error number semms wrong.  Perhaps
EDESTADDRREQ would be better there.

bluhm

> Index: lib/libc/sys/send.2
> ===
> RCS file: /cvs/src/lib/libc/sys/send.2,v
> retrieving revision 1.31
> diff -u -p -u -r1.31 send.2
> --- lib/libc/sys/send.2   9 Sep 2014 06:32:37 -   1.31
> +++ lib/libc/sys/send.2   29 Sep 2017 16:53:48 -
> @@ -196,6 +196,8 @@ and
>  .Fn sendto
>  may return the following error:
>  .Bl -tag -width Er
> +.It Bq Er EADDRNOTAVAIL
> +The specified address is not available on this machine.
>  .It Bq Er EINVAL
>  .Fa len
>  was larger than



Re: syslogd UDP EADDRNOTAVAIL

2017-09-29 Thread Rivo Nurges
Hi!

I have seen it number of times but haven't had time to investigate it
further. I have another ugly workaround to fix it. In my case it
happens because the route to the syslog target is learned via bgp and
the bgp is not up when syslogd tries to send first message. Your patch
fixes it.

Rivo

On Fri, 2017-09-29 at 13:44 +0200, Alexander Bluhm wrote:
> Hi,
> 
> A customer has seen a "Can't assign requested address" error from
> syslogd(8) at boot time and then sending messages per UDP did not
> work.  It is a carp(4) setup.
> 
> So I would suggest to add EADDRNOTAVAIL to the error numbers that
> are ignored when doing UDP sendto(2).  Otherwise syslogd would no
> longer send to this destination after the error occured once.
> 
> ok?
> 
> bluhm
> 
> Index: usr.sbin/syslogd/syslogd.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
> retrieving revision 1.249
> diff -u -p -r1.249 syslogd.c
> --- usr.sbin/syslogd/syslogd.c27 Sep 2017 15:09:48 -  
> 1.249
> +++ usr.sbin/syslogd/syslogd.c29 Sep 2017 11:32:51 -
> @@ -1957,6 +1957,7 @@ fprintlog(struct filed *f, int flags, ch
>   (struct sockaddr *)>f_un.f_forw.f_addr,
>   f->f_un.f_forw.f_addr.ss_len) != l) {
>   switch (errno) {
> + case EADDRNOTAVAIL:
>   case EHOSTDOWN:
>   case EHOSTUNREACH:
>   case ENETDOWN:
> 

Re: syslogd UDP EADDRNOTAVAIL

2017-09-29 Thread Todd C. Miller
On Fri, 29 Sep 2017 13:44:51 +0200, Alexander Bluhm wrote:

> A customer has seen a "Can't assign requested address" error from
> syslogd(8) at boot time and then sending messages per UDP did not
> work.  It is a carp(4) setup.
> 
> So I would suggest to add EADDRNOTAVAIL to the error numbers that
> are ignored when doing UDP sendto(2).  Otherwise syslogd would no
> longer send to this destination after the error occured once.

OK millert@ but let's also update send(2) to document EADDRNOTAVAIL
as a possible error.  The description is lifted from connect(2).

OK?

 - todd

Index: lib/libc/sys/send.2
===
RCS file: /cvs/src/lib/libc/sys/send.2,v
retrieving revision 1.31
diff -u -p -u -r1.31 send.2
--- lib/libc/sys/send.2 9 Sep 2014 06:32:37 -   1.31
+++ lib/libc/sys/send.2 29 Sep 2017 16:53:48 -
@@ -196,6 +196,8 @@ and
 .Fn sendto
 may return the following error:
 .Bl -tag -width Er
+.It Bq Er EADDRNOTAVAIL
+The specified address is not available on this machine.
 .It Bq Er EINVAL
 .Fa len
 was larger than



syslogd UDP EADDRNOTAVAIL

2017-09-29 Thread Alexander Bluhm
Hi,

A customer has seen a "Can't assign requested address" error from
syslogd(8) at boot time and then sending messages per UDP did not
work.  It is a carp(4) setup.

So I would suggest to add EADDRNOTAVAIL to the error numbers that
are ignored when doing UDP sendto(2).  Otherwise syslogd would no
longer send to this destination after the error occured once.

ok?

bluhm

Index: usr.sbin/syslogd/syslogd.c
===
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.249
diff -u -p -r1.249 syslogd.c
--- usr.sbin/syslogd/syslogd.c  27 Sep 2017 15:09:48 -  1.249
+++ usr.sbin/syslogd/syslogd.c  29 Sep 2017 11:32:51 -
@@ -1957,6 +1957,7 @@ fprintlog(struct filed *f, int flags, ch
(struct sockaddr *)>f_un.f_forw.f_addr,
f->f_un.f_forw.f_addr.ss_len) != l) {
switch (errno) {
+   case EADDRNOTAVAIL:
case EHOSTDOWN:
case EHOSTUNREACH:
case ENETDOWN: