]> git.proxmox.com Git - mirror_frr.git/blame - ripngd/ripng_nb_rpcs.c
bgpd: encode_label call, remove unnecessary braces
[mirror_frr.git] / ripngd / ripng_nb_rpcs.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
ca473936
RW
2/*
3 * Copyright (C) 2018 NetDEF, Inc.
4 * Renato Westphal
ca473936
RW
5 */
6
7#include <zebra.h>
8
9#include "if.h"
10#include "vrf.h"
11#include "log.h"
12#include "prefix.h"
13#include "table.h"
14#include "command.h"
15#include "routemap.h"
16#include "agg_table.h"
17#include "northbound.h"
18#include "libfrr.h"
19
20#include "ripngd/ripngd.h"
21#include "ripngd/ripng_nb.h"
22#include "ripngd/ripng_debug.h"
23#include "ripngd/ripng_route.h"
24
25/*
26 * XPath: /frr-ripngd:clear-ripng-route
27 */
28static void clear_ripng_route(struct ripng *ripng)
29{
30 struct agg_node *rp;
31
32 if (IS_RIPNG_DEBUG_EVENT)
33 zlog_debug("Clearing all RIPng routes (VRF %s)",
34 ripng->vrf_name);
35
36 /* Clear received RIPng routes */
37 for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) {
38 struct list *list;
39 struct listnode *listnode;
40 struct ripng_info *rinfo;
41
42 list = rp->info;
43 if (list == NULL)
44 continue;
45
46 for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
47 if (!ripng_route_rte(rinfo))
48 continue;
49
50 if (CHECK_FLAG(rinfo->flags, RIPNG_RTF_FIB))
51 ripng_zebra_ipv6_delete(ripng, rp);
52 break;
53 }
54
55 if (rinfo) {
e16d030c
DS
56 EVENT_OFF(rinfo->t_timeout);
57 EVENT_OFF(rinfo->t_garbage_collect);
ca473936
RW
58 listnode_delete(list, rinfo);
59 ripng_info_free(rinfo);
60 }
61
62 if (list_isempty(list)) {
63 list_delete(&list);
64 rp->info = NULL;
65 agg_unlock_node(rp);
66 }
67 }
68}
69
60ee8be1 70int clear_ripng_route_rpc(struct nb_cb_rpc_args *args)
ca473936
RW
71{
72 struct ripng *ripng;
73 struct yang_data *yang_vrf;
74
60ee8be1
RW
75 yang_vrf = yang_data_list_find(args->input, "%s/%s", args->xpath,
76 "input/vrf");
ca473936
RW
77 if (yang_vrf) {
78 ripng = ripng_lookup_by_vrf_name(yang_vrf->value);
79 if (ripng)
80 clear_ripng_route(ripng);
81 } else {
82 struct vrf *vrf;
83
84 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
85 ripng = vrf->info;
86 if (!ripng)
87 continue;
88
89 clear_ripng_route(ripng);
90 }
91 }
92
93 return NB_OK;
94}