Skip to content

Commit

Permalink
sharpd: Add start of global data structures
Browse files Browse the repository at this point in the history
We have a bit of a mess with globals in the sharp daemon.
Let's start formalizing it a bit.  Future commits will
take advantage of this, as that we need to have the ability
to start dumping stats about commands we have issued.

These changes will be useful for debugging and understanding
what is going on.

Signed-off-by: Donald sharp <sharpd@cumulusnetworks.com>
  • Loading branch information
donaldsharp committed Feb 7, 2019
1 parent a60ffbc commit d21f1a9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
28 changes: 28 additions & 0 deletions sharpd/sharp_globals.h
@@ -0,0 +1,28 @@
/*
* SHARP - code to track globals
* Copyright (C) 2019 Cumulus Networks, Inc.
* Donald Sharp
*
* This file is part of FRR.
*
* FRR 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.
*
* FRR 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
*/
#ifndef __SHARP_GLOBAL_H__
#define __SHARP_GLOBAL_H__

struct sharp_global {
};

#endif
10 changes: 9 additions & 1 deletion sharpd/sharp_main.c
Expand Up @@ -46,6 +46,7 @@

#include "sharp_zebra.h"
#include "sharp_vty.h"
#include "sharp_globals.h"

uint32_t total_routes = 0;
uint32_t installed_routes = 0;
Expand Down Expand Up @@ -125,7 +126,12 @@ FRR_DAEMON_INFO(sharpd, SHARP, .vty_port = SHARP_VTY_PORT,
.privs = &sharp_privs, .yang_modules = sharpd_yang_modules,
.n_yang_modules = array_size(sharpd_yang_modules), )

extern void sharp_vty_init(void);
struct sharp_global sg;

static void sharp_global_init(void)
{
memset(&sg, 0, sizeof(sg));
}

int main(int argc, char **argv, char **envp)
{
Expand All @@ -151,6 +157,8 @@ int main(int argc, char **argv, char **envp)

master = frr_init();

sharp_global_init();

nexthop_group_init(NULL, NULL, NULL, NULL);
vrf_init(NULL, NULL, NULL, NULL, NULL);

Expand Down
1 change: 1 addition & 0 deletions sharpd/subdir.am
Expand Up @@ -17,6 +17,7 @@ sharpd_libsharp_a_SOURCES = \

noinst_HEADERS += \
sharpd/sharp_vty.h \
sharpd/sharp_globals.h \
sharpd/sharp_zebra.h \
# end

Expand Down

0 comments on commit d21f1a9

Please sign in to comment.