-/* $OpenBSD: rtr_proto.c,v 1.31 2024/01/11 15:38:05 claudio Exp $ */
+/* $OpenBSD: rtr_proto.c,v 1.32 2024/01/15 11:55:26 claudio Exp $ */
/*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
{
struct rtr_header rh;
size_t len;
+ uint16_t errcode;
if (ibuf_get(hdr, &rh, sizeof(rh)) == -1)
fatal("%s: ibuf_get", __func__);
rtr_fsm(rs, RTR_EVNT_NEGOTIATION_DONE);
break;
case ERROR_REPORT:
- /* version handled in rtr_parse_error() */
+ errcode = ntohs(rh.session_id);
+ if (errcode == UNSUPP_PROTOCOL_VERS ||
+ errcode == NO_DATA_AVAILABLE) {
+ if (rh.version < rs->version) {
+ rs->prev_version = rs->version;
+ rs->version = rh.version;
+ }
+ }
break;
case SERIAL_NOTIFY:
/* ignore SERIAL_NOTIFY */
if (ibuf_get(pdu, ¬ify, sizeof(notify)) == -1)
goto badlen;
+ /* set session_id if not yet happened */
+ if (rs->session_id == -1)
+ rs->session_id = ntohs(notify.hdr.session_id);
+
if (rtr_check_session_id(rs, rs->session_id, ¬ify.hdr, pdu) == -1)
return -1;
rtr_fsm(rs, RTR_EVNT_NO_DATA);
rv = 0;
} else if (errcode == UNSUPP_PROTOCOL_VERS) {
- if (rh.version < rs->version) {
- rs->prev_version = rs->version;
- rs->version = rh.version;
- }
rtr_fsm(rs, RTR_EVNT_UNSUPP_PROTO_VERSION);
rv = 0;
} else
timer_set(&rs->timers, Timer_Rtr_Retry, rs->retry);
rtr_imsg_compose(IMSG_SOCKET_CONN, rs->id, 0, NULL, 0);
break;
+ case RTR_STATE_ESTABLISHED:
+ if (rs->session_id == -1)
+ rtr_send_reset_query(rs);
+ else
+ rtr_send_serial_query(rs);
default:
break;
}