-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
networkd: configure link even if no routes have been received by dhcp #6886
Conversation
src/network/networkd-dhcp4.c
Outdated
if (n < 0) | ||
return log_link_warning_errno(link, n, "DHCP error: could not get routes: %m"); | ||
log_link_warning_errno(link, n, "DHCP error: could not get routes: %m"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really an error for DHCP not to send a route. It could be just interface is unroutable to the outside....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pr is about dhcp not sending any routes. So what I am missing here. It's waring message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If sd_dhcp_lease_get_routes returns -ENODATA, this will still print an error. You have to exclude this case like above:
if (n < 0 && n != -ENODATA)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should log the warning message .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is about this change and the one in line 90.
If I got the intend of this PR right this is about DHCP responses that do not carry a ROUTER
attribute aka a default gateway.
IMHO logging this situation is definitely required. I am just unsure if warning
is the right level here. warning
causes me to think that there might be something wrong within networkd
but it was able to continue vs this is a (valid) edge case that networkd did handle, but you might be wondering why there is no default route.
Wouldn't log_link_info_errno
be better suited in that case? In any case the logged message could probably made more descriptive.
For the first message in Line 90 logging beased on one of the two return codes (-EINVAL, -ENODATA) could probably be something like
switch (n) {
case -ENODATA: log_info(…, "DHCP {nfo: No routes received from DHCP server: %m"); break ;
case -EINVAL:
default:
log_{warrning,error}(…, "DHCP {warning|error}: could not get routes: %m"); break ;
}
I have had many frustrating hours with software that just logged errors like Subsystem: error: ${errno}
where I had to start reading the source code to actually get why or what is going wrong. Getting this right in networkd would be awesome :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I may misunderstand the code or what the routes here are. But on my laptop, I got
wlp2s0: DHCP error: could not get routes: No data available
however I can connect internet. I thought that even if we do not get routes from DHCP, getting default gateway is sufficient to connect outside. Is it correct, or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is correct. But we can't really keep the log in info level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps "DHCP server did not provide any additional routes" would be a nicer message...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ssahani Then, I still do not understand why you stick to warn here. I think we should warn if DHCP server do not provide either default gateway or additional routes. What do you think about the following?
if (n == -ENODATA)
log_link_info(link, "DHCP: No routes received from DHCP server: %m");
else if (n < 0)
log_link_warning_errno(link, n, "DHCP error: could not get routes: %m");
if (r < 0 && n < 0)
log_link_warning(link, "DHCP error: No routes received from DHCP server: %m");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree this is more informative. When the asset fails for get_router we should warn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configure linke
Minor but you're missing an r on the word linker.
I can't follow you sorry |
He is referring to the title, it is meant to be "configure link", not "linke" or "linker". |
Ohh fixed thanks :) |
src/network/networkd-dhcp4.c
Outdated
return log_link_warning_errno(link, r, "DHCP error: could not get gateway: %m"); | ||
if (r == -ENODATA) | ||
log_link_info(link, "DHCP: No routes received from DHCP server: %m"); | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be else if (r < 0)
here? With this PR, I got
wlp2s0: DHCP error: could not get gateway: Success
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes right . updated. thanks !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated commit fixes my point. Thanks.
5b59a5d
to
91ba098
Compare
Thanks. lgtm. |
src/network/networkd-dhcp4.c
Outdated
else if (n < 0) | ||
log_link_warning_errno(link, n, "DHCP error: could not get routes: %m"); | ||
|
||
if (n < 0 && r < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, i really don't like that you check r here, after all it has possibly been updated in the mean time with lots of other values since it was set to -ENODATA because no routes were discovered.
Why not just use the the test "link->dhcp4_messages == 0" here instead? that's a much more correct and explicit test under the same conditions, or am I wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes that is much cleaner. thanks !
src/network/networkd-dhcp4.c
Outdated
|
||
link->dhcp4_configured = true; | ||
link_check_ready(link); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, even though it's not strictly necessary either you should do "return 0" here i figure, or just move the whole block to the end of the function... otherwise it's weird, if you still go through the loop even though you already decided its unnecessary...
or am i missing something here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok done
Fixes systemd#3752 networkctl IDX LINK TYPE OPERATIONAL SETUP 1 lo loopback carrier unmanaged 2 eth0 ether no-carrier configuring 5 host ether routable configured <========== 5 links listed.
updated |
…arspec_from_time_t() gmtime_r() will return NULL in that case, and we would crash. I committed the reproducer case in fuzz-regressions/, even though we don't have ubsan hooked up yet. Let's add it anyway in case it is useful in the future. We actually crash anyway when compiled with asserts, so this can be easily reproduced without ubsan. oss-fuzz systemd#6886.
…arspec_from_time_t() gmtime_r() will return NULL in that case, and we would crash. I committed the reproducer case in fuzz-regressions/, even though we don't have ubsan hooked up yet. Let's add it anyway in case it is useful in the future. We actually crash anyway when compiled with asserts, so this can be easily reproduced without ubsan. oss-fuzz systemd#6886.
Fixes #3752