Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/external/bsd/ipf/netinet/ip_nat.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/external/bsd/ipf/netinet/ip_nat.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.13.4.5 retrieving revision 1.14 diff -u -p -r1.13.4.5 -r1.14 --- src/sys/external/bsd/ipf/netinet/ip_nat.c 2017/08/28 17:52:34 1.13.4.5 +++ src/sys/external/bsd/ipf/netinet/ip_nat.c 2015/08/07 17:31:12 1.14 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_nat.c,v 1.13.4.5 2017/08/28 17:52:34 skrll Exp $ */ +/* $NetBSD: ip_nat.c,v 1.14 2015/08/07 17:31:12 prlw1 Exp $ */ /* * Copyright (C) 2012 by Darren Reed. @@ -113,7 +113,7 @@ extern struct ifnet vpnif; #if !defined(lint) #if defined(__NetBSD__) #include -__KERNEL_RCSID(0, "$NetBSD: ip_nat.c,v 1.13.4.5 2017/08/28 17:52:34 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_nat.c,v 1.14 2015/08/07 17:31:12 prlw1 Exp $"); #else static const char sccsid[] = "@(#)ip_nat.c 1.11 6/5/96 (C) 1995 Darren Reed"; static const char rcsid[] = "@(#)Id: ip_nat.c,v 1.1.1.2 2012/07/22 13:45:27 darrenr Exp"; @@ -4032,8 +4032,13 @@ ipf_nat_inlookup(fr_info_t *fin, u_int f dport = htons(fin->fin_data[1]); break; case IPPROTO_ICMP : - sport = 0; - dport = fin->fin_data[1]; + if (flags & IPN_ICMPERR) { + sport = fin->fin_data[1]; + dport = 0; + } else { + dport = fin->fin_data[1]; + sport = 0; + } break; default : sport = 0; @@ -4348,6 +4353,8 @@ ipf_nat_outlookup(fr_info_t *fin, u_int u_int hv; ifp = fin->fin_ifp; + sport = 0; + dport = 0; switch (p) { @@ -4357,12 +4364,12 @@ ipf_nat_outlookup(fr_info_t *fin, u_int dport = htons(fin->fin_data[1]); break; case IPPROTO_ICMP : - sport = 0; - dport = fin->fin_data[1]; + if (flags & IPN_ICMPERR) + sport = fin->fin_data[1]; + else + dport = fin->fin_data[1]; break; default : - sport = 0; - dport = 0; break; } @@ -4551,9 +4558,8 @@ find_out_wild_ports: /* Function: ipf_nat_lookupredir */ /* Returns: nat_t* - NULL == no match, */ /* else pointer to matching NAT entry */ -/* Parameters: softc(I) - pointer to soft context main structure */ -/* np(I) - pointer to description of packet to find NAT */ -/* table entry for. */ +/* Parameters: np(I) - pointer to description of packet to find NAT table */ +/* entry for. */ /* */ /* Lookup the NAT tables to search for a matching redirect */ /* The contents of natlookup_t should imitate those found in a packet that */ @@ -4621,8 +4627,8 @@ ipf_nat_lookupredir(ipf_main_softc_t *so } } - np->nl_realip = nat->nat_odstip; - np->nl_realport = nat->nat_odport; + np->nl_realip = nat->nat_ndstip; + np->nl_realport = nat->nat_ndport; } } @@ -6012,7 +6018,7 @@ ipf_nat_icmpquerytype(int icmptype) { case ICMP_ECHOREPLY: case ICMP_ECHO: - /* route advertisement/sollicitation is currently unsupported: */ + /* route aedvertisement/solliciation is currently unsupported: */ /* it would require rewriting the ICMP data section */ case ICMP_TSTAMP: case ICMP_TSTAMPREPLY: