mirror of
				https://git.proxmox.com/git/mirror_frr
				synced 2025-10-31 03:30:07 +00:00 
			
		
		
		
	vrrpd: interface support
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
		
							parent
							
								
									0ae3b19ca6
								
							
						
					
					
						commit
						a8144d7fc8
					
				
							
								
								
									
										25
									
								
								vrrpd/vrrp.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								vrrpd/vrrp.c
									
									
									
									
									
								
							| @ -149,6 +149,7 @@ static int vrrp_socket(struct vrrp_vrouter *vr) | ||||
| { | ||||
| 	struct ip_mreqn req; | ||||
| 	int ret; | ||||
| 	struct connected *c; | ||||
| 
 | ||||
| 	vr->sock = socket(AF_INET, SOCK_RAW, IPPROTO_VRRP); | ||||
| 
 | ||||
| @ -159,7 +160,10 @@ static int vrrp_socket(struct vrrp_vrouter *vr) | ||||
| 	/* Join the multicast group.*/ | ||||
| 
 | ||||
| 	 /* FIXME: Use first address on the interface and for imr_interface */ | ||||
| 	struct connected *c = listhead(vr->ifp->connected)->data; | ||||
| 	if (!listcount(vr->ifp->connected)) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	c = listhead(vr->ifp->connected)->data; | ||||
| 	struct in_addr v4 = c->address->u.prefix4; | ||||
| 
 | ||||
| 	memset(&req, 0, sizeof(req)); | ||||
| @ -277,10 +281,14 @@ static int vrrp_master_down_timer_expire(struct thread *thread) | ||||
|  * vr | ||||
|  *    Virtual Router on which to apply Startup event | ||||
|  */ | ||||
| static void vrrp_startup(struct vrrp_vrouter *vr) | ||||
| static int vrrp_startup(struct vrrp_vrouter *vr) | ||||
| { | ||||
| 	/* Create socket */ | ||||
| 	vrrp_socket(vr); | ||||
| 	int ret = vrrp_socket(vr); | ||||
| 	if (ret < 0) { | ||||
| 		zlog_warn("Cannot create VRRP socket\n"); | ||||
| 		return ret; | ||||
| 	} | ||||
| 
 | ||||
| 	/* Schedule listener */ | ||||
| 	/* ... */ | ||||
| @ -301,14 +309,17 @@ static void vrrp_startup(struct vrrp_vrouter *vr) | ||||
| 				      &vr->t_master_down_timer); | ||||
| 		vrrp_change_state(vr, VRRP_STATE_BACKUP); | ||||
| 	} | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| static void vrrp_shutdown(struct vrrp_vrouter *vr) | ||||
| static int vrrp_shutdown(struct vrrp_vrouter *vr) | ||||
| { | ||||
| 	/* NOTHING */ | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| static void (*vrrp_event_handlers[])(struct vrrp_vrouter *vr) = { | ||||
| static int (*vrrp_event_handlers[])(struct vrrp_vrouter *vr) = { | ||||
| 	[VRRP_EVENT_STARTUP] = vrrp_startup, | ||||
| 	[VRRP_EVENT_SHUTDOWN] = vrrp_shutdown, | ||||
| }; | ||||
| @ -322,9 +333,9 @@ static void (*vrrp_event_handlers[])(struct vrrp_vrouter *vr) = { | ||||
|  * event | ||||
|  *    The event to spawn | ||||
|  */ | ||||
| void vrrp_event(struct vrrp_vrouter *vr, int event) | ||||
| int vrrp_event(struct vrrp_vrouter *vr, int event) | ||||
| { | ||||
| 	vrrp_event_handlers[event](vr); | ||||
| 	return vrrp_event_handlers[event](vr); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -135,7 +135,6 @@ struct vrrp_vrouter { | ||||
| #define VRRP_EVENT_SHUTDOWN 2 | ||||
| 
 | ||||
| DECLARE_HOOK(vrrp_change_state_hook, (struct vrrp_vrouter *vr, int to), (vr, to)); | ||||
| void vrrp_event(struct vrrp_vrouter *vr, int event); | ||||
| /* End state machine */ | ||||
| 
 | ||||
| 
 | ||||
| @ -157,6 +156,6 @@ struct vrrp_vrouter *vrrp_lookup(uint8_t vrid); | ||||
| /*
 | ||||
|  * Trigger VRRP event | ||||
|  */ | ||||
| void vrrp_event(struct vrrp_vrouter *vr, int event); | ||||
| int vrrp_event(struct vrrp_vrouter *vr, int event); | ||||
| 
 | ||||
| #endif /* _VRRP_H */ | ||||
|  | ||||
| @ -31,6 +31,7 @@ | ||||
| #include "vrf.h" | ||||
| #include "nexthop.h" | ||||
| #include "filter.h" | ||||
| #include "if.h" | ||||
| 
 | ||||
| #include "vrrp.h" | ||||
| #include "vrrp_zebra.h" | ||||
| @ -98,6 +99,7 @@ struct quagga_signal_t vrrp_signals[] = { | ||||
| }; | ||||
| 
 | ||||
| static const struct frr_yang_module_info *vrrp_yang_modules[] = { | ||||
| 	&frr_interface_info, | ||||
| }; | ||||
| 
 | ||||
| #define VRRP_VTY_PORT 2617 | ||||
|  | ||||
| @ -61,7 +61,11 @@ DEFUN(vrrp_vrid, | ||||
| 	vrid = strtoul(argv[idx]->arg, NULL, 10); | ||||
| 
 | ||||
| 	struct vrrp_vrouter *vr = vrrp_vrouter_create(ifp, vrid); | ||||
| 	vrrp_event(vr, VRRP_EVENT_STARTUP); | ||||
| 	int ret = vrrp_event(vr, VRRP_EVENT_STARTUP); | ||||
| 	if (ret < 0) { | ||||
| 		vty_out(vty, "%% Failed to start VRRP instance\n"); | ||||
| 		return CMD_WARNING_CONFIG_FAILED; | ||||
| 	} | ||||
| 
 | ||||
| 	return CMD_SUCCESS; | ||||
| } | ||||
| @ -76,5 +80,6 @@ void vrrp_vty_init(void) | ||||
| 	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); | ||||
| } | ||||
|  | ||||
| @ -137,6 +137,7 @@ struct vtysh_client vtysh_client[] = { | ||||
| 	{.fd = -1, .name = "pbrd", .flag = VTYSH_PBRD, .next = NULL}, | ||||
| 	{.fd = -1, .name = "staticd", .flag = VTYSH_STATICD, .next = NULL}, | ||||
| 	{.fd = -1, .name = "bfdd", .flag = VTYSH_BFDD, .next = NULL}, | ||||
| 	{.fd = -1, .name = "vrrpd", .flag = VTYSH_VRRPD, .next = NULL}, | ||||
| }; | ||||
| 
 | ||||
| enum vtysh_write_integrated vtysh_write_integrated = | ||||
|  | ||||
| @ -51,9 +51,9 @@ DECLARE_MGROUP(MVTYSH) | ||||
| /* watchfrr is not in ALL since library CLI functions should not be
 | ||||
|  * run on it (logging & co. should stay in a fixed/frozen config, and | ||||
|  * things like prefix lists are not even initialised) */ | ||||
| #define VTYSH_ALL	  VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_SHARPD|VTYSH_PBRD|VTYSH_STATICD|VTYSH_BFDD|VTYSH_FABRICD | ||||
| #define VTYSH_ALL	  VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_SHARPD|VTYSH_PBRD|VTYSH_STATICD|VTYSH_BFDD|VTYSH_FABRICD|VTYSH_VRRPD | ||||
| #define VTYSH_RMAP	  VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_SHARPD|VTYSH_FABRICD | ||||
| #define VTYSH_INTERFACE	  VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_PBRD|VTYSH_FABRICD | ||||
| #define VTYSH_INTERFACE	  VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_PBRD|VTYSH_FABRICD|VTYSH_VRRPD | ||||
| #define VTYSH_NS          VTYSH_ZEBRA | ||||
| #define VTYSH_VRF	  VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_STATICD | ||||
| #define VTYSH_KEYS        VTYSH_RIPD|VTYSH_EIGRPD | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Quentin Young
						Quentin Young