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:
parent
1aa4c324ee
commit
0b4ae859ac
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=154767
@ -30,6 +30,7 @@
|
|||||||
* $FreeBSD$
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "opt_ipfw.h"
|
||||||
#include "opt_ipsec.h"
|
#include "opt_ipsec.h"
|
||||||
#include "opt_inet6.h"
|
#include "opt_inet6.h"
|
||||||
#include "opt_mac.h"
|
#include "opt_mac.h"
|
||||||
@ -154,6 +155,9 @@ udp_input(m, off)
|
|||||||
int len;
|
int len;
|
||||||
struct ip save_ip;
|
struct ip save_ip;
|
||||||
struct sockaddr_in udp_in;
|
struct sockaddr_in udp_in;
|
||||||
|
#ifdef IPFIREWALL_FORWARD
|
||||||
|
struct m_tag *fwd_tag;
|
||||||
|
#endif
|
||||||
|
|
||||||
udpstat.udps_ipackets++;
|
udpstat.udps_ipackets++;
|
||||||
|
|
||||||
@ -243,6 +247,22 @@ udp_input(m, off)
|
|||||||
} else
|
} else
|
||||||
udpstat.udps_nosum++;
|
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);
|
INP_INFO_RLOCK(&udbinfo);
|
||||||
|
|
||||||
if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
|
if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user