]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Add IFCAP_LINKSTATE support.
authorhrs <hrs@FreeBSD.org>
Sat, 3 Oct 2015 09:15:23 +0000 (09:15 +0000)
committerhrs <hrs@FreeBSD.org>
Sat, 3 Oct 2015 09:15:23 +0000 (09:15 +0000)
sys/net/if_gif.c
sys/net/if_gre.c
sys/net/if_me.c

index 5903abd1ab209d60bfa0876c799f56ef7f585441..33d583c9686a34fe86a866ad1dd21fff2422fb95 100644 (file)
@@ -197,6 +197,8 @@ gif_clone_create(struct if_clone *ifc, int unit, caddr_t params)
        GIF2IFP(sc)->if_transmit  = gif_transmit;
        GIF2IFP(sc)->if_qflush  = gif_qflush;
        GIF2IFP(sc)->if_output = gif_output;
+       GIF2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE;
+       GIF2IFP(sc)->if_capenable |= IFCAP_LINKSTATE;
        if_attach(GIF2IFP(sc));
        bpfattach(GIF2IFP(sc), DLT_NULL, sizeof(u_int32_t));
        if (ng_gif_attach_p != NULL)
@@ -1040,10 +1042,13 @@ gif_set_tunnel(struct ifnet *ifp, struct sockaddr *src, struct sockaddr *dst)
 #if defined(INET) || defined(INET6)
 bad:
 #endif
-       if (error == 0 && sc->gif_family != 0)
+       if (error == 0 && sc->gif_family != 0) {
                ifp->if_drv_flags |= IFF_DRV_RUNNING;
-       else
+               if_link_state_change(ifp, LINK_STATE_UP);
+       } else {
                ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+               if_link_state_change(ifp, LINK_STATE_DOWN);
+       }
        return (error);
 }
 
@@ -1065,4 +1070,5 @@ gif_delete_tunnel(struct ifnet *ifp)
                free(sc->gif_hdr, M_GIF);
        }
        ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+       if_link_state_change(ifp, LINK_STATE_DOWN);
 }
index 71addf5a100cf1886fc0a4493b8a8a426ad1aaf3..ffd94d831b080df22f7d9cdc4719f195554d3892 100644 (file)
@@ -179,6 +179,8 @@ gre_clone_create(struct if_clone *ifc, int unit, caddr_t params)
        GRE2IFP(sc)->if_ioctl = gre_ioctl;
        GRE2IFP(sc)->if_transmit = gre_transmit;
        GRE2IFP(sc)->if_qflush = gre_qflush;
+       GRE2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE;
+       GRE2IFP(sc)->if_capenable |= IFCAP_LINKSTATE;
        if_attach(GRE2IFP(sc));
        bpfattach(GRE2IFP(sc), DLT_NULL, sizeof(u_int32_t));
        GRE_LIST_LOCK();
@@ -648,8 +650,10 @@ gre_set_tunnel(struct ifnet *ifp, struct sockaddr *src,
                break;
 #endif
        }
-       if (error == 0)
+       if (error == 0) {
                ifp->if_drv_flags |= IFF_DRV_RUNNING;
+               if_link_state_change(ifp, LINK_STATE_UP);
+       }
        return (error);
 }
 
@@ -668,6 +672,7 @@ gre_delete_tunnel(struct ifnet *ifp)
                free(sc->gre_hdr, M_GRE);
        }
        ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+       if_link_state_change(ifp, LINK_STATE_DOWN);
 }
 
 int
index ff79713b256806b71fdb9d6532c3863470477862..7a092223aceb8f0a9226f3b75319fe8d5f8953a5 100644 (file)
@@ -192,6 +192,8 @@ me_clone_create(struct if_clone *ifc, int unit, caddr_t params)
        ME2IFP(sc)->if_ioctl = me_ioctl;
        ME2IFP(sc)->if_transmit = me_transmit;
        ME2IFP(sc)->if_qflush = me_qflush;
+       ME2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE;
+       ME2IFP(sc)->if_capenable |= IFCAP_LINKSTATE;
        if_attach(ME2IFP(sc));
        bpfattach(ME2IFP(sc), DLT_NULL, sizeof(u_int32_t));
        ME_LIST_LOCK();
@@ -376,8 +378,10 @@ me_set_tunnel(struct ifnet *ifp, struct sockaddr_in *src,
        if (sc->me_ecookie == NULL)
                sc->me_ecookie = encap_attach_func(AF_INET, IPPROTO_MOBILE,
                    me_encapcheck, &in_mobile_protosw, sc);
-       if (sc->me_ecookie != NULL)
+       if (sc->me_ecookie != NULL) {
                ifp->if_drv_flags |= IFF_DRV_RUNNING;
+               if_link_state_change(ifp, LINK_STATE_UP);
+       }
        return (0);
 }
 
@@ -395,6 +399,7 @@ me_delete_tunnel(struct ifnet *ifp)
        sc->me_dst.s_addr = 0;
        ME_WUNLOCK(sc);
        ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+       if_link_state_change(ifp, LINK_STATE_DOWN);
 }
 
 static uint16_t