|
@@ -2,33 +2,19 @@
|
|
|
#
|
|
|
# vim: set ts=4:sw=4
|
|
|
|
|
|
-# 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.
|
|
|
+# bgp import function
|
|
|
+# this function import routes according to the import_type and the AS number. It also add tag the route with
|
|
|
+# the given community
|
|
|
#
|
|
|
-# 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.
|
|
|
+# Parameters
|
|
|
+# AS / AS number of the peer
|
|
|
+# import_type / the import type. Could be
|
|
|
+# transit: this is a transit session
|
|
|
+# peering: this is a peering session on an Internet Exchange Point (including route
|
|
|
+# servers)
|
|
|
+# member: this is a member of Gitoyen.
|
|
|
+# core: this is a core session. It's the backbone iBGP sessions.
|
|
|
+# community / community number to associate to the route. If equal 0, there is no association.
|
|
|
#
|
|
|
function bgp_import( int AS; string import_type; int community)
|
|
|
{
|
|
@@ -42,64 +28,47 @@ function bgp_import( int AS; string import_type; int community)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- # en: weird routes are not accepted
|
|
|
- # fr: les routes bizarres ne sont pas acceptees
|
|
|
+ # weird routes are not accepted
|
|
|
if is_default() || is_martians() || is_rfc1918() then return false;
|
|
|
|
|
|
- # en: gitoyen's routes are not accepted
|
|
|
- # fr: les routes de gitoyen ne sont pas acceptes
|
|
|
+ # gitoyen's routes are not accepted
|
|
|
if is_gitoyen() then return false;
|
|
|
|
|
|
- # 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.
|
|
|
+ # in case of peering or transit, the routes within the gitoyen's network are not accepted.
|
|
|
if import_type = "peering" && import_type = "transit" then {
|
|
|
if is_within_gitoyen() then return false;
|
|
|
}
|
|
|
|
|
|
- # 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.
|
|
|
+ # in case of member, only the routes defined for the member AS are accepted.
|
|
|
if import_type = "member" && ! is_net_from_member(AS) then return false;
|
|
|
|
|
|
- # en: bgp local preference by default
|
|
|
- # fr: preference locales de bgp par defaut
|
|
|
+ # bgp local preference by default
|
|
|
if import_type = "transit" then bgp_local_pref=100;
|
|
|
if import_type = "peering" then bgp_local_pref=1000;
|
|
|
if import_type = "member" then bgp_local_pref=1500;
|
|
|
|
|
|
- # en: communities cleaning (only communities handled by Gitoyen are kept)
|
|
|
- # fr: nettoyage des communautes (seulement les communautes gerees par Gitoyen sont gardees)
|
|
|
+ # communities cleaning (only communities handled by Gitoyen are kept)
|
|
|
if import_type = "transit" then bgp_community.delete( [(20766,*)] );
|
|
|
if import_type = "peering" then bgp_community.delete( [(20766,*)] );
|
|
|
if import_type = "membre" then bgp_community.filter( [(20766,9999)] );
|
|
|
|
|
|
- # en: adding the community to identify the source of the route
|
|
|
+ # 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));
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-# 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
|
|
|
+# bgp export function
|
|
|
+# this function export routes according to the export_type and the AS number.
|
|
|
#
|
|
|
-# 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.
|
|
|
+# Parameters
|
|
|
+# AS / AS number of the peer
|
|
|
+# export_type / the export type. Could be
|
|
|
+# full: The full-view are exported
|
|
|
+# default: The default route are exported
|
|
|
+# members: The routes of the members are exported
|
|
|
+# core: All the routes learned by bgp are exported
|
|
|
#
|
|
|
function bgp_export(int AS; string export_type)
|
|
|
pair set members_export_communities;
|
|
@@ -111,16 +80,13 @@ pair set full_export_communities;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- # en: weird routes are not accepted
|
|
|
- # fr: les routes bizarres ne sont pas acceptees
|
|
|
+ # weird routes are not accepted
|
|
|
if is_martians() || is_rfc1918() then return false;
|
|
|
|
|
|
- # en: the default route are not exported except if asked.
|
|
|
- # fr: la route par defaut n'est pas exportee sauf si demandee.
|
|
|
+ # the default route are not exported except if asked.
|
|
|
if is_default() && ! (export_type="default") then return false;
|
|
|
|
|
|
- # 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
|
|
|
+ # for the routes of the members, only the routes having one of these communities are exported
|
|
|
members_export_communities = [
|
|
|
(20766,1),
|
|
|
(20766,9999),
|
|
@@ -131,8 +97,7 @@ pair set full_export_communities;
|
|
|
&& filter(bgp_community, members_export_communities).len = 0 then return false;
|
|
|
|
|
|
# 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
|
|
|
+ # for the full-view, only the routes having one of these communities are exported
|
|
|
full_export_communities = [
|
|
|
(20766,1),
|
|
|
(20766,9999),
|
|
@@ -145,18 +110,15 @@ pair set full_export_communities;
|
|
|
if export_type = "full"
|
|
|
&& filter(bgp_community, full_export_communities).len = 0 then return false;
|
|
|
|
|
|
- # en: for the default, only the default route are exported.
|
|
|
- # fr: pour default, seul la route par defaut est exportee.
|
|
|
+ # for the default, only the default route are exported.
|
|
|
if export_type = "default"
|
|
|
&& ! is_default() then return false;
|
|
|
|
|
|
- # 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
|
|
|
+ # for the core export type, only the routes learned by BGP are exported
|
|
|
if export_type = "core"
|
|
|
&& source != RTS_BGP then return false;
|
|
|
|
|
|
- # en: blackhole management
|
|
|
- # fr: gestion du blackhole
|
|
|
+ # blackhole management
|
|
|
case AS {
|
|
|
# Absolight
|
|
|
29608: if filter(bgp_community, [ (20766,9999) ]).len > 0 then bgp_community.add ((29608,65001));
|