From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id DB006A04FD;
	Thu, 24 Mar 2022 19:22:06 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id A7F3042833;
	Thu, 24 Mar 2022 19:22:06 +0100 (CET)
Received: from mga02.intel.com (mga02.intel.com [134.134.136.20])
 by mails.dpdk.org (Postfix) with ESMTP id 2F3F140698;
 Thu, 24 Mar 2022 19:22:04 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1648146124; x=1679682124;
 h=message-id:date:subject:to:cc:references:from:
 in-reply-to:content-transfer-encoding:mime-version;
 bh=9TpT7KGH7i2KFbsJgH1GoWJdIwnO4JsBcu2XPWhnUJQ=;
 b=c+eqv4qJL1uMTjC88Lz/ltjvBAge3g3u5mvvRnM5Z6UyI9/ugY4oPGX0
 MXZzA1bZqX2XST4WdPyzAIdgg29U9xrLbHjLdojy98QHsSRy3s9QsWVqX
 cTDHhnhmcCK71z0nzxDUEze1bEJCRCrAKHqxCeFc36leeUrqmAHQRD8YQ
 USCshb7bxsb9L17TNtxesSmtpojKwVET/mUk/5YZpLryzW+2WjwBnpgjo
 zDglT2rLuAs2m3d54BPexPp/JsLBRrntjmK3Q6LF6Bo+qhGV3rHIGZlsq
 UKOrW/YGK5Vdr3GYGxUswSTYZiJBbsi4JpvouTEuO6MwZxnySk237Blt9 w==;
X-IronPort-AV: E=McAfee;i="6200,9189,10296"; a="245931277"
X-IronPort-AV: E=Sophos;i="5.90,208,1643702400"; d="scan'208";a="245931277"
Received: from fmsmga006.fm.intel.com ([10.253.24.20])
 by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 24 Mar 2022 11:22:03 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.90,208,1643702400"; d="scan'208";a="786261842"
Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14])
 by fmsmga006.fm.intel.com with ESMTP; 24 Mar 2022 11:22:02 -0700
Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by
 ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2308.27; Thu, 24 Mar 2022 11:22:02 -0700
Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by
 ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2308.27; Thu, 24 Mar 2022 11:22:01 -0700
Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by
 orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2308.27 via Frontend Transport; Thu, 24 Mar 2022 11:22:01 -0700
Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.47) by
 edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.1.2308.21; Thu, 24 Mar 2022 11:22:01 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=gysCPdBeqkkcpTvQ9cPBMst0yB8YRShY5r8l7Aa/zQwTK9mlT9X2XebqVRBfF2BUxSozN1cfl3zVnQ/DkBZXWqWc56CtRGoKVsdegl15lxezpLEB+kxFJ9d7wUDsePPwHR4/7uik7ISnmJ3aSRdOtB+3nTGNQyV8N6QhqZFJ6aWt03wn7QEfBM4nFrgSQDC7Oj2OfHQ9CumklN9smeqpWdmjb93hlGaB17MQjZ2xri8bAxuXFUECSUV5e/Gn+DNCi35qL+lmoF7da4QiWf4nNwH0jtwtpYVRFUnSwLI57zKcFYUXNQepqHucXyqqXI4D2EtpsXHk6nTpNxhRaOqJSQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=Tb7W2icaHaNNJcLrSY+Wj50iXFOUKX1ph3IcXmyjmoQ=;
 b=D40L35Tly7t/+vUEQgu/Er3S0s1IshGgCGLOhWZdTDbkr2srSn61r6ItG5fpJD1FKbkMSpyRo5O0mLcl3NFE1RC9gZrbl4ZUvxodO+WGWugIcaKPTJwMEQirFe8TjSuSvlZN8Mnkzv7ZD30RvxKCiuS6guwCdUQ3d5ZvtYXKde3hsQWygMmJ0iQwHvhxp56olpbAFVfeQaA8aSj0bmVfhLxBRVV7hjQ3rhJc42fwjhcUxlVDsXaQw5EXJkTh8Xdkh7C+0E5uloHDYiGIKetMGKpHQfrz5bRMOceqq37EzFjyE2Rq48/QutCxHt2hgkEbj6G1y22JUJKjAc+25K/1Yw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com;
 dkim=pass header.d=intel.com; arc=none
Authentication-Results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=intel.com;
Received: from SJ0PR11MB5772.namprd11.prod.outlook.com (2603:10b6:a03:422::8)
 by BN6PR11MB1267.namprd11.prod.outlook.com (2603:10b6:404:3d::19)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.18; Thu, 24 Mar
 2022 18:21:59 +0000
Received: from SJ0PR11MB5772.namprd11.prod.outlook.com
 ([fe80::25b0:e7b7:e84a:e586]) by SJ0PR11MB5772.namprd11.prod.outlook.com
 ([fe80::25b0:e7b7:e84a:e586%3]) with mapi id 15.20.5102.016; Thu, 24 Mar 2022
 18:21:58 +0000
Message-ID: <48773f5f-0f60-b35b-93cd-6d6260737b78@intel.com>
Date: Thu, 24 Mar 2022 18:21:52 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
 Firefox/91.0 Thunderbird/91.7.0
Subject: Re: [Bug 976] rte_rib (and rte_rib6) do not handle /0 correctly
Content-Language: en-US
To: Stephen Hemminger <stephen@networkplumber.org>, <bugzilla@dpdk.org>
CC: <dev@dpdk.org>
References: <bug-976-3@http.bugs.dpdk.org/>
 <20220323163806.3693bc9b@hermes.local>
From: "Medvedkin, Vladimir" <vladimir.medvedkin@intel.com>
In-Reply-To: <20220323163806.3693bc9b@hermes.local>
Content-Type: text/plain; charset="UTF-8"; format=flowed
Content-Transfer-Encoding: 7bit
X-ClientProxiedBy: LO4P123CA0400.GBRP123.PROD.OUTLOOK.COM
 (2603:10a6:600:189::9) To SJ0PR11MB5772.namprd11.prod.outlook.com
 (2603:10b6:a03:422::8)
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: ef4eecb7-82f1-402c-dd7b-08da0dc32f10
X-MS-TrafficTypeDiagnostic: BN6PR11MB1267:EE_
X-Microsoft-Antispam-PRVS: <BN6PR11MB126745ED8711CCED937E6A2296199@BN6PR11MB1267.namprd11.prod.outlook.com>
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: 9XA5zT0xFPvxAJurcMsr6jjSXIIoy222/UMsxp6I9t6cthPTYuRVJPyYVTpaYPdkERPKpzqVnroAXMoc+I4DVTN1XPVrW5ezQFX3aUs6pEVpi2TYUuX350y0HpKZGPQ/F4hB+swKyi4C1OQyIj9Yan8mEqPh5IYeDyFXe4TFtCkZIHjtPd+QQnRT09Czw7AjjkI+ONJHJmDmRBATvhLJFIwXwwsEVoM94A5w/sRVOPurCdRVFsDg8sBgTX3uoaTZm65mBELK4mZj/TP/X94uHIb+uzA0EdEOARBlluThtyaeOP37jEvo7gSb3tSbBRAVkFYSjn5gd7a3IbI6RWoGFFuXPWZvpYp7wK+Bd0J9TugYmBklbhTmPjlGnG0uo0GnWcy4NFTdpez68Jl9NrkI0yzr+ghdu70WDid9QNBNzfHN9FHcbAALSCoMc+VZHstjy+6krrBu6upoGIf2+Ll66KTcMoWgwVVYkZCGTZjJmjKHkhPEfhPBEV5I1mLg0BK9R2lcb9jqjrl4VCfYIPuj6A72maKhVuUQBGi5tOde9Ois9j19M83pqVi7rIziFXkqF//YfGg+cZ4VqxzOO4L3mcRGzVwqZJiUdQqS+2KHciEMcd0HyTYU7pZ2vlrZ/weKa9Tdt+cpe79cuc6XZ9mdsaOQXCXVPMsFl34l59XZbp6+LmdMgURSJxz2e3vmfHsKZMOA4H/ctitcgQhYf5vdWyR24ESSA3KJ6e9MzNKJ/hg5ixyWeykFAgs4He5dP/Y8E2prqsKT9IOwC6rsB3QZKtqe1QLmUYhZ+nueJ0euVjQ+vlhB4STVupZAZrLtglX2
X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:SJ0PR11MB5772.namprd11.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(13230001)(366004)(6506007)(2906002)(5660300002)(83380400001)(66946007)(66556008)(53546011)(36756003)(316002)(31696002)(26005)(38100700002)(186003)(31686004)(508600001)(2616005)(4326008)(8676002)(6486002)(966005)(8936002)(82960400001)(6666004)(86362001)(6512007)(66476007)(45980500001)(43740500002);
 DIR:OUT; SFP:1102; 
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?V2wrZ2JtK3h5c0Mx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?B?Y1NFbW5tOHN3YytUMFhkTzlMbjdYT2lGRlB0YUNpVTJFejBOYTgrRWFUUS9B?=
 =?utf-8?B?UmtPT2htd3YyOWVLVlZKelpmS1BVNkxtdjdyRWZsbXJaOW15c25nNW9pSjZX?=
 =?utf-8?B?Mm5SSmJ1VmZiVFUrVkNTcm9RUTNtMDRNcDAxQWlRZTJOT0Z1UWRaQVAxT0kv?=
 =?utf-8?B?ZnZGTkJ0aHFIS1Q1Tzlud0s1U3FpZEhtbHdWdmk0RG1uVlM2NXdwQit6Snhy?=
 =?utf-8?B?a25JcUFBQStDakJHN2pTUEZhcVp1UldrRFJCTnBUSTlyczVzS2IyeDVBUmV4?=
 =?utf-8?B?Q29ycU1WREJLQllNaGhIQVVUWUw3MWtIUjNoVzhYaEpTY2xTR2pvU0ZibEp4?=
 =?utf-8?B?ZmhKdlg0MTVTQ1lMMk5pUzF6UVY4TFd0WlBHSXV1SytmeGRUVWswVWFTZ2ZY?=
 =?utf-8?B?eUJkK0FVQjc5Zm1wQ1Q5SWZSckJVbit2b3Y0QzR6YWY1Qng3NGVWOUtFakpT?=
 =?utf-8?B?RXdnTy91NkFnR2hZOGR2MWhvcUZQa3BrVE1CTTJmRGc4bVhNMUZ1eEN3Q1ZT?=
 =?utf-8?B?cW0rWWFqaVJwS3NBamYrZUFVNDIwZGRjSlhhbk1zQkFNOWNjTnpEVzhVL3Br?=
 =?utf-8?Q?iZAKrwIJbWiPII3Q=3D?=
X-MS-Exchange-CrossTenant-Network-Message-Id: ef4eecb7-82f1-402c-dd7b-08da0dc32f10
X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB5772.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2022 18:21:58.9044 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: m2kOXYTqdJVqKQ7fOU7jUFj7HNb0fjFkKBeXgOjn0eaKHpSbiJJT1Dh5MgFiZeoSRWON8PU3H4bmaqsllgzkRFqgmkgJHwEGjOgL1Vfynec=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1267
X-OriginatorOrg: intel.com
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Hi Stephen,

If I understand correctly, the only problem is that 
"rte_rib_get_nxt(rib, 0, 0, ..." does not return 0/0 prefix?
If so, that's what was intended. From the documentation:

  * Retrieve next more specific prefix from the RIB
  * that is covered by ip/depth supernet in an ascending order

so in this case the existing 0/0 route isn't more specific with respect 
to the 0/0 that you pass to rte_rib_get_nxt().
This function was designed in such a way to, for example, help the FIB 
library extract gaps between existing routes within a given super prefix.

However it would be great to have these extra tests, could you please 
update test_tree_traversal() to ignore 0/0 prefix and submit it?

Thanks!


On 23/03/2022 23:38, Stephen Hemminger wrote:
> On Wed, 23 Mar 2022 22:46:02 +0000
> bugzilla@dpdk.org wrote:
> 
>> https://bugs.dpdk.org/show_bug.cgi?id=976
>>
>>              Bug ID: 976
>>             Summary: rte_rib (and rte_rib6) do not handle /0 correctly
>>             Product: DPDK
>>             Version: 21.11
>>            Hardware: All
>>                  OS: All
>>              Status: UNCONFIRMED
>>            Severity: normal
>>            Priority: Normal
>>           Component: other
>>            Assignee: dev@dpdk.org
>>            Reporter: stephen@networkplumber.org
>>    Target Milestone: ---
>>
>> The function rte_rib_insert() allows inserting 0/0 as a default route, but it
>> is not correctly handled by the current tree code. For example lookups will
>> never match the default route and tree traversal never finds this default
>> route.
>>
>> Same bug probably exists in rte_rib6
>>
> 
> Here is a patch to existing RIB test that tests boundary conditions.
> It shows that /0 and /32 work correctly for lookup, it is just the
> tree traversal that is problematic.
> 
> diff --git a/app/test/test_rib.c b/app/test/test_rib.c
> index 06058f8f7c52..403fc85efe95 100644
> --- a/app/test/test_rib.c
> +++ b/app/test/test_rib.c
> @@ -307,6 +307,79 @@ test_basic(void)
>   	return TEST_SUCCESS;
>   }
>   
> +/*
> + * Call insert for successive depths from 0 to 32
> + * and then make sure we get the most specific rule.
> + */
> +static int32_t
> +test_depth(void)
> +{
> +	struct rte_rib *rib = NULL;
> +	struct rte_rib_node *node;
> +	const struct rte_rib_conf config = {
> +		.max_nodes = MAX_RULES,
> +	};
> +	const uint32_t ip = RTE_IPV4(192, 18, 10, 1);
> +	uint64_t next_hop_add = 0;
> +	uint64_t next_hop_return;
> +	uint8_t depth;
> +	int ret;
> +
> +	rib = rte_rib_create(__func__, SOCKET_ID_ANY, &config);
> +	RTE_TEST_ASSERT(rib != NULL, "Failed to create RIB\n");
> +
> +	for (depth = 0; depth <= MAX_DEPTH; depth++) {
> +		node = rte_rib_insert(rib, ip, depth);
> +		RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n");
> +
> +		ret = rte_rib_set_nh(node, next_hop_add);
> +		RTE_TEST_ASSERT(ret == 0,
> +				"Failed to set rte_rib_node field\n");
> +
> +		node = rte_rib_lookup_exact(rib, ip, depth);
> +		RTE_TEST_ASSERT(node != NULL,
> +				"Failed to lookup\n");
> +
> +		ret = rte_rib_get_nh(node, &next_hop_return);
> +		RTE_TEST_ASSERT((ret == 0) && (next_hop_add == next_hop_return),
> +				"Failed to get proper nexthop\n");
> +		++next_hop_add;
> +	}
> +
> +	/* depth = 33 = MAX_DEPTH + 1 */
> +	do {
> +		uint32_t this_ip;
> +		uint8_t this_depth;
> +
> +		--depth;
> +
> +		node = rte_rib_lookup(rib, ip);
> +		RTE_TEST_ASSERT(node != NULL, "Failed to lookup\n");
> +
> +		ret = rte_rib_get_nh(node, &next_hop_return);
> +		RTE_TEST_ASSERT((ret == 0) && (depth == next_hop_return),
> +				"Failed to get proper nexthop\n");
> +
> +		ret = rte_rib_get_depth(node, &this_depth);
> +		RTE_TEST_ASSERT((ret == 0) && (this_depth == depth),
> +				"Failed to get proper depth\n");
> +
> +		ret = rte_rib_get_ip(node, &this_ip);
> +		RTE_TEST_ASSERT(ret == 0, "Failed to get ip\n");
> +
> +		rte_rib_remove(rib, this_ip, this_depth);
> +	} while (depth != 0);
> +
> +	/* all rules removed should return NULL now */
> +	node = rte_rib_lookup(rib, ip);
> +	RTE_TEST_ASSERT(node == NULL,
> +		"Lookup returns non existent rule\n");
> +
> +	rte_rib_free(rib);
> +
> +	return TEST_SUCCESS;
> +}
> +
>   int32_t
>   test_tree_traversal(void)
>   {
> @@ -314,9 +387,17 @@ test_tree_traversal(void)
>   	struct rte_rib_node *node;
>   	struct rte_rib_conf config;
>   
> -	uint32_t ip1 = RTE_IPV4(10, 10, 10, 0);
> -	uint32_t ip2 = RTE_IPV4(10, 10, 130, 80);
> -	uint8_t depth = 30;
> +	uint32_t ips[] = {
> +		RTE_IPV4(0, 0, 0, 0),		/* /0 */
> +		RTE_IPV4(10, 10, 0, 0),		/* /8 */
> +		RTE_IPV4(10, 11, 0, 0),		/* /16 */
> +		RTE_IPV4(10, 10, 130, 0),	/* /24 */
> +		RTE_IPV4(10, 10, 130, 9),	/* /32 */
> +	};
> +	unsigned int count;
> +	uint32_t ip;
> +	uint8_t depth;
> +	int ret;
>   
>   	config.max_nodes = MAX_RULES;
>   	config.ext_sz = 0;
> @@ -324,16 +405,44 @@ test_tree_traversal(void)
>   	rib = rte_rib_create(__func__, SOCKET_ID_ANY, &config);
>   	RTE_TEST_ASSERT(rib != NULL, "Failed to create RIB\n");
>   
> -	node = rte_rib_insert(rib, ip1, depth);
> -	RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n");
> +	for (count = 0; count < RTE_DIM(ips); count++) {
> +		depth = count * 8;
>   
> -	node = rte_rib_insert(rib, ip2, depth);
> -	RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n");
> +		node = rte_rib_insert(rib, ips[count], depth);
> +		RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n");
> +
> +		ret = rte_rib_get_ip(node, &ip);
> +		RTE_TEST_ASSERT(ret == 0, "Failed to get ip\n");
> +
> +		printf("%u: insert [%p] %u.%u.%u.%u/%u\n",
> +		       count, node,
> +		       (ip >> 24) & 0xff,
> +		       (ip >> 16) & 0xff,
> +		       (ip >> 8) & 0xff,
> +		       ip & 0xff, depth);
> +	}
>   
> +	/* Expect to be able to traverse to all nodes */
>   	node = NULL;
> -	node = rte_rib_get_nxt(rib, RTE_IPV4(10, 10, 130, 0), 24, node,
> -			RTE_RIB_GET_NXT_ALL);
> -	RTE_TEST_ASSERT(node != NULL, "Failed to get rib_node\n");
> +	for (count = 0; count < RTE_DIM(ips); count++) {
> +
> +		node = rte_rib_get_nxt(rib, 0, 0,
> +				       node, RTE_RIB_GET_NXT_ALL);
> +		RTE_TEST_ASSERT(node != NULL, "Failed to get rib_node\n");
> +
> +		ret = rte_rib_get_ip(node, &ip);
> +		RTE_TEST_ASSERT(ret == 0, "Failed to get ip\n");
> +
> +		ret = rte_rib_get_depth(node, &depth);
> +		RTE_TEST_ASSERT(ret == 0, "Failed to get depth\n");
> +
> +		printf("%u: walk [%p] %u.%u.%u.%u/%u\n",
> +		       count, node,
> +		       (ip >> 24) & 0xff,
> +		       (ip >> 16) & 0xff,
> +		       (ip >> 8) & 0xff,
> +		       ip & 0xff, depth);
> +	}
>   
>   	rte_rib_free(rib);
>   
> @@ -350,6 +459,7 @@ static struct unit_test_suite rib_tests = {
>   		TEST_CASE(test_insert_invalid),
>   		TEST_CASE(test_get_fn),
>   		TEST_CASE(test_basic),
> +		TEST_CASE(test_depth),
>   		TEST_CASE(test_tree_traversal),
>   		TEST_CASES_END()
>   	}
> 

-- 
Regards,
Vladimir