-.\" $OpenBSD: ifconfig.8,v 1.395 2023/05/16 14:32:54 jan Exp $
+.\" $OpenBSD: ifconfig.8,v 1.396 2023/06/01 18:57:53 kn Exp $
.\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $
.\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $
.\"
.\"
.\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94
.\"
-.Dd $Mdocdate: May 16 2023 $
+.Dd $Mdocdate: June 1 2023 $
.Dt IFCONFIG 8
.Os
.Sh NAME
.Op Fl wgpeerall
.Oo
.Oo Fl Oc Ns Cm wgpeer Ar publickey
+.Op Oo Fl Oc Ns Cm wgdescr Ns Oo Cm iption Oc Ar value
.Op Cm wgaip Ar allowed-ip_address/prefix
.Op Cm wgendpoint Ar peer_address port
.Op Cm wgpka Ar interval
immediately preceding them,
are as follows:
.Bl -tag -width Ds
+.Tg wgdescription
+.It Cm wgdescr Ns Oo Cm iption Oc Ar value
+Set the peer's description.
+This can be used to label peers in situations where they may
+otherwise be difficult to distinguish.
+.It Cm -wgdescr Ns Op Cm iption
+Clear the peer description.
.It Cm wgaip Ar allowed-ip_address/prefix
Set the peer's IPv4 or IPv6
.Ar allowed-ip_address
-/* $OpenBSD: ifconfig.c,v 1.464 2023/05/16 14:32:54 jan Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.465 2023/06/01 18:57:54 kn Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
/* WG */
void setwgpeer(const char *, int);
+void setwgpeerdesc(const char *, int);
void setwgpeerep(const char *, const char *);
void setwgpeeraip(const char *, int);
void setwgpeerpsk(const char *, int);
void setwgrtable(const char *, int);
void unsetwgpeer(const char *, int);
+void unsetwgpeerdesc(const char *, int);
void unsetwgpeerpsk(const char *, int);
void unsetwgpeerall(const char *, int);
{ "sffdump", 0, 0, transceiverdump },
{ "wgpeer", NEXTARG, A_WIREGUARD, setwgpeer},
+ { "wgdescription", NEXTARG, A_WIREGUARD, setwgpeerdesc},
+ { "wgdescr", NEXTARG, A_WIREGUARD, setwgpeerdesc},
{ "wgendpoint", NEXTARG2, A_WIREGUARD, NULL, setwgpeerep},
{ "wgaip", NEXTARG, A_WIREGUARD, setwgpeeraip},
{ "wgpsk", NEXTARG, A_WIREGUARD, setwgpeerpsk},
{ "wgkey", NEXTARG, A_WIREGUARD, setwgkey},
{ "wgrtable", NEXTARG, A_WIREGUARD, setwgrtable},
{ "-wgpeer", NEXTARG, A_WIREGUARD, unsetwgpeer},
- { "-wgpsk", 0, A_WIREGUARD, unsetwgpeerpsk},
+ { "-wgdescription", 0, A_WIREGUARD, unsetwgpeerdesc},
+ { "-wgdescr", 0, A_WIREGUARD, unsetwgpeerdesc},
{ "-wgpeerall", 0, A_WIREGUARD, unsetwgpeerall},
#else /* SMALL */
wg_interface->i_peers_count++;
}
+void
+setwgpeerdesc(const char *descr, int param)
+{
+ if (wg_peer == NULL)
+ errx(1, "wgdescr: wgpeer not set");
+ wg_peer->p_flags |= WG_PEER_SET_DESCRIPTION;
+ strlcpy(wg_peer->p_description, descr, IFDESCRSIZE);
+}
+
void
setwgpeeraip(const char *aip, int param)
{
wg_peer->p_flags |= WG_PEER_REMOVE;
}
+void
+unsetwgpeerdesc(const char *descr, int param)
+{
+ if (wg_peer == NULL)
+ errx(1, "wgdescr: wgpeer not set");
+ wg_peer->p_flags |= WG_PEER_SET_DESCRIPTION;
+ strlcpy(wg_peer->p_description, "", IFDESCRSIZE);
+}
+
void
unsetwgpeerpsk(const char *value, int param)
{
key, sizeof(key));
printf("\twgpeer %s\n", key);
+ if (strlen(wg_peer->p_description))
+ printf("\t\twgdescr: %s\n",
+ wg_peer->p_description);
+
if (wg_peer->p_flags & WG_PEER_HAS_PSK)
printf("\t\twgpsk (present)\n");
-/* $OpenBSD: if_wg.c,v 1.27 2023/05/30 08:30:01 jsg Exp $ */
+/* $OpenBSD: if_wg.c,v 1.28 2023/06/01 18:57:53 kn Exp $ */
/*
* Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
SLIST_ENTRY(wg_peer) p_start_list;
int p_start_onlist;
+
+ char p_description[IFDESCRSIZE];
};
struct wg_softc {
peer->p_counters_tx = 0;
peer->p_counters_rx = 0;
+ strlcpy(peer->p_description, "", IFDESCRSIZE);
+
mtx_init(&peer->p_endpoint_mtx, IPL_NET);
bzero(&peer->p_endpoint, sizeof(peer->p_endpoint));
}
}
+ if (peer_o.p_flags & WG_PEER_SET_DESCRIPTION)
+ strlcpy(peer->p_description, peer_o.p_description,
+ IFDESCRSIZE);
+
aip_p = &peer_p->p_aips[0];
for (j = 0; j < peer_o.p_aips_count; j++) {
if ((ret = copyin(aip_p, &aip_o, sizeof(aip_o))) != 0)
}
peer_o.p_aips_count = aip_count;
+ strlcpy(peer_o.p_description, peer->p_description, IFDESCRSIZE);
+
if ((ret = copyout(&peer_o, peer_p, sizeof(peer_o))) != 0)
goto unlock_and_ret_size;