Commit Graph

323 Commits

Author SHA1 Message Date
roy d66a17fc6d arp: Validate ARP source hardware address matches Ethernet source
RFC 5227 section 1.1 states that for a DaD ARP probe the sender hardware
address must match the hardware address of the interface sending the
packet.

We can now verify this by checking the mbuf tag PACKET_TAG_ETHERNET_SRC.

This fixes an obsure issue where an old router was sending out bogus
ARP probes.

Thanks to Ryo Shimizu <ryo@nerv.org> for the re-implementation.
2022-11-15 10:47:39 +00:00
roy 7f8cc08460 Revert prior. 2022-11-15 09:13:43 +00:00
roy 17a43b3883 net: Store a pointer to the Layer 2 Sender Hardware address in mbuf
The BSD networking stack is designed around passing a mbuf down the chain
and each layer removes the part it's interested in before passing it to
the next. This makes it easy for each layer to do it's work,
but non trivial to work backwards.

As such we now store a pointer to the Senders Hardware address in the
mbuf packet header so that protocols can perform any required validation.
2022-11-14 09:23:42 +00:00
thorpej 6ffff4f242 Garbage-collect the remaining vestiges of netisr. 2022-09-03 02:47:59 +00:00
thorpej dd8687cce0 Convert MPLS from a legacy netisr to pktqueue. 2022-09-03 02:24:59 +00:00
thorpej 6bd159b890 Convert NETATALK from a legacy netisr to pktqueue. 2022-09-03 01:48:22 +00:00
thorpej 63ae4dd2e0 Convert ARP from a legacy netisr to pktqueue. 2022-09-03 01:35:03 +00:00
thorpej 8310d9409c Only use configured RPS hash functions for IPv4 and IPv6 packets.
This is NFC change now because only IPv4 and IPv6 use pktqueue,
but that will change in future commits.
2022-09-03 00:31:02 +00:00
martin 134829f4dd Avoid unused variable 2022-06-20 12:22:00 +00:00
yamaguchi 648b580182 bpf(4): added support for VLAN hardware offloading of ethernet devices 2022-06-20 08:20:09 +00:00
yamaguchi f17fac5794 bridge(4): support VLAN frames stripped by hardware tagging 2022-06-20 08:14:48 +00:00
yamaguchi e5dfb28098 Handling frames that vlan id is 0 as non-VLAN frames
even if a vlan tag is stripped by harware offloading
2022-06-20 08:02:25 +00:00
yamaguchi d1fb119648 Move input processing of lagg(4) before ether_input
to get rid of dependence.

This implementation is similar with that of bridge(4).
2022-04-04 06:10:00 +00:00
riastradh 0802103d64 ethersubr(9): Assert IFNET_LOCKED in ether_ioctl_reinit.
Changes to if_flags are nontrivial configuration changes that require
the long-term ioctl lock.
2021-12-31 14:26:09 +00:00
riastradh b4d088cb3b sys: Use if_init wrapper function.
Exception: Not in kern_pmf.c, for the kind of silly reason that it
avoids having kern_pmf.c refer to symbols defined only in net; this
avoids a pain in the rump.
2021-12-31 14:25:22 +00:00
riastradh 66fd63da02 sys: Use if_stop wrapper function.
Exception: Not in kern_pmf.c, for the kind of silly reason that it
avoids having kern_pmf.c refer to symbols defined only in net; this
avoids a pain in the rump.
2021-12-31 14:24:38 +00:00
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