NetBSD Problem Report #48422

From www@NetBSD.org  Tue Dec  3 04:03:36 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 56A8FA644F
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  3 Dec 2013 04:03:36 +0000 (UTC)
Message-Id: <20131203040334.78316A6451@mollari.NetBSD.org>
Date: Tue,  3 Dec 2013 04:03:34 +0000 (UTC)
From: dmarquess@gmail.com
Reply-To: dmarquess@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Possible recvmmsg/sendmmsg implementation problem
X-Send-Pr-Version: www-1.0

>Number:         48422
>Category:       kern
>Synopsis:       Possible recvmmsg/sendmmsg implementation problem
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 03 04:05:00 +0000 2013
>Originator:     Dustin Marquess
>Release:        6.6.28
>Organization:
>Environment:
NetBSD bobdole.fdf.net 6.99.28 NetBSD 6.99.28 (BOBDOLE) #0: Thu Nov 28 22:40:55 UTC 2013  root@bobdole.fdf.net:/usr/src/sys/arch/amd64/compile/BOBDOLE amd64
>Description:
nsd 4.0 from net/nsd goes into a infinite loop when recvmmsg/sendmmsg support is enabled (which it is, by default).  When disabling that (by passing --disable-recvmmsg to its configure), it works fine.  The same code seems to work on Linux, so I'm assuming that either this is a problem with the NetBSD implementation, or that nsd is using it wrong but in a way that just happens to work on Linux.

ktruss output:

  2538      1 nsd      __clock_gettime50(0x3, 0x7f7fffffd6c0) = 0
  2538      1 nsd      emul(netbsd)
  2538      1 nsd      __gettimeofday50(0x7f7fffffd6d0, 0) = 0
  2538      1 nsd      recvmmsg(0x3, 0x68cb80, 0x64, 0, 0) = 1
       "\M-Q?\^A\0\0\^A\0\0\0\0\0\0\abobdole\^Cfdf\^Cnet\0\0\^A\0\^A"
  2538      1 nsd      sendmmsg(0x3, 0x68cb80, 0x1, 0) Err#35 EAGAIN
  2538      1 nsd      issetugid()                 = 1
  2538      1 nsd      open("/usr/share/nls/nls.alias.db", 0x400000, 0) Err#2 ENOENT
  2538      1 nsd      open("/usr/share/nls/nls.alias", 0x400000, 0) = 8
  2538      1 nsd      __fstat50(0x8, 0x7f7fffffcc70) = 0
  2538      1 nsd      mmap(0, 0x5f0, 0x1, 0x2, 0x8, 0, 0) = 0x7f7ff7f65000
  2538      1 nsd      close(0x8)                  = 0
  2538      1 nsd      munmap(0x7f7ff7f65000, 0x5f0) = 0
  2538      1 nsd      open("/usr/share/nls/C/libc.cat", 0, 0x3a) = 8
  2538      1 nsd      __fstat50(0x8, 0x7f7fffffccf0) = 0
  2538      1 nsd      mmap(0, 0x10be, 0x1, 0x1, 0x8, 0, 0) = 0x7f7ff7f64000
  2538      1 nsd      close(0x8)                  = 0
  2538      1 nsd      munmap(0x7f7ff7f64000, 0x10be) = 0
  2538      1 nsd      __gettimeofday50(0x7f7fffffc190, 0) = 0
  2538      1 nsd      getpid()                    = 2538, 13362
  2538      1 nsd      fcntl(0xa, 0x3, 0)          = 2
  2538      1 nsd      sendto(0xa, 0x7f7fffffc1b0, 0x75, 0, 0, 0) = 117
       "<27>1 2013-12-03T03:42:32.309243+00:00 bobdole.fdf.net nsd 2538 - - s"
  2538      1 nsd      getpid()                    = 2538, 13362
  2538      1 nsd      __gettimeofday50(0x7f7fffffd320, 0) = 0
  2538      1 nsd      write(0x2, 0x7f7fffffca10, 0x50) = 80
       "[1386042152] nsd[2538]: error: sendmmsg failed: Resource temporarily "
  2538      1 nsd      write(0x2, 0x652bc7, 0x1)   = 1
       "\n"
  2538      1 nsd      __clock_gettime50(0x3, 0x7f7fffffd6c0) = 0
  2538      1 nsd      __gettimeofday50(0x7f7fffffd6d0, 0) = 0
  2538      1 nsd      __kevent50(0x7, 0x7f7ff7315000, 0, 0x7f7ff7316000, 0x40, 0) = 1
  2538      1 nsd      __clock_gettime50(0x3, 0x7f7fffffd6c0) = 0
  2538      1 nsd      __gettimeofday50(0x7f7fffffd6d0, 0) = 0
  2538      1 nsd      recvmmsg(0x3, 0x68cb80, 0x64, 0, 0) Err#35 EAGAIN
  2538      1 nsd      __clock_gettime50(0x3, 0x7f7fffffd6c0) = 0
  2538      1 nsd      __gettimeofday50(0x7f7fffffd6d0, 0) = 0
  2538      1 nsd      __kevent50(0x7, 0x7f7ff7315000, 0, 0x7f7ff7316000, 0x40, 0) = 1
  2538      1 nsd      __clock_gettime50(0x3, 0x7f7fffffd6c0) = 0
  2538      1 nsd      __gettimeofday50(0x7f7fffffd6d0, 0) = 0
  2538      1 nsd      recvmmsg(0x3, 0x68cb80, 0x64, 0, 0) Err#35 EAGAIN

So the initial recvmmsg works, however every subsequent call to either recvmmsg/sendmmsg always return EAGAIN, causing the process to loop.
>How-To-Repeat:
Install net/nsd (from pkgsrc HEAD) on a -current kernel since the original 2012/06/22 import of recvmmsg/sendmmsg.
>Fix:

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.