Home | History | Annotate | Download | only in net
History log of /src/sys/dist/pf/net/if_pflog.c
RevisionDateAuthorComments
 1.22  29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.21  26-Jun-2018  msaitoh branches: 1.21.2; 1.21.8;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.20  28-Apr-2016  ozaki-r branches: 1.20.16;
Constify rtentry of if_output

We no longer need to change rtentry below if_output.

The change makes it clear where rtentries are changed (or not)
and helps forthcoming locking (os psrefing) rtentries.
 1.19  20-Aug-2015  christos include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.18  12-Apr-2010  ahoka branches: 1.18.18; 1.18.36;
- Make the pf and pflog driver able to detach.
- Add code for module support.

Original patch from Jared McNeill
 1.17  05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.16  19-Jan-2010  pooka branches: 1.16.2; 1.16.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.15  28-Jul-2009  minskim Remove LKM code from pf.
 1.14  19-Dec-2008  cegger use M_ZERO on malloc() and remove subsequent bzero().
 1.13  07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.12  18-Jun-2008  yamt branches: 1.12.2; 1.12.4;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@
 1.11  11-Dec-2007  lukem branches: 1.11.8; 1.11.10; 1.11.12; 1.11.14; 1.11.16;
use __KERNEL_RCSID()
 1.10  04-Mar-2007  christos branches: 1.10.16; 1.10.24; 1.10.26; 1.10.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9  17-Feb-2007  dyoung KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.

Cosmetic: don't open-code TAILQ_FOREACH().

Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.

Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.

Constify:

1 Introduce const accessor for route->ro_dst, rtcache_getdst().

2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.

3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.

4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
 1.8  16-Nov-2006  christos branches: 1.8.4;
__unused removal on arguments; approved by core.
 1.7  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.6  11-Dec-2005  christos branches: 1.6.20; 1.6.22;
merge ktrace-lwp.
 1.5  14-Nov-2004  yamt branches: 1.5.12;
resolve conflicts. (pf from OpenBSD 3.6, kernel part)
 1.4  10-Sep-2004  yamt pflog_packet: use bpf_mtap2().
(our bpf_mtap() is more "strict" about mbufs
than openbsd's one is. eg. M_PKTHDR should be set properly.)
 1.3  29-Jun-2004  itojun branches: 1.3.2;
make PF lkm working. from Peter Postma and Joel Wilsson.

remove pf_ioctl_head/pf_newif_head, which was never used.
 1.2  22-Jun-2004  itojun PF from openbsd 3.5. missing features:
- pfsync (due to protocol # assignment issues)
- carp (not really a PF portion, but thought important to mention)
- PF and ALTQ are mutually-exclusive. this will be sorted out when
kjc@csl.sony.co.jp updates ALTQ and PF (and API inbetween)

reviewed by matt, christos, perry

torture-test is very welcomed.
 1.1  22-Jun-2004  itojun branches: 1.1.1;
Initial revision
 1.1.1.3  01-Dec-2009  martti Import PF from OpenBSD 4.2
 1.1.1.2  14-Nov-2004  yamt import pf from OpenBSD 3.6. (kernel part)
 1.1.1.1  22-Jun-2004  itojun PF from OpenBSD 3.5
 1.3.2.5  29-Nov-2004  skrll Sync with HEAD.
 1.3.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.3.2.2  03-Aug-2004  skrll Sync with HEAD
 1.3.2.1  29-Jun-2004  skrll file if_pflog.c was added on branch ktrace-lwp on 2004-08-03 10:52:23 +0000
 1.5.12.4  21-Jan-2008  yamt sync with head
 1.5.12.3  03-Sep-2007  yamt sync with head.
 1.5.12.2  26-Feb-2007  yamt sync with head.
 1.5.12.1  30-Dec-2006  yamt sync with head.
 1.6.22.2  10-Dec-2006  yamt sync with head.
 1.6.22.1  22-Oct-2006  yamt sync with head
 1.6.20.1  18-Nov-2006  ad Sync with head.
 1.8.4.2  12-Mar-2007  rmind Sync with HEAD.
 1.8.4.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.10.28.1  13-Dec-2007  bouyer Sync with HEAD
 1.10.26.1  11-Dec-2007  yamt sync with head.
 1.10.24.1  26-Dec-2007  ad Sync with head.
 1.10.16.1  09-Jan-2008  matt sync with HEAD
 1.11.16.1  18-Jun-2008  simonb Sync with head.
 1.11.14.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.11.12.4  11-Aug-2010  yamt sync with head.
 1.11.12.3  11-Mar-2010  yamt sync with head
 1.11.12.2  19-Aug-2009  yamt sync with head.
 1.11.12.1  04-May-2009  yamt sync with head.
 1.11.10.2  23-Apr-2008  peter Putting bpfilter.h/pf.h/pflog.h under _KERNEL_OPT was a mistake, revert this.
 1.11.10.1  19-Apr-2008  yamt Peter Postma's work-in-progress pf import from OpenBSD 4.2.
updated to -current by me.
 1.11.8.2  17-Jan-2009  mjf Sync with HEAD.
 1.11.8.1  29-Jun-2008  mjf Sync with HEAD.
 1.12.4.1  19-Jan-2009  skrll Sync with HEAD.
 1.12.2.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.16.4.1  30-May-2010  rmind sync with head
 1.16.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.18.36.2  29-May-2016  skrll Sync with HEAD
 1.18.36.1  22-Sep-2015  skrll Sync with HEAD
 1.18.18.1  03-Dec-2017  jdolecek update from HEAD
 1.20.16.1  28-Jul-2018  pgoyette Sync with HEAD
 1.21.8.1  29-Feb-2020  ad Sync with head.
 1.21.2.1  08-Apr-2020  martin Merge changes from current as of 20200406

RSS XML Feed