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
6 changes: 4 additions & 2 deletions scripts/package-build/zerotier-one/package.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ name = "zerotier-one"
commit_id = "1.16.0"
scm_url = "https://github.com/zerotier/ZeroTierOne.git"

pre_build_hook = "git apply ../patches/zerotier-one/0001-extosdep-config-update-nudge.patch"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Patch application is not idempotent and will fail on rebuild.

git apply will fail if the patch is already applied, breaking incremental build scenarios. Consider using git apply --reverse --check to test if the patch is already applied before attempting to apply it, or use git apply --check with conditional logic.

🔧 Suggested fix for idempotent patch application
-pre_build_hook = "git apply ../patches/zerotier-one/0001-extosdep-config-update-nudge.patch"
+pre_build_hook = """
+if ! git apply --reverse --check ../patches/zerotier-one/0001-extosdep-config-update-nudge.patch 2>/dev/null; then
+    git apply ../patches/zerotier-one/0001-extosdep-config-update-nudge.patch
+fi
+"""
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pre_build_hook = "git apply ../patches/zerotier-one/0001-extosdep-config-update-nudge.patch"
pre_build_hook = """
if ! git apply --reverse --check ../patches/zerotier-one/0001-extosdep-config-update-nudge.patch 2>/dev/null; then
git apply ../patches/zerotier-one/0001-extosdep-config-update-nudge.patch
fi
"""
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/package-build/zerotier-one/package.toml` at line 6, Update the
pre_build_hook so patch application is idempotent: before running git apply on
../patches/zerotier-one/0001-extosdep-config-update-nudge.patch, run a check
(e.g. git apply --reverse --check <patch> to detect already-applied patches, or
git apply --check <patch> to detect if it can be applied) and only run git apply
<patch> when the check indicates the patch is not yet applied; modify the
pre_build_hook entry that currently runs git apply to perform this conditional
check-and-apply sequence so rebuilds don’t fail.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The build.py script will always check the patches/<pkg-name> directory if it is exist it will patch the package during build process
So as I see we do not need additional pre_build_hook here


build_cmd = """
make -j"$(nproc)" ZT_SSO_SUPPORTED=0
make -j"$(nproc)" ZT_EXTOSDEP=1 ZT_SSO_SUPPORTED=0
mkdir -p tmp/usr/sbin
install -m0755 zerotier-one tmp/usr/sbin/zerotier-one
ln -s /usr/sbin/zerotier-one tmp/usr/sbin/zerotier-cli
ln -s /usr/sbin/zerotier-one tmp/usr/sbin/zerotier-idtool

fpm --input-type dir --output-type deb --name zerotier-one \
--version "1.16.0" --deb-compression gz \
--version "1.16.0" --iteration "vyos1" --deb-compression gz \
--maintainer "VyOS Package Maintainers <maintainers@vyos.net>" \
--description "ZeroTier virtual networking daemon" \
--license "MPL-2.0" --chdir tmp .
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
diff --git a/osdep/ExtOsdep.cpp b/osdep/ExtOsdep.cpp
index 4efab5a6c..771668d72 100644
--- a/osdep/ExtOsdep.cpp
+++ b/osdep/ExtOsdep.cpp
@@ -256,6 +256,18 @@ bool ExtOsdep::getBindAddrs(std::map<InetAddress, std::string>& ret)
return resp->result;
}

+void ExtOsdep::configUpdate(uint64_t nwid, uint64_t revision)
+{
+ zt_eod_msg_configupdate msg;
+ memset(&msg, 0, sizeof(msg));
+ msg.cmd = ZT_EOD_MSG_CONFIGUPDATE;
+ msg.nwid = nwid;
+ msg.revision = revision;
+
+ Mutex::Lock l(eodMutex);
+ __eodSend(msg);
+}
+
ExtOsdepTap::ExtOsdepTap(
const char* homePath,
const MAC& mac,
@@ -499,6 +511,7 @@ bool ExtOsdepTap::removeIp(const InetAddress& ip)
for (auto i = allIps.begin(); i != allIps.end(); ++i) {
if (*i == ip) {
doRemoveIp(*i);
+ allIps.erase(i);
return true;
}
}
diff --git a/osdep/ExtOsdep.hpp b/osdep/ExtOsdep.hpp
index d7028902c..c1951239f 100644
--- a/osdep/ExtOsdep.hpp
+++ b/osdep/ExtOsdep.hpp
@@ -34,6 +34,7 @@
#define ZT_EOD_MSG_ADDROUTERESP 17
#define ZT_EOD_MSG_DELROUTE 18
#define ZT_EOD_MSG_DELROUTERESP 19
+#define ZT_EOD_MSG_CONFIGUPDATE 20

struct zt_eod_msg_addtap {
unsigned char cmd;
@@ -105,6 +106,12 @@ struct zt_eod_msg_route {
unsigned char src[16];
} __attribute__((packed));

+struct zt_eod_msg_configupdate {
+ unsigned char cmd;
+ uint64_t nwid;
+ uint64_t revision;
+} __attribute__((packed));
+
struct zt_eod_mgmt_req {
uint32_t method;
uint32_t pathlen;
@@ -144,6 +151,7 @@ class ExtOsdep {

static void routeAddDel(bool, const InetAddress& target, const InetAddress& via, const InetAddress& src, const char* ifaceName);
static bool getBindAddrs(std::map<InetAddress, std::string>&);
+ static void configUpdate(uint64_t nwid, uint64_t revision);

static bool mgmtRecv(void* cookie, void* data, unsigned long len, std::function<unsigned(unsigned, const std::string&, const std::string&, std::string&)>);
static bool mgmtWritable(void*);
diff --git a/service/OneService.cpp b/service/OneService.cpp
index 41d790516..ea8e4ce3c 100644
--- a/service/OneService.cpp
+++ b/service/OneService.cpp
@@ -3599,6 +3599,9 @@ class OneServiceImpl : public OneService {
#endif
syncManagedStuff(n, true, true, true);
n.tap()->setMtu(nwc->mtu);
+#ifdef ZT_EXTOSDEP
+ ExtOsdep::configUpdate(nwid, (uint64_t)nwc->netconfRevision);
+#endif
}
else {
_nets.erase(nwid);
@@ -3611,6 +3614,9 @@ class OneServiceImpl : public OneService {
if (n.tap()) { // sanity check
#if defined(__WINDOWS__) && ! defined(ZT_SDK)
std::string winInstanceId(((WindowsEthernetTap*)(n.tap().get()))->instanceId());
+#endif
+#ifdef ZT_EXTOSDEP
+ ExtOsdep::configUpdate(nwid, (uint64_t)n.config().netconfRevision);
#endif
*nuptr = (void*)0;
n.tap().reset();
Loading