All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Subject: iproute2: dealing with tunnel type mismatchs how?
Date: Fri, 7 Apr 2023 12:54:06 -0700	[thread overview]
Message-ID: <20230407125406.10ac2ec4@hermes.local> (raw)

Luca notified us of a bug in iproute2 tunnel change that does not have an easy
way to resolve. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1032642

The trigger is doing a ip tunnel change request on the wrong type of tunnel.
In this case it is doing an IPv4 type change on an gre6 tunnel. Doing this
is not a valid thing to do, but the kernel and ip tunnel command do not
handle it well.

The root cause is that socket private ioctl's are a bad design from the start!
The same ioctl can return different data depending on the interface used.
The change request requires that ip tunnel do an ioctl
to get current values, and the returned data depends on the type of tunnel (gre vs gre6).
Netlink related API's don't have this type of issue.

None of the options is great:
1. Leave it alone, this has been this way for 15 years.
1a. Make the call to fetch tunnel parameters with a bigger buffer so
    that failure is not a stack smash, just garbage in.

2. Change kernel ioctl to not allow IPv4 socket to be used when doing IPv6 tunnel
   operations. Not easy since the socket context is not passed down through the
   tunnel ioctl calls.

3. Add logic to ip tunnel to do netlink calls to find the type of device being
   changed, and catch mismatches there. There is not a simple direct way to get
   the type, although it probably could be inferred from the ip link type.

4. The whole 'ip tunnel' set of commands is actually superfluous at this point.
   Same things can be done via 'ip link' and none of the problems happen.
   Therefore, start process of deprecating and removing 'ip tunnel'??

5. Remove the change option from 'ip tunnel'.  And force the user to make
   a new tunnel if they want to change endpoints etc.

Ideas and comments appreciated.

                 reply	other threads:[~2023-04-07 19:54 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=20230407125406.10ac2ec4@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    /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.