#
0bf686c1 |
| 06-Aug-2007 |
Robert Watson <rwatson@FreeBSD.org> |
Remove the now-unused NET_{LOCK,UNLOCK,ASSERT}_GIANT() macros, which previously conditionally acquired Giant based on debug.mpsafenet. As that has now been removed, they are no longer required. Rem
Remove the now-unused NET_{LOCK,UNLOCK,ASSERT}_GIANT() macros, which previously conditionally acquired Giant based on debug.mpsafenet. As that has now been removed, they are no longer required. Removing them significantly simplifies error-handling in the socket layer, eliminated quite a bit of unwinding of locking in error cases.
While here clean up the now unneeded opt_net.h, which previously was used for the NET_WITH_GIANT kernel option. Clean up some related gotos for consistency.
Reviewed by: bz, csjp Tested by: kris Approved by: re (kensmith)
show more ...
|
#
c6b28997 |
| 28-Jul-2007 |
Robert Watson <rwatson@FreeBSD.org> |
Replace references to NET_CALLOUT_MPSAFE with CALLOUT_MPSAFE, and remove definition of NET_CALLOUT_MPSAFE, which is no longer required now that debug.mpsafenet has been removed.
The once over: bz Ap
Replace references to NET_CALLOUT_MPSAFE with CALLOUT_MPSAFE, and remove definition of NET_CALLOUT_MPSAFE, which is no longer required now that debug.mpsafenet has been removed.
The once over: bz Approved by: re (kensmith)
show more ...
|
#
d83e603a |
| 17-Jun-2007 |
Christian S.J. Peron <csjp@FreeBSD.org> |
Silence some gcc 4 warnings. It is expected that the bpf_movein() routine will intialize the the header length and re-initialize the mbuf pointer to reference the mbuf that is allocated after moving
Silence some gcc 4 warnings. It is expected that the bpf_movein() routine will intialize the the header length and re-initialize the mbuf pointer to reference the mbuf that is allocated after moving user supplied packet data in.
show more ...
|
#
5632c982 |
| 15-Jun-2007 |
Christian S.J. Peron <csjp@FreeBSD.org> |
- Conditionally pickup Giant around the network interface ioctl routines if we are running with !mpsafenet - Change un-conditional Giant acquisition around ifpromisc to occur only if we are runni
- Conditionally pickup Giant around the network interface ioctl routines if we are running with !mpsafenet - Change un-conditional Giant acquisition around ifpromisc to occur only if we are running with !mpsafenet
With these locking bits in place, we can now remove the Giant requirement from BPF, so drop the D_NEEDGIANT device flag. This change removes Giant acquisitions around BPF device handlers (read, write, ioctl etc).
MFC after: 1 month Discussed with: rwatson
show more ...
|
#
560a54e1 |
| 26-Feb-2007 |
Jung-uk Kim <jkim@FreeBSD.org> |
Add three new ioctl(2) commands for bpf(4).
- BIOCGDIRECTION and BIOCSDIRECTION get or set the setting determining whether incoming, outgoing, or all packets on the interface should be returned by B
Add three new ioctl(2) commands for bpf(4).
- BIOCGDIRECTION and BIOCSDIRECTION get or set the setting determining whether incoming, outgoing, or all packets on the interface should be returned by BPF. Set to BPF_D_IN to see only incoming packets on the interface. Set to BPF_D_INOUT to see packets originating locally and remotely on the interface. Set to BPF_D_OUT to see only outgoing packets on the interface. This setting is initialized to BPF_D_INOUT by default. BIOCGSEESENT and BIOCSSEESENT are obsoleted by these but kept for backward compatibility.
- BIOCFEEDBACK sets packet feedback mode. This allows injected packets to be fed back as input to the interface when output via the interface is successful. When BPF_D_INOUT direction is set, injected outgoing packet is not returned by BPF to avoid duplication. This flag is initialized to zero by default.
Note that libpcap has been modified to support BPF_D_OUT direction for pcap_setdirection(3) and PCAP_D_OUT direction is functional now.
Reviewed by: rwatson
show more ...
|
#
5d1f8283 |
| 28-Jan-2007 |
Robert Watson <rwatson@FreeBSD.org> |
Remove slightly dubious comment; add descriptive strings for several sysctls.
MFC after: 3 days
|
Revision tags: release/6.2.0_cvs, release/6.2.0 |
|
#
acd3428b |
| 06-Nov-2006 |
Robert Watson <rwatson@FreeBSD.org> |
Sweep kernel replacing suser(9) calls with priv(9) calls, assigning specific privilege names to a broad range of privileges. These may require some future tweaking.
Sponsored by: nCircle
Sweep kernel replacing suser(9) calls with priv(9) calls, assigning specific privilege names to a broad range of privileges. These may require some future tweaking.
Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net>
show more ...
|
#
aed55708 |
| 22-Oct-2006 |
Robert Watson <rwatson@FreeBSD.org> |
Complete break-out of sys/sys/mac.h into sys/security/mac/mac_framework.h begun with a repo-copy of mac.h to mac_framework.h. sys/mac.h now contains the userspace and user<->kernel API and definitio
Complete break-out of sys/sys/mac.h into sys/security/mac/mac_framework.h begun with a repo-copy of mac.h to mac_framework.h. sys/mac.h now contains the userspace and user<->kernel API and definitions, with all in-kernel interfaces moved to mac_framework.h, which is now included across most of the kernel instead.
This change is the first step in a larger cleanup and sweep of MAC Framework interfaces in the kernel, and will not be MFC'd.
Obtained from: TrustedBSD Project Sponsored by: SPARTA
show more ...
|
#
a3594432 |
| 09-Aug-2006 |
Robert Watson <rwatson@FreeBSD.org> |
Since bpf_allocbufs() uses malloc() with M_WAITOK, don't check return values for NULL or return an error state. Assert that all three bpf buffer pointers are NULL before starting.
MFC after: 1 week
|
#
246b5467 |
| 26-Jul-2006 |
Sam Leffler <sam@FreeBSD.org> |
add support for 802.11 packet injection via bpf
Together with: Andrea Bittau <a.bittau@cs.ucl.ac.uk> Reviewed by: arch@ MFC after: 1 month
|
#
91433904 |
| 24-Jul-2006 |
David Malone <dwmalone@FreeBSD.org> |
Rather than calling mircotime() in catchpacket(), make catchpacket() take a timeval indicating when the packet was captured. Move microtime() to the calling functions and grab the timestamp as soon a
Rather than calling mircotime() in catchpacket(), make catchpacket() take a timeval indicating when the packet was captured. Move microtime() to the calling functions and grab the timestamp as soon as we know that we're going to call catchpacket at least once.
This means that we call microtime() once per matched packet, as opposed to once per matched packet per bpf listener. It also means that we return the same timestamp to all bpf listeners, rather than slightly different ones.
It would be more accurate to call microtime() even earlier for all packets, as you have to grab (1+#listener) locks before you can determine if the packet will be logged. You could always grab a timestamp before the locks, but microtime() can be costly, so this didn't seem like a good idea.
(I guess most ethernet interfaces will have a bpf listener these days because of dhclient. That means that we could be doing two bpf locks on most packets going through the interface.)
PR: 71711
show more ...
|
#
4b19419e |
| 03-Jul-2006 |
Christian S.J. Peron <csjp@FreeBSD.org> |
Adjust descriptor locking to tell the kqueue subsystem that our descriptor is already locked. The reason to do this is to avoid two lock+unlock operations in a row. We need the lock here to serialize
Adjust descriptor locking to tell the kqueue subsystem that our descriptor is already locked. The reason to do this is to avoid two lock+unlock operations in a row. We need the lock here to serialize access to bd_pid for stats collection purposes.
Drop the locks all together on detach, as they will be picked up by knlist_remove.
This should fix a failed locking assertion when kqueue is being used with bpf descriptors.
Discussed with: jmg
show more ...
|
#
19ba8395 |
| 15-Jun-2006 |
Christian S.J. Peron <csjp@FreeBSD.org> |
Since we are doing some bpf(4) clean up, change a couple of function prototypes to be consistent. Also, ANSI'fy function definitions. There is no functional change here.
|
#
7eae78a4 |
| 14-Jun-2006 |
Christian S.J. Peron <csjp@FreeBSD.org> |
If bpf(4) has not been compiled into the kernel, initialize the bpf interface pointer to a zeroed, statically allocated bpf_if structure. This way the LIST_EMPTY() macro will always return true. This
If bpf(4) has not been compiled into the kernel, initialize the bpf interface pointer to a zeroed, statically allocated bpf_if structure. This way the LIST_EMPTY() macro will always return true. This allows us to remove the additional unconditional memory reference for each packet in the fast path.
Discussed with: sam
show more ...
|
#
16d878cc |
| 02-Jun-2006 |
Christian S.J. Peron <csjp@FreeBSD.org> |
Fix the following bpf(4) race condition which can result in a panic:
(1) bpf peer attaches to interface netif0 (2) Packet is received by netif0 (3) ifp->if_bpf pointer is checked and handed off t
Fix the following bpf(4) race condition which can result in a panic:
(1) bpf peer attaches to interface netif0 (2) Packet is received by netif0 (3) ifp->if_bpf pointer is checked and handed off to bpf (4) bpf peer detaches from netif0 resulting in ifp->if_bpf being initialized to NULL. (5) ifp->if_bpf is dereferenced by bpf machinery (6) Kaboom
This race condition likely explains the various different kernel panics reported around sending SIGINT to tcpdump or dhclient processes. But really this race can result in kernel panics anywhere you have frequent bpf attach and detach operations with high packet per second load.
Summary of changes:
- Remove the bpf interface's "driverp" member - When we attach bpf interfaces, we now set the ifp->if_bpf member to the bpf interface structure. Once this is done, ifp->if_bpf should never be NULL. [1] - Introduce bpf_peers_present function, an inline operation which will do a lockless read bpf peer list associated with the interface. It should be noted that the bpf code will pickup the bpf_interface lock before adding or removing bpf peers. This should serialize the access to the bpf descriptor list, removing the race. - Expose the bpf_if structure in bpf.h so that the bpf_peers_present function can use it. This also removes the struct bpf_if; hack that was there. - Adjust all consumers of the raw if_bpf structure to use bpf_peers_present
Now what happens is:
(1) Packet is received by netif0 (2) Check to see if bpf descriptor list is empty (3) Pickup the bpf interface lock (4) Hand packet off to process
From the attach/detach side:
(1) Pickup the bpf interface lock (2) Add/remove from bpf descriptor list
Now that we are storing the bpf interface structure with the ifnet, there is is no need to walk the bpf interface list to locate the correct bpf interface. We now simply look up the interface, and initialize the pointer. This has a nice side effect of changing a bpf interface attach operation from O(N) (where N is the number of bpf interfaces), to O(1).
[1] From now on, we can no longer check ifp->if_bpf to tell us whether or not we have any bpf peers that might be interested in receiving packets.
In collaboration with: sam@ MFC after: 1 month
show more ...
|
#
293c06a1 |
| 30-May-2006 |
Ruslan Ermilov <ru@FreeBSD.org> |
Fix -Wundef warnings.
|
Revision tags: release/5.5.0_cvs, release/5.5.0 |
|
#
1fc9e387 |
| 07-May-2006 |
Christian S.J. Peron <csjp@FreeBSD.org> |
Pickup locks for the BPF interface structure. It's quite possible that bpf(4) descriptors can be added and removed on this interface while we are processing stats.
MFC after: 2 weeks
|
Revision tags: release/6.1.0_cvs, release/6.1.0 |
|
#
848c454c |
| 07-Dec-2005 |
Jung-uk Kim <jkim@FreeBSD.org> |
Add BPF Just-In-Time compiler support for ng_bpf(4).
The sysctl is changed from net.bpf.jitter.enable to net.bpf_jitter.enable and this controls both bpf(4) and ng_bpf(4) now.
|
#
ae275efc |
| 06-Dec-2005 |
Jung-uk Kim <jkim@FreeBSD.org> |
Add experimental BPF Just-In-Time compiler for amd64 and i386.
Use the following kernel configuration option to enable:
options BPF_JITTER
If you want to use bpf_filter() instead (e. g., debuggin
Add experimental BPF Just-In-Time compiler for amd64 and i386.
Use the following kernel configuration option to enable:
options BPF_JITTER
If you want to use bpf_filter() instead (e. g., debugging), do:
sysctl net.bpf.jitter.enable=0
to turn it off.
Currently BIOCSETWF and bpf_mtap2() are unsupported, and bpf_mtap() is partially supported because 1) no need, 2) avoid expensive m_copydata(9).
Obtained from: WinPcap 3.1 (for i386)
show more ...
|
Revision tags: release/6.0.0_cvs, release/6.0.0 |
|
#
cb1d4f92 |
| 04-Oct-2005 |
Christian S.J. Peron <csjp@FreeBSD.org> |
Protect PID initializations for statistics by the bpf descriptor locks. Also while we are here, protect the bpf descriptor during knlist_remove{add} operations.
Discussed with: rwatson
|
#
035ba190 |
| 14-Sep-2005 |
Andre Oppermann <andre@FreeBSD.org> |
Undo a tad little optimization to bpf_mtap() introduced in rev. 1.95 which broke the correct handling of the BIOCGSEESENT flag in the bpf listener.
PR: kern/56441 Submitted by: <vys at renet.ru> MF
Undo a tad little optimization to bpf_mtap() introduced in rev. 1.95 which broke the correct handling of the BIOCGSEESENT flag in the bpf listener.
PR: kern/56441 Submitted by: <vys at renet.ru> MFC after: 3 days
show more ...
|
#
b75a24a0 |
| 06-Sep-2005 |
Christian S.J. Peron <csjp@FreeBSD.org> |
Instead of caching the PID which opened the bpf descriptor, continuously refresh the PID which has the descriptor open. The PID is refreshed in various operations like ioctl(2), kevent(2) or poll(2).
Instead of caching the PID which opened the bpf descriptor, continuously refresh the PID which has the descriptor open. The PID is refreshed in various operations like ioctl(2), kevent(2) or poll(2). This produces more accurate information about current bpf consumers. While we are here remove the bd_pcomm member of the bpf stats structure because now that we have an accurate PID we can lookup the via the kern.proc.pid sysctl variable. This is the trick that NetBSD decided to use to deal with this issue.
Special care needs to be taken when MFC'ing this change, as we have made a change to the bpf stats structure. What will end up happening is we will leave the pcomm structure but just mark it as being un-used. This way we keep the ABI in tact.
MFC after: 1 month Discussed with: Rui Paulo < rpaulo at NetBSD dot org >
show more ...
|
#
93e39f0b |
| 22-Aug-2005 |
Christian S.J. Peron <csjp@FreeBSD.org> |
Introduce two new ioctl(2) commands, BIOCLOCK and BIOCSETWF. These commands enhance the security of bpf(4) by further relinquishing the privilege of the bpf(4) consumer (assuming the ioctl commands a
Introduce two new ioctl(2) commands, BIOCLOCK and BIOCSETWF. These commands enhance the security of bpf(4) by further relinquishing the privilege of the bpf(4) consumer (assuming the ioctl commands are being implemented).
Once BIOCLOCK is executed, the device becomes locked which prevents the execution of ioctl(2) commands which can change the underly parameters of the bpf(4) device. An example might be the setting of bpf(4) filter programs or attaching to different network interfaces.
BIOCSETWF can be used to set write filters for outgoing packets. Currently if a bpf(4) consumer is compromised, the bpf(4) descriptor can essentially be used as a raw socket, regardless of consumer's UID. Write filters give users the ability to constrain which packets can be sent through the bpf(4) descriptor.
These features are currently implemented by a couple programs which came from OpenBSD, such as the new dhclient and pflogd.
-Modify bpf_setf(9) to accept a "cmd" parameter. This will be used to specify whether a read or write filter is to be set. -Add a bpf(4) filter program as a parameter to bpf_movein(9) as we will run the filter program on the mbuf data once we move the packet in from user-space. -Rather than execute two uiomove operations, (one for the link header and the other for the packet data), execute one and manually copy the linker header into the sockaddr structure via bcopy. -Restructure bpf_setf to compensate for write filters, as well as read. -Adjust bpf(4) stats structures to include a bd_locked member.
It should be noted that the FreeBSD and OpenBSD implementations differ a bit in the sense that we unconditionally enforce the lock, where OpenBSD enforces it only if the calling credential is not root.
Idea from: OpenBSD Reviewed by: mlaier
show more ...
|
#
4ddfb531 |
| 19-Aug-2005 |
Christian S.J. Peron <csjp@FreeBSD.org> |
Add missing braces around bpf_filter which were missed when I merged the bpfstat code.
Pointed out by: iedowse Pointy hat to: csjp MFC after: 3 days
|
#
6a113b3d |
| 08-Aug-2005 |
Robert Watson <rwatson@FreeBSD.org> |
Merge the dev_clone and dev_clone_cred event handlers into a single event handler, dev_clone, which accepts a credential argument. Implementors of the event can ignore it if they're not interested, a
Merge the dev_clone and dev_clone_cred event handlers into a single event handler, dev_clone, which accepts a credential argument. Implementors of the event can ignore it if they're not interested, and most do. This avoids having multiple event handler types and fall-back/precedence logic in devfs.
This changes the kernel API for /dev cloning, and may affect third party packages containg cloning kernel modules.
Requested by: phk MFC after: 3 days
show more ...
|