vm/net: fix IP address calculation

7 is not the same as 7 bits...
This commit is contained in:
Marek Marczykowski-Górecki 2017-05-17 02:14:46 +02:00
parent 4d6d6c913a
commit e5daf902b3
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -143,11 +143,12 @@ class NetVMMixin(qubes.events.Emitter):
'''
import qubes.vm.dispvm # pylint: disable=redefined-outer-name
if isinstance(vm, qubes.vm.dispvm.DispVM):
return '10.138.{}.{}'.format((vm.dispid >> 8) & 7, vm.dispid & 7)
return '10.138.{}.{}'.format((vm.dispid >> 8) & 0xff,
vm.dispid & 0xff)
# VM technically can get address which ends in '.0'. This currently
# does not happen, because qid < 253, but may happen in the future.
return '10.137.{}.{}'.format((vm.qid >> 8) & 7, vm.qid & 7)
return '10.137.{}.{}'.format((vm.qid >> 8) & 0xff, vm.qid & 0xff)
@qubes.stateless_property
def gateway(self):