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

networkd: configure link even if no routes have been received by dhcp #6886

Merged
merged 1 commit into from
Nov 20, 2017

Conversation

ssahani
Copy link
Contributor

@ssahani ssahani commented Sep 22, 2017

Fixes #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.

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");
Copy link

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....

Copy link
Contributor Author

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.

Copy link

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)

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 think we should log the warning message .

Copy link
Contributor

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 :-)

Copy link
Member

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?

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 is correct. But we can't really keep the log in info level.

Copy link

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...

Copy link
Member

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");

Copy link
Contributor Author

@ssahani ssahani Oct 2, 2017

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.

Copy link

@sitsofe sitsofe left a 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.

@ssahani
Copy link
Contributor Author

ssahani commented Sep 22, 2017

I can't follow you sorry

@flo-wer
Copy link

flo-wer commented Sep 22, 2017

He is referring to the title, it is meant to be "configure link", not "linke" or "linker".

@ssahani ssahani changed the title networkd: configure linke even if no routes have been received by dhcp networkd: configure link even if no routes have been received by dhcp Sep 23, 2017
@ssahani
Copy link
Contributor Author

ssahani commented Sep 23, 2017

Ohh fixed thanks :)

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
Copy link
Member

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

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 right . updated. thanks !

Copy link
Member

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.

@yuwata yuwata added network reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Sep 30, 2017
@ssahani ssahani force-pushed the issue-3752 branch 2 times, most recently from 5b59a5d to 91ba098 Compare October 2, 2017 02:21
@yuwata yuwata removed the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Oct 2, 2017
@yuwata
Copy link
Member

yuwata commented Oct 2, 2017

Thanks. lgtm.

@yuwata yuwata added the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Oct 2, 2017
else if (n < 0)
log_link_warning_errno(link, n, "DHCP error: could not get routes: %m");

if (n < 0 && r < 0) {
Copy link
Member

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?

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 is much cleaner. thanks !


link->dhcp4_configured = true;
link_check_ready(link);
}
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok done

@poettering poettering added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed labels Oct 2, 2017
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.
@ssahani
Copy link
Contributor Author

ssahani commented Oct 2, 2017

updated

@poettering poettering merged commit 444b017 into systemd:master Nov 20, 2017
@ssahani ssahani deleted the issue-3752 branch November 21, 2017 09:15
keszybz added a commit to keszybz/systemd that referenced this pull request Mar 14, 2018
…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.
keszybz added a commit to keszybz/systemd that referenced this pull request Mar 14, 2018
…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.
@yuwata yuwata removed the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

6 participants