FreeBSD Bugzilla – Attachment 148767 Details for
Bug 194663
net/aoe and VIMAGE enabled kernel
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for aoenet.c, makes it VIMAGE aware
patch-aoenet.c (text/plain), 7.71 KB, created by
Andreas Neiser
on 2014-10-29 15:29:50 UTC
(
hide
)
Description:
Patch for aoenet.c, makes it VIMAGE aware
Filename:
MIME Type:
Creator:
Andreas Neiser
Created:
2014-10-29 15:29:50 UTC
Size:
7.71 KB
patch
obsolete
>--- aoenet.c.orig 2006-05-25 16:10:11 UTC >+++ aoenet.c >@@ -52,6 +52,13 @@ > > #include <dev/aoe/aoe.h> > >+#ifdef VIMAGE >+#include <sys/jail.h> >+#define _aoenet_ifnet V_ifnet >+#else >+#define _aoenet_ifnet ifnet >+#endif >+ > /* > * FORCE_NETWORK_HOOK is defined to support kernels that have not been patched > * to recognize AoE packets. >@@ -77,8 +84,11 @@ > #define NECODES (sizeof(aoe_errlist) / sizeof(char *) - 1) > #if (__FreeBSD_version < 600000) > #define IFPADDR(ifp) (((struct arpcom *) (ifp))->ac_enaddr) >-#else >+#elif (__FreeBSD_version < 700000) > #define IFPADDR(ifp) IFP2ENADDR(ifp) >+#else >+#include <net/if_dl.h> >+#define IFPADDR(ifp) IF_LLADDR(ifp) > #endif > #define IFLISTSZ 1024 > >@@ -160,7 +170,11 @@ > register char *p, *q; > register int len; > >+#if __FreeBSD_version >= 1100030 >+ switch (ifp->if_type) { >+#else > switch (ifp->if_data.ifi_type) { >+#endif > default: > return (FALSE); > case IFT_ETHER: >@@ -190,10 +204,24 @@ > /* > * a dummy "free" function for mbuf ext buffer > */ >+#if __FreeBSD_version >= 1000050 >+#if __FreeBSD_version >= 1100028 >+static void >+#else >+static int >+#endif >+nilfn(struct mbuf *m, void *a, void *b) >+{ >+#if __FreeBSD_version < 1100028 >+ return EXT_FREE_OK; >+#endif >+} >+#else > static void > nilfn(void *a, void *b) > { > } >+#endif > > /* Create a mbuf chain and point to our data section(s). */ > static struct mbuf * >@@ -201,7 +229,7 @@ > { > struct mbuf *m; > >- if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL) >+ if ((m = m_gethdr(M_NOWAIT, MT_DATA)) == NULL) > return (NULL); > m->m_len = AOEHDRSZ; > m->m_pkthdr.len = f->f_mlen; >@@ -215,14 +243,21 @@ > u_int len; > > len = f->f_mlen - AOEHDRSZ; >- if ((m1 = m_get(M_DONTWAIT, MT_DATA)) == NULL) { >+ if ((m1 = m_get(M_NOWAIT, MT_DATA)) == NULL) { > m_freem(m); > return (NULL); > } > m->m_next = m1; > >+#if __FreeBSD_version >= 1100028 >+ m1->m_ext.ext_cnt = NULL; >+#else > m1->m_ext.ref_cnt = NULL; >+#endif > MEXTADD(m1, f->f_data, len, nilfn, >+#if (__FreeBSD_version >= 800000) >+ f->f_data, >+#endif > NULL, 0, EXT_NET_DRV); > m1->m_len = len; > m1->m_next = NULL; >@@ -235,12 +270,20 @@ > aoenet_xmitframe(struct aoedev *d, struct frame *f) > { > struct mbuf *m; >- >+ > m = frame_mbufinit(f); > if (m == NULL) > return (ENOMEM); > >- return (ether_output_frame(d->ad_ifp, m)); >+#ifdef VIMAGE >+ CURVNET_SET_QUIET(d->ad_ifp->if_vnet); >+#endif >+ int ret = ether_output_frame(d->ad_ifp, m); >+#ifdef VIMAGE >+ CURVNET_RESTORE(); >+#endif >+ >+ return ret; > } > > void >@@ -250,6 +293,7 @@ > struct aoe_cfghdr *ch; > struct mbuf *m, *m0; > struct ifnet *ifp; >+ > > m0 = m_gethdr(M_NOWAIT, MT_DATA); > if (m0 == NULL) { >@@ -264,6 +308,7 @@ > bzero(h, sizeof(*h) + sizeof(*ch)); > m0->m_flags |= M_BCAST; > >+ > memset(h->ah_dst, 0xff, sizeof(h->ah_dst)); > h->ah_type = htons(ETHERTYPE_AOE); > h->ah_verfl = AOE_HVER; >@@ -271,20 +316,29 @@ > h->ah_minor = aoeminor; > h->ah_cmd = AOECMD_CFG; > >+#ifdef VIMAGE >+ CURVNET_SET_QUIET(CRED_TO_VNET(curthread->td_ucred)); >+#endif >+ > IFNET_RLOCK(); >- TAILQ_FOREACH(ifp, &ifnet, if_link) { >+ TAILQ_FOREACH(ifp, &_aoenet_ifnet, if_link) { > if (!is_aoe_netif(ifp)) > continue; > memcpy(h->ah_src, IFPADDR(ifp), sizeof(h->ah_src)); >- m = m_copypacket(m0, M_DONTWAIT); >+ m = m_copypacket(m0, M_NOWAIT); > if (m == NULL) { > IPRINTK("m_copypacket failure\n"); > continue; > } > ether_output_frame(ifp, m); >+ > } > IFNET_RUNLOCK(); > >+#ifdef VIMAGE >+ CURVNET_RESTORE(); >+#endif >+ > m_freem(m0); > } > >@@ -298,7 +352,11 @@ > aoenet_maxsize(struct ifnet *ifp) > { > /* max payload size of packet based on interface mtu setting */ >+#if __FreeBSD_version >= 1100030 >+ return ((ifp->if_mtu - AOEHDRSZ) & ~(DEV_BSIZE - 1)); >+#else > return ((ifp->if_data.ifi_mtu - AOEHDRSZ) & ~(DEV_BSIZE - 1)); >+#endif > } > > >@@ -362,7 +420,11 @@ > */ > if ((m->m_flags & M_PKTHDR) == 0) { > if_printf(ifp, "discard frame w/o packet header\n"); >+#if __FreeBSD_version >= 1100036 >+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); >+#else > ifp->if_ierrors++; >+#endif > m_freem(m); > return; > } >@@ -371,7 +433,11 @@ > if_printf(ifp, "discard frame w/o leading ethernet " > "header (len %u pkt len %u)\n", > m->m_len, m->m_pkthdr.len); >+#if __FreeBSD_version >= 1100036 >+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); >+#else > ifp->if_ierrors++; >+#endif > m_freem(m); > return; > } >@@ -384,17 +450,25 @@ > if (m->m_pkthdr.len > > ETHER_MAX_FRAME(ifp, etype, m->m_flags & M_HASFCS)) { > if_printf(ifp, "discard oversize frame " >- "(ether type %x flags %x len %u > max %lu)\n", >+ "(ether type %x flags %x len %u > max %u)\n", > etype, m->m_flags, m->m_pkthdr.len, >- ETHER_MAX_FRAME(ifp, etype, >+ (int) ETHER_MAX_FRAME(ifp, etype, > m->m_flags & M_HASFCS)); >+#if __FreeBSD_version >= 1100036 >+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); >+#else > ifp->if_ierrors++; >+#endif > m_freem(m); > return; > } > if (m->m_pkthdr.rcvif == NULL) { > if_printf(ifp, "discard frame w/o interface pointer\n"); >+#if __FreeBSD_version >= 1100036 >+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); >+#else > ifp->if_ierrors++; >+#endif > m_freem(m); > return; > } >@@ -417,7 +491,11 @@ > m->m_flags &= ~M_HASFCS; > } > >+#if __FreeBSD_version >= 1100036 >+ if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); >+#else > ifp->if_ibytes += m->m_pkthdr.len; >+#endif > > if (ETHER_IS_MULTICAST(eh->ether_dhost)) { > if (bcmp(etherbroadcastaddr, eh->ether_dhost, >@@ -427,7 +505,11 @@ > m->m_flags |= M_MCAST; > } > if (m->m_flags & (M_BCAST|M_MCAST)) >+#if __FreeBSD_version >= 1100036 >+ if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); >+#else > ifp->if_imcasts++; >+#endif > > aoeintr(m); > /* netisr_dispatch(NETISR_AOE, m); */ >@@ -440,13 +522,13 @@ > int error; > #ifdef FORCE_NETWORK_HOOK > struct ifnet *ifp; >-#endif >+#endif > > error = sysctl_handle_string(oidp, arg1, arg2, req); > > #ifdef FORCE_NETWORK_HOOK > IFNET_RLOCK(); >- TAILQ_FOREACH(ifp, &ifnet, if_link) { >+ TAILQ_FOREACH(ifp, &_aoenet_ifnet, if_link) { > if (!is_aoe_netif(ifp)) { > if (ifp->if_input == aoe_ether_input) > ifp->if_input = old_ether_input; >@@ -471,8 +553,12 @@ > struct ifnet *ifp; > > IFNET_RLOCK(); >- TAILQ_FOREACH(ifp, &ifnet, if_link) { >+ TAILQ_FOREACH(ifp, &_aoenet_ifnet, if_link) { >+#if __FreeBSD_version >= 1100030 >+ switch (ifp->if_type) { >+#else > switch (ifp->if_data.ifi_type) { >+#endif > case IFT_ETHER: > case IFT_FASTETHER: > case IFT_GIGABITETHERNET: >@@ -480,10 +566,11 @@ > default: > continue; > } >- if (old_ether_input == NULL) >+ if (old_ether_input == NULL) { > old_ether_input = ifp->if_input; >+ } > else if (old_ether_input != ifp->if_input) >- IPRINTK("ifp->if_input != ether_input\n"); >+ IPRINTK("ifp->if_input != ether_input, %s ignored\n", ifp->if_xname); > } > IFNET_RUNLOCK(); > #else >@@ -500,8 +587,12 @@ > struct ifnet *ifp; > > IFNET_RLOCK(); >- TAILQ_FOREACH(ifp, &ifnet, if_link) { >+ TAILQ_FOREACH(ifp, &_aoenet_ifnet, if_link) { >+#if __FreeBSD_version >= 1100030 >+ switch (ifp->if_type) { >+#else > switch (ifp->if_data.ifi_type) { >+#endif > case IFT_ETHER: > case IFT_FASTETHER: > case IFT_GIGABITETHERNET:
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 194663
:
148740
|
148765
|
148766
|
148767
|
149076
|
149077
|
149078
|
149079
|
149080