From b3055067ace901a89c63a9c03eda7cbaafe07c83 Mon Sep 17 00:00:00 2001 From: Cody Burkard <cody@onlab.us> Date: Tue, 10 Jun 2014 18:38:10 -0700 Subject: [PATCH] fixed netParse bug that caused mininet crash when no ip prefix was specified --- mininet/util.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mininet/util.py b/mininet/util.py index b03e945c..3dfa04ca 100644 --- a/mininet/util.py +++ b/mininet/util.py @@ -281,6 +281,8 @@ def ipAdd( i, prefixLen=8, ipBaseNum=0x0a000000 ): def ipParse( ip ): "Parse an IP address and return an unsigned int." args = [ int( arg ) for arg in ip.split( '.' ) ] + while ( len(args) < 4 ): + args.append( 0 ) return ipNum( *args ) def netParse( ipstr ): @@ -290,6 +292,10 @@ def netParse( ipstr ): if '/' in ipstr: ip, pf = ipstr.split( '/' ) prefixLen = int( pf ) + #if no prefix is specified, set the prefix to 24 + else: + ip = ipstr + prefixLen = 24 return ipParse( ip ), prefixLen def checkInt( s ): -- GitLab