Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Nov 2002 01:05:32 +0000
From:      Ian Dowse <iedowse@maths.tcd.ie>
To:        Julian Elischer <julian@elischer.org>
Cc:        Scot Loach <sloach@SANDVINE.com>, "'freebsd-net@freebsd.org'" <freebsd-net@freebsd.org>
Subject:   Re: Using ipfw to forward udp 
Message-ID:   <200211220105.aa75973@salmon.maths.tcd.ie>
In-Reply-To: Your message of "Thu, 21 Nov 2002 11:10:00 PST." <Pine.BSF.4.21.0211211109300.4293-100000@InterJet.elischer.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <Pine.BSF.4.21.0211211109300.4293-100000@InterJet.elischer.org>, 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi? <200211220105.aa75973>