Skip to content

Add IPv6 support to netmask and gateway fields#3

Merged
benjamreis merged 1 commit intoxcp-ng:adapt-for-ipv6from
Nambrok:adapt-for-ipv6
Nov 17, 2023
Merged

Add IPv6 support to netmask and gateway fields#3
benjamreis merged 1 commit intoxcp-ng:adapt-for-ipv6from
Nambrok:adapt-for-ipv6

Conversation

@Nambrok
Copy link
Copy Markdown

@Nambrok Nambrok commented Nov 16, 2023

No description provided.

@Nambrok Nambrok marked this pull request as draft November 16, 2023 15:34
@Nambrok Nambrok marked this pull request as ready for review November 16, 2023 15:34
@Nambrok
Copy link
Copy Markdown
Author

Nambrok commented Nov 16, 2023

@benjamreis @stormi In need of review

@stormi stormi requested review from benjamreis and stormi November 16, 2023 16:05
Copy link
Copy Markdown

@benjamreis benjamreis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added back an old logic, you only need to check the right field in XAPI depending on IPv6 or not.

Comment thread XSConsoleData.py Outdated
Comment on lines 989 to 992
elif configuration_mode.lower().startswith('dhcp'):
# For DHCP, find the gateway address by parsing the output from the 'route' command
if 'bridge' in pif['network']:
device = pif['network']['bridge']
else:
device = pif['device']

device = ShellUtils.MakeSafeParam(device)

ipre = r'[0-9a-f.:]+'
ifRE = re.compile(r'\s*inet\s+' + ipre + '\s+netmask\s+(' + ipre + r')\s+broadcast\s+(' + ipre + r')\s*$',
re.IGNORECASE)

ifconfig = commands.getoutput("/sbin/ifconfig '"+device+"'").split("\n")
for line in ifconfig:
match = ifRE.match(line)
if match:
retVal = match.group(1)
break

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is no longer relevant Whatever the mode the netmask should be read from xapi.

Comment thread XSConsoleData.py Outdated
Comment on lines 1020 to 1003
elif configuration_mode.lower().startswith('dhcp'):
# For DHCP, find the gateway address by parsing the output from the 'route' command
if 'bridge' in pif['network']:
device = pif['network']['bridge']
else:
device = pif['device']
routeRE = re.compile(r'([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+UG\s+\d+\s+\d+\s+\d+\s+'+device,
re.IGNORECASE)

routes = commands.getoutput("/sbin/route -n").split("\n")
for line in routes:
match = routeRE.match(line)
if match:
retVal = match.group(2)
break

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Copy Markdown

@benjamreis benjamreis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we maintain patches we try to limit stylistic changes AMAP

Comment thread XSConsoleData.py
Comment thread XSConsoleData.py
Comment thread XSConsoleData.py
retVal = pif['ipv6_gateway'] if ipv6 else pif['gateway']
if retVal:
break

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Co-authored-by: BenjiReis <benjamin.reis@vates.fr>
Signed-off-by: Damien Thenot <damien.thenot@vates.tech>
@benjamreis benjamreis merged commit fbc84b1 into xcp-ng:adapt-for-ipv6 Nov 17, 2023
@Nambrok Nambrok deleted the adapt-for-ipv6 branch November 17, 2023 12:50
@benjamreis
Copy link
Copy Markdown

Upstream contribution included in xapi-project#4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants