cnp3 / ipmininet

Mininet extension to make experimenting with IP networks easy
GNU General Public License v2.0
65 stars 51 forks source link

set_local_pref not flexible enough #99

Open fldardenne opened 3 years ago

fldardenne commented 3 years ago

Hi,

The set_local_pref function from bgp.py aims to change the local-preference attribute if the route matches the community or an AccessList. https://github.com/cnp3/ipmininet/blob/693f3b72761adb8896e3ceddb06c61c8a99ad2da/ipmininet/router/config/bgp.py#L151 To do so, the function creates a route-map in the router and links this route-map with the "from_peer" neighbor.

However, I noticed some problems:

What I suggest as a solution and that I applied in the project is to give more flexibility to this function :

With those two new parameters, the user can now define a succession of route-maps to define multiple local-pref matching some communities and finally set a default local-pref so that these route maps do not block others route.

If this solution is accepted, I can do a pull request for my implementation to solve these issues. If a better solution is proposed, I am willing to volunteer for the implementation of that one.

fldardenne commented 3 years ago

An optional parameter to define the order (actually hardcoded to 10)

But when creating a new route-map (let's call it rm11), the first route-map order should be set to 10. Or it will not be linked to the neighbor due to the bgpd.mako condition. https://github.com/cnp3/ipmininet/blob/693f3b72761adb8896e3ceddb06c61c8a99ad2da/ipmininet/router/config/templates/bgpd.mako#L29 Then afterward, the user can create other rm11 route-map with different order.

jadinm commented 3 years ago

Hello,

However, I noticed some problems:

  • The new route-map linked to the neighbor blocks all the other routes that do not match the CommunityList/AccessList.
  • We cannot set the same route-map with different orders.
  • If we try to set multiple local-pref with multiple Communities, it does not add a new route-map with different orders but appends the new "match" condition and appends the new "set local-preference" in the existing route-map.

Could you provide a minimal example for each of the issues that you noted ? For instance, a minimal topology with two BGP routers and maybe show the configuration that is produced.

Then, it would be easier to understand what the problem is and I will be able to provide feedback on your suggested solution ;-)