git: 2ef97d8b7564 - main - xen/netfront: use iflladdr_event to send ARPs

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Mon, 16 Dec 2024 14:50:06 UTC
The branch main has been updated by glebius:

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

commit 2ef97d8b7564c5d3e62248b49f9ebbbae5dc02f3
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2024-12-16 14:48:50 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2024-12-16 14:49:29 +0000

    xen/netfront: use iflladdr_event to send ARPs
    
    Avoids usage of arp_ifinit() and if_foreach_addr_type().  The former
    isn't encouraged to be used in drivers and the latter is about to
    change to not expose struct ifaddr.
    
    Reviewed by:            royger, ehem_freebsd_m5p.com
    Differential Revision:  https://reviews.freebsd.org/D48053
---
 sys/dev/xen/netfront/netfront.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c
index e13fb8765bae..3bc3679eb0db 100644
--- a/sys/dev/xen/netfront/netfront.c
+++ b/sys/dev/xen/netfront/netfront.c
@@ -1029,27 +1029,6 @@ out:
 	return (error);
 }
 
-#ifdef INET
-static u_int
-netfront_addr_cb(void *arg, struct ifaddr *a, u_int count)
-{
-	arp_ifinit((if_t)arg, a);
-	return (1);
-}
-/**
- * If this interface has an ipv4 address, send an arp for it. This
- * helps to get the network going again after migrating hosts.
- */
-static void
-netfront_send_fake_arp(device_t dev, struct netfront_info *info)
-{
-	if_t ifp;
-
-	ifp = info->xn_ifp;
-	if_foreach_addr_type(ifp, AF_INET, netfront_addr_cb, ifp);
-}
-#endif
-
 /**
  * Callback received when the backend's state changes.
  */
@@ -1090,7 +1069,12 @@ netfront_backend_changed(device_t dev, XenbusState newstate)
 		break;
 	case XenbusStateConnected:
 #ifdef INET
-		netfront_send_fake_arp(dev, sc);
+		/*
+		 * If this interface has an ipv4 address, send an arp for it.
+		 * This helps to get the network going again after migrating
+		 * hosts.
+		 */
+		EVENTHANDLER_INVOKE(iflladdr_event, sc->xn_ifp);
 #endif
 		break;
 	}