diff --git a/internal/config/config.go b/internal/config/config.go index dcbfeee..14ae95d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -46,7 +46,7 @@ func New() (*Config, error) { return &Config{ StateDir: stateDir, MaxRuntime: 0, // Run forever by default - EnableBatchedDatabaseWrites: true, // Enable batching by default + EnableBatchedDatabaseWrites: true, // Enable batching by default RouteExpirationTimeout: defaultRouteExpirationMinutes * time.Minute, // For active route monitoring }, nil } diff --git a/internal/routewatch/prefixhandler.go b/internal/routewatch/prefixhandler.go index 0f8ef1f..79917b5 100644 --- a/internal/routewatch/prefixhandler.go +++ b/internal/routewatch/prefixhandler.go @@ -21,7 +21,7 @@ const ( // prefixBatchTimeout is the maximum time to wait before flushing a batch prefixBatchTimeout = 5 * time.Second - + // IP version constants ipv4Version = 4 ipv6Version = 6 @@ -111,11 +111,11 @@ func (h *PrefixHandler) HandleMessage(msg *ristypes.RISMessage) { for _, prefix := range msg.Withdrawals { h.batch = append(h.batch, prefixUpdate{ prefix: prefix, - originASN: 0, // No origin for withdrawals + originASN: originASN, // Use the originASN from path if available peer: msg.Peer, messageType: "withdrawal", timestamp: timestamp, - path: nil, + path: msg.Path, }) } @@ -203,7 +203,7 @@ func parseCIDR(prefix string) (maskLength int, ipVersion int, err error) { if strings.Contains(prefix, ":") { return ones, ipv6Version, nil } - + return ones, ipv4Version, nil } @@ -255,11 +255,14 @@ func (h *PrefixHandler) processWithdrawal(_ *database.Prefix, update prefixUpdat ) } } else { - // If no origin ASN, log a warning - h.logger.Warn("Withdrawal without origin ASN", - "prefix", update.prefix, - "peer", update.peer, - ) + // If no origin ASN, just delete all routes for this prefix from this peer + if err := h.db.DeleteLiveRoute(update.prefix, 0, update.peer); err != nil { + h.logger.Error("Failed to delete live route (no origin ASN)", + "prefix", update.prefix, + "peer", update.peer, + "error", err, + ) + } } }