Must statement regarding default values

Hi,

I have the following YANG section:

leaf restart-time {
    type uint16 {
        range "0..4095";
    }
    units Seconds;
    default 200;
}

leaf stale-routes-time {
     type uint32 {
        range "1..4095";
     }
     units Seconds;
     default 240;
}

I need that: stale-routes-time >= restart-time
I tried the following expression:

must "stale-routes-time >= restart-time" {
    error-message "stale-routes-time must be greater or equal to restart-time";
}

but in case that I don’t set these leafs the expression doesn’t take the default value and therefore it return false.

Please assist.

Thanks,
Evyatar

Hi,

Can you please assist?
Thanks,

Evyatar

Default values “in effect” are indeed used in the evaluation of a must expression, and your example works just fine when I try it (putting the leafs in a toplevel container in order to have a home for the ‘must’). ConfD starts up fine, and if I change only stale-routes-time, to 180, the ‘must’ fires when I try to commit. Changing the default for stale-routes-time has the result that ConfD can’t start without an init file, dutifully reporting your error-message.

I.e. everything works as expected - did you make a mistake when posting, perhaps over-simplifying? Doesn’t the exact example you posted work? And if not, what version of ConfD are you using?

Hi,
You tried the negative test. Please try the positive. Configure stale-routes-time to 300, it should return commit OK but it will fail.
I am using confd 6.4
I didn’t understood your comment about the init file.

Thanks,

Evyatar

I already did the positive test by successfully starting ConfD - since I put the leafs in a toplevel (non-“presence”) container, the ‘must’ has to be satisfied already in the init transaction that creates CDB. But anyway:

admin@myhost% show top
No entries found.
[ok][2018-02-25 13:29:39]

[edit]
admin@myhost% show top | details
restart-time      200;
stale-routes-time 240;
[ok][2018-02-25 13:29:44]

[edit]
admin@myhost% set top stale-routes-time 300
[ok][2018-02-25 13:30:02]

[edit]
admin@myhost% commit
Commit complete.
[ok][2018-02-25 13:30:04]

I.e. it works just fine. Please check out my other questions in the previous message.

I was only referring to the fact that if a) the defaults don’t satisfy the ‘must’ (e.g. having stale-routes-time default be 180), and b) the ‘must’ has to be satisfied in the init transaction (e.g. because the leafs are in a toplevel np-container), ConfD will fail to start if you don’t provide some other value(s).

That doesn’t have to be via an init file, but it’s the most convenient way and definitely the most reasonable if you actually have a model that requires initial values other than data model defaults - it could also be done by using --start-phase0 and having a program attach to the init transaction and set the values.

Hi,

Thank you for the fast respond.
The exact code is:

   container graceful-restart {
     description
       "Parameters relating the graceful restart mechanism for BGP";
       uses bgp-neighbor-graceful-restart_config;
       must "current()/stale-routes-time >= current()/restart-time" {
           error-message "stale-routes-time must be greater or equal to restart-time";
       }
       must "current()/helper-stale-routes-time >= current()/max-restart-time" {
           error-message "helper-stale-routes-time must be greater or equal to max-restart-time";
       }
    }

when the definition of bgp-neighbor-graceful-restart_config is:

 grouping bgp-neighbor-graceful-restart_config {
   description
     "Configuration parameters relating to BGP graceful restart.";
   leaf enabled {
     type boolean;
     default false;
     description
       "Enable or disable the graceful-restart capability.
       Editing this attribute casues session(s) restart.";
   }
   leaf restart-time {
     type uint16 {
       range "0..4095";
    }
    units Seconds;
    default 200;

     description
       "Estimated time (in seconds) for the local BGP speaker to
        restart a session. This value is advertised in the graceful
        restart BGP capability.  This is a 12-bit value, referred to
        as Restart Time in RFC4724.  Per RFC4724, the suggested
        default value is <= the hold-time value.";
   }

   leaf stale-routes-time {
     type uint32 {
            range "1..4095";

     }

     units Seconds;
     default 240;


     description
       "An upper-bound on the time that stale routes will be
        retained by a router after a session is restarted by this BGP speaker. If an
        End-of-RIB (EOR) marker is received prior to this timer
        expiring stale-routes will be flushed upon its receipt - if
        no EOR is received, then when this timer expires stale paths
        will be purged. This timer is referred to as the
        Selection_Deferral_Timer in RFC4724.Root cause for the session restart is this BGP speaker restart.";
   }
   leaf helper-only {
     type boolean;
     default false;
     description
       "Enable graceful-restart in helper mode only. When this
        leaf is set, the local system does not retain forwarding
        its own state during a restart, but supports procedures
        for the receiving speaker, as defined in RFC4724.
        Editing this attribute causes session(s) restart.";
   }
   leaf helper-stale-routes-time {
     type uint32 {
            range "1..4095";
     }
    units Seconds;
    default 240;


     description
       "An upper-bound on the time that stale routes will be
        retained by a router after its peer session went down. If an
        End-of-RIB (EOR) marker is received prior to this timer
        expiring stale-routes will be flushed upon its receipt - if
        no EOR is received, then when this timer expires stale paths
        will be purged. Root cause for the session restart is the peer BGP speaker restart.";
   }
   leaf max-restart-time {
        type uint32{
            range "1..4095";
        }
        units Seconds;
        default 200;
        description "This is the maximum time (in seconds) to wait for a graceful restart capable peer
        to come back after a restart.
        This value is used when the restart-time value advertised by the peer exceeds it.";

    }

}

As I said I am using Confd version 6.4.

Thanks,

Evyatar Wiesel

OK, still works fine - I’m using 6.4, this time C-CLI just in case some readers are unfamiliar with the J-CLI:

myhost(config)# show full-configuration graceful-restart 
% No entries found.
myhost(config)# show full-configuration graceful-restart | details
graceful-restart disabled
graceful-restart restart-time 200
graceful-restart stale-routes-time 240
graceful-restart helper-only false
graceful-restart helper-stale-routes-time 240
graceful-restart max-restart-time 200
myhost(config)# graceful-restart stale-routes-time 300
myhost(config)# commit
Commit complete.
myhost(config)#