BFD: Fixes crash after socket error
Thanks to Thomas King for the bugreport.
This commit is contained in:
parent
a8ad8fd649
commit
ffa398b8d8
2 changed files with 22 additions and 14 deletions
|
@ -43,7 +43,7 @@
|
|||
* 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
|
||||
* 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
|
||||
* 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)
|
||||
return;
|
||||
|
||||
rem_node(&ifa->n);
|
||||
if (ifa->sk)
|
||||
{
|
||||
sk_stop(ifa->sk);
|
||||
rfree(ifa->sk);
|
||||
}
|
||||
|
||||
rem_node(&ifa->n);
|
||||
mb_free(ifa);
|
||||
}
|
||||
|
||||
|
@ -1092,7 +1096,7 @@ bfd_show_sessions(struct proto *P)
|
|||
/* FIXME: this is thread-unsafe, but perhaps harmless */
|
||||
state = s->loc_state;
|
||||
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;
|
||||
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)
|
||||
{
|
||||
sock *sk = s->ifa->sk;
|
||||
struct bfd_ctl_packet *pkt = (struct bfd_ctl_packet *) sk->tbuf;
|
||||
struct bfd_ctl_packet *pkt;
|
||||
char fb[8];
|
||||
|
||||
if (!sk)
|
||||
return;
|
||||
|
||||
pkt = (struct bfd_ctl_packet *) sk->tbuf;
|
||||
pkt->vdiag = bfd_pack_vdiag(1, s->loc_diag);
|
||||
pkt->flags = bfd_pack_flags(s->loc_state, 0);
|
||||
pkt->detect_mult = s->detect_mult;
|
||||
|
|
Loading…
Reference in a new issue