IfAPI: Add needed APIs for mbuf support

Summary:
Add 2 new APIs for supporting recent mbuf changes:
* 36e0a362ac added the m_snd_tag_alloc() wrapper around
  if_snd_tag_alloc().  Push this down to the ifnet level.
* 4d7a1361ef adds the m_rcvif_serialize()/m_rcvif_restore() KPIs to
  serialize and restore an ifnet pointer.  Add the necessary wrapper to
  get the index generation for this.

Reviewed By:	jhb
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38340
This commit is contained in:
Justin Hibbits 2023-02-01 09:56:34 -05:00
parent c079c82646
commit 1e6131bad6
3 changed files with 24 additions and 7 deletions

View File

@ -1586,9 +1586,7 @@ m_snd_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
struct m_snd_tag **mstp)
{
if (ifp->if_snd_tag_alloc == NULL)
return (EOPNOTSUPP);
return (ifp->if_snd_tag_alloc(ifp, params, mstp));
return (if_snd_tag_alloc(ifp, params, mstp));
}
void
@ -1620,13 +1618,13 @@ m_rcvif_serialize(struct mbuf *m)
u_short idx, gen;
M_ASSERTPKTHDR(m);
idx = m->m_pkthdr.rcvif->if_index;
gen = m->m_pkthdr.rcvif->if_idxgen;
idx = if_getindex(m->m_pkthdr.rcvif);
gen = if_getidxgen(m->m_pkthdr.rcvif);
m->m_pkthdr.rcvidx = idx;
m->m_pkthdr.rcvgen = gen;
if (__predict_false(m->m_pkthdr.leaf_rcvif != NULL)) {
idx = m->m_pkthdr.leaf_rcvif->if_index;
gen = m->m_pkthdr.leaf_rcvif->if_idxgen;
idx = if_getindex(m->m_pkthdr.leaf_rcvif);
gen = if_getidxgen(m->m_pkthdr.leaf_rcvif);
} else {
idx = -1;
gen = 0;

View File

@ -4295,6 +4295,12 @@ if_getindex(const if_t ifp)
return ((struct ifnet *)ifp)->if_index;
}
int
if_getidxgen(const if_t ifp)
{
return (ifp->if_idxgen);
}
void
if_setdescr(if_t ifp, char *descrbuf)
{
@ -4845,6 +4851,16 @@ if_setsndtagallocfn(if_t ifp, if_snd_tag_alloc_t alloc_fn)
((struct ifnet *)ifp)->if_snd_tag_alloc = alloc_fn;
}
int
if_snd_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
struct m_snd_tag **mstp)
{
if (ifp->if_snd_tag_alloc == NULL)
return (EOPNOTSUPP);
return (ifp->if_snd_tag_alloc(ifp, params, mstp));
}
void
if_setgetcounterfn(if_t ifp, if_get_counter_t fn)
{

View File

@ -578,6 +578,7 @@ int if_setcapenablebit(if_t ifp, int setcap, int clearcap);
int if_getcapenable(const if_t ifp);
int if_getdunit(const if_t ifp);
int if_getindex(const if_t ifp);
int if_getidxgen(const if_t ifp);
const char *if_getdname(const if_t ifp);
void if_setdname(if_t ifp, const char *name);
const char *if_name(if_t ifp);
@ -650,6 +651,8 @@ bool if_altq_is_enabled(if_t ifp);
void *if_getafdata(if_t ifp, int);
int if_snd_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
struct m_snd_tag **mstp);
/*
* Traversing through interface address lists.
*/