git: 1e6131bad6b4 - main - IfAPI: Add needed APIs for mbuf support
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Feb 2023 17:53:53 UTC
The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=1e6131bad6b47efbd35c5e7095637ed2aeaecd70 commit 1e6131bad6b47efbd35c5e7095637ed2aeaecd70 Author: Justin Hibbits <jhibbits@FreeBSD.org> AuthorDate: 2023-02-01 14:56:34 +0000 Commit: Justin Hibbits <jhibbits@FreeBSD.org> CommitDate: 2023-02-06 17:32:04 +0000 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 --- sys/kern/kern_mbuf.c | 12 +++++------- sys/net/if.c | 16 ++++++++++++++++ sys/net/if_var.h | 3 +++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index d47b1fbf3c60..84dea05f1bbb 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -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; diff --git a/sys/net/if.c b/sys/net/if.c index 8bb5ed0043e5..43d1e2b95a63 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -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) { diff --git a/sys/net/if_var.h b/sys/net/if_var.h index b4cdcf27253f..f33b4fc590c7 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -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. */