[Xorp-hackers] [PATCH] Admin distance set from config for RIP

Jean Michel MacKay mackay.jm at gmail.com
Thu Jan 10 09:13:01 PST 2013


Hey,
I realize now that I might of sent this patch at a bad time (right before
the holidays). I was just wondering if anyone had time or will have time to
look at it.

Here is a little description:

This patch allows admin distances to be changed through the config file.

I've mapped the token 'distance', currently only in RIP (also works for
OSPF), to the RIB's set_protocol_admin_distance. Now the origin table is
already created once set_protocol_admin_distance is called, so it fails. I
assume that it fails because you shouldn't change the AD once the origin
table exists, since it would comprise all the merge tables using that
origin table.

How I got around this was to implement change_admin_distance in the class
OriginTable and only allow the AD to be changed if they are no routes in
the OriginTable. Since that should keep the integrity of the merge tables.

Does this sound right? I'm worried that I'm missing something about the
design of the RIB.

Thanks everyone,
JM

On Mon, Dec 17, 2012 at 7:55 AM, Jean Michel MacKay <mackay.jm at gmail.com>wrote:

> From: Jean Michel MacKay <jnmackay at rockwellcollins.com>
>
> ---
>  xorp/etc/templates/rip.tp |    8 ++++++++
>  xorp/rib/rib.cc           |   10 +++++++---
>  xorp/rib/rt_tab_origin.hh |    5 +++++
>  3 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/xorp/etc/templates/rip.tp b/xorp/etc/templates/rip.tp
> index aff2763..8b32f04 100644
> --- a/xorp/etc/templates/rip.tp
> +++ b/xorp/etc/templates/rip.tp
> @@ -7,6 +7,7 @@
>  protocols {
>      rip {
>         targetname: txt = "rip";
> +       distance: u32;
>         traceoptions {
>             flag {
>                 all {
> @@ -95,6 +96,13 @@ protocols {
>             %set:;
>         }
>
> +       distance {
> +            %help:      short "Administrative Distance for RIP";
> +           %allow-range: $(@) "0" "255" %help: "Administrative Distance
> for RIP";
> +            %set:       xrl
> "rib/rib/0.1/set_protocol_admin_distance?protocol:txt=rip&ipv4:bool=true&ipv6:bool=false&unicast:bool=true&multicast:bool=false&admin_distance:u32=$(@)";
> +        }
> +
> +
>         traceoptions {
>             %help:      short "Configure the tracing options";
>             flag {
> diff --git a/xorp/rib/rib.cc b/xorp/rib/rib.cc
> index 3137750..8ad07db 100644
> --- a/xorp/rib/rib.cc
> +++ b/xorp/rib/rib.cc
> @@ -222,11 +222,15 @@ RIB<A>::set_protocol_admin_distance(const string&
> protocol_name,
>      map<string, uint32_t>::iterator mi =
> _admin_distances.find(protocol_name);
>      if (mi != _admin_distances.end()) {
>         OriginTable<A>* ot = find_origin_table(protocol_name);
> -       if (NULL != ot) {
> -           XLOG_ERROR("May not set an admin distance for protocol \"%s\",
> "
> -                      "which has already instantiated an origin table.",
> +       if (NULL != ot && ot->route_count() > 0) {
> +               XLOG_ERROR("May not set an admin distance for protocol
> \"%s\", "
> +                      "which has already instantiated an origin table and
> contains routes.",
>                        protocol_name.c_str());
>             return XORP_ERROR;
> +        }else if(NULL != ot && ot->route_count() == 0) {
> +            ot->change_admin_distance(admin_distance);
> +            XLOG_WARNING("Origin table was set but no routes were set."
> +                        " Should be safe to change admin distance.");
>         }
>      }
>      _admin_distances[protocol_name] = admin_distance;
> diff --git a/xorp/rib/rt_tab_origin.hh b/xorp/rib/rt_tab_origin.hh
> index 1899289..eb6df6b 100644
> --- a/xorp/rib/rt_tab_origin.hh
> +++ b/xorp/rib/rt_tab_origin.hh
> @@ -145,6 +145,11 @@ public:
>      RouteRange<A>* lookup_route_range(const A& addr) const;
>
>      /**
> +    * Changes the admin distance
> +    **/
> +    void change_admin_distance( uint32_t ad ){ _admin_distance = ad; }
> +
> +    /**
>       * @return the default administrative distance for this OriginTable
>       */
>      uint32_t admin_distance() const    { return _admin_distance; }
> --
> 1.7.4.1
>
> _______________________________________________
> Xorp-hackers mailing list
> Xorp-hackers at icir.org
> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20130110/99132072/attachment.html 


More information about the Xorp-hackers mailing list