Date: Wed, 26 Dec 2018 12:54:27 +0000 (UTC) From: Kristof Provost <kp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r342543 - stable/11/sys/netpfil/pf Message-ID: <201812261254.wBQCsRPi010899@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kp Date: Wed Dec 26 12:54:27 2018 New Revision: 342543 URL: https://svnweb.freebsd.org/changeset/base/342543 Log: MFC r341998: pf: Fix endless loop on NAT exhaustion with sticky-address When we try to find a source port in pf_get_sport() it's possible that all available source ports will be in use. In that case we call pf_map_addr() to try to find a new source IP to try from. If there are no more available source IPs pf_map_addr() will return 1 and we stop trying. However, if sticky-address is set we'll always return the same IP address, even if we've already tried that one. We need to check the supplied address, because if that's the one we'd set it means pf_get_sport() has already tried it, and we should error out rather than keep trying. PR: 233867 Modified: stable/11/sys/netpfil/pf/pf.c stable/11/sys/netpfil/pf/pf_lb.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/pf/pf.c ============================================================================== --- stable/11/sys/netpfil/pf/pf.c Wed Dec 26 12:54:24 2018 (r342542) +++ stable/11/sys/netpfil/pf/pf.c Wed Dec 26 12:54:27 2018 (r342543) @@ -5517,6 +5517,8 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, ifp = nh4.nh_ifp; dst.sin_addr = nh4.nh_addr; } else { + bzero(&naddr, sizeof(naddr)); + if (TAILQ_EMPTY(&r->rpool.list)) { DPFPRINTF(PF_DEBUG_URGENT, ("%s: TAILQ_EMPTY(&r->rpool.list)\n", __func__)); @@ -5686,6 +5688,8 @@ pf_route6(struct mbuf **m, struct pf_rule *r, int dir, *m = NULL; return; } + + bzero(&naddr, sizeof(naddr)); if (TAILQ_EMPTY(&r->rpool.list)) { DPFPRINTF(PF_DEBUG_URGENT, Modified: stable/11/sys/netpfil/pf/pf_lb.c ============================================================================== --- stable/11/sys/netpfil/pf/pf_lb.c Wed Dec 26 12:54:24 2018 (r342542) +++ stable/11/sys/netpfil/pf/pf_lb.c Wed Dec 26 12:54:27 2018 (r342543) @@ -322,6 +322,12 @@ pf_map_addr(sa_family_t af, struct pf_rule *r, struct src node was created just a moment ago in pf_create_state and it needs to be filled in with routing decision calculated here. */ if (*sn != NULL && !PF_AZERO(&(*sn)->raddr, af)) { + /* If the supplied address is the same as the current one we've + * been asked before, so tell the caller that there's no other + * address to be had. */ + if (PF_AEQ(naddr, &(*sn)->raddr, af)) + return (1); + PF_ACPY(naddr, &(*sn)->raddr, af); if (V_pf_status.debug >= PF_DEBUG_MISC) { printf("pf_map_addr: src tracking maps ");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812261254.wBQCsRPi010899>