* tunstart_l2 * * queue packets from higher level ready to put out */
| 869 | * queue packets from higher level ready to put out |
| 870 | */ |
| 871 | static void |
| 872 | tunstart_l2(struct ifnet *ifp) |
| 873 | { |
| 874 | struct tuntap_softc *tp = ifp->if_softc; |
| 875 | |
| 876 | TUNDEBUG(ifp, "starting\n"); |
| 877 | |
| 878 | /* |
| 879 | * do not junk pending output if we are in VMnet mode. |
| 880 | * XXX: can this do any harm because of queue overflow? |
| 881 | */ |
| 882 | |
| 883 | TUN_LOCK(tp); |
| 884 | if (((tp->tun_flags & TUN_VMNET) == 0) && |
| 885 | ((tp->tun_flags & TUN_READY) != TUN_READY)) { |
| 886 | struct mbuf *m; |
| 887 | |
| 888 | /* Unlocked read. */ |
| 889 | TUNDEBUG(ifp, "not ready, tun_flags = 0x%x\n", tp->tun_flags); |
| 890 | |
| 891 | for (;;) { |
| 892 | IF_DEQUEUE(&ifp->if_snd, m); |
| 893 | if (m != NULL) { |
| 894 | m_freem(m); |
| 895 | if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
| 896 | } else |
| 897 | break; |
| 898 | } |
| 899 | TUN_UNLOCK(tp); |
| 900 | |
| 901 | return; |
| 902 | } |
| 903 | |
| 904 | ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
| 905 | |
| 906 | if (!IFQ_IS_EMPTY(&ifp->if_snd)) { |
| 907 | if (tp->tun_flags & TUN_RWAIT) { |
| 908 | tp->tun_flags &= ~TUN_RWAIT; |
| 909 | wakeup(tp); |
| 910 | } |
| 911 | |
| 912 | if ((tp->tun_flags & TUN_ASYNC) && (tp->tun_sigio != NULL)) { |
| 913 | TUN_UNLOCK(tp); |
| 914 | pgsigio(&tp->tun_sigio, SIGIO, 0); |
| 915 | TUN_LOCK(tp); |
| 916 | } |
| 917 | |
| 918 | selwakeuppri(&tp->tun_rsel, PZERO+1); |
| 919 | KNOTE_LOCKED(&tp->tun_rsel.si_note, 0); |
| 920 | if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* obytes are counted in ether_output */ |
| 921 | } |
| 922 | |
| 923 | ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
| 924 | TUN_UNLOCK(tp); |
| 925 | } /* tunstart_l2 */ |
| 926 | |
| 927 | /* XXX: should return an error code so it can fail. */ |
| 928 | static void |
no test coverage detected