All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nico Schottelius <nico.schottelius@ungleich.ch>
To: wireguard@lists.zx2c4.com
Subject: Why is the src_valid_mark needed and not allowed (in kubernetes)?
Date: Thu, 05 May 2022 22:01:24 +0200	[thread overview]
Message-ID: <87o80b7mzf.fsf@ungleich.ch> (raw)


Hello again,

while debugging wireguard in Kubernetes, we noticed that adding a
default route for IPv4 is not possible/allowed, wg-quick fails with:

        sysctl: error setting key 'net.ipv4.conf.all.src_valid_mark': Read-only file system

Which can be traced back to:

        [[ $proto == -4 ]] && cmd sysctl -q net.ipv4.conf.all.src_valid_mark=1

inside the

       add_default() {

function of wg-quick. If one tries to escape this using a pod
specification to set the sysctl using

    spec:
       securityContext:
         sysctls:
           - name: net.ipv4.conf.all.src_valid_mark
             value: "1"

Kubernetes by default disallows it and returns a "SysctlForbidden"
error.

Now, one can easily "fool" wg-quick using

    AllowedIPs = 0.0.0.0/1, 128.0.0.0/1

instead of

    AllowedIPs = 0.0.0.0/0

which makes the container work w/o the sysctl, as the add_default()
function is not called. Running it like this in kubernetes results in:

+ wg show
interface: ipv4
  public key: HV9IgFLPSHJgG4jbDzaJg97Uch3eebrV5we4wUkAcUg=
  private key: (hidden)
  listening port: 51828

peer: 6BRnQ+dmeFzVCH9RbM1pbJ7u3y3qrl+zUzzYCmC88kE=
  endpoint: [2a0a:e5c0:2:2:0:84ff:fe41:f265]:51820
  allowed ips: 0.0.0.0/1, 128.0.0.0/1

And allows outside IPv4 communication within an IPv6 only kubernetes
cluster, which was the objective in the first place.

My questions:

   - Why is net.ipv4.conf.all.src_valid_mark needed?
   - And why does working around using 0.0.0.0/1, 128.0.0.0/1 works /
     what is the drawback of this?

Best regards and a good evening from container land,

Nico

--
Sustainable and modern Infrastructures by ungleich.ch

                 reply	other threads:[~2022-05-05 20:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o80b7mzf.fsf@ungleich.ch \
    --to=nico.schottelius@ungleich.ch \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.