History log of /freebsd-current/sbin/dhclient/bpf.c
Revision Date Author Comments
# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# abf5bff7 14-Feb-2022 Franco Fichtner <franco@opnsense.org>

dhclient: support VID 0 (no vlan) decapsulation

VLAN ID 0 is supposed to be interpreted as having no VLAN with a bit of
priority on the side, but the kernel is not able to decapsulate this on
the fly so dhclient needs to take care of it.

Reviewed by: markj
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D31515


# 5851803f 19-Aug-2021 Franco Fichtner <franco@opnsense.org>

dhclient: remove patching of static values in BPF programs

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31502


# 1e7fe2fb 21-Jul-2021 Luiz Otavio O Souza <loos@FreeBSD.org>

bpf: Add an ioctl to set the VLAN Priority on packets sent by bpf

This allows the use of VLAN PCP in dhclient, which is required for
certain ISPs (such as Orange.fr).

Reviewed by: bcr (man page)
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31263


# 377421df 04-Nov-2018 Mariusz Zaborski <oshogbo@FreeBSD.org>

capsicum: use a new capsicum helpers in tools

Use caph_{rights,ioctls,fcntls}_limit to simplify the code.


# 71c6c44d 24-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

dhclient: build with WARNS=6

- add static in a number of places
- initialize __progname rather than rely on magical extern values
- use nitems() instead of manually spelling it out
- unshadow 'idi'
- teach 'error' that it is '__dead2'
- add missing 'break'


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# e16406c7 26-Jun-2014 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Remove duplicated includes.

Submitted by: Mariusz Zaborski <oshogbo@FreeBSD.org>


# b881b8be 16-Mar-2014 Robert Watson <rwatson@FreeBSD.org>

Update most userspace consumers of capability.h to use capsicum.h instead.

auditdistd is not updated as I will make the change upstream and then do a
vendor import sometime in the next week or two.

MFC after: 3 weeks


# bb7a82ac 06-Feb-2014 Christian Brueffer <brueffer@FreeBSD.org>

Use CAP_EVENT instead of the deprecated CAP_POLL_EVENT.

PR: 185382 (based on)
Submitted by: Loganaden Velvindron
Reviewed by: pjd
MFC after: 1 week


# 7008be5b 04-Sep-2013 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Change the cap_rights_t type from uint64_t to a structure that we can extend
in the future in a backward compatible (API and ABI) way.

The cap_rights_t represents capability rights. We used to use one bit to
represent one right, but we are running out of spare bits. Currently the new
structure provides place for 114 rights (so 50 more than the previous
cap_rights_t), but it is possible to grow the structure to hold at least 285
rights, although we can make it even larger if 285 rights won't be enough.

The structure definition looks like this:

struct cap_rights {
uint64_t cr_rights[CAP_RIGHTS_VERSION + 2];
};

The initial CAP_RIGHTS_VERSION is 0.

The top two bits in the first element of the cr_rights[] array contain total
number of elements in the array - 2. This means if those two bits are equal to
0, we have 2 array elements.

The top two bits in all remaining array elements should be 0.
The next five bits in all array elements contain array index. Only one bit is
used and bit position in this five-bits range defines array index. This means
there can be at most five array elements in the future.

To define new right the CAPRIGHT() macro must be used. The macro takes two
arguments - an array index and a bit to set, eg.

#define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL)

We still support aliases that combine few rights, but the rights have to belong
to the same array element, eg:

#define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL)
#define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL)

#define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP)

There is new API to manage the new cap_rights_t structure:

cap_rights_t *cap_rights_init(cap_rights_t *rights, ...);
void cap_rights_set(cap_rights_t *rights, ...);
void cap_rights_clear(cap_rights_t *rights, ...);
bool cap_rights_is_set(const cap_rights_t *rights, ...);

bool cap_rights_is_valid(const cap_rights_t *rights);
void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);

Capability rights to the cap_rights_init(), cap_rights_set(),
cap_rights_clear() and cap_rights_is_set() functions are provided by
separating them with commas, eg:

cap_rights_t rights;

cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT);

There is no need to terminate the list of rights, as those functions are
actually macros that take care of the termination, eg:

#define cap_rights_set(rights, ...) \
__cap_rights_set((rights), __VA_ARGS__, 0ULL)
void __cap_rights_set(cap_rights_t *rights, ...);

Thanks to using one bit as an array index we can assert in those functions that
there are no two rights belonging to different array elements provided
together. For example this is illegal and will be detected, because CAP_LOOKUP
belongs to element 0 and CAP_PDKILL to element 1:

cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL);

Providing several rights that belongs to the same array's element this way is
correct, but is not advised. It should only be used for aliases definition.

This commit also breaks compatibility with some existing Capsicum system calls,
but I see no other way to do that. This should be fine as Capsicum is still
experimental and this change is not going to 9.x.

Sponsored by: The FreeBSD Foundation


# 3b2ed065 03-Jul-2013 Pawel Jakub Dawidek <pjd@FreeBSD.org>

MFp4 @229482:

- Limit bpf descriptor in unprivileged process to CAP_POLL_EVENT, CAP_READ and
allow for SIOCGIFFLAGS, SIOCGIFMEDIA ioctls.
- While here limit bpf descriptor in privileged process to only CAP_WRITE.

Reviewed by: brooks
Sponsored by: The FreeBSD Foundation


# 235eb530 03-Jul-2013 Pawel Jakub Dawidek <pjd@FreeBSD.org>

MFp4 @229481:

Currently it was allowed to send any UDP packets from unprivileged process and
possibly any packets because /dev/bpf was open for writing.

Move sending packets to privileged process. Unprivileged process has no longer
access to not connected UDP socket and has only access to /dev/bpf in read-only
mode.

Reviewed by: brooks
Sponsored by: The FreeBSD Foundation


# b0f1b32a 03-Jul-2013 Pawel Jakub Dawidek <pjd@FreeBSD.org>

MFp4 @229476,229478:

Make use of two fields: rfdesc and wfdesc to keep bpf descriptor open for
reading only in rfdesc and bpf descriptor open for writing only in wfdesc.
In the end they will be used by two different processes.

Reviewed by: brooks
Sponsored by: The FreeBSD Foundation


# 3a0fc7d8 03-Jul-2013 Pawel Jakub Dawidek <pjd@FreeBSD.org>

MFp4 @229474:

iov_base field is 'void *' in FreeBSD, no need to cast.

Reviewed by: brooks
Sponsored by: The FreeBSD Foundation


# e8da5003 03-Jul-2013 Pawel Jakub Dawidek <pjd@FreeBSD.org>

MFp4 @229473:

No caller checks send_packet() return value, so make it void.

Reviewed by: brooks
Sponsored by: The FreeBSD Foundation


# ba019ae5 03-Jul-2013 Pawel Jakub Dawidek <pjd@FreeBSD.org>

MFp4 @229472:

Use the same type for 'from' and 'to' argument in send_packet().

Reviewed by: brooks
Sponsored by: The FreeBSD Foundation


# d1f4d854 03-Jul-2013 Pawel Jakub Dawidek <pjd@FreeBSD.org>

MFp4 @229471:

Remove unused argument from assemble_hw_header().

Reviewed by: brooks
Sponsored by: The FreeBSD Foundation


# 592291c1 03-Jul-2013 Pawel Jakub Dawidek <pjd@FreeBSD.org>

MFp4 @229470:

Remove unused argument from send_packet().

Reviewed by: brooks
Sponsored by: The FreeBSD Foundation


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 1ca0e46f 23-Oct-2009 Philip Paeps <philip@FreeBSD.org>

MFC r198352

Make dhclient use bootpc (68) as the source port for unicast
DHCPREQUEST packets instead of allowing the protocol stack to pick
a random source port.

This fixes the behaviour where dhclient would never transition
from RENEWING to BOUND without going through REBINDING in networks
which are paranoid about DHCP spoofing, such as most mainstream
cable-broadband ISP networks.

Obtained from: OpenBSD
Reviewed by: brooks
Approved by: re (kib)


# 9b683f8d 21-Oct-2009 Philip Paeps <philip@FreeBSD.org>

Make dhclient use bootpc (68) as the source port for unicast DHCPREQUEST
packets instead of allowing the protocol stack to pick a random source port.

This fixes the behaviour where dhclient would never transition from RENEWING
to BOUND without going through REBINDING in networks which are paranoid about
DHCP spoofing, such as most mainstream cable-broadband ISP networks.

Reviewed by: brooks
Obtained from: OpenBSD (partly - I'm not convinced their solution can work)
MFC after: 1 week (pending re approval)


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 8ca3089a 15-Apr-2008 Brooks Davis <brooks@FreeBSD.org>

When sending packets directly to the DHCP server, use a socket and send
directly rather than bogusly sending it out as a link layer broadcast
(which fails to be received on some networks).

PR: bin/96018
MFC after: 2 weeks


# ebe609b4 25-Sep-2006 Brooks Davis <brooks@FreeBSD.org>

It is possible for bpf to return a length such that:

length != BPF_WORDALIGN(length)

This meeans that it is possible for this to be true:

interface->rbuf_offset > interface->rbuf_len

Handle this case in the test for running out of packets. While
OpenBSD's solution of setting interface->rbuf_len to
BPF_WORDALIGN(length) is safe due to the size of the buffer, I think
this solution results in less hidden assumptions.

This should fix the problem of dhclient running away and consuming 100%
CPU.

PR: bin/102226
Submitted by: Joost Bekkers <joost at jodocus.org>
MFC after: 3 days


# 8794fdbb 23-Aug-2005 Brooks Davis <brooks@FreeBSD.org>

Add __FBSDID to all .c files in dhclient to aid in determining file
versions when dealing with user problems.


# 4d3d0830 22-Aug-2005 Christian S.J. Peron <csjp@FreeBSD.org>

FreeBSD unconditionally supports write filters now.


# 289d89d8 28-Jul-2005 Brooks Davis <brooks@FreeBSD.org>

Further fix receive_packet() by using BPF_WORDALIGN to insure the offset
is properly aligned when we move to the next packet.

Obtained from: ISC dhclient via krw at OpenBSD


# 4eae015d 27-Jul-2005 Brooks Davis <brooks@FreeBSD.org>

Fix a bug in the handling of cases where we got a short (or zero)
capture. Zero length captures caused an infinte loop and short captures
probably caused memory corruption and a crash.

Reported by: many
MFC After: 3 days


# 1b3bb962 06-Jun-2005 Brooks Davis <brooks@FreeBSD.org>

We don't support BPF write filters at this time.

Submitted by: sam


# 47c08596 06-Jun-2005 Brooks Davis <brooks@FreeBSD.org>

Import the OpenBSD dhclient as shipped with OpenBSD-3.7 (the tag
OPENBSD_3_7).