Lines Matching refs:cfg
767 static int mpls_nh_build_from_cfg(struct mpls_route_config *cfg, in mpls_nh_build_from_cfg() argument
770 struct net *net = cfg->rc_nlinfo.nl_net; in mpls_nh_build_from_cfg()
778 nh->nh_labels = cfg->rc_output_labels; in mpls_nh_build_from_cfg()
780 nh->nh_label[i] = cfg->rc_output_label[i]; in mpls_nh_build_from_cfg()
782 nh->nh_via_table = cfg->rc_via_table; in mpls_nh_build_from_cfg()
783 memcpy(__mpls_nh_via(rt, nh), cfg->rc_via, cfg->rc_via_alen); in mpls_nh_build_from_cfg()
784 nh->nh_via_alen = cfg->rc_via_alen; in mpls_nh_build_from_cfg()
786 err = mpls_nh_assign_dev(net, rt, nh, cfg->rc_ifindex); in mpls_nh_build_from_cfg()
884 static int mpls_nh_build_multi(struct mpls_route_config *cfg, in mpls_nh_build_multi() argument
888 struct rtnexthop *rtnh = cfg->rc_mp; in mpls_nh_build_multi()
890 int remaining = cfg->rc_mp_len; in mpls_nh_build_multi()
918 err = mpls_nh_build(cfg->rc_nlinfo.nl_net, rt, nh, in mpls_nh_build_multi()
962 static int mpls_route_add(struct mpls_route_config *cfg, in mpls_route_add() argument
966 struct net *net = cfg->rc_nlinfo.nl_net; in mpls_route_add()
974 index = cfg->rc_label; in mpls_route_add()
978 (cfg->rc_nlflags & NLM_F_CREATE)) { in mpls_route_add()
987 if (cfg->rc_nlflags & NLM_F_APPEND) { in mpls_route_add()
995 if ((cfg->rc_nlflags & NLM_F_EXCL) && old) in mpls_route_add()
999 if (!(cfg->rc_nlflags & NLM_F_REPLACE) && old) in mpls_route_add()
1003 if (!(cfg->rc_nlflags & NLM_F_CREATE) && !old) in mpls_route_add()
1007 if (cfg->rc_mp) { in mpls_route_add()
1008 nhs = mpls_count_nexthops(cfg->rc_mp, cfg->rc_mp_len, in mpls_route_add()
1009 cfg->rc_via_alen, &max_via_alen, in mpls_route_add()
1012 max_via_alen = cfg->rc_via_alen; in mpls_route_add()
1013 max_labels = cfg->rc_output_labels; in mpls_route_add()
1028 rt->rt_protocol = cfg->rc_protocol; in mpls_route_add()
1029 rt->rt_payload_type = cfg->rc_payload_type; in mpls_route_add()
1030 rt->rt_ttl_propagate = cfg->rc_ttl_propagate; in mpls_route_add()
1032 if (cfg->rc_mp) in mpls_route_add()
1033 err = mpls_nh_build_multi(cfg, rt, max_labels, extack); in mpls_route_add()
1035 err = mpls_nh_build_from_cfg(cfg, rt); in mpls_route_add()
1039 mpls_route_update(net, index, rt, &cfg->rc_nlinfo); in mpls_route_add()
1049 static int mpls_route_del(struct mpls_route_config *cfg, in mpls_route_del() argument
1052 struct net *net = cfg->rc_nlinfo.nl_net; in mpls_route_del()
1056 index = cfg->rc_label; in mpls_route_del()
1061 mpls_route_update(net, index, NULL, &cfg->rc_nlinfo); in mpls_route_del()
1813 struct mpls_route_config *cfg, in rtm_to_route_config() argument
1871 cfg->rc_label = LABEL_NOT_SPECIFIED; in rtm_to_route_config()
1872 cfg->rc_protocol = rtm->rtm_protocol; in rtm_to_route_config()
1873 cfg->rc_via_table = MPLS_NEIGH_TABLE_UNSPEC; in rtm_to_route_config()
1874 cfg->rc_ttl_propagate = MPLS_TTL_PROP_DEFAULT; in rtm_to_route_config()
1875 cfg->rc_nlflags = nlh->nlmsg_flags; in rtm_to_route_config()
1876 cfg->rc_nlinfo.portid = NETLINK_CB(skb).portid; in rtm_to_route_config()
1877 cfg->rc_nlinfo.nlh = nlh; in rtm_to_route_config()
1878 cfg->rc_nlinfo.nl_net = sock_net(skb->sk); in rtm_to_route_config()
1887 cfg->rc_ifindex = nla_get_u32(nla); in rtm_to_route_config()
1891 &cfg->rc_output_labels, in rtm_to_route_config()
1892 cfg->rc_output_label, extack)) in rtm_to_route_config()
1899 &cfg->rc_label, extack)) in rtm_to_route_config()
1902 if (!mpls_label_ok(cfg->rc_nlinfo.nl_net, in rtm_to_route_config()
1903 &cfg->rc_label, extack)) in rtm_to_route_config()
1912 if (nla_get_via(nla, &cfg->rc_via_alen, in rtm_to_route_config()
1913 &cfg->rc_via_table, cfg->rc_via, in rtm_to_route_config()
1920 cfg->rc_mp = nla_data(nla); in rtm_to_route_config()
1921 cfg->rc_mp_len = nla_len(nla); in rtm_to_route_config()
1933 cfg->rc_ttl_propagate = ttl_propagate ? in rtm_to_route_config()
1953 struct mpls_route_config *cfg; in mpls_rtm_delroute() local
1956 cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); in mpls_rtm_delroute()
1957 if (!cfg) in mpls_rtm_delroute()
1960 err = rtm_to_route_config(skb, nlh, cfg, extack); in mpls_rtm_delroute()
1964 err = mpls_route_del(cfg, extack); in mpls_rtm_delroute()
1966 kfree(cfg); in mpls_rtm_delroute()
1975 struct mpls_route_config *cfg; in mpls_rtm_newroute() local
1978 cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); in mpls_rtm_newroute()
1979 if (!cfg) in mpls_rtm_newroute()
1982 err = rtm_to_route_config(skb, nlh, cfg, extack); in mpls_rtm_newroute()
1986 err = mpls_route_add(cfg, extack); in mpls_rtm_newroute()
1988 kfree(cfg); in mpls_rtm_newroute()