From owner-freebsd-net@FreeBSD.ORG Tue Mar 26 10:47:38 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B6BB167D for ; Tue, 26 Mar 2013 10:47:38 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from mail.ipfw.ru (unknown [IPv6:2a01:4f8:120:6141::2]) by mx1.freebsd.org (Postfix) with ESMTP id 7FE1715A for ; Tue, 26 Mar 2013 10:47:38 +0000 (UTC) Received: from [2a02:6b8:0:401:222:4dff:fe50:cd2f] (helo=dhcp170-36-red.yandex.net) by mail.ipfw.ru with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.76 (FreeBSD)) (envelope-from ) id 1UKRT8-0000Ko-8I; Tue, 26 Mar 2013 14:51:06 +0400 Message-ID: <51517CBD.8080805@FreeBSD.org> Date: Tue, 26 Mar 2013 14:47:25 +0400 From: "Alexander V. Chernikov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Stas Timokhin Subject: Re: ng_netflow patch for AS filling References: <201303261714.49770.devel@stasyan.com> In-Reply-To: <201303261714.49770.devel@stasyan.com> X-Enigmail-Version: 1.4.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 10:47:38 -0000 On 26.03.2013 14:14, Stas Timokhin wrote: > Hello ! Hello. > > > > Patch for injecting information network->as_number from extrernal > sources (RIPE database, for example) into kernel and filling src and dst > AS-number in Netflow v5 datagrams. > > > > http://www.stasyan.com/devel/ng_netflow/patch_ngnetflow_asnum.txt It is better to attach patches in ML to make it easier for others to comment :) + o1=(htonl(rec->src_addr)>>24)&0xFF; + o2=(htonl(rec->src_addr)>>16)&0xFF; + o3=(htonl(rec->src_addr)>>8)&0xFF; + o4=(htonl(rec->src_addr))&0xFF; + a1=GetAsnumber(aaa,o1,o2,o3,o4); Why do you need o* here? Why not using in_addr in GetAsnumber()? Why you are using 255 as multiplier ? MALLOC(asn[255*i1+i2].ptr_low,struct ascelllow*, sizeof(struct ascelllow),M_NETFLOW_HASH,M_NOWAIT); ^^ malloc() with M_WAITOK can be used here. + u_int8_t masklen; + u_int16_t asnum; +}; You should support at least loading 32-bit ASNs (and convert them to 23456 for v5 export). + case NGM_NETFLOW_DELETENETFROMAS: + { + break; + } You should probably support deleting prefixes :) +struct ascellhigh { + struct ascelllow* ptr_low; +}; Do we need another layer here? While v5 export supports IPv4 and 2-byte ASNs only it is probably much better to include IPv6 support at least in NGM_ messages ( like ng_ksocket do ). > > > > Example of converted RIPE-database for it: > > http://www.stasyan.com/devel/ng_netflow/ripe_201303.ng > > > > This patch made for FreeBSD 10.x-current for state at 26.02.2013. > > > > > -- WBR, Alexander