Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Dec 2011 16:13:04 -0800
From:      Adrian Chadd <adrian@freebsd.org>
To:        Lawrence Stewart <lstewart@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r228986 - in head: share/man/man4 sys/net
Message-ID:  <CAJ-Vmo=mj1QPYRWYhQe1XfTh9oZKjrJJ0LnQjy=QsUsPODK6mA@mail.gmail.com>
In-Reply-To: <201112300857.pBU8vxfP004914@svn.freebsd.org>
References:  <201112300857.pBU8vxfP004914@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This just broke wlan. Please consider fixing this patch :)


Adrian

*** Interface: wlan0: start
can't re-use a leaf (wlan0)!
panic: bpfattach tscfgoid
KDB: enter: panic
[ thread pid 166 tid 100048 ]Stopped at      kdb_enter+0x4c: lui     at,0x8=
048
db>
db> bt
Tracing pid 166 tid 100048 td 0x80c37900
db_trace_thread+30 (?,?,?,?) ra 80074cc0 sp c40075f0 sz 24
80074bac+114 (0,?,ffffffff,?) ra 8007427c sp c4007608 sz 32
80073ef4+388 (?,?,?,?) ra 80074400 sp c4007628 sz 168
db_command_loop+70 (?,?,?,?) ra 80076ac4 sp c40076d0 sz 24
800769d0+f4 (?,?,?,?) ra 801b7560 sp c40076e8 sz 424
kdb_trap+110 (?,?,?,?) ra 8035c7ec sp c4007890 sz 48
trap+bf4 (?,?,?,?) ra 80354560 sp c40078c0 sz 184
MipsKernGenException+134 (0,4,803c089c,113) ra 801b72d8 sp c4007978 sz 200
kdb_enter+4c (?,?,?,?) ra 8017f88c sp c4007a40 sz 24
panic+11c (?,0,80706500,0) ra 802304b8 sp c4007a58 sz 40
bpfattach2+cc (?,?,?,?) ra 802305e0 sp c4007a80 sz 64
bpfattach+10 (?,?,?,?) ra 802448ec sp c4007ac0 sz 24
ether_ifattach+d0 (?,?,?,?) ra 8025f0ac sp c4007ad8 sz 32
ieee80211_vap_attach+104 (?,?,?,?) ra 8007ffe8 sp c4007af8 sz 96
8007f960+688 (?,?,0,?) ra 8026a39c sp c4007b58 sz 88
8026a22c+170 (?,?,?,?) ra 802430dc sp c4007bb0 sz 88
ifc_simple_create+80 (?,?,?,?) ra 80242b04 sp c4007c08 sz 64
80242ab0+54 (?,?,?,?) ra 80242d78 sp c4007c48 sz 40
if_clone_create+a8 (?,?,?,?) ra 8023bdd4 sp c4007c70 sz 40
ifioctl+3a4 (?,?,80c7f460,80c37900) ra 801d8070 sp c4007c98 sz 144
soo_ioctl+3b0 (?,?,?,?) ra 801d2804 sp c4007d28 sz 40
kern_ioctl+248 (?,?,?,?) ra 801d29ac sp c4007d50 sz 64
sys_ioctl+130 (?,?,?,?) ra 8035c3ec sp c4007d90 sz 56
trap+7f4 (?,?,?,?) ra 8035475c sp c4007dc8 sz 184
MipsUserGenException+10c (?,?,?,4061d590) ra 0 sp c4007e80 sz 0
pid 166
db> reset


On 30 December 2011 00:57, Lawrence Stewart <lstewart@freebsd.org> wrote:
> Author: lstewart
> Date: Fri Dec 30 08:57:58 2011
> New Revision: 228986
> URL: http://svn.freebsd.org/changeset/base/228986
>
> Log:
> =A0- Introduce the net.bpf.tscfg sysctl tree and associated code so as to=
 make one
> =A0 =A0aspect of time stamp configuration per interface rather than per B=
PF
> =A0 =A0descriptor. Prior to this, the order in which BPF devices were ope=
ned and the
> =A0 =A0per descriptor time stamp configuration settings could cause non-d=
eterministic
> =A0 =A0and unintended behaviour with respect to time stamping. With the n=
ew scheme, a
> =A0 =A0BPF attached interface's tscfg sysctl entry can be set to "default=
", "none",
> =A0 =A0"fast", "normal" or "external". Setting "default" means use the sy=
stem default
> =A0 =A0option (set with the net.bpf.tscfg.default sysctl), "none" means d=
o not
> =A0 =A0generate time stamps for tapped packets, "fast" means generate tim=
e stamps for
> =A0 =A0tapped packets using a hz granularity system clock read, "normal" =
means
> =A0 =A0generate time stamps for tapped packets using a full timecounter g=
ranularity
> =A0 =A0system clock read and "external" (currently unimplemented) means u=
se the time
> =A0 =A0stamp provided with the packet from an underlying source.
>
> =A0- Utilise the recently introduced sysclock_getsnapshot() and
> =A0 =A0sysclock_snap2bintime() KPIs to ensure the system clock is only re=
ad once per
> =A0 =A0packet, regardless of the number of BPF descriptors and time stamp=
 formats
> =A0 =A0requested. Use the per BPF attached interface time stamp configura=
tion to
> =A0 =A0control if sysclock_getsnapshot() is called and whether the system=
 clock read
> =A0 =A0is fast or normal. The per BPF descriptor time stamp configuration=
 is then
> =A0 =A0used to control how the system clock snapshot is converted to a bi=
ntime by
> =A0 =A0sysclock_snap2bintime().
>
> =A0- Remove all FAST related BPF descriptor flag variants. Performing a "=
fast"
> =A0 =A0read of the system clock is now controlled per BPF attached interf=
ace using
> =A0 =A0the net.bpf.tscfg sysctl tree.
>
> =A0- Update the bpf.4 man page.
>
> =A0Committed on behalf of Julien Ridoux and Darryl Veitch from the Univer=
sity of
> =A0Melbourne, Australia, as part of the FreeBSD Foundation funded "Feed-F=
orward
> =A0Clock Synchronization Algorithms" project.
>
> =A0For more information, see http://www.synclab.org/radclock/
>
> =A0In collaboration with: =A0 =A0 =A0 =A0Julien Ridoux (jridoux at unimel=
b edu au)
>
> Modified:
> =A0head/share/man/man4/bpf.4
> =A0head/sys/net/bpf.c
> =A0head/sys/net/bpf.h
>
> Modified: head/share/man/man4/bpf.4
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/share/man/man4/bpf.4 =A0 Fri Dec 30 06:24:59 2011 =A0 =A0 =A0 =
=A0(r228985)
> +++ head/share/man/man4/bpf.4 =A0 Fri Dec 30 08:57:58 2011 =A0 =A0 =A0 =
=A0(r228986)
> @@ -49,7 +49,7 @@
> =A0.\"
> =A0.\" $FreeBSD$
> =A0.\"
> -.Dd June 15, 2010
> +.Dd December 30, 2011
> =A0.Dt BPF 4
> =A0.Os
> =A0.Sh NAME
> @@ -516,61 +516,48 @@ by default.
> =A0.It Dv BIOCSTSTAMP
> =A0.It Dv BIOCGTSTAMP
> =A0.Pq Li u_int
> -Set or get format and resolution of the time stamps returned by BPF.
> +Set or get the format and resolution of time stamps returned by BPF.
> +The per-BPF descriptor configuration provided by the
> +.Dv BIOCSTSTAMP
> +IOCTL complements the per-interface time stamp configuration detailed in=
 the
> +.Sx CONFIGURATION
> +section.
> +.Pp
> =A0Set to
> -.Dv BPF_T_MICROTIME ,
> -.Dv BPF_T_MICROTIME_FAST ,
> -.Dv BPF_T_MICROTIME_MONOTONIC ,
> +.Dv BPF_T_MICROTIME
> =A0or
> -.Dv BPF_T_MICROTIME_MONOTONIC_FAST
> +.Dv BPF_T_MICROTIME_MONOTONIC
> =A0to get time stamps in 64-bit
> =A0.Vt struct timeval
> =A0format.
> =A0Set to
> -.Dv BPF_T_NANOTIME ,
> -.Dv BPF_T_NANOTIME_FAST ,
> -.Dv BPF_T_NANOTIME_MONOTONIC ,
> +.Dv BPF_T_NANOTIME
> =A0or
> -.Dv BPF_T_NANOTIME_MONOTONIC_FAST
> +.Dv BPF_T_NANOTIME_MONOTONIC
> =A0to get time stamps in 64-bit
> =A0.Vt struct timespec
> =A0format.
> =A0Set to
> -.Dv BPF_T_BINTIME ,
> -.Dv BPF_T_BINTIME_FAST ,
> -.Dv BPF_T_NANOTIME_MONOTONIC ,
> +.Dv BPF_T_BINTIME
> =A0or
> -.Dv BPF_T_BINTIME_MONOTONIC_FAST
> +.Dv BPF_T_BINTIME_MONOTONIC
> =A0to get time stamps in 64-bit
> =A0.Vt struct bintime
> =A0format.
> =A0Set to
> =A0.Dv BPF_T_NONE
> -to ignore time stamp.
> +to not set a time stamp.
> +By default, time stamps are initilized to
> +.Dv BPF_T_MICROTIME .
> +.Pp
> =A0All 64-bit time stamp formats are wrapped in
> =A0.Vt struct bpf_ts .
> =A0The
> -.Dv BPF_T_MICROTIME_FAST ,
> -.Dv BPF_T_NANOTIME_FAST ,
> -.Dv BPF_T_BINTIME_FAST ,
> -.Dv BPF_T_MICROTIME_MONOTONIC_FAST ,
> -.Dv BPF_T_NANOTIME_MONOTONIC_FAST ,
> -and
> -.Dv BPF_T_BINTIME_MONOTONIC_FAST
> -are analogs of corresponding formats without _FAST suffix but do not per=
form
> -a full time counter query, so their accuracy is one timer tick.
> -The
> =A0.Dv BPF_T_MICROTIME_MONOTONIC ,
> =A0.Dv BPF_T_NANOTIME_MONOTONIC ,
> -.Dv BPF_T_BINTIME_MONOTONIC ,
> -.Dv BPF_T_MICROTIME_MONOTONIC_FAST ,
> -.Dv BPF_T_NANOTIME_MONOTONIC_FAST ,
> =A0and
> -.Dv BPF_T_BINTIME_MONOTONIC_FAST
> +.Dv BPF_T_BINTIME_MONOTONIC
> =A0store the time elapsed since kernel boot.
> -This setting is initialized to
> -.Dv BPF_T_MICROTIME
> -by default.
> =A0.It Dv BIOCFEEDBACK
> =A0.Pq Li u_int
> =A0Set packet feedback mode.
> @@ -692,14 +679,14 @@ Currently,
> =A0.Vt bpf_hdr
> =A0is used when the time stamp is set to
> =A0.Dv BPF_T_MICROTIME ,
> -.Dv BPF_T_MICROTIME_FAST ,
> =A0.Dv BPF_T_MICROTIME_MONOTONIC ,
> -.Dv BPF_T_MICROTIME_MONOTONIC_FAST ,
> =A0or
> =A0.Dv BPF_T_NONE
> -for backward compatibility reasons. =A0Otherwise,
> +for backward compatibility reasons.
> +Otherwise,
> =A0.Vt bpf_xhdr
> -is used. =A0However,
> +is used.
> +However,
> =A0.Vt bpf_hdr
> =A0may be deprecated in the near future.
> =A0Suitable precautions
> @@ -952,6 +939,48 @@ array initializers:
> =A0.Fn BPF_STMT opcode operand
> =A0and
> =A0.Fn BPF_JUMP opcode operand true_offset false_offset .
> +.Sh CONFIGURATION
> +Per-interface BPF time stamp configuration is possible via the
> +.Va net.bpf.tscfg
> +.Xr sysctl 8
> +tree which provides the following variables:
> +.Bl -tag -width " =A0 =A0" -offset indent
> +.It Va net.bpf.tscfg.default
> +The default time stamp configuration setting used by all BPF attached in=
terfaces
> +which have not been explicitly changed.
> +Valid values are "none", "fast", "normal" and "external".
> +The default is "normal".
> +.It Va net.bpf.tscfg.<interface>
> +The time stamp configuration setting used by a specific BPF attached int=
erface.
> +There will be a separate entry in the
> +.Va net.bpf.tscfg
> +sysctl tree for each BPF attached interface.
> +Valid values are "default", "none", "fast", "normal" and "external".
> +The default is "default", which means the system wide default setting sp=
ecified
> +by the
> +.Va net.bpf.tscfg.default
> +sysctl is used.
> +.El
> +.Pp
> +The meaning of each per-interface time stamp configuration option is as =
follows:
> +.Bl -tag -width " =A0 =A0" -offset indent
> +.It none
> +Do not generate a time stamp for all packets tapped from this interface.
> +.It fast
> +Generate a time stamp for all packets tapped from this interface by doin=
g a fast
> +read of the system clock.
> +Fast reads have a granularity equivalent to the underlying kernel tick r=
ate.
> +.It normal
> +Generate a time stamp for all packets tapped from this interface by doin=
g a full
> +read of the system clock.
> +Full reads are slower than fast reads, but provide full hardware time co=
unter
> +granularity for the time stamp.
> +.It external
> +Something external to BPF is capable of generating time stamps for all p=
ackets
> +tapped from this interface and BPF should use these external time stamps=
.
> +Currently unimplemented, but will become useful when drivers for NICs wh=
ich
> +support hardware packet time stamping add support for this feature.
> +.El
> =A0.Sh FILES
> =A0.Bl -tag -compact -width /dev/bpf
> =A0.It Pa /dev/bpf
>
> Modified: head/sys/net/bpf.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/net/bpf.c =A0Fri Dec 30 06:24:59 2011 =A0 =A0 =A0 =A0(r22898=
5)
> +++ head/sys/net/bpf.c =A0Fri Dec 30 08:57:58 2011 =A0 =A0 =A0 =A0(r22898=
6)
> @@ -1,12 +1,17 @@
> =A0/*-
> =A0* Copyright (c) 1990, 1991, 1993
> - * =A0 =A0 The Regents of the University of California. =A0All rights re=
served.
> + * =A0 =A0 The Regents of the University of California.
> + * Copyright (c) 2011 The University of Melbourne.
> + * All rights reserved.
> =A0*
> =A0* This code is derived from the Stanford/CMU enet packet filter,
> =A0* (net/enet.c) distributed as part of 4.3BSD, and code contributed
> =A0* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
> =A0* Berkeley Laboratory.
> =A0*
> + * Portions of this software were developed by Julien Ridoux at the Univ=
ersity
> + * of Melbourne under sponsorship from the FreeBSD Foundation.
> + *
> =A0* Redistribution and use in source and binary forms, with or without
> =A0* modification, are permitted provided that the following conditions
> =A0* are met:
> @@ -55,6 +60,7 @@ __FBSDID("$FreeBSD$");
> =A0#include <sys/signalvar.h>
> =A0#include <sys/filio.h>
> =A0#include <sys/sockio.h>
> +#include <sys/timeffc.h>
> =A0#include <sys/ttycom.h>
> =A0#include <sys/uio.h>
>
> @@ -112,7 +118,7 @@ struct bpf_hdr32 {
> =A0 =A0 =A0 =A0uint16_t =A0 =A0 =A0 =A0bh_hdrlen; =A0 =A0 =A0/* length of=
 bpf header (this struct
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 plus alignment padding) */
> =A0};
> -#endif
> +#endif /* !BURN_BRIDGES */
>
> =A0struct bpf_program32 {
> =A0 =A0 =A0 =A0u_int bf_len;
> @@ -130,7 +136,28 @@ struct bpf_dltlist32 {
> =A0#define =A0 =A0 =A0 =A0BIOCGDLTLIST32 =A0_IOWR('B', 121, struct bpf_dl=
tlist32)
> =A0#define =A0 =A0 =A0 =A0BIOCSETWF32 =A0 =A0 _IOW('B', 123, struct bpf_p=
rogram32)
> =A0#define =A0 =A0 =A0 =A0BIOCSETFNR32 =A0 =A0_IOW('B', 130, struct bpf_p=
rogram32)
> -#endif
> +#endif /* COMPAT_FREEBSD32 */
> +
> +static const char *bpfiftstypes[] =3D {
> + =A0 =A0 =A0 "default",
> +#define =A0 =A0 =A0 =A0BPF_TSTAMP_DEFAULT =A0 =A0 =A00
> + =A0 =A0 =A0 "none",
> +#define =A0 =A0 =A0 =A0BPF_TSTAMP_NONE =A0 =A0 =A0 =A0 1
> + =A0 =A0 =A0 "fast",
> +#define =A0 =A0 =A0 =A0BPF_TSTAMP_FAST =A0 =A0 =A0 =A0 2
> + =A0 =A0 =A0 "normal",
> +#define =A0 =A0 =A0 =A0BPF_TSTAMP_NORMAL =A0 =A0 =A0 3
> + =A0 =A0 =A0 "external"
> +#define =A0 =A0 =A0 =A0BPF_TSTAMP_EXTERNAL =A0 =A0 4
> +};
> +#define =A0 =A0 =A0 =A0NUM_BPFIFTSTYPES =A0 =A0 =A0 =A0(sizeof(bpfiftsty=
pes) / sizeof(*bpfiftstypes))
> +
> +#define =A0 =A0 =A0 =A0SET_CLOCKCFG_FLAGS(tstype, active, clock, flags) =
do { =A0 =A0 =A0 =A0 =A0 \
> + =A0 =A0 =A0 (flags) =3D 0; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
> + =A0 =A0 =A0 (clock) =3D SYSCLOCK_FBCK; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
> + =A0 =A0 =A0 if ((tstype) & BPF_T_MONOTONIC) =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 (flags) |=3D FBCLOCK_UPTIME; =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
> +} while (0)
>
> =A0/*
> =A0* bpf_iflist is a list of BPF interface structures, each corresponding=
 to a
> @@ -162,6 +189,7 @@ static void filt_bpfdetach(struct knote
> =A0static int =A0 =A0 filt_bpfread(struct knote *, long);
> =A0static void =A0 =A0bpf_drvinit(void *);
> =A0static int =A0 =A0 bpf_stats_sysctl(SYSCTL_HANDLER_ARGS);
> +static int =A0 =A0 bpf_tscfg_sysctl_handler(SYSCTL_HANDLER_ARGS);
>
> =A0SYSCTL_NODE(_net, OID_AUTO, bpf, CTLFLAG_RW, 0, "bpf sysctl");
> =A0int bpf_maxinsns =3D BPF_MAXINSNS;
> @@ -172,6 +200,12 @@ SYSCTL_INT(_net_bpf, OID_AUTO, zerocopy_
> =A0 =A0 &bpf_zerocopy_enable, 0, "Enable new zero-copy BPF buffer session=
s");
> =A0static SYSCTL_NODE(_net_bpf, OID_AUTO, stats, CTLFLAG_MPSAFE | CTLFLAG=
_RW,
> =A0 =A0 bpf_stats_sysctl, "bpf statistics portal");
> +static SYSCTL_NODE(_net_bpf, OID_AUTO, tscfg, CTLFLAG_RW, NULL,
> + =A0 =A0"Per-interface timestamp configuration");
> +static int bpf_default_tstype =3D BPF_TSTAMP_NORMAL;
> +SYSCTL_PROC(_net_bpf_tscfg, OID_AUTO, default,
> + =A0 =A0CTLTYPE_STRING | CTLFLAG_RW, NULL, 0, bpf_tscfg_sysctl_handler, =
"A",
> + =A0 =A0"Per-interface system wide default timestamp configuration");
>
> =A0static d_open_t =A0 =A0 =A0 =A0bpfopen;
> =A0static d_read_t =A0 =A0 =A0 =A0bpfread;
> @@ -1759,48 +1793,6 @@ filt_bpfread(struct knote *kn, long hint
> =A0 =A0 =A0 =A0return (ready);
> =A0}
>
> -#define =A0 =A0 =A0 =A0BPF_TSTAMP_NONE =A0 =A0 =A0 =A0 0
> -#define =A0 =A0 =A0 =A0BPF_TSTAMP_FAST =A0 =A0 =A0 =A0 1
> -#define =A0 =A0 =A0 =A0BPF_TSTAMP_NORMAL =A0 =A0 =A0 2
> -#define =A0 =A0 =A0 =A0BPF_TSTAMP_EXTERN =A0 =A0 =A0 3
> -
> -static int
> -bpf_ts_quality(int tstype)
> -{
> -
> - =A0 =A0 =A0 if (tstype =3D=3D BPF_T_NONE)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (BPF_TSTAMP_NONE);
> - =A0 =A0 =A0 if ((tstype & BPF_T_FAST) !=3D 0)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (BPF_TSTAMP_FAST);
> -
> - =A0 =A0 =A0 return (BPF_TSTAMP_NORMAL);
> -}
> -
> -static int
> -bpf_gettime(struct bintime *bt, int tstype, struct mbuf *m)
> -{
> - =A0 =A0 =A0 struct m_tag *tag;
> - =A0 =A0 =A0 int quality;
> -
> - =A0 =A0 =A0 quality =3D bpf_ts_quality(tstype);
> - =A0 =A0 =A0 if (quality =3D=3D BPF_TSTAMP_NONE)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (quality);
> -
> - =A0 =A0 =A0 if (m !=3D NULL) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 tag =3D m_tag_locate(m, MTAG_BPF, MTAG_BPF_=
TIMESTAMP, NULL);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (tag !=3D NULL) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *bt =3D *(struct bintime *)=
(tag + 1);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (BPF_TSTAMP_EXTERN);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> - =A0 =A0 =A0 }
> - =A0 =A0 =A0 if (quality =3D=3D BPF_TSTAMP_NORMAL)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 binuptime(bt);
> - =A0 =A0 =A0 else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 getbinuptime(bt);
> -
> - =A0 =A0 =A0 return (quality);
> -}
> -
> =A0/*
> =A0* Incoming linkage from device drivers. =A0Process the packet pkt, of =
length
> =A0* pktlen, which is stored in a contiguous buffer. =A0The packet is par=
sed
> @@ -1811,14 +1803,23 @@ void
> =A0bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen)
> =A0{
> =A0 =A0 =A0 =A0struct bintime bt;
> + =A0 =A0 =A0 struct sysclock_snap cs;
> =A0 =A0 =A0 =A0struct bpf_d *d;
> + =A0 =A0 =A0 int tstype, whichclock;
> + =A0 =A0 =A0 u_int clockflags, slen;
> =A0#ifdef BPF_JITTER
> =A0 =A0 =A0 =A0bpf_jit_filter *bf;
> =A0#endif
> - =A0 =A0 =A0 u_int slen;
> - =A0 =A0 =A0 int gottime;
>
> - =A0 =A0 =A0 gottime =3D BPF_TSTAMP_NONE;
> + =A0 =A0 =A0 tstype =3D bp->tstype;
> + =A0 =A0 =A0 if (tstype =3D=3D BPF_TSTAMP_DEFAULT)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 tstype =3D bpf_default_tstype;
> +
> + =A0 =A0 =A0 if (tstype =3D=3D BPF_TSTAMP_NORMAL || tstype =3D=3D BPF_TS=
TAMP_FAST)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 sysclock_getsnapshot(&cs, tstype =3D=3D BPF=
_TSTAMP_FAST ? 1 : 0);
> + =A0 =A0 =A0 else
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 bzero(&bt, sizeof(bt));
> +
> =A0 =A0 =A0 =A0BPFIF_LOCK(bp);
> =A0 =A0 =A0 =A0LIST_FOREACH(d, &bp->bif_dlist, bd_next) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0BPFD_LOCK(d);
> @@ -1838,8 +1839,16 @@ bpf_tap(struct bpf_if *bp, u_char *pkt,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0slen =3D bpf_filter(d->bd_rfilter, pkt, pk=
tlen, pktlen);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (slen !=3D 0) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0d->bd_fcount++;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (gottime < bpf_ts_qualit=
y(d->bd_tstamp))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gottime =3D=
 bpf_gettime(&bt, d->bd_tstamp, NULL);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (tstype =3D=3D BPF_TSTAM=
P_NORMAL ||
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 tstype =3D=3D BPF_T=
STAMP_FAST) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 whichclock =
=3D -1;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SET_CLOCKCF=
G_FLAGS(d->bd_tstamp,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cs.=
sysclock_active, whichclock, clockflags);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 KASSERT(whi=
chclock >=3D 0, ("Bogus BPF tstamp "
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "co=
nfiguration: 0x%04x", d->bd_tstamp));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sysclock_sn=
ap2bintime(&cs, &bt, whichclock,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 clo=
ckflags);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0#ifdef MAC
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (mac_bpfdesc_check_rece=
ive(d, bp->bif_ifp) =3D=3D 0)
> =A0#endif
> @@ -1862,12 +1871,13 @@ void
> =A0bpf_mtap(struct bpf_if *bp, struct mbuf *m)
> =A0{
> =A0 =A0 =A0 =A0struct bintime bt;
> + =A0 =A0 =A0 struct sysclock_snap cs;
> =A0 =A0 =A0 =A0struct bpf_d *d;
> + =A0 =A0 =A0 u_int clockflags, pktlen, slen;
> + =A0 =A0 =A0 int tstype, whichclock;
> =A0#ifdef BPF_JITTER
> =A0 =A0 =A0 =A0bpf_jit_filter *bf;
> =A0#endif
> - =A0 =A0 =A0 u_int pktlen, slen;
> - =A0 =A0 =A0 int gottime;
>
> =A0 =A0 =A0 =A0/* Skip outgoing duplicate packets. */
> =A0 =A0 =A0 =A0if ((m->m_flags & M_PROMISC) !=3D 0 && m->m_pkthdr.rcvif =
=3D=3D NULL) {
> @@ -1875,9 +1885,22 @@ bpf_mtap(struct bpf_if *bp, struct mbuf
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return;
> =A0 =A0 =A0 =A0}
>
> + =A0 =A0 =A0 tstype =3D bp->tstype;
> + =A0 =A0 =A0 if (tstype =3D=3D BPF_TSTAMP_DEFAULT)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 tstype =3D bpf_default_tstype;
> +
> + =A0 =A0 =A0 if (tstype =3D=3D BPF_TSTAMP_NORMAL || tstype =3D=3D BPF_TS=
TAMP_FAST)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 sysclock_getsnapshot(&cs, tstype =3D=3D BPF=
_TSTAMP_FAST ?
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 1 : 0);
> +#ifdef notyet
> + =A0 =A0 =A0 else if (tstype =3D=3D BPF_TSTAMP_EXTERNAL)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* XXX: Convert external tstamp to bintime.=
 */
> +#endif
> + =A0 =A0 =A0 else
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 bzero(&bt, sizeof(bt));
> +
> =A0 =A0 =A0 =A0pktlen =3D m_length(m, NULL);
>
> - =A0 =A0 =A0 gottime =3D BPF_TSTAMP_NONE;
> =A0 =A0 =A0 =A0BPFIF_LOCK(bp);
> =A0 =A0 =A0 =A0LIST_FOREACH(d, &bp->bif_dlist, bd_next) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (BPF_CHECK_DIRECTION(d, m->m_pkthdr.rcv=
if, bp->bif_ifp))
> @@ -1894,8 +1917,16 @@ bpf_mtap(struct bpf_if *bp, struct mbuf
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0slen =3D bpf_filter(d->bd_rfilter, (u_char=
 *)m, pktlen, 0);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (slen !=3D 0) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0d->bd_fcount++;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (gottime < bpf_ts_qualit=
y(d->bd_tstamp))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gottime =3D=
 bpf_gettime(&bt, d->bd_tstamp, m);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (tstype =3D=3D BPF_TSTAM=
P_NORMAL ||
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 tstype =3D=3D BPF_T=
STAMP_FAST) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 whichclock =
=3D -1;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SET_CLOCKCF=
G_FLAGS(d->bd_tstamp,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cs.=
sysclock_active, whichclock, clockflags);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 KASSERT(whi=
chclock >=3D 0, ("Bogus BPF tstamp "
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "co=
nfiguration: 0x%04x", d->bd_tstamp));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sysclock_sn=
ap2bintime(&cs, &bt, whichclock,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 clo=
ckflags);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0#ifdef MAC
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (mac_bpfdesc_check_rece=
ive(d, bp->bif_ifp) =3D=3D 0)
> =A0#endif
> @@ -1915,10 +1946,11 @@ void
> =A0bpf_mtap2(struct bpf_if *bp, void *data, u_int dlen, struct mbuf *m)
> =A0{
> =A0 =A0 =A0 =A0struct bintime bt;
> + =A0 =A0 =A0 struct sysclock_snap cs;
> =A0 =A0 =A0 =A0struct mbuf mb;
> =A0 =A0 =A0 =A0struct bpf_d *d;
> - =A0 =A0 =A0 u_int pktlen, slen;
> - =A0 =A0 =A0 int gottime;
> + =A0 =A0 =A0 u_int clockflags, pktlen, slen;
> + =A0 =A0 =A0 int tstype, whichclock;
>
> =A0 =A0 =A0 =A0/* Skip outgoing duplicate packets. */
> =A0 =A0 =A0 =A0if ((m->m_flags & M_PROMISC) !=3D 0 && m->m_pkthdr.rcvif =
=3D=3D NULL) {
> @@ -1926,6 +1958,20 @@ bpf_mtap2(struct bpf_if *bp, void *data,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return;
> =A0 =A0 =A0 =A0}
>
> + =A0 =A0 =A0 tstype =3D bp->tstype;
> + =A0 =A0 =A0 if (tstype =3D=3D BPF_TSTAMP_DEFAULT)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 tstype =3D bpf_default_tstype;
> +
> + =A0 =A0 =A0 if (tstype =3D=3D BPF_TSTAMP_NORMAL || tstype =3D=3D BPF_TS=
TAMP_FAST)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 sysclock_getsnapshot(&cs, tstype =3D=3D BPF=
_TSTAMP_FAST ?
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 1 : 0);
> +#ifdef notyet
> + =A0 =A0 =A0 else if (tstype =3D=3D BPF_TSTAMP_EXTERNAL)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* XXX: Convert extern tstamp to bintime. *=
/
> +#endif
> + =A0 =A0 =A0 else
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 bzero(&bt, sizeof(bt));
> +
> =A0 =A0 =A0 =A0pktlen =3D m_length(m, NULL);
> =A0 =A0 =A0 =A0/*
> =A0 =A0 =A0 =A0 * Craft on-stack mbuf suitable for passing to bpf_filter.
> @@ -1937,7 +1983,6 @@ bpf_mtap2(struct bpf_if *bp, void *data,
> =A0 =A0 =A0 =A0mb.m_len =3D dlen;
> =A0 =A0 =A0 =A0pktlen +=3D dlen;
>
> - =A0 =A0 =A0 gottime =3D BPF_TSTAMP_NONE;
> =A0 =A0 =A0 =A0BPFIF_LOCK(bp);
> =A0 =A0 =A0 =A0LIST_FOREACH(d, &bp->bif_dlist, bd_next) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (BPF_CHECK_DIRECTION(d, m->m_pkthdr.rcv=
if, bp->bif_ifp))
> @@ -1947,8 +1992,16 @@ bpf_mtap2(struct bpf_if *bp, void *data,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0slen =3D bpf_filter(d->bd_rfilter, (u_char=
 *)&mb, pktlen, 0);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (slen !=3D 0) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0d->bd_fcount++;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (gottime < bpf_ts_qualit=
y(d->bd_tstamp))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gottime =3D=
 bpf_gettime(&bt, d->bd_tstamp, m);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (tstype =3D=3D BPF_TSTAM=
P_NORMAL ||
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 tstype =3D=3D BPF_T=
STAMP_FAST) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 whichclock =
=3D -1;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SET_CLOCKCF=
G_FLAGS(d->bd_tstamp,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cs.=
sysclock_active, whichclock, clockflags);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 KASSERT(whi=
chclock >=3D 0, ("Bogus BPF tstamp "
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "co=
nfiguration: 0x%04x", d->bd_tstamp));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sysclock_sn=
ap2bintime(&cs, &bt, whichclock,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 clo=
ckflags);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0#ifdef MAC
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (mac_bpfdesc_check_rece=
ive(d, bp->bif_ifp) =3D=3D 0)
> =A0#endif
> @@ -1962,11 +2015,6 @@ bpf_mtap2(struct bpf_if *bp, void *data,
>
> =A0#undef BPF_CHECK_DIRECTION
>
> -#undef BPF_TSTAMP_NONE
> -#undef BPF_TSTAMP_FAST
> -#undef BPF_TSTAMP_NORMAL
> -#undef BPF_TSTAMP_EXTERN
> -
> =A0static int
> =A0bpf_hdrlen(struct bpf_d *d)
> =A0{
> @@ -1998,15 +2046,9 @@ bpf_hdrlen(struct bpf_d *d)
> =A0static void
> =A0bpf_bintime2ts(struct bintime *bt, struct bpf_ts *ts, int tstype)
> =A0{
> - =A0 =A0 =A0 struct bintime bt2;
> =A0 =A0 =A0 =A0struct timeval tsm;
> =A0 =A0 =A0 =A0struct timespec tsn;
>
> - =A0 =A0 =A0 if ((tstype & BPF_T_MONOTONIC) =3D=3D 0) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 bt2 =3D *bt;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 bintime_add(&bt2, &boottimebin);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 bt =3D &bt2;
> - =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0switch (BPF_T_FORMAT(tstype)) {
> =A0 =A0 =A0 =A0case BPF_T_MICROTIME:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0bintime2timeval(bt, &tsm);
> @@ -2200,6 +2242,64 @@ bpf_freed(struct bpf_d *d)
> =A0}
>
> =A0/*
> + * Show or change the per bpf_if or system wide default timestamp config=
uration.
> + */
> +static int
> +bpf_tscfg_sysctl_handler(SYSCTL_HANDLER_ARGS)
> +{
> + =A0 =A0 =A0 char tstype_name[16];
> + =A0 =A0 =A0 struct bpf_if *bp;
> + =A0 =A0 =A0 int error, tstype;
> +
> + =A0 =A0 =A0 bp =3D (struct bpf_if *)arg1;
> +
> + =A0 =A0 =A0 if (req->newptr =3D=3D NULL) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /*
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* Return the name of the BPF interface's=
 timestamp setting, or
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* the system wide default if bp is NULL.
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 strlcpy(tstype_name,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 bpfiftstypes[bp ? bp->tstype : bpf_=
default_tstype],
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sizeof(tstype_name));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D sysctl_handle_string(oidp, tstype=
_name,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sizeof(tstype_name), req);
> + =A0 =A0 =A0 } else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /*
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* Change the timestamp configuration for=
 this BPF interface or
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* the system wide default setting.
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D EINVAL;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 for (tstype =3D 0; tstype < NUM_BPFIFTSTYPE=
S; tstype++) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (strncmp((char *)req->ne=
wptr, bpfiftstypes[tstype],
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 strlen(bpfiftstypes=
[tstype])) =3D=3D 0) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* User spe=
cified type found in bpfiftstypes. */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (strcmp(=
oidp->oid_name, "default") =3D=3D 0) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 /*
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0* Don't allow BPF_TSTAMP_DEFAULT to be
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0* assigned to the
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0* "net.bpf.tscfg.default" OID.
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0*/
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 if (tstype !=3D BPF_TSTAMP_DEFAULT) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 bpf_default_tstype =3D tstype;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 error =3D 0;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 /*
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0* Valid tstype for
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0* "net.bpf.tscfg.<iface>" OID.
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0*/
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 bp->tstype =3D tstype;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 error =3D 0;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 return (error);
> +}
> +
> +/*
> =A0* Attach an interface to bpf. =A0dlt is the link layer type; hdrlen is=
 the
> =A0* fixed size of the link header (variable length headers not yet suppo=
rted).
> =A0*/
> @@ -2225,6 +2325,17 @@ bpfattach2(struct ifnet *ifp, u_int dlt,
> =A0 =A0 =A0 =A0if (bp =3D=3D NULL)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0panic("bpfattach");
>
> + =A0 =A0 =A0 bp->tscfgoid =3D SYSCTL_ADD_PROC(NULL,
> + =A0 =A0 =A0 =A0 =A0 SYSCTL_STATIC_CHILDREN(_net_bpf_tscfg), OID_AUTO, i=
fp->if_xname,
> + =A0 =A0 =A0 =A0 =A0 CTLTYPE_STRING | CTLFLAG_RW, bp, sizeof(bp),
> + =A0 =A0 =A0 =A0 =A0 bpf_tscfg_sysctl_handler, "A",
> + =A0 =A0 =A0 =A0 =A0 "Interface BPF timestamp configuration");
> + =A0 =A0 =A0 if (bp->tscfgoid =3D=3D NULL) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 free(bp, M_BPF);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 panic("bpfattach tscfgoid");
> + =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 bp->tstype =3D BPF_TSTAMP_DEFAULT;
> =A0 =A0 =A0 =A0LIST_INIT(&bp->bif_dlist);
> =A0 =A0 =A0 =A0bp->bif_ifp =3D ifp;
> =A0 =A0 =A0 =A0bp->bif_dlt =3D dlt;
> @@ -2278,6 +2389,7 @@ bpfdetach(struct ifnet *ifp)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0BPFD_UNLOCK(d);
> =A0 =A0 =A0 =A0}
>
> + =A0 =A0 =A0 sysctl_remove_oid(bp->tscfgoid, 1, 0);
> =A0 =A0 =A0 =A0mtx_destroy(&bp->bif_mtx);
> =A0 =A0 =A0 =A0free(bp, M_BPF);
> =A0}
>
> Modified: head/sys/net/bpf.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/net/bpf.h =A0Fri Dec 30 06:24:59 2011 =A0 =A0 =A0 =A0(r22898=
5)
> +++ head/sys/net/bpf.h =A0Fri Dec 30 08:57:58 2011 =A0 =A0 =A0 =A0(r22898=
6)
> @@ -1,12 +1,17 @@
> =A0/*-
> =A0* Copyright (c) 1990, 1991, 1993
> - * =A0 =A0 The Regents of the University of California. =A0All rights re=
served.
> + * =A0 =A0 The Regents of the University of California.
> + * Copyright (c) 2011 The University of Melbourne.
> + * All rights reserved.
> =A0*
> =A0* This code is derived from the Stanford/CMU enet packet filter,
> =A0* (net/enet.c) distributed as part of 4.3BSD, and code contributed
> =A0* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
> =A0* Berkeley Laboratory.
> =A0*
> + * Portions of this software were developed by Julien Ridoux at the Univ=
ersity
> + * of Melbourne under sponsorship from the FreeBSD Foundation.
> + *
> =A0* Redistribution and use in source and binary forms, with or without
> =A0* modification, are permitted provided that the following conditions
> =A0* are met:
> @@ -166,25 +171,17 @@ enum bpf_direction {
> =A0#define =A0 =A0 =A0 =A0BPF_T_NONE =A0 =A0 =A0 =A0 =A0 =A0 =A00x0003
> =A0#define =A0 =A0 =A0 =A0BPF_T_FORMAT_MASK =A0 =A0 =A0 0x0003
> =A0#define =A0 =A0 =A0 =A0BPF_T_NORMAL =A0 =A0 =A0 =A0 =A0 =A00x0000
> -#define =A0 =A0 =A0 =A0BPF_T_FAST =A0 =A0 =A0 =A0 =A0 =A0 =A00x0100
> -#define =A0 =A0 =A0 =A0BPF_T_MONOTONIC =A0 =A0 =A0 =A0 0x0200
> -#define =A0 =A0 =A0 =A0BPF_T_MONOTONIC_FAST =A0 =A0(BPF_T_FAST | BPF_T_M=
ONOTONIC)
> -#define =A0 =A0 =A0 =A0BPF_T_FLAG_MASK =A0 =A0 =A0 =A0 0x0300
> +#define =A0 =A0 =A0 =A0BPF_T_MONOTONIC =A0 =A0 =A0 =A0 0x0100
> +#define =A0 =A0 =A0 =A0BPF_T_FLAG_MASK =A0 =A0 =A0 =A0 0x0100
> =A0#define =A0 =A0 =A0 =A0BPF_T_FORMAT(t) =A0 =A0 =A0 =A0 ((t) & BPF_T_FO=
RMAT_MASK)
> =A0#define =A0 =A0 =A0 =A0BPF_T_FLAG(t) =A0 =A0 =A0 =A0 =A0 ((t) & BPF_T_=
FLAG_MASK)
> =A0#define =A0 =A0 =A0 =A0BPF_T_VALID(t) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
> =A0 =A0 ((t) =3D=3D BPF_T_NONE || (BPF_T_FORMAT(t) !=3D BPF_T_NONE && =A0=
 =A0\
> =A0 =A0 ((t) & ~(BPF_T_FORMAT_MASK | BPF_T_FLAG_MASK)) =3D=3D 0))
>
> -#define =A0 =A0 =A0 =A0BPF_T_MICROTIME_FAST =A0 =A0 =A0 =A0 =A0 =A0(BPF_=
T_MICROTIME | BPF_T_FAST)
> -#define =A0 =A0 =A0 =A0BPF_T_NANOTIME_FAST =A0 =A0 =A0 =A0 =A0 =A0 (BPF_=
T_NANOTIME | BPF_T_FAST)
> -#define =A0 =A0 =A0 =A0BPF_T_BINTIME_FAST =A0 =A0 =A0 =A0 =A0 =A0 =A0(BP=
F_T_BINTIME | BPF_T_FAST)
> =A0#define =A0 =A0 =A0 =A0BPF_T_MICROTIME_MONOTONIC =A0 =A0 =A0 (BPF_T_MI=
CROTIME | BPF_T_MONOTONIC)
> =A0#define =A0 =A0 =A0 =A0BPF_T_NANOTIME_MONOTONIC =A0 =A0 =A0 =A0(BPF_T_=
NANOTIME | BPF_T_MONOTONIC)
> =A0#define =A0 =A0 =A0 =A0BPF_T_BINTIME_MONOTONIC =A0 =A0 =A0 =A0 (BPF_T_=
BINTIME | BPF_T_MONOTONIC)
> -#define =A0 =A0 =A0 =A0BPF_T_MICROTIME_MONOTONIC_FAST =A0(BPF_T_MICROTIM=
E | BPF_T_MONOTONIC_FAST)
> -#define =A0 =A0 =A0 =A0BPF_T_NANOTIME_MONOTONIC_FAST =A0 (BPF_T_NANOTIME=
 | BPF_T_MONOTONIC_FAST)
> -#define =A0 =A0 =A0 =A0BPF_T_BINTIME_MONOTONIC_FAST =A0 =A0(BPF_T_BINTIM=
E | BPF_T_MONOTONIC_FAST)
>
> =A0/*
> =A0* Structure prepended to each packet.
> @@ -1100,6 +1097,8 @@ struct bpf_if {
> =A0 =A0 =A0 =A0u_int bif_hdrlen; =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* length of=
 link header */
> =A0 =A0 =A0 =A0struct ifnet *bif_ifp; =A0 =A0 =A0 =A0 =A0/* corresponding=
 interface */
> =A0 =A0 =A0 =A0struct mtx =A0 =A0 =A0bif_mtx; =A0 =A0 =A0 =A0/* mutex for=
 interface */
> + =A0 =A0 =A0 struct sysctl_oid *tscfgoid; =A0 =A0/* timestamp sysctl oid=
 for interface */
> + =A0 =A0 =A0 int tstype; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* time=
stamp setting for interface */
> =A0};
>
> =A0void =A0 =A0bpf_bufheld(struct bpf_d *d);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-Vmo=mj1QPYRWYhQe1XfTh9oZKjrJJ0LnQjy=QsUsPODK6mA>