Skip to content

Commit 1b08465

Browse files
committed
Add dual-stack mDNS and Samba link handling
Inventory IPv4 and IPv6 links for Samba and mDNS, keeping Samba bind tokens explicit while preserving IPv4 link-local support. Add UDP6 mDNS participation with per-link ff02::fb joins, scoped IPv6 sends, and link-valid A/AAAA advertising. Update watchdog, doctor probes, tests, manifests, and rebuilt NetBSD mdns/nbns artifacts.
1 parent 5ef7cac commit 1b08465

23 files changed

Lines changed: 3112 additions & 350 deletions

bin/mdns-netbsd4be/mdns-advertiser

14 KB
Binary file not shown.

bin/mdns-netbsd4le/mdns-advertiser

14.1 KB
Binary file not shown.

bin/mdns/mdns-advertiser

13.9 KB
Binary file not shown.

bin/nbns-netbsd4be/nbns-advertiser

-16.9 KB
Binary file not shown.

bin/nbns-netbsd4le/nbns-advertiser

-16.9 KB
Binary file not shown.

bin/nbns/nbns-advertiser

-14.3 KB
Binary file not shown.

build/auto-ip-common.inc

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

build/mdns-advertiser.c

Lines changed: 1535 additions & 196 deletions
Large diffs are not rendered by default.

src/timecapsulesmb/assets/artifact-manifest.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22
"artifacts": {
33
"mdns-advertiser": {
44
"path": "bin/mdns/mdns-advertiser",
5-
"sha256": "82245f3a581d196c9cad98d076d29769c0cf0dc4052681ddd8b4a050be0b0722"
5+
"sha256": "d50f8f54d74ef7549cfbea5515fc000f9ef82da423d45f1b112f7713257119e1"
66
},
77
"mdns-advertiser-netbsd4le": {
88
"path": "bin/mdns-netbsd4le/mdns-advertiser",
9-
"sha256": "9e63f0a4c2c483fd4c3b6727cd2005f363abe734c74ab14f1185c32d01823016"
9+
"sha256": "e27656e73a768d358ec4484cf464a34d074c87ef1eea3de4fdf59123b9a70d74"
1010
},
1111
"mdns-advertiser-netbsd4be": {
1212
"path": "bin/mdns-netbsd4be/mdns-advertiser",
13-
"sha256": "bdd638d4cca35d95307e4d93feba4ced1300fde4d96406e38d99f9747f00723d"
13+
"sha256": "012e8df43a0e53c2661a9aa080954601eda91b11a29211d00f104751fda2c09e"
1414
},
1515
"nbns-advertiser": {
1616
"path": "bin/nbns/nbns-advertiser",
17-
"sha256": "5dd1b7df3dedcbc5dd6e6d2575a3c141cad9757d09d3e94e836cee72d3c08e66"
17+
"sha256": "af2de6af905d9cc6e4415fdc104fd658c2a4812255c16e7ce71a502fde4968db"
1818
},
1919
"nbns-advertiser-netbsd4le": {
2020
"path": "bin/nbns-netbsd4le/nbns-advertiser",
21-
"sha256": "ffd0908e2803dd254e16ef9379000221037668be5735c86656c258ff44810d02"
21+
"sha256": "f52c5f708b6638589434e45b0d46cc830539c02748dd8b231da25d3406ea6fae"
2222
},
2323
"nbns-advertiser-netbsd4be": {
2424
"path": "bin/nbns-netbsd4be/nbns-advertiser",
25-
"sha256": "1c58af90353388535d9497573fa5151226ed0ed094a0f4b36788607b2c4b3078"
25+
"sha256": "60c8e5266a2efce13fd0fe4ae2e7264153e1d1aafa14c87707d27dc357aabfdb"
2626
},
2727
"smbd": {
2828
"path": "bin/samba4/smbd",

src/timecapsulesmb/assets/boot/samba4/common.d/45-network-bind.sh

Lines changed: 90 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,37 @@ tc_smb_bind_token_is_ipv4_cidr() {
2828
return 0
2929
}
3030

31-
tc_normalize_smb_bind_cidrs() {
32-
cidrs=$1
31+
tc_smb_bind_token_is_ipv6_cidr() {
32+
token=$1
33+
34+
case "$token" in
35+
""|/*|*/|*/*/*|*[!0123456789abcdefABCDEF:./]*) return 1 ;;
36+
*:*) ;;
37+
*) return 1 ;;
38+
esac
39+
40+
prefix_part=${token#*/}
41+
case "$prefix_part" in
42+
""|*[!0123456789]*) return 1 ;;
43+
esac
44+
[ "$prefix_part" -le 128 ] 2>/dev/null || return 1
45+
46+
return 0
47+
}
48+
49+
tc_smb_bind_token_is_cidr() {
50+
tc_smb_bind_token_is_ipv4_cidr "$1" || tc_smb_bind_token_is_ipv6_cidr "$1"
51+
}
52+
53+
tc_normalize_smb_bind_tokens() {
54+
bind_tokens=$1
3355
normalized=
3456

35-
set -- $cidrs
57+
set -- $bind_tokens
3658
[ "$#" -gt 0 ] || return 1
3759

3860
for cidr_token in "$@"; do
39-
tc_smb_bind_token_is_ipv4_cidr "$cidr_token" || return 1
61+
tc_smb_bind_token_is_cidr "$cidr_token" || return 1
4062
if [ -n "$normalized" ]; then
4163
normalized="$normalized $cidr_token"
4264
else
@@ -47,15 +69,69 @@ tc_normalize_smb_bind_cidrs() {
4769
printf '%s\n' "$normalized"
4870
}
4971

72+
tc_normalize_smb_bind_cidrs() {
73+
tc_normalize_smb_bind_tokens "$1"
74+
}
75+
76+
tc_normalize_mdns_socket_families() {
77+
families=$1
78+
saw_ipv4=0
79+
saw_ipv6=0
80+
normalized=
81+
82+
set -- $families
83+
[ "$#" -gt 0 ] || return 1
84+
85+
for family_token in "$@"; do
86+
case "$family_token" in
87+
ipv4)
88+
[ "$saw_ipv4" = "0" ] || return 1
89+
saw_ipv4=1
90+
;;
91+
ipv6)
92+
[ "$saw_ipv6" = "0" ] || return 1
93+
saw_ipv6=1
94+
;;
95+
*) return 1 ;;
96+
esac
97+
done
98+
99+
if [ "$saw_ipv4" = "1" ]; then
100+
normalized=ipv4
101+
fi
102+
if [ "$saw_ipv6" = "1" ]; then
103+
if [ -n "$normalized" ]; then
104+
normalized="$normalized ipv6"
105+
else
106+
normalized=ipv6
107+
fi
108+
fi
109+
110+
[ -n "$normalized" ] || return 1
111+
printf '%s\n' "$normalized"
112+
}
113+
50114
tc_probe_auto_ip_cidrs() {
51115
[ -x "$TC_MDNS_BIN" ] || return 1
52116
cidrs=$("$TC_MDNS_BIN" --print-auto-ip-cidrs 2>/dev/null) || return $?
53117
tc_normalize_smb_bind_cidrs "$cidrs" || return 1
54118
}
55119

120+
tc_probe_smb_bind_tokens() {
121+
[ -x "$TC_MDNS_BIN" ] || return 1
122+
bind_tokens=$("$TC_MDNS_BIN" --print-smb-bind-interfaces 2>/dev/null) || return $?
123+
tc_normalize_smb_bind_tokens "$bind_tokens" || return 1
124+
}
125+
126+
tc_probe_mdns_socket_families() {
127+
[ -x "$TC_MDNS_BIN" ] || return 1
128+
families=$("$TC_MDNS_BIN" --print-mdns-socket-families 2>/dev/null) || return $?
129+
tc_normalize_mdns_socket_families "$families" || return 1
130+
}
131+
56132
tc_probe_smb_bind_interfaces() {
57-
cidrs=$(tc_probe_auto_ip_cidrs) || return $?
58-
printf '127.0.0.1/8 %s\n' "$cidrs"
133+
bind_tokens=$(tc_probe_smb_bind_tokens) || return $?
134+
printf '127.0.0.1/8 ::1/128 %s\n' "$bind_tokens"
59135
}
60136

61137
tc_auto_ip_unavailable_status() {
@@ -65,27 +141,27 @@ tc_auto_ip_unavailable_status() {
65141
tc_mark_smb_deferred_no_ip() {
66142
TC_WATCHDOG_SMB_DEFERRED_NO_IP=1
67143
if [ "${TC_SMB_IPV4_WAIT_LOGGED:-0}" != "1" ]; then
68-
tc_log "Samba IPv4 bind discovery deferred; no usable IPv4 has appeared yet"
144+
tc_log "Samba bind discovery deferred; no usable address has appeared yet"
69145
TC_SMB_IPV4_WAIT_LOGGED=1
70146
fi
71147
}
72148

73149
tc_wait_for_smb_ipv4() {
74150
if [ ! -x "$TC_MDNS_BIN" ]; then
75-
tc_log "Samba IPv4 bind discovery failed; missing $TC_MDNS_BIN"
151+
tc_log "Samba bind discovery failed; missing $TC_MDNS_BIN"
76152
return 1
77153
fi
78154

79155
while :; do
80-
if cidrs=$(tc_probe_auto_ip_cidrs); then
81-
tc_log "Samba IPv4 bind discovery: first usable IPv4 observed: $cidrs"
156+
if bind_tokens=$(tc_probe_smb_bind_tokens); then
157+
tc_log "Samba bind discovery: first usable address observed: $bind_tokens"
82158
return 0
83159
else
84160
probe_status=$?
85161
fi
86162

87163
if ! tc_auto_ip_unavailable_status "$probe_status"; then
88-
tc_log "Samba IPv4 bind discovery failed with exit code $probe_status"
164+
tc_log "Samba bind discovery failed with exit code $probe_status"
89165
return 1
90166
fi
91167

@@ -98,7 +174,7 @@ tc_refresh_smb_bind_interfaces() {
98174
if bind_interfaces=$(tc_probe_smb_bind_interfaces); then
99175
TC_SMB_BIND_INTERFACES=$bind_interfaces
100176
TC_WATCHDOG_SMB_DEFERRED_NO_IP=0
101-
tc_log "Samba IPv4 bind interfaces: $TC_SMB_BIND_INTERFACES"
177+
tc_log "Samba bind interfaces: $TC_SMB_BIND_INTERFACES"
102178
return 0
103179
else
104180
probe_status=$?
@@ -107,14 +183,14 @@ tc_refresh_smb_bind_interfaces() {
107183
if tc_auto_ip_unavailable_status "$probe_status"; then
108184
tc_mark_smb_deferred_no_ip
109185
else
110-
tc_log "Samba IPv4 bind interface probe failed with exit code $probe_status"
186+
tc_log "Samba bind interface probe failed with exit code $probe_status"
111187
fi
112188
return 1
113189
}
114190

115191
tc_prepare_smb_bind_context() {
116192
tc_wait_for_smb_ipv4 || return 1
117-
tc_log "Samba IPv4 bind discovery: waiting ${TC_SMB_IPV4_SETTLE_SECONDS}s for network stabilization"
193+
tc_log "Samba bind discovery: waiting ${TC_SMB_IPV4_SETTLE_SECONDS}s for network stabilization"
118194
sleep "$TC_SMB_IPV4_SETTLE_SECONDS"
119195
tc_refresh_smb_bind_interfaces
120196
}

0 commit comments

Comments
 (0)