Commit Graph

3706 Commits

Author SHA1 Message Date
thorpej
7a9a30c5e7 Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
  access to media-related structures / hardware regsiters.  Converted
  drivers use the new ifmedia_init_with_lock() function for this.  The
  new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
  a compatibility lock to be used instead.  Several media-related entry
  points must be aware of this compatibility lock, and are able to acquire
  it recursively a limited number of times, if needed.  This is a SPIN
  mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
  MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex.  The mcx driver still needs to be fully converted to
NET_MPSAFE.
2020-03-15 23:04:50 +00:00
christos
8aaa9ad4fd Use the socket credentials that are established during the socket creation
instead of the current process credentials (which can change via
set{e,}{u,g}id(2)) and by passing the fd to a different process. This makes
the routing socket behave like other file descriptors. Proposed in tech-kern.
2020-03-13 16:37:12 +00:00
knakahara
e8a0215c37 reduce unnecessary reqid of NAT-T ipsecif(4), suggested by ohishi@IIJ. 2020-03-13 02:43:31 +00:00
christos
e3f8cbd510 move debugging code after the NULL check. 2020-03-12 19:36:33 +00:00
knakahara
258ba86eac Fix ipsecif(4) SPDADD pfkey message has garbage. Pointed out by ohishi@IIJ.
"setkey -x" output is the following.

========== before ==========
sadb_msg{ version=2 type=14 errno=0 satype=0
  len=15 reserved=0 seq=0 pid=0
sadb_ext{ len=56 type=18 }
sadb_x_policy{ type=2 dir=1 id=9 }
 { len=40 proto=50 mode=1 level=3 reqid=16393
sockaddr{ len=0 family=0  }
sockaddr{ len=0 family=0  }
 }
========== before ==========

========== after ==========
sadb_msg{ version=2 type=14 errno=0 satype=0
  len=11 reserved=0 seq=0 pid=0
sadb_ext{ len=24 type=18 }
sadb_x_policy{ type=2 dir=1 id=9 }
 { len=8 proto=50 mode=1 level=3 reqid=16393
 }
========== after ==========
2020-03-10 10:35:14 +00:00
roy
5ff17943ef route: RTM_MISS now puts the message source address in RTA_AUTHOR
route(8) also reports this.
A userland app could use this to blacklist nodes who probe for machines
that doesn't exist on a subnet / prefix.
2020-03-09 21:20:55 +00:00
knakahara
e9c0a9dc7d remove unnecessary lock in sppp_mediastatus() as it doesn't touch struct sppp.
ok'ed by yamaguchi@n.o.
2020-03-06 10:26:59 +00:00
riastradh
e5ba6e4e61 Avoid duplicate definition of internal_state struct. 2020-03-05 07:46:49 +00:00
riastradh
434e200c00 Need opt_inet.h for #ifdef INET, INET6. 2020-03-05 07:46:36 +00:00
rin
7edbe5fb42 Remove debug printf I put into bridge_calc_csum_flags().
Sorry for noise.
2020-02-24 00:47:38 +00:00
jdolecek
97e9007d62 disable the DEBUG bridge_calc_csum_flags() printf 2020-02-23 21:50:21 +00:00
maxv
a4bb61b904 pass the address of the field, instead of relying on it being the first
field of the structure, no functional change
2020-02-22 09:30:42 +00:00
joerg
ce578dfc2b Explicitly cast pointers to uintptr_t before casting to enums. They are
not necessarily the same size. Don't cast pointers to bool, check for
NULL instead.
2020-02-21 00:26:21 +00:00
msaitoh
2adc4cf2a7 - Remove 50GBASE-LR10.
- Add the following medias:
 - 25GBASE-ACC
 - 100GBASE-ACC
 - 100GBASE-AOC
 - 100GBASE-FR
 - 100GBASE-LR
 - 200GBASE-ER4
 - 400GBASE-ER8
 - 400GBASE-FR4
 - 400GBASE-LR4
 - 400GBASE-SR4.2
 - 400GBASE-SR8
2020-02-17 15:51:25 +00:00
thorpej
f5c34501a4 Remove the conditional __IF_STATS_PERCPU. 2020-02-14 22:04:12 +00:00
christos
457944128d PR/54950: Lloyd Parkes: Avoid NULL deref. 2020-02-12 01:34:55 +00:00
mlelstv
7c40e3b714 safely extract character sequences from packet for printing. 2020-02-10 22:38:10 +00:00
roy
3730c74003 route(4): dst addr could be in a different mbuf for RO_MISSFILTER
While here, the correct assertation is RTAX_DST == 0.
RTA_DST is just a flag.
2020-02-09 21:15:03 +00:00
roy
6847938ebe route(4): add RO_MISSFILTER socket option
This allows filtering of specific RTM_MISS destination sockaddrs.
2020-02-08 14:17:30 +00:00
thorpej
b578a8edb0 Use percpu_foreach_xcall() to gather volatile per-cpu counters. These
must be serialized against the interrupts / soft-interrupts in which
they're manipulated, as well as protected from non-atomic 64-bit memory
loads on 32-bit platforms.
2020-02-07 12:35:33 +00:00
thorpej
210125a7ef IPL_SOFTNET -> IPL_NET in previous. 2020-02-07 01:14:55 +00:00
thorpej
79aa1d4c98 Perform link state change processing on a work queue, rather than in a
softint.
2020-02-06 23:30:19 +00:00
thorpej
4947e861f2 Use ifmedia_fini(). 2020-02-04 05:44:14 +00:00
roy
5e6231cff4 rtsock: favour ifatoia and ifatoia6 over direct struct casts 2020-02-03 20:34:13 +00:00
thorpej
2e2b06fdb4 Make if_stats competely opaque to user-space. 2020-02-01 21:59:39 +00:00
thorpej
f76c553cad Flip the switch to the per-cpu implementation in <net/if_stats.h>. Leave
the conditional in place for a time in case serious problems are discovered,
so that the Old Way can be re-enabled quickly.  After some time, the Old
Way will be removed completely.
2020-02-01 21:11:10 +00:00
thorpej
a2249e70e6 - Add an ifmedia_fini() routine, to free resources assocated with
an ifmedia.  Currently calls ifmedia_removeall().  All drivers
  that call ifmedia_init() and support detach should call this
  routine.
- In ifmedia_delete_instance(), set ifm->ifm_cur to NULL and
  ifm->ifm_media to IFM_NONE when removing / freeing that entry,
  not simply when we've been asked to delete every media instance.
2020-02-01 20:56:16 +00:00
riastradh
4734f65cda Switch sys/net to percpu_create. 2020-02-01 12:54:50 +00:00
riastradh
a59e7725a3 Switch if_vlan to atomic_load/store_*.
Fix missing membar_datadep_consumer -- now atomic_load_consume -- in
vlan_lookup_tag_psref.
2020-02-01 02:58:15 +00:00
riastradh
24f30c4a12 Switch if_l2tp to atomic_load/store_*.
Fix missing membar_datadep_consumer -- now atomic_load_consume -- in
l2tp_lookup_session_ref.
2020-02-01 02:58:05 +00:00
riastradh
47880c1380 Fix order in rollback case; switch if_ipsec to atomic_load/store_*. 2020-02-01 02:57:55 +00:00
riastradh
ffb7faba0e Switch if_gif to atomic_load/store_*. 2020-02-01 02:57:45 +00:00
riastradh
1e135441b0 Fix wrong memory order and switch pfil to atomic_load/store_*. 2020-02-01 02:54:31 +00:00
riastradh
c776a021f6 Fix wrong memory order and switch bpf to atomic_load/store_*. 2020-02-01 02:54:02 +00:00
thorpej
4385a5d19d - Use kmem(9) instead of malloc(9).
- When handling SIOCGIFMEDIA, don't traverse the media list directly;
  refactor that out into a ifmedia_getwords() function.
2020-01-31 00:49:18 +00:00
thorpej
74f4907c2d Do not reference ifp->if_data directly; use if_export_if_data(). 2020-01-29 04:35:13 +00:00
thorpej
d99f8f369a Adopt <net/if_stats.h>. 2020-01-29 04:28:27 +00:00
thorpej
70b554e641 Adopt <net/if_stats.h>. 2020-01-29 04:11:35 +00:00
thorpej
72416f91e2 Add support for MP-safe network interface statistics by maintaining them
in per-cpu storage, and collecting them for export in an if_data structure
when user-space wants them.

The new if_stat API is structured to make a gradual transition to the
new way in network drivers possible, and per-cpu stats are currently
disabled (thus there is no kernel ABI change).  Once all drivers have
been converted, the old ABI will be removed, and per-cpu stats will be
enabled universally.
2020-01-29 03:16:28 +00:00
thorpej
bff1218097 - Make _NET_STAT_GETREF()'s return value a net_stat_ref_t, which is
defined as a "void *" to prevent using a net_stat_ref_t as an array.
- For each _NET_STATADD(), etc. macro, also define a _NET_STATADD_REF()
  macro that takes a ref returned by _NET_STAT_GETREF() as an argument.
  This is intended to replace direct subscripting of the refernce;
  consumers of this API will be updated in future commits.
2020-01-29 03:04:55 +00:00
thorpej
ce59b20525 In ifmedia_ioctl(), go to splnet() before acquiring the KERNEL_LOCK.
For non-NET_MPSAFE, this is benign, because we can nest raising to
splnet().  For the NET_MPSAFE, it means that drivers don't need to
raise to splnet() just in order to call ifmedia_ioctl().
2020-01-20 19:35:39 +00:00
thorpej
4541d6828b Remove FDDI support. 2020-01-20 18:38:17 +00:00
thorpej
ed469c22d6 Remove Token Ring support. 2020-01-19 20:00:35 +00:00
thorpej
85654ec7a9 Remove HIPPI support and the esh(4) driver that uses it. There have not
been any users of HIPPI for some time, and it is unlikely to be resurrected.
2020-01-19 06:55:21 +00:00
thorpej
2ad9c18235 Stop including strip.h (it's no longer generated). 2020-01-19 05:07:22 +00:00
thorpej
c1d9ec8d89 Remove the strip(4) - Starmode Radio IP - pseudo-device driver. It is
long since obsolete.
2020-01-19 01:25:03 +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
79fb69eea1 Add missing packet filter hooks, byte accounting. 2020-01-06 20:31:35 +00:00
ryo
8c476cf96f Add the ETHERTYPE_QINQ for 802.1ad VLAN stacking 2020-01-01 10:04:37 +00:00
christos
edc0c34588 Protect network ioctls from non-authorized users. (Ilja Van Sprundel) 2019-12-17 04:54:36 +00:00