From nobody Fri Nov 22 23:33:47 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XwBHw1PgQz5dXhj; Fri, 22 Nov 2024 23:33:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XwBHw0sJTz4ppX; Fri, 22 Nov 2024 23:33:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732318428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=t+ZvKc6OB7/VcHB/zv7fbBgOTO7YIVWBQ60K4LmC9V8=; b=Cj1RAw6PmkN1OGAA3ZA5XlIqjDE8JLMD/QklJGTc0fhZmx6IYEn798Rkf1t+aUnMw5+aGv LuXDBEWElmzqG1tY1tqHW3Wu5jUS2n/pwVw2aKJSKwK6g8MmuFnCTwMFAPMuFctc2i/KlE YmXiucNpSvnR3oO59m5m4l75zBqlEMJNxb7MEFYlJh3lD7H7A05LalqX36UxN6vjnmHsGY B9XSClqkLUW61cokwRwO3VLV+TGruKCxK4uFbJZpkrclxKIZ3+NDrSrZaPfbbx4f8TJZsM IpPS2BV2PDsTTD0/j5Df+h6BHW78nbA0pSREY4E/rPNWiWT/9LTgnyt4P/sz2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732318428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=t+ZvKc6OB7/VcHB/zv7fbBgOTO7YIVWBQ60K4LmC9V8=; b=PQsvT6cbvbBqn/5o+bzc83lzb4DtptYFT+moTKUbIMpl4MsqmBiCovpW/ckYgvTbenR9Um NfKRAKjbzF1f7phhJQ6m3sHGNNpszhcufIplZ5XVo9xHqDVJ6HOgI9Pp6bTanU1ijWPKDO NOOm4KezWN9YkcfthGNbkfF7upvDAFI24R1lznujnXQ46rZHmpD3JIu77Z7zuiG3ZLuxiW sGZX8PTH8HbkOTXmMPF6pTWUeLxwosjUHNcSzpUsm5NYtegrgGqD0TjZGWPjS8msnMw0P2 C3/Y7qLA50FPcFQkz1LA15iad2KSlO3aRmRB0V3RZ3u/LUYalpch/V72OaxT7A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732318428; a=rsa-sha256; cv=none; b=MoWgUBjRLf0uC1jRbL7bo4nktz4a7zV37QcyMimn2H2ZUgejfs7nFZQpMUqA1j0BUmNkws DyLl36rPligI7mnN5ziP/Ev3eFuDNs/XxCUYFaReNvmgMdYCN4kyajRCp2UIc6HpLcSytS p80IEG5L1J/s6XK3QEL4m0B9iSyqupePsumIj0WiVSNBLgangwX/2orHVX2WiJWKLBBQ2L hozZgxZVzNWG97+K/Ymq8SzSz4+vUSP/T5iB22ZsuZOzw0ZRfWmeE+F0kcZoT9bck0szaE h8eSbn2qUnhxhwqhTsjucgAH9mP2Q6fZy7Qkhm72HA1RCspEyH/fbksAm+jvhQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XwBHv73kfzlYV; Fri, 22 Nov 2024 23:33:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AMNXlgb029478; Fri, 22 Nov 2024 23:33:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AMNXl5i029475; Fri, 22 Nov 2024 23:33:47 GMT (envelope-from git) Date: Fri, 22 Nov 2024 23:33:47 GMT Message-Id: <202411222333.4AMNXl5i029475@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: e0bf7bc3b2ba - main - pf: reduce indentation level in pf_dummynet_route() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e0bf7bc3b2ba1b2d8a746311471611210ba6fc89 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e0bf7bc3b2ba1b2d8a746311471611210ba6fc89 commit e0bf7bc3b2ba1b2d8a746311471611210ba6fc89 Author: Kristof Provost AuthorDate: 2024-11-22 12:35:02 +0000 Commit: Kristof Provost CommitDate: 2024-11-22 23:32:04 +0000 pf: reduce indentation level in pf_dummynet_route() Reverse the first if() in pf_dummynet_route() to avoid an unneeded level of indendation. No functional change. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf.c | 98 +++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 99d30c1acf72..5a0cad132340 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -8383,66 +8383,68 @@ pf_dummynet_route(struct pf_pdesc *pd, struct pf_kstate *s, struct pf_krule *r, struct ifnet *ifp, struct sockaddr *sa, struct mbuf **m0) { + struct ip_fw_args dnflow; + NET_EPOCH_ASSERT(); - if (pd->act.dnpipe || pd->act.dnrpipe) { - struct ip_fw_args dnflow; - if (ip_dn_io_ptr == NULL) { - m_freem(*m0); - *m0 = NULL; - return (ENOMEM); - } + if (pd->act.dnpipe == 0 && pd->act.dnrpipe == 0) + return (0); - if (pd->pf_mtag == NULL && - ((pd->pf_mtag = pf_get_mtag(*m0)) == NULL)) { - m_freem(*m0); - *m0 = NULL; - return (ENOMEM); - } + if (ip_dn_io_ptr == NULL) { + m_freem(*m0); + *m0 = NULL; + return (ENOMEM); + } - if (ifp != NULL) { - pd->pf_mtag->flags |= PF_MTAG_FLAG_ROUTE_TO; + if (pd->pf_mtag == NULL && + ((pd->pf_mtag = pf_get_mtag(*m0)) == NULL)) { + m_freem(*m0); + *m0 = NULL; + return (ENOMEM); + } - pd->pf_mtag->if_index = ifp->if_index; - pd->pf_mtag->if_idxgen = ifp->if_idxgen; + if (ifp != NULL) { + pd->pf_mtag->flags |= PF_MTAG_FLAG_ROUTE_TO; - MPASS(sa != NULL); + pd->pf_mtag->if_index = ifp->if_index; + pd->pf_mtag->if_idxgen = ifp->if_idxgen; - switch (pd->af) { - case AF_INET: - memcpy(&pd->pf_mtag->dst, sa, - sizeof(struct sockaddr_in)); - break; - case AF_INET6: - memcpy(&pd->pf_mtag->dst, sa, - sizeof(struct sockaddr_in6)); - break; - } + MPASS(sa != NULL); + + switch (pd->af) { + case AF_INET: + memcpy(&pd->pf_mtag->dst, sa, + sizeof(struct sockaddr_in)); + break; + case AF_INET6: + memcpy(&pd->pf_mtag->dst, sa, + sizeof(struct sockaddr_in6)); + break; } + } - if (s != NULL && s->nat_rule != NULL && - s->nat_rule->action == PF_RDR && - ( + if (s != NULL && s->nat_rule != NULL && + s->nat_rule->action == PF_RDR && + ( #ifdef INET - (pd->af == AF_INET && IN_LOOPBACK(ntohl(pd->dst->v4.s_addr))) || + (pd->af == AF_INET && IN_LOOPBACK(ntohl(pd->dst->v4.s_addr))) || #endif - (pd->af == AF_INET6 && IN6_IS_ADDR_LOOPBACK(&pd->dst->v6)))) { - /* - * If we're redirecting to loopback mark this packet - * as being local. Otherwise it might get dropped - * if dummynet re-injects. - */ - (*m0)->m_pkthdr.rcvif = V_loif; - } + (pd->af == AF_INET6 && IN6_IS_ADDR_LOOPBACK(&pd->dst->v6)))) { + /* + * If we're redirecting to loopback mark this packet + * as being local. Otherwise it might get dropped + * if dummynet re-injects. + */ + (*m0)->m_pkthdr.rcvif = V_loif; + } - if (pf_pdesc_to_dnflow(pd, r, s, &dnflow)) { - pd->pf_mtag->flags |= PF_MTAG_FLAG_DUMMYNET; - pd->pf_mtag->flags |= PF_MTAG_FLAG_DUMMYNETED; - ip_dn_io_ptr(m0, &dnflow); - if (*m0 != NULL) { - pd->pf_mtag->flags &= ~PF_MTAG_FLAG_ROUTE_TO; - pf_dummynet_flag_remove(*m0, pd->pf_mtag); - } + if (pf_pdesc_to_dnflow(pd, r, s, &dnflow)) { + pd->pf_mtag->flags |= PF_MTAG_FLAG_DUMMYNET; + pd->pf_mtag->flags |= PF_MTAG_FLAG_DUMMYNETED; + ip_dn_io_ptr(m0, &dnflow); + if (*m0 != NULL) { + pd->pf_mtag->flags &= ~PF_MTAG_FLAG_ROUTE_TO; + pf_dummynet_flag_remove(*m0, pd->pf_mtag); } }