mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 00:25:01 +00:00
vrrpd: get sockets working
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
b6029d6a5f
commit
4074400076
31
vrrpd/vrrp.c
31
vrrpd/vrrp.c
@ -19,15 +19,16 @@
|
|||||||
*/
|
*/
|
||||||
#include <zebra.h>
|
#include <zebra.h>
|
||||||
|
|
||||||
#include "memory.h"
|
#include "lib/memory.h"
|
||||||
#include "if.h"
|
#include "lib/if.h"
|
||||||
#include "linklist.h"
|
#include "lib/linklist.h"
|
||||||
#include "prefix.h"
|
#include "lib/prefix.h"
|
||||||
#include "hash.h"
|
#include "lib/hash.h"
|
||||||
#include "vrf.h"
|
#include "lib/vrf.h"
|
||||||
#include "hook.h"
|
#include "lib/hook.h"
|
||||||
|
|
||||||
#include "vrrp.h"
|
#include "vrrp.h"
|
||||||
|
#include "vrrp_arp.h"
|
||||||
|
|
||||||
/* Utility functions ------------------------------------------------------- */
|
/* Utility functions ------------------------------------------------------- */
|
||||||
|
|
||||||
@ -151,12 +152,14 @@ static int vrrp_socket(struct vrrp_vrouter *vr)
|
|||||||
int ret;
|
int ret;
|
||||||
struct connected *c;
|
struct connected *c;
|
||||||
|
|
||||||
vr->sock = socket(AF_INET, SOCK_RAW, IPPROTO_VRRP);
|
errno = 0;
|
||||||
|
frr_elevate_privs(&vrrp_privs) {
|
||||||
if (vr->sock < 0) {
|
vr->sock = socket(AF_INET, SOCK_RAW, IPPROTO_VRRP);
|
||||||
/* FIXME */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vr->sock < 0)
|
||||||
|
perror("Error opening VRRP socket");
|
||||||
|
|
||||||
/* Join the multicast group.*/
|
/* Join the multicast group.*/
|
||||||
|
|
||||||
/* FIXME: Use first address on the interface and for imr_interface */
|
/* FIXME: Use first address on the interface and for imr_interface */
|
||||||
@ -283,6 +286,10 @@ static int vrrp_master_down_timer_expire(struct thread *thread)
|
|||||||
*/
|
*/
|
||||||
static int vrrp_startup(struct vrrp_vrouter *vr)
|
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 */
|
/* Create socket */
|
||||||
int ret = vrrp_socket(vr);
|
int ret = vrrp_socket(vr);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -295,7 +302,7 @@ static int vrrp_startup(struct vrrp_vrouter *vr)
|
|||||||
|
|
||||||
if (vr->priority == VRRP_PRIO_MASTER) {
|
if (vr->priority == VRRP_PRIO_MASTER) {
|
||||||
vrrp_send_advertisement(vr);
|
vrrp_send_advertisement(vr);
|
||||||
/* FIXME: vrrp_send_gratuitous_arp(vr); */
|
/* vrrp_garp_send(vr); */
|
||||||
|
|
||||||
thread_add_timer_msec(master, vrrp_adver_timer_expire, vr,
|
thread_add_timer_msec(master, vrrp_adver_timer_expire, vr,
|
||||||
vr->advertisement_interval * 10,
|
vr->advertisement_interval * 10,
|
||||||
|
@ -163,11 +163,16 @@ void vrrp_garp_init(void)
|
|||||||
{
|
{
|
||||||
/* Create the socket descriptor */
|
/* Create the socket descriptor */
|
||||||
/* FIXME: why ETH_P_RARP? */
|
/* 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)
|
if (garp_fd > 0)
|
||||||
zlog_info("Initialized gratuitous ARP socket");
|
zlog_info("Initialized gratuitous ARP socket");
|
||||||
else {
|
else {
|
||||||
|
perror("Error initializing gratuitous ARP socket");
|
||||||
zlog_err("Error initializing gratuitous ARP socket");
|
zlog_err("Error initializing gratuitous ARP socket");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -178,3 +183,8 @@ void vrrp_garp_fini(void)
|
|||||||
close(garp_fd);
|
close(garp_fd);
|
||||||
garp_fd = -1;
|
garp_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool vrrp_garp_is_init(void)
|
||||||
|
{
|
||||||
|
return garp_fd > 0;
|
||||||
|
}
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
/* prototypes */
|
/* prototypes */
|
||||||
extern void vrrp_garp_init(void);
|
extern void vrrp_garp_init(void);
|
||||||
extern void vrrp_garp_fini(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(struct vrrp_vrouter *vr, struct in_addr *v4);
|
||||||
extern void vrrp_garp_send_all(struct vrrp_vrouter *vr);
|
extern void vrrp_garp_send_all(struct vrrp_vrouter *vr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
char backup_config_file[256];
|
char backup_config_file[256];
|
||||||
|
|
||||||
zebra_capabilities_t _caps_p[] = {
|
zebra_capabilities_t _caps_p[] = {
|
||||||
|
ZCAP_NET_RAW,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct zebra_privs_t vrrp_privs = {
|
struct zebra_privs_t vrrp_privs = {
|
||||||
|
@ -80,6 +80,5 @@ void vrrp_vty_init(void)
|
|||||||
install_node(&interface_node, NULL);
|
install_node(&interface_node, NULL);
|
||||||
if_cmd_init();
|
if_cmd_init();
|
||||||
install_element(VIEW_NODE, &show_debugging_vrrpd_cmd);
|
install_element(VIEW_NODE, &show_debugging_vrrpd_cmd);
|
||||||
install_element(ENABLE_NODE, &show_debugging_vrrpd_cmd);
|
|
||||||
install_element(INTERFACE_NODE, &vrrp_vrid_cmd);
|
install_element(INTERFACE_NODE, &vrrp_vrid_cmd);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user