Created
November 27, 2024 13:52
-
-
Save tonusoo/eb48225b26abe648d83962f05d8e6c30 to your computer and use it in GitHub Desktop.
patch bgp-hackathon/bgpd-3/Solution-2-much-better/bgp_simple.pl bgp_simple.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- bgp_simple.pl~ 2024-11-27 12:26:17.057483859 +0200 | |
+++ bgp_simple.pl 2024-11-27 14:46:48.435675124 +0200 | |
@@ -16,6 +16,8 @@ | |
use Net::BGP; | |
use Net::BGP::Process; | |
+STDOUT->autoflush(1); | |
+ | |
my $version = "v0.12"; | |
my $version_date = "22-Jan-2011"; | |
@@ -232,7 +234,7 @@ | |
HoldTime => $holdtime, | |
KeepAliveTime => $keepalive, | |
Listen => !($nolisten), | |
- SupportADD_PATH => 1, | |
+ #SupportADD_PATH => 1, | |
KeepaliveCallback => \&sub_keepalive_callback, | |
UpdateCallback => \&sub_update_callback, | |
NotificationCallback => \&sub_notification_callback, | |
@@ -283,12 +285,16 @@ | |
sub sub_checkaspath | |
{ | |
("@_" !~ /^(([1-9]\d?\d?\d?|[1-5]\d\d\d\d|6[0-4]\d\d\d|65[0-4]\d\d|655[0-2]\d|6553[0-5]))(((\s| \{|,)([1-9]\d?\d?\d?|[1-5]\d\d\d\d|6[0-4]\d\d\d|65[0-4]\d\d|655[0-2]\d|6553[0-5]))\}?)*$|^$/) ? 1 : 0; | |
+ # Do not reject the prefix if AS path contains a 4-byte ASN | |
+ return 0; | |
} | |
sub sub_checkcommunity | |
{ | |
("@_" !~ /^(([0-9]\d?\d?\d?|[1-5]\d\d\d\d|6[0-4]\d\d\d|65[0-4]\d\d|655[0-2]\d|6553[0-5])\:([1-9]\d?\d?\d?|[1-5]\d\d\d\d|6[0-4]\d\d\d|65[0-4]\d\d|655[0-2]\d|6553[0-5]))( (([1-9]\d?\d?\d?|[1-5]\d\d\d\d|6[0-4]\d\d\d|65[0-4]\d\d|655[0-2]\d|6553[0-5])\:([1-9]\d?\d?\d?|[1-5]\d\d\d\d|6[0-4]\d\d\d|65[0-4]\d\d|655[0-2]\d|6553[0-5])))*$|^$/) ? 1 : 0; | |
+ # Do not reject the prefix if it has a large community | |
+ return 0; | |
} | |
sub sub_checkprefix | |
@@ -643,16 +649,18 @@ | |
next; | |
}; | |
- sub_debug ("u", "Send Update: ") if (!$dry); | |
- sub_debug ("u", "Generated Update (not sent): ") if ($dry); | |
- sub_debug ("u", "prfx [$prefix] aspath [$aspath] "); | |
- sub_debug ("u", "locprf [$local_pref] ") if ($peer_type eq "iBGP"); | |
- sub_debug ("u", "med [$med] ") if ($med); | |
- sub_debug ("u", "comm [@communities] ") if (@communities); | |
- sub_debug ("u", "orig [$nlri[7]] "); | |
- sub_debug ("u", "agg [@agg] ") if (@agg); | |
- sub_debug ("u", "atom [$atomic_agg] ") if ($atomic_agg); | |
- sub_debug ("u", "nxthp [$nexthop]\n"); | |
+ if ($verbose) { | |
+ sub_debug ("u", "Send Update: ") if (!$dry); | |
+ sub_debug ("u", "Generated Update (not sent): ") if ($dry); | |
+ sub_debug ("u", "prfx [$prefix] aspath [$aspath] "); | |
+ sub_debug ("u", "locprf [$local_pref] ") if ($peer_type eq "iBGP"); | |
+ sub_debug ("u", "med [$med] ") if ($med); | |
+ sub_debug ("u", "comm [@communities] ") if (@communities); | |
+ sub_debug ("u", "orig [$nlri[7]] "); | |
+ sub_debug ("u", "agg [@agg] ") if (@agg); | |
+ sub_debug ("u", "atom [$atomic_agg] ") if ($atomic_agg); | |
+ sub_debug ("u", "nxthp [$nexthop]\n"); | |
+ } | |
if (! $dry) | |
{ | |
@@ -685,7 +693,8 @@ | |
); | |
} | |
$update->communities([ @communities ]) if (@communities); | |
- $update->aggregator([ @agg ]) if (@agg); | |
+ # Workaround for prefixes which have the large communities field | |
+ #$update->aggregator([ @agg ]) if (@agg); | |
$update->atomic_aggregate("1") if ($atomic_agg); | |
$update->med($med) if ($med); | |
$update->local_pref($local_pref) if ($peer_type eq "iBGP"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment