NetBSD Problem Report #47861

From www@NetBSD.org  Mon May 27 12:31:22 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 3D2EB70D44
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 27 May 2013 12:31:13 +0000 (UTC)
Message-Id: <20130527123108.B473470D47@mollari.NetBSD.org>
Date: Mon, 27 May 2013 12:30:56 +0000 (UTC)
From: pettai@nordu.net
Reply-To: pettai@nordu.net
To: gnats-bugs@NetBSD.org
Subject: NetBSD 6.x syslog bug then using a remote dual stacked syslog receiver
X-Send-Pr-Version: www-1.0

>Number:         47861
>Category:       bin
>Synopsis:       NetBSD 6.x syslog bug then using a remote dual stacked syslog receiver
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 27 12:35:00 +0000 2013
>Closed-Date:    Thu Jun 13 11:06:45 +0000 2013
>Last-Modified:  Thu Jun 13 11:06:45 +0000 2013
>Originator:     Fredrik Pettai
>Release:        NetBSD 6.0.1 (i386)
>Organization:
NORDUnet
>Environment:
NetBSD stats3.nordu.net 6.0.1 NetBSD 6.0.1 (SD_VMT_TWEAK) #1: Wed Dec 26 21:56:55 CET 2012  root@stats3.nordu.net:/usr/obj/sys/arch/i386/compile/SD_VMT_TWEAK i386
>Description:
The syslog daemon on NetBSD 6.x complains with an error message:

Apr  9 14:00:00 stats3 syslogd[11311]: restart
Apr  9 14:00:00 stats3 syslogd[11311]: sendto() failed: Invalid argument

This started to come as our syslog servers became dual stacked (and equally got both A + AAAA addresses in its DNS name):

bash-4.2# more /etc/syslog.conf
[…]
*.emerg                                                 *
#*.notice                                               root
*.*     @syslog1.nordu.net

Here is a ktrace:

11311      1 syslogd  CALL  sendto(0xa,0xbb74aec3,0x32,0,0xbb774e10,0x10)
11311      1 syslogd  MISC  msghdr: [name=0xbb774e10, namelen=16, iov=0xd89cfc8c, iovlen=1, control=0x0, controllen=133, flags=0]
11311      1 syslogd  MISC  mbsoname: [109.105.113.13]
11311      1 syslogd  RET   sendto -1 errno 22 Invalid argument

he@ did some further debugging:

As far as I can tell, 0x32 is no reason to return EINVAL
according to the rule given in the man page:

    [EINVAL]           The total length of the I/O is more than can be
                       expressed by the ssize_t return value.

Hm, what I do see, though is that it's doing this sequence:

11311      1 syslogd  CALL  sendto(0xa,0xbb74aec3,0x32,0,0xbb74aea0,0x1c)
11311      1 syslogd  MISC  msghdr: [name=0xbb74aea0, namelen=28, iov=0xd89cfc8c, iovlen=1, control=0x0, controllen=133, flags=0]
11311      1 syslogd  MISC  mbsoname: [2001:948:4:2::13]
11311      1 syslogd  GIO   fd 10 wrote 50 bytes
      "<46>Apr 10 10:00:00 stats3 syslogd[11311]: restart"
11311      1 syslogd  RET   sendto 50/0x32
11311      1 syslogd  CALL  sendto(0xa,0xbb74aec3,0x32,0,0xbb774e10,0x10)
11311      1 syslogd  MISC  msghdr: [name=0xbb774e10, namelen=16, iov=0xd89cfc8c, iovlen=1, control=0x0, controllen=133, flags=0]
11311      1 syslogd  MISC  mbsoname: [109.105.113.13]
11311      1 syslogd  RET   sendto -1 errno 22 Invalid argument

So it's trying to use the same socket for sending both IPv6 and
IPv4 datagrams.  I suspect that doesn't work.
>How-To-Repeat:
* Add a DNS name with both A and AAAA for the (remote) syslog receiver host.
* Add its DNS name in /etc/syslog.conf and restart syslogd.


>Fix:

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47861 CVS commit: src/usr.sbin/syslogd
Date: Mon, 27 May 2013 19:15:51 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Mon May 27 23:15:51 UTC 2013

 Modified Files:
 	src/usr.sbin/syslogd: syslogd.c syslogd.h tls.c

 Log Message:
 PR/47861: Fredrik Pettai: keep track of the address family for each socket
 opened and don't send the a message to the wrong family type.


 To generate a diff of this commit:
 cvs rdiff -u -r1.114 -r1.115 src/usr.sbin/syslogd/syslogd.c
 cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/syslogd/syslogd.h
 cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/syslogd/tls.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Fredrik Pettai <pettai@nordu.net>
To: gnats-bugs@NetBSD.org, Christos Zoulas <christos@zoulas.com>
Cc: gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: PR/47861 CVS commit: src/usr.sbin/syslogd
Date: Tue, 28 May 2013 14:00:59 +0200

 Nice,

 I guess this bug is fixed now? (haven't verified yet)
 Will you, or should I request a pull-up?

 Thx,
 /P

From: "SAITOH Masanobu" <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47861 CVS commit: [netbsd-6] src/usr.sbin/syslogd
Date: Thu, 13 Jun 2013 07:11:11 +0000

 Module Name:	src
 Committed By:	msaitoh
 Date:		Thu Jun 13 07:11:11 UTC 2013

 Modified Files:
 	src/usr.sbin/syslogd [netbsd-6]: syslogd.c syslogd.h tls.c

 Log Message:
 Pull up following revision(s) (requested by pettai in ticket #897):
 	usr.sbin/syslogd/tls.c: revision 1.11
 	usr.sbin/syslogd/syslogd.h: revision 1.4
 	usr.sbin/syslogd/syslogd.c: revision 1.115
 PR/47861: Fredrik Pettai: keep track of the address family for each socket
 opened and don't send the a message to the wrong family type.


 To generate a diff of this commit:
 cvs rdiff -u -r1.105 -r1.105.4.1 src/usr.sbin/syslogd/syslogd.c
 cvs rdiff -u -r1.3 -r1.3.8.1 src/usr.sbin/syslogd/syslogd.h
 cvs rdiff -u -r1.9 -r1.9.2.1 src/usr.sbin/syslogd/tls.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Fredrik Pettai <pettai@nordu.net>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: PR/47861 CVS commit: [netbsd-6] src/usr.sbin/syslogd
Date: Thu, 13 Jun 2013 12:15:23 +0200

 I just tried it, and it works great.

 Thanks!

State-Changed-From-To: open->closed
State-Changed-By: msaitoh@NetBSD.org
State-Changed-When: Thu, 13 Jun 2013 11:06:45 +0000
State-Changed-Why:
Submitter reported this problem was fixed!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.