]>
Commit | Line | Data |
---|---|---|
df395600 DS |
1 | /* Zebra Mlag Code. |
2 | * Copyright (C) 2018 Cumulus Networks, Inc. | |
3 | * Donald Sharp | |
4 | * | |
5 | * This file is part of FRR. | |
6 | * | |
7 | * FRR is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * FRR is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with FRR; see the file COPYING. If not, write to the Free | |
19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | * 02111-1307, USA. | |
21 | */ | |
22 | #include "zebra.h" | |
23 | ||
763ec244 | 24 | #include "command.h" |
df395600 DS |
25 | #include "hook.h" |
26 | ||
27 | #include "zebra/zebra_mlag.h" | |
e96ba9da | 28 | #include "zebra/zebra_router.h" |
b120fe3b DS |
29 | #include "zebra/zapi_msg.h" |
30 | #include "zebra/debug.h" | |
df395600 | 31 | |
763ec244 DS |
32 | #ifndef VTYSH_EXTRACT_PL |
33 | #include "zebra/zebra_mlag_clippy.c" | |
34 | #endif | |
35 | ||
ff1fb8d5 DS |
36 | enum mlag_role zebra_mlag_get_role(void) |
37 | { | |
e96ba9da | 38 | return zrouter.mlag_info.role; |
ff1fb8d5 DS |
39 | } |
40 | ||
763ec244 DS |
41 | DEFUN_HIDDEN (show_mlag, |
42 | show_mlag_cmd, | |
43 | "show zebra mlag", | |
44 | SHOW_STR | |
45 | ZEBRA_STR | |
46 | "The mlag role on this machine\n") | |
47 | { | |
48 | char buf[80]; | |
49 | ||
50 | vty_out(vty, "MLag is configured to: %s\n", | |
e96ba9da | 51 | mlag_role2str(zrouter.mlag_info.role, buf, sizeof(buf))); |
763ec244 DS |
52 | |
53 | return CMD_SUCCESS; | |
54 | } | |
55 | ||
56 | DEFPY_HIDDEN (test_mlag, | |
57 | test_mlag_cmd, | |
58 | "test zebra mlag <none$none|primary$primary|secondary$secondary>", | |
59 | "Test code\n" | |
60 | ZEBRA_STR | |
61 | "Modify the Mlag state\n" | |
62 | "Mlag is not setup on the machine\n" | |
63 | "Mlag is setup to be primary\n" | |
64 | "Mlag is setup to be the secondary\n") | |
65 | { | |
b120fe3b DS |
66 | enum mlag_role orig = zrouter.mlag_info.role; |
67 | char buf1[80], buf2[80]; | |
68 | ||
763ec244 | 69 | if (none) |
e96ba9da | 70 | zrouter.mlag_info.role = MLAG_ROLE_NONE; |
763ec244 | 71 | if (primary) |
e96ba9da | 72 | zrouter.mlag_info.role = MLAG_ROLE_PRIMARY; |
763ec244 | 73 | if (secondary) |
e96ba9da | 74 | zrouter.mlag_info.role = MLAG_ROLE_SECONDARY; |
763ec244 | 75 | |
b120fe3b DS |
76 | if (IS_ZEBRA_DEBUG_MLAG) |
77 | zlog_debug("Test: Changing role from %s to %s", | |
78 | mlag_role2str(orig, buf1, sizeof(buf1)), | |
79 | mlag_role2str(orig, buf2, sizeof(buf2))); | |
80 | ||
81 | if (orig != zrouter.mlag_info.role) | |
82 | zsend_capabilities_all_clients(); | |
83 | ||
763ec244 DS |
84 | return CMD_SUCCESS; |
85 | } | |
86 | ||
df395600 DS |
87 | void zebra_mlag_init(void) |
88 | { | |
763ec244 DS |
89 | install_element(VIEW_NODE, &show_mlag_cmd); |
90 | install_element(ENABLE_NODE, &test_mlag_cmd); | |
df395600 DS |
91 | } |
92 | ||
93 | void zebra_mlag_terminate(void) | |
94 | { | |
95 | } |