git: 14148b5c5cd6 - stable/14 - wg: Use ENETUNREACH when transmitting to a non-existent peer

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 15 Apr 2024 14:05:37 UTC
The branch stable/14 has been updated by markj:

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

commit 14148b5c5cd602f57a7536fe295632173939380e
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-04-01 17:20:55 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-04-15 14:05:13 +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.
    
    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 25fa53c2e672..bf4eef31c0b3 100644
--- a/sys/dev/wg/if_wg.c
+++ b/sys/dev/wg/if_wg.c
@@ -251,9 +251,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)
@@ -2113,7 +2110,7 @@ wg_xmit(if_t 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;
 	}