From owner-svn-src-head@freebsd.org Sat Dec 2 22:04:01 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EA0BDE6AFFC; Sat, 2 Dec 2017 22:04:01 +0000 (UTC) (envelope-from bryanv@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C450A7F264; Sat, 2 Dec 2017 22:04:01 +0000 (UTC) (envelope-from bryanv@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vB2M40Es085044; Sat, 2 Dec 2017 22:04:00 GMT (envelope-from bryanv@FreeBSD.org) Received: (from bryanv@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vB2M403K085043; Sat, 2 Dec 2017 22:04:00 GMT (envelope-from bryanv@FreeBSD.org) Message-Id: <201712022204.vB2M403K085043@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bryanv set sender to bryanv@FreeBSD.org using -f From: Bryan Venteicher Date: Sat, 2 Dec 2017 22:04:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326480 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: bryanv X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 326480 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Dec 2017 22:04:02 -0000 Author: bryanv Date: Sat Dec 2 22:04:00 2017 New Revision: 326480 URL: https://svnweb.freebsd.org/changeset/base/326480 Log: Add if media and link status events to vxlan PR: 214359 MFC after: 2 weeks Modified: head/sys/net/if_vxlan.c Modified: head/sys/net/if_vxlan.c ============================================================================== --- head/sys/net/if_vxlan.c Sat Dec 2 19:42:08 2017 (r326479) +++ head/sys/net/if_vxlan.c Sat Dec 2 22:04:00 2017 (r326480) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -177,6 +178,7 @@ struct vxlan_softc { uint8_t vxl_hwaddr[ETHER_ADDR_LEN]; int vxl_mc_ifindex; struct ifnet *vxl_mc_ifp; + struct ifmedia vxl_media; char vxl_mc_ifname[IFNAMSIZ]; LIST_ENTRY(vxlan_softc) vxl_entry; LIST_ENTRY(vxlan_softc) vxl_ifdetach_list; @@ -342,6 +344,8 @@ static void vxlan_clone_destroy(struct ifnet *); static uint32_t vxlan_mac_hash(struct vxlan_softc *, const uint8_t *); static void vxlan_fakeaddr(struct vxlan_softc *); +static int vxlan_media_change(struct ifnet *); +static void vxlan_media_status(struct ifnet *, struct ifmediareq *); static int vxlan_sockaddr_cmp(const union vxlan_sockaddr *, const struct sockaddr *); @@ -1655,6 +1659,7 @@ vxlan_init(void *xsc) vxlan_timer, sc); VXLAN_WUNLOCK(sc); + if_link_state_change(ifp, LINK_STATE_UP); out: vxlan_init_complete(sc); } @@ -1710,6 +1715,7 @@ vxlan_teardown_locked(struct vxlan_softc *sc) sc->vxl_sock = NULL; VXLAN_WUNLOCK(sc); + if_link_state_change(ifp, LINK_STATE_DOWN); if (vso != NULL) { vxlan_socket_remove_softc(vso, sc); @@ -2219,6 +2225,12 @@ vxlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t dat case SIOCSIFFLAGS: error = vxlan_ioctl_ifflags(sc); break; + + case SIOCSIFMEDIA: + case SIOCGIFMEDIA: + error = ifmedia_ioctl(ifp, ifr, &sc->vxl_media, cmd); + break; + default: error = ether_ioctl(ifp, cmd, data); break; @@ -2685,6 +2697,10 @@ vxlan_clone_create(struct if_clone *ifc, int unit, cad ifp->if_transmit = vxlan_transmit; ifp->if_qflush = vxlan_qflush; + ifmedia_init(&sc->vxl_media, 0, vxlan_media_change, vxlan_media_status); + ifmedia_add(&sc->vxl_media, IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(&sc->vxl_media, IFM_ETHER | IFM_AUTO); + vxlan_fakeaddr(sc); ether_ifattach(ifp, sc->vxl_hwaddr); @@ -2711,6 +2727,7 @@ vxlan_clone_destroy(struct ifnet *ifp) ether_ifdetach(ifp); if_free(ifp); + ifmedia_removeall(&sc->vxl_media); vxlan_ftable_fini(sc); @@ -2768,6 +2785,22 @@ vxlan_fakeaddr(struct vxlan_softc *sc) arc4rand(sc->vxl_hwaddr, ETHER_ADDR_LEN, 1); sc->vxl_hwaddr[0] &= ~1; sc->vxl_hwaddr[0] |= 2; +} + +static int +vxlan_media_change(struct ifnet *ifp) +{ + + /* Ignore. */ + return (0); +} + +static void +vxlan_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) +{ + + ifmr->ifm_status = IFM_ACTIVE | IFM_AVALID; + ifmr->ifm_active = IFM_ETHER | IFM_FDX; } static int