Re: [ovs-dev] [PATCH ovn 1/7] northd: Count mask length and priority correctly for IPv6 addresses.

2020-10-27 Thread Ben Pfaff
Thanks for the reviews.  I applied this series to ovn master.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH ovn 1/7] northd: Count mask length and priority correctly for IPv6 addresses.

2020-10-27 Thread Numan Siddique
On Mon, Oct 26, 2020 at 11:46 PM Ben Pfaff  wrote:
>
> Before this commit, the IPv4 calculation was used even for IPv6
> addresses, which was wrong.
>
> Signed-off-by: Ben Pfaff 

Acked-by: Numan Siddique 

Thanks
Numan

> ---
>  northd/ovn-northd.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
> index 59b7b3d2ee3a..d677f357f5d0 100644
> --- a/northd/ovn-northd.c
> +++ b/northd/ovn-northd.c
> @@ -9303,10 +9303,13 @@ build_lrouter_flows(struct hmap *datapaths, struct 
> hmap *ports,
>
>  /* Check the validity of nat->logical_ip. 'logical_ip' can
>   * be a subnet when the type is "snat". */
> +int cidr_bits;
>  if (is_v6) {
>  error = ipv6_parse_masked(nat->logical_ip, , _v6);
> +cidr_bits = ipv6_count_cidr_bits(_v6);
>  } else {
>  error = ip_parse_masked(nat->logical_ip, , );
> +cidr_bits = ip_count_cidr_bits(mask);
>  }
>  if (!strcmp(nat->type, "snat")) {
>  if (error) {
> @@ -9612,11 +9615,11 @@ build_lrouter_flows(struct hmap *datapaths, struct 
> hmap *ports,
>   * nat->logical_ip with the longest mask gets a higher
>   * priority. */
>  ovn_lflow_add_with_hint(lflows, od, S_ROUTER_OUT_SNAT,
> -count_1bits(ntohl(mask)) + 1,
> +cidr_bits + 1,
>  ds_cstr(), 
> ds_cstr(),
>  >header_);
>  } else {
> -uint16_t priority = count_1bits(ntohl(mask)) + 1;
> +uint16_t priority = cidr_bits + 1;
>
>  /* Distributed router. */
>  ds_clear();
> --
> 2.26.2
>
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovn 1/7] northd: Count mask length and priority correctly for IPv6 addresses.

2020-10-26 Thread Ben Pfaff
Before this commit, the IPv4 calculation was used even for IPv6
addresses, which was wrong.

Signed-off-by: Ben Pfaff 
---
 northd/ovn-northd.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index 59b7b3d2ee3a..d677f357f5d0 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -9303,10 +9303,13 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap 
*ports,
 
 /* Check the validity of nat->logical_ip. 'logical_ip' can
  * be a subnet when the type is "snat". */
+int cidr_bits;
 if (is_v6) {
 error = ipv6_parse_masked(nat->logical_ip, , _v6);
+cidr_bits = ipv6_count_cidr_bits(_v6);
 } else {
 error = ip_parse_masked(nat->logical_ip, , );
+cidr_bits = ip_count_cidr_bits(mask);
 }
 if (!strcmp(nat->type, "snat")) {
 if (error) {
@@ -9612,11 +9615,11 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap 
*ports,
  * nat->logical_ip with the longest mask gets a higher
  * priority. */
 ovn_lflow_add_with_hint(lflows, od, S_ROUTER_OUT_SNAT,
-count_1bits(ntohl(mask)) + 1,
+cidr_bits + 1,
 ds_cstr(), ds_cstr(),
 >header_);
 } else {
-uint16_t priority = count_1bits(ntohl(mask)) + 1;
+uint16_t priority = cidr_bits + 1;
 
 /* Distributed router. */
 ds_clear();
-- 
2.26.2

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev