Skip to content

Commit 2e8fa56

Browse files
authored
Drop unused legacy/compat API (#262)
Libnetplan at out latest version 0.103 did not expose several symbols that we carry along (and would newly introduce as "legacy"/"compat" symbols in 0.104). This is due to the fact that the Makefile changed and those functions had been linked directly into the generate binary before, whereas they are now part of libnetplan.so. As those symbols have not been part of the library before, we should not introduce them now as legacy symbols, as no consumer can be using it from the old library. COMMITS: * openvswitch: make use of new netplan_netdef_write_network_file() API * abi_compat: drop legacy API that has never been part of the library
1 parent 4d74e2e commit 2e8fa56

File tree

8 files changed

+13
-154
lines changed

8 files changed

+13
-154
lines changed

src/abi_compat.c

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -82,124 +82,6 @@ netplan_clear_netdefs()
8282
netplan_parser_reset(&global_parser);
8383
return n;
8484
}
85-
86-
// LCOV_EXCL_START
87-
NETPLAN_INTERNAL void
88-
write_network_file(const NetplanNetDefinition* def, const char* rootdir, const char* path)
89-
{
90-
GError* error = NULL;
91-
if (!netplan_netdef_write_network_file(&global_state, def, rootdir, path, NULL, &error))
92-
{
93-
g_fprintf(stderr, "%s", error->message);
94-
exit(1);
95-
}
96-
}
97-
98-
/**
99-
* Generate networkd configuration in @rootdir/run/systemd/network/ from the
100-
* parsed #netdefs.
101-
* @rootdir: If not %NULL, generate configuration in this root directory
102-
* (useful for testing).
103-
* Returns: TRUE if @def applies to networkd, FALSE otherwise.
104-
*/
105-
gboolean
106-
write_networkd_conf(const NetplanNetDefinition* def, const char* rootdir)
107-
{
108-
GError* error = NULL;
109-
gboolean has_been_written;
110-
if (!netplan_netdef_write_networkd(&global_state, def, rootdir, &has_been_written, &error))
111-
{
112-
g_fprintf(stderr, "%s", error->message);
113-
exit(1);
114-
}
115-
return has_been_written;
116-
}
117-
118-
NETPLAN_INTERNAL void
119-
cleanup_networkd_conf(const char* rootdir)
120-
{
121-
netplan_networkd_cleanup(rootdir);
122-
}
123-
124-
// There only for compatibility purposes, the proper implementation is now directly
125-
// in the `generate` binary.
126-
NETPLAN_ABI void
127-
enable_networkd(const char* generator_dir)
128-
{
129-
g_autofree char* link = g_build_path(G_DIR_SEPARATOR_S, generator_dir, "multi-user.target.wants", "systemd-networkd.service", NULL);
130-
g_debug("We created networkd configuration, adding %s enablement symlink", link);
131-
safe_mkdir_p_dir(link);
132-
if (symlink("../systemd-networkd.service", link) < 0 && errno != EEXIST) {
133-
g_fprintf(stderr, "failed to create enablement symlink: %m\n");
134-
exit(1);
135-
}
136-
137-
g_autofree char* link2 = g_build_path(G_DIR_SEPARATOR_S, generator_dir, "network-online.target.wants", "systemd-networkd-wait-online.service", NULL);
138-
safe_mkdir_p_dir(link2);
139-
if (symlink("/lib/systemd/system/systemd-networkd-wait-online.service", link2) < 0 && errno != EEXIST) {
140-
g_fprintf(stderr, "failed to create enablement symlink: %m\n");
141-
exit(1);
142-
}
143-
}
144-
145-
NETPLAN_INTERNAL void
146-
write_nm_conf(NetplanNetDefinition* def, const char* rootdir)
147-
{
148-
GError* error = NULL;
149-
if (!netplan_netdef_write_nm(&global_state, def, rootdir, NULL, &error)) {
150-
g_fprintf(stderr, "%s", error->message);
151-
exit(1);
152-
}
153-
}
154-
155-
NETPLAN_INTERNAL void
156-
write_nm_conf_finish(const char* rootdir)
157-
{
158-
/* Original implementation had no error possible!! */
159-
g_assert(netplan_state_finish_nm_write(&global_state, rootdir, NULL));
160-
}
161-
162-
NETPLAN_INTERNAL void
163-
cleanup_nm_conf(const char* rootdir)
164-
{
165-
netplan_nm_cleanup(rootdir);
166-
}
167-
168-
NETPLAN_INTERNAL void
169-
write_ovs_conf(const NetplanNetDefinition* def, const char* rootdir)
170-
{
171-
GError* error = NULL;
172-
if (!netplan_netdef_write_ovs(&global_state, def, rootdir, NULL, &error)) {
173-
g_fprintf(stderr, "%s", error->message);
174-
exit(1);
175-
}
176-
}
177-
178-
NETPLAN_INTERNAL void
179-
write_ovs_conf_finish(const char* rootdir)
180-
{
181-
/* Original implementation had no error possible!! */
182-
g_assert(netplan_state_finish_ovs_write(&global_state, rootdir, NULL));
183-
}
184-
185-
NETPLAN_INTERNAL void
186-
cleanup_ovs_conf(const char* rootdir)
187-
{
188-
netplan_ovs_cleanup(rootdir);
189-
}
190-
191-
NETPLAN_INTERNAL void
192-
write_sriov_conf_finish(const char* rootdir)
193-
{
194-
/* Original implementation had no error possible!! */
195-
g_assert(netplan_state_finish_sriov_write(&global_state, rootdir, NULL));
196-
}
197-
198-
NETPLAN_INTERNAL void
199-
cleanup_sriov_conf(const char* rootdir)
200-
{
201-
netplan_sriov_cleanup(rootdir);
202-
}
20385
// LCOV_EXCL_STOP
20486

20587
gboolean

src/netplan.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,3 @@ netplan_state_dump_yaml(const NetplanState* np_state, int out_fd, GError** error
10031003

10041004
return netplan_netdef_list_write_yaml(np_state, np_state->netdefs_ordered, out_fd, error);
10051005
}
1006-
1007-
/* XXX: implement the following functions, once needed:
1008-
void write_netplan_conf_finish(const char* rootdir)
1009-
void cleanup_netplan_conf(const char* rootdir)
1010-
*/

src/networkd.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,3 @@ netplan_netdef_write_network_file(
3939

4040
NETPLAN_INTERNAL void
4141
netplan_networkd_cleanup(const char* rootdir);
42-
43-
/* Deprecated API */
44-
NETPLAN_INTERNAL gboolean
45-
write_networkd_conf(const NetplanNetDefinition* def, const char* rootdir);
46-
NETPLAN_INTERNAL void
47-
write_network_file(const NetplanNetDefinition* def, const char* rootdir, const char* path);
48-
NETPLAN_INTERNAL void
49-
cleanup_networkd_conf(const char* rootdir);

src/nm.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,3 @@ netplan_state_finish_nm_write(
3535

3636
NETPLAN_INTERNAL gboolean
3737
netplan_nm_cleanup(const char* rootdir);
38-
39-
/* Deprecated API */
40-
NETPLAN_INTERNAL void
41-
write_nm_conf(NetplanNetDefinition* def, const char* rootdir);
42-
NETPLAN_INTERNAL void
43-
write_nm_conf_finish(const char* rootdir);
44-
NETPLAN_INTERNAL void
45-
cleanup_nm_conf(const char* rootdir);

src/openvswitch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ netplan_netdef_write_ovs(const NetplanState* np_state, const NetplanNetDefinitio
413413

414414
/* Try writing out a base config */
415415
base_config_path = g_strjoin(NULL, "run/systemd/network/10-netplan-", def->id, NULL);
416-
write_network_file(def, rootdir, base_config_path);
416+
if (!netplan_netdef_write_network_file(np_state, def, rootdir, base_config_path, has_been_written, error))
417+
return FALSE;
417418
} else {
418419
/* Other interfaces must be part of an OVS bridge or bond to carry additional data */
419420
if ( (def->ovs_settings.external_ids && g_hash_table_size(def->ovs_settings.external_ids) > 0)

src/openvswitch.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,3 @@ netplan_state_finish_ovs_write(
3535

3636
NETPLAN_INTERNAL gboolean
3737
netplan_ovs_cleanup(const char* rootdir);
38-
39-
/* Deprecated API */
40-
NETPLAN_INTERNAL void
41-
write_ovs_conf(const NetplanNetDefinition* def, const char* rootdir);
42-
NETPLAN_INTERNAL void
43-
write_ovs_conf_finish(const char* rootdir);
44-
NETPLAN_INTERNAL void
45-
cleanup_ovs_conf(const char* rootdir);

src/sriov.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,3 @@ netplan_state_finish_sriov_write(
2626

2727
NETPLAN_INTERNAL gboolean
2828
netplan_sriov_cleanup(const char* rootdir);
29-
30-
/* Deprecated API */
31-
NETPLAN_INTERNAL void
32-
write_sriov_conf_finish(const char* rootdir);
33-
NETPLAN_INTERNAL void
34-
cleanup_sriov_conf(const char* rootdir);

tests/generator/test_ovs.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,3 +1019,14 @@ def test_bridge_non_ovs_bond(self):
10191019
'Bond=non-ovs-bond'),
10201020
'ovs-br.network': ND_EMPTY % ('ovs-br', 'ipv6'),
10211021
'non-ovs-bond.netdev': '[NetDev]\nName=non-ovs-bond\nKind=bond\n'})
1022+
1023+
def test_ovs_invalid_networkd_config(self):
1024+
err = self.generate('''network:
1025+
version: 2
1026+
bridges:
1027+
br0:
1028+
openvswitch: {}
1029+
ipv6-address-generation: stable-privacy
1030+
''', expect_fail=True)
1031+
self.assert_ovs({'cleanup.service': OVS_CLEANUP % {'iface': 'cleanup'}})
1032+
self.assertIn('br0: ipv6-address-generation mode is not supported by networkd', err)

0 commit comments

Comments
 (0)