Re: git: bf454ca88bdf - main - wg: Add netmap support

From: Peter Jeremy <peterj_at_freebsd.org>
Date: Sat, 15 Jun 2024 12:40:31 UTC
On 2024-Apr-20 16:05:06 +0000, Mark Johnston <markj@FreeBSD.org> wrote:
>URL: https://cgit.FreeBSD.org/src/commit/?id=bf454ca88bdf4acfa873386e876ff5e772e6a830
>
>    wg: Add netmap support
...
>--- a/sys/dev/wg/if_wg.c
>+++ b/sys/dev/wg/if_wg.c
...
>@@ -2206,6 +2341,11 @@ wg_output(if_t ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro
> 		return (EAFNOSUPPORT);
> 	}
> 
>+#ifdef DEV_NETMAP
>+	if ((if_getcapenable(ifp) & IFCAP_NETMAP) != 0)
>+		return (wg_xmit_netmap(ifp, m, af));
>+#endif
>+
> 	defragged = m_defrag(m, M_NOWAIT);
> 	if (defragged)
> 		m = defragged;
>@@ -2781,7 +2921,10 @@ 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);
>+	if_setinputfn(ifp, wg_if_input);
>+#endif
> 	if_setoutputfn(ifp, wg_output);
> 	if_setioctlfn(ifp, wg_ioctl);
> 	if_attach(ifp);

sys/net/if.c:if_attach_internal() (called from if_attach()) requires that
both transmit and qflush must either be NULL or set but if DEV_NETMAP is
undefined, this code only sets qflush, guaranteeing a panic() as soon as a
wg is attached.  Unfortunately, I don't understand the code well enough to
offer a fix.

-- 
Peter Jeremy