| 1138 | } |
| 1139 | |
| 1140 | static int |
| 1141 | bridge_ioctl_add(struct bridge_softc *sc, void *arg) |
| 1142 | { |
| 1143 | struct ifbreq *req = arg; |
| 1144 | struct bridge_iflist *bif = NULL; |
| 1145 | struct ifnet *ifs; |
| 1146 | int error = 0; |
| 1147 | |
| 1148 | ifs = ifunit(req->ifbr_ifsname); |
| 1149 | if (ifs == NULL) |
| 1150 | return (ENOENT); |
| 1151 | if (ifs->if_ioctl == NULL) /* must be supported */ |
| 1152 | return (EINVAL); |
| 1153 | |
| 1154 | /* If it's in the span list, it can't be a member. */ |
| 1155 | CK_LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) |
| 1156 | if (ifs == bif->bif_ifp) |
| 1157 | return (EBUSY); |
| 1158 | |
| 1159 | if (ifs->if_bridge == sc) |
| 1160 | return (EEXIST); |
| 1161 | |
| 1162 | if (ifs->if_bridge != NULL) |
| 1163 | return (EBUSY); |
| 1164 | |
| 1165 | switch (ifs->if_type) { |
| 1166 | case IFT_ETHER: |
| 1167 | case IFT_L2VLAN: |
| 1168 | case IFT_GIF: |
| 1169 | /* permitted interface types */ |
| 1170 | break; |
| 1171 | default: |
| 1172 | return (EINVAL); |
| 1173 | } |
| 1174 | |
| 1175 | #ifdef INET6 |
| 1176 | /* |
| 1177 | * Two valid inet6 addresses with link-local scope must not be |
| 1178 | * on the parent interface and the member interfaces at the |
| 1179 | * same time. This restriction is needed to prevent violation |
| 1180 | * of link-local scope zone. Attempts to add a member |
| 1181 | * interface which has inet6 addresses when the parent has |
| 1182 | * inet6 triggers removal of all inet6 addresses on the member |
| 1183 | * interface. |
| 1184 | */ |
| 1185 | |
| 1186 | /* Check if the parent interface has a link-local scope addr. */ |
| 1187 | if (V_allow_llz_overlap == 0 && |
| 1188 | in6ifa_llaonifp(sc->sc_ifp) != NULL) { |
| 1189 | /* |
| 1190 | * If any, remove all inet6 addresses from the member |
| 1191 | * interfaces. |
| 1192 | */ |
| 1193 | CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { |
| 1194 | if (in6ifa_llaonifp(bif->bif_ifp)) { |
| 1195 | in6_ifdetach(bif->bif_ifp); |
| 1196 | if_printf(sc->sc_ifp, |
| 1197 | "IPv6 addresses on %s have been removed " |
nothing calls this directly
no test coverage detected