mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-19 07:48:30 +02:00
l3cfg: simplify creating l3cd for NML3IPv4LL
This commit is contained in:
parent
149e66305f
commit
0dac741e5a
1 changed files with 15 additions and 33 deletions
|
|
@ -317,41 +317,10 @@ _acd_info_is_good(const NML3AcdAddrInfo *acd_info)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static NMPlatformIP4Address *
|
||||
_l3cd_config_plat_init_addr(NMPlatformIP4Address *a, int ifindex, in_addr_t addr)
|
||||
{
|
||||
nm_assert(nm_utils_ip4_address_is_link_local(addr));
|
||||
|
||||
*a = (NMPlatformIP4Address){
|
||||
.ifindex = ifindex,
|
||||
.address = addr,
|
||||
.peer_address = addr,
|
||||
.plen = ADDR_IPV4LL_PREFIX_LEN,
|
||||
.addr_source = NM_IP_CONFIG_SOURCE_IP4LL,
|
||||
};
|
||||
return a;
|
||||
}
|
||||
|
||||
static NMPlatformIP4Route *
|
||||
_l3cd_config_plat_init_route(NMPlatformIP4Route *r, int ifindex)
|
||||
{
|
||||
*r = (NMPlatformIP4Route){
|
||||
.ifindex = ifindex,
|
||||
.network = htonl(0xE0000000u),
|
||||
.plen = 4,
|
||||
.rt_source = NM_IP_CONFIG_SOURCE_IP4LL,
|
||||
.table_any = TRUE,
|
||||
.metric_any = TRUE,
|
||||
};
|
||||
return r;
|
||||
}
|
||||
|
||||
static const NML3ConfigData *
|
||||
_l3cd_config_create(int ifindex, in_addr_t addr, NMDedupMultiIndex *multi_idx)
|
||||
{
|
||||
nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL;
|
||||
NMPlatformIP4Address a;
|
||||
NMPlatformIP4Route r;
|
||||
|
||||
nm_assert(nm_utils_ip4_address_is_link_local(addr));
|
||||
nm_assert(ifindex > 0);
|
||||
|
|
@ -359,8 +328,21 @@ _l3cd_config_create(int ifindex, in_addr_t addr, NMDedupMultiIndex *multi_idx)
|
|||
|
||||
l3cd = nm_l3_config_data_new(multi_idx, ifindex, NM_IP_CONFIG_SOURCE_IP4LL);
|
||||
|
||||
nm_l3_config_data_add_address_4(l3cd, _l3cd_config_plat_init_addr(&a, ifindex, addr));
|
||||
nm_l3_config_data_add_route_4(l3cd, _l3cd_config_plat_init_route(&r, ifindex));
|
||||
nm_l3_config_data_add_address_4(
|
||||
l3cd,
|
||||
NM_PLATFORM_IP4_ADDRESS_INIT(.ifindex = ifindex,
|
||||
.address = addr,
|
||||
.peer_address = addr,
|
||||
.plen = ADDR_IPV4LL_PREFIX_LEN,
|
||||
.addr_source = NM_IP_CONFIG_SOURCE_IP4LL));
|
||||
|
||||
nm_l3_config_data_add_route_4(l3cd,
|
||||
NM_PLATFORM_IP4_ROUTE_INIT(.ifindex = ifindex,
|
||||
.network = htonl(0xE0000000u),
|
||||
.plen = 4,
|
||||
.rt_source = NM_IP_CONFIG_SOURCE_IP4LL,
|
||||
.table_any = TRUE,
|
||||
.metric_any = TRUE));
|
||||
|
||||
return nm_l3_config_data_seal(g_steal_pointer(&l3cd));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue