From owner-freebsd-net@FreeBSD.ORG Fri Aug 19 17:48:23 2005 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 53D3216A41F for ; Fri, 19 Aug 2005 17:48:23 +0000 (GMT) (envelope-from rik@cronyx.ru) Received: from hanoi.cronyx.ru (hanoi.cronyx.ru [144.206.181.53]) by mx1.FreeBSD.org (Postfix) with ESMTP id C84AE43D48 for ; Fri, 19 Aug 2005 17:48:22 +0000 (GMT) (envelope-from rik@cronyx.ru) Received: (from root@localhost) by hanoi.cronyx.ru (8.13.0/vak/3.0) id j7JHjHS2076889 for freebsd-net@freebsd.org.checked; Fri, 19 Aug 2005 21:45:17 +0400 (MSD) (envelope-from rik@cronyx.ru) Received: from [144.206.181.94] (hi.cronyx.ru [144.206.181.94]) by hanoi.cronyx.ru (8.13.0/vak/3.0) with ESMTP id j7JHhblb076863; Fri, 19 Aug 2005 21:43:37 +0400 (MSD) (envelope-from rik@cronyx.ru) Message-ID: <43061A4F.4050206@cronyx.ru> Date: Fri, 19 Aug 2005 21:43:43 +0400 From: Roman Kurakin User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Vos References: <16e39c5105081814432e922ec4@mail.gmail.com> In-Reply-To: <16e39c5105081814432e922ec4@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org Subject: Re: netgraph memory trouble X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Aug 2005 17:48:23 -0000 It seems reasonable. If no one take care of it, let me know I'll commit it. rik David Vos wrote: >I have been playing with the netgraph ng_split node. I discovered >that if I sent packets to it, after a period of time, I could no >longer use netgraph. If I tried to use ngctl, I got an error back >saying that it could not allocate memory to send a message. This also >meant that I could not shutdown my nodes (because that required >sending a message) and had to reboot my machine to start using >netgraph again. > >vmstat -m would show netgraph_item having 128 items in use. > >I am sending data to the split node using the macro >"NG_FWD_ITEM_HOOK". Since this macro nulls out the item pointer, I >assume it takes full responsibility to free the item if something >fails. > >The item then gets sent on to the function: >static int >ng_split_rcvdata(hook_p hook, item_p item) >{ > const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); > int error = 0; > > if (hook == priv->out) { > printf("ng_split: got packet from out hook!\n"); > NG_FREE_ITEM(item); > error = EINVAL; > } else if ((hook == priv->in) && (priv->mixed != NULL)) { > NG_FWD_ITEM_HOOK(error, item, priv->mixed); > } else if ((hook == priv->mixed) && (priv->out != NULL)) { > NG_FWD_ITEM_HOOK(error, item, priv->out); > } > > return (error); >} > > >Unfortunately, if priv->mixed or priv->out are NULL, then there is no >error generated, and the item is not freed. > >I modified the function to be: > printf("ng_split: got packet hook=%x, priv->in=%x, priv->out=%x > priv->mixed=%x\n", hook, priv->in, priv->out, priv->mixed); > > if (hook == priv->out) { > printf("ng_split: got packet from out hook!\n"); > NG_FREE_ITEM(item); > error = EINVAL; > } else if ((hook == priv->in) && (priv->mixed != NULL)) { > NG_FWD_ITEM_HOOK(error, item, priv->mixed); > } else if ((hook == priv->mixed) && (priv->out != NULL)) { > NG_FWD_ITEM_HOOK(error, item, priv->out); > } else { > printf("ng_split: got packet from unknown hook, or >output hook is null\n"); > NG_FREE_ITEM(item); > error = EINVAL; > } > >In /var/log/messages, I get: >Aug 18 15:31:50 foo kernel: ng_split: got packet hook=c53f6800, >priv->in=c53f6800, priv->out=c53f8c80 priv->mixed=0 >Aug 18 15:31:50 foo kernel: ng_split: got packet from unknown hook, or >output hook is null > >After making this modification to the code, I have not experienced any >of the memory problems mentioned above. > > >My conclusion is that an else clause needs to be added to the branches >in the ng_split_rcfdata() function. > >I am using FreeBSD 5.4-RELEASE #1. > > >David >_______________________________________________ >freebsd-net@freebsd.org mailing list >http://lists.freebsd.org/mailman/listinfo/freebsd-net >To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" > > >