From owner-freebsd-net Thu Nov 21 17: 5:40 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A2C2C37B408 for ; Thu, 21 Nov 2002 17:05:38 -0800 (PST) Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by mx1.FreeBSD.org (Postfix) with SMTP id 1CE1943EA9 for ; Thu, 21 Nov 2002 17:05:37 -0800 (PST) (envelope-from iedowse@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 22 Nov 2002 01:05:36 +0000 (GMT) To: Julian Elischer Cc: Scot Loach , "'freebsd-net@freebsd.org'" Subject: Re: Using ipfw to forward udp In-Reply-To: Your message of "Thu, 21 Nov 2002 11:10:00 PST." Date: Fri, 22 Nov 2002 01:05:32 +0000 From: Ian Dowse Message-ID: <200211220105.aa75973@salmon.maths.tcd.ie> Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org In message , Jul ian Elischer writes: >the local fwd command is only implemented for TCP Here is a patch against -stable that I did a while ago, but I never got around to doing a -current version - the code there is quite different. Ian Index: udp_usrreq.c =================================================================== RCS file: /home/iedowse/CVS/src/sys/netinet/udp_usrreq.c,v retrieving revision 1.64.2.16 diff -u -r1.64.2.16 udp_usrreq.c --- udp_usrreq.c 7 Aug 2002 16:14:47 -0000 1.64.2.16 +++ udp_usrreq.c 22 Nov 2002 01:02:14 -0000 @@ -34,6 +34,7 @@ * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.64.2.16 2002/08/07 16:14:47 luigi Exp $ */ +#include "opt_ipfw.h" #include "opt_ipsec.h" #include "opt_inet6.h" @@ -339,6 +340,22 @@ /* * Locate pcb for datagram. */ +#ifdef IPFIREWALL_FORWARD + if (ip_fw_fwd_addr != NULL) { + /* Diverted. Use the divert addr/port in the lookup. */ + if (!ip_fw_fwd_addr->sin_port) { + inp = in_pcblookup_hash(&udbinfo, ip->ip_src, + uh->uh_sport, ip_fw_fwd_addr->sin_addr, + uh->uh_dport, 1, m->m_pkthdr.rcvif); + } else { + inp = in_pcblookup_hash(&udbinfo, ip->ip_src, + uh->uh_sport, ip_fw_fwd_addr->sin_addr, + ntohs(ip_fw_fwd_addr->sin_port), 1, + m->m_pkthdr.rcvif); + } + ip_fw_fwd_addr = NULL; + } else +#endif /* IPFIREWALL_FORWARD */ inp = in_pcblookup_hash(&udbinfo, ip->ip_src, uh->uh_sport, ip->ip_dst, uh->uh_dport, 1, m->m_pkthdr.rcvif); if (inp == NULL) { To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message