summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2023-08-18 15:39:08 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2023-08-18 15:39:08 +0200
commitc40f29a79035b54a8b48ece0e91d38d9066529e3 (patch)
tree5b958aa32be398d9823d216adf10ad352c5f6b88 /proto
parentf4deef89bebae6e41654217e20f2a7531c65bf49 (diff)
BMP: Fix route timestamps
Diffstat (limited to 'proto')
-rw-r--r--proto/bmp/bmp.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/proto/bmp/bmp.c b/proto/bmp/bmp.c
index ec1614f5..964d44b5 100644
--- a/proto/bmp/bmp.c
+++ b/proto/bmp/bmp.c
@@ -770,7 +770,7 @@ bmp_send_peer_up_notif_msg(struct bmp_proto *p, const struct bgp_proto *bgp,
}
static void
-bmp_route_monitor_put_update(struct bmp_proto *p, struct bmp_stream *bs, const byte *data, size_t length)
+bmp_route_monitor_put_update(struct bmp_proto *p, struct bmp_stream *bs, const byte *data, size_t length, btime timestamp)
{
struct bmp_data_node *upd_msg = mb_alloc(p->update_msg_mem_pool,
sizeof (struct bmp_data_node));
@@ -784,7 +784,7 @@ bmp_route_monitor_put_update(struct bmp_proto *p, struct bmp_stream *bs, const b
upd_msg->remote_as = bgp->remote_as;
upd_msg->remote_id = bgp->remote_id;
upd_msg->remote_ip = bgp->remote_ip;
- upd_msg->timestamp = current_time();
+ upd_msg->timestamp = timestamp;
upd_msg->global_peer = bmp_is_peer_global_instance(bgp);
upd_msg->policy = bmp_stream_policy(bs);
@@ -800,8 +800,11 @@ bmp_route_monitor_notify(struct bmp_proto *p, struct bmp_stream *bs,
byte buf[BGP_MAX_EXT_MSG_LENGTH];
byte *end = bgp_bmp_encode_rte(bs->sender, buf, n, new, src);
+ btime delta_t = new ? current_time() - new->lastmod : 0;
+ btime timestamp = current_real_time() - delta_t;
+
if (end)
- bmp_route_monitor_put_update(p, bs, buf, end - buf);
+ bmp_route_monitor_put_update(p, bs, buf, end - buf, timestamp);
else
log(L_WARN "%s: Cannot encode update for %N", p->p.name, n);
}
@@ -850,7 +853,7 @@ bmp_route_monitor_end_of_rib(struct bmp_proto *p, struct bmp_stream *bs)
put_u16(rx_end_payload + BGP_MSG_HDR_LENGTH_POS, pos - rx_end_payload);
put_u8(rx_end_payload + BGP_MSG_HDR_TYPE_POS, PKT_UPDATE);
- bmp_route_monitor_put_update(p, bs, rx_end_payload, pos - rx_end_payload);
+ bmp_route_monitor_put_update(p, bs, rx_end_payload, pos - rx_end_payload, current_real_time());
}
static void