Skip to content

Commit 087ad4a

Browse files
authored
Merge pull request #2572 from pqarmitage/updates
Fix recreating VMACs and adding IPv6 link local addresses
2 parents a9f973b + 7048b66 commit 087ad4a

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

keepalived/core/keepalived_netlink.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,7 @@ netlink_if_address_filter(__attribute__((unused)) struct sockaddr_nl *snl, struc
10311031
!__test_bit(VRRP_VMAC_XMITBASE_BIT, &vrrp->flags) &&
10321032
ifa->ifa_family == AF_INET6 &&
10331033
vrrp->ifp->is_ours) {
1034+
if (vrrp->saddr.ss_family == AF_UNSPEC) {
10341035
inet_ip6tosockaddr(addr.in6, &vrrp->saddr);
10351036
#if 0
10361037
if (IN6_IS_ADDR_UNSPECIFIED(&vrrp->ifp->sin6_addr)) {
@@ -1041,12 +1042,13 @@ netlink_if_address_filter(__attribute__((unused)) struct sockaddr_nl *snl, struc
10411042
* does not have one, then we will need the following code
10421043
*/
10431044
if (add_link_local_address(vrrp->ifp, addr.in6) &&
1044-
vrrp->flags_if_fault &&
1045+
vrrp->flags_if_fault &&
10451046
(!__test_bit(VRRP_FLAG_SADDR_FROM_CONFIG, &vrrp->flags) || is_tracking_saddr))
10461047
try_up_instance(vrrp, false, VRRP_FAULT_FL_NO_SOURCE_IP);
10471048
} else
10481049
#endif
1049-
reset_link_local_address(&vrrp->ifp->sin6_addr, vrrp);
1050+
reset_link_local_address(&vrrp->ifp->sin6_addr, vrrp);
1051+
}
10501052
}
10511053
#endif
10521054
}

keepalived/include/vrrp_sock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ typedef struct _sock {
4545
#ifdef _HAVE_VRF_
4646
const interface_t *vrf_ifp;
4747
#endif
48-
const sockaddr_t *unicast_src;
49-
const sockaddr_t *mcast_daddr;
48+
sockaddr_t *unicast_src;
49+
sockaddr_t *mcast_daddr;
5050
int fd_in;
5151
int fd_out;
5252
int rx_buf_size;

keepalived/vrrp/vrrp.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2774,26 +2774,22 @@ void
27742774
open_sockpool_socket(sock_t *sock)
27752775
{
27762776
vrrp_t *vrrp;
2777-
sockaddr_t unicast_src;
2778-
const sockaddr_t *unicast_src_p = sock->unicast_src;
27792777
bool already_fault;
27802778

27812779
if (sock->unicast_src &&
27822780
sock->unicast_src->ss_family == AF_INET6 &&
27832781
IN6_IS_ADDR_LINKLOCAL(&PTR_CAST_CONST(struct sockaddr_in6, sock->unicast_src)->sin6_addr)) {
27842782
/* For an IPv6 link local address, we need to set the ifindex */
2785-
unicast_src = *sock->unicast_src;
2786-
unicast_src_p = &unicast_src;
2787-
27882783
/* coverity[deref_param] - since the address is IPv6 link local, sock->ifp != NULL */
2789-
PTR_CAST(struct sockaddr_in6, &unicast_src)->sin6_scope_id = sock->ifp->ifindex;
2790-
}
2784+
PTR_CAST(struct sockaddr_in6, sock->unicast_src)->sin6_scope_id = sock->ifp->ifindex;
2785+
} else if (sock->mcast_daddr && sock->mcast_daddr->ss_family == AF_INET6)
2786+
PTR_CAST(struct sockaddr_in6, sock->mcast_daddr)->sin6_scope_id = sock->ifp->ifindex;
27912787

27922788
sock->fd_in = open_vrrp_read_socket(sock->family, sock->proto, sock->ifp,
27932789
#ifdef _HAVE_VRF_
27942790
sock->vrf_ifp,
27952791
#endif
2796-
sock->mcast_daddr, unicast_src_p, sock->rx_buf_size);
2792+
sock->mcast_daddr, sock->unicast_src, sock->rx_buf_size);
27972793

27982794
if (sock->fd_in == -2) {
27992795
rb_for_each_entry(vrrp, &sock->rb_vrid, rb_vrid) {
@@ -2814,7 +2810,7 @@ open_sockpool_socket(sock_t *sock)
28142810
#ifdef _HAVE_VRF_
28152811
sock->vrf_ifp,
28162812
#endif
2817-
unicast_src_p);
2813+
sock->unicast_src);
28182814
}
28192815

28202816
/* Try to find a VRRP instance */

keepalived/vrrp/vrrp_scheduler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ alloc_sock(list_head_t *l, sa_family_t family, int proto, interface_t *ifp,
455455
#ifdef _HAVE_VRF_
456456
const interface_t *vrf_ifp,
457457
#endif
458-
const sockaddr_t *mcast_daddr, const sockaddr_t *unicast_src)
458+
sockaddr_t *mcast_daddr, sockaddr_t *unicast_src)
459459
{
460460
sock_t *new;
461461

0 commit comments

Comments
 (0)