Lines Matching refs:cfg

560 static int mpls_nh_build_from_cfg(struct mpls_route_config *cfg,  in mpls_nh_build_from_cfg()  argument
563 struct net *net = cfg->rc_nlinfo.nl_net; in mpls_nh_build_from_cfg()
573 if (cfg->rc_output_labels > MAX_NEW_LABELS) in mpls_nh_build_from_cfg()
576 nh->nh_labels = cfg->rc_output_labels; in mpls_nh_build_from_cfg()
578 nh->nh_label[i] = cfg->rc_output_label[i]; in mpls_nh_build_from_cfg()
580 nh->nh_via_table = cfg->rc_via_table; in mpls_nh_build_from_cfg()
581 memcpy(__mpls_nh_via(rt, nh), cfg->rc_via, cfg->rc_via_alen); in mpls_nh_build_from_cfg()
582 nh->nh_via_alen = cfg->rc_via_alen; in mpls_nh_build_from_cfg()
584 err = mpls_nh_assign_dev(net, rt, nh, cfg->rc_ifindex); in mpls_nh_build_from_cfg()
666 static int mpls_nh_build_multi(struct mpls_route_config *cfg, in mpls_nh_build_multi() argument
669 struct rtnexthop *rtnh = cfg->rc_mp; in mpls_nh_build_multi()
671 int remaining = cfg->rc_mp_len; in mpls_nh_build_multi()
699 err = mpls_nh_build(cfg->rc_nlinfo.nl_net, rt, nh, in mpls_nh_build_multi()
717 static int mpls_route_add(struct mpls_route_config *cfg) in mpls_route_add() argument
720 struct net *net = cfg->rc_nlinfo.nl_net; in mpls_route_add()
727 index = cfg->rc_label; in mpls_route_add()
731 (cfg->rc_nlflags & NLM_F_CREATE)) { in mpls_route_add()
745 if (cfg->rc_nlflags & NLM_F_APPEND) in mpls_route_add()
751 if ((cfg->rc_nlflags & NLM_F_EXCL) && old) in mpls_route_add()
755 if (!(cfg->rc_nlflags & NLM_F_REPLACE) && old) in mpls_route_add()
759 if (!(cfg->rc_nlflags & NLM_F_CREATE) && !old) in mpls_route_add()
763 nhs = mpls_count_nexthops(cfg->rc_mp, cfg->rc_mp_len, in mpls_route_add()
764 cfg->rc_via_alen, &max_via_alen); in mpls_route_add()
773 rt->rt_protocol = cfg->rc_protocol; in mpls_route_add()
774 rt->rt_payload_type = cfg->rc_payload_type; in mpls_route_add()
776 if (cfg->rc_mp) in mpls_route_add()
777 err = mpls_nh_build_multi(cfg, rt); in mpls_route_add()
779 err = mpls_nh_build_from_cfg(cfg, rt); in mpls_route_add()
783 mpls_route_update(net, index, rt, &cfg->rc_nlinfo); in mpls_route_add()
793 static int mpls_route_del(struct mpls_route_config *cfg) in mpls_route_del() argument
795 struct net *net = cfg->rc_nlinfo.nl_net; in mpls_route_del()
799 index = cfg->rc_label; in mpls_route_del()
809 mpls_route_update(net, index, NULL, &cfg->rc_nlinfo); in mpls_route_del()
1097 struct mpls_route_config *cfg) in rtm_to_route_config() argument
1110 memset(cfg, 0, sizeof(*cfg)); in rtm_to_route_config()
1135 cfg->rc_label = LABEL_NOT_SPECIFIED; in rtm_to_route_config()
1136 cfg->rc_protocol = rtm->rtm_protocol; in rtm_to_route_config()
1137 cfg->rc_via_table = MPLS_NEIGH_TABLE_UNSPEC; in rtm_to_route_config()
1138 cfg->rc_nlflags = nlh->nlmsg_flags; in rtm_to_route_config()
1139 cfg->rc_nlinfo.portid = NETLINK_CB(skb).portid; in rtm_to_route_config()
1140 cfg->rc_nlinfo.nlh = nlh; in rtm_to_route_config()
1141 cfg->rc_nlinfo.nl_net = sock_net(skb->sk); in rtm_to_route_config()
1150 cfg->rc_ifindex = nla_get_u32(nla); in rtm_to_route_config()
1154 &cfg->rc_output_labels, in rtm_to_route_config()
1155 cfg->rc_output_label)) in rtm_to_route_config()
1162 &cfg->rc_label)) in rtm_to_route_config()
1166 if (cfg->rc_label < MPLS_LABEL_FIRST_UNRESERVED) in rtm_to_route_config()
1173 if (nla_get_via(nla, &cfg->rc_via_alen, in rtm_to_route_config()
1174 &cfg->rc_via_table, cfg->rc_via)) in rtm_to_route_config()
1180 cfg->rc_mp = nla_data(nla); in rtm_to_route_config()
1181 cfg->rc_mp_len = nla_len(nla); in rtm_to_route_config()
1197 struct mpls_route_config cfg; in mpls_rtm_delroute() local
1200 err = rtm_to_route_config(skb, nlh, &cfg); in mpls_rtm_delroute()
1204 return mpls_route_del(&cfg); in mpls_rtm_delroute()
1210 struct mpls_route_config cfg; in mpls_rtm_newroute() local
1213 err = rtm_to_route_config(skb, nlh, &cfg); in mpls_rtm_newroute()
1217 return mpls_route_add(&cfg); in mpls_rtm_newroute()