Commit Graph

307 Commits

Author SHA1 Message Date
msaitoh 445ae7101a Add comment to clarify. 2021-12-10 01:18:29 +00:00
yamaguchi 39a10a7057 Move net/agr/ieee8023_slowprotocols.h to net/ether_slowprotocols.h
Definitions related to slowprotocols are duplicated between
agr/ieee8023ad_slowprotocols.h and lagg/if_lagg_lacp.h
Therefore, the contents are moved to added file.

Note: currently, there are just LACP and Marker protocol,
however slowprotocols is independent of them.
2021-11-30 01:17:02 +00:00
msaitoh d5e8a28158 Better counting for ierrors, iqdrops and noproto in ether_input().
- Use if_noproto for unknown or unsupported protocols.
 - Use if_ierrors for wrong mbuf or oversized frame.
2021-11-25 00:49:34 +00:00
yamaguchi 4263242bc9 introduced APIs to configure VLAN TAG to ethernet devices 2021-11-15 07:07:05 +00:00
christos b0f3d8a093 Don't classify dropped packets that we don't understand as errors, for
example etype 0x88CA (TIPC (Transparent Inter Process Communication,)
or 0x893A (IEEE 1905).
Classify them as dropped like Linux does (FreeBSD just ignores them). From RVP.
2021-11-08 16:50:05 +00:00
ryo f682244b8e frame's vlan tag must be ntohs()'ed.
VLAN 0 Priority tag was misrecognized on non vlan-hwtagging interfaces.
2021-10-25 17:05:43 +00:00
knakahara 7128a14d48 Make pktq_rps_hash() pluggable for each interface type. Reviewed by gdt@n.o, thorpej@n.o, and riastradh@n.o, thanks. 2021-10-11 05:13:10 +00:00
yamaguchi 1f3caf1ea7 lagg: Register lagg_ifdetach to ether_ifdetach hook 2021-09-30 04:29:16 +00:00
yamaguchi e87863469b vlan: Register vlan_ifdetach to ether_ifdetach hook 2021-09-30 04:13:42 +00:00
yamaguchi c06d6dc9b0 bridge: Register bridge_ifdetach to ether_ifdetach hook 2021-09-30 03:57:48 +00:00
yamaguchi e83dba728e Provide a hook point called when ether_ifdetach is called 2021-09-30 03:54:04 +00:00
yamaguchi b9fe3c4690 net: obsolete ifnet::if_link_state_chenged
that was used for updating link-state of vlan I/F

The obsoleted function is replaced with
ifnet::if_linkstate_hooks
2021-09-30 03:51:05 +00:00
yamaguchi 1202a27903 vlan: Register the callback to update link-state of vlan I/F
to link-state change hook

The callback is registered in every vlan I/F even if the parent
interface is the same. Therefore it is not needed to search the
vlan I/F by the parent interface unlike the previous callback.
2021-09-30 03:47:27 +00:00
yamaguchi 5efe2d40a7 Replace ifnet::if_agriprivate with ifnet::if_lagg
agr(4) and lagg(4) can not be used on the same interface so that
if_agrprivate and if_lagg are not used at the same time.
For resolve this wasteful, if_lagg is used in not only lagg(4)
but also agr(4).

After this modification, if_lagg has 3 states:
1. if_lagg == NULL
   - Both agr(4) and lagg(4) are not running on the interface
2. if_lagg != NULL && ifp->if_type != IFT_IEEE8023ADLAG
   - agr(4) is running on the I/F
3. if_lagg != NULL && ifp->if_type == IFT_IEEE8023ADLAG
   - lagg(4) is running on the I/F
2021-09-30 03:15:25 +00:00
yamaguchi f0101d0e08 Add a new link-aggregation pseudo interface named lagg(4)
- FreeBSD's lagg(4) based implementation
 - MP-safe and MP-scalable
2021-05-17 04:07:41 +00:00
roy 951b7674b2 if_ether: revert prior alignment checks
Apparently not needed as our drivers ensure this.
2021-02-14 19:35:37 +00:00
roy cb6917aa0d Prior alignment fixes should not use an offset 2021-02-13 13:00:16 +00:00
roy 1aaed635b1 if_ether: Ensure that ether_header is aligned 2021-02-13 07:28:04 +00:00
roy c271800399 vlan: match the interface link state with that of the parent
Now addresses on a vlan will detach and undergo duplicate address
dectection on link state changes just as on a standard interface.
2020-09-26 18:38:09 +00:00
ozaki-r 66c98485b3 ether: count dropped packets on output 2020-08-28 06:27:49 +00:00
ozaki-r 71970c91f7 ether: count dropped packets on input 2020-08-28 06:27:16 +00:00
ozaki-r 2b8d8a416c ether: separate handling of LLC frames as ether_input_llc (NFCI) 2020-08-28 06:25:52 +00:00
ozaki-r 28929b6f6d net: introduce IFQ_ENQUEUE_ISR to assemble packet queuing routines (NFCI) 2020-08-28 06:23:42 +00:00
riastradh f385d5ca9e Convert ether_input from rnd_initial_entropy to entropy_epoch(). 2020-04-30 03:29:55 +00:00
thorpej 83ce4c20bb Add and use a new function, mowner_init_owner(), that initializes an
MBUFTRACE mowner structure (so that providers of it don't have to
grovel the internals).
2020-03-15 23:14:41 +00:00
thorpej 70b554e641 Adopt <net/if_stats.h>. 2020-01-29 04:11:35 +00:00
kardel 12b9b4e230 use the CARP interface for arp/nd instead of the carp parent interface.
this provides the correct source mac address for the packets.

there are routers out there that cache the source mac during
nd and then subsequently bypass/miss packet filters on carp
interfaces as they send to the parent interface mac instead of the
correct carp interface mac.
2020-01-16 13:16:59 +00:00
christos 176ada4b2b Add and use __FPTRCAST, requested by uwe@ 2019-10-16 18:29:49 +00:00
christos d2348edc56 Add void * function pointer casts. There are different ways to "fix" those
warnings:
    1. this one: add a void * cast (which I think is the least intrusive)
    2. add pragmas to elide the warning
    3. add intermediate inline conversion functions
    4. change the called function prototypes, adding unused arguments and
       converting some of the pointer arguments to void *.
    5. make the functions varyadic (which defeats the purpose of checking)
    6. pass command line flags to elide the warning
I did try 3 and 4 and I was not pleased with the result (sys_ptrace_common.c)
(3) added too much code and defines, and (4) made the regular use clumsy.
2019-10-16 15:27:38 +00:00
msaitoh 08f48d8fd1 Print oversized frame's message only when DIAGNOSTIC is set. The message
is not so important because we increment if_iqdrops now.
2019-10-02 04:17:16 +00:00
msaitoh b7164648bb Increment if_iqdrops when dropping an oversized frame. 2019-10-01 08:13:16 +00:00
msaitoh eea2ee1212 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.
2019-07-17 03:26:24 +00:00
msaitoh b9958efe6c 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.
2019-05-29 10:07:28 +00:00
ozaki-r 99ec0af5eb 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
2019-05-15 02:56:47 +00:00
mrg 85303579aa add or adjust fallthru comments. 2019-02-04 10:09:31 +00:00
msaitoh 7b54e0066d Add SIOCSETHERCAP. It's used to change ec_capenable. 2018-12-21 08:58:08 +00:00
maxv 5c98710094 Remove the 't' argument from m_tag_find(). 2018-11-15 10:23:55 +00:00
yamaguchi 70db832747 Use ether_lookup_multi() instead of the macro
ok ozaki-r@
2018-06-14 07:54:57 +00:00
ozaki-r 8434fb2752 Check if ether_ifdetach is called without INET_LOCK 2018-06-12 07:12:35 +00:00
maxv 375907a025 Remove an XXX of mine, actually it's fine. While here also remove a
misleading printf.
2018-05-29 16:24:34 +00:00
maxv 4b9322a057 Replace KASSERT by m_pullup. While the ethernet header is always there
when the packet was received on a physical interface, it may not be if
the packet was received over L2TP/EtherIP.

In particular, if the inner ethernet header ends up on two separate IP
fragments. Here the KASSERT is triggered, and on !DIAGNOSTIC we corrupt
memory.

Note that this is a widespread problem: a lot of L2 code was written with
the assumption that "most" headers are present in the first mbuf.
Obviously, that's not true if L2 encapsulation is being used.
2018-05-29 08:24:59 +00:00
maxv 0be2ad1a12 Replace
m_copym(m, 0, M_COPYALL, M_DONTWAIT)
by
	m_copypacket(m, M_DONTWAIT)
when it is clear that we are copying a packet (that has M_PKTHDR) and not
a raw mbuf chain.
2018-05-09 06:35:10 +00:00
maxv 37402c2ad5 Remove references to m_copy in comments. 2018-04-29 07:13:10 +00:00
maxv ecb801f971 m_copy -> m_copym 2018-04-26 19:56:55 +00:00
maxv d2e2e0f086 Replace KASSERTMSG by a real check. L2 encapsulation protocols (at least
L2TP) don't ensure the LLC is there, and in !DIAGNOSTIC configurations
m_copydata will crash. Tested with L2TP.
2018-04-09 16:14:11 +00:00
maxv 00a2f9f8be Add KASSERT. The input point expects struct ether_header to be there.
Now, I'm wondering whether it can be triggered by L2 encapsulation
protocols - they may not provide a contiguous area.
2018-04-09 11:35:22 +00:00
maxv ce5bc9fcd8 Minor stylistic changes, add XXX and fix typo. No functional change. 2018-04-09 11:05:59 +00:00
maxv 995aacb845 Make the arpresolve branch more readable, fix typo, fix XXX (which I
added), add missing pserialize_read_exit (which I forgot).
2018-02-13 15:21:59 +00:00
maxv b46d58304b Remove KERNEL_LOCK around the MPLS code. It's not needed, since we're only
touching the tag of the mbuf - the tag belongs only to the mbuf, and the
mbuf is not shared.

ok knakahara@
2018-02-13 10:50:38 +00:00
maxv 70018dfa34 Fix typo, and add a comment about MPLS. 2018-02-12 12:17:38 +00:00