From owner-freebsd-pf@FreeBSD.ORG Sun Mar 17 18:21:09 2013 Return-Path: Delivered-To: freebsd-pf@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2B179C11 for ; Sun, 17 Mar 2013 18:21:09 +0000 (UTC) (envelope-from vegeta@tuxpowered.net) Received: from mail-wi0-x234.google.com (mail-wi0-x234.google.com [IPv6:2a00:1450:400c:c05::234]) by mx1.freebsd.org (Postfix) with ESMTP id BAB3CCC3 for ; Sun, 17 Mar 2013 18:21:08 +0000 (UTC) Received: by mail-wi0-f180.google.com with SMTP id hi8so1877000wib.13 for ; Sun, 17 Mar 2013 11:21:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:subject:date:user-agent:cc:references :in-reply-to:mime-version:content-type:content-transfer-encoding :message-id:x-gm-message-state; bh=L1wDGFpj2sJPrL/QXtwdWMyWmRELxbmHKLHmpLIhfpk=; b=aRddkXy3xv1a3hq9sJOpVOVNGzdFg7QzC8PSx9NZyTvRhU5ApKu2v3AY8bCtYUnLn9 Ti9tTaPSIvJPQGJs4r8e5qVCSExlrWgyBEyQLOnh01EkPb6ZdGmyJjSQD2+L0f8LsHMx U5/TFZyh6h2q6Gkx1l22MDnkPWSfev5As94xIYXb6/WNSr+vpktFAIAoiG4XQVZ3j16J AIfbLcRnMWmxZlkfAQOCSBd4TXAZ+BHnVrasDv9TF5qjUioB2nyFNdRGmwaP7nvg30+p LtDwbm4z6xymH/VmfIadTYLjKLeN6+TDT6o7nZTe+YGThUOLaiI7XQC85HqaReaKq8oQ VZHw== X-Received: by 10.180.105.99 with SMTP id gl3mr12616605wib.22.1363544467720; Sun, 17 Mar 2013 11:21:07 -0700 (PDT) Received: from zvezda.localnet ([109.144.239.183]) by mx.google.com with ESMTPS id ex1sm10482636wib.7.2013.03.17.11.21.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 17 Mar 2013 11:21:06 -0700 (PDT) From: Kajetan Staszkiewicz To: Ermal =?iso-8859-1?q?Lu=E7i?= Subject: Re: [patch] Source entries removing is awfully slow. Date: Sun, 17 Mar 2013 19:18:17 +0100 User-Agent: KMail/1.13.5 (Linux/3.6.6-vegeta.1; KDE/4.4.5; x86_64; ; ) References: <201303081419.17743.vegeta@tuxpowered.net> <201303111751.18274.vegeta@tuxpowered.net> <201303131651.03250.vegeta@tuxpowered.net> In-Reply-To: <201303131651.03250.vegeta@tuxpowered.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201303171918.17512.vegeta@tuxpowered.net> X-Gm-Message-State: ALoCoQlx4DBQC2xlZDCIAKU+o3FnBVot+1nyUNXo9Y37P3UrbkuZyDruGBErV81b78W8DeZSoLID Cc: "freebsd-net@freebsd.org" , "freebsd-pf@freebsd.org" X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Technical discussion and general questions about packet filter \(pf\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Mar 2013 18:21:09 -0000 Hi, I think I have the answer. 1. Some traffic creates a nat src node and some states. 2. Those states are properly linked to src_node->state_list, each has a proper pointer to nat_src_node. 3. At some point insertion of state (I do not for what reason) fails in this code: 3970 if (pf_state_insert(BOUND_IFACE(r, kif), skw, sks, s)) { 3971 if (pd->proto == IPPROTO_TCP) 3972 pf_normalize_tcp_cleanup(s); 3973 REASON_SET(&reason, PFRES_STATEINS); 3974 pf_src_tree_remove_state(s); 3975 STATE_DEC_COUNTERS(s); 3976 #ifdef __FreeBSD__ 3977 pool_put(&V_pf_state_pl, s); This state already has nat_src_node properly pointing to the src node. pf_src_tree_remove_state() is called: - s->nat_src_node is not NULL - TAILQ_EMPTY is false, as the src_node has a state_list containing some previously and properly created states - TAILQ_REMOVE fails because state s is not in the list, s->srcnode_link is {NULL,NULL}, src_node->state_list's head gets broken, giving the result as in my previous post and kernel panic. With calling TAILQ_INSERT_HEAD before any pf_src_tree_remove_state is potentally called, I have a kernel running stable since the last week. -- | pozdrawiam / greetings | powered by Debian, CentOS and FreeBSD | | Kajetan Staszkiewicz | jabber,email: vegeta()tuxpowered net | | Vegeta | www: http://vegeta.tuxpowered.net | `------------------------^---------------------------------------'