]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_srte.c
Merge pull request #13374 from opensourcerouting/build-fix-rmap-yang
[mirror_frr.git] / zebra / zebra_srte.c
index c0f18dd09160085ddbeced7a34a8e17d46d14c5c..c0b83382c457f037267ff3eaa099dc4cc7c82bd8 100644 (file)
@@ -1,21 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* Zebra SR-TE code
  * Copyright (C) 2020  NetDEF, Inc.
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra 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, or (at your option) any
- * later version.
- *
- * GNU Zebra 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>
@@ -140,7 +125,7 @@ static int zebra_sr_policy_notify_update_client(struct zebra_sr_policy *policy,
                stream_putc(s, IPV6_MAX_BITLEN);
                stream_put(s, &policy->endpoint.ipaddr_v6, IPV6_MAX_BYTELEN);
                break;
-       default:
+       case IPADDR_NONE:
                flog_warn(EC_LIB_DEVELOPMENT,
                          "%s: unknown policy endpoint address family: %u",
                          __func__, policy->endpoint.ipa_type);
@@ -202,7 +187,7 @@ static void zebra_sr_policy_notify_update(struct zebra_sr_policy *policy)
                p.prefixlen = IPV6_MAX_BITLEN;
                p.u.prefix6 = policy->endpoint.ipaddr_v6;
                break;
-       default:
+       case IPADDR_NONE:
                flog_warn(EC_LIB_DEVELOPMENT,
                          "%s: unknown policy endpoint address family: %u",
                          __func__, policy->endpoint.ipa_type);
@@ -384,6 +369,23 @@ int zebra_sr_policy_label_update(mpls_label_t label,
        return 0;
 }
 
+static int zebra_srte_client_close_cleanup(struct zserv *client)
+{
+       int sock = client->sock;
+       struct zebra_sr_policy *policy, *policy_temp;
+
+       if (!sock)
+               return 0;
+
+       RB_FOREACH_SAFE (policy, zebra_sr_policy_instance_head,
+                        &zebra_sr_policy_instances, policy_temp) {
+               if (policy->sock == sock)
+                       zebra_sr_policy_del(policy);
+       }
+       return 1;
+}
+
 void zebra_srte_init(void)
 {
+       hook_register(zserv_client_close, zebra_srte_client_close_cleanup);
 }