net: if: Check IPv6 pointers properly in hop limit setters/getters

We must make sure that IPv6 configuration pointer is valid
so that the hop limit can be set for a given interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
Jukka Rissanen 2024-02-07 10:02:05 +02:00 committed by Alberto Escolar
parent e7b1d6d8aa
commit 3de1f1b5d0

View file

@ -2649,6 +2649,10 @@ uint8_t net_if_ipv6_get_mcast_hop_limit(struct net_if *iface)
net_if_lock(iface);
if (net_if_config_ipv6_get(iface, NULL) < 0) {
goto out;
}
if (!iface->config.ip.ipv6) {
goto out;
}
@ -2670,6 +2674,10 @@ void net_if_ipv6_set_mcast_hop_limit(struct net_if *iface, uint8_t hop_limit)
#if defined(CONFIG_NET_NATIVE_IPV6)
net_if_lock(iface);
if (net_if_config_ipv6_get(iface, NULL) < 0) {
goto out;
}
if (!iface->config.ip.ipv6) {
goto out;
}
@ -2690,6 +2698,10 @@ uint8_t net_if_ipv6_get_hop_limit(struct net_if *iface)
net_if_lock(iface);
if (net_if_config_ipv6_get(iface, NULL) < 0) {
goto out;
}
if (!iface->config.ip.ipv6) {
goto out;
}
@ -2711,6 +2723,10 @@ void net_if_ipv6_set_hop_limit(struct net_if *iface, uint8_t hop_limit)
#if defined(CONFIG_NET_NATIVE_IPV6)
net_if_lock(iface);
if (net_if_config_ipv6_get(iface, NULL) < 0) {
goto out;
}
if (!iface->config.ip.ipv6) {
goto out;
}