diff options
author | David Lamparter <equinox@diac24.net> | 2019-06-21 08:33:17 +0200 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2019-06-21 08:54:25 +0200 |
commit | 7c136b081ed1ac70e1e04c26f36b977f01c55934 (patch) | |
tree | 87abaabe432f2d89eba0e27823b623010c211a63 /vrrpd | |
parent | lib: use MTYPE_STATIC (diff) | |
download | frr-7c136b081ed1ac70e1e04c26f36b977f01c55934.tar.xz frr-7c136b081ed1ac70e1e04c26f36b977f01c55934.zip |
vrrpd: use MTYPE_STATIC
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'vrrpd')
-rw-r--r-- | vrrpd/subdir.am | 2 | ||||
-rw-r--r-- | vrrpd/vrrp.c | 6 | ||||
-rw-r--r-- | vrrpd/vrrp.h | 3 | ||||
-rw-r--r-- | vrrpd/vrrp_main.c | 2 | ||||
-rw-r--r-- | vrrpd/vrrp_memory.c | 29 | ||||
-rw-r--r-- | vrrpd/vrrp_memory.h | 32 | ||||
-rw-r--r-- | vrrpd/vrrp_packet.c | 8 | ||||
-rw-r--r-- | vrrpd/vrrp_packet.h | 3 | ||||
-rw-r--r-- | vrrpd/vrrp_vty.c | 1 |
9 files changed, 19 insertions, 67 deletions
diff --git a/vrrpd/subdir.am b/vrrpd/subdir.am index a328f969d..57eec108c 100644 --- a/vrrpd/subdir.am +++ b/vrrpd/subdir.am @@ -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 \ diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c index 3d535cbfb..5213b27d3 100644 --- a/vrrpd/vrrp.c +++ b/vrrpd/vrrp.c @@ -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 diff --git a/vrrpd/vrrp.h b/vrrpd/vrrp.h index fd4901fe2..5d355d04b 100644 --- a/vrrpd/vrrp.h +++ b/vrrpd/vrrp.h @@ -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; diff --git a/vrrpd/vrrp_main.c b/vrrpd/vrrp_main.c index 46a92d936..6c6a06064 100644 --- a/vrrpd/vrrp_main.c +++ b/vrrpd/vrrp_main.c @@ -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[] = { diff --git a/vrrpd/vrrp_memory.c b/vrrpd/vrrp_memory.c deleted file mode 100644 index 30eef523c..000000000 --- a/vrrpd/vrrp_memory.c +++ /dev/null @@ -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"); diff --git a/vrrpd/vrrp_memory.h b/vrrpd/vrrp_memory.h deleted file mode 100644 index c3025d1ac..000000000 --- a/vrrpd/vrrp_memory.h +++ /dev/null @@ -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__ */ diff --git a/vrrpd/vrrp_packet.c b/vrrpd/vrrp_packet.c index c3f2afba4..c6b7ac1a7 100644 --- a/vrrpd/vrrp_packet.c +++ b/vrrpd/vrrp_packet.c @@ -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) diff --git a/vrrpd/vrrp_packet.h b/vrrpd/vrrp_packet.h index 475e4780d..c2ce22f00 100644 --- a/vrrpd/vrrp_packet.h +++ b/vrrpd/vrrp_packet.h @@ -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. * diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c index 48d81b025..2dc3d3f8a 100644 --- a/vrrpd/vrrp_vty.c +++ b/vrrpd/vrrp_vty.c @@ -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" |