Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ netbsd*)
hurd*)
echo "CPPFLAGS+= -D_GNU_SOURCE" >>$CONFIG_MK
echo "DHCPCD_SRCS+= if-hurd.c" >>$CONFIG_MK
echo "LDADD+= -lpthread" >>$CONFIG_MK

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason this is not added automatically in my local environment. It could be just my box, if it complies for you in the Hurd without it, this is probably not needed.

BPF_OS="bpf-hurd.c"
# No INET6 support
INET6=no
Expand Down
15 changes: 9 additions & 6 deletions hooks/10-pfinet
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2026 Roy Marples <roy@marples.name>

# Configure the Hurd PFINET translator.
# Configure the Hurd network translator (pfinet or lwip).
# It always on socket 2.

case "$(showtrans /servers/socket/2)" in
/hurd/pfinet" "*) pfinet=true;;
*) pfinet=false;;
trans=$(showtrans /servers/socket/2 2>/dev/null)
[ -z "$trans" ] && trans=$(fsysopts /servers/socket/2 2>/dev/null)

case "$trans" in
*/pfinet" "*|*/lwip" "*) hurd_net=true;;
*) hurd_net=false;;
Comment on lines +7 to +12

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few changes here:

  1. showtrans only returns passive translators, that is, when the directory entry in the FS has a record to execute the translator when the first RPC is received. However, we can also have active translators running in a node that are not installed as passive translators. Those are detected by fsysopts.
  2. Now it also detects lwip. I made some changes in the lwip translator so it mimics how pfinet responds to fsysopts. I'll send the patches to the hurd mailing list. But since now they are compatible, we can reuse the same hook from both.
  3. The pattern has been modified a bit so translators are detected also out of their default path at /hurd/*.

esac

if $pfinet && $if_configured && [ "$ifxname" != "lo" ] ; then
if $hurd_net && $if_configured && [ "$ifxname" != "lo" ] ; then
if $if_up && [ -n "$new_ip_address" ]; then
flags=
if [ -n "$new_subnet_mask" ]; then
Expand All @@ -20,7 +23,7 @@ if $pfinet && $if_configured && [ "$ifxname" != "lo" ] ; then
fi
fsysopts /servers/socket/2 -i "$ifxname" \
-a "$new_ip_address" $flags
elif $if_down; then
elif $if_down || { [ "$reason" = STOPPED ] && ! $if_persistent; }; then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my previous patches, which configured lwip/pfinet via ioctls, having persistent == false and release == false made dhcpcd unconfigure the interface on exit. However, this doesn't work when using the hook. With the hook, release == true unconfigures the stack in the kernel on exit but persistent == false + release == false doesn't. IMO it makes more sense to unconfigure always when persistent == false, and it seems to mimic how BSD behaves. Or am I missing something?

fsysopts /servers/socket/2 -i "$ifxname" -a 0.0.0.0
fi
fi
7 changes: 7 additions & 0 deletions hooks/dhcpcd-run-hooks.8.in
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ if dhcpcd has configured the
.Ev interface
otherwise
.Dv false .
.It Ev $if_persistent
.Dv true
if the
.Ev interface
is configured to be persistent when dhcpcd exits,
otherwise
.Dv false .
.It Ev $if_up
.Dv true
if the
Expand Down
3 changes: 3 additions & 0 deletions src/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
if (efprintf(fp, "if_configured=%s",
ifo->options & DHCPCD_CONFIGURE ? "true" : "false") == -1)
goto eexit;
if (efprintf(fp, "if_persistent=%s",
ifo->options & DHCPCD_PERSISTENT ? "true" : "false") == -1)
goto eexit;
Comment on lines +361 to +363

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a new var so the pfinet hook knows the value of the persistent option

if (efprintf(fp, "ifcarrier=%s",
ifp->carrier == LINK_UNKNOWN ? "unknown" :
ifp->carrier == LINK_UP ? "up" :
Expand Down