network: sort and rename elements in Network object

This commit is contained in:
Yu Watanabe 2020-10-16 14:56:38 +09:00
parent 69e0f833a3
commit db5756f3f3
5 changed files with 63 additions and 59 deletions

View File

@ -1458,8 +1458,8 @@ int dhcp4_configure(Link *link) {
return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set max attempts: %m");
}
if (link->network->ip_service_type > 0) {
r = sd_dhcp_client_set_service_type(link->dhcp_client, link->network->ip_service_type);
if (link->network->dhcp_ip_service_type > 0) {
r = sd_dhcp_client_set_service_type(link->dhcp_client, link->network->dhcp_ip_service_type);
if (r < 0)
return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set IP service type: %m");
}

View File

@ -1424,7 +1424,7 @@ int dhcp6_configure(Link *link) {
if (r < 0)
return log_link_error_errno(link, r, "DHCP6 CLIENT: Failed to set ifindex: %m");
if (link->network->rapid_commit) {
if (link->network->dhcp6_rapid_commit) {
r = sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_RAPID_COMMIT);
if (r < 0)
return log_link_error_errno(link, r, "DHCP6 CLIENT: Failed to set request flag for rapid commit: %m");

View File

@ -209,14 +209,14 @@ DHCPv4.SendRelease, config_parse_bool,
DHCPv4.SendDecline, config_parse_bool, 0, offsetof(Network, dhcp_send_decline)
DHCPv4.DenyList, config_parse_dhcp_acl_ip_address, 0, 0
DHCPv4.AllowList, config_parse_dhcp_acl_ip_address, 0, 0
DHCPv4.IPServiceType, config_parse_dhcp_ip_service_type, 0, offsetof(Network, ip_service_type)
DHCPv4.IPServiceType, config_parse_dhcp_ip_service_type, 0, offsetof(Network, dhcp_ip_service_type)
DHCPv4.SendOption, config_parse_dhcp_send_option, AF_INET, offsetof(Network, dhcp_client_send_options)
DHCPv4.SendVendorOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_client_send_vendor_options)
DHCPv4.RouteMTUBytes, config_parse_mtu, AF_INET, offsetof(Network, dhcp_route_mtu)
DHCPv4.FallbackLeaseLifetimeSec, config_parse_dhcp_fallback_lease_lifetime, 0, 0
DHCPv6.UseDNS, config_parse_dhcp_use_dns, 0, 0
DHCPv6.UseNTP, config_parse_dhcp_use_ntp, 0, 0
DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, rapid_commit)
DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_rapid_commit)
DHCPv6.MUDURL, config_parse_dhcp6_mud_url, 0, 0
DHCPv6.RequestOptions, config_parse_dhcp_request_options, AF_INET6, 0
DHCPv6.UserClass, config_parse_dhcp_user_class, AF_INET6, offsetof(Network, dhcp6_user_class)
@ -452,7 +452,7 @@ DHCP.RouteTable, config_parse_section_route_table,
DHCP.UseTimezone, config_parse_bool, 0, offsetof(Network, dhcp_use_timezone)
DHCP.IAID, config_parse_iaid, 0, 0
DHCP.ListenPort, config_parse_uint16, 0, offsetof(Network, dhcp_client_port)
DHCP.RapidCommit, config_parse_bool, 0, offsetof(Network, rapid_commit)
DHCP.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_rapid_commit)
DHCP.ForceDHCPv6PDOtherInformation, config_parse_bool, 0, offsetof(Network, dhcp6_force_pd_other_information)
DHCPv4.UseDomainName, config_parse_dhcp_use_domains, 0, offsetof(Network, dhcp_use_domains)
DHCPv4.CriticalConnection, config_parse_tristate, 0, offsetof(Network, dhcp_critical)

View File

@ -329,7 +329,16 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.required_for_online = true,
.required_operstate_for_online = LINK_OPERSTATE_RANGE_DEFAULT,
.arp = -1,
.multicast = -1,
.allmulticast = -1,
.configure_without_carrier = false,
.ignore_carrier_loss = -1,
.keep_configuration = _KEEP_CONFIGURATION_INVALID,
.dhcp = ADDRESS_FAMILY_NO,
.duid.type = _DUID_TYPE_INVALID,
.dhcp_critical = -1,
.dhcp_use_ntp = true,
.dhcp_use_sip = true,
@ -351,8 +360,9 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.dhcp_use_mtu = false,
/* NOTE: from man: UseTimezone=... Defaults to "no".*/
.dhcp_use_timezone = false,
.rapid_commit = true,
.dhcp_ip_service_type = -1,
.dhcp6_rapid_commit = true,
.dhcp6_route_metric = DHCP_ROUTE_METRIC,
.dhcp6_use_ntp = true,
.dhcp6_use_dns = true,
@ -397,17 +407,13 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.ipv6ll_address_gen_mode = _IPV6_LINK_LOCAL_ADDRESS_GEN_MODE_INVALID,
.ipv4_accept_local = -1,
.ipv6_privacy_extensions = IPV6_PRIVACY_EXTENSIONS_NO,
.ipv6_accept_ra = -1,
.ipv6_dad_transmits = -1,
.ipv6_hop_limit = -1,
.ipv6_proxy_ndp = -1,
.duid.type = _DUID_TYPE_INVALID,
.proxy_arp = -1,
.arp = -1,
.multicast = -1,
.allmulticast = -1,
.ipv6_accept_ra_use_dns = true,
.ipv6_accept_ra_use_autonomous_prefix = true,
.ipv6_accept_ra_use_onlink_prefix = true,
@ -415,15 +421,11 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.ipv6_accept_ra_route_table_set = false,
.ipv6_accept_ra_start_dhcp6_client = true,
.configure_without_carrier = false,
.ignore_carrier_loss = -1,
.keep_configuration = _KEEP_CONFIGURATION_INVALID,
.can_triple_sampling = -1,
.can_termination = -1,
.can_listen_only = -1,
.can_fd_mode = -1,
.can_non_iso = -1,
.ip_service_type = -1,
};
r = config_parse_many(

View File

@ -57,12 +57,14 @@ typedef struct NetworkDHCPServerEmitAddress {
struct Network {
Manager *manager;
char *filename;
char *name;
usec_t timestamp;
unsigned n_ref;
char *name;
char *filename;
usec_t timestamp;
char *description;
/* [Match] section */
Set *match_mac;
Set *match_permanent_mac;
char **match_path;
@ -75,8 +77,7 @@ struct Network {
Set *match_bssid;
LIST_HEAD(Condition, conditions);
char *description;
/* Master or stacked netdevs */
NetDev *bridge;
NetDev *bond;
NetDev *vrf;
@ -87,9 +88,31 @@ struct Network {
char *vrf_name;
Hashmap *stacked_netdev_names;
/* [Link] section */
struct ether_addr *mac;
uint32_t mtu;
uint32_t group;
int arp;
int multicast;
int allmulticast;
bool unmanaged;
bool required_for_online; /* Is this network required to be considered online? */
LinkOperationalStateRange required_operstate_for_online;
/* misc settings */
bool configure_without_carrier;
int ignore_carrier_loss;
KeepConfiguration keep_configuration;
char **bind_carrier;
bool default_route_on_device;
bool ip_masquerade;
/* DHCP Client Support */
AddressFamily dhcp;
DHCPClientIdentifier dhcp_client_identifier;
DUID duid;
uint32_t iaid;
bool iaid_set;
char *dhcp_vendor_class_identifier;
char *dhcp_mudurl;
char **dhcp_user_class;
@ -102,7 +125,7 @@ struct Network {
uint32_t dhcp_route_mtu;
uint16_t dhcp_client_port;
int dhcp_critical;
int ip_service_type;
int dhcp_ip_service_type;
bool dhcp_anonymize;
bool dhcp_send_hostname;
bool dhcp_broadcast;
@ -116,7 +139,6 @@ struct Network {
bool dhcp_use_routes;
int dhcp_use_gateway;
bool dhcp_use_timezone;
bool rapid_commit;
bool dhcp_use_hostname;
bool dhcp_route_table_set;
bool dhcp_send_release;
@ -127,14 +149,13 @@ struct Network {
Set *dhcp_request_options;
OrderedHashmap *dhcp_client_send_options;
OrderedHashmap *dhcp_client_send_vendor_options;
OrderedHashmap *dhcp_server_send_options;
OrderedHashmap *dhcp_server_send_vendor_options;
/* DHCPv6 Client support*/
bool dhcp6_use_dns;
bool dhcp6_use_dns_set;
bool dhcp6_use_ntp;
bool dhcp6_use_ntp_set;
bool dhcp6_rapid_commit;
uint8_t dhcp6_pd_length;
uint32_t dhcp6_route_metric;
bool dhcp6_route_metric_set;
@ -146,6 +167,8 @@ struct Network {
OrderedHashmap *dhcp6_client_send_options;
OrderedHashmap *dhcp6_client_send_vendor_options;
Set *dhcp6_request_options;
/* Start DHCPv6 PD also when 'O' RA flag is set, see RFC 7084, WPD-4 */
bool dhcp6_force_pd_other_information;
/* DHCP Server Support */
bool dhcp_server;
@ -156,14 +179,14 @@ struct Network {
usec_t dhcp_server_default_lease_time_usec, dhcp_server_max_lease_time_usec;
uint32_t dhcp_server_pool_offset;
uint32_t dhcp_server_pool_size;
OrderedHashmap *dhcp_server_send_options;
OrderedHashmap *dhcp_server_send_vendor_options;
/* link local addressing support */
AddressFamily link_local;
IPv6LinkLocalAddressGenMode ipv6ll_address_gen_mode;
bool ipv4ll_route;
bool default_route_on_device;
/* IPv6 prefix delegation support */
RADVPrefixDelegation router_prefix_delegation;
usec_t router_lifetime_usec;
@ -176,13 +199,11 @@ struct Network {
struct in6_addr *router_dns;
unsigned n_router_dns;
OrderedSet *router_search_domains;
bool dhcp6_force_pd_other_information; /* Start DHCPv6 PD also when 'O'
RA flag is set, see RFC 7084,
WPD-4 */
/* DHCPv6 Prefix Delegation support */
int64_t dhcp6_pd_subnet_id;
bool dhcp6_pd;
bool dhcp6_pd_assign;
int64_t dhcp6_pd_subnet_id;
union in_addr_union dhcp6_pd_token;
/* Bridge Support */
@ -201,6 +222,7 @@ struct Network {
uint16_t priority;
MulticastRouter multicast_router;
/* Bridge VLAN */
bool use_br_vlan;
uint16_t pvid;
uint32_t br_vid_bitmap[BRIDGE_VLAN_BITMAP_LEN];
@ -218,18 +240,19 @@ struct Network {
int can_fd_mode;
int can_non_iso;
/* sysctl settings */
AddressFamily ip_forward;
bool ip_masquerade;
int ipv4_accept_local;
int ipv6_accept_ra;
int ipv6_dad_transmits;
int ipv6_hop_limit;
int ipv6_proxy_ndp;
Set *ipv6_proxy_ndp_addresses;
int proxy_arp;
uint32_t ipv6_mtu;
IPv6PrivacyExtensions ipv6_privacy_extensions;
int ipv6_proxy_ndp;
Set *ipv6_proxy_ndp_addresses;
/* IPv6 accept RA */
int ipv6_accept_ra;
bool ipv6_accept_ra_use_dns;
bool ipv6_accept_ra_use_autonomous_prefix;
bool ipv6_accept_ra_use_onlink_prefix;
@ -242,26 +265,6 @@ struct Network {
Set *ndisc_deny_listed_prefix;
OrderedSet *ipv6_tokens;
IPv6PrivacyExtensions ipv6_privacy_extensions;
struct ether_addr *mac;
uint32_t mtu;
uint32_t group;
int arp;
int multicast;
int allmulticast;
bool unmanaged;
bool configure_without_carrier;
int ignore_carrier_loss;
KeepConfiguration keep_configuration;
uint32_t iaid;
DUID duid;
bool iaid_set;
bool required_for_online; /* Is this network required to be considered online? */
LinkOperationalStateRange required_operstate_for_online;
/* LLDP support */
LLDPMode lldp_mode; /* LLDP reception */
LLDPEmit lldp_emit; /* LLDP transmission */
@ -284,7 +287,6 @@ struct Network {
struct in_addr_full **dns;
unsigned n_dns;
OrderedSet *search_domains, *route_domains;
int dns_default_route;
ResolveSupport llmnr;
ResolveSupport mdns;
@ -292,8 +294,8 @@ struct Network {
DnsOverTlsMode dns_over_tls_mode;
Set *dnssec_negative_trust_anchors;
/* NTP */
char **ntp;
char **bind_carrier;
};
Network *network_ref(Network *network);