-/* $OpenBSD: ip_icmp.c,v 1.173 2017/10/18 17:01:14 bluhm Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.174 2017/12/14 14:26:50 bluhm Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
#if NPF > 0
if (m->m_pkthdr.pf.flags & PF_TAG_DIVERTED) {
switch (icp->icmp_type) {
+ /*
+ * As pf_icmp_mapping() considers redirects belonging to a
+ * diverted connection, we must include it here.
+ */
+ case ICMP_REDIRECT:
+ /* FALLTHROUGH */
/*
* These ICMP types map to other connections. They must be
* delivered to pr_ctlinput() also for diverted connections.
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:
+ /*
+ * Do not use the divert-to property of the TCP or UDP
+ * rule when doing the PCB lookup for the raw socket.
+ */
+ m->m_pkthdr.pf.flags &=~ PF_TAG_DIVERTED;
break;
default:
goto raw;
goto badcode;
code = PRC_QUENCH;
deliver:
- /* Free packet atttributes */
- if (m->m_flags & M_PKTHDR)
- m_tag_delete_chain(m);
-
/*
* Problem with datagram; advise higher level routines.
*/
&ip->ip_dst.s_addr, 1))
goto freeit;
#endif
- /* Free packet atttributes */
- if (m->m_flags & M_PKTHDR)
- m_tag_delete_chain(m);
-
icmpstat_inc(icps_reflect);
icmpstat_inc(icps_outhist + icp->icmp_type);
if (!icmp_reflect(m, &opts, NULL)) {
struct sockaddr_in ssrc;
struct rtentry *newrt = NULL;
- /* Free packet atttributes */
- if (m->m_flags & M_PKTHDR)
- m_tag_delete_chain(m);
if (icmp_rediraccept == 0 || ipforwarding == 1)
goto freeit;
if (code > 3)
-/* $OpenBSD: icmp6.c,v 1.220 2017/11/03 14:28:57 florian Exp $ */
+/* $OpenBSD: icmp6.c,v 1.221 2017/12/14 14:26:50 bluhm Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
case ICMP6_PACKET_TOO_BIG:
case ICMP6_TIME_EXCEEDED:
case ICMP6_PARAM_PROB:
+ /*
+ * Do not use the divert-to property of the TCP or UDP
+ * rule when doing the PCB lookup for the raw socket.
+ */
+ m->m_pkthdr.pf.flags &=~ PF_TAG_DIVERTED;
break;
default:
goto raw;