From nobody@FreeBSD.org  Tue Nov 10 14:40:27 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B01E6106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Nov 2009 14:40:27 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 85C238FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Nov 2009 14:40:27 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nAAEeQbR007758
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Nov 2009 14:40:26 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id nAAEeQkY007744;
	Tue, 10 Nov 2009 14:40:26 GMT
	(envelope-from nobody)
Message-Id: <200911101440.nAAEeQkY007744@www.freebsd.org>
Date: Tue, 10 Nov 2009 14:40:26 GMT
From: Sergey Mokryshev <mokr@mokr.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: netstat -f ng not working on 7-STABLE
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         140446
>Category:       kern
>Synopsis:       [patch] netstat(1): netstat -f ng not working on 7-STABLE
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    glebius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 10 14:50:02 UTC 2009
>Closed-Date:    Fri Apr 02 11:08:40 UTC 2010
>Last-Modified:  Fri Apr 02 11:08:40 UTC 2010
>Originator:     Sergey Mokryshev
>Release:        7.2-STABLE
>Organization:
>Environment:
FreeBSD mail.xxx.ru 7.2-STABLE FreeBSD 7.2-STABLE #3: Tue Nov 10 07:20:39 MSK 2009   root@mail.xxx.ru:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
netstat -f ng on FreeBSD 7-STABLE returns an error.

# netstat -f ng
netstat: ng_socket.ko not found
netstat: ng_socket.ko not found

# kldstat
Id Refs Address    Size     Name
 1   11 0xc0400000 a1547c   kernel
 2    1 0xc0e16000 164e8    geom_mirror.ko
 3    1 0xc0e2d000 19cc     accf_data.ko
 4    1 0xc0e2f000 2464     accf_http.ko
 5    1 0xc0e32000 6a4f8    acpi.ko
 6    1 0xc4695000 36000    ipl.ko
 7    1 0xc479b000 4000     ng_socket.ko
 8    2 0xc479f000 b000     netgraph.ko
 9    1 0xc47ee000 4000     ng_mppc.ko
10    1 0xc47f2000 2000     rc4.ko


Preloaded ng_socket.ko does not correct an error.
I did not check with NETGRAPH_SOCKET compiled into kernel.

The problem does not show up on 6.4-STABLE 
(FreeBSD *** 6.4-STABLE FreeBSD 6.4-STABLE #159: Fri Oct  2 23:42:26 UTC 2009)


There is another bug (probably related) with netgraph subsystem
mpd 5.[23] with config like
pppoe_client:
        create bundle static B1
        set iface route default
        set ipcp ranges 0.0.0.0/0 0.0.0.0/0

        create link static L1 pppoe
        set link action bundle B1
        set auth authname user
        set auth password pass
        set link max-redial 0
        set link mtu 1460
        set link keep-alive 10 60
        set pppoe iface fxp0
        set pppoe service ""
#        set nat enable log
immediately exits on SIGSEGV on any (uncommented) "set nat enable ..." command.

  2263 mpd5     STRU  struct sockaddr { AF_NETGRAPH, unknown address family }
  2263 mpd5     RET   recvfrom 128/0x80
  2263 mpd5     CALL  sendto(0x7,0x8850f0a0,0x58,0,0xbf9fe4a2,0x5)
  2263 mpd5     GIO   fd 7 wrote 88 bytes
       0x0000 0800 0000 2000 0000 0400 0000 0000 0000 0a00 0000 1e51 c643 636d 6434 0000 0000  |.... ................Q.Ccmd4....|
       0x0020 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 6d70 6432 3236 332d  |........................mpd2263-|
       0x0040 4231 0000 d8e7 9fbf 240a 0808 ce8f 0b08 1800 0000 0830 5188                      |B1......$............0Q.|

  2263 mpd5     RET   sendto 88/0x58
  2263 mpd5     PSIG  SIGSEGV caught handler=0x80949d0 mask=0x0 code=0x1



>How-To-Repeat:
netstat -f ng


>Fix:


>Release-Note:
>Audit-Trail:

From: Adrian Steinmann <ast@marabu.ch>
To: bug-followup@freebsd.org
Cc:  
Subject: kern/140446 [PATCH]
Date: Fri, 12 Mar 2010 09:07:40 +0100

 Organization:	Currently at devsummit at AsiaBSDCon
 Synopsis:	netstat -f ng broken RELENG7,8,HEAD fix for kern/140446 [PATCH]
 Severity:	non-critical
 Priority:	medium
 Category:	kern
 Class:		sw-bug
 Release:	FreeBSD 7.2-RELEASE-p6 i386 (and above)
 Environment:
 System: FreeBSD oneplusone.ch 7.2-RELEASE-p6 FreeBSD 7.2-RELEASE-p6 #7: Thu Feb 25 08:38:48 CET 2010 root@oneplusone.ch:/usr/obj/usr/src/sys/GENERIC i386
 
 
 Description:
 	Someone removed too much from ng_socket.c and so the 
 	static LIST_HEAD(, ngpcb) ngsocklist;
 	was left missing and netstat -f is now broken.
 
 How-To-Repeat:
 	netstat -f ng fails with "can't find netgraph.ko", with
         pathc the symbol is found.
 Fix:
 
 MD5 (ng_socket.c_RELENG7.patch) = 06979594e8d847ff172f42f4e19bf651
 MD5 (ng_socket.c_RELENG8.patch) = 164b2bfc3773fb0da27c11eeceace06a
 
 http://steinmann.com/ng_socket.c_RELENG7.patch
 http://steinmann.com/ng_socket.c_RELENG8.patch
Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: brooks 
Responsible-Changed-When: Fri Mar 12 08:43:37 UTC 2010 
Responsible-Changed-Why:  
glebius broke this is r163463 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140446 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/140446: commit references a PR
Date: Fri, 12 Mar 2010 14:51:58 +0000 (UTC)

 Author: glebius
 Date: Fri Mar 12 14:51:42 2010
 New Revision: 205082
 URL: http://svn.freebsd.org/changeset/base/205082
 
 Log:
   Fix 'netstat -f netgraph', which I had broken in r163463 ling time
   ago in 2006. This linked list is actually needed for userland.
   
   PR:		kern/140446
   Submitted by:	Adrian Steinmann <ast marabu.ch>
 
 Modified:
   head/sys/netgraph/ng_socket.c
 
 Modified: head/sys/netgraph/ng_socket.c
 ==============================================================================
 --- head/sys/netgraph/ng_socket.c	Fri Mar 12 13:53:52 2010	(r205081)
 +++ head/sys/netgraph/ng_socket.c	Fri Mar 12 14:51:42 2010	(r205082)
 @@ -156,6 +156,11 @@ static u_long ngpdg_recvspace = 20 * 102
  SYSCTL_INT(_net_graph, OID_AUTO, recvspace, CTLFLAG_RW,
      &ngpdg_recvspace , 0, "Maximum space for incoming Netgraph datagrams");
  
 +/* List of all sockets (for netstat -f netgraph) */
 +static LIST_HEAD(, ngpcb) ngsocklist;
 +
 +static struct mtx	ngsocketlist_mtx;
 +
  #define sotongpcb(so) ((struct ngpcb *)(so)->so_pcb)
  
  /* If getting unexplained errors returned, set this to "kdb_enter("X"); */
 @@ -584,6 +589,10 @@ ng_attach_common(struct socket *so, int 
  	so->so_pcb = (caddr_t)pcbp;
  	pcbp->ng_socket = so;
  
 +	/* Add the socket to linked list */
 +	mtx_lock(&ngsocketlist_mtx);
 +	LIST_INSERT_HEAD(&ngsocklist, pcbp, socks);
 +	mtx_unlock(&ngsocketlist_mtx);
  	return (0);
  }
  
 @@ -617,6 +626,9 @@ ng_detach_common(struct ngpcb *pcbp, int
  	}
  
  	pcbp->ng_socket->so_pcb = NULL;
 +	mtx_lock(&ngsocketlist_mtx);
 +	LIST_REMOVE(pcbp, socks);
 +	mtx_unlock(&ngsocketlist_mtx);
  	free(pcbp, M_PCB);
  }
  
 @@ -1115,8 +1127,14 @@ ngs_mod_event(module_t mod, int event, v
  
  	switch (event) {
  	case MOD_LOAD:
 +		mtx_init(&ngsocketlist_mtx, "ng_socketlist", NULL, MTX_DEF);
  		break;
  	case MOD_UNLOAD:
 +		/* Ensure there are no open netgraph sockets. */
 +		if (!LIST_EMPTY(&ngsocklist)) {
 +			error = EBUSY;
 +			break;
 +		}
  #ifdef NOTYET
  		/* Unregister protocol domain XXX can't do this yet.. */
  #endif
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: glebius 
State-Changed-When: Mon Mar 15 09:17:07 UTC 2010 
State-Changed-Why:  
fixed in head 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140446 
State-Changed-From-To: patched->closed 
State-Changed-By: glebius 
State-Changed-When: Fri Apr 2 11:08:27 UTC 2010 
State-Changed-Why:  
Merged to 8. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140446 
>Unformatted:
