Skip to content

Commit

Permalink
vrrpd: use MTYPE_STATIC
Browse files Browse the repository at this point in the history
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
  • Loading branch information
eqvinox committed Jun 21, 2019
1 parent eaf58ba commit 7c136b0
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 67 deletions.
2 changes: 0 additions & 2 deletions vrrpd/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down
6 changes: 4 additions & 2 deletions vrrpd/vrrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions vrrpd/vrrp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -54,6 +55,8 @@
/* User compatibility constant */
#define CS2MS 10

DECLARE_MGROUP(VRRPD)

/* Configured defaults */
struct vrrp_defaults {
uint8_t priority;
Expand Down
2 changes: 2 additions & 0 deletions vrrpd/vrrp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down
29 changes: 0 additions & 29 deletions vrrpd/vrrp_memory.c

This file was deleted.

32 changes: 0 additions & 32 deletions vrrpd/vrrp_memory.h

This file was deleted.

8 changes: 7 additions & 1 deletion vrrpd/vrrp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions vrrpd/vrrp_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
1 change: 0 additions & 1 deletion vrrpd/vrrp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7c136b0

Please sign in to comment.