Home | History | Annotate | Download | only in net
History log of /src/sys/net/if_ether.h
RevisionDateAuthorComments
 1.91  05-Feb-2024  andvar fix various typos in comments.
 1.90  01-Aug-2023  mrg fix simple mis-matched function prototype and definitions.

most of these are like, eg

void foo(int[2]);

with either of these

void foo(int*) { ... }
void foo(int[]) { ... }

in some cases (such as stat or utimes* calls found in our header files),
we now match standard definition from opengroup.

found by GCC 12.
 1.89  20-Jun-2022  yamaguchi bridge(4): support VLAN frames stripped by hardware tagging
 1.88  15-Nov-2021  yamaguchi introduced APIs to configure VLAN TAG to ethernet devices
 1.87  30-Sep-2021  yamaguchi Provide a hook point called when ether_ifdetach is called
 1.86  14-Feb-2021  roy if_ether: revert prior alignment checks

Apparently not needed as our drivers ensure this.
 1.85  13-Feb-2021  roy if_ether: Ensure that ether_header is aligned
 1.84  03-Feb-2021  roy CTASSERT -> __CTASSERT to unbreak userland build.

While here move __packed in tcp_debug.h back to where it was and
note removal warrants more investigation.
 1.83  03-Feb-2021  roy Sprinkle CTASSERT to enforce on-wire layout without __packed
 1.82  03-Feb-2021  roy Remove __packed from various network structures

They are already network aligned and adding the __packed attribute
just causes needless compiler warnings about accssing members of packed
objects.
 1.81  17-Jul-2019  msaitoh branches: 1.81.10;
Implement VLAN hardware filter function(ETHERCAP_VLAN_HWFILTER).
First proposed by jmcneill in 2017 and modified by me.

How to use:

- Set callback function:

ether_set_vlan_cb(struct ethercom *, ether_vlancb_t)

- Callback. This function is called when a vlan is attached/detached to the
parent interface:

int (*ether_vlancb_t)(struct ethercom *ec, uint16_t vlanid, bool set);

- ifconfig(8)

ifconfig ixg0 [-]vlan-hwfilter

Note that ETHERCAP_VLAN_HWFILTER is set by default on ixg(4) because
the PF driver usually enable "all block" filter by default.
 1.80  17-Jul-2019  msaitoh KNF. No functional change.
 1.79  29-May-2019  msaitoh Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.78  15-May-2019  ozaki-r Store IFF_ALLMULTI in ec_flags instead of if_flags to avoid data races

IFF_ALLMULTI is set/unset to if_flags via if_mcast_op. To avoid data races on
if_flags, IFNET_LOCK was added for if_mcast_op. Unfortunately it produces
a deadlock so we want to remove added IFNET_LOCK by avoiding the data races by
another approach.

This fix introduces ec_flags to struct ethercom and stores IFF_ALLMULTI to it.
ec_flags is protected by ETHER_LOCK and thus IFNET_LOCK is no longer necessary
for if_mcast_op. Note that the fix is applied only to MP-safe drivers that
the data races matter.

In the kernel, IFF_ALLMULTI is set by a driver and used by the driver itself.
So changing the storing place doesn't break anything. One exception is
ioctl(SIOCGIFFLAGS); we have to include IFF_ALLMULTI in a result if needed to
export the flag as well as before.

A upcoming commit will remove IFNET_LOCK.

PR kern/54189
 1.77  05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.76  21-Dec-2018  msaitoh Add ETHERCAP_VLAN_HWFILTER and ETHERCAP_EEE.
 1.75  14-Jun-2018  yamaguchi branches: 1.75.2;
Remove ETHER_LOOKUP_MULTI()

The macro has been replaced with a function.
ok ozaki-r@
 1.74  14-Jun-2018  yamaguchi Replace macros related to multicast address with inline functions

ok ozaki-r@
 1.73  14-Jun-2018  yamaguchi Move macros related to multicast address into #ifdef _KERNEL

Those macros and structure are only used in the kernel.
reviewed by ozaki-r@n.o, thanks.
 1.72  19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.71  15-Jan-2018  maxv branches: 1.71.2;
Mostly style, and add a bunch of KASSERTs.
 1.70  22-Nov-2017  msaitoh No functional change:
- u_int16_t -> uint16_t
- u_short -> uint16_t
- tag_hash_func -> vlan_tag_hash
- 0 -> NULL because vlr_parent is a pointer.
 1.69  22-Nov-2017  msaitoh Fix a bug that a vlan packet which has priority or CFI bit in the tag causes
panic.
 1.68  28-Sep-2017  christos - add a constant for the vlan mask.
- enforce that we have a tag before we get it.
 1.67  26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.66  28-Dec-2016  ozaki-r branches: 1.66.8;
Protect ec_multi* with mutex

The data can be accessed from sysctl, ioctl, interface watchdog
(if_slowtimo) and interrupt handlers. We need to protect the data against
parallel accesses from them.

Currently the mutex is applied to some drivers, we need to apply it to all
drivers in the future.

Note that the mutex is adaptive one for ease of implementation but some
drivers access the data in interrupt context so we cannot apply the mutex
to every drivers as is. We have two options: one is to replace the mutex
with a spin one, which requires some additional works (see
ether_multicast_sysctl), and the other is to modify the drivers to access
the data not in interrupt context somehow.
 1.65  19-Nov-2015  christos branches: 1.65.2;

Add handling of VLAN packets in if_bridge where the parent interface supports
them (Jean-Jacques.Puig@espci.fr). Factor out the vlan_mtu enabling and
disabling code.
 1.64  28-Jul-2014  ozaki-r branches: 1.64.2; 1.64.4;
Add a mutex for global variables of if_ethersubr.c

To initialize the mutex, we introduce etherinit that is called from ifinit1.
 1.63  10-Jun-2014  joerg Introduce new sysctls for obtaining interface-specific addresses:
- net.sdl for the active link-layer adddress (the MAC)
- net.ether.multicast for the Ethernet multicast addresses
- net.inet6.multicast for the IPv6 multicast groups
- net.inet6.multicast_kludge for temporarily removed multicast groups

Use this sysctls for replacing the kmem grovelling in ifmcstat(8).
 1.62  23-Apr-2014  pooka add a mask for currently valid ETHERCAP flags
 1.61  31-Oct-2012  msaitoh branches: 1.61.2; 1.61.10;
Add SIOCGETHERCAP ioctl.
There was no way to know the setting of ec_capabilities and ec_capenable
other than grepping the source.

See http://mail-index.netbsd.org/tech-kern/2010/07/28/msg008613.html
 1.60  25-Oct-2012  msaitoh Move the prototype definition of ether_input() from if.h to if_ether.h.
 1.59  30-Sep-2012  dholland Requires <net/if.h> to be compilable by itself.
 1.58  19-May-2010  christos branches: 1.58.8; 1.58.18;
Replace ether_nonstatic_aton with a
- better named one
- not suffering from buffer oveflow
- simpler
- handling different separators
- returning error codes for errors

Some ideas from one posted on tech-net by Jonathan A. Kollasch
 1.57  19-May-2010  jakllsch Changes to ether_nonstatic_aton():

Be more leinent on input string format. Each nibble pair may optionally be
followed by any of ':', '-', '.' or ' '.

Make source string const and work on a temporary copy. The caller may not
expect their string to be destroyed.
 1.56  18-Mar-2009  cegger branches: 1.56.2; 1.56.4;
bcmp -> memcmp
 1.55  14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.54  07-Nov-2008  dyoung branches: 1.54.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.53  25-Jul-2008  dsl branches: 1.53.2;
Move the body of VLAN_INPUT_TAG() into a static inline function.
(Maybe it shouldn't even be inline - but I'd have to work out where to put it).
VLAN_INPUT_TAG() now calls vlan_input_tag() and does '_errcase' when it fails.
In reality the callers should all be changed, _errcase is ALWAYS continue,
which used to 'continue' (ie break) the do .. while (0) loop - not the
intended action!
Found by ramming all the kernel sources through a modified lint and grepping
for a specific error.
While here enclose the body of VLAN_OUTPUT_TAG() in ().
 1.52  25-Jul-2008  christos PR/39203: Paul Ripke: PPPoE issues with broken MTU/MRU implementations
Allow larger frames for systems that don't negotiate MTU/MRU properly.
 1.51  22-May-2008  dyoung branches: 1.51.2; 1.51.4;
Add ETHER_IS_LOCAL(). Tests for "local" ethernet addresses.
 1.50  15-Mar-2008  rtr branches: 1.50.2; 1.50.4; 1.50.6;
whitespace '\t' -> ' '
 1.49  20-Feb-2008  matt branches: 1.49.2; 1.49.6;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)
 1.48  31-Dec-2007  dyoung Add media-handling code for several ethernet drivers with MII buses
to share.
 1.47  25-Dec-2007  perry Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.46  19-Sep-2007  dyoung branches: 1.46.6; 1.46.8; 1.46.12;
Constify sockaddr argument to ether_multiaddr(). Change struct
ifreq * arguments to ether_addmulti() and ether_delmulti() to const
struct sockaddr *, since ether_{add,del}multi() only ever read the
sockaddr ifreq member, ifr_addr. Update uses in carp(4) and in
vlan(4).
 1.45  04-Mar-2007  christos branches: 1.45.2; 1.45.14; 1.45.16;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.44  17-Feb-2007  dyoung KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.

Cosmetic: don't open-code TAILQ_FOREACH().

Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.

Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.

Constify:

1 Introduce const accessor for route->ro_dst, rtcache_getdst().

2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.

3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.

4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
 1.43  24-Nov-2006  rpaulo branches: 1.43.2; 1.43.4;
The change I committed to etherip was wrong. ether_snprintf doesn't make
sense when chaning the MAC address of the virtual interface as pointed
out by Hans himself.
So, introduce ether_nonstatic_aton() and make etherip(4) and tap(4) use it.
 1.42  16-Mar-2006  christos branches: 1.42.10; 1.42.12;
Add a new function called ether_snprintf() which takes an external buffer
and a length. The buffer should be 3 * addrlen.
Remove local tap_ether_sprintf(), and use ether_snprintf() instead.
 1.41  29-Jan-2006  jdolecek branches: 1.41.2; 1.41.4; 1.41.6; 1.41.8;
fix VLAN_ATTACHED() macro, it was always true due to condition bug

Fixes PR kern/32645 by Pavel Cahyna
 1.40  10-Dec-2005  elad branches: 1.40.2;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.39  18-Mar-2005  yamt branches: 1.39.2;
add agr(4), a pseudo network device driver for link aggregation.
 1.38  20-Feb-2005  jdolecek expose the new VLAN macros only within kernel
 1.37  20-Feb-2005  jdolecek add several VLAN tagging related macros, to reduce code duplication
in various ethernet adapter drivers and improve code consistency; mostly
FreeBSD-compatible, with exception of VLAN_OUTPUT_TAG(), which takes
(struct ethercom *) rather than (struct ifnet *) as first parameter
since the information cannot be extracted via (struct ifnet)

also add VLAN_ATTACHED(ec), which tests if any VLAN is attached to the
ethernet device
 1.36  08-Jan-2005  yamt branches: 1.36.2; 1.36.4;
constify broadcastaddr.
 1.35  08-Jan-2005  yamt remove an unused member, enm_ec from ether_multi.
 1.34  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.33  26-Jun-2003  tron branches: 1.33.2;
Test for symbol "_KERNEL_OPT" instead of "_LKM" as suggested by
Matthew Green.
 1.32  26-Jun-2003  tron Don't include "opt_mbuftrace.h" if "_LKM" is defined. This fixes a build
problem in the "vmware-module3" package.
 1.31  23-Jun-2003  martin Make sure to include opt_foo.h if a defflag option FOO is used.
 1.30  25-Mar-2003  bouyer Make promiscous mode work on vlans: introduce a new link-layer m_flag
M_PROMISC. In ether_input(), flag packets comming from an interface in
promiscous mode which are not for us M_PROMISC instead of droping them.
Drop M_PROMISC packets which are not passed to vlan_input(). M_PROMISC
packets passed to vlan_input() will be looped back to ether_input()
the M_PROMISC flag will be handled appropriately.
Clear M_PROMISC before giving the packet to bridge, as bridge has its own
checks for local MAC addresses.
This also makes bridges on vlan working.
 1.29  26-Feb-2003  matt Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.
 1.28  16-Sep-2002  tron Use "const" for all input parameters of ethers(3) functions.
 1.27  05-Mar-2002  itojun branches: 1.27.8;
bring in latest ALTQ from kjc. ALTQify some of the drivers.
 1.26  05-Nov-2001  matt Switch to using queue access macros instead of refering to the member
fields explicitly.
 1.25  03-Jun-2001  thorpej branches: 1.25.2; 1.25.6;
Consider the configured MTU of the interface when determining
if a packet is too large.
 1.24  03-Jun-2001  thorpej Add a capability bit that indicates support for Gigabit Ethernet
jumbo frames, and use it in SIOCSIFMTU.
 1.23  07-Apr-2001  thorpej Add altq_etherclassify(), a slight hack modified from the kame/freebsd4
tree, which allows a packet with Ethernet headers already present to
run through the ALTQ packet classifier. This is needed in order to
suport ALTQ on VLAN and bridge devices.
 1.22  07-Apr-2001  thorpej ether_*() functions belong in if_ether.h, not if.h.
 1.21  17-Nov-2000  bouyer branches: 1.21.2;
Supports hardware 802.1q VLAN tagging, per discussion on tech-net. The tag is
stored in a m_aux mbuf defined by AF_LINK, ETHERTYPE_VLAN.
Thanks to Jason & Itojun for the feedback.
 1.20  11-Oct-2000  thorpej Implement ether_ioctl(), ioctl operations common to all Ethernet
interfaces.
 1.19  03-Oct-2000  thorpej Improve the VLAN support, in particular, handling of MTU:
- Add a macro to compute the max frame length based on Ethertype
and presence of FCS, and use it to validate the packet size
in ether_input().
- Add capabilites to struct ethercom, and allow hardware drivers
to specify that they can handle the larger hardware MTU that
VLANs require in order to strictly conform to 802.1Q.
- Make ether_ifdetach() clear out the link address and free all of
the Ethernet multicast structures.

Also, rearrange the VLAN driver itself in preparation to supporting
other hardware types, including FDDI (which has 802.1Q VLAN capability).
 1.18  28-Sep-2000  enami Factor out and give a name to the common functionality to translate
sockaddr which represents a multicast address into an Ethernet address
or range of Etherenet addresses.
 1.17  17-Jun-2000  matt branches: 1.17.2;
Ansify before committing my next change.
 1.16  29-Mar-2000  enami branches: 1.16.2;
Fix typo in comment.
 1.15  29-Mar-2000  simonb Extern etherbroadcastaddr, ether_ipmulticast_min and ether_ipmulticast_max.
 1.14  06-Mar-2000  thorpej - Initialize ifp->if_baudrate to a sensible value when the interface is
attached.
- Add ether_crc32_be() and ether_crc_le(), common functions for computing
the Ethernet CRC on arbitrary length buffers. Nothing uses them yet,
and these should be double-checked and probably re-implemented as
table-driven functions.
 1.13  19-Nov-1999  thorpej Add the `packed' attribute to structures which describe wire protocol
data formats.
 1.12  10-Aug-1999  thorpej branches: 1.12.2; 1.12.8;
u_char -> u_int8_t in the IPv6 goo.
 1.11  05-Aug-1999  thorpej M_HASCRC -> M_HASFCS, as suggested by Christoph Badura.
 1.10  04-Aug-1999  thorpej Define an Ethernet-specific flag which drivers can use to tell
the input routine that the CRC is included at the end of the frame.
 1.9  01-Jul-1999  itojun IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.
 1.8  09-Apr-1999  drochner don't expose structures and prototypes to _STANDALONE programs
 1.7  25-Mar-1999  thorpej branches: 1.7.2;
Define several constants related to the Ethernet protocol:
- ETHER_ADDR_LEN: length of Ethernet address (actually, we already defined
this).
- ETHER_TYPE_LEN: length of the Ethernet header `type' field.
- ETHER_CRC_LEN: length of the Ethernet CRC (explorer got this already, mostly
because I forgot to commit these changes earlier).
- ETHER_HDR_LEN: total length of the Ethernet header
- ETHER_MAX_LEN: maximum length of an Ethernet frame, including header and CRC
- ETHER_MIN_LEN: minimum length of an Ethernet frame, including header and CRC

Define ETHERMTU and ETHERMIN (payload sizes) in terms of the above constants.
 1.6  25-Mar-1999  explorer define ETHER_CRC_LEN, for if_vr.c
 1.5  28-Jul-1998  is branches: 1.5.6;
Remove obsolete comment.
 1.4  09-Feb-1998  perry add multiple inclusion protection (and cleanup).
 1.3  02-Nov-1997  lukem * modify ether_aton, ether_hostton, and ether_line to take 'const char *'
arguments as appropriate
 1.2  15-Mar-1997  is branches: 1.2.8;
New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.1  07-Feb-1997  is branches: 1.1.2;
file if_ether.h was initially added on branch is-newarp.
 1.1.2.3  06-Mar-1997  is Factor out the ETHERTYPE_XXX definitions. They are needed as
- Ethernet protocol type numbers
- ARP protocol type numbers, as per "Assigned Numbers".
This way we don't need to pull in all the Ethernet include file into the
ARP code.
 1.1.2.2  18-Feb-1997  is Having converted everything, remove the struct ether_arp definition completely.
Some small cleanup.
STILLTODO: some sanity checks of the (now) variable link level address length
in incoming packets..
 1.1.2.1  07-Feb-1997  is Snapshot of new ARP code.

Our old ARP code was hardwired for 6-byte length medium
addresses, while the protocol is designed for any size.

This snapshot contains a first hack at getting rid of
Ethernet specific data structures. The ep driver is updated
(and tested on the PCI bus), the iy and fpa drivers have been
updated, but not real life tested yet.

If you want to test this with other drivers, you have to update
them first yourself, and probably tag the relevant directories.
Better contact me if you want to do this.
 1.2.8.1  10-Nov-1997  thorpej Sync w/ trunk.
 1.5.6.1  11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.7.2.1  09-Apr-1999  drochner branches: 1.7.2.1.2; 1.7.2.1.4;
pull up rev. 1.8 - namespace protection for _STANDALONE programs
 1.7.2.1.4.2  30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.7.2.1.4.1  28-Jun-1999  itojun KAME/NetBSD 1.4 SNAP kit, dated 19990628.

NOTE: this branch (kame) is used just for refernce. this may not compile
due to multiple reasons.
 1.7.2.1.2.2  01-Jul-1999  thorpej Sync w/ -current.
 1.7.2.1.2.1  21-Jun-1999  thorpej Sync w/ -current.
 1.12.8.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.2.3  21-Apr-2001  bouyer Sync with HEAD
 1.12.2.2  22-Nov-2000  bouyer Sync with HEAD.
 1.12.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.16.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.17.2.2  07-Jun-2001  he Pull up revision 1.25 (requested by thorpej):
Consider the configured MTU of the interface when determining
if a packet is too large.
 1.17.2.1  31-Dec-2000  jhawk Pull up revisions 1.18-1.19, 1.21 (requested by bouyer):
Add support for 802.1Q virtual LANs.
 1.21.2.5  18-Oct-2002  nathanw Catch up to -current.
 1.21.2.4  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.21.2.3  14-Nov-2001  nathanw Catch up to -current.
 1.21.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.21.2.1  09-Apr-2001  nathanw Catch up with -current.
 1.25.6.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.25.2.3  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.25.2.2  16-Mar-2002  jdolecek Catch up with -current.
 1.25.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.27.8.1  30-Jun-2003  grant Pull up revision 1.30 (requested by bouyer in ticket #1356):

Make promiscous mode work on vlans: introduce a new link-layer m_flag
M_PROMISC. In ether_input(), flag packets comming from an interface in
promiscous mode which are not for us M_PROMISC instead of droping them.
Drop M_PROMISC packets which are not passed to vlan_input(). M_PROMISC
packets passed to vlan_input() will be looped back to ether_input()
the M_PROMISC flag will be handled appropriately.
Clear M_PROMISC before giving the packet to bridge, as bridge has its
own checks for local MAC addresses.
This also makes bridges on vlan working.
 1.33.2.7  11-Dec-2005  christos Sync with head.
 1.33.2.6  01-Apr-2005  skrll Sync with HEAD.
 1.33.2.5  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.33.2.4  17-Jan-2005  skrll Sync with HEAD.
 1.33.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.33.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.33.2.1  03-Aug-2004  skrll Sync with HEAD
 1.36.4.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.36.2.1  29-Apr-2005  kent sync with -current
 1.39.2.8  17-Mar-2008  yamt sync with head.
 1.39.2.7  27-Feb-2008  yamt sync with head.
 1.39.2.6  21-Jan-2008  yamt sync with head
 1.39.2.5  27-Oct-2007  yamt sync with head.
 1.39.2.4  03-Sep-2007  yamt sync with head.
 1.39.2.3  26-Feb-2007  yamt sync with head.
 1.39.2.2  30-Dec-2006  yamt sync with head.
 1.39.2.1  21-Jun-2006  yamt sync with head.
 1.40.2.1  01-Feb-2006  yamt sync with head.
 1.41.8.1  19-Apr-2006  elad sync with head.
 1.41.6.1  01-Apr-2006  yamt sync with head.
 1.41.4.1  22-Apr-2006  simonb Sync with head.
 1.41.2.1  09-Sep-2006  rpaulo sync with head
 1.42.12.1  10-Dec-2006  yamt sync with head.
 1.42.10.1  12-Jan-2007  ad Sync with head.
 1.43.4.2  12-Mar-2007  rmind Sync with HEAD.
 1.43.4.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.43.2.1  31-Mar-2009  bouyer Pull up following revision(s) (requested by dholland in ticket #1294):
sys/net/if_ether.h: revision 1.52
PR/39203: Paul Ripke: PPPoE issues with broken MTU/MRU implementations
Allow larger frames for systems that don't negotiate MTU/MRU properly.
 1.45.16.3  23-Mar-2008  matt sync with HEAD
 1.45.16.2  09-Jan-2008  matt sync with HEAD
 1.45.16.1  06-Nov-2007  matt sync with HEAD
 1.45.14.1  02-Oct-2007  joerg Sync with HEAD.
 1.45.2.1  09-Oct-2007  ad Sync with head.
 1.46.12.1  02-Jan-2008  bouyer Sync with HEAD
 1.46.8.1  26-Dec-2007  ad Sync with head.
 1.46.6.1  18-Feb-2008  mjf Sync with HEAD.
 1.49.6.4  17-Jan-2009  mjf Sync with HEAD.
 1.49.6.3  28-Sep-2008  mjf Sync with HEAD.
 1.49.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.49.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.49.2.1  24-Mar-2008  keiichi sync with head.
 1.50.6.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.50.6.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.50.4.2  11-Aug-2010  yamt sync with head.
 1.50.4.1  04-May-2009  yamt sync with head.
 1.50.2.1  04-Jun-2008  yamt sync with head
 1.51.4.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.51.4.1  19-Oct-2008  haad Sync with HEAD.
 1.51.2.1  28-Jul-2008  simonb Sync with head.
 1.53.2.2  28-Apr-2009  skrll Sync with HEAD.
 1.53.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.54.4.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.56.4.1  30-May-2010  rmind sync with head
 1.56.2.1  17-Aug-2010  uebayasi Sync with HEAD.
 1.58.18.3  03-Dec-2017  jdolecek update from HEAD
 1.58.18.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.58.18.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.58.8.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.58.8.2  16-Jan-2013  yamt sync with (a bit old) head
 1.58.8.1  30-Oct-2012  yamt sync with head
 1.61.10.1  10-Aug-2014  tls Rebase.
 1.61.2.1  18-May-2014  rmind sync with head
 1.64.4.2  05-Feb-2017  skrll Sync with HEAD
 1.64.4.1  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.64.2.1  24-Sep-2017  snj Pull up following revision(s) (requested by manu in ticket #1409):
sys/arch/xen/xen/if_xennet_xenbus.c: 1.65
sys/arch/xen/xen/xennetback_xenbus.c: 1.53, 1.56 via patch
sys/net/if_bridge.c: 1.105
sys/net/if_ether.h: 1.65
sys/net/if_ethersubr.c: 1.215, 1.235
sys/net/if_vlan.c: 1.76, 1.77, 1.83, 1.88, 1.94
Protect vlan_unconfig with a mutex
It is not thread-safe but is likely to be executed in concurrent.
See PR 49264 for more detail.
--
Tweak vlan_unconfig
No functional change.
--
Add handling of VLAN packets in if_bridge where the parent interface supports
them (Jean-Jacques.Puig%espci.fr@localhost). Factor out the vlan_mtu enabling and
disabling code.
--
Enable the VLAN mtu capability and check for the adjusted packet size
(Jean-Jacques.Puig at espci.fr).
Factor out the packet-size checking function for clarity.
--
Don't increment the reference count only when it was 0...
From Jean-Jacques.Puig
--
Account for the CRC len (Jean-Jacques.Puig)
--
Fix a bug that the parent interface's callback wasn't called when the vlan
interface is configured. A callback function uses VLAN_ATTACHED() function
which check ec->ec_nvlans, the value should be incremented before calling the
callback. This bug was added in if_vlan.c rev. 1.83 (2015/11/19).
 1.65.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.66.8.2  24-Nov-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #389):
sys/net/if_ether.h: revision 1.69
sys/net/if_vlan.c: revision 1.108
sys/dev/pci/if_bge.c: revision 1.313
sys/net/if_vlanvar.h: revision 1.11
sys/net/if_vlanvar.h: revision 1.12
sys/net/if_ether.h: revision 1.70
sys/net/if_vlan.c: revision 1.110
sys/dev/pci/if_wm.c: revision 1.544
sys/dev/pci/if_wmreg.h: revision 1.105
Fix a bug that a vlan packet which has priority or CFI bit in the tag causes
panic.
Revert part of if_bge.c 1.312. It's not required to mask other than VLAN ID
bits in VLAN tag.
Revert if_wmreg.h 1.104 and if_wm.c 1.542. It's not required to mask other
than VLAN ID bits in VLAN tag.
No functional change:
- u_int16_t -> uint16_t
- u_short -> uint16_t
- tag_hash_func -> vlan_tag_hash
- 0 -> NULL because vlr_parent is a pointer.
 1.66.8.1  24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.71.2.3  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.71.2.2  25-Jun-2018  pgoyette Sync with HEAD
 1.71.2.1  22-Apr-2018  pgoyette Sync with HEAD
 1.75.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.75.2.1  10-Jun-2019  christos Sync with HEAD
 1.81.10.1  03-Apr-2021  thorpej Sync with HEAD.

RSS XML Feed