From nobody Tue Feb 08 06:19:32 2022 X-Original-To: ports-bugs@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 C4A1419C7ECD for ; Tue, 8 Feb 2022 06:19:32 +0000 (UTC) (envelope-from bugzilla-noreply@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 4JtCXN3bRKz3rXP for ; Tue, 8 Feb 2022 06:19:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 5C6001452B for ; Tue, 8 Feb 2022 06:19:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 2186JWNl063304 for ; Tue, 8 Feb 2022 06:19:32 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 2186JWHY063303 for ports-bugs@FreeBSD.org; Tue, 8 Feb 2022 06:19:32 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: ports-bugs@FreeBSD.org Subject: [Bug 261786] [maintainer update] net/vether-kmod: update to g20220208, head Date: Tue, 08 Feb 2022 06:19:32 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Ports & Packages X-Bugzilla-Component: Individual Port(s) X-Bugzilla-Version: Latest X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: henning.matyschok@outlook.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: ports-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter flagtypes.name attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Ports bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-ports-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-ports-bugs@freebsd.org X-BeenThere: freebsd-ports-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644301172; 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=FDFMZ187Efka30OMx9bODbOGi1wHUQMd/06pHDg1Wz8=; b=AO3AndhAdca6qDX6A1TQZ/Wa/qrUZHiBKwu/CDyCtBDOuhi4/41COjdrOMzJbgE14ju9yX On8+221rePL8LETSNHNvcQ43SwlsUpESiK1bgEV8G0SJMt4qIY0n1XB1x1DxKPSb4hh/L+ XSV336kIkFz9OawmUt0RLG1hEaltTb67jb7WYX/Nu1+yDj9bwZoVd27xATvgl2Kp0VMhMI 8Jfs2w40oWeKGHTWqT4b2p1j7SeC30VG9sdLOHQOVT/qrUBF5oEagvse6TpuZSixHpNQV+ fjI68yDm4X+TwRcqL1dX73BV8uHi4rra0rgrSwLOv4AMAfzsK1tJFJ4I7PC8Ig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644301172; a=rsa-sha256; cv=none; b=hCsqi4VizN4Q6YuAHRJnaa6yGb1X0xtEXaYxeN7gHWPWsCBrJHqbvaA/r/ugWMgIpUVeOs rg2WAIE3mYTmVxBOi5pTkz36YmJOs/kvRv5KBfOlATwbI3ncKgCd/sOTFdGy4spNr1KSpL qbFQDxbRmVW9WzrPhPRkCoIJQbH8uh7xcIyq3owLZzvlPoNkmK5vSLP7Rhcpuj7Ux8XvnP Z6jKjPUFTQ/bkmo/hyyP1sa+UgCgukxWaFpurTcyL9HHij8iubLLjhqi6JXl7OoLnb+DE6 qlhYjEVAbsUyKGFr4bIIA5E+8baoAjSX05vD+HJBO9odmNBqCKcX+H7f4a1s9Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D261786 Bug ID: 261786 Summary: [maintainer update] net/vether-kmod: update to g20220208, head Product: Ports & Packages Version: Latest Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: Individual Port(s) Assignee: ports-bugs@FreeBSD.org Reporter: henning.matyschok@outlook.com Attachment #231629 maintainer-approval+ Flags: Created attachment 231629 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D231629&action= =3Dedit Patch against distinfo and Makefile, g20220208 New version: Index: sys/net/if_vether.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /dev/null +++ sys/net/if_vether.c @@ -0,0 +1,451 @@ +/* + * Copyright (c) 2009 Theo de Raadt + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +/* + * Copyright (c) 2018, 2021 United States Marine Corps + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Virtual Ethernet interface, ported from OpenBSD. This interface + * operates in conjunction with if_bridge(4). + */ + +struct vether_softc { + struct ifmedia sc_ifm; /* fake media information */ + struct ifnet *sc_ifp; /* network interface. */ +}; +#define VETHER_IF_FLAGS (IFF_SIMPLEX|IFF_BROADCAST|IFF_MULTICAST) +#define VETHER_IFCAP_FLAGS (IFCAP_VLAN_MTU|IFCAP_JUMBO_MTU) +#define VETHER_IFM_FLAGS (IFM_ETHER|IFM_AUTO) + +/* + * XXX + * The set of protocol-numbers index-set + * against maps-to set + * over (enum), e. g.: + * + * typedef enum netisr_proto { + * netisr_ip =3D NETISR_IP, + * netisr_igmp =3D NETISR_IGMP, + * netisr_route =3D NETISR_ROUTE, + * netisr_arp =3D NETISR_ARP, + * netisr_ether =3D NETISR_ETHER, + * netisr_ipv6 =3D NETISR_IPV6, + * netisr_epair =3D NETISR_EPAIR, + * netisr_ip_direct =3D NETISR_IP_DIRECT, + * netisr_ipv6_direct =3D NETISR_IPV6_DIRECT, + * netisr_vether =3D NETISR_VETHER_FWD, + * } netisr_proto_t; + */ +#define NETISR_VETHER_FWD 11 + +typedef enum vether_netisr_component { + vether_netisr_fwd =3D NETISR_VETHER_FWD, +} vether_netisr_component_t; + +static void vether_ifaddr_init(struct ifnet *, struct ether_addr *); +static void vether_nh_fwd_cb(struct mbuf *); +static void vether_texeof(struct ifnet *); + +static void vether_init(void *); +static void vether_stop(struct ifnet *); +static void vether_start(struct ifnet *); + +static int vether_media_change(struct ifnet *); +static void vether_media_status(struct ifnet *, struct ifmediareq *); +static int vether_ioctl(struct ifnet *, u_long, caddr_t); + +static int vether_clone_create(struct if_clone *, int, caddr_t); +static void vether_clone_destroy(struct ifnet *); + +static struct netisr_handler vether_nh_fwd =3D { + .nh_name =3D "Softintr. for if_vether(4)", + .nh_handler =3D vether_nh_fwd_cb, + .nh_proto =3D vether_netisr_fwd, + .nh_policy =3D NETISR_POLICY_FLOW, +}; +static const char vether_name[] =3D "vether"; + +VNET_DEFINE(struct if_clone *, vether_cloner); +#define V_vether_cloner VNET(vether_cloner) + +static int +vether_clone_create(struct if_clone *ifc, int unit, caddr_t data) +{ + struct vether_softc *sc; + struct ifnet *ifp; + struct ether_addr lla; + int error; + + /* + * For safety reason, there is a condition test applied - + * independently, if M_WAITOK was enabled or not. + */ + + if ((sc =3D malloc(sizeof(struct vether_softc), + M_DEVBUF, M_WAITOK|M_ZERO)) !=3D NULL) { + + if ((ifp =3D if_alloc(IFT_ETHER)) !=3D NULL) { + sc->sc_ifp =3D ifp; + ifp->if_softc =3D sc; + + if_initname(ifp, vether_name, unit); + + ifp->if_init =3D vether_init; + ifp->if_ioctl =3D vether_ioctl; + ifp->if_start =3D vether_start; + + ifp->if_flags =3D VETHER_IF_FLAGS; + + ifp->if_capabilities =3D VETHER_IFCAP_FLAGS; + ifp->if_capenable =3D VETHER_IFCAP_FLAGS; + + ifp->if_baudrate =3D 0; + + ifmedia_init(&sc->sc_ifm, 0, vether_media_change, + vether_media_status); + ifmedia_add(&sc->sc_ifm, VETHER_IFM_FLAGS, 0, NULL); + ifmedia_set(&sc->sc_ifm, VETHER_IFM_FLAGS); + + vether_ifaddr_init(ifp, &lla); + ether_ifattach(ifp, lla.octet); + + error =3D 0; + } else { + error =3D ENOSPC; + free(sc, M_DEVBUF); + } + } else + error =3D ENOBUFS; + + return (error); +} + +static void +vether_clone_destroy(struct ifnet *ifp) +{ + struct vether_softc *sc; + + if (ifp !=3D NULL) { + ifp->if_flags &=3D ~IFF_UP; + + vether_stop(ifp); + + if ((sc =3D ifp->if_softc) !=3D NULL) { + free(sc, M_DEVBUF); + ifp->if_softc =3D NULL; + } + ether_ifdetach(ifp); + if_free(ifp); + } +} + +static void +vnet_vether_init(const void *unused __unused) +{ + + V_vether_cloner =3D if_clone_simple(vether_name, + vether_clone_create, vether_clone_destroy, 0); +} +VNET_SYSINIT(vnet_vether_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_vether_init, NULL); + +static void +vnet_vether_uninit(const void *unused __unused) +{ + + if_clone_detach(V_vether_cloner); +} +VNET_SYSUNINIT(vnet_vether_uninit, SI_SUB_PSEUDO, SI_ORDER_ANY, + vnet_vether_uninit, NULL); + +static int +vether_mod_event(module_t mod, int event, void *data) +{ + switch (event) { + case MOD_LOAD: + netisr_register(&vether_nh_fwd); + return (0); + case MOD_UNLOAD: + netisr_unregister(&vether_nh_fwd); + return (0); + default: + break; + } + return (EOPNOTSUPP); +} + +static moduledata_t vether_mod =3D { + "if_vether", + vether_mod_event, + 0, +}; +DECLARE_MODULE(if_vether, vether_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); + +/* + * I/O. + */ + +static void +vether_txeof(struct ifnet *ifp) +{ + struct mbuf *m; + + if (ifp !=3D NULL) { + IFQ_DEQUEUE(&ifp->if_snd, m); + if (m !=3D NULL) { + BPF_MTAP(ifp, m); + + if ((m->m_flags & M_PKTHDR) !=3D 0) { + + /* do some statistics */ + + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + + /* discard, if not member of if_bridge(4) */ + if (ifp->if_bridge =3D=3D NULL) + m->m_pkthdr.rcvif =3D ifp; + + /* + * Three cases are considered here: + * + * (a) Frame was tx'd by layer above. + * + * (b) Frame was rx'd by link-layer. + * + * (c) Data sink. + */ + if (m->m_pkthdr.rcvif =3D=3D NULL) { + m->m_pkthdr.rcvif =3D ifp; + netisr_dispatch(vether_netisr_fwd, m); + } else if (m->m_pkthdr.rcvif !=3D ifp) { + m->m_pkthdr.rcvif =3D ifp; + + /* demultiplex any other frame */ + (*ifp->if_input)(ifp, m); + } else { + m_freem(m); + m =3D NULL; + } + + } else { + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + + m_freem(m); + m =3D NULL; + } + vether_txeof(ifp); + } + } +} + +static void +vether_start(struct ifnet *ifp) +{ + if ((ifp->if_flags & IFF_UP) !=3D 0) { + ifp->if_drv_flags |=3D IFF_DRV_OACTIVE; + vether_txeof(ifp); + ifp->if_drv_flags &=3D ~IFF_DRV_OACTIVE; + } +} + +/* + * Broadcast frame by if_bridge(4). + */ + +static void +vether_nh_fwd_cb(struct mbuf *m) +{ + struct ifnet *ifp; + int error; + + if (m !=3D NULL) { + + if ((m->m_flags & M_PKTHDR) !=3D 0) { + + if ((ifp =3D m->m_pkthdr.rcvif) !=3D NULL) + BRIDGE_OUTPUT(ifp, m, error); + else + error =3D EADDRNOTAVAIL; + } else + error =3D ECONNABORTED; + } else + error =3D ENOBUFS; + + if (error !=3D 0) { + + if (m !=3D NULL) { + m_freem(m); + m =3D NULL; + } + } +} + +/* + * Initialize lla. + */ + +static void +vether_ifaddr_init(struct ifnet *ifp, struct ether_addr *lla) +{ + caddr_t pfx, sfx; + + if (ifp !=3D NULL) { + + if (lla !=3D NULL) { + pfx =3D lla->octet; + pfx[0] =3D 0x02; + + sfx =3D (pfx + 1); + arc4rand(sfx, 5, 0); + } + } +} + +static int +vether_media_change(struct ifnet *ifp) +{ + int error; + + if (ifp !=3D NULL) + error =3D 0; + else + error =3D EADDRNOTAVAIL; + + return (error); +} + +static void +vether_media_status(struct ifnet *ifp, struct ifmediareq *ifm) +{ + if (ifp !=3D NULL) { + + if (ifm !=3D NULL) { + ifm->ifm_active =3D (IFM_ETHER|IFM_AUTO); + ifm->ifm_status =3D (IFM_AVALID|IFM_ACTIVE); + } + } +} + +static void +vether_init(void *xsc) +{ + struct vether_softc *sc; + struct ifnet *ifp; + + if ((sc =3D (struct vether_softc *)xsc) !=3D NULL) { + + if ((ifp =3D sc->sc_ifp) !=3D NULL) { + ifp->if_drv_flags |=3D IFF_DRV_RUNNING; + ifp->if_drv_flags &=3D ~IFF_DRV_OACTIVE; + } + } +} + +static void +vether_stop(struct ifnet *ifp) +{ + if (ifp !=3D NULL) + ifp->if_drv_flags &=3D ~(IFF_DRV_RUNNING|IFF_DRV_OACTIVE); +} + +static int +vether_ioctl(struct ifnet *ifp, u_long req, caddr_t argp) +{ + struct vether_softc *sc; + struct ifreq *ifr; + int error; + + if (ifp !=3D NULL) { + + if ((sc =3D ifp->if_softc) !=3D NULL) { + ifr =3D (struct ifreq *)argp; + + switch (req) { + case SIOCSIFMTU: + if (ifr->ifr_mtu < ETHER_MAX_LEN_JUMBO) { + ifp->if_mtu =3D ifr->ifr_mtu; + error =3D 0; + } else + error =3D EINVAL; + break; + case SIOCSIFMEDIA: /* Media types can't be changed. */ + case SIOCGIFMEDIA: + error =3D ifmedia_ioctl(ifp, ifr, &sc->sc_ifm, req); + break; + case SIOCSIFFLAGS: + case SIOCADDMULTI: + case SIOCDELMULTI: + error =3D 0; + break; + case SIOCSIFPHYS: + error =3D EOPNOTSUPP; + break; + default: + error =3D ether_ioctl(ifp, req, argp); + break; + } + } else + error =3D ENXIO; + } else + error =3D ENOTTY; + + return (error); +} + Therefore, a new patch - see attachement: diff --git a/net/vether-kmod/Makefile b/net/vether-kmod/Makefile index 51dc96828b5b..17b999ded5ea 100644 --- a/net/vether-kmod/Makefile +++ b/net/vether-kmod/Makefile @@ -1,8 +1,8 @@ PORTNAME=3D vether-kmod -DISTVERSION=3D g20190422 +DISTVERSION=3D g20220208 CATEGORIES=3D net -MAINTAINER=3D henning.matyschok@outlook.com +MAINTAINER=3D secnavpa.fct@navy.mil COMMENT=3D Virtual Ethernet Interface LICENSE=3D BSD2CLAUSE ISCL @@ -11,9 +11,9 @@ LICENSE_COMB=3D multi USES=3D kmod uidfix USE_GITHUB=3D yes -GH_ACCOUNT=3D hmatyschok +GH_ACCOUNT=3D marforeur GH_PROJECT=3D if_vether -GH_TAGNAME=3D ecc91f865218f2bb85521b285c8f7f81198aa553 +GH_TAGNAME=3D 3a4426134448f0216fc92cd6eeaa2804ae8b118a PLIST_FILES=3D ${KMODDIR}/if_vether.ko \ man/man4/if_vether.4.gz \ diff --git a/net/vether-kmod/distinfo b/net/vether-kmod/distinfo index 4d14d86a02bc..95a2d2a17520 100644 --- a/net/vether-kmod/distinfo +++ b/net/vether-kmod/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP =3D 1555928075 -SHA256 (hmatyschok-if_vether-g20190422-ecc91f865218f2bb85521b285c8f7f81198aa553_GH= 0.tar.gz) =3D 85b4280715707734bac06cf8d950a11b6cd6f4ff8a2b61c684e16c86f92f5f7d -SIZE (hmatyschok-if_vether-g20190422-ecc91f865218f2bb85521b285c8f7f81198aa553_GH= 0.tar.gz) =3D 7015 +TIMESTAMP =3D 1644300411 +SHA256 (marforeur-if_vether-g20220208-3a4426134448f0216fc92cd6eeaa2804ae8b118a_GH0= .tar.gz) =3D 83de2a7be38529679fcddc8f1f394c30fa4776f76b43fdbbdc3b40949367ac30 +SIZE (marforeur-if_vether-g20220208-3a4426134448f0216fc92cd6eeaa2804ae8b118a_GH0= .tar.gz) =3D 8653 Would you commit those changes, upstream, to head. Henning Andersen Matyschok, 120179M11214, United States Marine Corps, Unit= ed States Air Force Facility, Wasserlooser Weg 5 Flensburg 24944 Germany --=20 You are receiving this mail because: You are the assignee for the bug.=