mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 20:30:08 +01:00
ndisc: implement "ipv6.ra-timeout" property
This commit is contained in:
parent
10f0253f2e
commit
9dde86d02c
8 changed files with 69 additions and 9 deletions
|
|
@ -749,6 +749,10 @@ ipv6.ip6-privacy=0
|
|||
removes extraneous routes from the tables.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv6.ra-timeout</varname></term>
|
||||
<listitem><para>If left unspecified, the default value depends on the sysctl solicitation settings.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv6.dhcp-duid</varname></term>
|
||||
<listitem><para>If left unspecified, it defaults to "lease".</para></listitem>
|
||||
|
|
|
|||
|
|
@ -10159,6 +10159,28 @@ ndisc_node_type (NMDevice *self)
|
|||
return NM_NDISC_NODE_TYPE_HOST;
|
||||
}
|
||||
|
||||
static gint32
|
||||
get_ra_timeout (NMDevice *self)
|
||||
{
|
||||
NMConnection *connection;
|
||||
gint32 timeout;
|
||||
|
||||
G_STATIC_ASSERT_EXPR (NM_RA_TIMEOUT_DEFAULT == 0);
|
||||
G_STATIC_ASSERT_EXPR (NM_RA_TIMEOUT_INFINITY == G_MAXINT32);
|
||||
|
||||
connection = nm_device_get_applied_connection (self);
|
||||
|
||||
timeout = nm_setting_ip6_config_get_ra_timeout (NM_SETTING_IP6_CONFIG (nm_connection_get_setting_ip6_config (connection)));
|
||||
nm_assert (timeout >= 0);
|
||||
if (timeout)
|
||||
return timeout;
|
||||
|
||||
return nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
|
||||
NM_CON_DEFAULT ("ipv6.ra-timeout"),
|
||||
self,
|
||||
0, G_MAXINT32, 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
addrconf6_start (NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr)
|
||||
{
|
||||
|
|
@ -10189,6 +10211,7 @@ addrconf6_start (NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr)
|
|||
stable_id,
|
||||
nm_setting_ip6_config_get_addr_gen_mode (s_ip6),
|
||||
ndisc_node_type (self),
|
||||
get_ra_timeout (self),
|
||||
&error);
|
||||
if (!priv->ndisc) {
|
||||
_LOGE (LOGD_IP6, "addrconf6: failed to start neighbor discovery: %s", error->message);
|
||||
|
|
|
|||
|
|
@ -563,6 +563,7 @@ nm_lndp_ndisc_new (NMPlatform *platform,
|
|||
const char *network_id,
|
||||
NMSettingIP6ConfigAddrGenMode addr_gen_mode,
|
||||
NMNDiscNodeType node_type,
|
||||
gint32 ra_timeout,
|
||||
GError **error)
|
||||
{
|
||||
nm_auto_pop_netns NMPNetns *netns = NULL;
|
||||
|
|
@ -588,6 +589,7 @@ nm_lndp_ndisc_new (NMPlatform *platform,
|
|||
NM_NDISC_MAX_ADDRESSES, ipv6_sysctl_get (platform, ifname,
|
||||
"max_addresses",
|
||||
0, G_MAXINT32, NM_NDISC_MAX_ADDRESSES_DEFAULT),
|
||||
NM_NDISC_RA_TIMEOUT, (int) ra_timeout,
|
||||
NM_NDISC_ROUTER_SOLICITATIONS, ipv6_sysctl_get (platform, ifname,
|
||||
"router_solicitations",
|
||||
1, G_MAXINT32, NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT),
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ NMNDisc *nm_lndp_ndisc_new (NMPlatform *platform,
|
|||
const char *network_id,
|
||||
NMSettingIP6ConfigAddrGenMode addr_gen_mode,
|
||||
NMNDiscNodeType node_type,
|
||||
gint32 ra_timeout,
|
||||
GError **error);
|
||||
|
||||
#endif /* __NETWORKMANAGER_LNDP_NDISC_H__ */
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ struct _NMNDiscPrivate {
|
|||
char *network_id;
|
||||
NMSettingIP6ConfigAddrGenMode addr_gen_mode;
|
||||
NMUtilsStableType stable_type;
|
||||
gint32 ra_timeout;
|
||||
gint32 max_addresses;
|
||||
gint32 router_solicitations;
|
||||
gint32 router_solicitation_interval;
|
||||
|
|
@ -67,6 +68,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE (
|
|||
PROP_NETWORK_ID,
|
||||
PROP_ADDR_GEN_MODE,
|
||||
PROP_MAX_ADDRESSES,
|
||||
PROP_RA_TIMEOUT,
|
||||
PROP_ROUTER_SOLICITATIONS,
|
||||
PROP_ROUTER_SOLICITATION_INTERVAL,
|
||||
PROP_NODE_TYPE,
|
||||
|
|
@ -907,7 +909,6 @@ nm_ndisc_start (NMNDisc *ndisc)
|
|||
{
|
||||
nm_auto_pop_netns NMPNetns *netns = NULL;
|
||||
NMNDiscPrivate *priv;
|
||||
gint64 ra_wait_secs;
|
||||
|
||||
g_return_if_fail (NM_IS_NDISC (ndisc));
|
||||
|
||||
|
|
@ -928,10 +929,19 @@ nm_ndisc_start (NMNDisc *ndisc)
|
|||
NM_NDISC_GET_CLASS (ndisc)->start (ndisc);
|
||||
|
||||
if (priv->node_type == NM_NDISC_NODE_TYPE_HOST) {
|
||||
ra_wait_secs = (((gint64) priv->router_solicitations) * priv->router_solicitation_interval) + 1;
|
||||
ra_wait_secs = MAX (ra_wait_secs, 30);
|
||||
priv->ra_timeout_id = g_timeout_add_seconds (ra_wait_secs, ndisc_ra_timeout_cb, ndisc);
|
||||
_LOGD ("scheduling RA timeout in %d seconds", (int) ra_wait_secs);
|
||||
gint32 ra_timeout = priv->ra_timeout;
|
||||
|
||||
G_STATIC_ASSERT_EXPR (NM_RA_TIMEOUT_DEFAULT == 0);
|
||||
G_STATIC_ASSERT_EXPR (NM_RA_TIMEOUT_INFINITY == G_MAXINT32);
|
||||
if (ra_timeout != NM_RA_TIMEOUT_INFINITY) {
|
||||
if (ra_timeout == NM_RA_TIMEOUT_DEFAULT) {
|
||||
ra_timeout = NM_MAX ((((gint64) priv->router_solicitations) * priv->router_solicitation_interval) + 1,
|
||||
30);
|
||||
}
|
||||
nm_assert (ra_timeout > 0 && ra_timeout < NM_RA_TIMEOUT_INFINITY);
|
||||
_LOGD ("scheduling RA timeout in %d seconds", ra_timeout);
|
||||
priv->ra_timeout_id = g_timeout_add_seconds (ra_timeout, ndisc_ra_timeout_cb, ndisc);
|
||||
}
|
||||
solicit_routers (ndisc);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1316,6 +1326,10 @@ set_property (GObject *object, guint prop_id,
|
|||
/* construct-only */
|
||||
priv->max_addresses = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_RA_TIMEOUT:
|
||||
/* construct-only */
|
||||
priv->ra_timeout = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_ROUTER_SOLICITATIONS:
|
||||
/* construct-only */
|
||||
priv->router_solicitations = g_value_get_int (value);
|
||||
|
|
@ -1407,8 +1421,8 @@ nm_ndisc_class_init (NMNDiscClass *klass)
|
|||
g_type_class_add_private (klass, sizeof (NMNDiscPrivate));
|
||||
|
||||
object_class->set_property = set_property;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
obj_properties[PROP_PLATFORM] =
|
||||
g_param_spec_object (NM_NDISC_PLATFORM, "", "",
|
||||
|
|
@ -1452,6 +1466,13 @@ nm_ndisc_class_init (NMNDiscClass *klass)
|
|||
G_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
G_STATIC_ASSERT_EXPR (G_MAXINT32 == NM_RA_TIMEOUT_INFINITY);
|
||||
obj_properties[PROP_RA_TIMEOUT] =
|
||||
g_param_spec_int (NM_NDISC_RA_TIMEOUT, "", "",
|
||||
0, G_MAXINT32, 0,
|
||||
G_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_ROUTER_SOLICITATIONS] =
|
||||
g_param_spec_int (NM_NDISC_ROUTER_SOLICITATIONS, "", "",
|
||||
1, G_MAXINT32, NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
#include "platform/nm-platform.h"
|
||||
#include "platform/nmp-object.h"
|
||||
|
||||
#define NM_RA_TIMEOUT_DEFAULT ((gint32) 0)
|
||||
#define NM_RA_TIMEOUT_INFINITY G_MAXINT32
|
||||
|
||||
#define NM_TYPE_NDISC (nm_ndisc_get_type ())
|
||||
#define NM_NDISC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_NDISC, NMNDisc))
|
||||
#define NM_NDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_NDISC, NMNDiscClass))
|
||||
|
|
@ -31,6 +34,7 @@
|
|||
#define NM_NDISC_STABLE_TYPE "stable-type"
|
||||
#define NM_NDISC_NODE_TYPE "node-type"
|
||||
#define NM_NDISC_MAX_ADDRESSES "max-addresses"
|
||||
#define NM_NDISC_RA_TIMEOUT "ra-timeout"
|
||||
#define NM_NDISC_ROUTER_SOLICITATIONS "router-solicitations"
|
||||
#define NM_NDISC_ROUTER_SOLICITATION_INTERVAL "router-solicitation-interval"
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ main (int argc, char **argv)
|
|||
"8ce666e8-d34d-4fb1-b858-f15a7al28086",
|
||||
NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64,
|
||||
NM_NDISC_NODE_TYPE_HOST,
|
||||
0,
|
||||
&error);
|
||||
if (!ndisc) {
|
||||
g_print ("Failed to create NMNDisc instance: %s\n", error->message);
|
||||
|
|
|
|||
|
|
@ -552,10 +552,14 @@ main (int argc, char *argv[])
|
|||
stable_type = (global_opt.stable_id[0] - '0');
|
||||
stable_id = &global_opt.stable_id[2];
|
||||
}
|
||||
ndisc = nm_lndp_ndisc_new (NM_PLATFORM_GET, gl.ifindex, global_opt.ifname,
|
||||
stable_type, stable_id,
|
||||
ndisc = nm_lndp_ndisc_new (NM_PLATFORM_GET,
|
||||
gl.ifindex,
|
||||
global_opt.ifname,
|
||||
stable_type,
|
||||
stable_id,
|
||||
global_opt.addr_gen_mode,
|
||||
NM_NDISC_NODE_TYPE_HOST,
|
||||
NM_RA_TIMEOUT_DEFAULT,
|
||||
NULL);
|
||||
g_assert (ndisc);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue