From 7ebb52c78d0adb7fd9d901be0f116aa16c16395e Mon Sep 17 00:00:00 2001
From: skorpy <magnus@skorpy.space>
Date: Sat, 1 Mar 2025 12:56:20 +0000
Subject: [PATCH] Never use RETN as transit

---
 bird/files/common-policy.conf   | 2 ++
 bird/files/routing-policy4.conf | 4 ++++
 bird/files/routing-policy6.conf | 4 ++++
 3 files changed, 10 insertions(+)

diff --git a/bird/files/common-policy.conf b/bird/files/common-policy.conf
index 9eef2f50..3426971a 100644
--- a/bird/files/common-policy.conf
+++ b/bird/files/common-policy.conf
@@ -1,3 +1,5 @@
+define RETN_CUSTOMERS_ONLY = (9002,65535);
+
 function honor_graceful_shutdown() {
 	if (65535, 0) ~ bgp_community then {
 		bgp_local_pref = 0;
diff --git a/bird/files/routing-policy4.conf b/bird/files/routing-policy4.conf
index 19f48b00..4cc06d8d 100644
--- a/bird/files/routing-policy4.conf
+++ b/bird/files/routing-policy4.conf
@@ -187,6 +187,10 @@ int path_prepend;
 		bgp_path.prepend(AS_ffffm);
 	}
 
+	if ("global-transit" = rt_scope) || ("metro-transit" = rt_scope) || ("bilateral-global-transit" = rt_scope) || ("bilateral-metro-transit" = rt_scope) then {
+		bgp_community.add(RETN_CUSTOMERS_ONLY);
+	}
+
 	if ("metro-transit" = rt_scope) || ("metro-peering" = rt_scope) then {
 		if (ORIGINATE ~ bgp_community) then {
 			if (LOCAL_METRO ~ bgp_community) then {
diff --git a/bird/files/routing-policy6.conf b/bird/files/routing-policy6.conf
index dfecaa41..1334e9de 100644
--- a/bird/files/routing-policy6.conf
+++ b/bird/files/routing-policy6.conf
@@ -233,6 +233,10 @@ int path_prepend;
 		bgp_path.prepend(AS_ffffm);
 	}
 
+	if ("global-transit" = rt_scope) || ("metro-transit" = rt_scope) || ("bilateral-global-transit" = rt_scope) || ("bilateral-metro-transit" = rt_scope) then {
+		bgp_community.add(RETN_CUSTOMERS_ONLY);
+	}
+
 	if ("metro-transit" = rt_scope) || ("metro-peering" = rt_scope) then {
 		if (ORIGINATE ~ bgp_community) then {
 			if (LOCAL_METRO ~ bgp_community) then {
-- 
GitLab