]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: Add 'allow bgp_med' option for EBGP sessions
authorTrisha Biswas <tbiswas@fastly.com>
Fri, 14 Apr 2023 02:28:37 +0000 (04:28 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Fri, 14 Apr 2023 02:28:37 +0000 (04:28 +0200)
This option allows to treat bgp_med as regular transitive attribute
on EBGP sessions (without hacks in filters).

Minor changes from committer.

doc/bird.sgml
proto/bgp/attrs.c
proto/bgp/bgp.h
proto/bgp/config.Y

index f75fa9fedab215a8408da803a0b87f79826044b6..557140b8c3a7261fb543ca71a0bf2bb3c624d4d7 100644 (file)
@@ -2625,12 +2625,19 @@ using the following configuration parameters:
        keeps MED attribute). Default: disabled.
 
        <tag><label id="bgp-allow-local-pref">allow bgp_local_pref <m/switch/</tag>
-       A standard BGP implementation do not send the Local Preference attribute
-       to eBGP neighbors and ignore this attribute if received from eBGP
+       Standard BGP implementations do not send the Local Preference attribute
+       to EBGP neighbors and ignore this attribute if received from EBGP
        neighbors, as per <rfc id="4271">.  When this option is enabled on an
-       eBGP session, this attribute will be sent to and accepted from the peer,
+       EBGP session, this attribute will be sent to and accepted from the peer,
        which is useful for example if you have a setup like in <rfc id="7938">.
-       The option does not affect iBGP sessions. Default: off.
+       The option does not affect IBGP sessions. Default: off.
+
+       <tag><label id="bgp-allow-med">allow bgp_med <m/switch/</tag>
+       Standard BGP implementations do not propagate the MULTI_EXIT_DESC
+       attribute unless it is configured locally. When this option is enabled
+       on an EBGP session, this attribute will be sent to the peer regardless,
+       which is useful for example if you have a setup like in <rfc id="7938">.
+       The option does not affect IBGP sessions. Default: off.
 
        <tag><label id="bgp-allow-local-as">allow local as [<m/number/]</tag>
        BGP prevents routing loops by rejecting received routes with the local
index 1e234b163e77fad7d361b956bb9778977c54b49a..204151c37742a726b86d9ea46aed5bc539f76c56 100644 (file)
@@ -1834,7 +1834,7 @@ bgp_update_attrs(struct bgp_proto *p, struct bgp_channel *c, rte *e, ea_list *at
 
     /* MULTI_EXIT_DESC attribute - accept only if set in export filter */
     a = bgp_find_attr(attrs0, BA_MULTI_EXIT_DISC);
-    if (a && !(a->fresh))
+    if (a && !a->fresh && !p->cf->allow_med)
       bgp_unset_attr(&attrs, pool, BA_MULTI_EXIT_DISC);
   }
 
index 0461ea28a6e5d266fc8fc68b517c9cd0f37558a5..302f58e7a5951fb564c778d141b076179a3bf1a3 100644 (file)
@@ -108,6 +108,7 @@ struct bgp_config {
   int interpret_communities;           /* Hardwired handling of well-known communities */
   int allow_local_as;                  /* Allow that number of local ASNs in incoming AS_PATHs */
   int allow_local_pref;                        /* Allow LOCAL_PREF in EBGP sessions */
+  int allow_med;                       /* Allow BGP_MED in EBGP sessions */
   int allow_as_sets;                   /* Allow AS_SETs in incoming AS_PATHs */
   int enforce_first_as;                        /* Enable check for neighbor AS as first AS in AS_PATH */
   int gr_mode;                         /* Graceful restart mode (BGP_GR_*) */
index a2dfa747df6399b704c02e8a26640d0a613a2ca6..013d14af71b425daaa9fee7aee0f56b3be4d1b43 100644 (file)
@@ -199,6 +199,7 @@ bgp_proto:
  | bgp_proto ALLOW LOCAL AS ';' { BGP_CFG->allow_local_as = -1; }
  | bgp_proto ALLOW LOCAL AS expr ';' { BGP_CFG->allow_local_as = $5; }
  | bgp_proto ALLOW BGP_LOCAL_PREF bool ';' { BGP_CFG->allow_local_pref = $4; }
+ | bgp_proto ALLOW BGP_MED bool ';' { BGP_CFG->allow_med = $4; }
  | bgp_proto ALLOW AS SETS bool ';' { BGP_CFG->allow_as_sets = $5; }
  | bgp_proto GRACEFUL RESTART bool ';' { BGP_CFG->gr_mode = $4; }
  | bgp_proto GRACEFUL RESTART AWARE ';' { BGP_CFG->gr_mode = BGP_GR_AWARE; }