-
Notifications
You must be signed in to change notification settings - Fork 196
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
libnetplan: expose coherent generator APIs #239
libnetplan: expose coherent generator APIs #239
Conversation
Note that we duplicated a function, as I'd like to remove it from the API seeing as it's really not netplan-specific, but we need to keep it in the ABI. The new API has the ability to report on errors, which allows us to remove all the calls to exit() within networkd.c. Those have nothing to do in library code. We also followed the current convention of using the return value to signal errors, forcing us to use an out-parameter for the "has_been_written" return value.
The NM generator directly called exit() when something went wrong, which is not ideal in library code! We copied the API from the netword generator, hence the has_been_written new capability.
The API is now the same as for the networkd and NM generators. No more exit()ing in the middle of a library call!
0be6e22
to
583917e
Compare
src/openvswitch.h
Outdated
NETPLAN_INTERNAL gboolean | ||
netplan_ovs_cleanup(const char* rootdir); | ||
|
||
|
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.
Add comment about deprecated API, instead of additional whitespace.
src/openvswitch.c
Outdated
return TRUE; | ||
} | ||
return FALSE; | ||
*result = FALSE; |
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.
The result
variable name is a bit unclear here. Maybe it could be called needs_ssl
instead?
src/openvswitch.c
Outdated
if (def->ovs_settings.protocols && def->ovs_settings.protocols->len > 0) { | ||
write_ovs_protocols(&(def->ovs_settings), def->id, cmds); | ||
} else if (ovs_settings_global.protocols && ovs_settings_global.protocols->len > 0) { | ||
write_ovs_protocols(&(ovs_settings_global), def->id, cmds); | ||
} else if (settings->protocols && settings->protocols->len > 0) { | ||
write_ovs_protocols(settings, def->id, cmds); | ||
} |
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.
we could use short-form if clauses here.
Codecov Report
@@ Coverage Diff @@
## main #239 +/- ##
==========================================
+ Coverage 99.06% 99.10% +0.03%
==========================================
Files 58 58
Lines 9713 9792 +79
==========================================
+ Hits 9622 9704 +82
+ Misses 91 88 -3
Continue to review full report at Codecov.
|
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 is another very good PR, removing the exit(1)
calls from inside the library (that lintian has been complaining about for a long time). Thank you Simon!
I added only a few inline nits about formatting things. I will push those changes and get this PR merged.
src/nm.h
Outdated
NETPLAN_INTERNAL gboolean | ||
netplan_nm_cleanup(const char* rootdir); | ||
|
||
|
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.
Add comment about deprecated API, instead of additional whitespace.
@@ -787,7 +789,8 @@ write_nm_conf_access_point(NetplanNetDefinition* def, const char* rootdir, const | |||
/* We can only write search domains and routes if we have an address */ | |||
if (def->ip4_addresses || def->dhcp4) { | |||
write_search_domains(def, "ipv4", kf); | |||
write_routes(def, kf, AF_INET); | |||
if (!write_routes(def, kf, AF_INET, error)) | |||
return FALSE; |
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.
Fix test coverage.
src/networkd.c
Outdated
/** | ||
* Generate networkd configuration in @rootdir/run/systemd/network/ from the | ||
* parsed #netdefs. | ||
* @rootdir: If not %NULL, generate configuration in this root directory | ||
* (useful for testing). | ||
* Returns: TRUE if @def applies to networkd, FALSE otherwise. | ||
*/ |
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.
We should probably keep that comment in networkd.c
(instead of abi_compat.c)
/** | ||
* Create enablement symlink for systemd-networkd.service. | ||
*/ |
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.
Let's not drop this comment, but move it to generate.c
, too.
passed integration tests with ABI compatibility check:
|
Description
New APIs for the generator APIs of libnetplan, with proper error handling and support for the NetplanState feature.
API and ABI compatibility is retained for now. Depends on #232 and #234, as usual see the commits after the merge.
Checklist
make check
successfully.make check-coverage
).