Lines 1-60
Link Here
|
1 |
--- aoenet.c.orig 2006-05-25 16:10:11.000000000 +0000 |
1 |
--- aoenet.c.orig 2006-05-25 16:10:11 UTC |
2 |
+++ aoenet.c 2017-10-17 20:01:42.698938000 +0000 |
2 |
+++ aoenet.c |
3 |
@@ -77,8 +77,11 @@ |
3 |
@@ -75,13 +75,12 @@ static char *aoe_errlist[] = |
|
|
4 |
}; |
5 |
|
4 |
#define NECODES (sizeof(aoe_errlist) / sizeof(char *) - 1) |
6 |
#define NECODES (sizeof(aoe_errlist) / sizeof(char *) - 1) |
5 |
#if (__FreeBSD_version < 600000) |
7 |
-#if (__FreeBSD_version < 600000) |
6 |
#define IFPADDR(ifp) (((struct arpcom *) (ifp))->ac_enaddr) |
8 |
-#define IFPADDR(ifp) (((struct arpcom *) (ifp))->ac_enaddr) |
7 |
-#else |
9 |
-#else |
8 |
+#elif (__FreeBSD_version < 700000) |
10 |
-#define IFPADDR(ifp) IFP2ENADDR(ifp) |
9 |
#define IFPADDR(ifp) IFP2ENADDR(ifp) |
11 |
-#endif |
10 |
+#else |
|
|
11 |
+#include <net/if_dl.h> |
12 |
+#include <net/if_dl.h> |
12 |
+#define IFPADDR(ifp) IF_LLADDR(ifp) |
13 |
+#define IFPADDR(ifp) IF_LLADDR(ifp) |
13 |
#endif |
|
|
14 |
#define IFLISTSZ 1024 |
14 |
#define IFLISTSZ 1024 |
15 |
|
15 |
|
16 |
@@ -160,7 +163,11 @@ |
16 |
+#define IFNET_FOREACH(v) CK_STAILQ_FOREACH(v, &V_ifnet, if_link) |
|
|
17 |
+ |
18 |
static char aoe_iflist[IFLISTSZ]; |
19 |
|
20 |
static int sysctl_aoe_iflist(SYSCTL_HANDLER_ARGS); |
21 |
@@ -91,50 +90,7 @@ SYSCTL_OID(_net_aoe, OID_AUTO, iflist, CTLTYPE_STRING| |
22 |
aoe_iflist, IFLISTSZ - 1, sysctl_aoe_iflist, "A", |
23 |
"Space separated list of interfaces valid for AoE"); |
24 |
|
25 |
-#if (__FreeBSD_version < 600000) |
26 |
-/* FreeBSD 5.X doesn't include strspn()... */ |
27 |
-#include <sys/limits.h> |
28 |
-#define IDX(c) ((u_char)(c) / LONG_BIT) |
29 |
-#define BIT(c) ((u_long)1 << ((u_char)(c) % LONG_BIT)) |
30 |
- |
31 |
-static size_t |
32 |
-strspn(const char *s, const char *charset) |
33 |
-{ |
34 |
- /* |
35 |
- * NB: idx and bit are temporaries whose use causes gcc 3.4.2 to |
36 |
- * generate better code. Without them, gcc gets a little confused. |
37 |
- */ |
38 |
- const char *s1; |
39 |
- u_long bit; |
40 |
- u_long tbl[(UCHAR_MAX + 1) / LONG_BIT]; |
41 |
- int idx; |
42 |
- |
43 |
- if(*s == '\0') |
44 |
- return (0); |
45 |
- |
46 |
-#if LONG_BIT == 64 /* always better to unroll on 64-bit architectures */ |
47 |
- tbl[3] = tbl[2] = tbl[1] = tbl[0] = 0; |
48 |
-#else |
49 |
- for (idx = 0; idx < sizeof(tbl) / sizeof(tbl[0]); idx++) |
50 |
- tbl[idx] = 0; |
51 |
-#endif |
52 |
- for (; *charset != '\0'; charset++) { |
53 |
- idx = IDX(*charset); |
54 |
- bit = BIT(*charset); |
55 |
- tbl[idx] |= bit; |
56 |
- } |
57 |
|
58 |
- for(s1 = s; ; s1++) { |
59 |
- idx = IDX(*s1); |
60 |
- bit = BIT(*s1); |
61 |
- if ((tbl[idx] & bit) == 0) |
62 |
- break; |
63 |
- } |
64 |
- return (s1 - s); |
65 |
-} |
66 |
-#endif /* __FreeBSD_version < 600000 */ |
67 |
- |
68 |
- |
69 |
/* aoe_strcspn -- span the complement of a string */ |
70 |
static size_t |
71 |
aoe_strcspn(const char *s, const char *reject) |
72 |
@@ -160,7 +116,7 @@ is_aoe_netif(struct ifnet *ifp) |
17 |
register char *p, *q; |
73 |
register char *p, *q; |
18 |
register int len; |
74 |
register int len; |
19 |
|
75 |
|
20 |
+#if __FreeBSD_version >= 1100030 |
76 |
- switch (ifp->if_data.ifi_type) { |
21 |
+ switch (ifp->if_type) { |
77 |
+ switch (ifp->if_type) { |
22 |
+#else |
|
|
23 |
switch (ifp->if_data.ifi_type) { |
24 |
+#endif |
25 |
default: |
78 |
default: |
26 |
return (FALSE); |
79 |
return (FALSE); |
27 |
case IFT_ETHER: |
80 |
case IFT_ETHER: |
28 |
@@ -190,10 +197,28 @@ |
81 |
@@ -191,7 +147,7 @@ is_aoe_netif(struct ifnet *ifp) |
29 |
/* |
|
|
30 |
* a dummy "free" function for mbuf ext buffer |
82 |
* a dummy "free" function for mbuf ext buffer |
31 |
*/ |
83 |
*/ |
32 |
+#if __FreeBSD_version >= 1200051 |
|
|
33 |
+static void |
34 |
+nilfn(struct mbuf *m) |
35 |
+{ |
36 |
+} |
37 |
+#elif __FreeBSD_version >= 1100028 |
38 |
+static void |
39 |
+nilfn(struct mbuf *m, void *a, void *b) |
40 |
+{ |
41 |
+} |
42 |
+#elif __FreeBSD_version >= 1000050 |
43 |
+static int |
44 |
+nilfn(struct mbuf *m, void *a, void *b) |
45 |
+{ |
46 |
+ return EXT_FREE_OK; |
47 |
+} |
48 |
+#else |
49 |
static void |
84 |
static void |
50 |
nilfn(void *a, void *b) |
85 |
-nilfn(void *a, void *b) |
|
|
86 |
+nilfn(struct mbuf *m) |
51 |
{ |
87 |
{ |
52 |
} |
88 |
} |
53 |
+#endif |
|
|
54 |
|
89 |
|
55 |
/* Create a mbuf chain and point to our data section(s). */ |
90 |
@@ -201,7 +157,7 @@ frame_mbufinit(struct frame *f) |
56 |
static struct mbuf * |
|
|
57 |
@@ -201,7 +226,7 @@ |
58 |
{ |
91 |
{ |
59 |
struct mbuf *m; |
92 |
struct mbuf *m; |
60 |
|
93 |
|
Lines 63-69
Link Here
|
63 |
return (NULL); |
96 |
return (NULL); |
64 |
m->m_len = AOEHDRSZ; |
97 |
m->m_len = AOEHDRSZ; |
65 |
m->m_pkthdr.len = f->f_mlen; |
98 |
m->m_pkthdr.len = f->f_mlen; |
66 |
@@ -215,14 +240,21 @@ |
99 |
@@ -215,14 +171,15 @@ frame_mbufinit(struct frame *f) |
67 |
u_int len; |
100 |
u_int len; |
68 |
|
101 |
|
69 |
len = f->f_mlen - AOEHDRSZ; |
102 |
len = f->f_mlen - AOEHDRSZ; |
Lines 74-92
Link Here
|
74 |
} |
107 |
} |
75 |
m->m_next = m1; |
108 |
m->m_next = m1; |
76 |
|
109 |
|
77 |
+#if __FreeBSD_version >= 1100028 |
110 |
- m1->m_ext.ref_cnt = NULL; |
78 |
+ m1->m_ext.ext_cnt = NULL; |
111 |
+ m1->m_ext.ext_cnt = NULL; |
79 |
+#else |
|
|
80 |
m1->m_ext.ref_cnt = NULL; |
81 |
+#endif |
82 |
MEXTADD(m1, f->f_data, len, nilfn, |
112 |
MEXTADD(m1, f->f_data, len, nilfn, |
83 |
+#if (__FreeBSD_version >= 800000) |
|
|
84 |
+ f->f_data, |
113 |
+ f->f_data, |
85 |
+#endif |
|
|
86 |
NULL, 0, EXT_NET_DRV); |
114 |
NULL, 0, EXT_NET_DRV); |
87 |
m1->m_len = len; |
115 |
m1->m_len = len; |
88 |
m1->m_next = NULL; |
116 |
m1->m_next = NULL; |
89 |
@@ -276,7 +308,7 @@ |
117 |
@@ -272,11 +229,11 @@ aoenet_xmitbcast(u_short aoemajor, u_char aoeminor) |
|
|
118 |
h->ah_cmd = AOECMD_CFG; |
119 |
|
120 |
IFNET_RLOCK(); |
121 |
- TAILQ_FOREACH(ifp, &ifnet, if_link) { |
122 |
+ IFNET_FOREACH(ifp) { |
90 |
if (!is_aoe_netif(ifp)) |
123 |
if (!is_aoe_netif(ifp)) |
91 |
continue; |
124 |
continue; |
92 |
memcpy(h->ah_src, IFPADDR(ifp), sizeof(h->ah_src)); |
125 |
memcpy(h->ah_src, IFPADDR(ifp), sizeof(h->ah_src)); |
Lines 95-137
Link Here
|
95 |
if (m == NULL) { |
128 |
if (m == NULL) { |
96 |
IPRINTK("m_copypacket failure\n"); |
129 |
IPRINTK("m_copypacket failure\n"); |
97 |
continue; |
130 |
continue; |
98 |
@@ -298,7 +330,11 @@ |
131 |
@@ -298,7 +255,7 @@ u_int |
99 |
aoenet_maxsize(struct ifnet *ifp) |
132 |
aoenet_maxsize(struct ifnet *ifp) |
100 |
{ |
133 |
{ |
101 |
/* max payload size of packet based on interface mtu setting */ |
134 |
/* max payload size of packet based on interface mtu setting */ |
102 |
+#if __FreeBSD_version >= 1100030 |
135 |
- return ((ifp->if_data.ifi_mtu - AOEHDRSZ) & ~(DEV_BSIZE - 1)); |
103 |
+ return ((ifp->if_mtu - AOEHDRSZ) & ~(DEV_BSIZE - 1)); |
136 |
+ return ((ifp->if_mtu - AOEHDRSZ) & ~(DEV_BSIZE - 1)); |
104 |
+#else |
|
|
105 |
return ((ifp->if_data.ifi_mtu - AOEHDRSZ) & ~(DEV_BSIZE - 1)); |
106 |
+#endif |
107 |
} |
137 |
} |
108 |
|
138 |
|
109 |
|
139 |
|
110 |
@@ -362,7 +398,11 @@ |
140 |
@@ -362,7 +319,7 @@ aoe_ether_input(struct ifnet *ifp, struct mbuf *m) |
111 |
*/ |
141 |
*/ |
112 |
if ((m->m_flags & M_PKTHDR) == 0) { |
142 |
if ((m->m_flags & M_PKTHDR) == 0) { |
113 |
if_printf(ifp, "discard frame w/o packet header\n"); |
143 |
if_printf(ifp, "discard frame w/o packet header\n"); |
114 |
+#if __FreeBSD_version >= 1100036 |
144 |
- ifp->if_ierrors++; |
115 |
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
145 |
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
116 |
+#else |
|
|
117 |
ifp->if_ierrors++; |
118 |
+#endif |
119 |
m_freem(m); |
146 |
m_freem(m); |
120 |
return; |
147 |
return; |
121 |
} |
148 |
} |
122 |
@@ -371,7 +411,11 @@ |
149 |
@@ -371,7 +328,7 @@ aoe_ether_input(struct ifnet *ifp, struct mbuf *m) |
123 |
if_printf(ifp, "discard frame w/o leading ethernet " |
150 |
if_printf(ifp, "discard frame w/o leading ethernet " |
124 |
"header (len %u pkt len %u)\n", |
151 |
"header (len %u pkt len %u)\n", |
125 |
m->m_len, m->m_pkthdr.len); |
152 |
m->m_len, m->m_pkthdr.len); |
126 |
+#if __FreeBSD_version >= 1100036 |
153 |
- ifp->if_ierrors++; |
127 |
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
154 |
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
128 |
+#else |
|
|
129 |
ifp->if_ierrors++; |
130 |
+#endif |
131 |
m_freem(m); |
155 |
m_freem(m); |
132 |
return; |
156 |
return; |
133 |
} |
157 |
} |
134 |
@@ -384,17 +428,25 @@ |
158 |
@@ -384,17 +341,17 @@ aoe_ether_input(struct ifnet *ifp, struct mbuf *m) |
135 |
if (m->m_pkthdr.len > |
159 |
if (m->m_pkthdr.len > |
136 |
ETHER_MAX_FRAME(ifp, etype, m->m_flags & M_HASFCS)) { |
160 |
ETHER_MAX_FRAME(ifp, etype, m->m_flags & M_HASFCS)) { |
137 |
if_printf(ifp, "discard oversize frame " |
161 |
if_printf(ifp, "discard oversize frame " |
Lines 141-260
Link Here
|
141 |
- ETHER_MAX_FRAME(ifp, etype, |
165 |
- ETHER_MAX_FRAME(ifp, etype, |
142 |
+ (int) ETHER_MAX_FRAME(ifp, etype, |
166 |
+ (int) ETHER_MAX_FRAME(ifp, etype, |
143 |
m->m_flags & M_HASFCS)); |
167 |
m->m_flags & M_HASFCS)); |
144 |
+#if __FreeBSD_version >= 1100036 |
168 |
- ifp->if_ierrors++; |
145 |
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
169 |
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
146 |
+#else |
|
|
147 |
ifp->if_ierrors++; |
148 |
+#endif |
149 |
m_freem(m); |
170 |
m_freem(m); |
150 |
return; |
171 |
return; |
151 |
} |
172 |
} |
152 |
if (m->m_pkthdr.rcvif == NULL) { |
173 |
if (m->m_pkthdr.rcvif == NULL) { |
153 |
if_printf(ifp, "discard frame w/o interface pointer\n"); |
174 |
if_printf(ifp, "discard frame w/o interface pointer\n"); |
154 |
+#if __FreeBSD_version >= 1100036 |
175 |
- ifp->if_ierrors++; |
155 |
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
176 |
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
156 |
+#else |
|
|
157 |
ifp->if_ierrors++; |
158 |
+#endif |
159 |
m_freem(m); |
177 |
m_freem(m); |
160 |
return; |
178 |
return; |
161 |
} |
179 |
} |
162 |
@@ -417,7 +469,11 @@ |
180 |
@@ -417,7 +374,7 @@ aoe_ether_input(struct ifnet *ifp, struct mbuf *m) |
163 |
m->m_flags &= ~M_HASFCS; |
181 |
m->m_flags &= ~M_HASFCS; |
164 |
} |
182 |
} |
165 |
|
183 |
|
166 |
+#if __FreeBSD_version >= 1100036 |
184 |
- ifp->if_ibytes += m->m_pkthdr.len; |
167 |
+ if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); |
185 |
+ if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); |
168 |
+#else |
|
|
169 |
ifp->if_ibytes += m->m_pkthdr.len; |
170 |
+#endif |
171 |
|
186 |
|
172 |
if (ETHER_IS_MULTICAST(eh->ether_dhost)) { |
187 |
if (ETHER_IS_MULTICAST(eh->ether_dhost)) { |
173 |
if (bcmp(etherbroadcastaddr, eh->ether_dhost, |
188 |
if (bcmp(etherbroadcastaddr, eh->ether_dhost, |
174 |
@@ -427,7 +483,11 @@ |
189 |
@@ -427,7 +384,7 @@ aoe_ether_input(struct ifnet *ifp, struct mbuf *m) |
175 |
m->m_flags |= M_MCAST; |
190 |
m->m_flags |= M_MCAST; |
176 |
} |
191 |
} |
177 |
if (m->m_flags & (M_BCAST|M_MCAST)) |
192 |
if (m->m_flags & (M_BCAST|M_MCAST)) |
178 |
+#if __FreeBSD_version >= 1100036 |
193 |
- ifp->if_imcasts++; |
179 |
+ if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); |
194 |
+ if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); |
180 |
+#else |
|
|
181 |
ifp->if_imcasts++; |
182 |
+#endif |
183 |
|
195 |
|
184 |
aoeintr(m); |
196 |
aoeintr(m); |
185 |
/* netisr_dispatch(NETISR_AOE, m); */ |
197 |
/* netisr_dispatch(NETISR_AOE, m); */ |
186 |
@@ -472,7 +532,11 @@ |
198 |
@@ -446,7 +403,7 @@ sysctl_aoe_iflist(SYSCTL_HANDLER_ARGS) |
187 |
|
|
|
188 |
IFNET_RLOCK(); |
189 |
TAILQ_FOREACH(ifp, &ifnet, if_link) { |
190 |
+#if __FreeBSD_version >= 1100030 |
191 |
+ switch (ifp->if_type) { |
192 |
+#else |
193 |
switch (ifp->if_data.ifi_type) { |
194 |
+#endif |
195 |
case IFT_ETHER: |
196 |
case IFT_FASTETHER: |
197 |
case IFT_GIGABITETHERNET: |
198 |
@@ -501,7 +565,11 @@ |
199 |
|
200 |
IFNET_RLOCK(); |
201 |
TAILQ_FOREACH(ifp, &ifnet, if_link) { |
202 |
+#if __FreeBSD_version >= 1100030 |
203 |
+ switch (ifp->if_type) { |
204 |
+#else |
205 |
switch (ifp->if_data.ifi_type) { |
206 |
+#endif |
207 |
case IFT_ETHER: |
208 |
case IFT_FASTETHER: |
209 |
case IFT_GIGABITETHERNET: |
210 |
--- aoenet.c.orig 2019-08-14 20:53:51.415030000 -0700 |
211 |
+++ aoenet.c 2019-08-14 20:58:53.326160000 -0700 |
212 |
@@ -85,6 +85,12 @@ |
213 |
#endif |
214 |
#define IFLISTSZ 1024 |
215 |
|
216 |
+#if __FreeBSD_version >= 1200000 |
217 |
+#define IFNET_FOREACH(v, h, e) CK_STAILQ_FOREACH(v, h, e) |
218 |
+#else |
219 |
+#define IFNET_FOREACH(v, h, e) TAILQ_FOREACH(v, h, e) |
220 |
+#endif |
221 |
+ |
222 |
static char aoe_iflist[IFLISTSZ]; |
223 |
|
224 |
static int sysctl_aoe_iflist(SYSCTL_HANDLER_ARGS); |
225 |
@@ -304,7 +310,7 @@ |
226 |
h->ah_cmd = AOECMD_CFG; |
227 |
|
228 |
IFNET_RLOCK(); |
229 |
- TAILQ_FOREACH(ifp, &ifnet, if_link) { |
230 |
+ IFNET_FOREACH(ifp, &ifnet, if_link) { |
231 |
if (!is_aoe_netif(ifp)) |
232 |
continue; |
233 |
memcpy(h->ah_src, IFPADDR(ifp), sizeof(h->ah_src)); |
234 |
@@ -506,7 +512,7 @@ |
235 |
|
199 |
|
236 |
#ifdef FORCE_NETWORK_HOOK |
200 |
#ifdef FORCE_NETWORK_HOOK |
237 |
IFNET_RLOCK(); |
201 |
IFNET_RLOCK(); |
238 |
- TAILQ_FOREACH(ifp, &ifnet, if_link) { |
202 |
- TAILQ_FOREACH(ifp, &ifnet, if_link) { |
239 |
+ IFNET_FOREACH(ifp, &ifnet, if_link) { |
203 |
+ IFNET_FOREACH(ifp) { |
240 |
if (!is_aoe_netif(ifp)) { |
204 |
if (!is_aoe_netif(ifp)) { |
241 |
if (ifp->if_input == aoe_ether_input) |
205 |
if (ifp->if_input == aoe_ether_input) |
242 |
ifp->if_input = old_ether_input; |
206 |
ifp->if_input = old_ether_input; |
243 |
@@ -531,7 +537,7 @@ |
207 |
@@ -471,8 +428,8 @@ aoenet_init(void) |
244 |
struct ifnet *ifp; |
208 |
struct ifnet *ifp; |
245 |
|
209 |
|
246 |
IFNET_RLOCK(); |
210 |
IFNET_RLOCK(); |
247 |
- TAILQ_FOREACH(ifp, &ifnet, if_link) { |
211 |
- TAILQ_FOREACH(ifp, &ifnet, if_link) { |
248 |
+ IFNET_FOREACH(ifp, &ifnet, if_link) { |
212 |
- switch (ifp->if_data.ifi_type) { |
249 |
#if __FreeBSD_version >= 1100030 |
213 |
+ IFNET_FOREACH(ifp) { |
250 |
switch (ifp->if_type) { |
214 |
+ switch (ifp->if_type) { |
251 |
#else |
215 |
case IFT_ETHER: |
252 |
@@ -564,7 +570,7 @@ |
216 |
case IFT_FASTETHER: |
|
|
217 |
case IFT_GIGABITETHERNET: |
218 |
@@ -500,8 +457,8 @@ aoenet_exit(void) |
253 |
struct ifnet *ifp; |
219 |
struct ifnet *ifp; |
254 |
|
220 |
|
255 |
IFNET_RLOCK(); |
221 |
IFNET_RLOCK(); |
256 |
- TAILQ_FOREACH(ifp, &ifnet, if_link) { |
222 |
- TAILQ_FOREACH(ifp, &ifnet, if_link) { |
257 |
+ IFNET_FOREACH(ifp, &ifnet, if_link) { |
223 |
- switch (ifp->if_data.ifi_type) { |
258 |
#if __FreeBSD_version >= 1100030 |
224 |
+ IFNET_FOREACH(ifp) { |
259 |
switch (ifp->if_type) { |
225 |
+ switch (ifp->if_type) { |
260 |
#else |
226 |
case IFT_ETHER: |
|
|
227 |
case IFT_FASTETHER: |
228 |
case IFT_GIGABITETHERNET: |