From nobody Mon Oct 17 13:58:23 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Mrdr02QCfz4g2S6; Mon, 17 Oct 2022 13:58:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Mrdr020Lyz48j2; Mon, 17 Oct 2022 13:58:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666015104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cw+kOVwMrgADOF+Yl1M73aklFN7IxD6NjrmxXL5SGOg=; b=LPWQv3EX92WuSVUvPyTkFbB0/fnnLusw23vNbtUQLY5fh8lGyg65abIPRUuEfMN37dA61/ SIol+sRQ8Su6gAP4Rfyx0uPgmYzSbtURwHlIu3PnhCuJvDcobuOEGKp/A+y6xHQSXEAxTQ 0ddzRQ3UytSFOsMJ2UILzKUZdnbAwRBCdreqcwfYsn24gICDmCQbAfpWVo4VwuTDwPixLs vsCQgYL7aDz9ymwGLUG1AK6seGZHthmA6QR0prFea47eoTPCksUmSVT1XwU2UIBLeaRf4L XugafpnaeCdNT5imLSP6powzXEr7OLJ+6Z47KpzxEVYuQ5fi6zt0XViL+THvMg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Mrdr00nT9zrZ4; Mon, 17 Oct 2022 13:58:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29HDwNmh082325; Mon, 17 Oct 2022 13:58:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29HDwNdl082324; Mon, 17 Oct 2022 13:58:23 GMT (envelope-from git) Date: Mon, 17 Oct 2022 13:58:23 GMT Message-Id: <202210171358.29HDwNdl082324@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 2e797555f701 - main - if_ovpn(4): implement ioctl() to set if_flags List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2e797555f701c38d9d82cbbea61d3d8933f2bd56 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666015104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cw+kOVwMrgADOF+Yl1M73aklFN7IxD6NjrmxXL5SGOg=; b=ZyhY+57I0frPbOXtCFwGEalro9JO+upmrQljLg0M6c4OxDnH9AP9o6fXeE2+8hiHjK2kqg G2Rz6T2GmtLSX0abKjLCprjgFiUZNd60Fu259WAsSzl2/XQh6AP+GaaaLfuBauwUfvhpm8 ANOaA/pvvSrb3vU26zhqDjwu6gQV3JY54/pnmh25x5+V8N0IPNT6Q4hO0+/yVwPxwH4CV+ N2lzDowcdTdwoAwWKAZ3cJYPjbUO2RjXK+qBv4W85gRQ7msmTXS85enGnqZOVSFxdUegM4 Qvlq4J751QcjQDieu9kFKYLpdReXxQ1/E9SGyxzYcoTvhL9U71uSNi2D5CdYnA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666015104; a=rsa-sha256; cv=none; b=I3/zZowhD55Qn4Wkk1IvVP0GrrGvIYwr8kV5shISGfuv2LbWrRy+VSmpeTBhY2TBFgfHS1 4/XC2z41bKxQImGeYbQ2cc6RUnLE0QOiAXwai1T11NY4E4gjPZtMj/QT0zAVDxdkHcyzT6 hZpq8GYbFhzz/BJeL0OSQqsS+udxObEQ5fw+qaSDi74qQSCwKykY8KY1HeGd26/8Uvytv/ IliV8kzskOPoW33zrxaWmiwLt/5SyjHaJ2R2LScHNzfIu0DcToUw2eXujhBABMi6SsxaCj KVRMkGZNJGjXmq2qq/gtN/jI/zaD20vgKIMqxuDdADKBxOvWbiyaIJ+ymERyNg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2e797555f701c38d9d82cbbea61d3d8933f2bd56 commit 2e797555f701c38d9d82cbbea61d3d8933f2bd56 Author: Gert Doering AuthorDate: 2022-10-12 13:30:07 +0000 Commit: Kristof Provost CommitDate: 2022-10-17 13:33:45 +0000 if_ovpn(4): implement ioctl() to set if_flags Fully working openvpn(8) --iroute support needs real subnet config on ovpn(4) interfaces (IFF_BROADCAST), while client-side/p2p configs need IFF_POINTOPOINT setting. So make this configurable. Reviewed by: kp --- sys/net/if_ovpn.c | 42 ++++++++++++++++++++++++++++++++++++++++++ sys/net/if_ovpn.h | 1 + 2 files changed, 43 insertions(+) diff --git a/sys/net/if_ovpn.c b/sys/net/if_ovpn.c index 524640639e76..14634cfc969b 100644 --- a/sys/net/if_ovpn.c +++ b/sys/net/if_ovpn.c @@ -1081,6 +1081,45 @@ ovpn_set_peer(struct ifnet *ifp, const nvlist_t *nvl) return (0); } +static int +ovpn_set_ifmode(struct ifnet *ifp, const nvlist_t *nvl) +{ + struct ovpn_softc *sc = ifp->if_softc; + int ifmode; + + if (nvl == NULL) + return (EINVAL); + + if (! nvlist_exists_number(nvl, "ifmode") ) + return (EINVAL); + + ifmode = nvlist_get_number(nvl, "ifmode"); + + OVPN_WLOCK(sc); + + /* deny this if UP */ + if (ifp->if_flags & IFF_UP) { + OVPN_WUNLOCK(sc); + return (EBUSY); + } + + switch (ifmode & ~IFF_MULTICAST) { + case IFF_POINTOPOINT: + case IFF_BROADCAST: + ifp->if_flags &= + ~(IFF_BROADCAST|IFF_POINTOPOINT|IFF_MULTICAST); + ifp->if_flags |= ifmode; + break; + default: + OVPN_WUNLOCK(sc); + return (EINVAL); + } + + OVPN_WUNLOCK(sc); + + return (0); +} + static int ovpn_ioctl_set(struct ifnet *ifp, struct ifdrv *ifd) { @@ -1135,6 +1174,9 @@ ovpn_ioctl_set(struct ifnet *ifp, struct ifdrv *ifd) case OVPN_SET_PEER: ret = ovpn_set_peer(ifp, nvl); break; + case OVPN_SET_IFMODE: + ret = ovpn_set_ifmode(ifp, nvl); + break; default: ret = ENOTSUP; } diff --git a/sys/net/if_ovpn.h b/sys/net/if_ovpn.h index 26a9907711ce..fd1c21e70435 100644 --- a/sys/net/if_ovpn.h +++ b/sys/net/if_ovpn.h @@ -60,5 +60,6 @@ enum ovpn_key_cipher { #define OVPN_SEND_PKT _IO ('D', 9) #define OVPN_POLL_PKT _IO ('D', 10) #define OVPN_GET_PKT _IO ('D', 11) +#define OVPN_SET_IFMODE _IO ('D', 12) #endif