Skip to content

Commit

Permalink
net: loopback: Register IPv4 netmask
Browse files Browse the repository at this point in the history
A proper netmask should be set on the loopback interface, so that
source address selection work properly when there are multiple
interfaces in the system.

(cherry picked from commit c7ac921)

Original-Signed-off-by: Robert Lubos <[email protected]>
GitOrigin-RevId: c7ac921
Change-Id: Ie5e52de9c4f5b8a53b72e47b0d0b99ed45cdd5f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5036511
Tested-by: ChromeOS Prod (Robot) <[email protected]>
Reviewed-by: Keith Short <[email protected]>
Tested-by: Keith Short <[email protected]>
Commit-Queue: Keith Short <[email protected]>
  • Loading branch information
rlubos authored and Chromeos LUCI committed Nov 16, 2023
1 parent 36621c8 commit 4d1e12c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ static void loopback_init(struct net_if *iface)

if (IS_ENABLED(CONFIG_NET_IPV4)) {
struct in_addr ipv4_loopback = INADDR_LOOPBACK_INIT;
struct in_addr netmask = { { { 255, 0, 0, 0 } } };

ifaddr = net_if_ipv4_addr_add(iface, &ipv4_loopback,
NET_ADDR_AUTOCONF, 0);
if (!ifaddr) {
LOG_ERR("Failed to register IPv4 loopback address");
}

net_if_ipv4_set_netmask(iface, &netmask);
}

if (IS_ENABLED(CONFIG_NET_IPV6)) {
Expand Down

0 comments on commit 4d1e12c

Please sign in to comment.