Skip to content

Commit

Permalink
net: if: Check IPv6 pointers properly in hop limit setters/getters
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jukkar authored and aescolar committed Feb 26, 2024
1 parent e7b1d6d commit 3de1f1b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions subsys/net/ip/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 3de1f1b

Please sign in to comment.