git: 5515e8874a8d - main - wg: Implement if_transmit unconditionally

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Sun, 16 Jun 2024 18:11:18 UTC
The branch main has been updated by markj:

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

commit 5515e8874a8d85a8d961fca64c494dfc1bea4bd0
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-06-16 17:33:45 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-06-16 17:33:45 +0000

    wg: Implement if_transmit unconditionally
    
    Commit bf454ca88bdf made wg_transmit() defined only when "device netmap"
    is configured, as if_wg's if_transmit implementation should never be
    called otherwise, but this breaks a requirement that interfaces
    implement both or neither of if_transmit and if_qflush.
    
    Restore the old behaviour of unconditionally defining wg_transmit().  It
    contains an assertion that the interface is in netmap mode.
    
    Reported by:    peterj
    MFC after:      2 weeks
    Fixes:  bf454ca88bdf ("wg: Add netmap support")
---
 sys/dev/wg/if_wg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/wg/if_wg.c b/sys/dev/wg/if_wg.c
index d0b75d5cbf4b..6683d0505b26 100644
--- a/sys/dev/wg/if_wg.c
+++ b/sys/dev/wg/if_wg.c
@@ -2196,7 +2196,6 @@ determine_af_and_pullup(struct mbuf **m, sa_family_t *af)
 	return (0);
 }
 
-#ifdef DEV_NETMAP
 static int
 determine_ethertype_and_pullup(struct mbuf **m, int *etp)
 {
@@ -2258,6 +2257,7 @@ wg_transmit(if_t ifp, struct mbuf *m)
 	return (0);
 }
 
+#ifdef DEV_NETMAP
 /*
  * This should only be invoked by netmap, via nm_os_send_up(), to process
  * packets from the host TX ring.
@@ -2921,8 +2921,8 @@ wg_clone_create(struct if_clone *ifc, char *name, size_t len,
 	if_setinitfn(ifp, wg_init);
 	if_setreassignfn(ifp, wg_reassign);
 	if_setqflushfn(ifp, wg_qflush);
-#ifdef DEV_NETMAP
 	if_settransmitfn(ifp, wg_transmit);
+#ifdef DEV_NETMAP
 	if_setinputfn(ifp, wg_if_input);
 #endif
 	if_setoutputfn(ifp, wg_output);