icmp_reflect: check if m_pkthdr.rcvif is non-NULL before touching it.

icmp_reflect could be called from the output path, so m_pkthdr.rcvif may not
be set.  (found by panic when PF is configured "block return all")
This commit is contained in:
itojun 2004-06-25 15:43:00 +00:00
parent 0fc8b3b26d
commit db45a6f189
1 changed files with 6 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_icmp.c,v 1.85 2004/06/25 15:24:41 itojun Exp $ */
/* $NetBSD: ip_icmp.c,v 1.86 2004/06/25 15:43:00 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -101,7 +101,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.85 2004/06/25 15:24:41 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.86 2004/06/25 15:43:00 itojun Exp $");
#include "opt_ipsec.h"
@ -688,7 +688,7 @@ icmp_reflect(m)
* use that, if it's an address on the interface which
* received the packet
*/
if (sin == (struct sockaddr_in *)0) {
if (sin == (struct sockaddr_in *)0 && m->m_pkthdr.rcvif) {
struct sockaddr_in sin_dst;
struct route icmproute;
int errornum;
@ -723,7 +723,7 @@ icmp_reflect(m)
* interface. This can happen when routing is asymmetric, or
* when the incoming packet was encapsulated
*/
if (sin == (struct sockaddr_in *)0) {
if (sin == (struct sockaddr_in *)0 && m->m_pkthdr.rcvif) {
TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
@ -836,7 +836,8 @@ icmp_reflect(m)
/*
* Clear any in-bound checksum flags for this packet.
*/
m->m_pkthdr.csum_flags = 0;
if (m->m_flags & M_PKTHDR)
m->m_pkthdr.csum_flags = 0;
icmp_send(m, opts);
done: