use hex value for short session ID used in naming interfaces

use interface names "vethOOOOO.ii.ss" and "vethOOOOO.iipss" for veth pairs

(where OOOOO = object id, ii = interface index, ss = hex short session ID)

fixes bug #260 virtual interface names too long
(Boeing r1894)
This commit is contained in:
ahrenholz@gmail.com 2014-10-28 21:18:16 +00:00
parent a1eab16d5b
commit e282c8c302
3 changed files with 6 additions and 4 deletions

View file

@ -167,9 +167,9 @@ class SimpleLxcNode(PyCoreNode):
if ifname is None: if ifname is None:
ifname = "eth%d" % ifindex ifname = "eth%d" % ifindex
sessionid = self.session.shortsessionid() sessionid = self.session.shortsessionid()
name = "veth%s.%s.1.%s" % (self.objid, ifindex, sessionid) name = "veth%s.%sp%s" % (self.objid, ifindex, sessionid)
localname = "veth%s.%s.%s" % (self.objid, ifindex, sessionid) localname = "veth%s.%s.%s" % (self.objid, ifindex, sessionid)
if len(ifname) > 16: if len(localname) >= 16:
raise ValueError, "interface local name '%s' to long" % \ raise ValueError, "interface local name '%s' to long" % \
localname localname
ifclass = VEth ifclass = VEth

View file

@ -689,7 +689,8 @@ class Session(object):
''' Return a shorter version of the session ID, appropriate for ''' Return a shorter version of the session ID, appropriate for
interface names, where length may be limited. interface names, where length may be limited.
''' '''
return (self.sessionid >> 8) ^ (self.sessionid & ((1 << 8) - 1)) ssid = (self.sessionid >> 8) ^ (self.sessionid & ((1 << 8) - 1))
return "%x" % ssid
def sendnodeemuid(self, handler, nodenum): def sendnodeemuid(self, handler, nodenum):
''' Send back node messages to the GUI for node messages that had ''' Send back node messages to the GUI for node messages that had

View file

@ -1160,7 +1160,8 @@ proc get_term_prog { want_default } {
# short session ID used by Python daemon for interface names # short session ID used by Python daemon for interface names
proc shortSessionID { sid } { proc shortSessionID { sid } {
return [ expr { ($sid >> 8) ^ ($sid & ((1<<8) - 1)) } ] set ssid [ expr { ($sid >> 8) ^ ($sid & ((1<<8) - 1)) } ]
return [format "%x" $ssid]
} }