From 46dfa5555565fdb77e9f5ff59c114436d47f1c7a Mon Sep 17 00:00:00 2001 From: itojun Date: Fri, 11 Feb 2000 05:57:58 +0000 Subject: [PATCH] fix in-kernel packet forwarding loop (till TTL becomes 0) when: - a packet is delivered to an address X, - and the address X is configured on my !IFF_UP interface - and ipforwarding=1 NetBSD PR: 9387 From: nrt@iij.ad.jp --- sys/netinet/ip_input.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 366fd162d8e8..e61876df3364 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.96 2000/02/01 00:07:09 thorpej Exp $ */ +/* $NetBSD: ip_input.c,v 1.97 2000/02/11 05:57:58 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -488,7 +488,19 @@ ip_input(struct mbuf *m) /* * Check our list of addresses, to see if the packet is for us. */ - INADDR_TO_IA(ip->ip_dst, ia); + for (ia = IN_IFADDR_HASH(ip->ip_dst.s_addr).lh_first; + ia != NULL; + ia = ia->ia_hash.le_next) { + if (in_hosteq(ia->ia_addr.sin_addr, ip->ip_dst)) { + if ((ia->ia_ifp->if_flags & IFF_UP) != 0) + break; + else { + icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, + 0, m->m_pkthdr.rcvif); + return; + } + } + } if (ia != NULL) goto ours; if (m->m_pkthdr.rcvif->if_flags & IFF_BROADCAST) {