From nobody Fri Jul 08 18:18:40 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 DA2A317D70F7; Fri, 8 Jul 2022 18:18:40 +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 4LfhNw5nzjz3Hmw; Fri, 8 Jul 2022 18:18:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657304320; 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=1xWQliSTWEk2vIOw3hPu1QTkr5Nk2i0P4rpZsPdJH60=; b=vA+ulCtRZNiB7fsDtMXnte0uiS1wVoICfx3L79WpKMr6NBemirQWHkJnyj6hFrzqEFqmcu BTb4LDEOUaOb1hpwpmZEHTc+tSZ8NST2jijmv825G8x2qvw0hsY+94OlcnOPAYmb9ML3zN ThY9I1a05EYrB1akB48ou9RtE9yC4b3rowyWfRrgNJ2A7J9Lk1aaDnSqdbWUZiAYzz1Qjw z87p8SGN8Eq3EHFLMolz7+EmFxODRyvDA3RGajrm8YOIFQ2QoFusMD8dj/QvtYPtySGqRz oOleJpO3Tby3w6xf8SXOy1+U3cixVU0a4MkHxOkbEZ16Ss/dnMaiPm6yx4pINQ== 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 4LfhNw4qNxzGsc; Fri, 8 Jul 2022 18:18:40 +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 268IIeQF005752; Fri, 8 Jul 2022 18:18:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 268IIeto005751; Fri, 8 Jul 2022 18:18:40 GMT (envelope-from git) Date: Fri, 8 Jul 2022 18:18:40 GMT Message-Id: <202207081818.268IIeto005751@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 7f7a804ae077 - main - vxlan: Add support for socket ioctls SIOC[SG]TUNFIB 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: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7f7a804ae077a0c43d8c3f1444f90bdfb841c6b1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657304320; 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=1xWQliSTWEk2vIOw3hPu1QTkr5Nk2i0P4rpZsPdJH60=; b=t9ZBHA9niXeu2q89pwAO8cZY+ABwm+9ZSgPnQdRNvazvjYZE/jySV1sBZDMwC4Ag59qj8/ NwvDneRE+TXAH3gZIQ3uWO/e/zJtF0HzJu+5fF4WKZsECTRzbs5zb96UwSY/eSNk2f0dif RW8K9B8lvjwK5taUY4LGenJV9X8KLVT2ZUvZC6udXho7zXQOQKy284OjY+caG3sXkNnSp7 ztkHFAIxCvawFdmfouP7AMW1qCL1Zf4Nlj3N6N/yxZzKkCvxqSGnapmvPqoq2pNhp5wKz6 0gSyZc53giNnKFHw1lGmhKMJVJ58nz8AWxgAohAPYeRTlk85R9z/SNSTfevTtg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657304320; a=rsa-sha256; cv=none; b=yjA9P28pflYSkdM9Od9W+A+M2nCoKkB3Fc3tS4z+EOQNQDBeFFsJoPjuzZUbxqXXg7v8Sb 7UWuwOGrqCeLldwG0/69Ljw/Fl+VAHNmie0b68iJjAyKR9Yatiguw4d6ZEkWvVCeGMPdvd 1+n+DOeLTEeWYWQrmOZn6eHcXtOjJ1BGxMqmwcEhiTBneb6VePwahS2PHj90McQgWQxf9w C8yuxouKkoomJj9R3c68XZRdJhc+N9quWtUcuebhcgS9ygqcxwkSbJ6RiQ/z5VCcjGD1Ed P9Pp3+Zg6GdwKK7NkAi236PVWPNoUPKu17Clg5+5uBsj/GPu7dR6KjLtYSCgag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=7f7a804ae077a0c43d8c3f1444f90bdfb841c6b1 commit 7f7a804ae077a0c43d8c3f1444f90bdfb841c6b1 Author: Zhenlei Huang AuthorDate: 2022-07-08 18:12:14 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-07-08 18:14:19 +0000 vxlan: Add support for socket ioctls SIOC[SG]TUNFIB Submitted by: Luiz Amaral PR: 244004 Differential Revision: https://reviews.freebsd.org/D32820 MFC after: 2 weeks --- sbin/ifconfig/ifconfig.8 | 5 +++-- sys/net/if_vxlan.c | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index e059c172dd5c..6cbe30748a13 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -520,9 +520,10 @@ Specify tunnel FIB. A FIB .Ar fib_number is assigned to all packets encapsulated by tunnel interface, e.g., -.Xr gif 4 +.Xr gif 4 , +.Xr gre 4 and -.Xr gre 4 . +.Xr vxlan 4 . .It Cm maclabel Ar label If Mandatory Access Control support is enabled in the kernel, set the MAC label to diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index 99efbe255695..a1e925195d74 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -163,6 +163,7 @@ struct vxlan_statistics { struct vxlan_softc { struct ifnet *vxl_ifp; int vxl_reqcap; + u_int vxl_fibnum; struct vxlan_socket *vxl_sock; uint32_t vxl_vni; union vxlan_sockaddr vxl_src_addr; @@ -2329,6 +2330,7 @@ vxlan_ioctl_drvspec(struct vxlan_softc *sc, struct ifdrv *ifd, int get) static int vxlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { + struct rm_priotracker tracker; struct vxlan_softc *sc; struct ifreq *ifr; struct ifdrv *ifd; @@ -2378,6 +2380,25 @@ vxlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) VXLAN_WUNLOCK(sc); break; + case SIOCGTUNFIB: + VXLAN_RLOCK(sc, &tracker); + ifr->ifr_fib = sc->vxl_fibnum; + VXLAN_RUNLOCK(sc, &tracker); + break; + + case SIOCSTUNFIB: + if ((error = priv_check(curthread, PRIV_NET_VXLAN)) != 0) + break; + + if (ifr->ifr_fib >= rt_numfibs) + error = EINVAL; + else { + VXLAN_WLOCK(sc); + sc->vxl_fibnum = ifr->ifr_fib; + VXLAN_WUNLOCK(sc); + } + break; + default: error = ether_ioctl(ifp, cmd, data); break; @@ -2533,7 +2554,7 @@ vxlan_encap4(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, sin->sin_family = AF_INET; sin->sin_len = sizeof(*sin); sin->sin_addr = ip->ip_dst; - ro->ro_nh = fib4_lookup(RT_DEFAULT_FIB, ip->ip_dst, 0, NHR_NONE, + ro->ro_nh = fib4_lookup(M_GETFIB(m), ip->ip_dst, 0, NHR_NONE, 0); if (ro->ro_nh == NULL) { m_freem(m); @@ -2645,7 +2666,7 @@ vxlan_encap6(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(*sin6); sin6->sin6_addr = ip6->ip6_dst; - ro->ro_nh = fib6_lookup(RT_DEFAULT_FIB, &ip6->ip6_dst, 0, + ro->ro_nh = fib6_lookup(M_GETFIB(m), &ip6->ip6_dst, 0, NHR_NONE, 0); if (ro->ro_nh == NULL) { m_freem(m); @@ -2722,6 +2743,7 @@ vxlan_transmit(struct ifnet *ifp, struct mbuf *m) ETHER_BPF_MTAP(ifp, m); VXLAN_RLOCK(sc, &tracker); + M_SETFIB(m, sc->vxl_fibnum); if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { VXLAN_RUNLOCK(sc, &tracker); m_freem(m); @@ -3181,6 +3203,7 @@ vxlan_clone_create(struct if_clone *ifc, int unit, caddr_t params) sc = malloc(sizeof(struct vxlan_softc), M_VXLAN, M_WAITOK | M_ZERO); sc->vxl_unit = unit; + sc->vxl_fibnum = curthread->td_proc->p_fibnum; vxlan_set_default_config(sc); error = vxlan_stats_alloc(sc); if (error != 0)