Handle an announcement without an origin like a replacement (closes #113)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
An announcement whose AS path is empty or ends in AS 0 now deletes the peer's route for the prefix, as a withdrawal does. Before, it was neither stored nor applied: the peer's old route stayed live, and within one batch it cancelled the peer's earlier withdrawal of the prefix. Model: opus-5-5
This commit was merged in pull request #138.
This commit is contained in:
@@ -44,8 +44,9 @@ const (
|
||||
)
|
||||
|
||||
// PrefixHandler tracks BGP prefixes and maintains a live routing table in the
|
||||
// database. Routes are added on announcement and deleted on withdrawal, and all
|
||||
// routes of a peer are deleted when its BGP session goes down.
|
||||
// database. Routes are added on announcement and deleted on withdrawal or on an
|
||||
// announcement whose AS path is empty or ends in AS 0, and all routes of a peer
|
||||
// are deleted when its BGP session goes down.
|
||||
type PrefixHandler struct {
|
||||
db database.Store
|
||||
logger *logger.Logger
|
||||
@@ -371,7 +372,11 @@ func (h *PrefixHandler) flushBatch() {
|
||||
for _, update := range lastUpdates {
|
||||
// An announcement is stored when its path gives an origin, or when it
|
||||
// ends in an AS set of several members: that route is stored with
|
||||
// origin 0 (none). An announcement with an empty path is not stored.
|
||||
// origin 0 (none). Any other update deletes the peer's route for the
|
||||
// prefix: a withdrawal, or an announcement whose path is empty or ends
|
||||
// in AS 0. Such an announcement replaces the peer's route, as any
|
||||
// announcement does, with none (RFC 7607 treats AS 0 in a path as a
|
||||
// withdrawal).
|
||||
if update.messageType == "announcement" &&
|
||||
(update.originASN > 0 || update.endsInSet) {
|
||||
// Create live route for batch upsert
|
||||
@@ -379,11 +384,11 @@ func (h *PrefixHandler) flushBatch() {
|
||||
if route != nil {
|
||||
routesToUpsert = append(routesToUpsert, route)
|
||||
}
|
||||
} else if update.messageType == "withdrawal" {
|
||||
} else {
|
||||
// Parse CIDR to get IP version
|
||||
_, ipVersion, err := parseCIDR(update.prefix)
|
||||
if err != nil {
|
||||
h.logger.Error("Failed to parse CIDR for withdrawal",
|
||||
h.logger.Error("Failed to parse CIDR for route deletion",
|
||||
"prefix", update.prefix, "error", err)
|
||||
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user