From: Willy Tarreau <w@1wt.eu>
To: Marco Davids <mdavids@forfun.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to turn off IPv4 without disabling IPv6
Date: Thu, 25 Apr 2019 22:34:24 +0200 [thread overview]
Message-ID: <20190425203424.GA14855@1wt.eu> (raw)
In-Reply-To: <85740792-d244-ba03-3e72-fb576ddcb7dc@forfun.net>
On Thu, Apr 25, 2019 at 06:42:52PM +0200, Marco Davids wrote:
> Op Thu, Apr 25, 2019 at 13:22, Nico Schottelius wrote:
> > if I cannot turn off IPv4, I cannot test what needs to be fixed.
>
> You know what? I actually agree with Nico on this.
>
> It's 2019 and the adoption of IPv6 is actually gaining momentum (at last).
>
> This is absolutely the time to seriously start thinking about unbundling
> IP-stacks the kernel, so that IPv4 can be truly disabled at compile time.
>
> That will allow for further testing and fixes, just as Nico suggests.
While I can understand the value in doing this, I think that there's
much more value in being able to disable it at run time, precisely
because if you have to reboot to a different kernel for each and every
minor application issue you meet, it will take ages before you converge
to something usable.
Probably that for such tests instead you should use a sysctl to allow/deny
IPv4 socket creation. It should be more than enough for program validation.
Something like the following code (not even compile-tested) could possibly
be sufficient.
Just my two cents,
Willy
-------------
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 104a666..aa9ac80 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -83,6 +83,8 @@ struct netns_ipv4 {
struct xt_table *nat_table;
#endif
+ int sysctl_disable;
+
int sysctl_icmp_echo_ignore_all;
int sysctl_icmp_echo_ignore_broadcasts;
int sysctl_icmp_ignore_bogus_error_responses;
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index eab3ebd..0784c41 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -255,6 +255,9 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
int try_loading_module = 0;
int err;
+ if (net->ipv4.sysctl_disable)
+ return -EAFNOSUPPORT;
+
if (protocol < 0 || protocol >= IPPROTO_MAX)
return -EINVAL;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index eeb4041..73a7ead 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -555,6 +555,13 @@ static struct ctl_table ipv4_table[] = {
static struct ctl_table ipv4_net_table[] = {
{
+ .procname = "disable",
+ .data = &init_net.ipv4.sysctl_disable,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec
+ },
+ {
.procname = "icmp_echo_ignore_all",
.data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
.maxlen = sizeof(int),
next prev parent reply other threads:[~2019-04-25 20:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87mukeqqgf.fsf () line ! ungleich ! ch>
2019-04-25 16:42 ` How to turn off IPv4 without disabling IPv6 Marco Davids
2019-04-25 20:34 ` Willy Tarreau [this message]
2019-04-25 9:32 Nico Schottelius
2019-04-25 10:30 ` Adam Borowski
2019-04-25 11:22 ` Nico Schottelius
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=20190425203424.GA14855@1wt.eu \
--to=w@1wt.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=mdavids@forfun.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).