vrrpd: use MTYPE_STATIC

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2019-06-21 08:33:17 +02:00
parent eaf58ba906
commit 7c136b081e
9 changed files with 19 additions and 67 deletions

View File

@ -14,7 +14,6 @@ vrrpd_libvrrp_a_SOURCES = \
vrrpd/vrrp.c \
vrrpd/vrrp_arp.c \
vrrpd/vrrp_debug.c \
vrrpd/vrrp_memory.c \
vrrpd/vrrp_ndisc.c \
vrrpd/vrrp_packet.c \
vrrpd/vrrp_vty.c \
@ -25,7 +24,6 @@ noinst_HEADERS += \
vrrpd/vrrp.h \
vrrpd/vrrp_arp.h \
vrrpd/vrrp_debug.h \
vrrpd/vrrp_memory.h \
vrrpd/vrrp_ndisc.h \
vrrpd/vrrp_packet.h \
vrrpd/vrrp_vty.h \

View File

@ -34,13 +34,15 @@
#include "vrrp.h"
#include "vrrp_arp.h"
#include "vrrp_debug.h"
#include "vrrp_memory.h"
#include "vrrp_ndisc.h"
#include "vrrp_packet.h"
#include "vrrp_zebra.h"
#define VRRP_LOGPFX "[CORE] "
DEFINE_MTYPE_STATIC(VRRPD, VRRP_IP, "VRRP IP address")
DEFINE_MTYPE_STATIC(VRRPD, VRRP_RTR, "VRRP Router")
/* statics */
struct hash *vrrp_vrouters_hash;
bool vrrp_autoconfig_is_on;
@ -768,7 +770,7 @@ static void vrrp_send_advertisement(struct vrrp_router *r)
ssize_t sent = sendto(r->sock_tx, pkt, (size_t)pktsz, 0, &dest.sa,
sockunion_sizeof(&dest));
XFREE(MTYPE_VRRP_PKT, pkt);
vrrp_pkt_free(pkt);
if (sent < 0) {
zlog_warn(VRRP_LOGPFX VRRP_LOGPFX_VRID VRRP_LOGPFX_FAM

View File

@ -23,6 +23,7 @@
#include <zebra.h>
#include <netinet/ip.h>
#include "lib/memory.h"
#include "lib/hash.h"
#include "lib/hook.h"
#include "lib/if.h"
@ -54,6 +55,8 @@
/* User compatibility constant */
#define CS2MS 10
DECLARE_MGROUP(VRRPD)
/* Configured defaults */
struct vrrp_defaults {
uint8_t priority;

View File

@ -39,6 +39,8 @@
#include "vrrp_vty.h"
#include "vrrp_zebra.h"
DEFINE_MGROUP(VRRPD, "vrrpd")
char backup_config_file[256];
zebra_capabilities_t _caps_p[] = {

View File

@ -1,29 +0,0 @@
/*
* VRRP memory types.
* Copyright (C) 2018-2019 Cumulus Networks, Inc.
* Quentin Young
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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
*/
#include <zebra.h>
#include "lib/memory.h"
#include "vrrp_memory.h"
DEFINE_MGROUP(VRRPD, "vrrpd");
DEFINE_MTYPE(VRRPD, VRRP_IP, "VRRP IP address");
DEFINE_MTYPE(VRRPD, VRRP_PKT, "VRRP packet");
DEFINE_MTYPE(VRRPD, VRRP_RTR, "VRRP Router");

View File

@ -1,32 +0,0 @@
/*
* VRRP memory types.
* Copyright (C) 2018-2019 Cumulus Networks, Inc.
* Quentin Young
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 __VRRP_MEMORY_H__
#define __VRRP_MEMORY_H__
#include <zebra.h>
#include "lib/memory.h"
DECLARE_MGROUP(VRRPD);
DECLARE_MTYPE(VRRP_IP);
DECLARE_MTYPE(VRRP_PKT);
DECLARE_MTYPE(VRRP_RTR);
#endif /* __VRRP_MEMORY_H__ */

View File

@ -28,9 +28,10 @@
#include "vrrp.h"
#include "vrrp_debug.h"
#include "vrrp_memory.h"
#include "vrrp_packet.h"
DEFINE_MTYPE_STATIC(VRRPD, VRRP_PKT, "VRRP packet")
/* clang-format off */
const char *vrrp_packet_names[16] = {
[0] = "Unknown",
@ -151,6 +152,11 @@ ssize_t vrrp_pkt_adver_build(struct vrrp_pkt **pkt, struct ipaddr *src,
return pktsize;
}
void vrrp_pkt_free(struct vrrp_pkt *pkt)
{
XFREE(MTYPE_VRRP_PKT, pkt);
}
size_t vrrp_pkt_adver_dump(char *buf, size_t buflen, struct vrrp_pkt *pkt)
{
if (buflen < 1)

View File

@ -135,6 +135,9 @@ ssize_t vrrp_pkt_adver_build(struct vrrp_pkt **pkt, struct ipaddr *src,
uint16_t max_adver_int, uint8_t numip,
struct ipaddr **ips);
/* free memory allocated by vrrp_pkt_adver_build's pkt arg */
void vrrp_pkt_free(struct vrrp_pkt *pkt);
/*
* Dumps a VRRP ADVERTISEMENT packet to a string.
*

View File

@ -29,7 +29,6 @@
#include "vrrp.h"
#include "vrrp_debug.h"
#include "vrrp_memory.h"
#include "vrrp_vty.h"
#ifndef VTYSH_EXTRACT_PL
#include "vrrpd/vrrp_vty_clippy.c"