]> git.proxmox.com Git - mirror_frr.git/blame - pbrd/pbr_debug.c
Merge pull request #12603 from opensourcerouting/fix/deprecate_bgp_stuff_some
[mirror_frr.git] / pbrd / pbr_debug.c
CommitLineData
e5c83d9b
DS
1/*
2 * PBR - debugging
3 * Copyright (C) 2018 Cumulus Networks, Inc.
4 * Quentin Young
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <zebra.h>
21
22#include "debug.h"
23#include "command.h"
24#include "vector.h"
25
e5c83d9b 26#include "pbrd/pbr_debug_clippy.c"
e5c83d9b
DS
27#include "pbrd/pbr_debug.h"
28
29struct debug pbr_dbg_map = {0, "PBR map"};
30struct debug pbr_dbg_zebra = {0, "PBR Zebra communications"};
31struct debug pbr_dbg_nht = {0, "PBR nexthop tracking"};
32struct debug pbr_dbg_event = {0, "PBR events"};
33
34struct debug *pbr_debugs[] = {&pbr_dbg_map, &pbr_dbg_zebra, &pbr_dbg_nht,
35 &pbr_dbg_event};
36
37const char *pbr_debugs_conflines[] = {
38 "debug pbr map",
39 "debug pbr zebra",
40 "debug pbr nht",
41 "debug pbr events",
42};
43
e14f43cc 44void pbr_debug_set_all(uint32_t flags, bool set)
e5c83d9b
DS
45{
46 for (unsigned int i = 0; i < array_size(pbr_debugs); i++) {
47 DEBUG_FLAGS_SET(pbr_debugs[i], flags, set);
48
49 /* if all modes have been turned off, don't preserve options */
50 if (!DEBUG_MODE_CHECK(pbr_debugs[i], DEBUG_MODE_ALL))
51 DEBUG_CLEAR(pbr_debugs[i]);
52 }
53}
54
e14f43cc 55int pbr_debug_config_write_helper(struct vty *vty, bool config)
e5c83d9b
DS
56{
57 uint32_t mode = DEBUG_MODE_ALL;
58
59 if (config)
60 mode = DEBUG_MODE_CONF;
61
e5c83d9b
DS
62 for (unsigned int i = 0; i < array_size(pbr_debugs); i++)
63 if (DEBUG_MODE_CHECK(pbr_debugs[i], mode))
64 vty_out(vty, "%s\n", pbr_debugs_conflines[i]);
65 return 0;
66}
67
68int pbr_debug_config_write(struct vty *vty)
69{
70 return pbr_debug_config_write_helper(vty, true);
71}
72
e5c83d9b
DS
73struct debug_callbacks pbr_dbg_cbs = {.debug_set_all = pbr_debug_set_all};
74
75void pbr_debug_init(void)
76{
77 debug_init(&pbr_dbg_cbs);
78}