The branch main has been updated by bdrewery:

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

commit 7cbf1de38e06663c76f4f075db31ea25f429f1b3
Author:     Bryan Drewery <bdrew...@freebsd.org>
AuthorDate: 2021-07-27 20:12:37 +0000
Commit:     Bryan Drewery <bdrew...@freebsd.org>
CommitDate: 2021-07-28 23:34:14 +0000

    debugnet: Fix false-positive assertions for dp_state
    
    debugnet_handle_arp:
      An assertion is present to ensure the pcb is only modified when the state 
is
      DN_STATE_INIT. Because debugnet_arp_gw() is asynchronous it is possible 
for
      ARP replies to come in after the gateway address is known and the state
      already changed.
    
    debugnet_handle_ip:
      Similarly it is possible for packets to come in, from the expected
      server, during the gateway mac discovery phase.  This can happen from
      testing disconnects / reconnects in quick succession.  This later
      causes some acks to be sent back but hit an assertion because the
      state is wrong.
    
    Reviewed by:    cem, debugnet_handle_arp: markj, vangyzen
    Sponsored by:   Dell EMC
    Differential Revision:  https://reviews.freebsd.org/D31327
---
 sys/net/debugnet_inet.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/sys/net/debugnet_inet.c b/sys/net/debugnet_inet.c
index 837f838fa6d9..e7449113ba10 100644
--- a/sys/net/debugnet_inet.c
+++ b/sys/net/debugnet_inet.c
@@ -86,6 +86,9 @@ debugnet_handle_ip(struct debugnet_pcb *pcb, struct mbuf **mb)
        struct mbuf *m;
        unsigned short hlen;
 
+       if (pcb->dp_state < DN_STATE_HAVE_GW_MAC)
+               return;
+
        /* IP processing. */
        m = *mb;
        if (m->m_pkthdr.len < sizeof(struct ip)) {
@@ -347,13 +350,19 @@ debugnet_handle_arp(struct debugnet_pcb *pcb, struct mbuf 
**mb)
                            " server or gateway)\n", buf);
                        return;
                }
+               if (pcb->dp_state >= DN_STATE_HAVE_GW_MAC) {
+                       inet_ntoa_r(isaddr, buf);
+                       DNETDEBUG("ignoring server ARP reply from %s (already"
+                           " have gateway address)\n", buf);
+                       return;
+               }
+               MPASS(pcb->dp_state == DN_STATE_INIT);
                memcpy(pcb->dp_gw_mac.octet, ar_sha(ah),
                    min(ah->ar_hln, ETHER_ADDR_LEN));
                
                DNETDEBUG("got server MAC address %6D\n",
                    pcb->dp_gw_mac.octet, ":");
 
-               MPASS(pcb->dp_state == DN_STATE_INIT);
                pcb->dp_state = DN_STATE_HAVE_GW_MAC;
                return;
        }
_______________________________________________
dev-commits-src-main@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"

Reply via email to