Lines Matching defs:route

81 #include <net/route.h>
144 * gets inserted into the list when the route is created and gets
161 * as the route entry itself. When a route is deleted (RTM_DELETE),
163 * freed until the route itself is freed.
505 * Instead of issuing RTM_DELETE, stop this route entry
507 * the route is later reused, arp_validate() will revert
517 * rt_setgate() on this route.
603 * XXX: If this is a manually added route to interface
612 * Case 1: This route should come from a route to iface.
647 break; /* This happens on a route change */
649 * Case 2: This route may come from cloning, or a manual route
720 * remove the route to force traffic out to the
735 * Adjust route ref count for the
755 * Unchain it but defer the actual freeing until the route
758 * route entry, except that RTF_LLINFO is now cleared.
803 * arp_lookup_route will lookup the route for a given address.
806 * If the returned route is non-NULL, the route is locked and the caller
811 route_t *route, unsigned int ifscope)
818 *route = NULL;
843 why = "gateway route is not ours";
856 * If there are no references to this route, and it is
857 * a cloned route, and not static, and ARP had created
858 * the route, then purge it from the routing table as
867 * dropped by marking the route as defunct.
884 *route = rt;
890 * the "hint" route never gets freed via rtfree(), since the caller may
891 * have stored it inside a struct route with a reference held for that
899 route_t route = NULL; /* output route */
913 * If we were given a route, verify the route and grab the gateway
917 * Callee holds a reference on the route and returns
918 * with the route entry locked, upon success.
921 net_dest, hint, &route);
924 if (route != NULL)
925 RT_LOCK_ASSERT_HELD(route);
942 if (route != NULL)
943 RT_UNLOCK(route);
947 if (route != NULL)
948 RT_LOCK(route);
953 * If we didn't find a route, or the route doesn't have
955 * route and link layer information.
957 if (route == NULL || route->rt_llinfo == NULL) {
959 if (route != NULL) {
960 if (route == hint) {
961 RT_REMREF_LOCKED(route);
962 RT_UNLOCK(route);
964 RT_UNLOCK(route);
965 rtfree(route);
969 * Callee holds a reference on the route and returns
970 * with the route entry locked, upon success.
972 result = arp_lookup_route(&net_dest->sin_addr, 1, 0, &route,
975 RT_LOCK_ASSERT_HELD(route);
978 if (result || route == NULL || (llinfo = route->rt_llinfo) == NULL) {
981 /* In case result is 0 but no route, return an error */
986 route != NULL && route->rt_llinfo == NULL)
994 * Now that we have the right route, is it filled in?
996 gateway = SDL(route->rt_gateway);
998 VERIFY(route->rt_expire == 0 || route->rt_rmx.rmx_expire != 0);
999 VERIFY(route->rt_expire != 0 || route->rt_rmx.rmx_expire == 0);
1000 if ((route->rt_expire == 0 ||
1001 route->rt_expire > timenow) && gateway != NULL &&
1029 if (route->rt_expire) {
1030 route->rt_flags &= ~RTF_REJECT;
1032 route->rt_expire != timenow) {
1033 rt_setexpire(route, timenow);
1035 struct ifaddr *rt_ifa = route->rt_ifa;
1040 RT_CONVERT_LOCK(route);
1052 rtflags = route->rt_flags;
1053 RT_UNLOCK(route);
1058 RT_LOCK(route);
1062 route->rt_flags |= RTF_REJECT;
1063 rt_setexpire(route, rt_expiry(route,
1064 route->rt_expire, arpt_down));
1082 if (route != NULL) {
1083 if (route == hint) {
1084 RT_REMREF_LOCKED(route);
1085 RT_UNLOCK(route);
1087 RT_UNLOCK(route);
1088 rtfree(route);
1109 route_t route = NULL;
1259 * Callee holds a reference on the route and returns with the route
1264 sender_ip->sin_addr.s_addr != 0), 0, &route, ifp->if_index);
1267 RT_LOCK_ASSERT_HELD(route);
1269 if (error || route == 0 || route->rt_gateway == 0) {
1282 if (route != NULL) {
1283 RT_REMREF_LOCKED(route);
1284 RT_UNLOCK(route);
1285 route = NULL;
1288 * Callee holds a reference on the route and returns
1289 * with the route entry locked, upon success.
1292 &route, ifp->if_index);
1295 RT_LOCK_ASSERT_HELD(route);
1297 if (error == 0 && route && route->rt_gateway) {
1298 gateway = SDL(route->rt_gateway);
1299 if (route->rt_ifp != ifp && gateway->sdl_alen != 0
1316 route->rt_ifp->if_name, route->rt_ifp->if_unit);
1323 if (route->rt_llinfo != NULL)
1324 arp_llreach_use(route->rt_llinfo);
1325 /* We're done with the route */
1326 RT_REMREF_LOCKED(route);
1327 RT_UNLOCK(route);
1328 route = NULL;
1355 if (route != NULL) {
1356 RT_REMREF_LOCKED(route);
1357 RT_UNLOCK(route);
1358 route = NULL;
1361 * Callee holds a reference on the route and
1362 * returns with the route entry locked, upon
1366 1, 0, &route, ifp->if_index);
1369 RT_LOCK_ASSERT_HELD(route);
1371 if (error == 0 && route != NULL && route->rt_gateway != NULL) {
1383 RT_LOCK_ASSERT_HELD(route);
1384 VERIFY(route->rt_expire == 0 || route->rt_rmx.rmx_expire != 0);
1385 VERIFY(route->rt_expire != 0 || route->rt_rmx.rmx_expire == 0);
1386 gateway = SDL(route->rt_gateway);
1387 if (!bridged && route->rt_ifp != ifp) {
1393 route->rt_ifp->if_name,
1394 route->rt_ifp->if_unit,
1401 if (route->rt_expire == 0) {
1406 * We're about to check and/or change the route's ifp
1410 * route, so it won't go away while we do this.
1412 RT_UNLOCK(route);
1414 RT_LOCK(route);
1416 * Don't change the cloned route away from the
1418 * or if the route is defunct. rt_ifp on both
1422 gateway = SDL(route->rt_gateway);
1423 if ((gateway->sdl_alen != 0 && route->rt_parent &&
1424 route->rt_parent->rt_ifp == route->rt_ifp) ||
1425 (route->rt_flags & RTF_CONDEMNED)) {
1426 RT_REMREF_LOCKED(route);
1427 RT_UNLOCK(route);
1428 route = NULL;
1432 if (route->rt_ifp != ifp) {
1436 if (route->rt_llinfo_purge != NULL)
1437 route->rt_llinfo_purge(route);
1439 /* Adjust route ref count for the interfaces */
1440 if (route->rt_if_ref_fn != NULL) {
1441 route->rt_if_ref_fn(ifp, 1);
1442 route->rt_if_ref_fn(route->rt_ifp, -1);
1445 /* Change the interface when the existing route is on */
1446 route->rt_ifp = ifp;
1447 rtsetifa(route, &best_ia->ia_ifa);
1449 RT_UNLOCK(route);
1451 RT_LOCK(route);
1452 /* Don't bother if the route is down */
1453 if (!(route->rt_flags & RTF_UP))
1456 gateway = SDL(route->rt_gateway);
1458 RT_LOCK_ASSERT_HELD(route);
1462 if (route->rt_expire && log_arp_warnings) {
1471 else if (route->rt_expire == 0) {
1485 /* Copy the sender hardware address in to the route's gateway address */
1489 /* Update the expire time for the route and clear the reject flag */
1490 if (route->rt_expire) {
1494 rt_setexpire(route,
1495 rt_expiry(route, timenow, arpt_keep));
1497 route->rt_flags &= ~RTF_REJECT;
1500 arp_llreach_alloc(route, ifp, LLADDR(gateway), gateway->sdl_alen,
1504 llinfo = route->rt_llinfo;
1511 RT_UNLOCK(route);
1512 dlil_output(ifp, PF_INET, m0, (caddr_t)route, rt_key(route), 0, NULL);
1513 RT_REMREF(route);
1514 route = NULL;
1518 if (route != NULL) {
1520 if (arpop == ARPOP_REQUEST && route->rt_llinfo != NULL)
1521 arp_llreach_use(route->rt_llinfo);
1522 RT_REMREF_LOCKED(route);
1523 RT_UNLOCK(route);
1524 route = NULL;
1533 * Find a proxy route; callee holds a reference on the
1534 * route and returns with the route entry locked, upon
1538 &route, ifp->if_index);
1541 RT_LOCK_ASSERT_HELD(route);
1548 if (route->rt_ifp != ifp &&
1549 (route->rt_ifp->if_bridge != ifp->if_bridge ||
1551 RT_REMREF_LOCKED(route);
1552 RT_UNLOCK(route);
1555 proxied = *SDL(route->rt_gateway);
1559 * We don't have a route entry indicating we should
1567 * See if we have a route to the target ip before
1570 route = rtalloc1_scoped((struct sockaddr *)
1572 if (!route)
1578 RT_LOCK(route);
1579 if (route->rt_ifp == ifp) {
1580 RT_UNLOCK(route);
1581 rtfree(route);
1586 if (route->rt_llinfo != NULL)
1587 arp_llreach_use(route->rt_llinfo);
1588 RT_REMREF_LOCKED(route);
1589 RT_UNLOCK(route);