Bug 1867013

Summary: if set the lsp-addresses dynamic,the ip distributed was wrong when the subnet mask is set to CIDR
Product: Red Hat Enterprise Linux Fast Datapath Reporter: ying xu <yinxu>
Component: ovn2.11Assignee: OVN Team <ovnteam>
Status: NEW --- QA Contact: Jianlin Shi <jishi>
Severity: medium Docs Contact:
Priority: medium    
Version: FDP 20.ECC: avishnoi, ctrautma, jishi, ovnteam, ralongi
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1865866 Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1865866    
Bug Blocks:    

Description ying xu 2020-08-07 06:59:06 UTC
+++ This bug was initially created as a clone of Bug #1865866 +++

Description of problem:
if set the lsp-addresses dynamic,the ip distributed was wrong when the subnet mask is set to CIDR
that means when I config 
ovn-nbctl lsp-set-addresses vm1 "00:de:ad:01:00:01 dynamic"

and set the ls subnet which netmask is not 8/16/24,like below,
ovn-nbctl set logical_switch s1 other_config:subnet=42.42.42.0/25

the ip for the dynamic_addresses may get "42.42.42.127" or "42.42.42.128"

but 42.42.42.128 is not belong to the subnet 42.42.42.0/25,and 42.42.42.127 can't be assign to a port as it is the broadcast ip for this subnet.

Version-Release number of selected component (if applicable):
# rpm -qa|grep ovn
ovn2.13-20.06.1-6.el8fdp.x86_64
ovn2.13-host-20.06.1-6.el8fdp.x86_64
ovn2.13-central-20.06.1-6.el8fdp.x86_64

How reproducible:
always

Steps to Reproduce:
ovn-nbctl ls-add s1
i=1
for m in `seq 0 4`;do
                for n in `seq 1 99`;do
                ovn-nbctl lsp-add s1 vm$i
                ovn-nbctl lsp-set-addresses vm$i "00:de:ad:01:$m:$n dynamic"

                let i++
                if [ $i -gt 200 ];then
                        break;
                fi
                done
                if [ $i -gt 200 ];then
                        break;
                fi
        done
ovn-nbctl set logical_switch s1 other_config:subnet=42.42.42.0/25
Actual results:

# ovn-nbctl list logical-switch-port|grep 42.42.42.128\"
dynamic_addresses   : "00:de:ad:01:02:31 42.42.42.128"
# ovn-nbctl list logical-switch-port|grep 42.42.42.127\"
dynamic_addresses   : "00:de:ad:01:00:65 42.42.42.127"

Expected results:
these two ip should not be distributed to the port

Additional info:

--- Additional comment from ying xu on 2020-08-05 03:05:57 UTC ---

try to reproduce this issue,you should change the subnet config.
based on the env in the description,you should config "ovn-nbctl set logical_switch s1 other_config:subnet=42.42.42.0/24" first,and the dynamic addresses are correct.
#ovn-nbctl list logical-switch-port|grep 42.42.42.127
#
#ovn-nbctl list logical-switch-port|grep 42.42.42.128
#

then, change the config "ovn-nbctl set logical_switch s1 other_config:subnet=42.42.42.0/25",now you can see the wrong results.
#ovn-nbctl list logical-switch-port|grep 42.42.42.127
#dynamic_addresses   : "00:de:ad:01:00:56 42.42.42.127"
#ovn-nbctl list logical-switch-port|grep 42.42.42.128
#dynamic_addresses   : "00:de:ad:01:00:77 42.42.42.128"