Skip to content

Commit

Permalink
loopback-setup: set IFA_F_NOPREFIXROUTE when configuring 'lo' ipv6 ad…
Browse files Browse the repository at this point in the history
…dress

Otherwise the kernel will set up two routes to ::1, one in the "main",
and one in the "local" routing table.

Fixes: #25819
  • Loading branch information
poettering committed May 31, 2023
1 parent 40fb9ee commit 8557425
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/shared/loopback-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,15 @@ static int add_ipv6_address(sd_netlink *rtnl, struct state *s) {
if (r < 0)
return r;

r = sd_rtnl_message_addr_set_flags(req, IFA_F_PERMANENT);
uint32_t flags = IFA_F_PERMANENT|IFA_F_NOPREFIXROUTE;
r = sd_rtnl_message_addr_set_flags(req, flags & 0xffu); /* rtnetlink wants low 8 bit of flags via regular flags field… */
if (r < 0)
return r;
if ((flags & ~0xffu) != 0) {
r = sd_netlink_message_append_u32(req, IFA_FLAGS, flags); /* …and the rest of the flags via IFA_FLAGS */
if (r < 0)
return r;
}

r = sd_rtnl_message_addr_set_scope(req, RT_SCOPE_HOST);
if (r < 0)
Expand Down

0 comments on commit 8557425

Please sign in to comment.