← Back to Pull requests

Fix/gobgp legacy withdraw #631

Closed
nuclearcat closed this pull request without merging on Oct 09, 2026 13:36 UTC
View on GitHub
nuclearcat nuclearcat commented on Sep 29, 2026 14:18 UTC
Author

Adding support of GoBGP binary NLRI and attribute fields and supports withdrawals through both legacy AddPath with is_withdraw = true and UUID-free DeletePath. GoBGP CLI rib del now works for IPv4, IPv6, FlowSpec, path identifiers, and VRF paths. global rib del all withdraws locally injected routes in the selected address family while preserving peer and kernel routes.

Withdrawals identify a local path by NLRI and path identifier. Withdrawing an absent path succeeds silently, matching GoBGP. Removed UUID handles are invalidated so they cannot delete a later announcement. UUID-based DeletePath remains supported and takes precedence over path and bulk selectors. VRF path deletions are translated to the VRF's exported VPN NLRI; bulk VRF deletions are scoped by RD and export label.

The real GoBGP v4.8.0 CLI passed the new CLI-only end-to-end test, including repeated withdrawals, multiple path identifiers, family-scoped bulk deletion, FlowSpec, and VRF isolation.

For example, after gobgp global rib add 198.51.100.42/32, withdraw it with gobgp global rib del 198.51.100.42/32. No UUID state is needed. Use gobgp global rib del all -a ipv4 to remove all local IPv4 paths. Programmatic clients can call DeletePath with a Path containing the same family, NLRI, and identifier used for the announcement.

Fixes: https://github.com/osrg/rustybgp/issues/616.

Did you use an AI tool?


Assisted-by: Codex AI

Diff: 1223 lines (+1189 / -34) across 6 files Reviewer: fujita Review duration: 14358m
All Vouch review confidence checks passed
Residual risk 0.09 = Change Risk (0.50) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 1223 lines diff across 6 files
0.50
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.70 · 5 substantive comment(s)
0.70
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
83%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.400
Real PR Conversation Timeline
7 items
fujita fujita commented on code on Oct 08, 2026 08:58 UTC
Code Review
daemon/src/event/grpc.rs:1
@@ -2043,10 +2085,8 @@ impl GoBgpService for GrpcService {
         }
         let id = uuid::Uuid::from_slice(&inner.uuid)
             .map_err(|_| tonic::Status::new(tonic::Code::InvalidArgument, "invalid uuid"))?;
-        let (family, nets) = self
-            .path_uuid_map
-            .lock()
-            .await
+        let mut uuid_map = self.path_uuid_map.lock().await;

DeletePath still returns "uuid is required" when uuid is empty, so
#616 is not fixed.

GoBGP's DeletePath handles three cases:

| uuid | path | Action |
|---|---|---|
| set | (ignored) | Delete the path with this UUID |
| empty | set | Delete the given path |
| empty | not set | Delete all local paths (in family if set) |

#616 needs the second case. gobgp global rib del <prefix> also sends
this request. Please implement it in DeletePath.

fujita fujita commented on code on Oct 08, 2026 08:58 UTC
Code Review
packet/src/bgp.rs:1
@@ -1214,6 +1224,29 @@ impl Attribute {
         self.flags
     }
 
+    /// Decode one complete BGP attribute, using four-octet AS numbers as in
+    /// GoBGP's binary gRPC representation. Reject truncation and trailing data.
+    pub fn decode_from_bytes(bytes: &[u8]) -> Result<Self, Notification> {
+        let invalid = || Notification::UpdateMalformedAttributeList;
+        let mut reader = Cursor::new(bytes);
+        let flags = reader.read_u8().map_err(|_| invalid())?;
+        let code = reader.read_u8().map_err(|_| invalid())?;
+        let len = if flags & Self::FLAG_EXTENDED != 0 {
+            reader.read_u16::<NetworkEndian>().map_err(|_| invalid())?
+        } else {
+            reader.read_u8().map_err(|_| invalid())? as u16
+        };
+        if reader.position() as usize + len as usize != bytes.len() {
+            return Err(invalid());
+        }
+        let attribute =

The flags are not checked. For example, ORIGIN with flags 0xe0 is
accepted and then advertised to peers with these flags.

GoBGP rejects such a request (validatePathAttributeFlags()). Could you
do the same check here, like the UPDATE parser does with
canonical_flags()? A test case for it would be good too.

fujita fujita requested changes on Oct 08, 2026 08:58 UTC
Changes Requested Reviewer

Requested changes.

nuclearcat nuclearcat commented on code on Oct 08, 2026 13:51 UTC
Code Review
daemon/src/event/grpc.rs:1
@@ -2043,10 +2085,8 @@ impl GoBgpService for GrpcService {
         }
         let id = uuid::Uuid::from_slice(&inner.uuid)
             .map_err(|_| tonic::Status::new(tonic::Code::InvalidArgument, "invalid uuid"))?;
-        let (family, nets) = self
-            .path_uuid_map
-            .lock()
-            .await
+        let mut uuid_map = self.path_uuid_map.lock().await;

Sorry forgot to publish 2 more commits, will fix now

nuclearcat nuclearcat commented on code on Oct 08, 2026 13:56 UTC
Code Review
packet/src/bgp.rs:1
@@ -1214,6 +1224,29 @@ impl Attribute {
         self.flags
     }
 
+    /// Decode one complete BGP attribute, using four-octet AS numbers as in
+    /// GoBGP's binary gRPC representation. Reject truncation and trailing data.
+    pub fn decode_from_bytes(bytes: &[u8]) -> Result<Self, Notification> {
+        let invalid = || Notification::UpdateMalformedAttributeList;
+        let mut reader = Cursor::new(bytes);
+        let flags = reader.read_u8().map_err(|_| invalid())?;
+        let code = reader.read_u8().map_err(|_| invalid())?;
+        let len = if flags & Self::FLAG_EXTENDED != 0 {
+            reader.read_u16::<NetworkEndian>().map_err(|_| invalid())?
+        } else {
+            reader.read_u8().map_err(|_| invalid())? as u16
+        };
+        if reader.position() as usize + len as usize != bytes.len() {
+            return Err(invalid());
+        }
+        let attribute =

Done

fujita fujita commented on Oct 09, 2026 13:36 UTC
Contributor

Merged, thanks.

Reviewers
Assignees
nuclearcat nuclearcat
Labels
risk: low confidence: 83% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 50.3% (MEDIUM) · Higher = larger blast radius
50.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 83% · Lower = rushed or shallow review
83%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 8.5% · Safe to merge
8.5%
Repository