From owner-freebsd-net@FreeBSD.ORG Wed Jun 9 19:31:47 2010 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1FE45106566B; Wed, 9 Jun 2010 19:31:47 +0000 (UTC) (envelope-from ghelmer@palisadesystems.com) Received: from smtp-saas2.palisadesystems.com (smtp-saas2.palisadesystems.com [216.81.161.162]) by mx1.freebsd.org (Postfix) with ESMTP id F13968FC08; Wed, 9 Jun 2010 19:31:46 +0000 (UTC) Received: from [172.16.2.94] (localhost.palisadesystems.com [127.0.0.1]) by smtp-saas2.palisadesystems.com (8.14.3/8.14.3) with ESMTP id o59J4fge039178; Wed, 9 Jun 2010 14:04:48 -0500 (CDT) (envelope-from ghelmer@palisadesystems.com) Mime-Version: 1.0 (Apple Message framework v1078) Content-Type: text/plain; charset=us-ascii From: Guy Helmer In-Reply-To: <201006091444.50560.jkim@FreeBSD.org> Date: Wed, 9 Jun 2010 14:04:41 -0500 Content-Transfer-Encoding: 7bit Message-Id: <95304DD4-3F41-4439-BD54-6E31D0445FEC@palisadesystems.com> References: <201006091444.50560.jkim@FreeBSD.org> To: Jung-uk Kim X-Mailer: Apple Mail (2.1078) X-PacketSure-Scanned: Yes Cc: freebsd-net@freebsd.org Subject: Re: [RFC] BPF timestamping 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: Wed, 09 Jun 2010 19:31:47 -0000 On Jun 9, 2010, at 1:44 PM, Jung-uk Kim wrote: > bpf(4) can only timestamp packets with microtime(9). I want to expand > it to be able to use different format and resolution. The patch is > here: > > http://people.freebsd.org/~jkim/bpf_tstamp.diff > > With this patch, we can select different format and resolution of the > timestamps. It is done via ioctl(2) with BIOCSTSTAMP command. > Similarly, you can get the current format and resolution with > BIOCGTSTAMP command. Currently, the following functions are > available: > > BPF_T_MICROTIME microtime(9) > BPF_T_NANOTIME nanotime(9) > BPF_T_BINTIME bintime(9) > BPF_T_MICROTIME_FAST getmicrotime(9) > BPF_T_NANOTIME_FAST getnanotime(9) > BPF_T_BINTIME_FAST getbintime(9) > BPF_T_NONE ignore time stamps > I like this idea. I've been using getmicrotime(9) myself. > (Note: Additionally, there is an experimental machanism to tag packets > with timestamps in struct bintime format via mbuf_tags(9) from lower > layer, e.g., device driver. However, I didn't test it because I > wasn't sure whether this is the right thing to do.) Not sure about this. > While I was here, I moved the bogus SIZEOF_BPF_HDR macro into bpf.c > and tried to make it little bit more correct. For example, the > 32-bit shim should be able to handle alignment more properly for > non-Ethernet DLTs. I tried my best not to break ABI/API (especially > for 32-bit platforms) and relevant places are all marked with > BURN_BRIDGES. Not sure about this either. Guy