ovn-lb-benchmark.py embedded the node index directly in the last
octet of VIP addresses (42.42.42.{i}).  When more than 255 nodes
are requested, this produces addresses like 42.42.42.256 which are
not valid IPv4 — octets must be in the range 0-255.

Spread the node index across the third and fourth octets
(42.42.{i >> 8}.{i & 0xff}) to support up to 65535 nodes with
valid addresses.

This is the same design as ovn-benchmark.py.

Signed-off-by: Rosemarie O'Riorden <[email protected]>
---
This patch is new for v2. So there are no changes to log.
---
 tutorial/ovn-lb-benchmark.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tutorial/ovn-lb-benchmark.py b/tutorial/ovn-lb-benchmark.py
index 658beb94c..f7075174c 100755
--- a/tutorial/ovn-lb-benchmark.py
+++ b/tutorial/ovn-lb-benchmark.py
@@ -20,6 +20,11 @@ def die(msg):
     sys.exit(1)
 
 
+def ip_node(i):
+    """Convert node index to two IP octets, supporting up to 65535 nodes."""
+    return f'{i >> 8}.{i & 0xff}'
+
+
 def create_topology(idl, n):
     vlog.info('Creating topology')
     txn = ovs.db.idl.Transaction(idl)
@@ -121,7 +126,7 @@ def add_chassis_template_vars(idl, n, n_vips, n_backends):
         txn = ovs.db.idl.Transaction(idl)
         tv = txn.insert(idl.tables['Chassis_Template_Var'])
         tv.chassis = f'chassis-{i}'
-        tv.setkey('variables', 'vip', f'42.42.42.{i}')
+        tv.setkey('variables', 'vip', f'42.42.{ip_node(i)}')
 
         for j in range(n_vips):
             port = j + 1
@@ -154,7 +159,8 @@ def add_explicit_lbs(idl, n, n_vips, n_backends):
 
             lb = txn.insert(idl.tables['Load_Balancer'])
             lb.name = f'lb-{j}-{i}'
-            lb.setkey('vips', f'42.42.42.{i}:{port}', f'{",".join(backends)}')
+            lb.setkey('vips', f'42.42.{ip_node(i)}:{port}',
+                      f'{",".join(backends)}')
             lb.protocol = 'tcp'
             lr.addvalue('load_balancer', lb.uuid)
             ls.addvalue('load_balancer', lb.uuid)
@@ -223,6 +229,11 @@ def main(argv):
     )
     parser.set_defaults(template=False)
     args = parser.parse_args()
+
+    if args.nodes > 65535:
+        sys.stderr.write('Error: maximum supported node count is 65535\n')
+        sys.exit(1)
+
     run(args.remote, args.nodes, args.vips, args.backends, args.template)
 
 
-- 
2.54.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to