[j-nsp] non-existing changes?

Daniel Roesen dr at cluenet.de
Tue Mar 16 05:47:16 EST 2004


Hi Daniel,

On Mon, Mar 15, 2004 at 10:52:25PM +0100, daniel wrote:
> as soon as for example you do 'edit <some_not_yet_existing_hierarchy>'
> the config database gets updated with that hierarchy. When you then
> decide not put any statement under that hierarchy the empty hierarchy
> gets removed again. As far as the config is concerned there no change,
> but technically the db did change and this triggers such warning
> messages. 

Well sure... being a somewhat programming-literate myself I smell when
I'm seeing someone taking "the easy way". :-P

switch (cmd.type) {
    case CMD_SET:
    case CMD_EDIT:
    case CMD_ACTIVATE:
    case CMD_DEACTIVATE:
        config.candidate->modified = TRUE;
        [...]

    case CMD_EXIT:
        if (config.candidate->editlevel->prev == NULL) {   // toplevel
            if (config.candidate->modified == TRUE &&
                request_confirmation_yesno("Exit with uncommitted changes?") == CONFIRM_NO) {
                return(CMDRESULT_CONTINUE);
            }
            
            return(CMDRESULT_LEAVE_EDIT);
        }

        config.candidate->editlevel = editlevel->prev;
        return(CMDRESULT_CONTINUE);
[...]
}

:-)

Proposed change:

-           if (config.candidate->modified &&
+           if (config_diff(config.candidate, config.current) != CDIFF_EMPTY &&

All simplified pseudo-code of course (not accounting for simple
no-op statements, removal of empty config object containers after an
"edit foo .. up" cycle etc).

Would make tracking "config changed" with a flag unnecessary... so
remove complexity. But maybe things are handled completely different
than I'm thinking out loud here. :-)


Best regards,
Daniel


More information about the juniper-nsp mailing list