]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
PFIL_MEMPTR for ipfw link level hook
authorGleb Smirnoff <glebius@FreeBSD.org>
Thu, 14 Mar 2019 22:52:16 +0000 (22:52 +0000)
committerGleb Smirnoff <glebius@FreeBSD.org>
Thu, 14 Mar 2019 22:52:16 +0000 (22:52 +0000)
commitf355cb3e6fa1dea72938b83d5b69a99bc4e1fe0c
treeed0b83b52e894cafd489ef0896d32c9e571ea1f0
parentdc0fa4f7122faf346f0a3ca884dabbdbb7467f2d
PFIL_MEMPTR for ipfw link level hook

With new pfil(9) KPI it is possible to pass a void pointer with length
instead of mbuf pointer to a packet filter. Until this commit no filters
supported that, so pfil run through a shim function pfil_fake_mbuf().

Now the ipfw(4) hook named "default-link", that is instantiated when
net.link.ether.ipfw sysctl is on, supports processing pointer/length
packets natively.

- ip_fw_args now has union for either mbuf or void *, and if flags have
  non-zero length, then we use the void *.
- through ipfw_chk() we handle mem/mbuf cases differently.
- ether_header goes away from args. It is ipfw_chk() responsibility
  to do parsing of Ethernet header.
- ipfw_log() now uses different bpf APIs to log packets.

Although ipfw_chk() is now capable to process pointer/length packets,
this commit adds support for the link level hook only, see
ipfw_check_frame(). Potentially the IP processing hook ipfw_check_packet()
can be improved too, but that requires more changes since the hook
supports more complex actions: NAT, divert, etc.

Reviewed by: ae
Differential Revision: https://reviews.freebsd.org/D19357
sys/netpfil/ipfw/ip_fw2.c
sys/netpfil/ipfw/ip_fw_bpf.c
sys/netpfil/ipfw/ip_fw_log.c
sys/netpfil/ipfw/ip_fw_pfil.c
sys/netpfil/ipfw/ip_fw_private.h