]> git.proxmox.com Git - mirror_frr.git/blobdiff - pathd/path_nb_config.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / pathd / path_nb_config.c
index 669db169ae7172ca8855d8c2cfdb3493b0f23c53..ad24f23dd9f9730e70b45b40d87a66952b4477ab 100644 (file)
@@ -1,19 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (C) 2020  NetDEF, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -160,6 +147,22 @@ int pathd_srte_segment_list_segment_sid_value_modify(
        return NB_OK;
 }
 
+int pathd_srte_segment_list_segment_sid_value_destroy(
+       struct nb_cb_destroy_args *args)
+{
+       struct srte_segment_entry *segment;
+
+       if (args->event != NB_EV_APPLY)
+               return NB_OK;
+
+       segment = nb_running_get_entry(args->dnode, NULL, true);
+       segment->sid_value = MPLS_LABEL_NONE;
+       SET_FLAG(segment->segment_list->flags, F_SEGMENT_LIST_MODIFIED);
+
+       return NB_OK;
+}
+
+
 int pathd_srte_segment_list_segment_nai_destroy(struct nb_cb_destroy_args *args)
 {
        struct srte_segment_entry *segment;
@@ -184,6 +187,8 @@ void pathd_srte_segment_list_segment_nai_apply_finish(
        enum srte_segment_nai_type type;
        struct ipaddr local_addr, remote_addr;
        uint32_t local_iface = 0, remote_iface = 0;
+       uint8_t algo = 0, local_prefix_len = 0;
+       const char *algo_buf, *local_prefix_len_buf;
 
        segment = nb_running_get_entry(args->dnode, NULL, true);
        type = yang_dnode_get_enum(args->dnode, "./type");
@@ -207,12 +212,34 @@ void pathd_srte_segment_list_segment_nai_apply_finish(
                remote_iface = yang_dnode_get_uint32(args->dnode,
                                                     "./remote-interface");
                break;
-       default:
+       case SRTE_SEGMENT_NAI_TYPE_IPV4_ALGORITHM:
+               algo_buf = yang_dnode_get_string(args->dnode, "./algorithm");
+               algo = atoi(algo_buf);
+               local_prefix_len_buf = yang_dnode_get_string(
+                       args->dnode, "./local-prefix-len");
+               local_prefix_len = atoi(local_prefix_len_buf);
+               break;
+       case SRTE_SEGMENT_NAI_TYPE_IPV4_LOCAL_IFACE:
+               local_iface =
+                       yang_dnode_get_uint32(args->dnode, "./local-interface");
+               local_prefix_len_buf = yang_dnode_get_string(
+                       args->dnode, "./local-prefix-len");
+               local_prefix_len = atoi(local_prefix_len_buf);
+               break;
+       case SRTE_SEGMENT_NAI_TYPE_NONE:
+       case SRTE_SEGMENT_NAI_TYPE_IPV6_ADJACENCY_LINK_LOCAL_ADDRESSES:
+       case SRTE_SEGMENT_NAI_TYPE_IPV6_LOCAL_IFACE:
+       case SRTE_SEGMENT_NAI_TYPE_IPV6_ALGORITHM:
                break;
        }
 
-       srte_segment_entry_set_nai(segment, type, &local_addr, local_iface,
-                                  &remote_addr, remote_iface);
+       zlog_debug(" Segment list name (%d) index (%s) ", segment->index,
+                  segment->segment_list->name);
+       if (srte_segment_entry_set_nai(segment, type, &local_addr, local_iface,
+                                      &remote_addr, remote_iface, algo,
+                                      local_prefix_len))
+               SET_FLAG(segment->segment_list->flags,
+                        F_SEGMENT_LIST_SID_CONFLICT);
 }
 
 /*
@@ -229,7 +256,7 @@ int pathd_srte_policy_create(struct nb_cb_create_args *args)
 
        color = yang_dnode_get_uint32(args->dnode, "./color");
        yang_dnode_get_ip(&endpoint, args->dnode, "./endpoint");
-       policy = srte_policy_add(color, &endpoint);
+       policy = srte_policy_add(color, &endpoint, SRTE_ORIGIN_LOCAL, NULL);
 
        nb_running_set_entry(args->dnode, policy);
        SET_FLAG(policy->flags, F_POLICY_NEW);
@@ -302,7 +329,6 @@ int pathd_srte_policy_binding_sid_modify(struct nb_cb_modify_args *args)
        struct srte_policy *policy;
        mpls_label_t binding_sid;
 
-       policy = nb_running_get_entry(args->dnode, NULL, true);
        binding_sid = yang_dnode_get_uint32(args->dnode, NULL);
 
        switch (args->event) {
@@ -315,6 +341,7 @@ int pathd_srte_policy_binding_sid_modify(struct nb_cb_modify_args *args)
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+               policy = nb_running_get_entry(args->dnode, NULL, true);
                srte_policy_update_binding_sid(policy, binding_sid);
                SET_FLAG(policy->flags, F_POLICY_MODIFIED);
                break;
@@ -351,7 +378,8 @@ int pathd_srte_policy_candidate_path_create(struct nb_cb_create_args *args)
 
        policy = nb_running_get_entry(args->dnode, NULL, true);
        preference = yang_dnode_get_uint32(args->dnode, "./preference");
-       candidate = srte_candidate_add(policy, preference);
+       candidate =
+               srte_candidate_add(policy, preference, SRTE_ORIGIN_LOCAL, NULL);
        nb_running_set_entry(args->dnode, candidate);
        SET_FLAG(candidate->flags, F_CANDIDATE_NEW);
 
@@ -668,12 +696,12 @@ int pathd_srte_policy_candidate_path_segment_list_name_modify(
        struct srte_candidate *candidate;
        const char *segment_list_name;
 
-       candidate = nb_running_get_entry(args->dnode, NULL, true);
-       segment_list_name = yang_dnode_get_string(args->dnode, NULL);
-
        if (args->event != NB_EV_APPLY)
                return NB_OK;
 
+       candidate = nb_running_get_entry(args->dnode, NULL, true);
+       segment_list_name = yang_dnode_get_string(args->dnode, NULL);
+
        candidate->segment_list = srte_segment_list_find(segment_list_name);
        candidate->lsp->segment_list = candidate->segment_list;
        assert(candidate->segment_list);