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

Network component updates - not for merging #1175

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

gombasg
Copy link
Contributor

@gombasg gombasg commented Sep 12, 2017

This branch contains our changes to ncm-network, rebased on top of current master. I cleaned up the obvious conflicts during rebasing, but this is mostly untested. I'm looking into porting these changes on top of #1087, but that may take a while.

When an interface has to be renamed, ncm-network used to call ifdown for
both the old and the new name. But if the new name did not exist before,
that resulted in an error.
The actual renaming is handled by udev, so we need to kick it at the
right time.
The fact is: any interfaces can be given any names, so the names are
meaningless - at least for the tools, the interface names can be
meaningful for humans.
The old-style ifconfig and route commands cannot display all
network settings, only the new ip tool knows all the details.
@@ -6,6 +6,41 @@ include 'pan/types';
include 'quattor/functions/network';

@documentation{
IPv4/IPv6 prefix notation
}
function is_ip_prefix = {
Copy link
Member

Choose a reason for hiding this comment

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

there is a is_ipv4_prefix_length and similar one for ipv6 in pan/types in template library core. this function should be moved there

Single byte
}
# TODO: This should likely be defined elsewhere
type type_byte = long with { SELF >= 0 && SELF <= 255; };
Copy link
Member

@stdweird stdweird Sep 12, 2017

Choose a reason for hiding this comment

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

and use long(0..255)?

"num_grat_arp" ? long
"num_unsol_na" ? long
"resend_igmp" ? long
"mode" : long(0..6) # TODO: allow mode to be given as a string
Copy link
Member

Choose a reason for hiding this comment

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

why? dual typed values are not recommended. we have run into it on some other occasions, and i think they are used to migrate from legacy yes/no boolean strings to actual booleans.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I'd be happy to switch to string unconditionally :-) That's what we use internally, and it is much more readable.

# Name of the auto-generated udev rule which needs to be removed to allow udev re-consider the interface names
"udev_rules_file" ? string
# E.g. "/usr/bin/udevadm trigger", although restricting the scope to just network devices should not hurt
"udev_trigger_command" ? string
Copy link
Member

Choose a reason for hiding this comment

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

what possible values could there be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nowadays I think only what's written in the comments, but I'd need to check. RH4 had an old udev with a different interface, so the value had to be configurable. But the new udevadm CLI is stable for a while, so I'd not mind removing these commands from the templates and just hard-code them in the component.

@@ -10,6 +10,12 @@ include 'quattor/schema';

type component_network_type = {
include structure_component
# Name of the auto-generated udev rule which needs to be removed to allow udev re-consider the interface names
"udev_rules_file" ? string
Copy link
Member

Choose a reason for hiding this comment

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

move all the udev_ attributes to a new udev related type

},
);

my %mask_to_prefix = (
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that should likely happen here. We didn't want to introduce new dependencies when this code was originally written.

# simple routes to the policy routing syntax
if (exists($net{$iface}{route})) {
foreach my $rt (sort keys %{$net{$iface}{route}}) {
my $route = {"dev" => $iface};
Copy link
Member

Choose a reason for hiding this comment

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

this is not correct, should be devicename like https://github.com/quattor/configuration-modules-core/pull/1087/files#diff-90bc6b2e2a105ae5c62daf55ef95b2a7R1573

but new code makes this much easier; and also support arbitrary commands via cmd attribute

$was_change = 1;
}
}
## kick udev to rename devices if needed; do nothing if no files were changed
Copy link
Member

Choose a reason for hiding this comment

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

see also #1012
but we had some udev related issues with storage devices too, so maybe a CAF::udev might make sense

Copy link
Member

Choose a reason for hiding this comment

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

see #1118 for storage udev PR

## kick udev to rename devices if needed; do nothing if no files were changed
if ($was_change) {
# Remove the auto-generated rule file if present
if ($config->elementExists("/software/components/network/udev_rules_file")) {
Copy link
Member

Choose a reason for hiding this comment

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

metaconfig has udev related TT files, maybe we can generate the udev files with metaconfig, and call the trigger/settle here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to create any udev files - but I need to remove the one udev generates automatically. If the auto-generated file exists, then udev will not look into the ifcfg-* files, and it will not notice that some interfaces which did not have a configuration before may need to be renamed.

Copy link
Member

Choose a reason for hiding this comment

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

what autogenerates it? anaconda? i always tought that ifcfg file preceded udev rules if HWADDR was set.
the location of this autogenerated udev file is OS release specific i guess? it would be nice to add the value somewhere (for aii we have os flavours); or do you think we can hardcode the location?

@@ -1145,6 +1312,9 @@ sub Configure
my @op;

while (my ($k, $v) = each(%$opts)) {
if ($v->isType(LIST)) {
Copy link
Member

Choose a reason for hiding this comment

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

i'm surprised this works. i'm going to assume you use a recent CCM?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It may not work :-) The original code which we still use is much uglier, and I just found this construct in one of the other components and decided it's not that horrible. I think you already have a much more generic solution in #1087, but I did not have time to try that so far.

Copy link
Member

Choose a reason for hiding this comment

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

the ->getTree call a few lines higher returns arrayrefs for lists, that's why i was asking.

@stdweird
Copy link
Member

@gombasg this doesn't look too hard, iwas worried for something far worse 😄
i guess this PR can be closed and is only here as a reference for future PRs?

@gombasg
Copy link
Contributor Author

gombasg commented Sep 12, 2017

@stdweird: I just wanted to push this out to show what we'd like to be included, to make sure the changes you're working on are not outright incompatible. We should have published these changes a long time ago...

@ned21
Copy link
Contributor

ned21 commented Oct 26, 2017

@stdweird confirmed at RAL workshop that none of these items are in the latest ncm-network rewrite so they will all need to be reimplemented.

@stdweird stdweird marked this pull request as draft July 28, 2023 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants