|
@@ -2,14 +2,34 @@
|
|
#
|
|
#
|
|
# vim: set ts=4:sw=4
|
|
# vim: set ts=4:sw=4
|
|
|
|
|
|
-# fonction d'import BGP
|
|
|
|
-# AS: numero d'AS du partenaire
|
|
|
|
-# import_type: transit|peering|member|core
|
|
|
|
-# transit: transitaire
|
|
|
|
-# peering: session de peering sur un IX (incluant les RS)
|
|
|
|
-# member: membre de Gitoyen beneficiant du completement du reseau
|
|
|
|
-# core: session iBGP du backbone
|
|
|
|
-# community: numero de communaute a utiliser pour tagguer, si =0 alors pas de tag.
|
|
|
|
|
|
+# en: bgp import function
|
|
|
|
+# en: this function import routes according to the import_type and the AS number. It also add tag the route with
|
|
|
|
+# en: the given community
|
|
|
|
+# en:
|
|
|
|
+# en: Parameters
|
|
|
|
+# en: AS / AS number of the peer
|
|
|
|
+# en: import_type / the import type. Could be
|
|
|
|
+# en: transit: this is a transit session
|
|
|
|
+# en: peering: this is a peering session on an Internet Exchange Point (including route
|
|
|
|
+# en: servers)
|
|
|
|
+# en: member: this is a member of Gitoyen.
|
|
|
|
+# en: core: this is a core session. It's the backbone iBGP sessions.
|
|
|
|
+# en: community / community number to associate to the route. If equal 0, there is no association.
|
|
|
|
+#
|
|
|
|
+# fr: fonction d'import bgp
|
|
|
|
+# fr: cette fonction importe les routes selon import_type et selon le numero d'AS. Elle associe aussi un numero
|
|
|
|
+# fr: de communaute aux routes importees.
|
|
|
|
+# fr:
|
|
|
|
+# fr: Parametres
|
|
|
|
+# fr: AS / Numero d'AS du pair
|
|
|
|
+# fr: import_type / Le type d'import. Peut-etre:
|
|
|
|
+# fr: transit: c'est une session de transit
|
|
|
|
+# fr: peering: c'est une session de pair sur une point d'echange Internet (incluant les
|
|
|
|
+# fr: serveurs de routes)
|
|
|
|
+# fr: member: c'est une session avec un membre de Gitoyen.
|
|
|
|
+# fr: core: c'est une session de coeur de reseau. Ce sont les sessions iBGP.
|
|
|
|
+# fr: community / le numero de communaute a associer aux routes. Si egal a 0, il n'y a pas d'association.
|
|
|
|
+#
|
|
function bgp_import( int AS; string import_type; int community)
|
|
function bgp_import( int AS; string import_type; int community)
|
|
{
|
|
{
|
|
if ! (import_type = "transit" || import_type="peering" || import_type="member" || import_type="core") then {
|
|
if ! (import_type = "transit" || import_type="peering" || import_type="member" || import_type="core") then {
|
|
@@ -22,44 +42,65 @@ function bgp_import( int AS; string import_type; int community)
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- # On n'accepte pas les routes bizarres
|
|
|
|
|
|
+ # en: weird routes are not accepted
|
|
|
|
+ # fr: les routes bizarres ne sont pas acceptees
|
|
if is_default() || is_martians() || is_rfc1918() then return false;
|
|
if is_default() || is_martians() || is_rfc1918() then return false;
|
|
|
|
|
|
- # On n'accepte pas les routes de Gitoyen
|
|
|
|
|
|
+ # en: gitoyen's routes are not accepted
|
|
|
|
+ # fr: les routes de gitoyen ne sont pas acceptes
|
|
if is_gitoyen() then return false;
|
|
if is_gitoyen() then return false;
|
|
|
|
|
|
- # On n'accepte pas les routes dans le reseau de Gitoyen provenant des upstreams
|
|
|
|
|
|
+ # en: in case of peering or transit, the routes within the gitoyen's network are not accepted.
|
|
|
|
+ # fr: dans le cas du peering & transit, les routes incluses dans le reseau de Gitoyen ne sont pas acceptees.
|
|
if import_type = "peering" && import_type = "transit" then {
|
|
if import_type = "peering" && import_type = "transit" then {
|
|
if is_within_gitoyen() then return false;
|
|
if is_within_gitoyen() then return false;
|
|
}
|
|
}
|
|
|
|
|
|
- # On n'accepte pas les routes autres que celles definies pour les membres
|
|
|
|
|
|
+ # en: in case of member, only the routes defined for the member AS are accepted.
|
|
|
|
+ # fr: dans le cas d'un membre, seulement les routes definies pour l'AS du membre sont acceptees.
|
|
if import_type = "member" && ! is_net_from_member(AS) then return false;
|
|
if import_type = "member" && ! is_net_from_member(AS) then return false;
|
|
|
|
|
|
- # Gestion des local pref par defaut
|
|
|
|
|
|
+ # en: bgp local preference by default
|
|
|
|
+ # fr: preference locales de bgp par defaut
|
|
if import_type = "transit" then bgp_local_pref=100;
|
|
if import_type = "transit" then bgp_local_pref=100;
|
|
if import_type = "peering" then bgp_local_pref=1000;
|
|
if import_type = "peering" then bgp_local_pref=1000;
|
|
if import_type = "member" then bgp_local_pref=1500;
|
|
if import_type = "member" then bgp_local_pref=1500;
|
|
|
|
|
|
-
|
|
|
|
- # Nettoyage des communautes (On ne garde que les communautes que Gitoyen va traiter)
|
|
|
|
|
|
+ # en: communities cleaning (only communities handled by Gitoyen are kept)
|
|
|
|
+ # fr: nettoyage des communautes (seulement les communautes gerees par Gitoyen sont gardees)
|
|
if import_type = "transit" then bgp_community.delete( [(20766,*)] );
|
|
if import_type = "transit" then bgp_community.delete( [(20766,*)] );
|
|
if import_type = "peering" then bgp_community.delete( [(20766,*)] );
|
|
if import_type = "peering" then bgp_community.delete( [(20766,*)] );
|
|
if import_type = "membre" then bgp_community.filter( [(20766,9999)] );
|
|
if import_type = "membre" then bgp_community.filter( [(20766,9999)] );
|
|
|
|
|
|
- # Ajout d'une communaute pour identifier la source de la route
|
|
|
|
|
|
+ # en: adding the community to identify the source of the route
|
|
|
|
+ # fr: ajout de la communaute pour identifier la source de la route
|
|
if import_type != "core" && community > 0 then bgp_community.add((20766,community));
|
|
if import_type != "core" && community > 0 then bgp_community.add((20766,community));
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-# fonction d'export BGP
|
|
|
|
-# AS: numero d'AS du partenaire
|
|
|
|
-# export_type: full|default|core|member)
|
|
|
|
-# full: envoi la full-view
|
|
|
|
-# default: envoi uniquement la route par default
|
|
|
|
-# members: envoi les routes des membres uniquements
|
|
|
|
-# core: envoi tout ce qui est connu en bgp
|
|
|
|
|
|
+# en: bgp export function
|
|
|
|
+# en: this function export routes according to the export_type and the AS number.
|
|
|
|
+# en:
|
|
|
|
+# en: Parameters
|
|
|
|
+# en: AS / AS number of the peer
|
|
|
|
+# en: export_type / the export type. Could be
|
|
|
|
+# en: full: The full-view are exported
|
|
|
|
+# en: default: The default route are exported
|
|
|
|
+# en: members: The routes of the members are exported
|
|
|
|
+# en: core: All the routes learned by bgp are exported
|
|
|
|
+#
|
|
|
|
+# fr: fonction d'export bgp
|
|
|
|
+# fr: this function export routes according to the export_type and the AS number.
|
|
|
|
+# fr:
|
|
|
|
+# fr: Parametres
|
|
|
|
+# fr: AS / AS numero d'AS du pair
|
|
|
|
+# fr: export_type / Type d'export. Cela peut etre :
|
|
|
|
+# fr: full: La vue complete d'internet est exportee.
|
|
|
|
+# fr: default: La route par defaut est exportee.
|
|
|
|
+# fr: members: Les routes des membres sont exportees.
|
|
|
|
+# fr: core: Toutes les routes apprises par bgp sont exportees.
|
|
|
|
+#
|
|
function bgp_export(int AS; string export_type)
|
|
function bgp_export(int AS; string export_type)
|
|
pair set members_export_communities;
|
|
pair set members_export_communities;
|
|
pair set full_export_communities;
|
|
pair set full_export_communities;
|
|
@@ -70,13 +111,16 @@ pair set full_export_communities;
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- # On n'exporte pas les routes bizarres
|
|
|
|
|
|
+ # en: weird routes are not accepted
|
|
|
|
+ # fr: les routes bizarres ne sont pas acceptees
|
|
if is_martians() || is_rfc1918() then return false;
|
|
if is_martians() || is_rfc1918() then return false;
|
|
|
|
|
|
- # On n'exporte pas la route par default sauf si demandee
|
|
|
|
|
|
+ # en: the default route are not exported except if asked.
|
|
|
|
+ # fr: la route par defaut n'est pas exportee sauf si demandee.
|
|
if is_default() && ! (export_type="default") then return false;
|
|
if is_default() && ! (export_type="default") then return false;
|
|
|
|
|
|
- # Filtrage des exports des routes des membres
|
|
|
|
|
|
+ # en: for the routes of the members, only the routes having one of these communities are exported
|
|
|
|
+ # fr: pour les routes des membres, seulement les routes ayant au moins une de ces communautes sont exportees
|
|
members_export_communities = [
|
|
members_export_communities = [
|
|
(20766,1),
|
|
(20766,1),
|
|
(20766,9999),
|
|
(20766,9999),
|
|
@@ -87,6 +131,8 @@ pair set full_export_communities;
|
|
&& filter(bgp_community, members_export_communities).len = 0 then return false;
|
|
&& filter(bgp_community, members_export_communities).len = 0 then return false;
|
|
|
|
|
|
# Filtrage des exports de la full view
|
|
# Filtrage des exports de la full view
|
|
|
|
+ # en: for the full-view, only the routes having one of these communities are exported
|
|
|
|
+ # fr: pour la vue complete, seulement les routes ayant au moins une de ces communautes sont exportees
|
|
full_export_communities = [
|
|
full_export_communities = [
|
|
(20766,1),
|
|
(20766,1),
|
|
(20766,9999),
|
|
(20766,9999),
|
|
@@ -99,15 +145,18 @@ pair set full_export_communities;
|
|
if export_type = "full"
|
|
if export_type = "full"
|
|
&& filter(bgp_community, full_export_communities).len = 0 then return false;
|
|
&& filter(bgp_community, full_export_communities).len = 0 then return false;
|
|
|
|
|
|
- # Filtrage pour la route par defaut
|
|
|
|
|
|
+ # en: for the default, only the default route are exported.
|
|
|
|
+ # fr: pour default, seul la route par defaut est exportee.
|
|
if export_type = "default"
|
|
if export_type = "default"
|
|
&& ! is_default() then return false;
|
|
&& ! is_default() then return false;
|
|
|
|
|
|
- # Filtrage des exports pour le backbone
|
|
|
|
|
|
+ # en: for the core export type, only the routes learned by BGP are exported
|
|
|
|
+ # fr: pour l'export de type core, seulement les routes apprises par BGP sont exportees
|
|
if export_type = "core"
|
|
if export_type = "core"
|
|
&& source != RTS_BGP then return false;
|
|
&& source != RTS_BGP then return false;
|
|
|
|
|
|
- # Gestion du blackhole
|
|
|
|
|
|
+ # en: blackhole management
|
|
|
|
+ # fr: gestion du blackhole
|
|
case AS {
|
|
case AS {
|
|
# Absolight
|
|
# Absolight
|
|
29608: if filter(bgp_community, [ (20766,9999) ]).len > 0 then bgp_community.add ((29608,65001));
|
|
29608: if filter(bgp_community, [ (20766,9999) ]).len > 0 then bgp_community.add ((29608,65001));
|