diff options
author | 2013-06-05 15:22:32 +0000 | |
---|---|---|
committer | 2013-06-05 15:22:32 +0000 | |
commit | d2d95ac127156f8813e554019a54a890dc86c19d (patch) | |
tree | ffaf6aa0b6dc05aae250d85532339f80a705e339 /sys/netinet/ip_icmp.c | |
parent | Include sys/timeout.h to make if_gre.c compile without pf. (diff) | |
download | wireguard-openbsd-d2d95ac127156f8813e554019a54a890dc86c19d.tar.xz wireguard-openbsd-d2d95ac127156f8813e554019a54a890dc86c19d.zip |
If an ICMP packet gets diverted to a raw IP socket, if must not be
consumed by icmp_input(). As an exception, control packets that
belong to a connection to a local socket must go to pr_ctlinput().
Add a switch over the ICMP type to handle that.
OK markus@ henning@
Diffstat (limited to 'sys/netinet/ip_icmp.c')
-rw-r--r-- | sys/netinet/ip_icmp.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index baef294334c..4e62bb9d028 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.100 2013/06/05 02:25:05 lteo Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.101 2013/06/05 15:22:32 bluhm Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -363,6 +363,29 @@ icmp_input(struct mbuf *m, ...) #endif if (icp->icmp_type > ICMP_MAXTYPE) goto raw; +#if NPF > 0 + if (m->m_pkthdr.pf.flags & PF_TAG_DIVERTED) { + switch (icp->icmp_type) { + /* + * These ICMP types map to other connections. They must be + * delivered to pr_ctlinput() also for diverted connections. + */ + case ICMP_UNREACH: + case ICMP_TIMXCEED: + case ICMP_PARAMPROB: + case ICMP_SOURCEQUENCH: + break; + /* + * Although pf_icmp_mapping() considers redirects belonging + * to a diverted connection, we must process it here anyway. + */ + case ICMP_REDIRECT: + break; + default: + goto raw; + } + } +#endif /* NPF */ icmpstat.icps_inhist[icp->icmp_type]++; code = icp->icmp_code; switch (icp->icmp_type) { |