Subject: kern/31471: comments wrong in sys/protosw.h
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Iain Hibbert <plunky@rya-online.net>
List: netbsd-bugs
Date: 10/04/2005 19:07:00
>Number:         31471
>Category:       kern
>Synopsis:       comments in sys/protosw.h are wrong
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 04 19:07:00 +0000 2005
>Originator:     Iain Hibbert
>Release:        NetBSD 2.0 (still wrong in -current)
>Organization:
dis
>Environment:
	
	
System: NetBSD galant 2.0 NetBSD 2.0 (GALANT) #102: Tue Oct 4 14:11:35 BST 2005 plunky@galant:/home/plunky/src/sys/arch/i386/compile/GALANT i386
Architecture: i386
Machine: i386
>Description:
	in sys/protosw.h, there is the following comment:

/*
 * The arguments to usrreq are:
 *	(*protosw[].pr_usrreq)(up, req, m, nam, opt, p);
 * where up is a (struct socket *), req is one of these requests,
 * m is a optional mbuf chain containing a message,
 * nam is an optional mbuf chain containing an address,
 * opt is a pointer to a socketopt structure or nil,
 * and p is a pointer to the process requesting the action (if any).
 * The protocol is responsible for disposal of the mbuf chain m,
 * the caller is responsible for any space held by nam and opt.
 * A non-zero return from usrreq gives an
 * UNIX error number which should be passed to higher level software.
 */

 So,

 "opt is a pointer to socketopt structure or nil"

  in fact, the only place I can see that calls pr_usrreq(.., PRU_SEND, ..)
  is in kern/uipc_socket.c and it is actually sending an mbuf containing
  socket options, so:

  "opt is an optional mbuf containing socket options"

  would be more precise since there is no 'socketopt' structure, in fact its
  a cmsghdr structure that come through there in the mbuf.

  my primary concern was the next bit though, about disposal - the calling kernel
  code does NOT free any such control mbuf, rather expects the protocol to do so,
  thus:

  "The protocol is responsible for disposal of the mbuf chains m and opt"
  "the caller is responsible for any space held by nam"

>How-To-Repeat:
  Try to write a protocol from scratch, then get confused by the only available
  documentation (the source code :)

>Fix:
  use a text editor, possibly 'vi' or even 'ex' if you are really hardcore.. sorry, I
  can't provide a patch as my source is a little out of date.

>Unformatted: