Handle a ref counted flag that should be set on the lagg port as well */
| 1945 | |
| 1946 | /* Handle a ref counted flag that should be set on the lagg port as well */ |
| 1947 | static int |
| 1948 | lagg_setflag(struct lagg_port *lp, int flag, int status, |
| 1949 | int (*func)(struct ifnet *, int)) |
| 1950 | { |
| 1951 | struct lagg_softc *sc = lp->lp_softc; |
| 1952 | struct ifnet *scifp = sc->sc_ifp; |
| 1953 | struct ifnet *ifp = lp->lp_ifp; |
| 1954 | int error; |
| 1955 | |
| 1956 | LAGG_XLOCK_ASSERT(sc); |
| 1957 | |
| 1958 | status = status ? (scifp->if_flags & flag) : 0; |
| 1959 | /* Now "status" contains the flag value or 0 */ |
| 1960 | |
| 1961 | /* |
| 1962 | * See if recorded ports status is different from what |
| 1963 | * we want it to be. If it is, flip it. We record ports |
| 1964 | * status in lp_ifflags so that we won't clear ports flag |
| 1965 | * we haven't set. In fact, we don't clear or set ports |
| 1966 | * flags directly, but get or release references to them. |
| 1967 | * That's why we can be sure that recorded flags still are |
| 1968 | * in accord with actual ports flags. |
| 1969 | */ |
| 1970 | if (status != (lp->lp_ifflags & flag)) { |
| 1971 | error = (*func)(ifp, status); |
| 1972 | if (error) |
| 1973 | return (error); |
| 1974 | lp->lp_ifflags &= ~flag; |
| 1975 | lp->lp_ifflags |= status; |
| 1976 | } |
| 1977 | return (0); |
| 1978 | } |
| 1979 | |
| 1980 | /* |
| 1981 | * Handle IFF_* flags that require certain changes on the lagg port |