Remove the home-grown metadata facility in favour of the now generic
mbuf tags facility. Netgraph modules will all need a recompile. Submitted by: Gleb Smirnoff <glebius@cell.sick.ru>
This commit is contained in:
parent
b4994e318a
commit
8ed370fd90
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=131374
9
UPDATING
9
UPDATING
@ -17,6 +17,15 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 5.x IS SLOW:
|
||||
developers choose to disable these features on build machines
|
||||
to maximize performance.
|
||||
|
||||
20040630:
|
||||
The netgraph ABI version number has been incremented to indicate
|
||||
an incompatible change in the ABI. Old netgraph nodes will refuse
|
||||
to attach until recompiled. Netgraph no uses tehmbuf TAGS feature
|
||||
to move metadata and this commit removes its home-grown metadata
|
||||
facility. Nodes should just recompile unless they use metadata
|
||||
in which case the changes are simple and shown in ng_ksocket.c
|
||||
which can be used as an example.
|
||||
|
||||
20040630:
|
||||
ACPI has been updated to disable known-bad BIOS revisions. A message
|
||||
will be printed on console indicating that ACPI has been disabled
|
||||
|
@ -62,7 +62,7 @@
|
||||
* Change it for NETGRAPH_DEBUG version so we cannot mix debug and non debug
|
||||
* modules.
|
||||
*/
|
||||
#define _NG_ABI_VERSION 8
|
||||
#define _NG_ABI_VERSION 9
|
||||
#ifdef NETGRAPH_DEBUG /*----------------------------------------------*/
|
||||
#define NG_ABI_VERSION (_NG_ABI_VERSION + 0x10000)
|
||||
#else /* NETGRAPH_DEBUG */ /*----------------------------------------------*/
|
||||
@ -553,42 +553,6 @@ _ng_node_foreach_hook(node_p node, ng_fn_eachhook *fn, void *arg,
|
||||
_NG_NODE_FOREACH_HOOK(node, fn, arg, rethook)
|
||||
#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/
|
||||
|
||||
/***********************************************************************
|
||||
***************** Meta Data Structures and Methods ********************
|
||||
***********************************************************************
|
||||
*
|
||||
* The structure that holds meta_data about a data packet (e.g. priority)
|
||||
* Nodes might add or subtract options as needed if there is room.
|
||||
* They might reallocate the struct to make more room if they need to.
|
||||
* Meta-data is still experimental.
|
||||
*/
|
||||
struct meta_field_header {
|
||||
u_long cookie; /* cookie for the field. Skip fields you don't
|
||||
* know about (same cookie as in messgaes) */
|
||||
u_short type; /* field ID */
|
||||
u_short len; /* total len of this field including extra
|
||||
* data */
|
||||
char data[0]; /* data starts here */
|
||||
};
|
||||
|
||||
/* To zero out an option 'in place' set it's cookie to this */
|
||||
#define NGM_INVALID_COOKIE 865455152
|
||||
|
||||
/* This part of the metadata is always present if the pointer is non NULL */
|
||||
struct ng_meta {
|
||||
char priority; /* -ve is less priority, 0 is default */
|
||||
char discardability; /* higher is less valuable.. discard first */
|
||||
u_short allocated_len; /* amount malloc'd */
|
||||
u_short used_len; /* sum of all fields, options etc. */
|
||||
u_short flags; /* see below.. generic flags */
|
||||
struct meta_field_header options[0]; /* add as (if) needed */
|
||||
};
|
||||
typedef struct ng_meta *meta_p;
|
||||
|
||||
/* Flags for meta-data */
|
||||
#define NGMF_TEST 0x01 /* discard at the last moment before sending */
|
||||
#define NGMF_TRACE 0x02 /* trace when handing this data to a node */
|
||||
|
||||
/***********************************************************************
|
||||
************* Node Queue and Item Structures and Methods **************
|
||||
***********************************************************************
|
||||
@ -601,10 +565,7 @@ struct ng_item {
|
||||
node_p el_dest; /* The node it will be applied against (or NULL) */
|
||||
hook_p el_hook; /* Entering hook. Optional in Control messages */
|
||||
union {
|
||||
struct {
|
||||
struct mbuf *da_m;
|
||||
meta_p da_meta;
|
||||
} data;
|
||||
struct mbuf *da_m;
|
||||
struct {
|
||||
struct ng_mesg *msg_msg;
|
||||
ng_ID_t msg_retaddr;
|
||||
@ -644,8 +605,7 @@ struct ng_item {
|
||||
* The debug versions must be either all used everywhere or not at all.
|
||||
*/
|
||||
|
||||
#define _NGI_M(i) ((i)->body.data.da_m)
|
||||
#define _NGI_META(i) ((i)->body.data.da_meta)
|
||||
#define _NGI_M(i) ((i)->body.da_m)
|
||||
#define _NGI_MSG(i) ((i)->body.msg.msg_msg)
|
||||
#define _NGI_RETADDR(i) ((i)->body.msg.msg_retaddr)
|
||||
#define _NGI_FN(i) ((i)->body.fn.fn_fn)
|
||||
@ -674,7 +634,6 @@ struct ng_item {
|
||||
void dumpitem(item_p item, char *file, int line);
|
||||
static __inline void _ngi_check(item_p item, char *file, int line) ;
|
||||
static __inline struct mbuf ** _ngi_m(item_p item, char *file, int line) ;
|
||||
static __inline meta_p * _ngi_meta(item_p item, char *file, int line) ;
|
||||
static __inline ng_ID_t * _ngi_retaddr(item_p item, char *file, int line);
|
||||
static __inline struct ng_mesg ** _ngi_msg(item_p item, char *file, int line) ;
|
||||
static __inline ng_item_fn ** _ngi_fn(item_p item, char *file, int line) ;
|
||||
@ -701,13 +660,6 @@ _ngi_m(item_p item, char *file, int line)
|
||||
return (&_NGI_M(item));
|
||||
}
|
||||
|
||||
static __inline meta_p *
|
||||
_ngi_meta(item_p item, char *file, int line)
|
||||
{
|
||||
_ngi_check(item, file, line);
|
||||
return (&_NGI_META(item));
|
||||
}
|
||||
|
||||
static __inline struct ng_mesg **
|
||||
_ngi_msg(item_p item, char *file, int line)
|
||||
{
|
||||
@ -758,7 +710,6 @@ _ngi_hook(item_p item, char *file, int line)
|
||||
}
|
||||
|
||||
#define NGI_M(i) (*_ngi_m(i, _NN_))
|
||||
#define NGI_META(i) (*_ngi_meta(i, _NN_))
|
||||
#define NGI_MSG(i) (*_ngi_msg(i, _NN_))
|
||||
#define NGI_RETADDR(i) (*_ngi_retaddr(i, _NN_))
|
||||
#define NGI_FN(i) (*_ngi_fn(i, _NN_))
|
||||
@ -790,7 +741,6 @@ _ngi_hook(item_p item, char *file, int line)
|
||||
#else /* NETGRAPH_DEBUG */ /*----------------------------------------------*/
|
||||
|
||||
#define NGI_M(i) _NGI_M(i)
|
||||
#define NGI_META(i) _NGI_META(i)
|
||||
#define NGI_MSG(i) _NGI_MSG(i)
|
||||
#define NGI_RETADDR(i) _NGI_RETADDR(i)
|
||||
#define NGI_FN(i) _NGI_FN(i)
|
||||
@ -814,12 +764,6 @@ _ngi_hook(item_p item, char *file, int line)
|
||||
_NGI_M(i) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define NGI_GET_META(i,m) \
|
||||
do { \
|
||||
(m) = NGI_META(i); \
|
||||
_NGI_META(i) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define NGI_GET_MSG(i,m) \
|
||||
do { \
|
||||
(m) = NGI_MSG(i); \
|
||||
@ -857,12 +801,11 @@ _ngi_hook(item_p item, char *file, int line)
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Forward a data packet with no new meta-data.
|
||||
* old metadata is passed along without change.
|
||||
* Mbuf pointer is updated to new value. We presume you dealt with the
|
||||
* old one when you update it to the new one (or it maybe the old one).
|
||||
* We got a packet and possibly had to modify the mbuf.
|
||||
* You should probably use NGI_GET_M() if you are going to use this too
|
||||
* Forward a data packet. Mbuf pointer is updated to new value. We
|
||||
* presume you dealt with the old one when you update it to the new one
|
||||
* (or it maybe the old one). We got a packet and possibly had to modify
|
||||
* the mbuf. You should probably use NGI_GET_M() if you are going to use
|
||||
* this too.
|
||||
*/
|
||||
#define NG_FWD_NEW_DATA(error, item, hook, m) \
|
||||
do { \
|
||||
@ -871,7 +814,10 @@ _ngi_hook(item_p item, char *file, int line)
|
||||
NG_FWD_ITEM_HOOK(error, item, hook); \
|
||||
} while (0)
|
||||
|
||||
/* Send a previously unpackaged mbuf when we have no metadata to send */
|
||||
/* Send a previously unpackaged mbuf. XXX: This should be called
|
||||
* NG_SEND_DATA in future, but this name is kept for compatibility
|
||||
* reasons.
|
||||
*/
|
||||
#define NG_SEND_DATA_ONLY(error, hook, m) \
|
||||
do { \
|
||||
item_p _item; \
|
||||
@ -883,18 +829,7 @@ _ngi_hook(item_p item, char *file, int line)
|
||||
(m) = NULL; \
|
||||
} while (0)
|
||||
|
||||
/* Send previously unpackeged data and metadata. */
|
||||
#define NG_SEND_DATA(error, hook, m, meta) \
|
||||
do { \
|
||||
item_p _item; \
|
||||
if ((_item = ng_package_data((m), (meta)))) { \
|
||||
NG_FWD_ITEM_HOOK(error, _item, hook); \
|
||||
} else { \
|
||||
(error) = ENOMEM; \
|
||||
} \
|
||||
(m) = NULL; \
|
||||
(meta) = NULL; \
|
||||
} while (0)
|
||||
#define NG_SEND_DATA(error, hook, m, x) NG_SEND_DATA_ONLY(error, hook, m)
|
||||
|
||||
#define NG_FREE_MSG(msg) \
|
||||
do { \
|
||||
@ -904,14 +839,6 @@ _ngi_hook(item_p item, char *file, int line)
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define NG_FREE_META(meta) \
|
||||
do { \
|
||||
if ((meta)) { \
|
||||
FREE((meta), M_NETGRAPH_META); \
|
||||
(meta) = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define NG_FREE_M(m) \
|
||||
do { \
|
||||
if ((m)) { \
|
||||
@ -1098,7 +1025,6 @@ MODULE_DEPEND(ng_##typename, netgraph, NG_ABI_VERSION, \
|
||||
/* Only these two types should be visible to nodes */
|
||||
MALLOC_DECLARE(M_NETGRAPH);
|
||||
MALLOC_DECLARE(M_NETGRAPH_MSG);
|
||||
MALLOC_DECLARE(M_NETGRAPH_META);
|
||||
|
||||
/* declare the base of the netgraph sysclt hierarchy */
|
||||
/* but only if this file cares about sysctls */
|
||||
@ -1115,13 +1041,12 @@ int ng_address_ID(node_p here, item_p item, ng_ID_t ID, ng_ID_t retaddr);
|
||||
int ng_address_hook(node_p here, item_p item, hook_p hook, ng_ID_t retaddr);
|
||||
int ng_address_path(node_p here, item_p item, char *address, ng_ID_t raddr);
|
||||
int ng_bypass(hook_p hook1, hook_p hook2);
|
||||
meta_p ng_copy_meta(meta_p meta);
|
||||
hook_p ng_findhook(node_p node, const char *name);
|
||||
int ng_make_node_common(struct ng_type *typep, node_p *nodep);
|
||||
int ng_name_node(node_p node, const char *name);
|
||||
int ng_newtype(struct ng_type *tp);
|
||||
ng_ID_t ng_node2ID(node_p node);
|
||||
item_p ng_package_data(struct mbuf *m, meta_p meta);
|
||||
item_p ng_package_data(struct mbuf *m, void *dummy);
|
||||
item_p ng_package_msg(struct ng_mesg *msg);
|
||||
item_p ng_package_msg_self(node_p here, hook_p hook, struct ng_mesg *msg);
|
||||
void ng_replace_retaddr(node_p here, item_p item, ng_ID_t retaddr);
|
||||
@ -1157,4 +1082,14 @@ struct ng_tag_prio {
|
||||
#define NG_PRIO_CUTOFF 32
|
||||
#define NG_PRIO_LINKSTATE 64
|
||||
|
||||
/* Macros and declarations to keep compatibility with metadata, which
|
||||
* is obsoleted now. To be deleted.
|
||||
*/
|
||||
typedef void *meta_p;
|
||||
#define _NGI_META(i) NULL
|
||||
#define NGI_META(i) NULL
|
||||
#define NG_FREE_META(meta)
|
||||
#define NGI_GET_META(i,m)
|
||||
#define ng_copy_meta(meta) NULL
|
||||
|
||||
#endif /* _NETGRAPH_NETGRAPH_H_ */
|
||||
|
@ -216,7 +216,6 @@ MALLOC_DEFINE(M_NETGRAPH, "netgraph", "netgraph structures and ctrl messages");
|
||||
MALLOC_DEFINE(M_NETGRAPH_HOOK, "netgraph_hook", "netgraph hook structures");
|
||||
MALLOC_DEFINE(M_NETGRAPH_NODE, "netgraph_node", "netgraph node structures");
|
||||
MALLOC_DEFINE(M_NETGRAPH_ITEM, "netgraph_item", "netgraph item structures");
|
||||
MALLOC_DEFINE(M_NETGRAPH_META, "netgraph_meta", "netgraph name storage");
|
||||
MALLOC_DEFINE(M_NETGRAPH_MSG, "netgraph_msg", "netgraph name storage");
|
||||
|
||||
/* Should not be visible outside this file */
|
||||
@ -1151,6 +1150,9 @@ ng_newtype(struct ng_type *tp)
|
||||
|| (namelen == 0)
|
||||
|| (namelen >= NG_TYPESIZ)) {
|
||||
TRAP_ERROR();
|
||||
if (tp->version != NG_ABI_VERSION) {
|
||||
printf("Netgraph: Node type rejected. ABI mismatch. Suggest recompile\n");
|
||||
}
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
@ -2095,7 +2097,6 @@ ng_flush_input_queue(struct ng_queue * ngq)
|
||||
* Reference to destination rcv hook if relevant.
|
||||
* Data:
|
||||
* pointer to mbuf
|
||||
* pointer to metadata
|
||||
* Control_Message:
|
||||
* pointer to msg.
|
||||
* ID of original sender node. (return address)
|
||||
@ -2890,26 +2891,6 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy a 'meta'.
|
||||
*
|
||||
* Returns new meta, or NULL if original meta is NULL or ENOMEM.
|
||||
*/
|
||||
meta_p
|
||||
ng_copy_meta(meta_p meta)
|
||||
{
|
||||
meta_p meta2;
|
||||
|
||||
if (meta == NULL)
|
||||
return (NULL);
|
||||
MALLOC(meta2, meta_p, meta->used_len, M_NETGRAPH_META, M_NOWAIT);
|
||||
if (meta2 == NULL)
|
||||
return (NULL);
|
||||
meta2->allocated_len = meta->used_len;
|
||||
bcopy(meta, meta2, meta->used_len);
|
||||
return (meta2);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Module routines
|
||||
************************************************************************/
|
||||
@ -3122,9 +3103,8 @@ ng_free_item(item_p item)
|
||||
}
|
||||
switch (item->el_flags & NGQF_TYPE) {
|
||||
case NGQF_DATA:
|
||||
/* If we have an mbuf and metadata still attached.. */
|
||||
/* If we have an mbuf still attached.. */
|
||||
NG_FREE_M(_NGI_M(item));
|
||||
NG_FREE_META(_NGI_META(item));
|
||||
break;
|
||||
case NGQF_MESG:
|
||||
_NGI_RETADDR(item) = 0;
|
||||
@ -3400,7 +3380,7 @@ ng_setisr(node_p node)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Put elements into the item.
|
||||
* Put mbuf into the item.
|
||||
* Hook and node references will be removed when the item is dequeued.
|
||||
* (or equivalent)
|
||||
* (XXX) Unsafe because no reference held by peer on remote node.
|
||||
@ -3413,20 +3393,18 @@ ng_setisr(node_p node)
|
||||
* This is possibly in the critical path for new data.
|
||||
*/
|
||||
item_p
|
||||
ng_package_data(struct mbuf *m, meta_p meta)
|
||||
ng_package_data(struct mbuf *m, void *dummy)
|
||||
{
|
||||
item_p item;
|
||||
|
||||
if ((item = ng_getqblk()) == NULL) {
|
||||
NG_FREE_M(m);
|
||||
NG_FREE_META(meta);
|
||||
return (NULL);
|
||||
}
|
||||
ITEM_DEBUG_CHECKS;
|
||||
item->el_flags = NGQF_DATA;
|
||||
item->el_next = NULL;
|
||||
NGI_M(item) = m;
|
||||
NGI_META(item) = meta;
|
||||
return (item);
|
||||
}
|
||||
|
||||
@ -3708,16 +3686,14 @@ ng_macro_test(item_p item)
|
||||
node_p node = NULL;
|
||||
hook_p hook = NULL;
|
||||
struct mbuf *m;
|
||||
meta_p meta;
|
||||
struct ng_mesg *msg;
|
||||
ng_ID_t retaddr;
|
||||
int error;
|
||||
|
||||
NGI_GET_M(item, m);
|
||||
NGI_GET_META(item, meta);
|
||||
NGI_GET_MSG(item, msg);
|
||||
retaddr = NGI_RETADDR(item);
|
||||
NG_SEND_DATA(error, hook, m, meta);
|
||||
NG_SEND_DATA(error, hook, m, NULL);
|
||||
NG_SEND_DATA_ONLY(error, hook, m);
|
||||
NG_FWD_NEW_DATA(error, item, hook, m);
|
||||
NG_FWD_ITEM_HOOK(error, item, hook);
|
||||
|
Loading…
Reference in New Issue
Block a user