git: 894bf6bd7d1d - stable/13 - wg: Use ENETUNREACH when transmitting to a non-existent peer

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 16 Apr 2024 16:18:05 UTC
The branch stable/13 has been updated by markj:

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

commit 894bf6bd7d1dcdb2869cf065bea697e1dda07cb0
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-04-01 17:20:55 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-04-16 16:08:54 +0000

    wg: Use ENETUNREACH when transmitting to a non-existent peer
    
    The old errno value used is specifically for Capsicum and shouldn't be
    co-opted in this way.  It has special handling in the generic syscall
    layer (see syscallret()).  OpenBSD returns ENETUNREACH in this case;
    let's do the same thing.
    
    PR:             266712
    Reviewed by:    kevans, imp
    MFC after:      2 weeks
    Sponsored by:   Klara, Inc.
    Differential Revision:  https://reviews.freebsd.org/D44582
    
    (cherry picked from commit 63613e3ba1e188e9fece43e1613bd697f04b345e)
---
 sys/dev/wg/if_wg.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/sys/dev/wg/if_wg.c b/sys/dev/wg/if_wg.c
index 6638524301b8..a65c3a707985 100644
--- a/sys/dev/wg/if_wg.c
+++ b/sys/dev/wg/if_wg.c
@@ -255,9 +255,6 @@ struct wg_softc {
 
 #define MAX_LOOPS	8
 #define MTAG_WGLOOP	0x77676c70 /* wglp */
-#ifndef ENOKEY
-#define	ENOKEY	ENOTCAPABLE
-#endif
 
 #define	GROUPTASK_DRAIN(gtask)			\
 	gtaskqueue_drain((gtask)->gt_taskqueue, &(gtask)->gt_task)
@@ -2116,7 +2113,7 @@ wg_xmit(struct ifnet *ifp, struct mbuf *m, sa_family_t af, uint32_t mtu)
 	BPF_MTAP2_AF(ifp, m, pkt->p_af);
 
 	if (__predict_false(peer == NULL)) {
-		rc = ENOKEY;
+		rc = ENETUNREACH;
 		goto err_xmit;
 	}