diff options
author | glebius <glebius@FreeBSD.org> | 2006-01-24 09:08:54 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2006-01-24 09:08:54 +0000 |
commit | d9cbe01472a3c8e7b2e2261f8c9bfea443a3ef61 (patch) | |
tree | 2ff0a67ac1b049ad7113d8fba9060ce00b9d2527 /sys/netinet/udp_usrreq.c | |
parent | 1f5105d8a7b8d380fb0dc8ca4418eba706d5cb16 (diff) | |
download | FreeBSD-src-d9cbe01472a3c8e7b2e2261f8c9bfea443a3ef61.zip FreeBSD-src-d9cbe01472a3c8e7b2e2261f8c9bfea443a3ef61.tar.gz |
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
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r-- | sys/netinet/udp_usrreq.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 0693a7e..993450b 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)) || |