freebsd-dev/sys/net
Robert Watson 225bff6f8b Move MAC label storage for mbufs into m_tags from the m_pkthdr structure,
returning some additional room in the first mbuf in a chain, and
avoiding feature-specific contents in the mbuf header.  To do this:

- Modify mbuf_to_label() to extract the tag, returning NULL if not
  found.

- Introduce mac_init_mbuf_tag() which does most of the work
  mac_init_mbuf() used to do, except on an m_tag rather than an
  mbuf.

- Scale back mac_init_mbuf() to perform m_tag allocation and invoke
  mac_init_mbuf_tag().

- Replace mac_destroy_mbuf() with mac_destroy_mbuf_tag(), since
  m_tag's are now GC'd deep in the m_tag/mbuf code rather than
  at a higher level when mbufs are directly free()'d.

- Add mac_copy_mbuf_tag() to support m_copy_pkthdr() and related
  notions.

- Generally change all references to mbuf labels so that they use
  mbuf_to_label() rather than &mbuf->m_pkthdr.label.  This
  required no changes in the MAC policies (yay!).

- Tweak mbuf release routines to not call mac_destroy_mbuf(),
  tag destruction takes care of it for us now.

- Remove MAC magic from m_copy_pkthdr() and m_move_pkthdr() --
  the existing m_tag support does all this for us.  Note that
  we can no longer just zero the m_tag list on the target mbuf,
  rather, we have to delete the chain because m_tag's will
  already be hung off freshly allocated mbuf's.

- Tweak m_tag copying routines so that if we're copying a MAC
  m_tag, we don't do a binary copy, rather, we initialize the
  new storage and do a deep copy of the label.

- Remove use of MAC_FLAG_INITIALIZED in a few bizarre places
  having to do with mbuf header copies previously.

- When an mbuf is copied in ip_input(), we no longer need to
  explicitly copy the label because it will get handled by the
  m_tag code now.

- No longer any weird handling of MAC labels in if_loop.c during
  header copies.

- Add MPC_LOADTIME_FLAG_LABELMBUFS flag to Biba, MLS, mac_test.
  In mac_test, handle the label==NULL case, since it can be
  dynamically loaded.

In order to improve performance with this change, introduce the notion
of "lazy MAC label allocation" -- only allocate m_tag storage for MAC
labels if we're running with a policy that uses MAC labels on mbufs.
Policies declare this intent by setting the MPC_LOADTIME_FLAG_LABELMBUFS
flag in their load-time flags field during declaration.  Note: this
opens up the possibility of post-boot policy modules getting back NULL
slot entries even though they have policy invariants of non-NULL slot
entries, as the policy might have been loaded after the mbuf was
allocated, leaving the mbuf without label storage.  Policies that cannot
handle this case must be declared as NOTLATE, or must be modified.

- mac_labelmbufs holds the current cumulative status as to whether
  any policies require mbuf labeling or not.  This is updated whenever
  the active policy set changes by the function mac_policy_updateflags().
  The function iterates the list and checks whether any have the
  flag set.  Write access to this variable is protected by the policy
  list; read access is currently not protected for performance reasons.
  This might change if it causes problems.

- Add MAC_POLICY_LIST_ASSERT_EXCLUSIVE() to permit the flags update
  function to assert appropriate locks.

- This makes allocation in mac_init_mbuf() conditional on the flag.

Reviewed by:	sam
Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
2003-04-14 20:39:06 +00:00
..
bpf_compat.h Back out M_* changes, per decision of the TRB. 2003-02-19 05:47:46 +00:00
bpf_filter.c
bpf.c Assignment could be NULL, check. 2003-03-21 15:13:29 +00:00
bpf.h
bpfdesc.h
bridge.c Back out M_* changes, per decision of the TRB. 2003-02-19 05:47:46 +00:00
bridge.h
bsd_comp.c Back out M_* changes, per decision of the TRB. 2003-02-19 05:47:46 +00:00
ethernet.h
fddi.h
if_arc.h
if_arcsubr.c Update netisr handling; Each SWI now registers its queue, and all queue 2003-03-04 23:19:55 +00:00
if_arp.h - Use if_broadcastaddr from struct ifnet rather than relying on 2003-03-21 17:53:16 +00:00
if_atm.h This corrects a longstanding endian bug in processing LLC/SNAP encoded 2003-03-13 12:44:06 +00:00
if_atmsubr.c This corrects a longstanding endian bug in processing LLC/SNAP encoded 2003-03-13 12:44:06 +00:00
if_disc.c Introduce an M_ASSERTPKTHDR() macro which performs the very common task 2003-04-08 14:25:47 +00:00
if_dl.h
if_ef.c Update netisr handling; Each SWI now registers its queue, and all queue 2003-03-04 23:19:55 +00:00
if_ethersubr.c - Use if_broadcastaddr from struct ifnet rather than relying on 2003-03-21 17:53:16 +00:00
if_faith.c Introduce an M_ASSERTPKTHDR() macro which performs the very common task 2003-04-08 14:25:47 +00:00
if_fddisubr.c - Use IFP2AC(). 2003-03-16 00:17:44 +00:00
if_gif.c Update netisr handling; Each SWI now registers its queue, and all queue 2003-03-04 23:19:55 +00:00
if_gif.h
if_gre.c Finish driving a stake through the heart of netns and the associated 2003-03-05 19:24:24 +00:00
if_gre.h
if_ieee80211.h
if_ieee80211subr.c Revert last commit. File tracks NetBSD. 2003-03-03 06:09:18 +00:00
if_iso88025subr.c - Use IFP2AC(). 2003-03-16 00:17:44 +00:00
if_llc.h
if_loop.c Move MAC label storage for mbufs into m_tags from the m_pkthdr structure, 2003-04-14 20:39:06 +00:00
if_media.c
if_media.h
if_mib.c
if_mib.h
if_ppp.c o netisr_queue() returns 1 on success and 0 on failure, 2003-03-27 12:52:57 +00:00
if_ppp.h
if_pppvar.h
if_sl.c Update netisr handling; Each SWI now registers its queue, and all queue 2003-03-04 23:19:55 +00:00
if_slvar.h
if_sppp.h
if_spppsubr.c Finish driving a stake through the heart of netns and the associated 2003-03-05 19:24:24 +00:00
if_stf.c Update netisr handling; Each SWI now registers its queue, and all queue 2003-03-04 23:19:55 +00:00
if_stf.h
if_tap.c Gigacommit to improve device-driver source compatibility between 2003-03-03 12:15:54 +00:00
if_tap.h
if_tapvar.h
if_tun.c Revert last change and insure the driver can support other address families. 2003-03-08 17:32:21 +00:00
if_tun.h
if_tunvar.h
if_types.h
if_var.h
if_vlan_var.h Pass the correct malloc flags to m_tag_alloc(). 2003-03-13 00:30:31 +00:00
if_vlan.c correct two more flag misuses; m_tag* use malloc flags 2003-03-12 14:45:22 +00:00
if.c Use td->td_ucred instead of td->td_proc->p_ucred. 2003-03-20 21:17:40 +00:00
if.h
iso88025.h Fix whitespace issues. 2003-03-15 23:55:33 +00:00
net_osdep.c
net_osdep.h
netisr.c Discard the packet if the netisr queue is null instead of panicing, for 2003-03-08 22:12:32 +00:00
netisr.h Finish driving a stake through the heart of netns and the associated 2003-03-05 19:24:24 +00:00
pfil.c Back out M_* changes, per decision of the TRB. 2003-02-19 05:47:46 +00:00
pfil.h
pfkeyv2.h
ppp_comp.h
ppp_deflate.c Back out M_* changes, per decision of the TRB. 2003-02-19 05:47:46 +00:00
ppp_defs.h
ppp_tty.c Back out M_* changes, per decision of the TRB. 2003-02-19 05:47:46 +00:00
radix.c
radix.h
raw_cb.c Back out M_* changes, per decision of the TRB. 2003-02-19 05:47:46 +00:00
raw_cb.h
raw_usrreq.c
route.c No need to unlock if error detected before locking. 2003-04-13 06:21:02 +00:00
route.h Finish driving a stake through the heart of netns and the associated 2003-03-05 19:24:24 +00:00
rtsock.c Finish driving a stake through the heart of netns and the associated 2003-03-05 19:24:24 +00:00
slcompress.c Don't use ovbcopy(); use void * instead of char *. 2003-04-04 12:11:46 +00:00
slcompress.h
slip.h
zlib.c
zlib.h