Lines Matching refs:ifp

229 static void	tunrename(void *arg, struct ifnet *ifp);
245 static void tun_vnethdr_set(struct ifnet *ifp, int vhdrlen);
654 tun_clone_destroy(struct if_clone *ifc __unused, struct ifnet *ifp, uint32_t flags) in tun_clone_destroy() argument
656 struct tuntap_softc *tp = ifp->if_softc; in tun_clone_destroy()
721 tuntap_driver_from_ifnet(const struct ifnet *ifp) in tuntap_driver_from_ifnet() argument
726 if (ifp == NULL) in tuntap_driver_from_ifnet()
731 if (strcmp(ifp->if_dname, drv->cdevsw.d_name) == 0) in tuntap_driver_from_ifnet()
857 tunstart(struct ifnet *ifp) in tunstart() argument
859 struct tuntap_softc *tp = ifp->if_softc; in tunstart()
862 TUNDEBUG(ifp, "starting\n"); in tunstart()
863 if (ALTQ_IS_ENABLED(&ifp->if_snd)) { in tunstart()
864 IFQ_LOCK(&ifp->if_snd); in tunstart()
865 IFQ_POLL_NOLOCK(&ifp->if_snd, m); in tunstart()
867 IFQ_UNLOCK(&ifp->if_snd); in tunstart()
870 IFQ_UNLOCK(&ifp->if_snd); in tunstart()
893 tunstart_l2(struct ifnet *ifp) in tunstart_l2() argument
895 struct tuntap_softc *tp = ifp->if_softc; in tunstart_l2()
897 TUNDEBUG(ifp, "starting\n"); in tunstart_l2()
910 TUNDEBUG(ifp, "not ready, tun_flags = 0x%x\n", tp->tun_flags); in tunstart_l2()
913 IF_DEQUEUE(&ifp->if_snd, m); in tunstart_l2()
916 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); in tunstart_l2()
925 ifp->if_drv_flags |= IFF_DRV_OACTIVE; in tunstart_l2()
927 if (!IFQ_IS_EMPTY(&ifp->if_snd)) { in tunstart_l2()
941 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* obytes are counted in ether_output */ in tunstart_l2()
944 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; in tunstart_l2()
949 tap_transmit(struct ifnet *ifp, struct mbuf *m) in tap_transmit() argument
953 BPF_MTAP(ifp, m); in tap_transmit()
954 IFQ_HANDOFF(ifp, m, error); in tap_transmit()
963 struct ifnet *ifp; in tuncreate() local
981 ifp = tp->tun_ifp = if_alloc(type); in tuncreate()
982 ifp->if_softc = tp; in tuncreate()
983 if_initname(ifp, drv->cdevsw.d_name, dev2unit(dev)); in tuncreate()
984 ifp->if_ioctl = tunifioctl; in tuncreate()
985 ifp->if_flags = iflags; in tuncreate()
986 IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); in tuncreate()
987 ifp->if_capabilities |= IFCAP_LINKSTATE | IFCAP_MEXTPG; in tuncreate()
989 ifp->if_capabilities |= in tuncreate()
991 ifp->if_capenable |= IFCAP_LINKSTATE | IFCAP_MEXTPG; in tuncreate()
994 ifp->if_init = tunifinit; in tuncreate()
995 ifp->if_start = tunstart_l2; in tuncreate()
996 ifp->if_transmit = tap_transmit; in tuncreate()
997 ifp->if_qflush = if_qflush; in tuncreate()
999 ether_gen_addr(ifp, &eaddr); in tuncreate()
1000 ether_ifattach(ifp, eaddr.octet); in tuncreate()
1002 ifp->if_mtu = TUNMTU; in tuncreate()
1003 ifp->if_start = tunstart; in tuncreate()
1004 ifp->if_output = tunoutput; in tuncreate()
1006 ifp->if_snd.ifq_drv_maxlen = 0; in tuncreate()
1007 IFQ_SET_READY(&ifp->if_snd); in tuncreate()
1009 if_attach(ifp); in tuncreate()
1010 bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); in tuncreate()
1017 TUNDEBUG(ifp, "interface %s is created, minor = %#x\n", in tuncreate()
1018 ifp->if_xname, dev2unit(dev)); in tuncreate()
1022 tunrename(void *arg __unused, struct ifnet *ifp) in tunrename() argument
1027 if ((ifp->if_flags & IFF_RENAMING) == 0) in tunrename()
1030 if (tuntap_driver_from_ifnet(ifp) == NULL) in tunrename()
1042 tp = ifp->if_softc; in tunrename()
1056 if (strcmp(ifp->if_xname, tp->tun_dev->si_name) == 0) in tunrename()
1067 ifp->if_xname); in tunrename()
1075 struct ifnet *ifp; in tunopen() local
1105 ifp = TUN2IFP(tp); in tunopen()
1108 bcopy(IF_LLADDR(ifp), tp->tun_ether.octet, in tunopen()
1111 ifp->if_drv_flags |= IFF_DRV_RUNNING; in tunopen()
1112 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; in tunopen()
1115 ifp->if_flags |= IFF_UP; in tunopen()
1121 if_link_state_change(ifp, LINK_STATE_UP); in tunopen()
1122 TUNDEBUG(ifp, "open\n"); in tunopen()
1146 struct ifnet *ifp; in tundtor() local
1151 ifp = TUN2IFP(tp); in tundtor()
1172 CURVNET_SET(ifp->if_vnet); in tundtor()
1177 IF_DRAIN(&ifp->if_snd); in tundtor()
1179 IFQ_PURGE(&ifp->if_snd); in tundtor()
1184 (l2tun && (ifp->if_flags & IFF_LINK0) != 0)) in tundtor()
1188 TUNDEBUG (ifp, "LRO disabled\n"); in tundtor()
1193 if (ifp->if_flags & IFF_UP) { in tundtor()
1195 if_down(ifp); in tundtor()
1200 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { in tundtor()
1201 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; in tundtor()
1203 if_purgeaddrs(ifp); in tundtor()
1208 if_link_state_change(ifp, LINK_STATE_DOWN); in tundtor()
1214 TUNDEBUG (ifp, "closed\n"); in tundtor()
1217 tun_vnethdr_set(ifp, 0); in tundtor()
1224 tuninit(struct ifnet *ifp) in tuninit() argument
1226 struct tuntap_softc *tp = ifp->if_softc; in tuninit()
1228 TUNDEBUG(ifp, "tuninit\n"); in tuninit()
1231 ifp->if_drv_flags |= IFF_DRV_RUNNING; in tuninit()
1233 ifp->if_flags |= IFF_UP; in tuninit()
1234 getmicrotime(&ifp->if_lastchange); in tuninit()
1239 TUNDEBUG(ifp, "LRO enabled\n"); in tuninit()
1240 tp->tun_lro.ifp = ifp; in tuninit()
1243 TUNDEBUG(ifp, "Could not enable LRO\n"); in tuninit()
1247 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; in tuninit()
1250 tunstart_l2(ifp); in tuninit()
1272 tun_caps_changed(struct ifnet *ifp) in tun_caps_changed() argument
1276 TUN_LOCK_ASSERT((struct tuntap_softc *)ifp->if_softc); in tun_caps_changed()
1277 if (ifp->if_capenable & IFCAP_TXCSUM) in tun_caps_changed()
1279 if (ifp->if_capenable & IFCAP_TXCSUM_IPV6) in tun_caps_changed()
1282 if (ifp->if_capenable & IFCAP_TSO4) in tun_caps_changed()
1284 if (ifp->if_capenable & IFCAP_TSO6) in tun_caps_changed()
1286 ifp->if_hwassist = hwassist; in tun_caps_changed()
1294 tun_vnethdr_set(struct ifnet *ifp, int vhdrlen) in tun_vnethdr_set() argument
1296 struct tuntap_softc *tp = ifp->if_softc; in tun_vnethdr_set()
1309 ifp->if_capabilities |= in tun_vnethdr_set()
1312 ifp->if_capabilities &= in tun_vnethdr_set()
1318 ifp->if_capenable &= ifp->if_capabilities; in tun_vnethdr_set()
1319 tun_caps_changed(ifp); in tun_vnethdr_set()
1322 TUNDEBUG(ifp, "vnet_hdr_len=%d, if_capabilities=%x\n", in tun_vnethdr_set()
1323 vhdrlen, ifp->if_capabilities); in tun_vnethdr_set()
1330 tunifioctl(struct ifnet *ifp, u_long cmd, caddr_t data) in tunifioctl() argument
1341 tp = ifp->if_softc; in tunifioctl()
1360 error = ether_ioctl(ifp, cmd, data); in tunifioctl()
1362 tuninit(ifp); in tunifioctl()
1364 TUNDEBUG(ifp, "address set\n"); in tunifioctl()
1367 ifp->if_mtu = ifr->ifr_mtu; in tunifioctl()
1368 TUNDEBUG(ifp, "mtu set\n"); in tunifioctl()
1395 ifp->if_capenable = ifr->ifr_reqcap; in tunifioctl()
1396 tun_caps_changed(ifp); in tunifioctl()
1398 VLAN_CAPABILITIES(ifp); in tunifioctl()
1402 error = ether_ioctl(ifp, cmd, data); in tunifioctl()
1416 tunoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, in tunoutput() argument
1419 struct tuntap_softc *tp = ifp->if_softc; in tunoutput()
1424 TUNDEBUG (ifp, "tunoutput\n"); in tunoutput()
1427 error = mac_ifnet_check_transmit(ifp, m0); in tunoutput()
1439 TUNDEBUG (ifp, "not ready 0%o\n", tp->tun_flags); in tunoutput()
1444 if ((ifp->if_flags & IFF_UP) != IFF_UP) { in tunoutput()
1455 BPF_MTAP2(ifp, &af, sizeof(af), m0); in tunoutput()
1464 if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); in tunoutput()
1465 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); in tunoutput()
1478 if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); in tunoutput()
1479 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); in tunoutput()
1493 error = (ifp->if_transmit)(ifp, m0); in tunoutput()
1496 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); in tunoutput()
1509 struct ifnet *ifp = TUN2IFP(tp); in tunioctl() local
1533 ifp->if_flags = iflags | in tunioctl()
1534 (ifp->if_flags & IFF_CANTCHANGE); in tunioctl()
1560 tun_vnethdr_set(ifp, ival); in tunioctl()
1722 struct ifnet *ifp = TUN2IFP(tp); in tunread() local
1727 TUNDEBUG (ifp, "read\n"); in tunread()
1731 TUNDEBUG (ifp, "not ready 0%o\n", tp->tun_flags); in tunread()
1738 IFQ_DEQUEUE(&ifp->if_snd, m); in tunread()
1761 m = virtio_net_tx_offload(ifp, m, false, &vhdr.hdr); in tunread()
1764 TUNDEBUG(ifp, "txvhdr: f %u, gt %u, hl %u, " in tunread()
1783 struct ifnet *ifp; in tunwrite_l2() local
1785 ifp = TUN2IFP(tp); in tunwrite_l2()
1798 if ((ifp->if_flags & IFF_PROMISC) == 0 && in tunwrite_l2()
1800 bcmp(eh->ether_dhost, IF_LLADDR(ifp), ETHER_ADDR_LEN) != 0) { in tunwrite_l2()
1814 if (ifp->if_capenable & IFCAP_RXCSUM) { in tunwrite_l2()
1825 if (ifp->if_capenable & IFCAP_RXCSUM_IPV6) { in tunwrite_l2()
1837 CURVNET_SET(ifp->if_vnet); in tunwrite_l2()
1840 if (tp->tun_lro_ready && ifp->if_capenable & IFCAP_LRO && in tunwrite_l2()
1845 (*ifp->if_input)(ifp, m); in tunwrite_l2()
1849 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); in tunwrite_l2()
1857 struct ifnet *ifp; in tunwrite_l3() local
1860 ifp = TUN2IFP(tp); in tunwrite_l3()
1875 BPF_MTAP2(ifp, &family, sizeof(family), m); in tunwrite_l3()
1893 if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); in tunwrite_l3()
1894 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); in tunwrite_l3()
1895 CURVNET_SET(ifp->if_vnet); in tunwrite_l3()
1896 M_SETFIB(m, ifp->if_fib); in tunwrite_l3()
1912 struct ifnet *ifp; in tunwrite() local
1919 ifp = TUN2IFP(tp); in tunwrite()
1920 TUNDEBUG(ifp, "tunwrite\n"); in tunwrite()
1921 if ((ifp->if_flags & IFF_UP) != IFF_UP) in tunwrite()
1938 TUNDEBUG(ifp, "len=%zd!\n", uio->uio_resid); in tunwrite()
1946 TUNDEBUG(ifp, "txvhdr: f %u, gt %u, hl %u, " in tunwrite()
1954 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); in tunwrite()
1958 m->m_pkthdr.rcvif = ifp; in tunwrite()
1960 mac_ifnet_create_mbuf(ifp, m); in tunwrite()
1978 struct ifnet *ifp = TUN2IFP(tp); in tunpoll() local
1981 TUNDEBUG(ifp, "tunpoll\n"); in tunpoll()
1984 IFQ_LOCK(&ifp->if_snd); in tunpoll()
1985 if (!IFQ_IS_EMPTY(&ifp->if_snd)) { in tunpoll()
1986 TUNDEBUG(ifp, "tunpoll q=%d\n", ifp->if_snd.ifq_len); in tunpoll()
1989 TUNDEBUG(ifp, "tunpoll waiting\n"); in tunpoll()
1992 IFQ_UNLOCK(&ifp->if_snd); in tunpoll()
2006 struct ifnet *ifp = TUN2IFP(tp); in tunkqfilter() local
2010 TUNDEBUG(ifp, "%s kqfilter: EVFILT_READ, minor = %#x\n", in tunkqfilter()
2011 ifp->if_xname, dev2unit(dev)); in tunkqfilter()
2016 TUNDEBUG(ifp, "%s kqfilter: EVFILT_WRITE, minor = %#x\n", in tunkqfilter()
2017 ifp->if_xname, dev2unit(dev)); in tunkqfilter()
2022 TUNDEBUG(ifp, "%s kqfilter: invalid filter, minor = %#x\n", in tunkqfilter()
2023 ifp->if_xname, dev2unit(dev)); in tunkqfilter()
2042 struct ifnet *ifp = TUN2IFP(tp); in tunkqread() local
2044 if ((kn->kn_data = ifp->if_snd.ifq_len) > 0) { in tunkqread()
2045 TUNDEBUG(ifp, in tunkqread()
2047 ifp->if_xname, ifp->if_snd.ifq_len, dev2unit(dev)); in tunkqread()
2050 TUNDEBUG(ifp, in tunkqread()
2051 "%s waiting for data, minor = %#x\n", ifp->if_xname, in tunkqread()
2066 struct ifnet *ifp = TUN2IFP(tp); in tunkqwrite() local
2068 kn->kn_data = ifp->if_mtu; in tunkqwrite()