sys/net: Add dom_if_up and dom_if_down
authorRoy Marples <roy@marples.name>
Tue, 10 Sep 2019 11:09:20 +0000 (12:09 +0100)
committerRoy Marples <roy@marples.name>
Tue, 10 Sep 2019 11:09:20 +0000 (12:09 +0100)
Domain functions for when the interface goes up and down.

sys/net/if.c
sys/sys/domain.h

index b3d8cfb..862d816 100644 (file)
@@ -1662,6 +1662,7 @@ if_unroute_dispatch(netmsg_t nmsg)
        struct ifnet *ifp = msg->ifp;
        int flag = msg->flag, fam = msg->fam;
        struct ifaddr_container *ifac;
+       struct domain *dp;
 
        ASSERT_NETISR0;
 
@@ -1686,6 +1687,10 @@ if_unroute_dispatch(netmsg_t nmsg)
                        kpfctlinput(PRC_IFDOWN, ifa->ifa_addr);
        }
 
+       SLIST_FOREACH(dp, &domains, dom_next)
+               if (dp->dom_if_down != NULL)
+                       dp->dom_if_down(ifp);
+
        ifq_purge_all(&ifp->if_snd);
        netisr_replymsg(&nmsg->base, 0);
 }
@@ -1713,6 +1718,7 @@ if_route_dispatch(netmsg_t nmsg)
        struct ifnet *ifp = msg->ifp;
        int flag = msg->flag, fam = msg->fam;
        struct ifaddr_container *ifac;
+       struct domain *dp;
 
        ASSERT_NETISR0;
 
@@ -1737,6 +1743,10 @@ if_route_dispatch(netmsg_t nmsg)
                if (fam == PF_UNSPEC || (fam == ifa->ifa_addr->sa_family))
                        kpfctlinput(PRC_IFUP, ifa->ifa_addr);
        }
+
+       SLIST_FOREACH(dp, &domains, dom_next)
+               if (dp->dom_if_up != NULL)
+                       dp->dom_if_up(ifp);
 #ifdef INET6
        in6_if_up(ifp);
 #endif
index 776c7db..7976e49 100644 (file)
@@ -64,6 +64,8 @@ struct        domain {
        int     dom_maxrtkey;           /* for routing layer */
        void    *(*dom_ifattach)(struct ifnet *);
        void    (*dom_ifdetach)(struct ifnet *, void *);
+       void    (*dom_if_up)(struct ifnet *);
+       void    (*dom_if_down)(struct ifnet *);
                                        /* af-dependent data on ifnet */
 };