-
Notifications
You must be signed in to change notification settings - Fork 320
Set of minor fixes across the board #442
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
Changes from all commits
f3a2a47
5463545
873d543
c05a7ff
c20968a
6d7b10d
e71bdfb
75352b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
|
|
||
| #include "nl-route.h" | ||
| #include "link-api.h" | ||
| #include "nl-aux-route/nl-route.h" | ||
|
|
||
| #define IPIP_ATTR_LINK (1 << 0) | ||
| #define IPIP_ATTR_LOCAL (1 << 1) | ||
|
|
@@ -189,10 +190,12 @@ static void ipip_dump_line(struct rtnl_link *link, struct nl_dump_params *p) | |
| static void ipip_dump_details(struct rtnl_link *link, struct nl_dump_params *p) | ||
| { | ||
| struct ipip_info *ipip = link->l_info; | ||
| char *name, addr[INET_ADDRSTRLEN]; | ||
| struct rtnl_link *parent; | ||
| char addr[INET_ADDRSTRLEN]; | ||
|
|
||
| if (ipip->ipip_mask & IPIP_ATTR_LINK) { | ||
| _nl_auto_rtnl_link struct rtnl_link *parent = NULL; | ||
| char *name; | ||
|
|
||
| nl_dump(p, " link "); | ||
|
|
||
| name = NULL; | ||
|
|
@@ -208,18 +211,20 @@ static void ipip_dump_details(struct rtnl_link *link, struct nl_dump_params *p) | |
|
|
||
| if (ipip->ipip_mask & IPIP_ATTR_LOCAL) { | ||
| nl_dump(p, " local "); | ||
| if(inet_ntop(AF_INET, &ipip->local, addr, sizeof(addr))) | ||
|
|
||
| if (inet_ntop(AF_INET, &ipip->local, addr, sizeof(addr))) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think checking the return value for I mean, if libc is not able to convert an And the else path is just unreached code and noise and place for bugs. But the patch is good. Maybe I will drop some
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see! I just blindly fixed whitespace here without actually reading what the purpose of inet_ntop here is 😅 |
||
| nl_dump_line(p, "%s\n", addr); | ||
| else | ||
| nl_dump_line(p, "%#x\n", ntohs(ipip->local)); | ||
| nl_dump_line(p, "%#x\n", ntohl(ipip->local)); | ||
| } | ||
|
|
||
| if (ipip->ipip_mask & IPIP_ATTR_REMOTE) { | ||
| nl_dump(p, " remote "); | ||
| if(inet_ntop(AF_INET, &ipip->remote, addr, sizeof(addr))) | ||
|
|
||
| if (inet_ntop(AF_INET, &ipip->remote, addr, sizeof(addr))) | ||
| nl_dump_line(p, "%s\n", addr); | ||
| else | ||
| nl_dump_line(p, "%#x\n", ntohs(ipip->remote)); | ||
| nl_dump_line(p, "%#x\n", ntohl(ipip->remote)); | ||
| } | ||
|
|
||
| if (ipip->ipip_mask & IPIP_ATTR_TTL) { | ||
|
|
||
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 also think that
link_lookup()returns a reference. So you would need_nl_auto_rtnl_link.On the other hand,
link_lookup()is internal API only (it can change). This API shouldn't return a reference/ownership, that would only make sense if cache andnl_object_get()were thread-safe and could be filled at the same time by other threads. But it is not, so nobody is going to unref the returned object unexpectedly. The callers just need to take care that they do nothing with the looked up link, after it might be destroyed (or take a reference here).I would even go a step further and add a
link_lookup_name()helper (that returns aconst char *) and use that.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, we are leaking objects. 75352b7 intended to fix that.
If you rather prefer to change
link_lookupto not take the ref and/or addlink_lookup_name, I can do that !