From bedcc5fc0414019d4c75c2d2ffded34c4dff3586 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Tue, 26 Sep 2023 11:35:36 +0300 Subject: [PATCH] Add CONFIG_NET_ICMPv6_ROUTER_LIFETIME Allows setting the advertised route lifetime, and also to set it to 0 for advertising only the prefix. From RFC4861: A router might want to send Router Advertisements without advertising itself as a default router. For instance, a router might advertise prefixes for stateless address autoconfiguration while not wishing to forward packets. Such a router sets the Router Lifetime field in outgoing advertisements to zero. --- net/icmpv6/Kconfig | 8 ++++++++ net/icmpv6/icmpv6_radvertise.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/net/icmpv6/Kconfig b/net/icmpv6/Kconfig index 3b90476f33..13a8bbbb15 100644 --- a/net/icmpv6/Kconfig +++ b/net/icmpv6/Kconfig @@ -120,6 +120,14 @@ config NET_ICMPv6_ROUTER if NET_ICMPv6_ROUTER +config NET_ICMPv6_ROUTER_LIFETIME + int "Router Advertisement router lifetime in seconds" + default 1800 + ---help--- + Set the router lifetime for advertising as a default router. + Set to 0 to only advertise autoconfiguration prefix without + advertising as a router. + config NET_ICMPv6_ROUTER_MANUAL bool "Manual router prefix" default n diff --git a/net/icmpv6/icmpv6_radvertise.c b/net/icmpv6/icmpv6_radvertise.c index 5b83530f53..f8926403f2 100644 --- a/net/icmpv6/icmpv6_radvertise.c +++ b/net/icmpv6/icmpv6_radvertise.c @@ -197,7 +197,8 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) adv->code = 0; /* Message qualifier */ adv->hoplimit = 64; /* Current hop limit */ adv->flags = ICMPv6_RADV_FLAG_M; /* Managed address flag. */ - adv->lifetime = HTONS(1800); /* Router lifetime */ + adv->lifetime = + HTONS(CONFIG_NET_ICMPv6_ROUTER_LIFETIME); /* Router lifetime */ adv->reachable[0] = 0; /* Reachable time */ adv->reachable[1] = 0; adv->retrans[0] = 0; /* Retransmission timer */