mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
BFD: Fixes crash after socket error
Thanks to Thomas King for the bugreport.
This commit is contained in:
parent
a8ad8fd649
commit
ffa398b8d8
@ -43,7 +43,7 @@
|
|||||||
* the needs of BFD sessions. When a new session is created, it requests a
|
* the needs of BFD sessions. When a new session is created, it requests a
|
||||||
* proper BFD interface by function bfd_get_iface(), which either finds an
|
* proper BFD interface by function bfd_get_iface(), which either finds an
|
||||||
* existing one in &iface_list (from &bfd_proto) or allocates a new one. When a
|
* existing one in &iface_list (from &bfd_proto) or allocates a new one. When a
|
||||||
* session is removed, an associated iface is dicharged by bfd_free_iface().
|
* session is removed, an associated iface is discharged by bfd_free_iface().
|
||||||
*
|
*
|
||||||
* BFD requests are the external API for the other protocols. When a protocol
|
* BFD requests are the external API for the other protocols. When a protocol
|
||||||
* wants a BFD session, it calls bfd_request_session(), which creates a
|
* wants a BFD session, it calls bfd_request_session(), which creates a
|
||||||
@ -575,9 +575,13 @@ bfd_free_iface(struct bfd_iface *ifa)
|
|||||||
if (!ifa || --ifa->uc)
|
if (!ifa || --ifa->uc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (ifa->sk)
|
||||||
|
{
|
||||||
|
sk_stop(ifa->sk);
|
||||||
|
rfree(ifa->sk);
|
||||||
|
}
|
||||||
|
|
||||||
rem_node(&ifa->n);
|
rem_node(&ifa->n);
|
||||||
sk_stop(ifa->sk);
|
|
||||||
rfree(ifa->sk);
|
|
||||||
mb_free(ifa);
|
mb_free(ifa);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1092,7 +1096,7 @@ bfd_show_sessions(struct proto *P)
|
|||||||
/* FIXME: this is thread-unsafe, but perhaps harmless */
|
/* FIXME: this is thread-unsafe, but perhaps harmless */
|
||||||
state = s->loc_state;
|
state = s->loc_state;
|
||||||
diag = s->loc_diag;
|
diag = s->loc_diag;
|
||||||
ifname = (s->ifa && s->ifa->sk->iface) ? s->ifa->sk->iface->name : "---";
|
ifname = (s->ifa && s->ifa->iface) ? s->ifa->iface->name : "---";
|
||||||
tx_int = s->last_tx ? (MAX(s->des_min_tx_int, s->rem_min_rx_int) TO_MS) : 0;
|
tx_int = s->last_tx ? (MAX(s->des_min_tx_int, s->rem_min_rx_int) TO_MS) : 0;
|
||||||
timeout = (MAX(s->req_min_rx_int, s->rem_min_tx_int) TO_MS) * s->rem_detect_mult;
|
timeout = (MAX(s->req_min_rx_int, s->rem_min_tx_int) TO_MS) * s->rem_detect_mult;
|
||||||
|
|
||||||
|
@ -63,9 +63,13 @@ void
|
|||||||
bfd_send_ctl(struct bfd_proto *p, struct bfd_session *s, int final)
|
bfd_send_ctl(struct bfd_proto *p, struct bfd_session *s, int final)
|
||||||
{
|
{
|
||||||
sock *sk = s->ifa->sk;
|
sock *sk = s->ifa->sk;
|
||||||
struct bfd_ctl_packet *pkt = (struct bfd_ctl_packet *) sk->tbuf;
|
struct bfd_ctl_packet *pkt;
|
||||||
char fb[8];
|
char fb[8];
|
||||||
|
|
||||||
|
if (!sk)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pkt = (struct bfd_ctl_packet *) sk->tbuf;
|
||||||
pkt->vdiag = bfd_pack_vdiag(1, s->loc_diag);
|
pkt->vdiag = bfd_pack_vdiag(1, s->loc_diag);
|
||||||
pkt->flags = bfd_pack_flags(s->loc_state, 0);
|
pkt->flags = bfd_pack_flags(s->loc_state, 0);
|
||||||
pkt->detect_mult = s->detect_mult;
|
pkt->detect_mult = s->detect_mult;
|
||||||
|
Loading…
Reference in New Issue
Block a user