From nobody Sun Nov 05 19:36:43 2023 X-Original-To: dev-commits-src-all@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 4SNl975Q3hz507j0; Sun, 5 Nov 2023 19:36:43 +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 4SNl974zT8z3fvr; Sun, 5 Nov 2023 19:36:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699213003; 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=W1Ub0TboH5r+zMACH8+ty8gW21dc3o1L4nNF3uNt4d8=; b=mOWrtiIP/7rXb3P4Dnk5LjLfNVyQvng/m0lmOYzMR28qrtE4V6nkqYXef657jqUBhjuj70 lmRJvyo9BQzwq1E7/4HbiVjbtsKIMt3DshVkJHd1qiO2zfXKm9W3VV63VGafsaUhioO3zJ r/ein2dGBjlusIciALroGGVSZd0aWKI04M4aYhkfGJlSr5NBPA505V8l2UdwQm1Xr/GsZq 57MFRJ2LGawrzbFEXkF2iBvPQLfbwoF5Jqi/lZupJeofRwmT1FebAxrJtKJZqtemD05Cvn We5GPxfNsOnf+oS2Yb4LFvxu0yQIhIkjEw7ZGmrHZ3/IRYD4gffMrMHOA354wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699213003; 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=W1Ub0TboH5r+zMACH8+ty8gW21dc3o1L4nNF3uNt4d8=; b=W0Y7lu895EPKIqs1AjhuwgidtAkrkb2rvbbzmpxt3WMWBtQZgW2N0vMv8r9bjj6s3w1AC0 F8CdF+S9BMwx81grJ3NPr1Ud9C+fBwWPfb/ifGTOMikRRUxY6PyH0+71v/FZ/aHr6USKOR hJ+YM7YBPp89JlhJsAmZY8IEX/F8wA3ynSUKtYwg/+usbgP/rJ12dO4zHQ75Wil+wOqDUl m8kQGf6/X6Xc79WbyB18ZjaBJbNvrfQQitMuiUl4zV0dY7OvMHT8AFRXz8wGNm6I9cX1Iz wv8fLUnAK24JkW2VIvTlMTwvdDiw6ppbN4xsVBumtWij8mKrrYzqQek7LT0R1g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699213003; a=rsa-sha256; cv=none; b=L9F3Y+pk4mIAsyVpkB0wOSc7Fe/3th5UK/ZJMKKWAo47nso0ReBeSdmRtYOqT65VYg8BV1 QPV/G+pHz6/twgHHpKeEJwnQaNyBvViQovd8AeTpIYJtertdRaKQoDHDrnCHwnbqgJ8E4X Tu1FvQ+0pxBqO+S1fDdfhrP4R/TzZGT40OwvlaXuAYSYUCRQOKCEcU+LADMSZS3SsKk8gh OEp5Liozf2IfSQPEsi/GeYbs5Nc08CHW5YxqBck9MJU4oyyL9fWEucpero7xsPZXgnELNb ImVyG+gYx2zZuDUecm5vwTylmmGUrwW5TbF0UyMjSo/mA52vONPnPRkyXaBJjw== 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 4SNl973kNgzdG9; Sun, 5 Nov 2023 19:36:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3A5JahR6039290; Sun, 5 Nov 2023 19:36:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A5Jahbi039287; Sun, 5 Nov 2023 19:36:43 GMT (envelope-from git) Date: Sun, 5 Nov 2023 19:36:43 GMT Message-Id: <202311051936.3A5Jahbi039287@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 35af22ac986c - main - if_tuntap: trigger the bpf hook on transmitting for the tap interface List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 35af22ac986c4f3e8160c943a478492e748b6f23 Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=35af22ac986c4f3e8160c943a478492e748b6f23 commit 35af22ac986c4f3e8160c943a478492e748b6f23 Author: Michael Tuexen AuthorDate: 2023-11-05 19:32:46 +0000 Commit: Michael Tuexen CommitDate: 2023-11-05 19:32:46 +0000 if_tuntap: trigger the bpf hook on transmitting for the tap interface The tun interface triggers the bpf hook when a packet is transmitted, the tap interface triggers it when the packet is read from the character device. This is inconsistent. So fix the tap device such that it behaves like the tun device. This is needed for adding support for the tap device to packetdrill. Reviewed by: kevans, rscheff MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D42467 --- sys/net/if_tuntap.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c index 3eeaadb83a20..a865c23cb372 100644 --- a/sys/net/if_tuntap.c +++ b/sys/net/if_tuntap.c @@ -933,6 +933,16 @@ tunstart_l2(struct ifnet *ifp) TUN_UNLOCK(tp); } /* tunstart_l2 */ +static int +tap_transmit(struct ifnet *ifp, struct mbuf *m) +{ + int error; + + BPF_MTAP(ifp, m); + IFQ_HANDOFF(ifp, m, error); + return (error); +} + /* XXX: should return an error code so it can fail. */ static void tuncreate(struct cdev *dev) @@ -972,6 +982,8 @@ tuncreate(struct cdev *dev) if ((tp->tun_flags & TUN_L2) != 0) { ifp->if_init = tunifinit; ifp->if_start = tunstart_l2; + ifp->if_transmit = tap_transmit; + ifp->if_qflush = if_qflush; ether_gen_addr(ifp, &eaddr); ether_ifattach(ifp, eaddr.octet); @@ -1713,9 +1725,6 @@ tunread(struct cdev *dev, struct uio *uio, int flag) } TUN_UNLOCK(tp); - if ((tp->tun_flags & TUN_L2) != 0) - BPF_MTAP(ifp, m); - len = min(tp->tun_vhdrlen, uio->uio_resid); if (len > 0) { struct virtio_net_hdr_mrg_rxbuf vhdr;