* [dpdk-dev] [PATCH] lpm: skip table entries update if rules found @ 2020-04-17 13:48 Yangchao Zhou 2020-04-17 14:01 ` Medvedkin, Vladimir 2020-04-17 15:09 ` [dpdk-dev] [PATCH v2] " Yangchao Zhou 0 siblings, 2 replies; 8+ messages in thread From: Yangchao Zhou @ 2020-04-17 13:48 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Vladimir Medvedkin Table entries do not need to be updated if the same rules can be found. Signed-off-by: Yangchao Zhou <zhouyates@gmail.com> --- lib/librte_lpm/rte_lpm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index 268756419..ee44fc4e5 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -287,7 +287,7 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, if (lpm->rules_tbl[rule_index].ip == ip_masked) { lpm->rules_tbl[rule_index].next_hop = next_hop; - return rule_index; + return -EEXIST; } } @@ -674,6 +674,10 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, /* Add the rule to the rule table. */ rule_index = rule_add(lpm, ip_masked, depth, next_hop); + /* Skip table entries update if rule is found in rule table */ + if (rule_index == -EEXIST) + return 0; + /* If the is no space available for new rule return error. */ if (rule_index < 0) { return rule_index; -- 2.17.1 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH] lpm: skip table entries update if rules found 2020-04-17 13:48 [dpdk-dev] [PATCH] lpm: skip table entries update if rules found Yangchao Zhou @ 2020-04-17 14:01 ` Medvedkin, Vladimir [not found] ` <CABLiTuxTNQYYSCwWRuqqSZy+0JhBqjcE2v5ha+OqWk+YH42+TA@mail.gmail.com> 2020-04-17 15:09 ` [dpdk-dev] [PATCH v2] " Yangchao Zhou 1 sibling, 1 reply; 8+ messages in thread From: Medvedkin, Vladimir @ 2020-04-17 14:01 UTC (permalink / raw) To: Yangchao Zhou, dev; +Cc: Richardson, Bruce Hi Zhou, NACK. This patch makes lpm inconsistent. From the programmers guide "If a rule with the same prefix is already present in the table, the next hop of the rule is updated." So, here in case of presence of a route, next hop will be updated only in rules_table which is helper data struct, but won't be updated in lpm data plane struct. -----Original Message----- From: Yangchao Zhou <zhouyates@gmail.com> Sent: Friday, April 17, 2020 2:49 PM To: dev@dpdk.org Cc: Richardson, Bruce <bruce.richardson@intel.com>; Medvedkin, Vladimir <vladimir.medvedkin@intel.com> Subject: [PATCH] lpm: skip table entries update if rules found Table entries do not need to be updated if the same rules can be found. Signed-off-by: Yangchao Zhou <zhouyates@gmail.com> --- lib/librte_lpm/rte_lpm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index 268756419..ee44fc4e5 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -287,7 +287,7 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, if (lpm->rules_tbl[rule_index].ip == ip_masked) { lpm->rules_tbl[rule_index].next_hop = next_hop; - return rule_index; + return -EEXIST; } } @@ -674,6 +674,10 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, /* Add the rule to the rule table. */ rule_index = rule_add(lpm, ip_masked, depth, next_hop); + /* Skip table entries update if rule is found in rule table */ + if (rule_index == -EEXIST) + return 0; + /* If the is no space available for new rule return error. */ if (rule_index < 0) { return rule_index; -- 2.17.1 ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <CABLiTuxTNQYYSCwWRuqqSZy+0JhBqjcE2v5ha+OqWk+YH42+TA@mail.gmail.com>]
* Re: [dpdk-dev] [PATCH] lpm: skip table entries update if rules found [not found] ` <CABLiTuxTNQYYSCwWRuqqSZy+0JhBqjcE2v5ha+OqWk+YH42+TA@mail.gmail.com> @ 2020-04-17 15:07 ` Yangchao Zhou 0 siblings, 0 replies; 8+ messages in thread From: Yangchao Zhou @ 2020-04-17 15:07 UTC (permalink / raw) Cc: dev, Richardson, Bruce ++ dev@dpdk.org On Fri, Apr 17, 2020 at 10:38 PM Yangchao Zhou <zhouyates@gmail.com> wrote: > Hi Vladimir, > > Thanks, you are right. I saw that the next hop is also in lpm table > entries. > On the basis of the same route, skiping the table entries update only if > the next hop is also the same. > > On Fri, Apr 17, 2020 at 10:04 PM Medvedkin, Vladimir < > vladimir.medvedkin@intel.com> wrote: > >> Hi Zhou, >> >> NACK. >> This patch makes lpm inconsistent. >> From the programmers guide >> "If a rule with the same prefix is already present in the table, the next >> hop of the rule is updated." >> So, here in case of presence of a route, next hop will be updated only in >> rules_table which is helper data struct, but won't be updated in lpm data >> plane struct. >> >> -----Original Message----- >> From: Yangchao Zhou <zhouyates@gmail.com> >> Sent: Friday, April 17, 2020 2:49 PM >> To: dev@dpdk.org >> Cc: Richardson, Bruce <bruce.richardson@intel.com>; Medvedkin, Vladimir < >> vladimir.medvedkin@intel.com> >> Subject: [PATCH] lpm: skip table entries update if rules found >> >> Table entries do not need to be updated if the same rules can be found. >> >> Signed-off-by: Yangchao Zhou <zhouyates@gmail.com> >> --- >> lib/librte_lpm/rte_lpm.c | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index >> 268756419..ee44fc4e5 100644 >> --- a/lib/librte_lpm/rte_lpm.c >> +++ b/lib/librte_lpm/rte_lpm.c >> @@ -287,7 +287,7 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, >> uint8_t depth, >> if (lpm->rules_tbl[rule_index].ip == ip_masked) { >> lpm->rules_tbl[rule_index].next_hop = >> next_hop; >> >> - return rule_index; >> + return -EEXIST; >> } >> } >> >> @@ -674,6 +674,10 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, >> uint8_t depth, >> /* Add the rule to the rule table. */ >> rule_index = rule_add(lpm, ip_masked, depth, next_hop); >> >> + /* Skip table entries update if rule is found in rule table */ >> + if (rule_index == -EEXIST) >> + return 0; >> + >> /* If the is no space available for new rule return error. */ >> if (rule_index < 0) { >> return rule_index; >> -- >> 2.17.1 >> >> ^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH v2] lpm: skip table entries update if rules found 2020-04-17 13:48 [dpdk-dev] [PATCH] lpm: skip table entries update if rules found Yangchao Zhou 2020-04-17 14:01 ` Medvedkin, Vladimir @ 2020-04-17 15:09 ` Yangchao Zhou 2020-04-17 17:26 ` [dpdk-dev] [PATCH v3] " Yangchao Zhou 2020-04-20 2:48 ` [dpdk-dev] [PATCH v4] " Yangchao Zhou 1 sibling, 2 replies; 8+ messages in thread From: Yangchao Zhou @ 2020-04-17 15:09 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Vladimir Medvedkin Table entries do not need to be updated if the same rules can be found. Signed-off-by: Yangchao Zhou <zhouyates@gmail.com> --- lib/librte_lpm/rte_lpm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index 268756419..83db3cd34 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -285,6 +285,9 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, /* If rule already exists update its next_hop and return. */ if (lpm->rules_tbl[rule_index].ip == ip_masked) { + + if (lpm->rules_tbl[rule_index].next_hop == next_hop) + return -EEXIST; lpm->rules_tbl[rule_index].next_hop = next_hop; return rule_index; @@ -674,6 +677,11 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, /* Add the rule to the rule table. */ rule_index = rule_add(lpm, ip_masked, depth, next_hop); + /* Skip table entries update if The rule is the same as + * the rule in the rules table */ + if (rule_index == -EEXIST) + return 0; + /* If the is no space available for new rule return error. */ if (rule_index < 0) { return rule_index; -- 2.17.1 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH v3] lpm: skip table entries update if rules found 2020-04-17 15:09 ` [dpdk-dev] [PATCH v2] " Yangchao Zhou @ 2020-04-17 17:26 ` Yangchao Zhou 2020-04-20 2:48 ` [dpdk-dev] [PATCH v4] " Yangchao Zhou 1 sibling, 0 replies; 8+ messages in thread From: Yangchao Zhou @ 2020-04-17 17:26 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Vladimir Medvedkin Table entries do not need to be updated if the same rules can be found. Signed-off-by: Yangchao Zhou <zhouyates@gmail.com> --- lib/librte_lpm/rte_lpm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index 268756419..9085f935e 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -285,6 +285,9 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, /* If rule already exists update its next_hop and return. */ if (lpm->rules_tbl[rule_index].ip == ip_masked) { + + if (lpm->rules_tbl[rule_index].next_hop == next_hop) + return -EEXIST; lpm->rules_tbl[rule_index].next_hop = next_hop; return rule_index; @@ -674,6 +677,12 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, /* Add the rule to the rule table. */ rule_index = rule_add(lpm, ip_masked, depth, next_hop); + /* Skip table entries update if The rule is the same as + * the rule in the rules table. + */ + if (rule_index == -EEXIST) + return 0; + /* If the is no space available for new rule return error. */ if (rule_index < 0) { return rule_index; -- 2.17.1 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH v4] lpm: skip table entries update if rules found 2020-04-17 15:09 ` [dpdk-dev] [PATCH v2] " Yangchao Zhou 2020-04-17 17:26 ` [dpdk-dev] [PATCH v3] " Yangchao Zhou @ 2020-04-20 2:48 ` Yangchao Zhou 2020-04-21 15:44 ` Medvedkin, Vladimir 1 sibling, 1 reply; 8+ messages in thread From: Yangchao Zhou @ 2020-04-20 2:48 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Vladimir Medvedkin Table entries do not need to be updated if the same rules can be found. Signed-off-by: Yangchao Zhou <zhouyates@gmail.com> --- v1-v2: Skip updating when the next hop is the same as the current one v2-v4: Coding style fix --- lib/librte_lpm/rte_lpm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index 268756419..b8a90e385 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -285,6 +285,9 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, /* If rule already exists update its next_hop and return. */ if (lpm->rules_tbl[rule_index].ip == ip_masked) { + + if (lpm->rules_tbl[rule_index].next_hop == next_hop) + return -EEXIST; lpm->rules_tbl[rule_index].next_hop = next_hop; return rule_index; @@ -674,6 +677,12 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, /* Add the rule to the rule table. */ rule_index = rule_add(lpm, ip_masked, depth, next_hop); + /* Skip table entries update if The rule is the same as + * the rule in the rules table. + */ + if (rule_index == -EEXIST) + return 0; + /* If the is no space available for new rule return error. */ if (rule_index < 0) { return rule_index; -- 2.17.1 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v4] lpm: skip table entries update if rules found 2020-04-20 2:48 ` [dpdk-dev] [PATCH v4] " Yangchao Zhou @ 2020-04-21 15:44 ` Medvedkin, Vladimir 2020-04-24 17:17 ` Thomas Monjalon 0 siblings, 1 reply; 8+ messages in thread From: Medvedkin, Vladimir @ 2020-04-21 15:44 UTC (permalink / raw) To: Yangchao Zhou, dev; +Cc: Bruce Richardson Hi Yangchao, Thanks for the patch. This might be useful for control plane implementations that don't track inserted routes. I have just a one nit inlined below. Also, could you do the same for lpm6? P.S. Please have a look at rte_fib library, there are more optimizations compared to lpm library. Apart from that, Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> On 20/04/2020 03:48, Yangchao Zhou wrote: > Table entries do not need to be updated if the same rules can be found. > > Signed-off-by: Yangchao Zhou <zhouyates@gmail.com> > --- > v1-v2: Skip updating when the next hop is the same as the current one > v2-v4: Coding style fix > --- > lib/librte_lpm/rte_lpm.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c > index 268756419..b8a90e385 100644 > --- a/lib/librte_lpm/rte_lpm.c > +++ b/lib/librte_lpm/rte_lpm.c > @@ -285,6 +285,9 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, > > /* If rule already exists update its next_hop and return. */ > if (lpm->rules_tbl[rule_index].ip == ip_masked) { > + > + if (lpm->rules_tbl[rule_index].next_hop == next_hop) Line over 80 characters, please split it by two. > + return -EEXIST; > lpm->rules_tbl[rule_index].next_hop = next_hop; > > return rule_index; > @@ -674,6 +677,12 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, > /* Add the rule to the rule table. */ > rule_index = rule_add(lpm, ip_masked, depth, next_hop); > > + /* Skip table entries update if The rule is the same as > + * the rule in the rules table. > + */ > + if (rule_index == -EEXIST) > + return 0; > + > /* If the is no space available for new rule return error. */ > if (rule_index < 0) { > return rule_index; -- Regards, Vladimir ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v4] lpm: skip table entries update if rules found 2020-04-21 15:44 ` Medvedkin, Vladimir @ 2020-04-24 17:17 ` Thomas Monjalon 0 siblings, 0 replies; 8+ messages in thread From: Thomas Monjalon @ 2020-04-24 17:17 UTC (permalink / raw) To: Yangchao Zhou, Medvedkin, Vladimir; +Cc: dev, Bruce Richardson 21/04/2020 17:44, Medvedkin, Vladimir: > Hi Yangchao, > > Thanks for the patch. > This might be useful for control plane implementations that don't track > inserted routes. > I have just a one nit inlined below. Also, could you do the same for lpm6? > > P.S. Please have a look at rte_fib library, there are more optimizations > compared to lpm library. > > Apart from that, > Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> [...] > > /* If rule already exists update its next_hop and return. */ Reduced length of above comment, > > if (lpm->rules_tbl[rule_index].ip == ip_masked) { > > + > > + if (lpm->rules_tbl[rule_index].next_hop == next_hop) > > > Line over 80 characters, please split it by two. and split above line. Applied with requested changes, thanks. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-04-24 17:17 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-04-17 13:48 [dpdk-dev] [PATCH] lpm: skip table entries update if rules found Yangchao Zhou 2020-04-17 14:01 ` Medvedkin, Vladimir [not found] ` <CABLiTuxTNQYYSCwWRuqqSZy+0JhBqjcE2v5ha+OqWk+YH42+TA@mail.gmail.com> 2020-04-17 15:07 ` Yangchao Zhou 2020-04-17 15:09 ` [dpdk-dev] [PATCH v2] " Yangchao Zhou 2020-04-17 17:26 ` [dpdk-dev] [PATCH v3] " Yangchao Zhou 2020-04-20 2:48 ` [dpdk-dev] [PATCH v4] " Yangchao Zhou 2020-04-21 15:44 ` Medvedkin, Vladimir 2020-04-24 17:17 ` Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).