From 82cb6f8ba0df89a83fbe3a2aff0876357f91f4cf Mon Sep 17 00:00:00 2001 From: Mike O'Driscoll Date: Mon, 23 Nov 2026 09:59:20 -0500 Subject: [PATCH] wgengine/router: add envknob to disable src_valid_mark (#22591) Add TS_DEBUG_DISABLE_SRC_VALID_MARK to allow disabling of net.ipv4.conf.all.src_valid_mark being set. Updates #3310 Updates #19796 Signed-off-by: Mike O'Driscoll --- wgengine/router/osrouter/router_linux.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wgengine/router/osrouter/router_linux.go b/wgengine/router/osrouter/router_linux.go index c8b31d00e..0d235723d 100644 --- a/wgengine/router/osrouter/router_linux.go +++ b/wgengine/router/osrouter/router_linux.go @@ -283,6 +283,11 @@ func useAmbientCaps() bool { var forceIPCommand = envknob.RegisterBool("TS_DEBUG_USE_IP_COMMAND") +// disableSrcValidMark, if true, disables setting +// net.ipv4.conf.all.src_valid_mark=1, which is normally enabled along with the +// connmark-based rp_filter workaround. +var disableSrcValidMark = envknob.RegisterBool("TS_DEBUG_DISABLE_SRC_VALID_MARK") + // useIPCommand reports whether r should use the "ip" command (or its // fake commandRunner for tests) instead of netlink. func (r *linuxRouter) useIPCommand() bool { @@ -570,7 +575,9 @@ func (r *linuxRouter) Set(cfg *router.Config) error { // connmark restore in mangle/PREROUTING is ineffective — rp_filter // does its routing lookup with fwmark=0, ignoring the restored // bypass mark, and drops reply packets as martians. - if err := writeSysctl("net.ipv4.conf.all.src_valid_mark", "1"); err != nil { + if disableSrcValidMark() { + r.logf("skipping src_valid_mark sysctl (disabled via TS_DEBUG_DISABLE_SRC_VALID_MARK)") + } else if err := writeSysctl("net.ipv4.conf.all.src_valid_mark", "1"); err != nil { r.logf("warning: failed to enable src_valid_mark: %v", err) } default: