Add some #define's for mbuf annotations.

As the comment in the code says, eventually there will be a proper
data structure (e.g NetBSD's struct m_tag) to store chains of
annotations, and mbuf-handling procedures will handle these chains
in the correct way.

Right now, these chains do not exist, and we just use the constants
defined here to implement simple ad-hoc solutions to remove some global
variables used so far to pass around informations about packets
being processed.

Global variables are not only ugly and make the code unreadable, they
also prevent from using parallelism in network stack processing.

(the 3-days MFC only refers to this commit, i.e. the PACKET_TAG_*
constants; the full mechanism will be committed and MFC'ed on a
longer timescale).

MFC after: 3 days
This commit is contained in:
Luigi Rizzo 2002-06-20 21:29:55 +00:00
parent d0e8afbf5a
commit 4ad01e18e3

View File

@ -410,6 +410,54 @@ struct mauxtag {
void *p;
};
/*
* Some packet tags to identify different mbuf annotations.
*
* Eventually, these annotations will end up in an appropriate chain
* (struct m_tag or similar, e.g. as in NetBSD) properly managed by
* the mbuf handling routines.
*
* As a temporary and low impact solution to replace the even uglier
* approach used so far in some parts of the network stack (which relies
* on global variables), these annotations are stored in MT_CONTROL
* mbufs (or lookalikes) prepended to the actual mbuf chain.
*
* m_type = MT_CONTROL
* m_flags = m_tag_id
* m_next = next buffer in chain.
*
* BE VERY CAREFUL not to pass these blocks to the mbuf handling routines.
*
*/
#define m_tag_id m_hdr.mh_flags
/* Packet tag types -- first ones are from NetBSD */
#define PACKET_TAG_NONE 0 /* Nadda */
#define PACKET_TAG_IPSEC_IN_DONE 1 /* IPsec applied, in */
#define PACKET_TAG_IPSEC_OUT_DONE 2 /* IPsec applied, out */
#define PACKET_TAG_IPSEC_IN_CRYPTO_DONE 3 /* NIC IPsec crypto done */
#define PACKET_TAG_IPSEC_OUT_CRYPTO_NEEDED 4 /* NIC IPsec crypto req'ed */
#define PACKET_TAG_IPSEC_IN_COULD_DO_CRYPTO 5 /* NIC notifies IPsec */
#define PACKET_TAG_IPSEC_PENDING_TDB 6 /* Reminder to do IPsec */
#define PACKET_TAG_BRIDGE 7 /* Bridge processing done */
#define PACKET_TAG_GIF 8 /* GIF processing done */
#define PACKET_TAG_GRE 9 /* GRE processing done */
#define PACKET_TAG_IN_PACKET_CHECKSUM 10 /* NIC checksumming done */
#define PACKET_TAG_ENCAP 11 /* Encap. processing */
#define PACKET_TAG_IPSEC_SOCKET 12 /* IPSEC socket ref */
#define PACKET_TAG_IPSEC_HISTORY 13 /* IPSEC history */
#define PACKET_TAG_IPV6_INPUT 14 /* IPV6 input processing */
/* Packet tags used in the FreeBSD network stack */
#define PACKET_TAG_DUMMYNET 15 /* dummynet info */
#define PACKET_TAG_IPFW 16 /* ipfw classification */
#define PACKET_TAG_DIVERT 17 /* divert info */
#define PACKET_TAG_IPFORWARD 18 /* ipforward info */
#define PACKET_TAG_MAX 19
extern int max_datalen; /* MHLEN - max_hdr */
extern int max_hdr; /* largest link + protocol header */
extern int max_linkhdr; /* largest link-level header */