MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rip_ctlinput

Function rip_ctlinput

freebsd/netinet/raw_ip.c:811–878  ·  view source on GitHub ↗

* This function exists solely to receive the PRC_IFDOWN messages which are * sent by if_down(). It looks for an ifaddr whose ifa_addr is sa, and calls * in_ifadown() to remove all routes corresponding to that address. It also * receives the PRC_IFUP messages from if_up() and reinstalls the interface * routes. */

Source from the content-addressed store, hash-verified

809 * routes.
810 */
811void
812rip_ctlinput(int cmd, struct sockaddr *sa, void *vip)
813{
814 struct rm_priotracker in_ifa_tracker;
815 struct in_ifaddr *ia;
816 struct ifnet *ifp;
817 int err;
818 int flags;
819
820 switch (cmd) {
821 case PRC_IFDOWN:
822 IN_IFADDR_RLOCK(&in_ifa_tracker);
823 CK_STAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) {
824 if (ia->ia_ifa.ifa_addr == sa
825 && (ia->ia_flags & IFA_ROUTE)) {
826 ifa_ref(&ia->ia_ifa);
827 IN_IFADDR_RUNLOCK(&in_ifa_tracker);
828 /*
829 * in_scrubprefix() kills the interface route.
830 */
831 in_scrubprefix(ia, 0);
832 /*
833 * in_ifadown gets rid of all the rest of the
834 * routes. This is not quite the right thing
835 * to do, but at least if we are running a
836 * routing process they will come back.
837 */
838 in_ifadown(&ia->ia_ifa, 0);
839 ifa_free(&ia->ia_ifa);
840 break;
841 }
842 }
843 if (ia == NULL) /* If ia matched, already unlocked. */
844 IN_IFADDR_RUNLOCK(&in_ifa_tracker);
845 break;
846
847 case PRC_IFUP:
848 IN_IFADDR_RLOCK(&in_ifa_tracker);
849 CK_STAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) {
850 if (ia->ia_ifa.ifa_addr == sa)
851 break;
852 }
853 if (ia == NULL || (ia->ia_flags & IFA_ROUTE)) {
854 IN_IFADDR_RUNLOCK(&in_ifa_tracker);
855 return;
856 }
857 ifa_ref(&ia->ia_ifa);
858 IN_IFADDR_RUNLOCK(&in_ifa_tracker);
859 flags = RTF_UP;
860 ifp = ia->ia_ifa.ifa_ifp;
861
862 if ((ifp->if_flags & IFF_LOOPBACK)
863 || (ifp->if_flags & IFF_POINTOPOINT))
864 flags |= RTF_HOST;
865
866 err = ifa_del_loopback_route((struct ifaddr *)ia, sa);
867
868 rt_addrmsg(RTM_ADD, &ia->ia_ifa, ia->ia_ifp->if_fib);

Callers

nothing calls this directly

Calls 8

ifa_refFunction · 0.85
in_scrubprefixFunction · 0.85
in_ifadownFunction · 0.85
ifa_freeFunction · 0.85
ifa_del_loopback_routeFunction · 0.85
rt_addrmsgFunction · 0.85
in_handle_ifaddr_routeFunction · 0.85
ifa_add_loopback_routeFunction · 0.85

Tested by

no test coverage detected