fib_semantics.c (a4654e9bde4ecedb4921e6c8fe2088114bdff1b3) | fib_semantics.c (faee676944dab731c9b2b91cf86c769d291a2237) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * INET An implementation of the TCP/IP protocol suite for the LINUX 4 * operating system. INET is implemented using the BSD Socket 5 * interface as the means of communication with the user level. 6 * 7 * IPv4 Forwarding Information Base: semantics. 8 * --- 556 unchanged lines hidden (view full) --- 565 if ((state & NUD_VALID) || 566 (*last_idx < 0 && order > dflt && state != NUD_INCOMPLETE)) { 567 *last_resort = fi; 568 *last_idx = order; 569 } 570 return 1; 571} 572 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * INET An implementation of the TCP/IP protocol suite for the LINUX 4 * operating system. INET is implemented using the BSD Socket 5 * interface as the means of communication with the user level. 6 * 7 * IPv4 Forwarding Information Base: semantics. 8 * --- 556 unchanged lines hidden (view full) --- 565 if ((state & NUD_VALID) || 566 (*last_idx < 0 && order > dflt && state != NUD_INCOMPLETE)) { 567 *last_resort = fi; 568 *last_idx = order; 569 } 570 return 1; 571} 572 |
573int fib_nh_common_init(struct fib_nh_common *nhc, struct nlattr *encap, 574 u16 encap_type, void *cfg, gfp_t gfp_flags, | 573int fib_nh_common_init(struct net *net, struct fib_nh_common *nhc, 574 struct nlattr *encap, u16 encap_type, 575 void *cfg, gfp_t gfp_flags, |
575 struct netlink_ext_ack *extack) 576{ 577 int err; 578 579 nhc->nhc_pcpu_rth_output = alloc_percpu_gfp(struct rtable __rcu *, 580 gfp_flags); 581 if (!nhc->nhc_pcpu_rth_output) 582 return -ENOMEM; 583 584 if (encap) { 585 struct lwtunnel_state *lwtstate; 586 587 if (encap_type == LWTUNNEL_ENCAP_NONE) { 588 NL_SET_ERR_MSG(extack, "LWT encap type not specified"); 589 err = -EINVAL; 590 goto lwt_failure; 591 } | 576 struct netlink_ext_ack *extack) 577{ 578 int err; 579 580 nhc->nhc_pcpu_rth_output = alloc_percpu_gfp(struct rtable __rcu *, 581 gfp_flags); 582 if (!nhc->nhc_pcpu_rth_output) 583 return -ENOMEM; 584 585 if (encap) { 586 struct lwtunnel_state *lwtstate; 587 588 if (encap_type == LWTUNNEL_ENCAP_NONE) { 589 NL_SET_ERR_MSG(extack, "LWT encap type not specified"); 590 err = -EINVAL; 591 goto lwt_failure; 592 } |
592 err = lwtunnel_build_state(encap_type, encap, nhc->nhc_family, 593 cfg, &lwtstate, extack); | 593 err = lwtunnel_build_state(net, encap_type, encap, 594 nhc->nhc_family, cfg, &lwtstate, 595 extack); |
594 if (err) 595 goto lwt_failure; 596 597 nhc->nhc_lwtstate = lwtstate_get(lwtstate); 598 } 599 600 return 0; 601 --- 7 unchanged lines hidden (view full) --- 609int fib_nh_init(struct net *net, struct fib_nh *nh, 610 struct fib_config *cfg, int nh_weight, 611 struct netlink_ext_ack *extack) 612{ 613 int err; 614 615 nh->fib_nh_family = AF_INET; 616 | 596 if (err) 597 goto lwt_failure; 598 599 nhc->nhc_lwtstate = lwtstate_get(lwtstate); 600 } 601 602 return 0; 603 --- 7 unchanged lines hidden (view full) --- 611int fib_nh_init(struct net *net, struct fib_nh *nh, 612 struct fib_config *cfg, int nh_weight, 613 struct netlink_ext_ack *extack) 614{ 615 int err; 616 617 nh->fib_nh_family = AF_INET; 618 |
617 err = fib_nh_common_init(&nh->nh_common, cfg->fc_encap, | 619 err = fib_nh_common_init(net, &nh->nh_common, cfg->fc_encap, |
618 cfg->fc_encap_type, cfg, GFP_KERNEL, extack); 619 if (err) 620 return err; 621 622 nh->fib_nh_oif = cfg->fc_oif; 623 nh->fib_nh_gw_family = cfg->fc_gw_family; 624 if (cfg->fc_gw_family == AF_INET) 625 nh->fib_nh_gw4 = cfg->fc_gw4; --- 183 unchanged lines hidden (view full) --- 809 810 return -EINVAL; 811} 812 813#define fib_rebalance(fi) do { } while (0) 814 815#endif /* CONFIG_IP_ROUTE_MULTIPATH */ 816 | 620 cfg->fc_encap_type, cfg, GFP_KERNEL, extack); 621 if (err) 622 return err; 623 624 nh->fib_nh_oif = cfg->fc_oif; 625 nh->fib_nh_gw_family = cfg->fc_gw_family; 626 if (cfg->fc_gw_family == AF_INET) 627 nh->fib_nh_gw4 = cfg->fc_gw4; --- 183 unchanged lines hidden (view full) --- 811 812 return -EINVAL; 813} 814 815#define fib_rebalance(fi) do { } while (0) 816 817#endif /* CONFIG_IP_ROUTE_MULTIPATH */ 818 |
817static int fib_encap_match(u16 encap_type, | 819static int fib_encap_match(struct net *net, u16 encap_type, |
818 struct nlattr *encap, 819 const struct fib_nh *nh, 820 const struct fib_config *cfg, 821 struct netlink_ext_ack *extack) 822{ 823 struct lwtunnel_state *lwtstate; 824 int ret, result = 0; 825 826 if (encap_type == LWTUNNEL_ENCAP_NONE) 827 return 0; 828 | 820 struct nlattr *encap, 821 const struct fib_nh *nh, 822 const struct fib_config *cfg, 823 struct netlink_ext_ack *extack) 824{ 825 struct lwtunnel_state *lwtstate; 826 int ret, result = 0; 827 828 if (encap_type == LWTUNNEL_ENCAP_NONE) 829 return 0; 830 |
829 ret = lwtunnel_build_state(encap_type, encap, AF_INET, | 831 ret = lwtunnel_build_state(net, encap_type, encap, AF_INET, |
830 cfg, &lwtstate, extack); 831 if (!ret) { 832 result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws); 833 lwtstate_free(lwtstate); 834 } 835 836 return result; 837} 838 | 832 cfg, &lwtstate, extack); 833 if (!ret) { 834 result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws); 835 lwtstate_free(lwtstate); 836 } 837 838 return result; 839} 840 |
839int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, | 841int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi, |
840 struct netlink_ext_ack *extack) 841{ 842#ifdef CONFIG_IP_ROUTE_MULTIPATH 843 struct rtnexthop *rtnh; 844 int remaining; 845#endif 846 847 if (cfg->fc_priority && cfg->fc_priority != fi->fib_priority) --- 4 unchanged lines hidden (view full) --- 852 return 0; 853 return 1; 854 } 855 856 if (cfg->fc_oif || cfg->fc_gw_family) { 857 struct fib_nh *nh = fib_info_nh(fi, 0); 858 859 if (cfg->fc_encap) { | 842 struct netlink_ext_ack *extack) 843{ 844#ifdef CONFIG_IP_ROUTE_MULTIPATH 845 struct rtnexthop *rtnh; 846 int remaining; 847#endif 848 849 if (cfg->fc_priority && cfg->fc_priority != fi->fib_priority) --- 4 unchanged lines hidden (view full) --- 854 return 0; 855 return 1; 856 } 857 858 if (cfg->fc_oif || cfg->fc_gw_family) { 859 struct fib_nh *nh = fib_info_nh(fi, 0); 860 861 if (cfg->fc_encap) { |
860 if (fib_encap_match(cfg->fc_encap_type, cfg->fc_encap, 861 nh, cfg, extack)) | 862 if (fib_encap_match(net, cfg->fc_encap_type, 863 cfg->fc_encap, nh, cfg, extack)) |
862 return 1; 863 } 864#ifdef CONFIG_IP_ROUTE_CLASSID 865 if (cfg->fc_flow && 866 cfg->fc_flow != nh->nh_tclassid) 867 return 1; 868#endif 869 if ((cfg->fc_oif && cfg->fc_oif != nh->fib_nh_oif) || --- 1087 unchanged lines hidden (view full) --- 1957 if (nexthop_nh->fib_nh_flags & RTNH_F_DEAD) 1958 dead++; 1959 else if (nexthop_nh->fib_nh_dev == dev && 1960 nexthop_nh->fib_nh_scope != scope) { 1961 switch (event) { 1962 case NETDEV_DOWN: 1963 case NETDEV_UNREGISTER: 1964 nexthop_nh->fib_nh_flags |= RTNH_F_DEAD; | 864 return 1; 865 } 866#ifdef CONFIG_IP_ROUTE_CLASSID 867 if (cfg->fc_flow && 868 cfg->fc_flow != nh->nh_tclassid) 869 return 1; 870#endif 871 if ((cfg->fc_oif && cfg->fc_oif != nh->fib_nh_oif) || --- 1087 unchanged lines hidden (view full) --- 1959 if (nexthop_nh->fib_nh_flags & RTNH_F_DEAD) 1960 dead++; 1961 else if (nexthop_nh->fib_nh_dev == dev && 1962 nexthop_nh->fib_nh_scope != scope) { 1963 switch (event) { 1964 case NETDEV_DOWN: 1965 case NETDEV_UNREGISTER: 1966 nexthop_nh->fib_nh_flags |= RTNH_F_DEAD; |
1965 /* fall through */ | 1967 fallthrough; |
1966 case NETDEV_CHANGE: 1967 nexthop_nh->fib_nh_flags |= RTNH_F_LINKDOWN; 1968 break; 1969 } 1970 call_fib_nh_notifiers(nexthop_nh, 1971 FIB_EVENT_NH_DEL); 1972 dead++; 1973 } --- 5 unchanged lines hidden (view full) --- 1979 } 1980#endif 1981 } endfor_nexthops(fi) 1982 if (dead == fi->fib_nhs) { 1983 switch (event) { 1984 case NETDEV_DOWN: 1985 case NETDEV_UNREGISTER: 1986 fi->fib_flags |= RTNH_F_DEAD; | 1968 case NETDEV_CHANGE: 1969 nexthop_nh->fib_nh_flags |= RTNH_F_LINKDOWN; 1970 break; 1971 } 1972 call_fib_nh_notifiers(nexthop_nh, 1973 FIB_EVENT_NH_DEL); 1974 dead++; 1975 } --- 5 unchanged lines hidden (view full) --- 1981 } 1982#endif 1983 } endfor_nexthops(fi) 1984 if (dead == fi->fib_nhs) { 1985 switch (event) { 1986 case NETDEV_DOWN: 1987 case NETDEV_UNREGISTER: 1988 fi->fib_flags |= RTNH_F_DEAD; |
1987 /* fall through */ | 1989 fallthrough; |
1988 case NETDEV_CHANGE: 1989 fi->fib_flags |= RTNH_F_LINKDOWN; 1990 break; 1991 } 1992 ret++; 1993 } 1994 1995 fib_rebalance(fi); --- 230 unchanged lines hidden --- | 1990 case NETDEV_CHANGE: 1991 fi->fib_flags |= RTNH_F_LINKDOWN; 1992 break; 1993 } 1994 ret++; 1995 } 1996 1997 fib_rebalance(fi); --- 230 unchanged lines hidden --- |