network: rename NetworkConfigSection -> ConfigSection

And move it and relevant functions to conf-parser.[ch].
This commit is contained in:
Yu Watanabe
2021-12-27 10:34:24 +09:00
parent e5c4289a9d
commit 307fe3cdf2
36 changed files with 196 additions and 196 deletions

View File

@@ -46,15 +46,15 @@ static L2tpSession* l2tp_session_free(L2tpSession *s) {
if (s->tunnel && s->section)
ordered_hashmap_remove(s->tunnel->sessions_by_section, s->section);
network_config_section_free(s->section);
config_section_free(s->section);
free(s->name);
return mfree(s);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(L2tpSession, l2tp_session_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(L2tpSession, l2tp_session_free);
static int l2tp_session_new_static(L2tpTunnel *t, const char *filename, unsigned section_line, L2tpSession **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(l2tp_session_freep) L2tpSession *s = NULL;
int r;
@@ -63,7 +63,7 @@ static int l2tp_session_new_static(L2tpTunnel *t, const char *filename, unsigned
assert(filename);
assert(section_line > 0);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -83,7 +83,7 @@ static int l2tp_session_new_static(L2tpTunnel *t, const char *filename, unsigned
.section = TAKE_PTR(n),
};
r = ordered_hashmap_ensure_put(&t->sessions_by_section, &network_config_hash_ops, s->section, s);
r = ordered_hashmap_ensure_put(&t->sessions_by_section, &config_section_hash_ops, s->section, s);
if (r < 0)
return r;

View File

@@ -34,7 +34,7 @@ typedef struct L2tpTunnel L2tpTunnel;
typedef struct L2tpSession {
L2tpTunnel *tunnel;
NetworkConfigSection *section;
ConfigSection *section;
char *name;

View File

@@ -43,16 +43,16 @@ static ReceiveAssociation* macsec_receive_association_free(ReceiveAssociation *c
if (c->macsec && c->section)
ordered_hashmap_remove(c->macsec->receive_associations_by_section, c->section);
network_config_section_free(c->section);
config_section_free(c->section);
security_association_clear(&c->sa);
return mfree(c);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(ReceiveAssociation, macsec_receive_association_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(ReceiveAssociation, macsec_receive_association_free);
static int macsec_receive_association_new_static(MACsec *s, const char *filename, unsigned section_line, ReceiveAssociation **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(macsec_receive_association_freep) ReceiveAssociation *c = NULL;
int r;
@@ -61,7 +61,7 @@ static int macsec_receive_association_new_static(MACsec *s, const char *filename
assert(filename);
assert(section_line > 0);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -82,7 +82,7 @@ static int macsec_receive_association_new_static(MACsec *s, const char *filename
security_association_init(&c->sa);
r = ordered_hashmap_ensure_put(&s->receive_associations_by_section, &network_config_hash_ops, c->section, c);
r = ordered_hashmap_ensure_put(&s->receive_associations_by_section, &config_section_hash_ops, c->section, c);
if (r < 0)
return r;
@@ -103,12 +103,12 @@ static ReceiveChannel* macsec_receive_channel_free(ReceiveChannel *c) {
ordered_hashmap_remove(c->macsec->receive_channels_by_section, c->section);
}
network_config_section_free(c->section);
config_section_free(c->section);
return mfree(c);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(ReceiveChannel, macsec_receive_channel_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(ReceiveChannel, macsec_receive_channel_free);
static int macsec_receive_channel_new(MACsec *s, uint64_t sci, ReceiveChannel **ret) {
ReceiveChannel *c;
@@ -129,7 +129,7 @@ static int macsec_receive_channel_new(MACsec *s, uint64_t sci, ReceiveChannel **
}
static int macsec_receive_channel_new_static(MACsec *s, const char *filename, unsigned section_line, ReceiveChannel **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(macsec_receive_channel_freep) ReceiveChannel *c = NULL;
int r;
@@ -138,7 +138,7 @@ static int macsec_receive_channel_new_static(MACsec *s, const char *filename, un
assert(filename);
assert(section_line > 0);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -154,7 +154,7 @@ static int macsec_receive_channel_new_static(MACsec *s, const char *filename, un
c->section = TAKE_PTR(n);
r = ordered_hashmap_ensure_put(&s->receive_channels_by_section, &network_config_hash_ops, c->section, c);
r = ordered_hashmap_ensure_put(&s->receive_channels_by_section, &config_section_hash_ops, c->section, c);
if (r < 0)
return r;
@@ -170,16 +170,16 @@ static TransmitAssociation* macsec_transmit_association_free(TransmitAssociation
if (a->macsec && a->section)
ordered_hashmap_remove(a->macsec->transmit_associations_by_section, a->section);
network_config_section_free(a->section);
config_section_free(a->section);
security_association_clear(&a->sa);
return mfree(a);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(TransmitAssociation, macsec_transmit_association_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(TransmitAssociation, macsec_transmit_association_free);
static int macsec_transmit_association_new_static(MACsec *s, const char *filename, unsigned section_line, TransmitAssociation **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(macsec_transmit_association_freep) TransmitAssociation *a = NULL;
int r;
@@ -188,7 +188,7 @@ static int macsec_transmit_association_new_static(MACsec *s, const char *filenam
assert(filename);
assert(section_line > 0);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -209,7 +209,7 @@ static int macsec_transmit_association_new_static(MACsec *s, const char *filenam
security_association_init(&a->sa);
r = ordered_hashmap_ensure_put(&s->transmit_associations_by_section, &network_config_hash_ops, a->section, a);
r = ordered_hashmap_ensure_put(&s->transmit_associations_by_section, &config_section_hash_ops, a->section, a);
if (r < 0)
return r;

View File

@@ -39,14 +39,14 @@ typedef struct SecurityAssociation {
typedef struct TransmitAssociation {
MACsec *macsec;
NetworkConfigSection *section;
ConfigSection *section;
SecurityAssociation sa;
} TransmitAssociation;
typedef struct ReceiveAssociation {
MACsec *macsec;
NetworkConfigSection *section;
ConfigSection *section;
MACsecSCI sci;
SecurityAssociation sa;
@@ -54,7 +54,7 @@ typedef struct ReceiveAssociation {
typedef struct ReceiveChannel {
MACsec *macsec;
NetworkConfigSection *section;
ConfigSection *section;
MACsecSCI sci;
ReceiveAssociation *rxsa[MACSEC_MAX_ASSOCIATION_NUMBER];

View File

@@ -47,7 +47,7 @@ static WireguardPeer* wireguard_peer_free(WireguardPeer *peer) {
hashmap_remove(peer->wireguard->peers_by_section, peer->section);
}
network_config_section_free(peer->section);
config_section_free(peer->section);
while ((mask = peer->ipmasks)) {
LIST_REMOVE(ipmasks, peer->ipmasks, mask);
@@ -65,10 +65,10 @@ static WireguardPeer* wireguard_peer_free(WireguardPeer *peer) {
return mfree(peer);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(WireguardPeer, wireguard_peer_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(WireguardPeer, wireguard_peer_free);
static int wireguard_peer_new_static(Wireguard *w, const char *filename, unsigned section_line, WireguardPeer **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(wireguard_peer_freep) WireguardPeer *peer = NULL;
int r;
@@ -77,7 +77,7 @@ static int wireguard_peer_new_static(Wireguard *w, const char *filename, unsigne
assert(filename);
assert(section_line > 0);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -99,7 +99,7 @@ static int wireguard_peer_new_static(Wireguard *w, const char *filename, unsigne
LIST_PREPEND(peers, w->peers, peer);
r = hashmap_ensure_put(&w->peers_by_section, &network_config_hash_ops, peer->section, peer);
r = hashmap_ensure_put(&w->peers_by_section, &config_section_hash_ops, peer->section, peer);
if (r < 0)
return r;

View File

@@ -24,7 +24,7 @@ typedef struct WireguardIPmask {
typedef struct WireguardPeer {
Wireguard *wireguard;
NetworkConfigSection *section;
ConfigSection *section;
uint8_t public_key[WG_KEY_LEN];
uint8_t preshared_key[WG_KEY_LEN];

View File

@@ -21,14 +21,14 @@ AddressLabel *address_label_free(AddressLabel *label) {
hashmap_remove(label->network->address_labels_by_section, label->section);
}
network_config_section_free(label->section);
config_section_free(label->section);
return mfree(label);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(AddressLabel, address_label_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(AddressLabel, address_label_free);
static int address_label_new_static(Network *network, const char *filename, unsigned section_line, AddressLabel **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(address_label_freep) AddressLabel *label = NULL;
int r;
@@ -37,7 +37,7 @@ static int address_label_new_static(Network *network, const char *filename, unsi
assert(filename);
assert(section_line > 0);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -57,7 +57,7 @@ static int address_label_new_static(Network *network, const char *filename, unsi
.label = UINT32_MAX,
};
r = hashmap_ensure_put(&network->address_labels_by_section, &network_config_hash_ops, label->section, label);
r = hashmap_ensure_put(&network->address_labels_by_section, &config_section_hash_ops, label->section, label);
if (r < 0)
return r;

View File

@@ -13,7 +13,7 @@ typedef struct Request Request;
typedef struct AddressLabel {
Network *network;
NetworkConfigSection *section;
ConfigSection *section;
uint32_t label;
struct in6_addr prefix;

View File

@@ -77,7 +77,7 @@ int address_new(Address **ret) {
}
static int address_new_static(Network *network, const char *filename, unsigned section_line, Address **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(address_freep) Address *address = NULL;
int r;
@@ -86,7 +86,7 @@ static int address_new_static(Network *network, const char *filename, unsigned s
assert(filename);
assert(section_line > 0);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -107,7 +107,7 @@ static int address_new_static(Network *network, const char *filename, unsigned s
address->section = TAKE_PTR(n);
address->source = NETWORK_CONFIG_SOURCE_STATIC;
r = ordered_hashmap_ensure_put(&network->addresses_by_section, &network_config_hash_ops, address->section, address);
r = ordered_hashmap_ensure_put(&network->addresses_by_section, &config_section_hash_ops, address->section, address);
if (r < 0)
return r;
@@ -134,7 +134,7 @@ Address *address_free(Address *address) {
sd_ipv4acd_unref(address->acd);
network_config_section_free(address->section);
config_section_free(address->section);
free(address->label);
return mfree(address);
}

View File

@@ -22,7 +22,7 @@ typedef int (*address_ready_callback_t)(Address *address);
struct Address {
Link *link;
Network *network;
NetworkConfigSection *section;
ConfigSection *section;
NetworkConfigSource source;
NetworkConfigState state;
union in_addr_union provider; /* DHCP server or router address */
@@ -72,7 +72,7 @@ int address_dup(const Address *src, Address **ret);
bool address_is_ready(const Address *a);
void address_set_broadcast(Address *a);
DEFINE_NETWORK_SECTION_FUNCTIONS(Address, address_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(Address, address_free);
int link_drop_addresses(Link *link);
int link_drop_foreign_addresses(Link *link);

View File

@@ -32,13 +32,13 @@ BridgeFDB *bridge_fdb_free(BridgeFDB *fdb) {
hashmap_remove(fdb->network->bridge_fdb_entries_by_section, fdb->section);
}
network_config_section_free(fdb->section);
config_section_free(fdb->section);
free(fdb->outgoing_ifname);
return mfree(fdb);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(BridgeFDB, bridge_fdb_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(BridgeFDB, bridge_fdb_free);
/* create a new FDB entry or get an existing one. */
static int bridge_fdb_new_static(
@@ -47,7 +47,7 @@ static int bridge_fdb_new_static(
unsigned section_line,
BridgeFDB **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(bridge_fdb_freep) BridgeFDB *fdb = NULL;
int r;
@@ -56,7 +56,7 @@ static int bridge_fdb_new_static(
assert(filename);
assert(section_line > 0);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -83,7 +83,7 @@ static int bridge_fdb_new_static(
.ntf_flags = NEIGHBOR_CACHE_ENTRY_FLAGS_SELF,
};
r = hashmap_ensure_put(&network->bridge_fdb_entries_by_section, &network_config_hash_ops, fdb->section, fdb);
r = hashmap_ensure_put(&network->bridge_fdb_entries_by_section, &config_section_hash_ops, fdb->section, fdb);
if (r < 0)
return r;

View File

@@ -27,7 +27,7 @@ typedef enum NeighborCacheEntryFlags {
typedef struct BridgeFDB {
Network *network;
NetworkConfigSection *section;
ConfigSection *section;
uint32_t vni;

View File

@@ -24,12 +24,12 @@ BridgeMDB *bridge_mdb_free(BridgeMDB *mdb) {
hashmap_remove(mdb->network->bridge_mdb_entries_by_section, mdb->section);
}
network_config_section_free(mdb->section);
config_section_free(mdb->section);
return mfree(mdb);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(BridgeMDB, bridge_mdb_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(BridgeMDB, bridge_mdb_free);
/* create a new MDB entry or get an existing one. */
static int bridge_mdb_new_static(
@@ -38,7 +38,7 @@ static int bridge_mdb_new_static(
unsigned section_line,
BridgeMDB **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(bridge_mdb_freep) BridgeMDB *mdb = NULL;
int r;
@@ -47,7 +47,7 @@ static int bridge_mdb_new_static(
assert(filename);
assert(section_line > 0);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -72,7 +72,7 @@ static int bridge_mdb_new_static(
.section = TAKE_PTR(n),
};
r = hashmap_ensure_put(&network->bridge_mdb_entries_by_section, &network_config_hash_ops, mdb->section, mdb);
r = hashmap_ensure_put(&network->bridge_mdb_entries_by_section, &config_section_hash_ops, mdb->section, mdb);
if (r < 0)
return r;

View File

@@ -13,7 +13,7 @@ typedef struct Request Request;
typedef struct BridgeMDB {
Network *network;
NetworkConfigSection *section;
ConfigSection *section;
int family;
union in_addr_union group_addr;

View File

@@ -7,7 +7,7 @@
#include "networkd-network.h"
#include "networkd-util.h"
DEFINE_NETWORK_SECTION_FUNCTIONS(DHCPStaticLease, dhcp_static_lease_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(DHCPStaticLease, dhcp_static_lease_free);
DHCPStaticLease *dhcp_static_lease_free(DHCPStaticLease *static_lease) {
if (!static_lease)
@@ -16,7 +16,7 @@ DHCPStaticLease *dhcp_static_lease_free(DHCPStaticLease *static_lease) {
if (static_lease->network && static_lease->section)
hashmap_remove(static_lease->network->dhcp_static_leases_by_section, static_lease->section);
network_config_section_free(static_lease->section);
config_section_free(static_lease->section);
free(static_lease->client_id);
return mfree(static_lease);
}
@@ -35,7 +35,7 @@ static int dhcp_static_lease_new(DHCPStaticLease **ret) {
}
static int lease_new_static(Network *network, const char *filename, unsigned section_line, DHCPStaticLease **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(dhcp_static_lease_freep) DHCPStaticLease *static_lease = NULL;
int r;
@@ -44,7 +44,7 @@ static int lease_new_static(Network *network, const char *filename, unsigned sec
assert(section_line > 0);
assert(ret);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -60,7 +60,7 @@ static int lease_new_static(Network *network, const char *filename, unsigned sec
static_lease->network = network;
static_lease->section = TAKE_PTR(n);
r = hashmap_ensure_put(&network->dhcp_static_leases_by_section, &network_config_hash_ops, static_lease->section, static_lease);
r = hashmap_ensure_put(&network->dhcp_static_leases_by_section, &config_section_hash_ops, static_lease->section, static_lease);
if (r < 0)
return r;

View File

@@ -8,11 +8,11 @@
#include "in-addr-util.h"
typedef struct Network Network;
typedef struct NetworkConfigSection NetworkConfigSection;
typedef struct ConfigSection ConfigSection;
typedef struct DHCPStaticLease {
Network *network;
NetworkConfigSection *section;
ConfigSection *section;
struct in_addr address;
uint8_t *client_id;

View File

@@ -19,7 +19,7 @@ Neighbor *neighbor_free(Neighbor *neighbor) {
hashmap_remove(neighbor->network->neighbors_by_section, neighbor->section);
}
network_config_section_free(neighbor->section);
config_section_free(neighbor->section);
if (neighbor->link)
set_remove(neighbor->link->neighbors, neighbor);
@@ -27,10 +27,10 @@ Neighbor *neighbor_free(Neighbor *neighbor) {
return mfree(neighbor);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(Neighbor, neighbor_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(Neighbor, neighbor_free);
static int neighbor_new_static(Network *network, const char *filename, unsigned section_line, Neighbor **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(neighbor_freep) Neighbor *neighbor = NULL;
int r;
@@ -39,7 +39,7 @@ static int neighbor_new_static(Network *network, const char *filename, unsigned
assert(filename);
assert(section_line > 0);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -60,7 +60,7 @@ static int neighbor_new_static(Network *network, const char *filename, unsigned
.source = NETWORK_CONFIG_SOURCE_STATIC,
};
r = hashmap_ensure_put(&network->neighbors_by_section, &network_config_hash_ops, neighbor->section, neighbor);
r = hashmap_ensure_put(&network->neighbors_by_section, &config_section_hash_ops, neighbor->section, neighbor);
if (r < 0)
return r;

View File

@@ -18,7 +18,7 @@ typedef struct Request Request;
typedef struct Neighbor {
Network *network;
Link *link;
NetworkConfigSection *section;
ConfigSection *section;
NetworkConfigSource source;
NetworkConfigState state;

View File

@@ -27,7 +27,7 @@ NextHop *nexthop_free(NextHop *nexthop) {
hashmap_remove(nexthop->network->nexthops_by_section, nexthop->section);
}
network_config_section_free(nexthop->section);
config_section_free(nexthop->section);
if (nexthop->link) {
set_remove(nexthop->link->nexthops, nexthop);
@@ -48,7 +48,7 @@ NextHop *nexthop_free(NextHop *nexthop) {
return mfree(nexthop);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(NextHop, nexthop_free);
DEFINE_SECTION_CLEANUP_FUNCTIONS(NextHop, nexthop_free);
static int nexthop_new(NextHop **ret) {
_cleanup_(nexthop_freep) NextHop *nexthop = NULL;
@@ -68,7 +68,7 @@ static int nexthop_new(NextHop **ret) {
}
static int nexthop_new_static(Network *network, const char *filename, unsigned section_line, NextHop **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(nexthop_freep) NextHop *nexthop = NULL;
int r;
@@ -77,7 +77,7 @@ static int nexthop_new_static(Network *network, const char *filename, unsigned s
assert(filename);
assert(section_line > 0);
r = network_config_section_new(filename, section_line, &n);
r = config_section_new(filename, section_line, &n);
if (r < 0)
return r;
@@ -96,7 +96,7 @@ static int nexthop_new_static(Network *network, const char *filename, unsigned s
nexthop->section = TAKE_PTR(n);
nexthop->source = NETWORK_CONFIG_SOURCE_STATIC;
r = hashmap_ensure_put(&network->nexthops_by_section, &network_config_hash_ops, nexthop->section, nexthop);
r = hashmap_ensure_put(&network->nexthops_by_section, &config_section_hash_ops, nexthop->section, nexthop);
if (r < 0)
return r;

View File

@@ -22,7 +22,7 @@ typedef struct NextHop {
Network *network;
Manager *manager;
Link *link;
NetworkConfigSection *section;
ConfigSection *section;
NetworkConfigSource source;
NetworkConfigState state;

Some files were not shown because too many files have changed in this diff Show More