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
This commit is contained in:
Gleb Smirnoff 2006-01-24 09:08:54 +00:00
parent 1aa4c324ee
commit 0b4ae859ac
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=154767

View File

@ -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)) ||