History log of /freebsd-10.3-release/sbin/ifconfig/ifconfig.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 296373 04-Mar-2016 marius

- Copy stable/10@296371 to releng/10.3 in preparation for 10.3-RC1
builds.
- Update newvers.sh to reflect RC1.
- Update __FreeBSD_version to reflect 10.3.
- Update default pkg(8) configuration to use the quarterly branch.

Approved by: re (implicit)

# 293729 12-Jan-2016 allanjude

MFC: r287842
Make ifconfig always exit with an error code if an important ioctl fails

PR: 203062


# 289986 26-Oct-2015 ngie

MFC r288305:

Replace N #defines with nitems to simplify ifconfig code slightly


# 286810 15-Aug-2015 melifaro

MFC r270064,r270068,r270069,r270115,r270129,r270287,r270822,r271014,
r271524,r273541,r282967,r283009,r283364.

Add support for reading i2c SFP/SFP+ data from NIC driver and
presenting most interesting fields via ifconfig -v.
This version supports Intel ixgbe driver only.

Tested on: Cisco,Intel,Mellanox,ModuleTech,Molex transceivers

* Add new net/sff8436.h containing constants used to access
QSFP+ data via i2c inteface. These constants has been taken
from SFF-8436 "QSFP+ 10 Gbs 4X PLUGGABLE TRANSCEIVER" standard
rev 4.8.
* Add support for printing QSFP+ information from 40G NICs
such as Chelsio T5.

Example:
cxl1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=ec07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,.....>
ether 00:07:43:28:ad:08
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet 40Gbase-LR4 <full-duplex>
status: active
plugged: QSFP+ 40GBASE-LR4 (MPO Parallel Optic)
vendor: OEM PN: OP-QSFP-40G-LR4 SN: 20140318001 DATE: 2014-03-18
module temperature: 64.06 C voltage: 3.26 Volts
lane 1: RX: 0.47 mW (-3.21 dBm) TX: 2.78 mW (4.46 dBm)
lane 2: RX: 0.20 mW (-6.94 dBm) TX: 2.80 mW (4.47 dBm)
lane 3: RX: 0.18 mW (-7.38 dBm) TX: 2.79 mW (4.47 dBm)
lane 4: RX: 0.90 mW (-0.45 dBm) TX: 2.80 mW (4.48 dBm)

Tested on: Chelsio T5
Tested on: Mellanox/Huawei passive/active cables/transceivers.

Sponsored by: Yandex LLC


# 281326 09-Apr-2015 jhb

MFC 279951:
Simplify string mangling in ifmaybeload().
- Use strlcpy() instead of strcpy().
- Use strlcat() instead of a strlcpy() with a magic number subtracted
from the length.
- Replace strncmp(..., strlen(foo) + 1) with strcmp(...).


# 270009 15-Aug-2014 gjb

MFC r269888:
Fix a typo in a comment: s/interprete/interpret/

Sponsored by: The FreeBSD Foundation


# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 244538 21-Dec-2012 kevlo

Fix socket calls on error post-r243965.

Submitted by: Garrett Cooper


# 237263 19-Jun-2012 np

- Updated TOE support in the kernel.

- Stateful TCP offload drivers for Terminator 3 and 4 (T3 and T4) ASICs.
These are available as t3_tom and t4_tom modules that augment cxgb(4)
and cxgbe(4) respectively. The cxgb/cxgbe drivers continue to work as
usual with or without these extra features.

- iWARP driver for Terminator 3 ASIC (kernel verbs). T4 iWARP in the
works and will follow soon.

Build-tested with make universe.

30s overview
============
What interfaces support TCP offload? Look for TOE4 and/or TOE6 in the
capabilities of an interface:
# ifconfig -m | grep TOE

Enable/disable TCP offload on an interface (just like any other ifnet
capability):
# ifconfig cxgbe0 toe
# ifconfig cxgbe0 -toe

Which connections are offloaded? Look for toe4 and/or toe6 in the
output of netstat and sockstat:
# netstat -np tcp | grep toe
# sockstat -46c | grep toe

Reviewed by: bz, gnn
Sponsored by: Chelsio communications.
MFC after: ~3 months (after 9.1, and after ensuring MFC is feasible)


# 236176 28-May-2012 bz

Removed the IFCAP_ prefix when printing the IPv6 checksum capabilities.

Submitted by: dim
MFC after: 3 days


# 236170 28-May-2012 bz

It turns out that too many drivers are not only parsing the L2/3/4
headers for TSO but also for generic checksum offloading. Ideally we
would only have one common function shared amongst all drivers, and
perhaps when updating them for IPv6 we should introduce that.
Eventually we should provide the meta information along with mbufs to
avoid (re-)parsing entirely.

To not break IPv6 (checksums and offload) and to be able to MFC the
changes without risking to hurt 3rd party drivers, duplicate the v4
framework, as other OSes have done as well.

Introduce interface capability flags for TX/RX checksum offload with
IPv6, to allow independent toggling (where possible). Add CSUM_*_IPV6
flags for UDP/TCP over IPv6, and reserve further for SCTP, and IPv6
fragmentation. Define CSUM_DELAY_DATA_IPV6 as we do for legacy IP and
add an alias for CSUM_DATA_VALID_IPV6.

This pretty much brings IPv6 handling in line with IPv4.
TSO is still handled in a different way and not via if_hwassist.

Update ifconfig to allow (un)setting of the new capability flags.
Update loopback to announce the new capabilities and if_hwassist flags.

Individual driver updates will have to follow, as will SCTP.

Reported by: gallatin, dim, ..
Reviewed by: gallatin (glanced at?)
MFC after: 3 days
X-MFC with: r235961,235959,235958


# 235671 19-May-2012 bz

MFp4 bz_ipv6_fast:

Allow tso4 and tso6 be set individually given we have the bits.
This will help with drivers not working as expected during the
transition time and later.

Sponsored by: The FreeBSD Foundation
Sponsored by: iXsystems

Reviewed by: gnn
MFC After: 1 week


# 231642 14-Feb-2012 rmh

Disable jail support in ifconfig when either building a rescue
image or MK_JAIL knob has been set to "no".

Reviewed by: bz
Approved by: adrian (mentor)


# 228571 16-Dec-2011 glebius

A major overhaul of the CARP implementation. The ip_carp.c was started
from scratch, copying needed functionality from the old implemenation
on demand, with a thorough review of all code. The main change is that
interface layer has been removed from the CARP. Now redundant addresses
are configured exactly on the interfaces, they run on.

The CARP configuration itself is, as before, configured and read via
SIOCSVH/SIOCGVH ioctls. A new prefix created with SIOCAIFADDR or
SIOCAIFADDR_IN6 may now be configured to a particular virtual host id,
which makes the prefix redundant.

ifconfig(8) semantics has been changed too: now one doesn't need
to clone carpXX interface, he/she should directly configure a vhid
on a Ethernet interface.

To supply vhid data from the kernel to an application the getifaddrs(8)
function had been changed to pass ifam_data with each address. [1]

The new implementation definitely closes all PRs related to carp(4)
being an interface, and may close several others. It also allows
to run a single redundant IP per interface.

Big thanks to Bjoern Zeeb for his help with inet6 part of patch, for
idea on using ifam_data and for several rounds of reviewing!

PR: kern/117000, kern/126945, kern/126714, kern/120130, kern/117448
Reviewed by: bz
Submitted by: bz [1]


# 224179 18-Jul-2011 bz

If compiling RESCUE always ignore feature_present(3) calls so that
a /rescue/ifconfig more modern than the kernel could still configure
IPv4 or IPv6 addresses.

Reported by: Andrzej Tobola (ato iem.pw.edu.pl)
Reported by: gcooper
MFC after: 1 day
X-MFC: will not MFC any time soon, just reminder for r222527


# 223078 14-Jun-2011 luigi

Grab one of the ifcap bits for netmap, and enable printing in ifconfig.

Document the fact that we might want an IFCAP_CANTCHANGE mask,
even though the value is not yet used in sys/net/if.c

(asked on -current a week ago, no feedback so i assume no objection).


# 222527 31-May-2011 bz

Conditionally compile in the af_inet and af_inet6, af_nd6 modules.
If compiled in for dual-stack use, test with feature_present(3)
to see if we should register the IPv4/IPv6 address family related
options.

In case there is no "inet" support we would love to go with the
usage() and make the address family mandatory (as it is for anything
but inet in theory). Unfortunately people are used to
ifconfig IF up/down
etc. as well, so use a fallback of "link". Adjust the man page
to reflect these minor details.

Improve error handling printing a warning in addition to the usage
telling that we do not know the given address family in two places.

Reviewed by: hrs, rwatson
Sponsored by: The FreeBSD Foundation
Sponsored by: iXsystems
MFC after: 2 weeks


# 216267 07-Dec-2010 weongyo

Introduces IFF_CANTCONFIG interface flag to point that the interface
isn't configurable in a meaningful way. This is for ifconfig(8) or
other tools not to change code whenever IFT_USB-like interfaces are
registered at the interface list.

Reviewed by: brooks
No objections: gavin, jkim


# 216089 01-Dec-2010 weongyo

Don't print usbus[0-9] interfaces that it's not the interesting
interface type for ifconfig(8).


# 210936 06-Aug-2010 jhb

Ethernet vlan(4) interfaces have valid Ethernet link layer addresses but
use a different interface type (IFT_L2VLAN vs IFT_ETHER). Treat IFT_L2VLAN
interfaces like IFT_ETHER interfaces when handling link layer addresses.

Reviewed by: syrinx (bsnmpd)
MFC after: 1 week


# 206637 14-Apr-2010 delphij

When an underlying ioctl(2) handler returns an error, our ioctl(2)
interface considers that it hits a fatal error, and will not copyout
the request structure back for _IOW and _IOWR ioctls, keeping them
untouched.

The previous implementation of the SIOCGIFDESCR ioctl intends to
feed the buffer length back to userland. However, if we return
an error, the feedback would be defeated and ifconfig(8) would
trap into an infinite loop.

This commit changes SIOCGIFDESCR to set buffer field to NULL to
indicate the previous ENAMETOOLONG case.

Reported by: bschmidt
MFC after: 2 weeks


# 205222 16-Mar-2010 qingli

Verify interface up status using its link state only
if the interface has such capability. The interface
capability flag indicates whether such capability
exists. This approach is much more backward compatible.
Physical device driver changes will be part of another
commit.

Also updated the ifconfig utility to show the LINKSTATE
capability if present.

Reviewed by: rwatson, imp, juli
MFC after: 3 days


# 204150 20-Feb-2010 yongari

Add TSO support on VLAN in fconfig(8).

Reviewed by: thompsa


# 203052 27-Jan-2010 delphij

Revised revision 199201 (add interface description capability as inspired
by OpenBSD), based on comments from many, including rwatson, jhb, brooks
and others.

Sponsored by: iXsystems, Inc.
MFC after: 1 month


# 199770 25-Nov-2009 will

Make ``ifconfig -l ether'' only list interfaces that speak Ethernet.

PR: 118987
Approved by: ken (mentor)


# 199231 12-Nov-2009 delphij

Revert revision 199201 for now as it has introduced a kernel vulnerability
and requires more polishing.


# 199201 11-Nov-2009 delphij

Add interface description capability as inspired by OpenBSD.

MFC after: 3 months


# 195890 26-Jul-2009 bz

Make ifconfig ifN -vnet <jname|jid> actually work:

- fix ifconfig to ignore the non-existent interface in the current
network stack in case of '-vnet'.
- in ifconfig: actually use the local variables defined for the
vnet functions rather than modifying the global.

Reviewed by: rwatson
Approved by: re (kib)


# 194871 24-Jun-2009 jamie

Add the "vnet" and "-vnet" options, to allow moving interfaces between
jails with VIMAGE.

Approved by: bz (mentor)


# 194799 23-Jun-2009 delphij

- Use size_t instead of int when appropriate;
- Use C99 sparse initialization.

With these changes ifconfig(8) is WARNS=2 clean.


# 191252 18-Apr-2009 rwatson

ifconfig(8) no longer needs to know how to print the IFF_NEEDSGIANT flag,
since it shortly won't be defined at all.


# 189864 15-Mar-2009 jamie

Default to AF_LOCAL instead of AF_INET sockets for non-family-specific
operations. This allows the query operations to work in non-IPv4 jails,
and will be necessary in a future of possible non-INET networking.

Approved by: bz (mentor)


# 187253 14-Jan-2009 sam

use correct interface name when setting flags; fixes ifconfig ... create ... up

Noticed by: Chris Anderson


# 183466 29-Sep-2008 sam

Distinguish between cmd/parameters used for clone operations and
all others. Use this to disambiguate cmd line arguments that can
be either clone params or regular parameters so, in particular,
"bssid" again works as a regular parameter.

While here leverage the above to improve the logic for flushing
clone operations on the first !clone cmd line parameter.

Reviewed by: jhay


# 182414 28-Aug-2008 jfv

Add support in ifconfig to control the vlan hardware filter feature.

Reviewed by: EvilSam and moi
MFC after:1 week


# 181224 03-Aug-2008 thompsa

Move the grekey to its own file, ifconfig.c does not have interface specific
code.

Submitted by: sam


# 179894 20-Jun-2008 thompsa

Add support for the optional key in the GRE header.

PR: kern/114714
Submitted by: Cristian KLEIN


# 177799 31-Mar-2008 sam

Fix handling of create operation together with setting other parameters:
o mark cmds/parameters to indicate they are potential arguments to a clone
operation (e.g. vlantag)
o when handling a create/clone operation do the callback on seeing the first
non-clone cmd line argument so the new device is created and can be used;
and re-setup operating state to reflect the newly created device

Reviewed by: Eugene Grosbein
MFC after: 2 weeks


# 174505 10-Dec-2007 sam

Wake On Lan (WOL) infrastructure

Submitted by: Stefan Sperling <stsp@stsp.name>
Reviewed by: brooks


# 172438 04-Oct-2007 thompsa

Fix the module name matching to the drivers present in the kernel. Previously
it would return true on a partial match where it would think the edsc module
was already present by having a positive match on 'ed'. This changes it so
that it compares the full string including the nul terminators.

This also fixes a buffer overflow in the ifkind variable where the length of
the interface name in *argv wasnt checked for size.

Reviewed by: brooks
Approved by: re (gnn)


# 170679 13-Jun-2007 rwatson

Remove IPX over IP tunneling pieces from ifconfig(8), omitted portion of
previous commit:

Remove IPX over IP tunneling support, which allows IPX routing over IP
tunnels, and was not MPSAFE. The code can be easily restored in the
event that someone with an IPX over IP tunnel configuration can work
with me to test patches.

This removes one of five remaining consumers of NET_NEEDS_GIANT.

Approved by: re (kensmith)

Spotted by: Artem Naluzhny <tutat nhamon dot com dot ua>


# 170578 11-Jun-2007 andre

Add reporting and toggling of TCP LRO (large receive offload) support to
ifconfig(8).


# 169873 22-May-2007 thompsa

Add the -n flag for disabling automatic module loading, this will be used by
rc.d to stop it reloading the network module on unload.


# 167871 24-Mar-2007 yar

Back out rev. 1.129 because it breaks the practice of auto-loading
hardware drivers. Unlike pseudo-device drivers, which just attach
to the cloning framework and wait for "ifconfig create", h/w drivers
create interfaces for installed cards as soon as loaded. The issue
of devd(8) involuntarily reloading modules should be dealt with in a
different way.


# 167485 12-Mar-2007 yar

Attempt to load the kernel module only if we are going to create a
new interface. In other cases loading the module is unwanted and
can lead to ill side effects. One such effect found is as follows:
"kldunload if_foo" tells the module to kill all its interfaces,
which results in messages sent to devd; the module unloads. Then
devd starts processing the messages, which ends up in a etc script
running ifconfig fooX, which reloads the module.


# 167081 27-Feb-2007 sam

o consistently check strlcpy result
o warn when we skip an interface because it's name is too long


# 167079 27-Feb-2007 sam

correct type to silence const complaint


# 167078 27-Feb-2007 sam

unbreak create operation, must copy argument to global name

Spotted by: des


# 166956 24-Feb-2007 sam

use getifaddrs from libc instead of private code

Reviewed by: bms
MFC after: 1 month


# 165641 29-Dec-2006 bz

Fix an off-by-one which could mean writing beyond the end of the array
when copying the interface name.
This code part should probably be rewritten.


# 162469 20-Sep-2006 andre

In setifcap() only set/unset those capabilities the interface actually
supports.


# 162152 08-Sep-2006 andre

Fix octal representation of TSO4 and TSO6 bits in interface capabilities
description.


# 162088 06-Sep-2006 andre

Make TSO (TCP segmentation offload) capabilities visible and accessible with
'ifconfig em0 tso' and 'ifconfig em0 -tso'. TSO for IPv4 and IPv6 is always
enabled or disabled together. The driver may enable only one if it doesn't
support both.

Document 'tso' and '-tso' in the ifconfig(8) man pages.

Sponsored by: TCP/IP Optimization Fundraise 2005


# 160196 09-Jul-2006 sam

o replace special handling of clone operations by a clone callback
mechanism
o change vlan cloning to use callback and pass all vlan parameters
on create using the new SIOCREATE2 ioctl
o update vlan set logic to match existing practice


# 156591 12-Mar-2006 glebius

There is no IFF_POLLING flag anymore.


# 155053 30-Jan-2006 glebius

Recognize new VLAN_HWCSUM flag.


# 155050 30-Jan-2006 yar

Do address assignment/removal operations after callbacks.

Presently, ifconfig callbacks are used for L2 configuration, media
and vlan, so actions associated with address assignment, like sending
out a gratuitous ARP, should go when L2 is running already.

This also should fix the problem with setting up vlan interfaces
from rc.conf, when both IP and vlan+vlandev parameters are passed
to ifconfig at once.

Future work: Consider introducing several ifconfig callback lists
to invoke callbacks orderly.

MFC after: 1 week


# 150740 29-Sep-2005 yar

For the sake of consistency and easier typing,
introduce "-tunnel" as an alias for "deletetunnel".
The latter is overly long and prone to typos, but
keep it for POLA since it costs nothing.

MFC after: 5 days


# 148001 14-Jul-2005 rwatson

Add a new flag '-k' to ifconfig(8), indicating that it is alright to
print potentially sensitive keying material to stdout. With the new
802.11 support, ifconfig(8) is now capable of printing 802.11 keys,
and did by default for the root user, which is undesirable in some
environments. Now it will not print keying material unless requested
(and available to the user).

MFC after: 1 week


# 147979 13-Jul-2005 yar

Add symbolic names for the IFF_PPROMISC and IFF_NEEDSGIANT flags
so that ifconfig(8) can print them.

MFC after: 5 days


# 146426 20-May-2005 sam

guard against bogus address data

Submitted by: Bakul Shah


# 144818 08-Apr-2005 stefanf

ISO C does not allow unnamed union members.


# 144817 08-Apr-2005 stefanf

Fix typo in comment.


# 139494 31-Dec-2004 sam

Fix special status reporting. Prior to the reorg there was
special-purpose code to display status for an interface for
state that was not address-oriented. This status reporting
was merged in to the address-oriented status reporting but
did not work for link address reporting (as discovered with
fwip interfaces). Correct this mis-merge and eliminate the
bogus kludge that was used for link-level address reporting.

o add an af_other_status method for an address family for
reporting status of things like media, vlan, etc.
o call the af_other_status methods after reporting address
status for an interface
o special-case link address status; when reporting all
status for an interface invoke it specially prior to
reporting af_other_status methods (since it requires the
sockaddr_dl that is passed in to status separately from
the rtmsg address state)
o correct the calling convention for link address status;
don't cast types, construct the proper parameter

This fixes ifconfig on fwip interfaces.


# 138671 11-Dec-2004 sam

add a callback mechanism for code that wants to defer committing changes
until all the command line args have been processed

Reviewed by: ambrisko


# 138593 08-Dec-2004 sam

Overhaul to cleanup some of the tangled logic that's grown over the years.

o break per-address family support out into separate files
o modularize per-address family and functional operations using
a registration mechanism; this permits configuration according
to which files you include (but beware that order of the files
is important to insure backwards compatibility)
o many cleanups to eliminate incestuous behaviour, global variables,
and poor coding practices (still much more to fix)

The original motivation of this work was to support dynamic addition
of functionality based on the interface so we can eliminate the various
little control programs and so that vendors can distribute ifconfig
plugins that support their in-kernel code. That work is still to be
completed.

o Update 802.11 support for all the new net80211 functionality; some
of these operations (e.g. list *) may be better suited in a different
program


# 134609 01-Sep-2004 brooks

Use a spare byte in struct if_data to store the structure size without
increasing it. Add code to ifconfig to use this size to find the
sockaddr_dl after the struct if_data in the routing message. This
allows struct if_data to grow (up to 255 bytes) without breaking
ifconfig.

Submitted by: peter


# 133352 09-Aug-2004 yongari

Fix long standing mediaopt setting bugs seen on sparc64. Though
the bug exists in little-endian machine, it was not triggered due
to the difference of memory ordering between little/big endian
machines. Instead of relying on possibly modified value during
function invokcations, use saved copy of ifr.ifr_addr.sa_family.
Also add a comment at the top of ifconfig.c clarifying the issue
so the bug won't re-appear.

Approved by: jake
Reviewed by: yar


# 132658 26-Jul-2004 yar

Add two knobs to ifconfig(8), `vlanmtu' and `vlanhwtag',
that provide control over the respective capabilities
of an interface, reception of extended frames and hardware
VLAN multiplexor.


# 128782 30-Apr-2004 ambrisko

For both ifconfig and route if we didn't get enough memory from the
prior sysctl due to the structure growing between calls try again.

Also try again for deleting routes if things fail. We've seen
route -f fail this way which does not actually flush all routes.
This fixes it. It will whine but it will do the work.

PR: 56732
Obtained from: IronPort


# 128186 13-Apr-2004 luigi

Replace ROUNDUP/ADVANCE with SA_SIZE


# 128113 11-Apr-2004 ru

Added the new interface capability option for drivers that implement
user-configurable polling(4) support. Make ifconfig(8) aware of it.

Suggested by: luigi


# 128073 09-Apr-2004 markm

Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp


# 127649 30-Mar-2004 sam

add support for setting 802.11 rtsthreshold, transmit power,
and 11g protection mode

Reviewed by: imp (just code)


# 126895 12-Mar-2004 ru

The print mask's first part is the base, not the total number of bit
identifiers.


# 126894 12-Mar-2004 ru

Show the polling(4) flag on the interface.


# 126797 10-Mar-2004 bde

Fixed a misspelling of 0 as NULL.


# 126301 27-Feb-2004 kan

Look for both name and if_<name> strings in module metadata. Pseudo-devices
like tun are naming their modules using the 'if_; prefix and previous version of
the code failed to detect their presence in the kernel, resulting in the same
module being loaded twice.


# 125412 04-Feb-2004 brooks

Add ifconfig support for network interface renaming. In the process,
reorganize the printing of the interface name when using wildcard
cloning so it is not printed if it we either immediately rename or
destroy the interface.

Reviewed by: ru


# 125280 31-Jan-2004 brooks

Use memcpy plus a manual NUL termination when copying the interface name
from the sdl because strlcpy requires that the source string be
NUL-terminated unlike strncpy.

Submitted by: Peter Jeremy <PeterJeremy at optushome dot com dot au>


# 125060 27-Jan-2004 brooks

Use IFNAMSIZ instead of a magic value for the length of an interface
name.

Prevent the kernel from potentially overflowing the interface name
variable. The size argument of strlcpy is complex because the name is
not null-terminated in sdl_data.


# 121539 26-Oct-2003 peter

Give wider types to sscanf to fix two warnings (u_short cannot be > 0xffff)
and to make sure that we catch oversized arguments rather than silently
truncate them. I dont know if sscanf will reject an integer if it will
not fit in the short return variable or not, but this way it should be
detected.


# 120626 01-Oct-2003 ru

By popular demand, added the "static ARP" per-interface option.


# 114164 28-Apr-2003 sam

add a "mode" directive to specify the operating mode for multi-mode devices;
this is mostly intended for use with multi-mode 802.11 devices that support
some combination of 11a, 11b, and 11g


# 113503 15-Apr-2003 mdodd

Don't abuse module names to facilitate ifconfig module loading;
such abuse isn't really needed. (And if we do need type information
associated with a module then we should make it explicit and not
use hacks.)


# 111921 05-Mar-2003 peter

Kill #ifdef NS code


# 109740 23-Jan-2003 mdodd

Add missing #if USE_IF_MEDIA/#endif.


# 109670 22-Jan-2003 fjoe

fix link_status() in non-Ethernet case

MFC after: 1 week


# 106940 15-Nov-2002 sam

o display new interface capability bits
o capitilize capability bit strings for consistency

Approved by: re


# 105881 24-Oct-2002 phk

Report the MONITOR bit.


# 105825 23-Oct-2002 rwatson

Rename ifconfig's "mac" argument to "maclabel" to prevent confusion
regarding 802.1 MAC and Mandatory Access Control (MAC). Some
potential for confusion remains further in other areas of the
system regarding Message Authentication Codes (MAC).

Requested by: wollman
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories


# 105760 23-Oct-2002 rwatson

Teach ifconfig(8) how to print and set the MAC labels on network
interfaces using the 'mac' argument. Without MAC support in the
kernel, this does not change the behavior of ifconfig.

Approved by: re
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories


# 104337 02-Oct-2002 dd

Don't crash when the user feeds us nonesense in the form:
ifconfig IF ether WHATEVER -alias

PR: 42544
Submitted by: Mike Makonnen <makonnen@pacbell.net>


# 104044 27-Sep-2002 phk

Add the "Monitor" interface flag.

Setting this flag on an ethernet interface blocks transmission of packets
and discards incoming packets after BPF processing.

This is useful if you want to monitor network trafic but not interact
with the network in question.

Sponsored by: http://www.babeltech.dk


# 102099 19-Aug-2002 sobomax

Implement user-setable promiscuous mode (a new `promisc' flag for ifconfig(8)).
Also, for all interfaces in this mode pass all ethernet frames to upper layer,
even those not addressed to our own MAC, which allows packets encapsulated
in those frames be processed with packet filters (ipfw(8) et al).

Emphatically requested by: Anton Turygin <pa3op@ukr-link.net>
Valuable suggestions by: fenner


# 102095 19-Aug-2002 sobomax

Fix last-minute typo which breaks the world.

Submitted by: many


# 102052 18-Aug-2002 sobomax

Increase size of ifnet.if_flags from 16 bits (short) to 32 bits (int). To avoid
breaking application ABI use unused ifreq.ifru_flags[1] for upper 16 bits in
SIOCSIFFLAGS and SIOCGIFFLAGS ioctl's.

Reviewed by: -hackers, -net


# 98258 15-Jun-2002 ume

Add eui64 option which fills interface index (lowermost 64bit of
an IPv6 address) automatically.
This should obsolete prefix(8).

Obtained from: NetBSD
MFC after: 2 weeks


# 95005 18-Apr-2002 imp

De-__P, use ansi function definitions


# 93281 27-Mar-2002 ru

Turn "ether" address family into a generic "link" family
that could be used to set/get arbitrary length link level
addresses. Alias "lladdr" parameter and "ether" family
to the new "link" family for backward compatibility.

PR: bin/31476
MFC after: 1 week


# 92806 20-Mar-2002 obrien

Remove 'register' keyword.
It does not help modern compilers, and some may take some hit from it.
(I also found several functions that listed *every* of its 10 local vars with
"register" -- just how many free registers do people think machines have?)


# 87274 03-Dec-2001 ru

MTU and metric are available with NET_RT_IFLIST.

MFC after: 3 days


# 85075 17-Oct-2001 jlemon

When specifying an interface to ifconfig, first look up the interface
index, then retrieve statistics for that index, rather than retrieving
all interfaces and then looking for a matching name. This allows the
user to refer to an interface via an alias name.

While I'm here, also perform a few assorted cleanups.


# 83637 18-Sep-2001 jlemon

Split hwcsum into rxcsum and txcsum components.


# 83626 18-Sep-2001 jlemon

Teach ifconfig about the new interface capability words.


# 81862 17-Aug-2001 brooks

Actuall make plumb work in addition to create as per the manpage.

PR: bin/29812
Submitted by: Joao Carlos Mendes Luis <jonny@eng05.embratel.net.br>


# 80392 26-Jul-2001 ume

ifconfig if0 netmask xxx.xxx.xxx.0 didn't change the netmask.

PR: bin/28833
MFC after: 3 days


# 80057 21-Jul-2001 obrien

Dike out the IPX bits if RELEASE_CRUNCH is defined.


# 79105 02-Jul-2001 brooks

Support network device cloning via create and destroy options.

Reviewed by: ru, ume
Obtained from: NetBSD
MFC after: 1 week


# 78064 11-Jun-2001 ume

Sync with recent KAME.
This work was based on kame-20010528-freebsd43-snap.tgz and some
critical problem after the snap was out were fixed.
There are many many changes since last KAME merge.

TODO:
- The definitions of SADB_* in sys/net/pfkeyv2.h are still different
from RFC2407/IANA assignment because of binary compatibility
issue. It should be fixed under 5-CURRENT.
- ip6po_m member of struct ip6_pktopts is no longer used. But, it
is still there because of binary compatibility issue. It should
be removed under 5-CURRENT.

Reviewed by: itojun
Obtained from: KAME
MFC after: 3 weeks


# 77385 29-May-2001 phk

When using interfaces that support if_media, the supported media list is
printed on a single, very long, and generally unreadable line. This
isn't very useful. It's also really ugly and most of the time you don't
care what media is supported anyway.

PR: 27701
Submitted by: Brooks Davis <brooks@one-eyed-alien.net>


# 77217 26-May-2001 phk

Currently, each wireless networking driver has it's own control program
despite the fact that most people want to set exactly the same settings
regardless of which card they have. It has been repeatidly suggested
that this configuration should be done via ifconfig. This patch
implements the required functionality in ifconfig and add support to the
wi and an drivers. It also provides partial, untested support for the
awi driver.

PR: 25577
Submitted by: Brooks Davis <brooks@one-eyed-alien.net>


# 76276 04-May-2001 jesper

Implement slash/CIDR notation for IPv4 and IPv6 addresses.

MFC after: 1 week

Reviewed by: phk
Obtained from: NetBSD


# 72805 21-Feb-2001 ume

if no address is setted, do not call ioctl(SIOCAIFADDR)

Obtained from: KAME


# 69424 30-Nov-2000 ache

Add missing && which absense stops 'make world'


# 69414 30-Nov-2000 luigi

remove an undefined reference when no VLAN support is compiled in.


# 69261 27-Nov-2000 ume

Add missing initialization for IPv6 address lifetime.

PR: misc/22884
Obtained from: KAME


# 63542 19-Jul-2000 archie

Show the actual command line usage in the man page and usage error string.


# 63473 18-Jul-2000 archie

Make "ifconfig" with no arguments equivalent to "ifconfig -a".


# 63026 12-Jul-2000 jhb

Add support to the 'ether' address family to support setting of addresses.
This allows you to set ether addresses with 'ifconfig ether'. Also, use
some saner socket address families that allow several special case tests
to be removed.


# 61734 16-Jun-2000 wpaul

Implement SIOCSIFLLADDR, which allows you to change the link-level
address on an interface. This basically allows you to do what my
little setmac module/utility does via ifconfig. This involves the
following changes:

socket.h: define SIOCSIFLLADDR
if.c: add support for SIOCSIFLLADDR, which resets the values in
the arpcom struct and sockaddr_dl for the specified interface.
Note that if the interface is already up, we need to down/up
it in order to program the underlying hardware's receive filter.
ifconfig.c: add lladdr command
ifconfig.8: document lladdr command

You can now force the MAC address on any ethernet interface to be
whatever you want. (The change is not sticky across reboots of course:
we don't actually reprogram the EEPROM or anything.) Actually, you
can reprogram the MAC address on other kinds of interfaces too; this
shouldn't be ethernet-specific (though at the moment it's limited to
6 bytes of address data).

Nobody ran up to me and said "this is the politically correct way to
do this!" so I don't want to hear any complaints from people who think
I could have done it more elegantly. Consider yourselves lucky I didn't
do it by having ifconfig tread all over /dev/kmem.


# 57776 06-Mar-2000 peter

Purely cosmetic tweak, use consistant whitespace with scopeid.


# 57562 28-Feb-2000 shin

Print scope id for scoped addrs.

Approved by: jkh


# 57520 26-Feb-2000 rwatson

Introduce ``add'' and ``remove'' as alternatives to ``alias'' and ``delete''.
Improve compatibility with BSD/OS, and also more accurately reflect that
IP aliases aren't really any different than the primary IP address on an
interface.

Reviewed by: dcs
Approved by: jkh


# 57108 10-Feb-2000 shin

Support IPv6 scoped addr in ifconfig and route

IPv6 scoped addr display is not yet supported by ifconfig
and route. Now almost of IPv6 apps support it, so its support
in ifconfig and route is important to keep consisetncy, and
to avoid user confusion.

Approved by: jkh


# 55215 29-Dec-1999 ru

- do not dereference a null pointer.
- minor sanity.

PR: 15318


# 54662 16-Dec-1999 billf

Spelling correction (adress -> address)


# 54263 07-Dec-1999 shin

udp IPv6 support, IPv6/IPv4 tunneling support in kernel,
packet divert at kernel for IPv6/IPv4 translater daemon

This includes queue related patch submitted by jburkhol@home.com.

Submitted by: queue related patch from jburkhol@home.com
Reviewed by: freebsd-arch, cvs-committers
Obtained from: KAME project


# 51452 20-Sep-1999 msmith

If we don't appear to have a module loaded supporting the interface
we're about to operate on, try to load one. Don't complain if the
load fails, and always press on regardless (there may not be a module
suitable or required).

With the renaming of the PCI ethernet driver modules and the addition
of appropriate miibus dependancies on those modules that need it, it is
now no longer necessary to compile many ethernet drivers into the kernel;
they will be loaded on demand the first time they are ifconfig'ed.

Inspiration from: mount
Reviewed by: obrien


# 50476 28-Aug-1999 peter

$Id$ -> $FreeBSD$


# 48027 19-Jun-1999 phk

Move the IFSTATUS stuff after the address listing.


# 48021 19-Jun-1999 phk

Add a new interface ioctl, to return "aux status".

This is inteded for to allow ifconfig to print various unstructured
information from an interface.

The data is returned from the kernel in ASCII form, see the comment in
if.h for some technicalities.

Canonical cut&paste example to be found in if_tun.c

Initial use:
Now tun* interfaces tell the PID of the process which opened them.

Future uses could be (volounteers welcome!):
Have ppp/slip interfaces tell which tty they use.
Make sync interfaces return their media state: red/yellow/blue
alarm, timeslot assignment and so on.
Make ethernets warn about missing heartbeats and/or cables


# 47777 06-Jun-1999 phk

Introduce IFF_SMART bit.

This means that the driver will add/delete routes when it knows it is
up/down, rather than have the generic code belive it is up if configured.

This is probably most useful for serial lines, although many PHY chips
could probably tell us if we're connected to the cable/hub as well.


# 44764 15-Mar-1999 wpaul

Grrr... botched remote commit. Let's try this again: vlan updates,
take two.


# 38154 07-Aug-1998 phk

unifdef -UISO

Inspired by bdes comment to PR: 7419


# 37445 06-Jul-1998 bde

ioctl() request args are unsigned longs, so don't attempt to store
them as ints. Among other bugs, doing so at best caused benign
overflow followed by fatal sign extension on machines with 32-bit
ints and 64-bit longs.


# 37416 06-Jul-1998 charnier

Update man page to allow adding address_family when -l is used (this is a no op
for now). Correct use of .Nm. Short usage string (see man page for full list).
Spelling. Use err(3).


# 34691 19-Mar-1998 eivind

Make 'ifconfig -l ether' only list Ethernet interfaces. This is
useful, intuitive, and match the old comments in the source.
Previously, 'ifconfig -l ether' and 'ifconfig -l' were equal.


# 32008 26-Dec-1997 imp

style(9) corrections
Submitted by: bde


# 31954 24-Dec-1997 imp

Be extra paranoid about trusting the size of the address returned from
gethostbyaddr.
Submitted by: Julian Assange


# 30757 27-Oct-1997 steve

Fix a misleading comment.

PR: bin/4861
Submitted by: Alex <garbanzo@hooked.net>


# 30459 16-Oct-1997 peter

Make the supported media info output the default.
The -m switch is now accepted for backwards compatability.

Suggested by: davidg


# 25667 10-May-1997 peter

Clean up some more. Move parsing of sysctl iflist data into a single
place rather than updating the main loop's index variables from within
a subroutine and other revolting things like that. Move some more
globals into local variables.


# 25660 10-May-1997 peter

Grumble.. My last patchup here didn't quite work either. I hate this
program and it's use of global variables. Somehow, I managed to miss the
most obvious case.. "ifconfig ed0 10.0.0.1" failed (no "inet")

Submitted by: dfr


# 25522 07-May-1997 peter

Restore unintentially lost backwards compat behavior of defaulting to
family inet if not specified. (eg: "ifconfig ed0" down would fail because
no family was specified, even though the up/down status is not per family)

Pointed out by: Wolfgang Helbig <helbig@MX.BA-Stuttgart.De>


# 25451 04-May-1997 peter

Commit hooks for ifmedia support. It's optional in the Makefile, and
can be trivially disabled.


# 25449 04-May-1997 peter

Second try at cleanups and fixes (without if_media stuff for the moment)
- parse command options using getopt for consistancy
- sanitise the command parsing so that it's less like spaghetti
- implement a "-l" option (idea from NetBSD - just list names)
- attempt to clean up the sysctl parsing loop some more. It still needs
to be taken out the back and shot though.
- cut down on global usage, but there's a lot more scope for this.
- make usage string a bit closer to reality (it was missing lots of things)

Unfortunately, I did this for the second time but with the memory of
the NetBSD version still recently in my mind. It's hard to redo simple
changes or getopt stuff without making it look like what you've been
working with a few hours ago.


# 25448 04-May-1997 peter

force null commit to skip over rev 1.25 so there's less cvs trouble


# 22990 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 21264 03-Jan-1997 wollman

Update to match changes in <net/if.h>.


# 20287 10-Dec-1996 wollman

Fix up programs which expect <net/if.h> to include <sys/time.h> to instead
do it themselves. (Some of these programs actually depended on this
beyond compiling the definition of struct ifinfo!) Also fix up some
other #include messes while we're at it.


# 19914 21-Nov-1996 wollman

Fix lots of non-bug questionable code:

- Don't link against libkvm and don't uselessly include <kvm.h>.
- Declare constant objects as const.
- Declare functions with the correct types.
- Call functions with the correct parameters.

Not fixed:

- The sysctl parsing remains ugly (but it may be the best we can do).
- atnetrange() should use strtoul() rather than sscanf() for better
error checking.


# 18032 04-Sep-1996 julian

Get rid of an unexpectedly bogus sanity check under appletalk because
it stopped us from removing or setting loopback address
on lo0:

also make use of the fact the athe sockaddre_at struct now has a "netrange"
field.

CVS ----------------------------------------------------------------------


# 17254 23-Jul-1996 julian

Submitted by: archie@whistle.com

appletalk cleanups


# 17171 14-Jul-1996 alex

Grammar fix described by wollman in response to PR 1363.


# 17022 09-Jul-1996 julian

Submitted by: Archie@whistle.com
Obtained from: Whistle Communications
patches to allow ifconfig to work with appletalk addresses etc.


# 14092 13-Feb-1996 wollman

XNS sort-of-support is no more.


# 13940 06-Feb-1996 wollman

Remove support for OSI networking in user-land (#ifdef OSI aor CCITT)
in preparation for its removal from the kernel source tree. NB: because
a function was deleted, libc is now at version 3.0 (was 2.2 previously).


# 13753 30-Jan-1996 ache

Add missing comma in usage printf


# 13345 08-Jan-1996 peter

Yet another "fix" for some of the mistakes in the recent versions..

I discovered that when asking for the IFLIST via sysctl(), if you
specify only AF_INET address, it actually gives you only AF_INET..
(suprise, suprise..!)

Now, it should "do the right thing" in just about all cases... The only
problem, is that "the right thing" isn't exactly clear in all cases.


# 13329 08-Jan-1996 peter

Fix some of my mistakes, slight cleanup, improve reliability (the old
ifconfig would segfault on "ifconfig ed0 ether up" and the like).

The main reason for this commit was that an "ifconfig -a" would also show
the AF_INET addresses in AF_IPX form (if the kernel was configured for IPX)
due to insufficient AF checking in my "new way" of doing it.


# 13145 01-Jan-1996 peter

My really ugly hack to ifconfig to make it pick up interface aliases
and the ethernet address for non-root users.

I apologise to the world for propagating the ugliness of some of the code
constructs within ifconfig... Fixing them would just abou mean rewriting
most of the function call interfaces, something I didn't have the stomach
for. :-)


# 12672 07-Dec-1995 wollman

Use a dynamically-sized buffer for SIOCGIFCONF so that `ifconfig -a'
actually retrieves all the information no matter how many interfaces
there are. (Probably there are other utilities which need similar
modification.)

Submitted by: Andrew Webster <awebster@dataradio.com>


# 11819 26-Oct-1995 julian

Reviewed by: julian and jhay@mikom.csir.co.za
Submitted by: Mike Mitchell, supervisor@alb.asctmd.com

This is a bulk mport of Mike's IPX/SPX protocol stacks and all the
related gunf that goes with it..
it is not guaranteed to work 100% correctly at this time
but as we had several people trying to work on it
I figured it would be better to get it checked in so
they could all get teh same thing to work on..

Mikes been using it for a year or so
but on 2.0

more changes and stuff will be merged in from other developers now that this is in.

Mike Mitchell, Network Engineer
AMTECH Systems Corporation, Technology and Manufacturing
8600 Jefferson Street, Albuquerque, New Mexico 87113 (505) 856-8000
supervisor@alb.asctmd.com


# 8871 30-May-1995 rgrimes

Remove trailing whitespace.


# 8089 26-Apr-1995 pst

Replace call to obsolete inet_addr routine with inet_aton so we can specify
netmasks and broadcast addresses of 255.255.255.255.


# 7039 12-Mar-1995 wpaul

Impliment -ad and -au flags in addition to -a and document the change
in the man page. ifconfig -au affects all interfaces marked as up,
and ifconfig -ad affects only the interfaces marked down. ifconfig -a
still handles everything. This change is purely for compatibility with
SunOS, for those who might be accustomed to the SunOS ifconfig's
behavior.


# 5298 30-Dec-1994 jkh

From: Wankle Rotary Engine <wpaul@skynet.ctr.columbia.edu>

- The -a flag now works just as it does in SunOS: '-a' is actually
handled like a wildcard for all interfaces. 'ifconfig -a' displays
the status of all interfaces, 'ifconfig -a netmask 0xffffff00' sets
the netmask of all interfaces, and so forth. I don't know if many
people really need to be able to set the netmasks of all interfaces
at once, but the SunOS ifconfig seems to allow this, so there you
have it.

- An 'ether_status' function has been added to display the ethernet
address of all ethernet interfaces. Again, as in SunOS, you must
be root in order for this to work. The ethernet address is read
from /dev/kmem using kvm_open() and kvm_read(), much in the same
was as it's done with netstat. If you choose to install ifconfig
set-gid kmem then normal users will be able to see the ethernet
address as well, though this may not be desireable. This feature
requires a small change to the ifconfig Makefile: you need to link
with -lkvm in order to use the kvm_*() functions.

Submitted by: wpaul


# 4702 20-Nov-1994 ats

Add parameters "compress", "normal" and "noicmp" for the slip usage.
These names are used in the slip.hosts file as examples, but ifconfig
have formerly only accepted link0, -link0 and link1 for this.


# 1940 08-Aug-1994 dg

Added support for setting the per-interface MTU.


# 1559 26-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1558,
which included commits to RCS files with non-trunk default branches.


# 1558 26-May-1994 rgrimes

BSD 4.4 Lite sbin Sources

Note: XNSrouted and routed NOT imported here, they shall be imported with
usr.sbin.