Skip to content

Commit

Permalink
net: if: Check IPv4 pointers properly in TTL setters/getters
Browse files Browse the repository at this point in the history
We must make sure that IPv4 configuration pointer is valid
so that the TTL can be set for a given interface.

(cherry picked from commit e7b1d6d)

Original-Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
GitOrigin-RevId: e7b1d6d
Change-Id: I191c01a02fa5940df89c979ee542b5401d8c71ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5324198
Tested-by: Keith Short <keithshort@chromium.org>
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Commit-Queue: Keith Short <keithshort@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
  • Loading branch information
jukkar authored and Chromeos LUCI committed Feb 26, 2024
1 parent 30c6619 commit 9a62eac
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 @@ -3165,6 +3165,10 @@ uint8_t net_if_ipv4_get_ttl(struct net_if *iface)

net_if_lock(iface);

if (net_if_config_ipv4_get(iface, NULL) < 0) {
goto out;
}

if (!iface->config.ip.ipv4) {
goto out;
}
Expand All @@ -3186,6 +3190,10 @@ void net_if_ipv4_set_ttl(struct net_if *iface, uint8_t ttl)
#if defined(CONFIG_NET_NATIVE_IPV4)
net_if_lock(iface);

if (net_if_config_ipv4_get(iface, NULL) < 0) {
goto out;
}

if (!iface->config.ip.ipv4) {
goto out;
}
Expand All @@ -3206,6 +3214,10 @@ uint8_t net_if_ipv4_get_mcast_ttl(struct net_if *iface)

net_if_lock(iface);

if (net_if_config_ipv4_get(iface, NULL) < 0) {
goto out;
}

if (!iface->config.ip.ipv4) {
goto out;
}
Expand All @@ -3227,6 +3239,10 @@ void net_if_ipv4_set_mcast_ttl(struct net_if *iface, uint8_t ttl)
#if defined(CONFIG_NET_NATIVE_IPV4)
net_if_lock(iface);

if (net_if_config_ipv4_get(iface, NULL) < 0) {
goto out;
}

if (!iface->config.ip.ipv4) {
goto out;
}
Expand Down

0 comments on commit 9a62eac

Please sign in to comment.