*/
#include <zebra.h>
-#include "memory.h"
-#include "if.h"
-#include "linklist.h"
-#include "prefix.h"
-#include "hash.h"
-#include "vrf.h"
-#include "hook.h"
+#include "lib/memory.h"
+#include "lib/if.h"
+#include "lib/linklist.h"
+#include "lib/prefix.h"
+#include "lib/hash.h"
+#include "lib/vrf.h"
+#include "lib/hook.h"
#include "vrrp.h"
+#include "vrrp_arp.h"
/* Utility functions ------------------------------------------------------- */
int ret;
struct connected *c;
- vr->sock = socket(AF_INET, SOCK_RAW, IPPROTO_VRRP);
-
- if (vr->sock < 0) {
- /* FIXME */
+ errno = 0;
+ frr_elevate_privs(&vrrp_privs) {
+ vr->sock = socket(AF_INET, SOCK_RAW, IPPROTO_VRRP);
}
+ if (vr->sock < 0)
+ perror("Error opening VRRP socket");
+
/* Join the multicast group.*/
/* FIXME: Use first address on the interface and for imr_interface */
*/
static int vrrp_startup(struct vrrp_vrouter *vr)
{
+ /* Initialize global gratuitous ARP socket if necessary */
+ if (!vrrp_garp_is_init())
+ vrrp_garp_init();
+
/* Create socket */
int ret = vrrp_socket(vr);
if (ret < 0) {
if (vr->priority == VRRP_PRIO_MASTER) {
vrrp_send_advertisement(vr);
- /* FIXME: vrrp_send_gratuitous_arp(vr); */
+ /* vrrp_garp_send(vr); */
thread_add_timer_msec(master, vrrp_adver_timer_expire, vr,
vr->advertisement_interval * 10,
{
/* Create the socket descriptor */
/* FIXME: why ETH_P_RARP? */
- garp_fd = socket(PF_PACKET, SOCK_RAW | SOCK_CLOEXEC, htons(ETH_P_RARP));
+ errno = 0;
+ frr_elevate_privs(&vrrp_privs) {
+ garp_fd = socket(PF_PACKET, SOCK_RAW | SOCK_CLOEXEC,
+ htons(ETH_P_RARP));
+ }
if (garp_fd > 0)
zlog_info("Initialized gratuitous ARP socket");
else {
+ perror("Error initializing gratuitous ARP socket");
zlog_err("Error initializing gratuitous ARP socket");
return;
}
close(garp_fd);
garp_fd = -1;
}
+
+bool vrrp_garp_is_init(void)
+{
+ return garp_fd > 0;
+}
/* prototypes */
extern void vrrp_garp_init(void);
extern void vrrp_garp_fini(void);
+extern bool vrrp_garp_is_init(void);
extern void vrrp_garp_send(struct vrrp_vrouter *vr, struct in_addr *v4);
extern void vrrp_garp_send_all(struct vrrp_vrouter *vr);
#endif
char backup_config_file[256];
zebra_capabilities_t _caps_p[] = {
+ ZCAP_NET_RAW,
};
struct zebra_privs_t vrrp_privs = {
install_node(&interface_node, NULL);
if_cmd_init();
install_element(VIEW_NODE, &show_debugging_vrrpd_cmd);
- install_element(ENABLE_NODE, &show_debugging_vrrpd_cmd);
install_element(INTERFACE_NODE, &vrrp_vrid_cmd);
}