diff options
| author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-05-04 17:32:06 -0300 |
|---|---|---|
| committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-06-05 14:36:54 -0300 |
| commit | cf4472c4f733496a12f2e73b3b89f38af723aa0d (patch) | |
| tree | 3c562b3593cd7d2100d7c68ed492da3b2a448ba2 /lib/filter_nb.c | |
| parent | 81b504228564980bf4dcc7ad4808e2833012c35e (diff) | |
lib: implement additional CLI prefix list check
Changes:
- Move the `TODO` to the appropriated place and hint how to resolve
it.
- Apply mask to prefix when storing it in the data structures. We
can't just add a validation for it otherwise it will break old
CLIs.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'lib/filter_nb.c')
| -rw-r--r-- | lib/filter_nb.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/filter_nb.c b/lib/filter_nb.c index 9df37d7ccc..f2f334d9f4 100644 --- a/lib/filter_nb.c +++ b/lib/filter_nb.c @@ -761,8 +761,6 @@ static int lib_prefix_list_create(struct nb_cb_create_args *args) const char *name; int type; - /* TODO: validate prefix_entry_dup_check() passes. */ - if (args->event != NB_EV_APPLY) return NB_OK; @@ -907,6 +905,20 @@ static int lib_prefix_list_entry_ipv4_prefix_modify(struct nb_cb_modify_args *args) { struct prefix_list_entry *ple; + struct prefix p; + + if (args->event == NB_EV_VALIDATE) { + /* + * TODO: validate prefix_entry_dup_check() passes. + * + * This needs to be implemented using YANG lyd_node + * navigation, because the `priv` data structures are not + * available at `NB_EV_VALIDATE` phase. An easier + * alternative would be mark `ipvx-prefix` as unique + * (see RFC 7950, Section 7.8.3. The list "unique" Statement). + */ + return NB_OK; + } if (args->event != NB_EV_APPLY) return NB_OK; @@ -918,6 +930,16 @@ lib_prefix_list_entry_ipv4_prefix_modify(struct nb_cb_modify_args *args) yang_dnode_get_prefix(&ple->prefix, args->dnode, NULL); + /* Apply mask and correct original address if necessary. */ + prefix_copy(&p, &ple->prefix); + apply_mask(&p); + if (!prefix_same(&ple->prefix, &p)) { + zlog_info("%s: bad network %pFX correcting it to %pFX", + __func__, &ple->prefix, &p); + prefix_copy(&ple->prefix, &p); + } + + /* Finish prefix entry update procedure. */ prefix_list_entry_update_finish(ple); |
