From 0b4ae859ac4f6a9e9e90bf70607cf29c5bdacae5 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Tue, 24 Jan 2006 09:08:54 +0000 Subject: Implement 'ipfw fwd laddr,port' feature for UDP. According to ipfw(8) it should work, however it never did. People expect it to work. PR: kern/90834 --- sys/netinet/udp_usrreq.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sys/netinet/udp_usrreq.c') diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 0693a7eabe98..993450bbb69d 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -30,6 +30,7 @@ * $FreeBSD$ */ +#include "opt_ipfw.h" #include "opt_ipsec.h" #include "opt_inet6.h" #include "opt_mac.h" @@ -154,6 +155,9 @@ udp_input(m, off) int len; struct ip save_ip; struct sockaddr_in udp_in; +#ifdef IPFIREWALL_FORWARD + struct m_tag *fwd_tag; +#endif udpstat.udps_ipackets++; @@ -243,6 +247,22 @@ udp_input(m, off) } else udpstat.udps_nosum++; +#ifdef IPFIREWALL_FORWARD + /* Grab info from PACKET_TAG_IPFORWARD tag prepended to the chain. */ + fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL); + + if (fwd_tag != NULL) { + struct sockaddr_in *next_hop; + + /* Do the hack. */ + next_hop = (struct sockaddr_in *)(fwd_tag + 1); + ip->ip_dst = next_hop->sin_addr; + uh->uh_dport = ntohs(next_hop->sin_port); + /* Remove the tag from the packet. We don't need it anymore. */ + m_tag_delete(m, fwd_tag); + } +#endif + INP_INFO_RLOCK(&udbinfo); if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) || -- cgit v1.3