Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(migration): handle truncated wan #1073

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/ns-migration/files/scripts/network
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ alias_zones = dict()
devices = dict()
bond_zones = dict()
bonds = dict()
interface_names = dict()

def exists(key):
try:
Expand Down Expand Up @@ -236,11 +237,12 @@ for a in data['aliases']:

# Create interfaces
for i in data['interfaces']:
iname = utils.sanitize(i["interface"])
siname = utils.sanitize(i["interface"])
if i["proto"] == "pppoe":
iname = iname[0:8] # make sure interface name is 8 chars max, reserve space for "pppoe-" prefix
iname = siname[0:8] # make sure interface name is 8 chars max, reserve space for "pppoe-" prefix
else:
iname = iname[0:14] # make sure interface name is 15 chars max
iname = siname[0:14] # make sure interface name is 15 chars max
interface_names[siname] = iname
nsmigration.vprint(f'Creating interface {iname}')
u.set("network", iname, "interface") # create named record
u.set("network", iname, "proto", i["proto"])
Expand Down Expand Up @@ -290,7 +292,8 @@ for z in data['zones']:
if base_name in z["network"]:
z["network"].remove(base_name) # avoid duplicate bond like bond0 and bond0_lan
z["network"] = z["network"] + bond_zones[z["name"]]
u.set("firewall", zname, "network", [utils.sanitize(n) for n in z["network"]])
# retrieve reduced network name, if present
u.set("firewall", zname, "network", [interface_names.get(utils.sanitize(n), utils.sanitize(n)) for n in z["network"]])
if z["name"].startswith("wan"): # setup masquerading for wans
u.set("firewall", zname, "masq", '1')
u.set("firewall", zname, "mtu_fix", '1')
Expand Down
6 changes: 0 additions & 6 deletions packages/ns-migration/files/scripts/wan
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ else:
# create mwan policy
mwan.store_policy(u, policy_name, interfaces)

# generate one policy for each interface to ease divert rules creation
for i in interfaces:
pname = i.get("name")
# make sure to not exceed 12 chars
mwan.store_policy(u, f'{pname[0:6]}_only', [i])

# divert rule are not migrated

# push default rule to the end
Expand Down
Loading