git: b0491d5a73d1 - stable/12 - netmap_update_config: update na->name to cope with reconfigurations

From: Vincenzo Maffione <vmaffione_at_FreeBSD.org>
Date: Sat, 31 Dec 2022 12:29:14 UTC
The branch stable/12 has been updated by vmaffione:

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

commit b0491d5a73d16a3d8144c0d95a158498c29f841a
Author:     Vincenzo Maffione <vmaffione@FreeBSD.org>
AuthorDate: 2022-12-03 18:12:04 +0000
Commit:     Vincenzo Maffione <vmaffione@FreeBSD.org>
CommitDate: 2022-12-31 12:13:55 +0000

    netmap_update_config: update na->name to cope with reconfigurations
    
    MFC after:      1 week
    
    (cherry picked from commit 4ad57c7afaca3fd94b67c00706e210f0373b8e62)
---
 sys/dev/netmap/netmap.c      | 4 ++++
 sys/dev/netmap/netmap_bdg.h  | 1 -
 sys/dev/netmap/netmap_kern.h | 2 ++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/sys/dev/netmap/netmap.c b/sys/dev/netmap/netmap.c
index 52c7987f32fe..d3a0e935aef1 100644
--- a/sys/dev/netmap/netmap.c
+++ b/sys/dev/netmap/netmap.c
@@ -760,6 +760,10 @@ netmap_update_config(struct netmap_adapter *na)
 {
 	struct nm_config_info info;
 
+	if (na->ifp && !nm_is_bwrap(na)) {
+		strlcpy(na->name, na->ifp->if_xname, sizeof(na->name));
+	}
+
 	bzero(&info, sizeof(info));
 	if (na->nm_config == NULL ||
 	    na->nm_config(na, &info)) {
diff --git a/sys/dev/netmap/netmap_bdg.h b/sys/dev/netmap/netmap_bdg.h
index e4683885e66c..42640128fcbd 100644
--- a/sys/dev/netmap/netmap_bdg.h
+++ b/sys/dev/netmap/netmap_bdg.h
@@ -190,7 +190,6 @@ void netmap_uninit_bridges2(struct nm_bridge *, u_int);
 int netmap_bdg_update_private_data(const char *name, bdg_update_private_data_fn_t callback,
 	void *callback_data, void *auth_token);
 int netmap_bdg_config(struct nm_ifreq *nifr);
-int nm_is_bwrap(struct netmap_adapter *);
 
 #define NM_NEED_BWRAP (-2)
 #endif /* _NET_NETMAP_BDG_H_ */
diff --git a/sys/dev/netmap/netmap_kern.h b/sys/dev/netmap/netmap_kern.h
index 297e4c25e641..a45a405d5163 100644
--- a/sys/dev/netmap/netmap_kern.h
+++ b/sys/dev/netmap/netmap_kern.h
@@ -1097,6 +1097,7 @@ struct netmap_bwrap_adapter {
 	 */
 	struct netmap_vp_adapter *saved_na_vp;
 };
+int nm_is_bwrap(struct netmap_adapter *na);
 int nm_bdg_polling(struct nmreq_header *hdr);
 
 #ifdef WITH_VALE
@@ -1511,6 +1512,7 @@ extern unsigned int vale_max_bridges;
 #define	netmap_get_vale_na(_1, _2, _3, _4)	0
 #define netmap_bdg_create(_1, _2)	NULL
 #define netmap_bdg_destroy(_1, _2)	0
+#define vale_max_bridges		1
 #endif /* !WITH_VALE */
 
 #ifdef WITH_PIPES