Skip to content

Commit 3691c9d

Browse files
authored
Merge pull request #9990 from FRRouting/mergify/bp/stable/8.1/pr-9972
bfdd,bgpd: fix some integration bugs (backport #9972)
2 parents 41adf5b + 3795733 commit 3691c9d

File tree

4 files changed

+67
-22
lines changed

4 files changed

+67
-22
lines changed

bgpd/bgp_bfd.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ void bgp_peer_config_apply(struct peer *p, struct peer_group *pg)
150150
void bgp_peer_bfd_update_source(struct peer *p)
151151
{
152152
struct bfd_session_params *session = p->bfd_config->session;
153+
const union sockunion *source;
153154
bool changed = false;
154155
int family;
155156
union {
@@ -161,44 +162,45 @@ void bgp_peer_bfd_update_source(struct peer *p)
161162
if (CHECK_FLAG(p->sflags, PEER_STATUS_GROUP))
162163
return;
163164

165+
/* Figure out the correct source to use. */
166+
if (CHECK_FLAG(p->flags, PEER_FLAG_UPDATE_SOURCE))
167+
source = p->update_source;
168+
else
169+
source = p->su_local;
170+
164171
/* Update peer's source/destination addresses. */
165172
bfd_sess_addresses(session, &family, &src.v6, &dst.v6);
166173
if (family == AF_INET) {
167-
if ((p->su_local
168-
&& p->su_local->sin.sin_addr.s_addr != src.v4.s_addr)
174+
if ((source && source->sin.sin_addr.s_addr != src.v4.s_addr)
169175
|| p->su.sin.sin_addr.s_addr != dst.v4.s_addr) {
170176
if (BGP_DEBUG(bfd, BFD_LIB))
171177
zlog_debug(
172178
"%s: address [%pI4->%pI4] to [%pI4->%pI4]",
173179
__func__, &src.v4, &dst.v4,
174-
p->su_local ? &p->su_local->sin.sin_addr
175-
: &src.v4,
180+
source ? &source->sin.sin_addr
181+
: &src.v4,
176182
&p->su.sin.sin_addr);
177183

178184
bfd_sess_set_ipv4_addrs(
179-
session,
180-
p->su_local ? &p->su_local->sin.sin_addr : NULL,
185+
session, source ? &source->sin.sin_addr : NULL,
181186
&p->su.sin.sin_addr);
182187
changed = true;
183188
}
184189
} else {
185-
if ((p->su_local
186-
&& memcmp(&p->su_local->sin6, &src.v6, sizeof(src.v6)))
190+
if ((source && memcmp(&source->sin6, &src.v6, sizeof(src.v6)))
187191
|| memcmp(&p->su.sin6, &dst.v6, sizeof(dst.v6))) {
188192
if (BGP_DEBUG(bfd, BFD_LIB))
189193
zlog_debug(
190194
"%s: address [%pI6->%pI6] to [%pI6->%pI6]",
191195
__func__, &src.v6, &dst.v6,
192-
p->su_local
193-
? &p->su_local->sin6.sin6_addr
194-
: &src.v6,
196+
source ? &source->sin6.sin6_addr
197+
: &src.v6,
195198
&p->su.sin6.sin6_addr);
196199

197-
bfd_sess_set_ipv6_addrs(
198-
session,
199-
p->su_local ? &p->su_local->sin6.sin6_addr
200-
: NULL,
201-
&p->su.sin6.sin6_addr);
200+
bfd_sess_set_ipv6_addrs(session,
201+
source ? &source->sin6.sin6_addr
202+
: NULL,
203+
&p->su.sin6.sin6_addr);
202204
changed = true;
203205
}
204206
}

bgpd/bgpd.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4751,6 +4751,10 @@ int peer_ebgp_multihop_set(struct peer *peer, int ttl)
47514751
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
47524752
else
47534753
bgp_session_reset(peer);
4754+
4755+
/* Reconfigure BFD peer with new TTL. */
4756+
if (peer->bfd_config)
4757+
bgp_peer_bfd_update_source(peer);
47544758
}
47554759
} else {
47564760
group = peer->group;
@@ -4765,6 +4769,10 @@ int peer_ebgp_multihop_set(struct peer *peer, int ttl)
47654769
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
47664770
else
47674771
bgp_session_reset(peer);
4772+
4773+
/* Reconfigure BFD peer with new TTL. */
4774+
if (peer->bfd_config)
4775+
bgp_peer_bfd_update_source(peer);
47684776
}
47694777
}
47704778
return 0;
@@ -4798,6 +4806,10 @@ int peer_ebgp_multihop_unset(struct peer *peer)
47984806
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
47994807
else
48004808
bgp_session_reset(peer);
4809+
4810+
/* Reconfigure BFD peer with new TTL. */
4811+
if (peer->bfd_config)
4812+
bgp_peer_bfd_update_source(peer);
48014813
} else {
48024814
group = peer->group;
48034815
for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
@@ -4814,6 +4826,10 @@ int peer_ebgp_multihop_unset(struct peer *peer)
48144826
else
48154827
bgp_session_reset(peer);
48164828
}
4829+
4830+
/* Reconfigure BFD peer with new TTL. */
4831+
if (peer->bfd_config)
4832+
bgp_peer_bfd_update_source(peer);
48174833
}
48184834
}
48194835
return 0;
@@ -4859,6 +4875,10 @@ int peer_update_source_if_set(struct peer *peer, const char *ifname)
48594875
} else
48604876
bgp_session_reset(peer);
48614877

4878+
/* Apply new source configuration to BFD session. */
4879+
if (peer->bfd_config)
4880+
bgp_peer_bfd_update_source(peer);
4881+
48624882
/* Skip peer-group mechanics for regular peers. */
48634883
return 0;
48644884
}
@@ -4892,6 +4912,10 @@ int peer_update_source_if_set(struct peer *peer, const char *ifname)
48924912
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
48934913
} else
48944914
bgp_session_reset(member);
4915+
4916+
/* Apply new source configuration to BFD session. */
4917+
if (member->bfd_config)
4918+
bgp_peer_bfd_update_source(member);
48954919
}
48964920

48974921
return 0;
@@ -4922,6 +4946,10 @@ int peer_update_source_addr_set(struct peer *peer, const union sockunion *su)
49224946
} else
49234947
bgp_session_reset(peer);
49244948

4949+
/* Apply new source configuration to BFD session. */
4950+
if (peer->bfd_config)
4951+
bgp_peer_bfd_update_source(peer);
4952+
49254953
/* Skip peer-group mechanics for regular peers. */
49264954
return 0;
49274955
}
@@ -4954,6 +4982,10 @@ int peer_update_source_addr_set(struct peer *peer, const union sockunion *su)
49544982
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
49554983
} else
49564984
bgp_session_reset(member);
4985+
4986+
/* Apply new source configuration to BFD session. */
4987+
if (member->bfd_config)
4988+
bgp_peer_bfd_update_source(member);
49574989
}
49584990

49594991
return 0;
@@ -4991,6 +5023,10 @@ int peer_update_source_unset(struct peer *peer)
49915023
} else
49925024
bgp_session_reset(peer);
49935025

5026+
/* Apply new source configuration to BFD session. */
5027+
if (peer->bfd_config)
5028+
bgp_peer_bfd_update_source(peer);
5029+
49945030
/* Skip peer-group mechanics for regular peers. */
49955031
return 0;
49965032
}
@@ -5022,6 +5058,10 @@ int peer_update_source_unset(struct peer *peer)
50225058
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
50235059
} else
50245060
bgp_session_reset(member);
5061+
5062+
/* Apply new source configuration to BFD session. */
5063+
if (member->bfd_config)
5064+
bgp_peer_bfd_update_source(member);
50255065
}
50265066

50275067
return 0;

lib/bfd.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ static bool bfd_sess_address_changed(const struct bfd_session_params *bsp,
552552
}
553553

554554
void bfd_sess_set_ipv4_addrs(struct bfd_session_params *bsp,
555-
struct in_addr *src, struct in_addr *dst)
555+
const struct in_addr *src,
556+
const struct in_addr *dst)
556557
{
557558
if (!bfd_sess_address_changed(bsp, AF_INET, (struct in6_addr *)src,
558559
(struct in6_addr *)dst))
@@ -576,10 +577,10 @@ void bfd_sess_set_ipv4_addrs(struct bfd_session_params *bsp,
576577
}
577578

578579
void bfd_sess_set_ipv6_addrs(struct bfd_session_params *bsp,
579-
struct in6_addr *src, struct in6_addr *dst)
580+
const struct in6_addr *src,
581+
const struct in6_addr *dst)
580582
{
581-
if (!bfd_sess_address_changed(bsp, AF_INET, (struct in6_addr *)src,
582-
(struct in6_addr *)dst))
583+
if (!bfd_sess_address_changed(bsp, AF_INET6, src, dst))
583584
return;
584585

585586
/* If already installed, remove the old setting. */

lib/bfd.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ void bfd_sess_free(struct bfd_session_params **bsp);
124124
* \param dst remote address (mandatory).
125125
*/
126126
void bfd_sess_set_ipv4_addrs(struct bfd_session_params *bsp,
127-
struct in_addr *src, struct in_addr *dst);
127+
const struct in_addr *src,
128+
const struct in_addr *dst);
128129

129130
/**
130131
* Set the local and peer address of the BFD session.
@@ -138,7 +139,8 @@ void bfd_sess_set_ipv4_addrs(struct bfd_session_params *bsp,
138139
* \param dst remote address (mandatory).
139140
*/
140141
void bfd_sess_set_ipv6_addrs(struct bfd_session_params *bsp,
141-
struct in6_addr *src, struct in6_addr *dst);
142+
const struct in6_addr *src,
143+
const struct in6_addr *dst);
142144

143145
/**
144146
* Configure the BFD session interface.

0 commit comments

Comments
 (0)