The branch main has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b34f497b3e6eff1c7b12f5700d897743073dfcff

commit b34f497b3e6eff1c7b12f5700d897743073dfcff
Author:     Kristof Provost <k...@freebsd.org>
AuthorDate: 2025-02-11 13:24:56 +0000
Commit:     Kristof Provost <k...@freebsd.org>
CommitDate: 2025-02-19 10:41:09 +0000

    pf: simplify pf_check_proto_cksum()
    
    Simplify and shorten the way ICMP checksums are verified in
    pf_check_proto_cksum() by letting it use the same in4_cksum() call that
    is used for TCP and UDP checksums.
    
    ok henning@ naddy@
    
    Obtained from:  OpenBSD, lteo <l...@openbsd.org>, 3c23016fb7
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/netpfil/pf/pf.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index ea5687407881..da741364d372 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -9276,19 +9276,9 @@ pf_check_proto_cksum(struct mbuf *m, int off, int len, 
u_int8_t p, sa_family_t a
        if (!hw_assist) {
                switch (af) {
                case AF_INET:
-                       if (p == IPPROTO_ICMP) {
-                               if (m->m_len < off)
-                                       return (1);
-                               m->m_data += off;
-                               m->m_len -= off;
-                               sum = in_cksum(m, len);
-                               m->m_data -= off;
-                               m->m_len += off;
-                       } else {
-                               if (m->m_len < sizeof(struct ip))
-                                       return (1);
-                               sum = in4_cksum(m, p, off, len);
-                       }
+                       if (m->m_len < sizeof(struct ip))
+                               return (1);
+                       sum = in4_cksum(m, (p == IPPROTO_ICMP ? 0 : p), off, 
len);
                        break;
 #ifdef INET6
                case AF_INET6:

Reply via email to