From: Andries.Brouwer@cwi.nl
To: linux-kernel@vger.kernel.org, net-tools@lina.inka.de, philb@gnu.org
Subject: ifconfig and SIOCSIFADDR
Date: Tue, 24 Jul 2001 14:47:56 GMT [thread overview]
Message-ID: <200107241447.OAA07015@vlet.cwi.nl> (raw)
I just noticed that the command
ifconfig eth1 netmask 255.255.255.0 broadcast 10.0.0.255 10.0.0.150
(with ifconfig from net-tools-1.60)
results in a netmask of 255.0.0.0, which is wrong in my situation.
Why does ifconfig ignore the explicitly given netmask?
Because it does SIOCSIFNETMASK, then SIOCSIFBRDADDR, then SIOCSIFADDR,
and the last ioctl destroys the information set by the previous two.
I consider this a kernel bug, but the code has been in the kernel
for a long time. In 2.2 and 2.4 it is (devinet.c):
case SIOCSIFADDR:
...
if (!(dev->flags&IFF_POINTOPOINT)) {
ifa->ifa_prefixlen = inet_abc_len(ifa->ifa_address);
ifa->ifa_mask = inet_make_mask(ifa->ifa_prefixlen);
if ((dev->flags&IFF_BROADCAST) && ifa->ifa_prefixlen < 31)
ifa->ifa_broadcast = ifa->ifa_address|~ifa->ifa_mask;
} else {
ifa->ifa_prefixlen = 32;
ifa->ifa_mask = inet_make_mask(32);
}
and in 2.0 it is (net/core/dev.c):
case SIOCSIFADDR:
...
/* This is naughty. When net-032e comes out It wants moving
into the net032 code not the kernel. Till then it can sit
here (SIGH) */
if (!dev->pa_mask)
dev->pa_mask = ip_get_mask(dev->pa_addr);
if (!dev->pa_brdaddr)
dev->pa_brdaddr = dev->pa_addr | ~dev->pa_mask;
that is, 2.0 and earlier will only (reluctantly) set netmask and
broadcast address when it was not set already.
Probably things should be corrected both in the kernel and in ifconfig:
SIOCSIFADDR should not change netmask and broadcast address,
and ifconfig should assume that SIOCSIFADDR may be destructive
and hence wait with setting netmask and broadcast address
until after the SIOCSIFADDR.
Andries
next reply other threads:[~2001-07-24 14:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-24 14:47 Andries.Brouwer [this message]
2001-07-24 16:05 ` Ingo Oeser
2001-07-24 22:50 ` Alexey Kuznetsov
2001-07-25 19:23 Andries.Brouwer
2001-07-25 19:40 ` kuznet
2001-07-26 14:47 ` Gerhard Mack
2001-07-25 20:26 Andries.Brouwer
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=200107241447.OAA07015@vlet.cwi.nl \
--to=andries.brouwer@cwi.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=net-tools@lina.inka.de \
--cc=philb@gnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®