• Home
  • Raw
  • Download

Lines Matching refs:route

292 	struct rtnl_route *route = (struct rtnl_route *) obj;  in route_dump_stats()  local
296 if (route->ce_mask & ROUTE_ATTR_CACHEINFO) { in route_dump_stats()
297 struct rtnl_rtcacheinfo *ci = &route->rt_cacheinfo; in route_dump_stats()
310 struct rtnl_route *route = (struct rtnl_route *) obj; in route_keygen() local
324 if (route->rt_dst) in route_keygen()
325 addr = route->rt_dst; in route_keygen()
336 rkey->rt_family = route->rt_family; in route_keygen()
337 rkey->rt_tos = route->rt_tos; in route_keygen()
338 rkey->rt_table = route->rt_table; in route_keygen()
339 rkey->rt_prio = route->rt_prio; in route_keygen()
347 "hash 0x%x\n", route, rkey->rt_family, rkey->rt_tos, in route_keygen()
358 struct rtnl_route *route = (struct rtnl_route *)obj; in route_id_attrs_get() local
363 if (route->rt_family == AF_MPLS) in route_id_attrs_get()
610 void rtnl_route_get(struct rtnl_route *route) in rtnl_route_get() argument
612 nl_object_get((struct nl_object *) route); in rtnl_route_get()
615 void rtnl_route_put(struct rtnl_route *route) in rtnl_route_put() argument
617 nl_object_put((struct nl_object *) route); in rtnl_route_put()
627 void rtnl_route_set_table(struct rtnl_route *route, uint32_t table) in rtnl_route_set_table() argument
629 route->rt_table = table; in rtnl_route_set_table()
630 route->ce_mask |= ROUTE_ATTR_TABLE; in rtnl_route_set_table()
633 uint32_t rtnl_route_get_table(struct rtnl_route *route) in rtnl_route_get_table() argument
635 return route->rt_table; in rtnl_route_get_table()
638 void rtnl_route_set_scope(struct rtnl_route *route, uint8_t scope) in rtnl_route_set_scope() argument
640 route->rt_scope = scope; in rtnl_route_set_scope()
641 route->ce_mask |= ROUTE_ATTR_SCOPE; in rtnl_route_set_scope()
644 uint8_t rtnl_route_get_scope(struct rtnl_route *route) in rtnl_route_get_scope() argument
646 return route->rt_scope; in rtnl_route_get_scope()
649 void rtnl_route_set_tos(struct rtnl_route *route, uint8_t tos) in rtnl_route_set_tos() argument
651 route->rt_tos = tos; in rtnl_route_set_tos()
652 route->ce_mask |= ROUTE_ATTR_TOS; in rtnl_route_set_tos()
655 uint8_t rtnl_route_get_tos(struct rtnl_route *route) in rtnl_route_get_tos() argument
657 return route->rt_tos; in rtnl_route_get_tos()
660 void rtnl_route_set_protocol(struct rtnl_route *route, uint8_t protocol) in rtnl_route_set_protocol() argument
662 route->rt_protocol = protocol; in rtnl_route_set_protocol()
663 route->ce_mask |= ROUTE_ATTR_PROTOCOL; in rtnl_route_set_protocol()
666 uint8_t rtnl_route_get_protocol(struct rtnl_route *route) in rtnl_route_get_protocol() argument
668 return route->rt_protocol; in rtnl_route_get_protocol()
671 void rtnl_route_set_priority(struct rtnl_route *route, uint32_t prio) in rtnl_route_set_priority() argument
673 route->rt_prio = prio; in rtnl_route_set_priority()
674 route->ce_mask |= ROUTE_ATTR_PRIO; in rtnl_route_set_priority()
677 uint32_t rtnl_route_get_priority(struct rtnl_route *route) in rtnl_route_get_priority() argument
679 return route->rt_prio; in rtnl_route_get_priority()
682 int rtnl_route_set_family(struct rtnl_route *route, uint8_t family) in rtnl_route_set_family() argument
689 route->rt_family = family; in rtnl_route_set_family()
690 route->ce_mask |= ROUTE_ATTR_FAMILY; in rtnl_route_set_family()
697 uint8_t rtnl_route_get_family(struct rtnl_route *route) in rtnl_route_get_family() argument
699 return route->rt_family; in rtnl_route_get_family()
702 int rtnl_route_set_dst(struct rtnl_route *route, struct nl_addr *addr) in rtnl_route_set_dst() argument
704 if (route->ce_mask & ROUTE_ATTR_FAMILY) { in rtnl_route_set_dst()
705 if (addr->a_family != route->rt_family) in rtnl_route_set_dst()
708 route->rt_family = addr->a_family; in rtnl_route_set_dst()
710 if (route->rt_dst) in rtnl_route_set_dst()
711 nl_addr_put(route->rt_dst); in rtnl_route_set_dst()
714 route->rt_dst = addr; in rtnl_route_set_dst()
716 route->ce_mask |= (ROUTE_ATTR_DST | ROUTE_ATTR_FAMILY); in rtnl_route_set_dst()
721 struct nl_addr *rtnl_route_get_dst(struct rtnl_route *route) in rtnl_route_get_dst() argument
723 return route->rt_dst; in rtnl_route_get_dst()
726 int rtnl_route_set_src(struct rtnl_route *route, struct nl_addr *addr) in rtnl_route_set_src() argument
731 if (route->ce_mask & ROUTE_ATTR_FAMILY) { in rtnl_route_set_src()
732 if (addr->a_family != route->rt_family) in rtnl_route_set_src()
735 route->rt_family = addr->a_family; in rtnl_route_set_src()
737 if (route->rt_src) in rtnl_route_set_src()
738 nl_addr_put(route->rt_src); in rtnl_route_set_src()
741 route->rt_src = addr; in rtnl_route_set_src()
742 route->ce_mask |= (ROUTE_ATTR_SRC | ROUTE_ATTR_FAMILY); in rtnl_route_set_src()
747 struct nl_addr *rtnl_route_get_src(struct rtnl_route *route) in rtnl_route_get_src() argument
749 return route->rt_src; in rtnl_route_get_src()
752 int rtnl_route_set_type(struct rtnl_route *route, uint8_t type) in rtnl_route_set_type() argument
757 route->rt_type = type; in rtnl_route_set_type()
758 route->ce_mask |= ROUTE_ATTR_TYPE; in rtnl_route_set_type()
763 uint8_t rtnl_route_get_type(struct rtnl_route *route) in rtnl_route_get_type() argument
765 return route->rt_type; in rtnl_route_get_type()
768 void rtnl_route_set_flags(struct rtnl_route *route, uint32_t flags) in rtnl_route_set_flags() argument
770 route->rt_flag_mask |= flags; in rtnl_route_set_flags()
771 route->rt_flags |= flags; in rtnl_route_set_flags()
772 route->ce_mask |= ROUTE_ATTR_FLAGS; in rtnl_route_set_flags()
775 void rtnl_route_unset_flags(struct rtnl_route *route, uint32_t flags) in rtnl_route_unset_flags() argument
777 route->rt_flag_mask |= flags; in rtnl_route_unset_flags()
778 route->rt_flags &= ~flags; in rtnl_route_unset_flags()
779 route->ce_mask |= ROUTE_ATTR_FLAGS; in rtnl_route_unset_flags()
782 uint32_t rtnl_route_get_flags(struct rtnl_route *route) in rtnl_route_get_flags() argument
784 return route->rt_flags; in rtnl_route_get_flags()
787 int rtnl_route_set_metric(struct rtnl_route *route, int metric, uint32_t value) in rtnl_route_set_metric() argument
792 route->rt_metrics[metric - 1] = value; in rtnl_route_set_metric()
794 if (!(route->rt_metrics_mask & (1 << (metric - 1)))) { in rtnl_route_set_metric()
795 route->rt_nmetrics++; in rtnl_route_set_metric()
796 route->rt_metrics_mask |= (1 << (metric - 1)); in rtnl_route_set_metric()
799 route->ce_mask |= ROUTE_ATTR_METRICS; in rtnl_route_set_metric()
804 int rtnl_route_unset_metric(struct rtnl_route *route, int metric) in rtnl_route_unset_metric() argument
809 if (route->rt_metrics_mask & (1 << (metric - 1))) { in rtnl_route_unset_metric()
810 route->rt_nmetrics--; in rtnl_route_unset_metric()
811 route->rt_metrics_mask &= ~(1 << (metric - 1)); in rtnl_route_unset_metric()
817 int rtnl_route_get_metric(struct rtnl_route *route, int metric, uint32_t *value) in rtnl_route_get_metric() argument
822 if (!(route->rt_metrics_mask & (1 << (metric - 1)))) in rtnl_route_get_metric()
826 *value = route->rt_metrics[metric - 1]; in rtnl_route_get_metric()
831 int rtnl_route_set_pref_src(struct rtnl_route *route, struct nl_addr *addr) in rtnl_route_set_pref_src() argument
833 if (route->ce_mask & ROUTE_ATTR_FAMILY) { in rtnl_route_set_pref_src()
834 if (addr->a_family != route->rt_family) in rtnl_route_set_pref_src()
837 route->rt_family = addr->a_family; in rtnl_route_set_pref_src()
839 if (route->rt_pref_src) in rtnl_route_set_pref_src()
840 nl_addr_put(route->rt_pref_src); in rtnl_route_set_pref_src()
843 route->rt_pref_src = addr; in rtnl_route_set_pref_src()
844 route->ce_mask |= (ROUTE_ATTR_PREF_SRC | ROUTE_ATTR_FAMILY); in rtnl_route_set_pref_src()
849 struct nl_addr *rtnl_route_get_pref_src(struct rtnl_route *route) in rtnl_route_get_pref_src() argument
851 return route->rt_pref_src; in rtnl_route_get_pref_src()
854 void rtnl_route_set_iif(struct rtnl_route *route, int ifindex) in rtnl_route_set_iif() argument
856 route->rt_iif = ifindex; in rtnl_route_set_iif()
857 route->ce_mask |= ROUTE_ATTR_IIF; in rtnl_route_set_iif()
860 int rtnl_route_get_iif(struct rtnl_route *route) in rtnl_route_get_iif() argument
862 return route->rt_iif; in rtnl_route_get_iif()
865 void rtnl_route_add_nexthop(struct rtnl_route *route, struct rtnl_nexthop *nh) in rtnl_route_add_nexthop() argument
867 nl_list_add_tail(&nh->rtnh_list, &route->rt_nexthops); in rtnl_route_add_nexthop()
868 route->rt_nr_nh++; in rtnl_route_add_nexthop()
869 route->ce_mask |= ROUTE_ATTR_MULTIPATH; in rtnl_route_add_nexthop()
872 void rtnl_route_remove_nexthop(struct rtnl_route *route, struct rtnl_nexthop *nh) in rtnl_route_remove_nexthop() argument
874 if (route->ce_mask & ROUTE_ATTR_MULTIPATH) { in rtnl_route_remove_nexthop()
875 route->rt_nr_nh--; in rtnl_route_remove_nexthop()
880 struct nl_list_head *rtnl_route_get_nexthops(struct rtnl_route *route) in rtnl_route_get_nexthops() argument
882 if (route->ce_mask & ROUTE_ATTR_MULTIPATH) in rtnl_route_get_nexthops()
883 return &route->rt_nexthops; in rtnl_route_get_nexthops()
888 int rtnl_route_get_nnexthops(struct rtnl_route *route) in rtnl_route_get_nnexthops() argument
890 if (route->ce_mask & ROUTE_ATTR_MULTIPATH) in rtnl_route_get_nnexthops()
891 return route->rt_nr_nh; in rtnl_route_get_nnexthops()
924 void rtnl_route_set_ttl_propagate(struct rtnl_route *route, uint8_t ttl_prop) in rtnl_route_set_ttl_propagate() argument
926 route->rt_ttl_propagate = ttl_prop; in rtnl_route_set_ttl_propagate()
927 route->ce_mask |= ROUTE_ATTR_TTL_PROPAGATE; in rtnl_route_set_ttl_propagate()
930 int rtnl_route_get_ttl_propagate(struct rtnl_route *route) in rtnl_route_get_ttl_propagate() argument
932 if (!route) in rtnl_route_get_ttl_propagate()
934 if (!(route->ce_mask & ROUTE_ATTR_TTL_PROPAGATE)) in rtnl_route_get_ttl_propagate()
936 return route->rt_ttl_propagate; in rtnl_route_get_ttl_propagate()
959 int rtnl_route_guess_scope(struct rtnl_route *route) in rtnl_route_guess_scope() argument
961 if (route->rt_type == RTN_LOCAL) in rtnl_route_guess_scope()
964 if (route->rt_family == AF_MPLS) in rtnl_route_guess_scope()
967 if (!nl_list_empty(&route->rt_nexthops)) { in rtnl_route_guess_scope()
974 nl_list_for_each_entry(nh, &route->rt_nexthops, rtnh_list) { in rtnl_route_guess_scope()
1023 static int parse_multipath(struct rtnl_route *route, struct nlattr *attr) in parse_multipath() argument
1053 route->rt_family); in parse_multipath()
1074 route->rt_family); in parse_multipath()
1106 rtnl_route_add_nexthop(route, nh); in parse_multipath()
1122 struct rtnl_route *route; in rtnl_route_parse() local
1128 route = rtnl_route_alloc(); in rtnl_route_parse()
1129 if (!route) in rtnl_route_parse()
1132 route->ce_msgtype = nlh->nlmsg_type; in rtnl_route_parse()
1139 route->rt_family = family = rtm->rtm_family; in rtnl_route_parse()
1140 route->rt_tos = rtm->rtm_tos; in rtnl_route_parse()
1141 route->rt_table = rtm->rtm_table; in rtnl_route_parse()
1142 route->rt_type = rtm->rtm_type; in rtnl_route_parse()
1143 route->rt_scope = rtm->rtm_scope; in rtnl_route_parse()
1144 route->rt_protocol = rtm->rtm_protocol; in rtnl_route_parse()
1145 route->rt_flags = rtm->rtm_flags; in rtnl_route_parse()
1146 route->rt_prio = 0; in rtnl_route_parse()
1148 route->ce_mask |= ROUTE_ATTR_FAMILY | ROUTE_ATTR_TOS | in rtnl_route_parse()
1157 route->ce_mask |= ROUTE_ATTR_PRIO; in rtnl_route_parse()
1169 err = rtnl_route_set_dst(route, dst); in rtnl_route_parse()
1184 rtnl_route_set_src(route, src); in rtnl_route_parse()
1189 rtnl_route_set_table(route, nla_get_u32(tb[RTA_TABLE])); in rtnl_route_parse()
1192 rtnl_route_set_iif(route, nla_get_u32(tb[RTA_IIF])); in rtnl_route_parse()
1195 rtnl_route_set_priority(route, nla_get_u32(tb[RTA_PRIORITY])); in rtnl_route_parse()
1200 rtnl_route_set_pref_src(route, addr); in rtnl_route_parse()
1216 err = rtnl_route_set_metric(route, i, m); in rtnl_route_parse()
1224 if ((err = parse_multipath(route, tb[RTA_MULTIPATH])) < 0) in rtnl_route_parse()
1228 nla_memcpy(&route->rt_cacheinfo, tb[RTA_CACHEINFO], in rtnl_route_parse()
1229 sizeof(route->rt_cacheinfo)); in rtnl_route_parse()
1230 route->ce_mask |= ROUTE_ATTR_CACHEINFO; in rtnl_route_parse()
1264 addr = nl_addr_alloc_attr(tb[RTA_NEWDST], route->rt_family); in rtnl_route_parse()
1292 rtnl_route_set_ttl_propagate(route, in rtnl_route_parse()
1308 if (route->rt_nr_nh == 0) { in rtnl_route_parse()
1312 rtnl_route_add_nexthop(route, old_nh); in rtnl_route_parse()
1318 first = nl_list_first_entry(&route->rt_nexthops, in rtnl_route_parse()
1335 *result = route; in rtnl_route_parse()
1341 rtnl_route_put(route); in rtnl_route_parse()
1349 int rtnl_route_build_msg(struct nl_msg *msg, struct rtnl_route *route) in rtnl_route_build_msg() argument
1354 .rtm_family = route->rt_family, in rtnl_route_build_msg()
1355 .rtm_tos = route->rt_tos, in rtnl_route_build_msg()
1356 .rtm_table = route->rt_table, in rtnl_route_build_msg()
1357 .rtm_protocol = route->rt_protocol, in rtnl_route_build_msg()
1358 .rtm_scope = route->rt_scope, in rtnl_route_build_msg()
1359 .rtm_type = route->rt_type, in rtnl_route_build_msg()
1360 .rtm_flags = route->rt_flags, in rtnl_route_build_msg()
1363 if (route->rt_dst == NULL) in rtnl_route_build_msg()
1366 rtmsg.rtm_dst_len = nl_addr_get_prefixlen(route->rt_dst); in rtnl_route_build_msg()
1367 if (route->rt_src) in rtnl_route_build_msg()
1368 rtmsg.rtm_src_len = nl_addr_get_prefixlen(route->rt_src); in rtnl_route_build_msg()
1370 if (!(route->ce_mask & ROUTE_ATTR_SCOPE)) in rtnl_route_build_msg()
1371 rtmsg.rtm_scope = rtnl_route_guess_scope(route); in rtnl_route_build_msg()
1373 if (rtnl_route_get_nnexthops(route) == 1) { in rtnl_route_build_msg()
1375 nh = rtnl_route_nexthop_n(route, 0); in rtnl_route_build_msg()
1386 if (route->rt_family != AF_MPLS) in rtnl_route_build_msg()
1387 NLA_PUT_U32(msg, RTA_TABLE, route->rt_table); in rtnl_route_build_msg()
1389 if (nl_addr_get_len(route->rt_dst)) in rtnl_route_build_msg()
1390 NLA_PUT_ADDR(msg, RTA_DST, route->rt_dst); in rtnl_route_build_msg()
1392 if (route->ce_mask & ROUTE_ATTR_PRIO) in rtnl_route_build_msg()
1393 NLA_PUT_U32(msg, RTA_PRIORITY, route->rt_prio); in rtnl_route_build_msg()
1395 if (route->ce_mask & ROUTE_ATTR_SRC) in rtnl_route_build_msg()
1396 NLA_PUT_ADDR(msg, RTA_SRC, route->rt_src); in rtnl_route_build_msg()
1398 if (route->ce_mask & ROUTE_ATTR_PREF_SRC) in rtnl_route_build_msg()
1399 NLA_PUT_ADDR(msg, RTA_PREFSRC, route->rt_pref_src); in rtnl_route_build_msg()
1401 if (route->ce_mask & ROUTE_ATTR_IIF) in rtnl_route_build_msg()
1402 NLA_PUT_U32(msg, RTA_IIF, route->rt_iif); in rtnl_route_build_msg()
1404 if (route->ce_mask & ROUTE_ATTR_TTL_PROPAGATE) in rtnl_route_build_msg()
1405 NLA_PUT_U8(msg, RTA_TTL_PROPAGATE, route->rt_ttl_propagate); in rtnl_route_build_msg()
1407 if (route->rt_nmetrics > 0) { in rtnl_route_build_msg()
1415 if (!rtnl_route_get_metric(route, i, &val)) in rtnl_route_build_msg()
1422 if (rtnl_route_get_nnexthops(route) == 1) { in rtnl_route_build_msg()
1425 nh = rtnl_route_nexthop_n(route, 0); in rtnl_route_build_msg()
1439 } else if (rtnl_route_get_nnexthops(route) > 1) { in rtnl_route_build_msg()
1446 nl_list_for_each_entry(nh, &route->rt_nexthops, rtnh_list) { in rtnl_route_build_msg()