X Tutup
Skip to content

Commit 307fe3c

Browse files
committed
network: rename NetworkConfigSection -> ConfigSection
And move it and relevant functions to conf-parser.[ch].
1 parent e5c4289 commit 307fe3c

36 files changed

+196
-196
lines changed

src/network/netdev/l2tp-tunnel.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ static L2tpSession* l2tp_session_free(L2tpSession *s) {
4646
if (s->tunnel && s->section)
4747
ordered_hashmap_remove(s->tunnel->sessions_by_section, s->section);
4848

49-
network_config_section_free(s->section);
49+
config_section_free(s->section);
5050
free(s->name);
5151
return mfree(s);
5252
}
5353

54-
DEFINE_NETWORK_SECTION_FUNCTIONS(L2tpSession, l2tp_session_free);
54+
DEFINE_SECTION_CLEANUP_FUNCTIONS(L2tpSession, l2tp_session_free);
5555

5656
static int l2tp_session_new_static(L2tpTunnel *t, const char *filename, unsigned section_line, L2tpSession **ret) {
57-
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
57+
_cleanup_(config_section_freep) ConfigSection *n = NULL;
5858
_cleanup_(l2tp_session_freep) L2tpSession *s = NULL;
5959
int r;
6060

@@ -63,7 +63,7 @@ static int l2tp_session_new_static(L2tpTunnel *t, const char *filename, unsigned
6363
assert(filename);
6464
assert(section_line > 0);
6565

66-
r = network_config_section_new(filename, section_line, &n);
66+
r = config_section_new(filename, section_line, &n);
6767
if (r < 0)
6868
return r;
6969

@@ -83,7 +83,7 @@ static int l2tp_session_new_static(L2tpTunnel *t, const char *filename, unsigned
8383
.section = TAKE_PTR(n),
8484
};
8585

86-
r = ordered_hashmap_ensure_put(&t->sessions_by_section, &network_config_hash_ops, s->section, s);
86+
r = ordered_hashmap_ensure_put(&t->sessions_by_section, &config_section_hash_ops, s->section, s);
8787
if (r < 0)
8888
return r;
8989

src/network/netdev/l2tp-tunnel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef struct L2tpTunnel L2tpTunnel;
3434

3535
typedef struct L2tpSession {
3636
L2tpTunnel *tunnel;
37-
NetworkConfigSection *section;
37+
ConfigSection *section;
3838

3939
char *name;
4040

src/network/netdev/macsec.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ static ReceiveAssociation* macsec_receive_association_free(ReceiveAssociation *c
4343
if (c->macsec && c->section)
4444
ordered_hashmap_remove(c->macsec->receive_associations_by_section, c->section);
4545

46-
network_config_section_free(c->section);
46+
config_section_free(c->section);
4747
security_association_clear(&c->sa);
4848

4949
return mfree(c);
5050
}
5151

52-
DEFINE_NETWORK_SECTION_FUNCTIONS(ReceiveAssociation, macsec_receive_association_free);
52+
DEFINE_SECTION_CLEANUP_FUNCTIONS(ReceiveAssociation, macsec_receive_association_free);
5353

5454
static int macsec_receive_association_new_static(MACsec *s, const char *filename, unsigned section_line, ReceiveAssociation **ret) {
55-
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
55+
_cleanup_(config_section_freep) ConfigSection *n = NULL;
5656
_cleanup_(macsec_receive_association_freep) ReceiveAssociation *c = NULL;
5757
int r;
5858

@@ -61,7 +61,7 @@ static int macsec_receive_association_new_static(MACsec *s, const char *filename
6161
assert(filename);
6262
assert(section_line > 0);
6363

64-
r = network_config_section_new(filename, section_line, &n);
64+
r = config_section_new(filename, section_line, &n);
6565
if (r < 0)
6666
return r;
6767

@@ -82,7 +82,7 @@ static int macsec_receive_association_new_static(MACsec *s, const char *filename
8282

8383
security_association_init(&c->sa);
8484

85-
r = ordered_hashmap_ensure_put(&s->receive_associations_by_section, &network_config_hash_ops, c->section, c);
85+
r = ordered_hashmap_ensure_put(&s->receive_associations_by_section, &config_section_hash_ops, c->section, c);
8686
if (r < 0)
8787
return r;
8888

@@ -103,12 +103,12 @@ static ReceiveChannel* macsec_receive_channel_free(ReceiveChannel *c) {
103103
ordered_hashmap_remove(c->macsec->receive_channels_by_section, c->section);
104104
}
105105

106-
network_config_section_free(c->section);
106+
config_section_free(c->section);
107107

108108
return mfree(c);
109109
}
110110

111-
DEFINE_NETWORK_SECTION_FUNCTIONS(ReceiveChannel, macsec_receive_channel_free);
111+
DEFINE_SECTION_CLEANUP_FUNCTIONS(ReceiveChannel, macsec_receive_channel_free);
112112

113113
static int macsec_receive_channel_new(MACsec *s, uint64_t sci, ReceiveChannel **ret) {
114114
ReceiveChannel *c;
@@ -129,7 +129,7 @@ static int macsec_receive_channel_new(MACsec *s, uint64_t sci, ReceiveChannel **
129129
}
130130

131131
static int macsec_receive_channel_new_static(MACsec *s, const char *filename, unsigned section_line, ReceiveChannel **ret) {
132-
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
132+
_cleanup_(config_section_freep) ConfigSection *n = NULL;
133133
_cleanup_(macsec_receive_channel_freep) ReceiveChannel *c = NULL;
134134
int r;
135135

@@ -138,7 +138,7 @@ static int macsec_receive_channel_new_static(MACsec *s, const char *filename, un
138138
assert(filename);
139139
assert(section_line > 0);
140140

141-
r = network_config_section_new(filename, section_line, &n);
141+
r = config_section_new(filename, section_line, &n);
142142
if (r < 0)
143143
return r;
144144

@@ -154,7 +154,7 @@ static int macsec_receive_channel_new_static(MACsec *s, const char *filename, un
154154

155155
c->section = TAKE_PTR(n);
156156

157-
r = ordered_hashmap_ensure_put(&s->receive_channels_by_section, &network_config_hash_ops, c->section, c);
157+
r = ordered_hashmap_ensure_put(&s->receive_channels_by_section, &config_section_hash_ops, c->section, c);
158158
if (r < 0)
159159
return r;
160160

@@ -170,16 +170,16 @@ static TransmitAssociation* macsec_transmit_association_free(TransmitAssociation
170170
if (a->macsec && a->section)
171171
ordered_hashmap_remove(a->macsec->transmit_associations_by_section, a->section);
172172

173-
network_config_section_free(a->section);
173+
config_section_free(a->section);
174174
security_association_clear(&a->sa);
175175

176176
return mfree(a);
177177
}
178178

179-
DEFINE_NETWORK_SECTION_FUNCTIONS(TransmitAssociation, macsec_transmit_association_free);
179+
DEFINE_SECTION_CLEANUP_FUNCTIONS(TransmitAssociation, macsec_transmit_association_free);
180180

181181
static int macsec_transmit_association_new_static(MACsec *s, const char *filename, unsigned section_line, TransmitAssociation **ret) {
182-
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
182+
_cleanup_(config_section_freep) ConfigSection *n = NULL;
183183
_cleanup_(macsec_transmit_association_freep) TransmitAssociation *a = NULL;
184184
int r;
185185

@@ -188,7 +188,7 @@ static int macsec_transmit_association_new_static(MACsec *s, const char *filenam
188188
assert(filename);
189189
assert(section_line > 0);
190190

191-
r = network_config_section_new(filename, section_line, &n);
191+
r = config_section_new(filename, section_line, &n);
192192
if (r < 0)
193193
return r;
194194

@@ -209,7 +209,7 @@ static int macsec_transmit_association_new_static(MACsec *s, const char *filenam
209209

210210
security_association_init(&a->sa);
211211

212-
r = ordered_hashmap_ensure_put(&s->transmit_associations_by_section, &network_config_hash_ops, a->section, a);
212+
r = ordered_hashmap_ensure_put(&s->transmit_associations_by_section, &config_section_hash_ops, a->section, a);
213213
if (r < 0)
214214
return r;
215215

src/network/netdev/macsec.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ typedef struct SecurityAssociation {
3939

4040
typedef struct TransmitAssociation {
4141
MACsec *macsec;
42-
NetworkConfigSection *section;
42+
ConfigSection *section;
4343

4444
SecurityAssociation sa;
4545
} TransmitAssociation;
4646

4747
typedef struct ReceiveAssociation {
4848
MACsec *macsec;
49-
NetworkConfigSection *section;
49+
ConfigSection *section;
5050

5151
MACsecSCI sci;
5252
SecurityAssociation sa;
5353
} ReceiveAssociation;
5454

5555
typedef struct ReceiveChannel {
5656
MACsec *macsec;
57-
NetworkConfigSection *section;
57+
ConfigSection *section;
5858

5959
MACsecSCI sci;
6060
ReceiveAssociation *rxsa[MACSEC_MAX_ASSOCIATION_NUMBER];

src/network/netdev/wireguard.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static WireguardPeer* wireguard_peer_free(WireguardPeer *peer) {
4747
hashmap_remove(peer->wireguard->peers_by_section, peer->section);
4848
}
4949

50-
network_config_section_free(peer->section);
50+
config_section_free(peer->section);
5151

5252
while ((mask = peer->ipmasks)) {
5353
LIST_REMOVE(ipmasks, peer->ipmasks, mask);
@@ -65,10 +65,10 @@ static WireguardPeer* wireguard_peer_free(WireguardPeer *peer) {
6565
return mfree(peer);
6666
}
6767

68-
DEFINE_NETWORK_SECTION_FUNCTIONS(WireguardPeer, wireguard_peer_free);
68+
DEFINE_SECTION_CLEANUP_FUNCTIONS(WireguardPeer, wireguard_peer_free);
6969

7070
static int wireguard_peer_new_static(Wireguard *w, const char *filename, unsigned section_line, WireguardPeer **ret) {
71-
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
71+
_cleanup_(config_section_freep) ConfigSection *n = NULL;
7272
_cleanup_(wireguard_peer_freep) WireguardPeer *peer = NULL;
7373
int r;
7474

@@ -77,7 +77,7 @@ static int wireguard_peer_new_static(Wireguard *w, const char *filename, unsigne
7777
assert(filename);
7878
assert(section_line > 0);
7979

80-
r = network_config_section_new(filename, section_line, &n);
80+
r = config_section_new(filename, section_line, &n);
8181
if (r < 0)
8282
return r;
8383

@@ -99,7 +99,7 @@ static int wireguard_peer_new_static(Wireguard *w, const char *filename, unsigne
9999

100100
LIST_PREPEND(peers, w->peers, peer);
101101

102-
r = hashmap_ensure_put(&w->peers_by_section, &network_config_hash_ops, peer->section, peer);
102+
r = hashmap_ensure_put(&w->peers_by_section, &config_section_hash_ops, peer->section, peer);
103103
if (r < 0)
104104
return r;
105105

src/network/netdev/wireguard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef struct WireguardIPmask {
2424

2525
typedef struct WireguardPeer {
2626
Wireguard *wireguard;
27-
NetworkConfigSection *section;
27+
ConfigSection *section;
2828

2929
uint8_t public_key[WG_KEY_LEN];
3030
uint8_t preshared_key[WG_KEY_LEN];

src/network/networkd-address-label.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ AddressLabel *address_label_free(AddressLabel *label) {
2121
hashmap_remove(label->network->address_labels_by_section, label->section);
2222
}
2323

24-
network_config_section_free(label->section);
24+
config_section_free(label->section);
2525
return mfree(label);
2626
}
2727

28-
DEFINE_NETWORK_SECTION_FUNCTIONS(AddressLabel, address_label_free);
28+
DEFINE_SECTION_CLEANUP_FUNCTIONS(AddressLabel, address_label_free);
2929

3030
static int address_label_new_static(Network *network, const char *filename, unsigned section_line, AddressLabel **ret) {
31-
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
31+
_cleanup_(config_section_freep) ConfigSection *n = NULL;
3232
_cleanup_(address_label_freep) AddressLabel *label = NULL;
3333
int r;
3434

@@ -37,7 +37,7 @@ static int address_label_new_static(Network *network, const char *filename, unsi
3737
assert(filename);
3838
assert(section_line > 0);
3939

40-
r = network_config_section_new(filename, section_line, &n);
40+
r = config_section_new(filename, section_line, &n);
4141
if (r < 0)
4242
return r;
4343

@@ -57,7 +57,7 @@ static int address_label_new_static(Network *network, const char *filename, unsi
5757
.label = UINT32_MAX,
5858
};
5959

60-
r = hashmap_ensure_put(&network->address_labels_by_section, &network_config_hash_ops, label->section, label);
60+
r = hashmap_ensure_put(&network->address_labels_by_section, &config_section_hash_ops, label->section, label);
6161
if (r < 0)
6262
return r;
6363

src/network/networkd-address-label.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ typedef struct Request Request;
1313

1414
typedef struct AddressLabel {
1515
Network *network;
16-
NetworkConfigSection *section;
16+
ConfigSection *section;
1717

1818
uint32_t label;
1919
struct in6_addr prefix;

src/network/networkd-address.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ int address_new(Address **ret) {
7777
}
7878

7979
static int address_new_static(Network *network, const char *filename, unsigned section_line, Address **ret) {
80-
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
80+
_cleanup_(config_section_freep) ConfigSection *n = NULL;
8181
_cleanup_(address_freep) Address *address = NULL;
8282
int r;
8383

@@ -86,7 +86,7 @@ static int address_new_static(Network *network, const char *filename, unsigned s
8686
assert(filename);
8787
assert(section_line > 0);
8888

89-
r = network_config_section_new(filename, section_line, &n);
89+
r = config_section_new(filename, section_line, &n);
9090
if (r < 0)
9191
return r;
9292

@@ -107,7 +107,7 @@ static int address_new_static(Network *network, const char *filename, unsigned s
107107
address->section = TAKE_PTR(n);
108108
address->source = NETWORK_CONFIG_SOURCE_STATIC;
109109

110-
r = ordered_hashmap_ensure_put(&network->addresses_by_section, &network_config_hash_ops, address->section, address);
110+
r = ordered_hashmap_ensure_put(&network->addresses_by_section, &config_section_hash_ops, address->section, address);
111111
if (r < 0)
112112
return r;
113113

@@ -134,7 +134,7 @@ Address *address_free(Address *address) {
134134

135135
sd_ipv4acd_unref(address->acd);
136136

137-
network_config_section_free(address->section);
137+
config_section_free(address->section);
138138
free(address->label);
139139
return mfree(address);
140140
}

src/network/networkd-address.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ typedef int (*address_ready_callback_t)(Address *address);
2222
struct Address {
2323
Link *link;
2424
Network *network;
25-
NetworkConfigSection *section;
25+
ConfigSection *section;
2626
NetworkConfigSource source;
2727
NetworkConfigState state;
2828
union in_addr_union provider; /* DHCP server or router address */
@@ -72,7 +72,7 @@ int address_dup(const Address *src, Address **ret);
7272
bool address_is_ready(const Address *a);
7373
void address_set_broadcast(Address *a);
7474

75-
DEFINE_NETWORK_SECTION_FUNCTIONS(Address, address_free);
75+
DEFINE_SECTION_CLEANUP_FUNCTIONS(Address, address_free);
7676

7777
int link_drop_addresses(Link *link);
7878
int link_drop_foreign_addresses(Link *link);

0 commit comments

Comments
 (0)
X Tutup