Skip to content

Commit 9be9885

Browse files
authored
tools: topogen: Fix network argument. Added IPv6 network argument. (scionproto#4536)
The argument `-n` or `--network` in [topogen.py](https://github.com/scionproto/scion/blob/9d52e2f8d2211427707dfe5b4028158759ebddeb/tools/topogen.py) is ignored when generating a topology, the default network is always used. There exists no argument for the user to specify a different IPv6 network with respect to the default one. I have added the argument `-n6` or `--network-v6` which is the IPv6 version of the `--network` argument. I moved for consistency the variables like `DEFAULT_NETWORK` from [net.py](https://github.com/scionproto/scion/blob/9d52e2f8d2211427707dfe5b4028158759ebddeb/tools/topology/net.py) to [defines.py](https://github.com/scionproto/scion/blob/9d52e2f8d2211427707dfe5b4028158759ebddeb/tools/topology/defines.py) where the IPv6 network defines are already present.
1 parent 9d52e2f commit 9be9885

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

tools/topogen.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def add_arguments(parser):
3737
parser.add_argument('-d', '--docker', action='store_true',
3838
help='Create a docker compose configuration')
3939
parser.add_argument('-n', '--network',
40-
help='Network to create subnets in (E.g. "127.0.0.0/8"')
40+
help='IPv4 network to create subnets in (E.g. "127.0.0.0/8"')
41+
parser.add_argument('-n6', '--network-v6',
42+
help='IPv6 network to create subnets in (E.g. "fd00:f00d:cafe::7f00:0000/104"')
4143
parser.add_argument('-o', '--output-dir', default=GEN_PATH,
4244
help='Output directory')
4345
parser.add_argument('--random-ifids', action='store_true',

tools/topology/config.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,17 @@ def __init__(self, args):
7676
logging.critical("Cannot use sig without docker!")
7777
sys.exit(1)
7878
self.default_mtu = None
79-
self._read_defaults(self.args.network)
79+
self._read_defaults()
8080

81-
def _read_defaults(self, network):
81+
def _read_defaults(self):
8282
"""
8383
Configure default network.
8484
"""
8585
defaults = self.topo_config.get("defaults", {})
86-
self.subnet_gen4 = SubnetGenerator(DEFAULT_NETWORK, self.args.docker)
87-
self.subnet_gen6 = SubnetGenerator(DEFAULT6_NETWORK, self.args.docker)
86+
self.subnet_gen4 = SubnetGenerator(self.args.network, self.args.docker) \
87+
if self.args.network else SubnetGenerator(DEFAULT_NETWORK, self.args.docker)
88+
self.subnet_gen6 = SubnetGenerator(self.args.network_v6, self.args.docker) \
89+
if self.args.network_v6 else SubnetGenerator(DEFAULT6_NETWORK, self.args.docker)
8890
self.default_mtu = defaults.get("mtu", DEFAULT_MTU)
8991
self.dispatched_ports = defaults.get("dispatched_ports", DEFAULT_DISPATCHED_PORTS)
9092

tools/topology/defines.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
#: IPv6 min value
4141
SCION_MIN_MTU = 1280
4242

43+
# Default IPv4 network
44+
DEFAULT_NETWORK = "127.0.0.0/8"
45+
DEFAULT_PRIV_NETWORK = "192.168.0.0/16"
46+
DEFAULT_SCN_DC_NETWORK = "172.20.0.0/20"
47+
4348
# Default IPv6 network, our equivalent to 127.0.0.0/8
4449
# https://en.wikipedia.org/wiki/Unique_local_address#Definition
4550
DEFAULT6_MASK = "/104"

tools/topology/net.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@
3737
import yaml
3838

3939
# SCION
40-
from topology.defines import DEFAULT6_NETWORK_ADDR
41-
42-
DEFAULT_NETWORK = "127.0.0.0/8"
43-
DEFAULT_PRIV_NETWORK = "192.168.0.0/16"
44-
DEFAULT_SCN_DC_NETWORK = "172.20.0.0/20"
40+
from topology.defines import DEFAULT_NETWORK, DEFAULT_SCN_DC_NETWORK, DEFAULT6_NETWORK_ADDR
4541

4642
IPAddress = Union[IPv4Address, IPv6Address]
4743
IPNetwork = Union[IPv4Network, IPv6Network]

0 commit comments

Comments
 (0)