git: 332219c93baf - main - pf: deduplicate code
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 23 Apr 2025 11:56:52 UTC
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=332219c93baf85691af957f22bc66848f2636168 commit 332219c93baf85691af957f22bc66848f2636168 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2025-04-21 15:30:37 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2025-04-23 08:15:08 +0000 pf: deduplicate code In pf_translate() the TCP, UDP and SCTP cases were identical. Deduplicate them. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 95dc6a318dd4..a4a24148da72 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -6328,19 +6328,8 @@ pf_translate(struct pf_pdesc *pd, struct pf_addr *saddr, u_int16_t sport, switch (pd->proto) { case IPPROTO_TCP: - if (afto || *pd->sport != sport) { - pf_change_ap(pd, pd->src, pd->sport, - saddr, sport); - rewrite = 1; - } - if (afto || *pd->dport != dport) { - pf_change_ap(pd, pd->dst, pd->dport, - daddr, dport); - rewrite = 1; - } - break; - case IPPROTO_UDP: + case IPPROTO_SCTP: if (afto || *pd->sport != sport) { pf_change_ap(pd, pd->src, pd->sport, saddr, sport); @@ -6353,20 +6342,6 @@ pf_translate(struct pf_pdesc *pd, struct pf_addr *saddr, u_int16_t sport, } break; - case IPPROTO_SCTP: { - if (afto || *pd->sport != sport) { - pf_change_ap(pd, pd->src, pd->sport, - saddr, sport); - rewrite = 1; - } - if (afto || *pd->dport != dport) { - pf_change_ap(pd, pd->dst, pd->dport, - daddr, dport); - rewrite = 1; - } - break; - } - #ifdef INET case IPPROTO_ICMP: /* pf_translate() is also used when logging invalid packets */