diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-11-17 15:26:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-17 15:26:55 +0200 |
| commit | 1e5e7934eabc39831f79c113bb1c0b8b9a74c499 (patch) | |
| tree | 1be73f3cb020ddf37aeaf7bbffe828016c6fda84 | |
| parent | 884f617f54d763a71f4acc85d79d66f4f7ea72f1 (diff) | |
| parent | 6082fb4249ce59b5e19b2257d78c4d91316a11bc (diff) | |
Merge pull request #12147 from pguibert6WIND/srte_flush
zebra: upon srte leave, flush sr policies
| -rw-r--r-- | zebra/zapi_msg.c | 4 | ||||
| -rw-r--r-- | zebra/zebra_srte.c | 17 | ||||
| -rw-r--r-- | zebra/zebra_srte.h | 1 |
3 files changed, 21 insertions, 1 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 85eb6b3451..130fb972db 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -2606,8 +2606,10 @@ static void zread_sr_policy_set(ZAPI_HANDLER_ARGS) return; policy = zebra_sr_policy_find(zp.color, &zp.endpoint); - if (!policy) + if (!policy) { policy = zebra_sr_policy_add(zp.color, &zp.endpoint, zp.name); + policy->sock = client->sock; + } /* TODO: per-VRF list of SR-TE policies. */ policy->zvrf = zvrf; diff --git a/zebra/zebra_srte.c b/zebra/zebra_srte.c index c0f18dd091..7d95607fcf 100644 --- a/zebra/zebra_srte.c +++ b/zebra/zebra_srte.c @@ -384,6 +384,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; + + if (!sock) + return 0; + + RB_FOREACH (policy, zebra_sr_policy_instance_head, + &zebra_sr_policy_instances) { + 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); } diff --git a/zebra/zebra_srte.h b/zebra/zebra_srte.h index fe77809446..dff2f595fd 100644 --- a/zebra/zebra_srte.h +++ b/zebra/zebra_srte.h @@ -45,6 +45,7 @@ struct zebra_sr_policy { struct zapi_srte_tunnel segment_list; struct zebra_lsp *lsp; struct zebra_vrf *zvrf; + int sock; }; RB_HEAD(zebra_sr_policy_instance_head, zebra_sr_policy); RB_PROTOTYPE(zebra_sr_policy_instance_head, zebra_sr_policy, entry, |
