mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 10:14:50 +00:00
vrrpd: make vrrp_[add|del]_ip not insane
For some reason I made these functions require you to pass the correct (v4 or v6) router when we could determine it from the type of address passed; fix this Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
0dcbec72aa
commit
671fd2a318
19
vrrpd/vrrp.c
19
vrrpd/vrrp.c
@ -397,9 +397,10 @@ static bool vrrp_has_ip(struct vrrp_vrouter *vr, struct ipaddr *ip)
|
||||
return false;
|
||||
}
|
||||
|
||||
int vrrp_add_ip(struct vrrp_router *r, struct ipaddr *ip)
|
||||
int vrrp_add_ip(struct vrrp_vrouter *vr, struct ipaddr *ip)
|
||||
{
|
||||
int af = (ip->ipa_type == IPADDR_V6) ? AF_INET6 : AF_INET;
|
||||
struct vrrp_router *r = IS_IPADDR_V4(ip) ? vr->v4 : vr->v6;
|
||||
int af = r->family;
|
||||
|
||||
assert(r->family == af);
|
||||
assert(!(r->vr->version == 2 && ip->ipa_type == IPADDR_V6));
|
||||
@ -443,7 +444,7 @@ int vrrp_add_ipv4(struct vrrp_vrouter *vr, struct in_addr v4)
|
||||
|
||||
ip.ipa_type = IPADDR_V4;
|
||||
ip.ipaddr_v4 = v4;
|
||||
return vrrp_add_ip(vr->v4, &ip);
|
||||
return vrrp_add_ip(vr, &ip);
|
||||
}
|
||||
|
||||
int vrrp_add_ipv6(struct vrrp_vrouter *vr, struct in6_addr v6)
|
||||
@ -454,15 +455,19 @@ int vrrp_add_ipv6(struct vrrp_vrouter *vr, struct in6_addr v6)
|
||||
|
||||
ip.ipa_type = IPADDR_V6;
|
||||
ip.ipaddr_v6 = v6;
|
||||
return vrrp_add_ip(vr->v6, &ip);
|
||||
return vrrp_add_ip(vr, &ip);
|
||||
}
|
||||
|
||||
int vrrp_del_ip(struct vrrp_router *r, struct ipaddr *ip)
|
||||
|
||||
|
||||
int vrrp_del_ip(struct vrrp_vrouter *vr, struct ipaddr *ip)
|
||||
{
|
||||
struct listnode *ln, *nn;
|
||||
struct ipaddr *iter;
|
||||
int ret = 0;
|
||||
|
||||
struct vrrp_router *r = IS_IPADDR_V4(ip) ? vr->v4 : vr->v6;
|
||||
|
||||
if (!vrrp_has_ip(r->vr, ip))
|
||||
return 0;
|
||||
|
||||
@ -488,7 +493,7 @@ int vrrp_del_ipv6(struct vrrp_vrouter *vr, struct in6_addr v6)
|
||||
|
||||
ip.ipa_type = IPADDR_V6;
|
||||
ip.ipaddr_v6 = v6;
|
||||
return vrrp_del_ip(vr->v6, &ip);
|
||||
return vrrp_del_ip(vr, &ip);
|
||||
}
|
||||
|
||||
int vrrp_del_ipv4(struct vrrp_vrouter *vr, struct in_addr v4)
|
||||
@ -497,7 +502,7 @@ int vrrp_del_ipv4(struct vrrp_vrouter *vr, struct in_addr v4)
|
||||
|
||||
ip.ipa_type = IPADDR_V4;
|
||||
ip.ipaddr_v4 = v4;
|
||||
return vrrp_del_ip(vr->v4, &ip);
|
||||
return vrrp_del_ip(vr, &ip);
|
||||
}
|
||||
|
||||
|
||||
|
@ -340,7 +340,7 @@ void vrrp_set_advertisement_interval(struct vrrp_vrouter *vr,
|
||||
/*
|
||||
* Add an IPvX address to a VRRP Virtual Router.
|
||||
*
|
||||
* r
|
||||
* vr
|
||||
* Virtual Router to add IPvx address to
|
||||
*
|
||||
* ip
|
||||
@ -354,7 +354,7 @@ void vrrp_set_advertisement_interval(struct vrrp_vrouter *vr,
|
||||
* -1 on error
|
||||
* 0 otherwise
|
||||
*/
|
||||
int vrrp_add_ip(struct vrrp_router *r, struct ipaddr *ip);
|
||||
int vrrp_add_ip(struct vrrp_vrouter *vr, struct ipaddr *ip);
|
||||
|
||||
/*
|
||||
* Add an IPv4 address to a VRRP Virtual Router.
|
||||
@ -397,7 +397,7 @@ int vrrp_add_ipv6(struct vrrp_vrouter *vr, struct in6_addr v6);
|
||||
/*
|
||||
* Remove an IP address from a VRRP Virtual Router.
|
||||
*
|
||||
* r
|
||||
* vr
|
||||
* Virtual Router to remove IP address from
|
||||
*
|
||||
* ip
|
||||
@ -413,7 +413,7 @@ int vrrp_add_ipv6(struct vrrp_vrouter *vr, struct in6_addr v6);
|
||||
* -1 on error
|
||||
* 0 otherwise
|
||||
*/
|
||||
int vrrp_del_ip(struct vrrp_router *r, struct ipaddr *ip);
|
||||
int vrrp_del_ip(struct vrrp_vrouter *vr, struct ipaddr *ip);
|
||||
|
||||
/*
|
||||
* Remove an IPv4 address from a VRRP Virtual Router.
|
||||
|
Loading…
Reference in New Issue
Block a user