mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 10:30:22 +01:00
core/ndisc: move nm_lndp_ndisc_get_sysctl() to "nm-ndisc.[ch]"
NMNDisc has two implementations: lndp and fake. Fake only exists as a stub for unit tests, otherwise there is no purpose to it. Also, we won't ever add another implementation beside lndp. If lndp is not suitable, it would be replaced, but not accompanied by a second implementation. As such, nm_lndp_ndisc_get_sysctl() has no purpose to be in "nm-lndp-ndisc.c". This split does not exist to abstract "nm-ndisc.c" from NMPlatform. It exists to make it easier to test.
This commit is contained in:
parent
e7fb9a682b
commit
a8866095dd
7 changed files with 90 additions and 88 deletions
|
|
@ -11048,12 +11048,12 @@ addrconf6_start(NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr)
|
|||
else
|
||||
node_type = NM_NDISC_NODE_TYPE_HOST;
|
||||
|
||||
nm_lndp_ndisc_get_sysctl(nm_device_get_platform(self),
|
||||
nm_device_get_ip_iface(self),
|
||||
&max_addresses,
|
||||
&router_solicitations,
|
||||
&router_solicitation_interval,
|
||||
&default_ra_timeout);
|
||||
nm_ndisc_get_sysctl(nm_device_get_platform(self),
|
||||
nm_device_get_ip_iface(self),
|
||||
&max_addresses,
|
||||
&router_solicitations,
|
||||
&router_solicitation_interval,
|
||||
&default_ra_timeout);
|
||||
|
||||
if (node_type == NM_NDISC_NODE_TYPE_ROUTER)
|
||||
ra_timeout = 0u;
|
||||
|
|
|
|||
|
|
@ -664,69 +664,6 @@ stop(NMNDisc *ndisc)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int
|
||||
ipv6_sysctl_get(NMPlatform *platform,
|
||||
const char *ifname,
|
||||
const char *property,
|
||||
int min,
|
||||
int max,
|
||||
int defval)
|
||||
{
|
||||
return nm_platform_sysctl_ip_conf_get_int_checked(platform,
|
||||
AF_INET6,
|
||||
ifname,
|
||||
property,
|
||||
10,
|
||||
min,
|
||||
max,
|
||||
defval);
|
||||
}
|
||||
|
||||
void
|
||||
nm_lndp_ndisc_get_sysctl(NMPlatform *platform,
|
||||
const char *ifname,
|
||||
int * out_max_addresses,
|
||||
int * out_router_solicitations,
|
||||
int * out_router_solicitation_interval,
|
||||
guint32 * out_default_ra_timeout)
|
||||
{
|
||||
int router_solicitation_interval = 0;
|
||||
int router_solicitations = 0;
|
||||
|
||||
if (out_max_addresses) {
|
||||
*out_max_addresses = ipv6_sysctl_get(platform,
|
||||
ifname,
|
||||
"max_addresses",
|
||||
0,
|
||||
G_MAXINT32,
|
||||
NM_NDISC_MAX_ADDRESSES_DEFAULT);
|
||||
}
|
||||
if (out_router_solicitations || out_default_ra_timeout) {
|
||||
router_solicitations = ipv6_sysctl_get(platform,
|
||||
ifname,
|
||||
"router_solicitations",
|
||||
1,
|
||||
G_MAXINT32,
|
||||
NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT);
|
||||
NM_SET_OUT(out_router_solicitations, router_solicitations);
|
||||
}
|
||||
if (out_router_solicitation_interval || out_default_ra_timeout) {
|
||||
router_solicitation_interval = ipv6_sysctl_get(platform,
|
||||
ifname,
|
||||
"router_solicitation_interval",
|
||||
1,
|
||||
G_MAXINT32,
|
||||
NM_NDISC_RFC4861_RTR_SOLICITATION_INTERVAL);
|
||||
NM_SET_OUT(out_router_solicitation_interval, router_solicitation_interval);
|
||||
}
|
||||
if (out_default_ra_timeout) {
|
||||
*out_default_ra_timeout =
|
||||
NM_MAX((((gint64) router_solicitations) * router_solicitation_interval) + 1, 30);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_lndp_ndisc_init(NMLndpNDisc *lndp_ndisc)
|
||||
{}
|
||||
|
|
|
|||
|
|
@ -36,11 +36,4 @@ NMNDisc *nm_lndp_ndisc_new(NMPlatform * platform,
|
|||
guint32 ra_timeout,
|
||||
GError ** error);
|
||||
|
||||
void nm_lndp_ndisc_get_sysctl(NMPlatform *platform,
|
||||
const char *ifname,
|
||||
int * out_max_addresses,
|
||||
int * out_router_solicitations,
|
||||
int * out_router_solicitation_interval,
|
||||
guint32 * out_default_ra_timeout);
|
||||
|
||||
#endif /* __NETWORKMANAGER_LNDP_NDISC_H__ */
|
||||
|
|
|
|||
|
|
@ -1560,6 +1560,69 @@ nm_ndisc_rs_received(NMNDisc *ndisc)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int
|
||||
ipv6_sysctl_get(NMPlatform *platform,
|
||||
const char *ifname,
|
||||
const char *property,
|
||||
int min,
|
||||
int max,
|
||||
int defval)
|
||||
{
|
||||
return nm_platform_sysctl_ip_conf_get_int_checked(platform,
|
||||
AF_INET6,
|
||||
ifname,
|
||||
property,
|
||||
10,
|
||||
min,
|
||||
max,
|
||||
defval);
|
||||
}
|
||||
|
||||
void
|
||||
nm_ndisc_get_sysctl(NMPlatform *platform,
|
||||
const char *ifname,
|
||||
int * out_max_addresses,
|
||||
int * out_router_solicitations,
|
||||
int * out_router_solicitation_interval,
|
||||
guint32 * out_default_ra_timeout)
|
||||
{
|
||||
int router_solicitation_interval = 0;
|
||||
int router_solicitations = 0;
|
||||
|
||||
if (out_max_addresses) {
|
||||
*out_max_addresses = ipv6_sysctl_get(platform,
|
||||
ifname,
|
||||
"max_addresses",
|
||||
0,
|
||||
G_MAXINT32,
|
||||
NM_NDISC_MAX_ADDRESSES_DEFAULT);
|
||||
}
|
||||
if (out_router_solicitations || out_default_ra_timeout) {
|
||||
router_solicitations = ipv6_sysctl_get(platform,
|
||||
ifname,
|
||||
"router_solicitations",
|
||||
1,
|
||||
G_MAXINT32,
|
||||
NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT);
|
||||
NM_SET_OUT(out_router_solicitations, router_solicitations);
|
||||
}
|
||||
if (out_router_solicitation_interval || out_default_ra_timeout) {
|
||||
router_solicitation_interval = ipv6_sysctl_get(platform,
|
||||
ifname,
|
||||
"router_solicitation_interval",
|
||||
1,
|
||||
G_MAXINT32,
|
||||
NM_NDISC_RFC4861_RTR_SOLICITATION_INTERVAL);
|
||||
NM_SET_OUT(out_router_solicitation_interval, router_solicitation_interval);
|
||||
}
|
||||
if (out_default_ra_timeout) {
|
||||
*out_default_ra_timeout =
|
||||
NM_MAX((((gint64) router_solicitations) * router_solicitation_interval) + 1, 30);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
dns_domain_free(gpointer data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -266,6 +266,15 @@ nm_ndisc_dad_addr_is_fail_candidate(NMPlatform *platform, const NMPObject *obj)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void nm_ndisc_get_sysctl(NMPlatform *platform,
|
||||
const char *ifname,
|
||||
int * out_max_addresses,
|
||||
int * out_router_solicitations,
|
||||
int * out_router_solicitation_interval,
|
||||
guint32 * out_default_ra_timeout);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct _NML3ConfigData;
|
||||
|
||||
struct _NML3ConfigData *nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx,
|
||||
|
|
|
|||
|
|
@ -49,12 +49,12 @@ main(int argc, char **argv)
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nm_lndp_ndisc_get_sysctl(NM_PLATFORM_GET,
|
||||
ifname,
|
||||
&max_addresses,
|
||||
&router_solicitations,
|
||||
&router_solicitation_interval,
|
||||
&ra_timeout);
|
||||
nm_ndisc_get_sysctl(NM_PLATFORM_GET,
|
||||
ifname,
|
||||
&max_addresses,
|
||||
&router_solicitations,
|
||||
&router_solicitation_interval,
|
||||
&ra_timeout);
|
||||
|
||||
ndisc = nm_lndp_ndisc_new(NM_PLATFORM_GET,
|
||||
ifindex,
|
||||
|
|
|
|||
|
|
@ -708,12 +708,12 @@ main(int argc, char *argv[])
|
|||
stable_id = &global_opt.stable_id[2];
|
||||
}
|
||||
|
||||
nm_lndp_ndisc_get_sysctl(NM_PLATFORM_GET,
|
||||
global_opt.ifname,
|
||||
&max_addresses,
|
||||
&router_solicitations,
|
||||
&router_solicitation_interval,
|
||||
&default_ra_timeout);
|
||||
nm_ndisc_get_sysctl(NM_PLATFORM_GET,
|
||||
global_opt.ifname,
|
||||
&max_addresses,
|
||||
&router_solicitations,
|
||||
&router_solicitation_interval,
|
||||
&default_ra_timeout);
|
||||
|
||||
ndisc = nm_lndp_ndisc_new(NM_PLATFORM_GET,
|
||||
gl.ifindex,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue