Lines Matching +full:use +full:- +full:rtm

1 // SPDX-License-Identifier: GPL-2.0-or-later
58 return -ENOMEM; in fib4_rules_init()
64 hlist_add_head_rcu(&local_table->tb_hlist, in fib4_rules_init()
65 &net->ipv4.fib_table_hash[TABLE_LOCAL_INDEX]); in fib4_rules_init()
66 hlist_add_head_rcu(&main_table->tb_hlist, in fib4_rules_init()
67 &net->ipv4.fib_table_hash[TABLE_MAIN_INDEX]); in fib4_rules_init()
72 return -ENOMEM; in fib4_rules_init()
87 if (id == RT_TABLE_LOCAL && !net->ipv4.fib_has_custom_rules) in fib_new_table()
96 rcu_assign_pointer(net->ipv4.fib_main, tb); in fib_new_table()
99 rcu_assign_pointer(net->ipv4.fib_default, tb); in fib_new_table()
105 h = id & (FIB_TABLE_HASHSZ - 1); in fib_new_table()
106 hlist_add_head_rcu(&tb->tb_hlist, &net->ipv4.fib_table_hash[h]); in fib_new_table()
120 h = id & (FIB_TABLE_HASHSZ - 1); in fib_get_table()
122 head = &net->ipv4.fib_table_hash[h]; in fib_get_table()
125 if (tb->tb_id == id) in fib_get_table()
136 switch (new->tb_id) { in fib_replace_table()
138 rcu_assign_pointer(net->ipv4.fib_main, new); in fib_replace_table()
141 rcu_assign_pointer(net->ipv4.fib_default, new); in fib_replace_table()
149 hlist_replace_rcu(&old->tb_hlist, &new->tb_hlist); in fib_replace_table()
163 return -ENOMEM; in fib_unmerge()
190 struct hlist_head *head = &net->ipv4.fib_table_hash[h]; in fib_flush()
228 if (!dev || dev == nhc->nhc_dev) in __inet_dev_addr_type()
273 struct net_device *dev = skb->dev; in fib_compute_spec_dst()
281 if ((rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST | RTCF_LOCAL)) == in fib_compute_spec_dst()
283 return ip_hdr(skb)->daddr; in fib_compute_spec_dst()
290 if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) { in fib_compute_spec_dst()
295 .daddr = ip_hdr(skb)->saddr, in fib_compute_spec_dst()
296 .flowi4_tos = ip_hdr(skb)->tos & INET_DSCP_MASK, in fib_compute_spec_dst()
298 .flowi4_mark = vmark ? skb->mark : 0, in fib_compute_spec_dst()
306 return inet_select_addr(dev, ip_hdr(skb)->saddr, scope); in fib_compute_spec_dst()
313 if (unlikely(fi->nh)) { in fib_info_nh_uses_dev()
314 dev_match = nexthop_uses_dev(fi->nh, dev); in fib_info_nh_uses_dev()
328 if (fib_info_nhc(fi, 0)->nhc_dev == dev) in fib_info_nh_uses_dev()
337 * - (main) check, that source is valid i.e. not broadcast or our local
339 * - figure out what "logical" interface this packet arrived
341 * - check, that packet arrived from expected physical interface.
367 no_addr = idev->ifa_list == NULL; in __fib_validate_source()
369 fl4.flowi4_mark = IN_DEV_SRC_VMARK(idev) ? skb->mark : 0; in __fib_validate_source()
390 dev == net->loopback_dev); in __fib_validate_source()
392 ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_HOST; in __fib_validate_source()
399 fl4.flowi4_oif = dev->ifindex; in __fib_validate_source()
404 ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_HOST; in __fib_validate_source()
415 return -EINVAL; in __fib_validate_source()
417 return -EXDEV; in __fib_validate_source()
429 (dev->ifindex != oif || !IN_DEV_TX_REDIRECTS(idev))) { in fib_validate_source()
436 if (net->ipv4.fib_has_custom_local_routes || in fib_validate_source()
443 return -EINVAL; in fib_validate_source()
456 return ((struct sockaddr_in *) addr)->sin_addr.s_addr; in sk_extract_addr()
464 nla->nla_type = type; in put_rtax()
465 nla->nla_len = nla_attr_size(4); in put_rtax()
478 cfg->fc_nlinfo.nl_net = net; in rtentry_to_fib_config()
480 if (rt->rt_dst.sa_family != AF_INET) in rtentry_to_fib_config()
481 return -EAFNOSUPPORT; in rtentry_to_fib_config()
492 addr = sk_extract_addr(&rt->rt_dst); in rtentry_to_fib_config()
493 if (!(rt->rt_flags & RTF_HOST)) { in rtentry_to_fib_config()
494 __be32 mask = sk_extract_addr(&rt->rt_genmask); in rtentry_to_fib_config()
496 if (rt->rt_genmask.sa_family != AF_INET) { in rtentry_to_fib_config()
497 if (mask || rt->rt_genmask.sa_family) in rtentry_to_fib_config()
498 return -EAFNOSUPPORT; in rtentry_to_fib_config()
502 return -EINVAL; in rtentry_to_fib_config()
507 cfg->fc_dst_len = plen; in rtentry_to_fib_config()
508 cfg->fc_dst = addr; in rtentry_to_fib_config()
511 cfg->fc_nlflags = NLM_F_CREATE; in rtentry_to_fib_config()
512 cfg->fc_protocol = RTPROT_BOOT; in rtentry_to_fib_config()
515 if (rt->rt_metric) in rtentry_to_fib_config()
516 cfg->fc_priority = rt->rt_metric - 1; in rtentry_to_fib_config()
518 if (rt->rt_flags & RTF_REJECT) { in rtentry_to_fib_config()
519 cfg->fc_scope = RT_SCOPE_HOST; in rtentry_to_fib_config()
520 cfg->fc_type = RTN_UNREACHABLE; in rtentry_to_fib_config()
524 cfg->fc_scope = RT_SCOPE_NOWHERE; in rtentry_to_fib_config()
525 cfg->fc_type = RTN_UNICAST; in rtentry_to_fib_config()
527 if (rt->rt_dev) { in rtentry_to_fib_config()
532 if (copy_from_user(devname, rt->rt_dev, IFNAMSIZ-1)) in rtentry_to_fib_config()
533 return -EFAULT; in rtentry_to_fib_config()
535 devname[IFNAMSIZ-1] = 0; in rtentry_to_fib_config()
541 return -ENODEV; in rtentry_to_fib_config()
542 cfg->fc_oif = dev->ifindex; in rtentry_to_fib_config()
543 cfg->fc_table = l3mdev_fib_table(dev); in rtentry_to_fib_config()
550 return -ENODEV; in rtentry_to_fib_config()
556 if (strcmp(ifa->ifa_label, devname) == 0) in rtentry_to_fib_config()
562 return -ENODEV; in rtentry_to_fib_config()
563 cfg->fc_prefsrc = ifa->ifa_local; in rtentry_to_fib_config()
567 addr = sk_extract_addr(&rt->rt_gateway); in rtentry_to_fib_config()
568 if (rt->rt_gateway.sa_family == AF_INET && addr) { in rtentry_to_fib_config()
571 cfg->fc_gw4 = addr; in rtentry_to_fib_config()
572 cfg->fc_gw_family = AF_INET; in rtentry_to_fib_config()
573 addr_type = inet_addr_type_table(net, addr, cfg->fc_table); in rtentry_to_fib_config()
574 if (rt->rt_flags & RTF_GATEWAY && in rtentry_to_fib_config()
576 cfg->fc_scope = RT_SCOPE_UNIVERSE; in rtentry_to_fib_config()
579 if (!cfg->fc_table) in rtentry_to_fib_config()
580 cfg->fc_table = RT_TABLE_MAIN; in rtentry_to_fib_config()
585 if (rt->rt_flags & RTF_GATEWAY && !cfg->fc_gw_family) in rtentry_to_fib_config()
586 return -EINVAL; in rtentry_to_fib_config()
588 if (cfg->fc_scope == RT_SCOPE_NOWHERE) in rtentry_to_fib_config()
589 cfg->fc_scope = RT_SCOPE_LINK; in rtentry_to_fib_config()
591 if (rt->rt_flags & (RTF_MTU | RTF_WINDOW | RTF_IRTT)) { in rtentry_to_fib_config()
597 return -ENOMEM; in rtentry_to_fib_config()
599 if (rt->rt_flags & RTF_MTU) in rtentry_to_fib_config()
600 len = put_rtax(mx, len, RTAX_ADVMSS, rt->rt_mtu - 40); in rtentry_to_fib_config()
602 if (rt->rt_flags & RTF_WINDOW) in rtentry_to_fib_config()
603 len = put_rtax(mx, len, RTAX_WINDOW, rt->rt_window); in rtentry_to_fib_config()
605 if (rt->rt_flags & RTF_IRTT) in rtentry_to_fib_config()
606 len = put_rtax(mx, len, RTAX_RTT, rt->rt_irtt << 3); in rtentry_to_fib_config()
608 cfg->fc_mx = mx; in rtentry_to_fib_config()
609 cfg->fc_mx_len = len; in rtentry_to_fib_config()
627 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) in ip_rt_ioctl()
628 return -EPERM; in ip_rt_ioctl()
641 err = -ESRCH; in ip_rt_ioctl()
648 err = -ENOBUFS; in ip_rt_ioctl()
657 return -EINVAL; in ip_rt_ioctl()
691 return -EINVAL; in fib_gw_from_via()
695 alen = nla_len(nla) - offsetof(struct rtvia, rtvia_addr); in fib_gw_from_via()
697 switch (via->rtvia_family) { in fib_gw_from_via()
701 return -EINVAL; in fib_gw_from_via()
703 cfg->fc_gw_family = AF_INET; in fib_gw_from_via()
704 cfg->fc_gw4 = *((__be32 *)via->rtvia_addr); in fib_gw_from_via()
710 return -EINVAL; in fib_gw_from_via()
712 cfg->fc_gw_family = AF_INET6; in fib_gw_from_via()
713 cfg->fc_gw6 = *((struct in6_addr *)via->rtvia_addr); in fib_gw_from_via()
716 return -EINVAL; in fib_gw_from_via()
721 return -EINVAL; in fib_gw_from_via()
734 struct rtmsg *rtm; in rtm_to_fib_config() local
736 err = nlmsg_validate_deprecated(nlh, sizeof(*rtm), RTA_MAX, in rtm_to_fib_config()
743 rtm = nlmsg_data(nlh); in rtm_to_fib_config()
745 if (!inet_validate_dscp(rtm->rtm_tos)) { in rtm_to_fib_config()
748 err = -EINVAL; in rtm_to_fib_config()
751 cfg->fc_dscp = inet_dsfield_to_dscp(rtm->rtm_tos); in rtm_to_fib_config()
753 cfg->fc_dst_len = rtm->rtm_dst_len; in rtm_to_fib_config()
754 cfg->fc_table = rtm->rtm_table; in rtm_to_fib_config()
755 cfg->fc_protocol = rtm->rtm_protocol; in rtm_to_fib_config()
756 cfg->fc_scope = rtm->rtm_scope; in rtm_to_fib_config()
757 cfg->fc_type = rtm->rtm_type; in rtm_to_fib_config()
758 cfg->fc_flags = rtm->rtm_flags; in rtm_to_fib_config()
759 cfg->fc_nlflags = nlh->nlmsg_flags; in rtm_to_fib_config()
761 cfg->fc_nlinfo.portid = NETLINK_CB(skb).portid; in rtm_to_fib_config()
762 cfg->fc_nlinfo.nlh = nlh; in rtm_to_fib_config()
763 cfg->fc_nlinfo.nl_net = net; in rtm_to_fib_config()
765 if (cfg->fc_type > RTN_MAX) { in rtm_to_fib_config()
767 err = -EINVAL; in rtm_to_fib_config()
774 cfg->fc_dst = nla_get_be32(attr); in rtm_to_fib_config()
777 cfg->fc_oif = nla_get_u32(attr); in rtm_to_fib_config()
781 cfg->fc_gw4 = nla_get_be32(attr); in rtm_to_fib_config()
782 if (cfg->fc_gw4) in rtm_to_fib_config()
783 cfg->fc_gw_family = AF_INET; in rtm_to_fib_config()
792 cfg->fc_priority = nla_get_u32(attr); in rtm_to_fib_config()
795 cfg->fc_prefsrc = nla_get_be32(attr); in rtm_to_fib_config()
798 cfg->fc_mx = nla_data(attr); in rtm_to_fib_config()
799 cfg->fc_mx_len = nla_len(attr); in rtm_to_fib_config()
807 cfg->fc_mp = nla_data(attr); in rtm_to_fib_config()
808 cfg->fc_mp_len = nla_len(attr); in rtm_to_fib_config()
811 cfg->fc_flow = nla_get_u32(attr); in rtm_to_fib_config()
814 cfg->fc_table = nla_get_u32(attr); in rtm_to_fib_config()
817 cfg->fc_encap = attr; in rtm_to_fib_config()
820 cfg->fc_encap_type = nla_get_u16(attr); in rtm_to_fib_config()
821 err = lwtunnel_valid_encap_type(cfg->fc_encap_type, in rtm_to_fib_config()
827 cfg->fc_nh_id = nla_get_u32(attr); in rtm_to_fib_config()
832 if (cfg->fc_nh_id) { in rtm_to_fib_config()
833 if (cfg->fc_oif || cfg->fc_gw_family || in rtm_to_fib_config()
834 cfg->fc_encap || cfg->fc_mp) { in rtm_to_fib_config()
837 return -EINVAL; in rtm_to_fib_config()
844 return -EINVAL; in rtm_to_fib_config()
847 if (!cfg->fc_table) in rtm_to_fib_config()
848 cfg->fc_table = RT_TABLE_MAIN; in rtm_to_fib_config()
858 struct net *net = sock_net(skb->sk); in inet_rtm_delroute()
869 err = -EINVAL; in inet_rtm_delroute()
876 err = -ESRCH; in inet_rtm_delroute()
888 struct net *net = sock_net(skb->sk); in inet_rtm_newroute()
899 err = -ENOBUFS; in inet_rtm_newroute()
905 net->ipv4.fib_has_custom_local_routes = true; in inet_rtm_newroute()
914 struct netlink_ext_ack *extack = cb->extack; in ip_valid_fib_dump_req()
916 struct rtmsg *rtm; in ip_valid_fib_dump_req() local
919 if (filter->rtnl_held) in ip_valid_fib_dump_req()
922 if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) { in ip_valid_fib_dump_req()
924 return -EINVAL; in ip_valid_fib_dump_req()
927 rtm = nlmsg_data(nlh); in ip_valid_fib_dump_req()
928 if (rtm->rtm_dst_len || rtm->rtm_src_len || rtm->rtm_tos || in ip_valid_fib_dump_req()
929 rtm->rtm_scope) { in ip_valid_fib_dump_req()
931 return -EINVAL; in ip_valid_fib_dump_req()
934 if (rtm->rtm_flags & ~(RTM_F_CLONED | RTM_F_PREFIX)) { in ip_valid_fib_dump_req()
936 return -EINVAL; in ip_valid_fib_dump_req()
938 if (rtm->rtm_flags & RTM_F_CLONED) in ip_valid_fib_dump_req()
939 filter->dump_routes = false; in ip_valid_fib_dump_req()
941 filter->dump_exceptions = false; in ip_valid_fib_dump_req()
943 filter->flags = rtm->rtm_flags; in ip_valid_fib_dump_req()
944 filter->protocol = rtm->rtm_protocol; in ip_valid_fib_dump_req()
945 filter->rt_type = rtm->rtm_type; in ip_valid_fib_dump_req()
946 filter->table_id = rtm->rtm_table; in ip_valid_fib_dump_req()
948 err = nlmsg_parse_deprecated_strict(nlh, sizeof(*rtm), tb, RTA_MAX, in ip_valid_fib_dump_req()
961 filter->table_id = nla_get_u32(tb[i]); in ip_valid_fib_dump_req()
965 if (filter->rtnl_held) in ip_valid_fib_dump_req()
966 filter->dev = __dev_get_by_index(net, ifindex); in ip_valid_fib_dump_req()
968 filter->dev = dev_get_by_index_rcu(net, ifindex); in ip_valid_fib_dump_req()
969 if (!filter->dev) in ip_valid_fib_dump_req()
970 return -ENODEV; in ip_valid_fib_dump_req()
974 return -EINVAL; in ip_valid_fib_dump_req()
978 if (filter->flags || filter->protocol || filter->rt_type || in ip_valid_fib_dump_req()
979 filter->table_id || filter->dev) { in ip_valid_fib_dump_req()
980 filter->filter_set = 1; in ip_valid_fib_dump_req()
981 cb->answer_flags = NLM_F_DUMP_FILTERED; in ip_valid_fib_dump_req()
995 const struct nlmsghdr *nlh = cb->nlh; in inet_dump_fib()
996 struct net *net = sock_net(skb->sk); in inet_dump_fib()
1004 if (cb->strict_check) { in inet_dump_fib()
1009 struct rtmsg *rtm = nlmsg_data(nlh); in inet_dump_fib() local
1011 filter.flags = rtm->rtm_flags & (RTM_F_PREFIX | RTM_F_CLONED); in inet_dump_fib()
1014 /* ipv4 does not use prefix flag */ in inet_dump_fib()
1021 if (rtnl_msg_family(cb->nlh) != PF_INET) in inet_dump_fib()
1024 NL_SET_ERR_MSG(cb->extack, "ipv4: FIB table does not exist"); in inet_dump_fib()
1025 err = -ENOENT; in inet_dump_fib()
1032 s_h = cb->args[0]; in inet_dump_fib()
1033 s_e = cb->args[1]; in inet_dump_fib()
1038 head = &net->ipv4.fib_table_hash[h]; in inet_dump_fib()
1043 memset(&cb->args[2], 0, sizeof(cb->args) - in inet_dump_fib()
1044 2 * sizeof(cb->args[0])); in inet_dump_fib()
1055 cb->args[1] = e; in inet_dump_fib()
1056 cb->args[0] = h; in inet_dump_fib()
1063 /* Prepare and feed intra-kernel routing request.
1064 * Really, it should be netlink message, but :-( netlink
1072 struct net *net = dev_net(ifa->ifa_dev->dev); in fib_magic()
1073 u32 tb_id = l3mdev_fib_table(ifa->ifa_dev->dev); in fib_magic()
1081 .fc_prefsrc = ifa->ifa_local, in fib_magic()
1082 .fc_oif = ifa->ifa_dev->dev->ifindex, in fib_magic()
1096 cfg.fc_table = tb->tb_id; in fib_magic()
1111 struct in_device *in_dev = ifa->ifa_dev; in fib_add_ifaddr()
1112 struct net_device *dev = in_dev->dev; in fib_add_ifaddr()
1114 __be32 mask = ifa->ifa_mask; in fib_add_ifaddr()
1115 __be32 addr = ifa->ifa_local; in fib_add_ifaddr()
1116 __be32 prefix = ifa->ifa_address & mask; in fib_add_ifaddr()
1118 if (ifa->ifa_flags & IFA_F_SECONDARY) { in fib_add_ifaddr()
1128 if (!(dev->flags & IFF_UP)) in fib_add_ifaddr()
1132 if (ifa->ifa_broadcast && ifa->ifa_broadcast != htonl(0xFFFFFFFF)) { in fib_add_ifaddr()
1133 fib_magic(RTM_NEWROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, in fib_add_ifaddr()
1135 arp_invalidate(dev, ifa->ifa_broadcast, false); in fib_add_ifaddr()
1138 if (!ipv4_is_zeronet(prefix) && !(ifa->ifa_flags & IFA_F_SECONDARY) && in fib_add_ifaddr()
1139 (prefix != addr || ifa->ifa_prefixlen < 32)) { in fib_add_ifaddr()
1140 if (!(ifa->ifa_flags & IFA_F_NOPREFIXROUTE)) in fib_add_ifaddr()
1142 dev->flags & IFF_LOOPBACK ? RTN_LOCAL : RTN_UNICAST, in fib_add_ifaddr()
1143 prefix, ifa->ifa_prefixlen, prim, in fib_add_ifaddr()
1144 ifa->ifa_rt_priority); in fib_add_ifaddr()
1147 if (ifa->ifa_prefixlen < 31) { in fib_add_ifaddr()
1157 __be32 prefix = ifa->ifa_address & ifa->ifa_mask; in fib_modify_prefix_metric()
1158 struct in_device *in_dev = ifa->ifa_dev; in fib_modify_prefix_metric()
1159 struct net_device *dev = in_dev->dev; in fib_modify_prefix_metric()
1161 if (!(dev->flags & IFF_UP) || in fib_modify_prefix_metric()
1162 ifa->ifa_flags & (IFA_F_SECONDARY | IFA_F_NOPREFIXROUTE) || in fib_modify_prefix_metric()
1164 (prefix == ifa->ifa_local && ifa->ifa_prefixlen == 32)) in fib_modify_prefix_metric()
1169 dev->flags & IFF_LOOPBACK ? RTN_LOCAL : RTN_UNICAST, in fib_modify_prefix_metric()
1170 prefix, ifa->ifa_prefixlen, ifa, new_metric); in fib_modify_prefix_metric()
1174 dev->flags & IFF_LOOPBACK ? RTN_LOCAL : RTN_UNICAST, in fib_modify_prefix_metric()
1175 prefix, ifa->ifa_prefixlen, ifa, ifa->ifa_rt_priority); in fib_modify_prefix_metric()
1185 struct in_device *in_dev = ifa->ifa_dev; in fib_del_ifaddr()
1186 struct net_device *dev = in_dev->dev; in fib_del_ifaddr()
1189 __be32 brd = ifa->ifa_address | ~ifa->ifa_mask; in fib_del_ifaddr()
1190 __be32 any = ifa->ifa_address & ifa->ifa_mask; in fib_del_ifaddr()
1200 if (ifa->ifa_flags & IFA_F_SECONDARY) { in fib_del_ifaddr()
1201 prim = inet_ifa_byprefix(in_dev, any, ifa->ifa_mask); in fib_del_ifaddr()
1206 if (!in_dev->dead) in fib_del_ifaddr()
1215 (any != ifa->ifa_local || ifa->ifa_prefixlen < 32)) { in fib_del_ifaddr()
1216 if (!(ifa->ifa_flags & IFA_F_NOPREFIXROUTE)) in fib_del_ifaddr()
1218 dev->flags & IFF_LOOPBACK ? RTN_LOCAL : RTN_UNICAST, in fib_del_ifaddr()
1219 any, ifa->ifa_prefixlen, prim, 0); in fib_del_ifaddr()
1223 if (in_dev->dead) in fib_del_ifaddr()
1227 * We should take care of not to delete too much :-) in fib_del_ifaddr()
1239 if (iprim && ifa1->ifa_mask == iprim->ifa_mask && in fib_del_ifaddr()
1240 inet_ifa_match(ifa1->ifa_address, iprim)) in fib_del_ifaddr()
1244 if (ifa1->ifa_flags & IFA_F_SECONDARY) { in fib_del_ifaddr()
1246 if (ifa1->ifa_mask == prim->ifa_mask && in fib_del_ifaddr()
1247 inet_ifa_match(ifa1->ifa_address, prim)) in fib_del_ifaddr()
1259 ifa1->ifa_mask != prim1->ifa_mask || in fib_del_ifaddr()
1260 !inet_ifa_match(ifa1->ifa_address, prim1)) in fib_del_ifaddr()
1262 ifa1->ifa_address, in fib_del_ifaddr()
1263 ifa1->ifa_mask); in fib_del_ifaddr()
1266 if (prim1->ifa_local != prim->ifa_local) in fib_del_ifaddr()
1270 if (prim->ifa_local != ifa1->ifa_local) in fib_del_ifaddr()
1276 if (ifa->ifa_local == ifa1->ifa_local) in fib_del_ifaddr()
1278 if (ifa->ifa_broadcast == ifa1->ifa_broadcast) in fib_del_ifaddr()
1280 if (brd == ifa1->ifa_broadcast) in fib_del_ifaddr()
1282 if (any == ifa1->ifa_broadcast) in fib_del_ifaddr()
1285 if (prim1 == ifa1 && ifa1->ifa_prefixlen < 31) { in fib_del_ifaddr()
1286 __be32 brd1 = ifa1->ifa_address | ~ifa1->ifa_mask; in fib_del_ifaddr()
1287 __be32 any1 = ifa1->ifa_address & ifa1->ifa_mask; in fib_del_ifaddr()
1290 if (ifa->ifa_broadcast == brd1 || in fib_del_ifaddr()
1291 ifa->ifa_broadcast == any1) in fib_del_ifaddr()
1304 fib_magic(RTM_DELROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, in fib_del_ifaddr()
1306 if (subnet && ifa->ifa_prefixlen < 31) { in fib_del_ifaddr()
1317 fib_magic(RTM_DELROUTE, RTN_LOCAL, ifa->ifa_local, 32, prim, 0); in fib_del_ifaddr()
1321 ifa->ifa_local); in fib_del_ifaddr()
1329 if (fib_sync_down_addr(dev, ifa->ifa_local)) in fib_del_ifaddr()
1344 .flowi4_mark = frn->fl_mark, in nl_fib_lookup()
1345 .daddr = frn->fl_addr, in nl_fib_lookup()
1346 .flowi4_tos = frn->fl_tos & INET_DSCP_MASK, in nl_fib_lookup()
1347 .flowi4_scope = frn->fl_scope, in nl_fib_lookup()
1353 tb = fib_get_table(net, frn->tb_id_in); in nl_fib_lookup()
1355 frn->err = -ENOENT; in nl_fib_lookup()
1359 frn->tb_id = tb->tb_id; in nl_fib_lookup()
1360 frn->err = fib_table_lookup(tb, &fl4, &res, FIB_LOOKUP_NOREF); in nl_fib_lookup()
1362 if (!frn->err) { in nl_fib_lookup()
1363 frn->prefixlen = res.prefixlen; in nl_fib_lookup()
1364 frn->nh_sel = res.nh_sel; in nl_fib_lookup()
1365 frn->type = res.type; in nl_fib_lookup()
1366 frn->scope = res.scope; in nl_fib_lookup()
1381 net = sock_net(skb->sk); in nl_fib_input()
1383 if (skb->len < nlmsg_total_size(sizeof(*frn)) || in nl_fib_input()
1384 skb->len < nlh->nlmsg_len || in nl_fib_input()
1399 nlmsg_unicast(net->ipv4.fibnl, skb, portid); in nl_fib_input()
1411 return -EAFNOSUPPORT; in nl_fib_lookup_init()
1412 net->ipv4.fibnl = sk; in nl_fib_lookup_init()
1418 netlink_kernel_release(net->ipv4.fibnl); in nl_fib_lookup_exit()
1419 net->ipv4.fibnl = NULL; in nl_fib_lookup_exit()
1435 struct net_device *dev = ifa->ifa_dev->dev; in fib_inetaddr_event()
1444 atomic_inc(&net->ipv4.dev_addr_genid); in fib_inetaddr_event()
1449 atomic_inc(&net->ipv4.dev_addr_genid); in fib_inetaddr_event()
1450 if (!ifa->ifa_dev->ifa_list) { in fib_inetaddr_event()
1491 atomic_inc(&net->ipv4.dev_addr_genid); in fib_netdev_event()
1506 fib_sync_mtu(dev, info_ext->ext.mtu); in fib_netdev_event()
1514 if (upper_info->upper_dev && in fib_netdev_event()
1515 netif_is_l3_master(upper_info->upper_dev)) in fib_netdev_event()
1540 /* Default to 3-tuple */ in ip_fib_net_init()
1541 net->ipv4.sysctl_fib_multipath_hash_fields = in ip_fib_net_init()
1545 /* Avoid false sharing : Use at least a full cache line */ in ip_fib_net_init()
1548 net->ipv4.fib_table_hash = kzalloc(size, GFP_KERNEL); in ip_fib_net_init()
1549 if (!net->ipv4.fib_table_hash) { in ip_fib_net_init()
1550 err = -ENOMEM; in ip_fib_net_init()
1560 kfree(net->ipv4.fib_table_hash); in ip_fib_net_init()
1572 RCU_INIT_POINTER(net->ipv4.fib_main, NULL); in ip_fib_net_exit()
1573 RCU_INIT_POINTER(net->ipv4.fib_default, NULL); in ip_fib_net_exit()
1580 for (i = FIB_TABLE_HASHSZ - 1; i >= 0; i--) { in ip_fib_net_exit()
1581 struct hlist_head *head = &net->ipv4.fib_table_hash[i]; in ip_fib_net_exit()
1586 hlist_del(&tb->tb_hlist); in ip_fib_net_exit()
1596 kfree(net->ipv4.fib_table_hash); in ip_fib_net_exit()
1605 atomic_set(&net->ipv4.fib_num_tclassid_users, 0); in fib_net_init()