git: a9a57c843264 - stable/14 - wg: Implement if_transmit unconditionally

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 02 Jul 2024 13:22:32 UTC
The branch stable/14 has been updated by markj:

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

commit a9a57c843264ae1fecf8f0b63f95edbca2496819
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-06-16 17:33:45 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-07-02 13:19:28 +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")
    
    (cherry picked from commit 5515e8874a8d85a8d961fca64c494dfc1bea4bd0)
---
 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 552f47f9645b..b0ad94e284f1 100644
--- a/sys/dev/wg/if_wg.c
+++ b/sys/dev/wg/if_wg.c
@@ -2194,7 +2194,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)
 {
@@ -2256,6 +2255,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.
@@ -2919,8 +2919,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);