| 855 | } |
| 856 | |
| 857 | static void |
| 858 | if_attach_internal(struct ifnet *ifp, int vmove, struct if_clone *ifc) |
| 859 | { |
| 860 | unsigned socksize, ifasize; |
| 861 | int namelen, masklen; |
| 862 | struct sockaddr_dl *sdl; |
| 863 | struct ifaddr *ifa; |
| 864 | |
| 865 | if (ifp->if_index == 0 || ifp != ifnet_byindex(ifp->if_index)) |
| 866 | panic ("%s: BUG: if_attach called without if_alloc'd input()\n", |
| 867 | ifp->if_xname); |
| 868 | |
| 869 | #ifdef VIMAGE |
| 870 | ifp->if_vnet = curvnet; |
| 871 | if (ifp->if_home_vnet == NULL) |
| 872 | ifp->if_home_vnet = curvnet; |
| 873 | #endif |
| 874 | |
| 875 | if_addgroup(ifp, IFG_ALL); |
| 876 | |
| 877 | /* Restore group membership for cloned interfaces. */ |
| 878 | if (vmove && ifc != NULL) |
| 879 | if_clone_addgroup(ifp, ifc); |
| 880 | |
| 881 | getmicrotime(&ifp->if_lastchange); |
| 882 | ifp->if_epoch = time_uptime; |
| 883 | |
| 884 | KASSERT((ifp->if_transmit == NULL && ifp->if_qflush == NULL) || |
| 885 | (ifp->if_transmit != NULL && ifp->if_qflush != NULL), |
| 886 | ("transmit and qflush must both either be set or both be NULL")); |
| 887 | if (ifp->if_transmit == NULL) { |
| 888 | ifp->if_transmit = if_transmit; |
| 889 | ifp->if_qflush = if_qflush; |
| 890 | } |
| 891 | if (ifp->if_input == NULL) |
| 892 | ifp->if_input = if_input_default; |
| 893 | |
| 894 | if (ifp->if_requestencap == NULL) |
| 895 | ifp->if_requestencap = if_requestencap_default; |
| 896 | |
| 897 | if (!vmove) { |
| 898 | #ifdef MAC |
| 899 | mac_ifnet_create(ifp); |
| 900 | #endif |
| 901 | |
| 902 | /* |
| 903 | * Create a Link Level name for this device. |
| 904 | */ |
| 905 | namelen = strlen(ifp->if_xname); |
| 906 | /* |
| 907 | * Always save enough space for any possiable name so we |
| 908 | * can do a rename in place later. |
| 909 | */ |
| 910 | masklen = offsetof(struct sockaddr_dl, sdl_data[0]) + IFNAMSIZ; |
| 911 | socksize = masklen + ifp->if_addrlen; |
| 912 | if (socksize < sizeof(*sdl)) |
| 913 | socksize = sizeof(*sdl); |
| 914 | socksize = roundup2(socksize, sizeof(long)); |
no test coverage detected