diff options
author | bz <bz@FreeBSD.org> | 2007-11-28 22:33:53 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2007-11-28 22:33:53 +0000 |
commit | 05fda2a0bf2b957c1175b607bf125c590f44a416 (patch) | |
tree | f1d778f747c5bf1497e0442e09b46a480cdc112d /sys/netipsec/ipsec_output.c | |
parent | 4a39f29f1b08c6b6d6b082dee8129524b1fda5e5 (diff) | |
download | FreeBSD-src-05fda2a0bf2b957c1175b607bf125c590f44a416.zip FreeBSD-src-05fda2a0bf2b957c1175b607bf125c590f44a416.tar.gz |
Add sysctls to if_enc(4) to control whether the firewalls or
bpf will see inner and outer headers or just inner or outer
headers for incoming and outgoing IPsec packets.
This is useful in bpf to not have over long lines for debugging
or selcting packets based on the inner headers.
It also properly defines the behavior of what the firewalls see.
Last but not least it gives you if_enc(4) for IPv6 as well.
[ As some auxiliary state was not available in the later
input path we save it in the tdbi. That way tcpdump can give a
consistent view of either of (authentic,confidential) for both
before and after states. ]
Discussed with: thompsa (2007-04-25, basic idea of unifying paths)
Reviewed by: thompsa, gnn
Diffstat (limited to 'sys/netipsec/ipsec_output.c')
-rw-r--r-- | sys/netipsec/ipsec_output.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c index 27ad224..ae7c08b 100644 --- a/sys/netipsec/ipsec_output.c +++ b/sys/netipsec/ipsec_output.c @@ -362,8 +362,10 @@ ipsec4_process_packet( sav = isr->sav; #ifdef DEV_ENC + /* pass the mbuf to enc0 for bpf processing */ + ipsec_bpf(m, sav, AF_INET, ENC_OUT|ENC_BEFORE); /* pass the mbuf to enc0 for packet filtering */ - if ((error = ipsec_filter(&m, PFIL_OUT)) != 0) + if ((error = ipsec_filter(&m, PFIL_OUT, ENC_OUT|ENC_BEFORE)) != 0) goto bad; #endif @@ -466,7 +468,10 @@ ipsec4_process_packet( #ifdef DEV_ENC /* pass the mbuf to enc0 for bpf processing */ - ipsec_bpf(m, sav, AF_INET); + ipsec_bpf(m, sav, AF_INET, ENC_OUT|ENC_AFTER); + /* pass the mbuf to enc0 for packet filtering */ + if ((error = ipsec_filter(&m, PFIL_OUT, ENC_OUT|ENC_AFTER)) != 0) + goto bad; #endif /* @@ -710,6 +715,14 @@ ipsec6_output_tunnel(struct ipsec_output_state *state, struct secpolicy *sp, int if (isr == NULL) goto bad; +#ifdef DEV_ENC + /* pass the mbuf to enc0 for bpf processing */ + ipsec_bpf(m, isr->sav, AF_INET6, ENC_OUT|ENC_BEFORE); + /* pass the mbuf to enc0 for packet filtering */ + if ((error = ipsec_filter(&m, PFIL_OUT, ENC_OUT|ENC_BEFORE)) != 0) + goto bad; +#endif + /* * There may be the case that SA status will be changed when * we are refering to one. So calling splsoftnet(). @@ -778,6 +791,15 @@ ipsec6_output_tunnel(struct ipsec_output_state *state, struct secpolicy *sp, int goto bad; } ip6 = mtod(m, struct ip6_hdr *); + +#ifdef DEV_ENC + /* pass the mbuf to enc0 for bpf processing */ + ipsec_bpf(m, isr->sav, AF_INET6, ENC_OUT|ENC_AFTER); + /* pass the mbuf to enc0 for packet filtering */ + if ((error = ipsec_filter(&m, PFIL_OUT, ENC_OUT|ENC_AFTER)) != 0) + goto bad; +#endif + error = (*isr->sav->tdb_xform->xf_output)(m, isr, NULL, sizeof (struct ip6_hdr), offsetof(struct ip6_hdr, ip6_nxt)); |