git: f766d1d5a7c6 - main - IfAPI: Add if_maddr_empty() to check for any maddrs

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Tue, 02 May 2023 18:46:49 UTC
The branch main has been updated by jhibbits:

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

commit f766d1d5a7c65d001c443e3fd21694645d58b8b2
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2023-04-10 18:20:00 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2023-05-02 18:34:47 +0000

    IfAPI: Add if_maddr_empty() to check for any maddrs
    
    if_llmaddr_count() only counts link-level multicast addresses.
    hv_netvsc(4) needs to know if there are any multicast addresses.  Since
    hv_netvsc(4) is the only instance where this would be used, make it a
    simple boolean.  If others need a if_maddr_count(), that can be added in
    the future.
    
    Reviewed by:    melifaro
    Sponsored by:   Juniper Networks, Inc.
    Differential Revision: https://reviews.freebsd.org/D39493
---
 sys/net/if.c     | 7 +++++++
 sys/net/if_var.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/sys/net/if.c b/sys/net/if.c
index b53a361c2ba3..af9758a39324 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -4685,6 +4685,13 @@ if_llmaddr_count(if_t ifp)
 	return (count);
 }
 
+bool
+if_maddr_empty(if_t ifp)
+{
+
+	return (CK_STAILQ_EMPTY(&ifp->if_multiaddrs));
+}
+
 u_int
 if_foreach_llmaddr(if_t ifp, iflladdr_cb_t cb, void *cb_arg)
 {
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 98d65be2ef81..f87472509863 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -657,6 +657,7 @@ u_int if_foreach_lladdr(if_t, iflladdr_cb_t, void *);
 u_int if_foreach_llmaddr(if_t, iflladdr_cb_t, void *);
 u_int if_lladdr_count(if_t);
 u_int if_llmaddr_count(if_t);
+bool if_maddr_empty(if_t);
 
 int if_getamcount(const if_t ifp);
 struct ifaddr * if_getifaddr(const if_t ifp);