From nobody Fri Jan 12 16:53:37 2024 X-Original-To: dev-commits-src-branches@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 4TBSKZ0bZFz5795w; Fri, 12 Jan 2024 16:53:38 +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 4TBSKY6ksLz4XrS; Fri, 12 Jan 2024 16:53:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705078417; 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=eHTygr40q/eob9Iro/FoRmbuY7cv9d/iX+78D1jW3/0=; b=ENVUF994Ok6ILN9kOi67G+AcHV1YrXDQPqm0hZeFvyZuG6kvYxvnjgc6DrfBH0PCyRCuXh KVuD5eFcjpZzEMd/gdGKu3XfU1MkJkAnUn9iPmpIBqzqVY59Zmjaf6bF51LIr7Qn4WlTvA qxV6YCuFEGW6mQr4seC3H3Xm3Oyzuu/kfCPQt+jFyxVrm8UG2QfnZbtqTB4ewCydpfQQh9 dB55aY2ugssUoeSBaQed3zDR1SHA9qteCAY6P3fxwivz1nBwhdsXuf+7LCWLwwBOITRE7m pXOEasaFeaY5YgemCd5XdSqf0/TRvUIB2zZ7smgQlPPkDmGHL/Y7Gou8uarsnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705078417; 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=eHTygr40q/eob9Iro/FoRmbuY7cv9d/iX+78D1jW3/0=; b=VjfIZeIQdjQ92cf9B3IfIojDoqx/g1rwMq4DPV/3RqYo4RlihM/EDvFnq8xga4SQuUIStq 1D5hQRasLCJnczVzsfrgoA37hfIMEhLBMpMDtzJXQNXTAo3RUtn8zm0usKX3odb9GJdg49 SNptCqKco9EMIYPArnwveM2ZmtU8+WZpFncQItmEZl2CJd65jMq9GBYyqcztFLBCBOjjon Fj54ruGnPBru4ppXJcSda38+Nm2x+Xm/ycCG6YU4s1r3diUfSpZo2AHBKBCTebvYcrKB6t 0XKH+6uY9G8L02MMVZ21C/srf6PX85fLhEo1+ZsAsVkyYfTY/Lf9JkA2rYjzsA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705078417; a=rsa-sha256; cv=none; b=h2EDis6IX/IUgBGuQv0QcYo41pk1eLPXvm5ja64NXxlvEE5AAw3DOfuCUgbtUex9fgHh6a rN/2MX6pUUaHq6mqNBYIEUY4744f98wdke/eNhhFOBQsuXkhRU1v0D5s7tnjsUjeWaJcQ5 ivMuzoqW13kkW9Hpm58dumrxhkGGg+/irL8+pK8xeM4Lj69JG+43FtuWaLVYcIXa7Xqbo6 JGKwsYsRRWRpKS/ekEH9CEp/VYnbpAp7xXrJ8VpQOLmWs4jvaZAkmlJxnn1/NS0PD0AU+/ CwjsRCyOc+WUAUoe4QPX+Hj9zzTj1pSMBGw5Bl+6rV3UcZuWRl8lC3MK7e5BQA== 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 4TBSKY5nymz192x; Fri, 12 Jan 2024 16:53:37 +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 40CGrbo6096048; Fri, 12 Jan 2024 16:53:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40CGrbvs096045; Fri, 12 Jan 2024 16:53:37 GMT (envelope-from git) Date: Fri, 12 Jan 2024 16:53:37 GMT Message-Id: <202401121653.40CGrbvs096045@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: e0f22f9e1867 - stable/14 - if_tuntap: trigger the bpf hook on transmitting for the tap interface List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: e0f22f9e1867e9a4a2fc90327a13265eb233c7f3 Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=e0f22f9e1867e9a4a2fc90327a13265eb233c7f3 commit e0f22f9e1867e9a4a2fc90327a13265eb233c7f3 Author: Michael Tuexen AuthorDate: 2023-11-05 19:32:46 +0000 Commit: Michael Tuexen CommitDate: 2024-01-12 16:51:40 +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 Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D42467 (cherry picked from commit 35af22ac986c4f3e8160c943a478492e748b6f23) --- 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 298f37bebc56..f273e4993dfd 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;