Message ID | 20201026181626.1827014-1-blp@ovn.org |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev,1/7] northd: Count mask length and priority correctly for IPv6 addresses. | expand |
On Mon, Oct 26, 2020 at 11:46 PM Ben Pfaff <blp@ovn.org> wrote: > > Before this commit, the IPv4 calculation was used even for IPv6 > addresses, which was wrong. > > Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Numan Siddique <numans@ovn.org> 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, &ipv6, &mask_v6); > + cidr_bits = ipv6_count_cidr_bits(&mask_v6); > } else { > error = ip_parse_masked(nat->logical_ip, &ip, &mask); > + 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(&match), ds_cstr(&actions), > &nat->header_); > } else { > - uint16_t priority = count_1bits(ntohl(mask)) + 1; > + uint16_t priority = cidr_bits + 1; > > /* Distributed router. */ > ds_clear(&match); > -- > 2.26.2 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev >
Thanks for the reviews. I applied this series to ovn master.
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, &ipv6, &mask_v6); + cidr_bits = ipv6_count_cidr_bits(&mask_v6); } else { error = ip_parse_masked(nat->logical_ip, &ip, &mask); + 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(&match), ds_cstr(&actions), &nat->header_); } else { - uint16_t priority = count_1bits(ntohl(mask)) + 1; + uint16_t priority = cidr_bits + 1; /* Distributed router. */ ds_clear(&match);
Before this commit, the IPv4 calculation was used even for IPv6 addresses, which was wrong. Signed-off-by: Ben Pfaff <blp@ovn.org> --- northd/ovn-northd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)