diff options
| author | Wesley Coakley <wcoakley@nvidia.com> | 2021-05-05 10:28:53 -0400 | 
|---|---|---|
| committer | Wesley Coakley <wcoakley@nvidia.com> | 2021-05-06 14:07:06 -0400 | 
| commit | 6907bb6bbf8bff8575e6a9c6da78b353276feafd (patch) | |
| tree | 51967cbd73fb439f1ecb766755839a85d0972bed /lib | |
| parent | d7e594edd241b9ed62d0023cfc06e41423e1585b (diff) | |
lib: ip prefix-list enforce expected ge le behavior
When specifying only an "le" for an existing ip prefix-list qualified with
both an "le" and "ge" make sure to remove the "ge" property so it does
not stay in the tree.
E.g. Saying these two things in order:
ip prefix-list test seq 1 permit 1.1.0.0/16 ge 18 le 24
ip prefix-list test seq 1 permit 1.1.0.0/16 ge 18
... should result in the second statement "overwriting" the first like
this:
vxdev-arch# do show ip prefix-list
ZEBRA: ip prefix-list foobar: 3 entries
   seq 1 permit 15.0.0.0/16 ge 18
Previously this did not happen and "le" would stick around since it was
never given NB_OP_DESTROY and purged from the data tree.
Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/filter_cli.c | 42 | 
1 files changed, 38 insertions, 4 deletions
diff --git a/lib/filter_cli.c b/lib/filter_cli.c index e147ed5639..f030ce1b33 100644 --- a/lib/filter_cli.c +++ b/lib/filter_cli.c @@ -1360,14 +1360,31 @@ DEFPY_YANG(  		nb_cli_enqueue_change(vty, "./ipv4-prefix", NB_OP_MODIFY,  				      prefix_str); -		if (ge_str) +		if (ge_str) {  			nb_cli_enqueue_change(  				vty, "./ipv4-prefix-length-greater-or-equal",  				NB_OP_MODIFY, ge_str); -		if (le_str) +		} else { +			/* +			 * Remove old ge if not being modified +			 */ +			nb_cli_enqueue_change( +				vty, "./ipv4-prefix-length-greater-or-equal", +				NB_OP_DESTROY, NULL); +		} + +		if (le_str) {  			nb_cli_enqueue_change(  				vty, "./ipv4-prefix-length-lesser-or-equal",  				NB_OP_MODIFY, le_str); +		} else { +			/* +			 * Remove old le if not being modified +			 */ +			nb_cli_enqueue_change( +				vty, "./ipv4-prefix-length-lesser-or-equal", +				NB_OP_DESTROY, NULL); +		}  	} else {  		nb_cli_enqueue_change(vty, "./any", NB_OP_CREATE, NULL);  	} @@ -1561,14 +1578,31 @@ DEFPY_YANG(  		nb_cli_enqueue_change(vty, "./ipv6-prefix", NB_OP_MODIFY,  				      prefix_str); -		if (ge_str) +		if (ge_str) {  			nb_cli_enqueue_change(  				vty, "./ipv6-prefix-length-greater-or-equal",  				NB_OP_MODIFY, ge_str); -		if (le_str) +		} else { +			/* +			 * Remove old ge if not being modified +			 */ +			nb_cli_enqueue_change( +				vty, "./ipv6-prefix-length-greater-or-equal", +				NB_OP_DESTROY, NULL); +		} + +		if (le_str) {  			nb_cli_enqueue_change(  				vty, "./ipv6-prefix-length-lesser-or-equal",  				NB_OP_MODIFY, le_str); +		} else { +			/* +			 * Remove old le if not being modified +			 */ +			nb_cli_enqueue_change( +				vty, "./ipv6-prefix-length-lesser-or-equal", +				NB_OP_DESTROY, NULL); +		}  	} else {  		nb_cli_enqueue_change(vty, "./any", NB_OP_CREATE, NULL);  	}  | 
