|
| 1 | +From 8384d41144496019725c1e250abd0ceea854341f Mon Sep 17 00:00:00 2001 |
| 2 | +From: Donatas Abraitis < [email protected]> |
| 3 | +Date: Tue, 25 Mar 2025 13:54:24 +0200 |
| 4 | +Subject: [PATCH] lib: Return duplicate prefix-list entry test If we do e.g.: |
| 5 | + |
| 6 | +ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32 |
| 7 | +ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32 |
| 8 | +ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32 |
| 9 | + |
| 10 | +We end up, having duplicate records with a different sequence number only. |
| 11 | +Also ported the same changes for ipv6 also. |
| 12 | +--- |
| 13 | + lib/filter_cli.c | 25 ++++++++++++++++--------- |
| 14 | + 1 file changed, 16 insertions(+), 9 deletions(-) |
| 15 | + |
| 16 | +diff --git a/lib/filter_cli.c b/lib/filter_cli.c |
| 17 | +index c40c2a75f..2012fa987 100644 |
| 18 | +--- a/lib/filter_cli.c |
| 19 | ++++ b/lib/filter_cli.c |
| 20 | +@@ -1206,10 +1206,14 @@ DEFPY_YANG( |
| 21 | + snprintf(xpath, sizeof(xpath), |
| 22 | + "/frr-filter:lib/prefix-list[type='ipv4'][name='%s']", name); |
| 23 | + if (seq_str == NULL) { |
| 24 | +- /* Use XPath to find the next sequence number. */ |
| 25 | +- sseq = acl_get_seq(vty, xpath, false); |
| 26 | +- if (sseq < 0) |
| 27 | +- return CMD_WARNING_CONFIG_FAILED; |
| 28 | ++ if (plist_is_dup(vty->candidate_config->dnode, &pda)) |
| 29 | ++ sseq = pda.pda_seq; |
| 30 | ++ else { |
| 31 | ++ /* Use XPath to find the next sequence number. */ |
| 32 | ++ sseq = acl_get_seq(vty, xpath, false); |
| 33 | ++ if (sseq < 0) |
| 34 | ++ return CMD_WARNING_CONFIG_FAILED; |
| 35 | ++ } |
| 36 | + |
| 37 | + snprintfrr(xpath_entry, sizeof(xpath_entry), |
| 38 | + "%s/entry[sequence='%" PRId64 "']", xpath, sseq); |
| 39 | +@@ -1396,11 +1400,14 @@ DEFPY_YANG( |
| 40 | + snprintf(xpath, sizeof(xpath), |
| 41 | + "/frr-filter:lib/prefix-list[type='ipv6'][name='%s']", name); |
| 42 | + if (seq_str == NULL) { |
| 43 | +- /* Use XPath to find the next sequence number. */ |
| 44 | +- sseq = acl_get_seq(vty, xpath, false); |
| 45 | +- if (sseq < 0) |
| 46 | +- return CMD_WARNING_CONFIG_FAILED; |
| 47 | +- |
| 48 | ++ if (plist_is_dup(vty->candidate_config->dnode, &pda)) |
| 49 | ++ sseq = pda.pda_seq; |
| 50 | ++ else { |
| 51 | ++ /* Use XPath to find the next sequence number. */ |
| 52 | ++ sseq = acl_get_seq(vty, xpath, false); |
| 53 | ++ if (sseq < 0) |
| 54 | ++ return CMD_WARNING_CONFIG_FAILED; |
| 55 | ++ } |
| 56 | + snprintfrr(xpath_entry, sizeof(xpath_entry), |
| 57 | + "%s/entry[sequence='%" PRId64 "']", xpath, sseq); |
| 58 | + } else |
| 59 | +-- |
| 60 | +2.39.4 |
| 61 | + |
0 commit comments