svn commit: r272555 - head/sys/contrib/ipfilter/netinet

Cy Schubert cy at FreeBSD.org
Sun Oct 5 03:58:31 UTC 2014


Author: cy
Date: Sun Oct  5 03:58:30 2014
New Revision: 272555
URL: https://svnweb.freebsd.org/changeset/base/272555

Log:
  ipfilter bug #537 NAT rules with sticky have incorrect hostmap IP address.
  This fixes when an IP address mapping is put in the hostmap table for
  sticky NAT rules, it ends up having the wrong byte order.
  
  Obtained from:	ipfilter CVS repo (r1.102), NetBSD CVS repo (r1.12)

Modified:
  head/sys/contrib/ipfilter/netinet/ip_nat.c

Modified: head/sys/contrib/ipfilter/netinet/ip_nat.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_nat.c	Sun Oct  5 03:52:09 2014	(r272554)
+++ head/sys/contrib/ipfilter/netinet/ip_nat.c	Sun Oct  5 03:58:30 2014	(r272555)
@@ -2946,10 +2946,11 @@ ipf_nat_newrdr(fin, nat, ni)
 	 */
 	if (np->in_flags & IPN_SPLIT) {
 		in.s_addr = np->in_dnip;
+		inb.s_addr = htonl(in.s_addr);
 
 		if ((np->in_flags & (IPN_ROUNDR|IPN_STICKY)) == IPN_STICKY) {
 			hm = ipf_nat_hostmap(softn, NULL, fin->fin_src,
-					     fin->fin_dst, in, (u_32_t)dport);
+					     fin->fin_dst, inb, (u_32_t)dport);
 			if (hm != NULL) {
 				in.s_addr = hm->hm_ndstip.s_addr;
 				move = 0;
@@ -3050,13 +3051,14 @@ ipf_nat_newrdr(fin, nat, ni)
 		return -1;
 	}
 
+	inb.s_addr = htonl(in.s_addr);
 	nat->nat_ndstaddr = htonl(in.s_addr);
 	nat->nat_odstip = fin->fin_dst;
 	nat->nat_nsrcip = fin->fin_src;
 	nat->nat_osrcip = fin->fin_src;
 	if ((nat->nat_hm == NULL) && ((np->in_flags & IPN_STICKY) != 0))
 		nat->nat_hm = ipf_nat_hostmap(softn, np, fin->fin_src,
-					      fin->fin_dst, in, (u_32_t)dport);
+					      fin->fin_dst, inb, (u_32_t)dport);
 
 	if (flags & IPN_TCPUDP) {
 		nat->nat_odport = dport;


More information about the svn-src-head mailing list