@@ -14,6 +14,7 @@ to the compiler.
14
14
15
15
For example, to install C-libmemif system-wide into the standard
16
16
locations, execute:
17
+
17
18
```
18
19
$ git clone https://gerrit.fd.io/r/vpp
19
20
$ cd vpp/extras/libmemif
@@ -28,6 +29,7 @@ Package **libmemif** is not part of the **GoVPP** core and as such it is
28
29
not included in the [ make build] ( ../../Makefile ) target.
29
30
Instead, it has its own target in the [ top-level Makefile] ( ../../Makefile )
30
31
used to build the attached examples with the adapter:
32
+
31
33
```
32
34
$ make extras
33
35
```
@@ -59,6 +61,7 @@ structure representing the underlying memif interface.
59
61
60
62
Callbacks are optional and can be shared across multiple memif instances.
61
63
Available callbacks are:
64
+
62
65
1 . ** OnConnect** : called when the connection is established.
63
66
By the time the callback is called, the Rx/Tx queues are initialized
64
67
and ready for data transmission. Interrupt channels are also
@@ -103,7 +106,7 @@ Do not touch memif after it was closed, let garbage collector to remove
103
106
the ` Memif ` instance. In the end, ` Cleanup() ` will also ensure that all
104
107
active memif interfaces are closed before the cleanup finalizes.
105
108
106
- To use libmemif with ` google/gopacket ` , simply call ` Memif .NewPacketHandle()`
109
+ To use libmemif with ` google/gopacket ` , simply call ` libmemif .NewPacketHandle()`
107
110
to create ` google/gopacket/PacketDataSource ` from memif queue. After this you
108
111
can use gopacket API to read from ` MemifPacketHandle ` as normal. You can pass
109
112
optional ` rxCount ` when creating the packet handle and then when reading data,
@@ -119,46 +122,48 @@ The examples can be found in the subdirectory [examples](./examples).
119
122
120
123
#### Raw data (libmemif <-> libmemif)
121
124
122
- * raw-data * is a basic example showing how to create a memif interface,
125
+ _ raw-data _ is a basic example showing how to create a memif interface,
123
126
handle events through callbacks and perform Rx/Tx of raw data. Before
124
127
handling an actual packets it is important to understand the skeleton
125
128
of libmemif-based applications.
126
129
127
130
Since VPP expects proper packet data, it is not very useful to connect
128
- * raw-data * example with VPP, even though it will work, since all
131
+ _ raw-data _ example with VPP, even though it will work, since all
129
132
the received data will get dropped on the VPP side.
130
133
131
134
To create a connection of two raw-data instances, start two processes
132
135
concurrently in an arbitrary order:
133
- - * master* memif:
134
- ```
135
- $ cd extras/libmemif/examples/raw-data
136
- $ ./raw-data
137
- ```
138
- - * slave* memif:
139
- ```
140
- $ cd extras/libmemif/examples/raw-data
141
- $ ./raw-data --slave
142
- ```
136
+
137
+ - _ master_ memif:
138
+ ```
139
+ $ cd extras/libmemif/examples/raw-data
140
+ $ ./raw-data
141
+ ```
142
+ - _ slave_ memif:
143
+ ```
144
+ $ cd extras/libmemif/examples/raw-data
145
+ $ ./raw-data --slave
146
+ ```
143
147
144
148
Every 3 seconds both sides send 3 raw-data packets to the opposite end
145
149
through each of the 3 queues. The received packets are printed to stdout.
146
150
147
- Stop an instance of * raw-data * with an interrupt signal (^C).
151
+ Stop an instance of _ raw-data _ with an interrupt signal (^C).
148
152
149
153
#### Jumbo Frames Raw data (libmemif <-> libmemif)
150
154
151
- * jumbo-frames * is simple example how to send larger and larger jumbo
152
- packets with libmemif adapter. This is simple copy of * raw-data * but with
155
+ _ jumbo-frames _ is simple example how to send larger and larger jumbo
156
+ packets with libmemif adapter. This is simple copy of _ raw-data _ but with
153
157
sending larger packets, so for more information read its code and documentation.
154
158
155
159
#### ICMP Responder
156
160
157
- * icmp-responder * is a simple example showing how to answer APR and ICMP
161
+ _ icmp-responder _ is a simple example showing how to answer APR and ICMP
158
162
echo requests through a memif interface. Package ` google/gopacket ` is
159
163
used to decode and construct packets.
160
164
161
165
The appropriate VPP configuration for the opposite memif is:
166
+
162
167
```
163
168
vpp$ create memif socket id 1 filename /tmp/icmp-responder-example
164
169
vpp$ create interface memif id 1 socket-id 1 slave secret secret no-zero-copy
@@ -167,22 +172,25 @@ vpp$ set int ip address memif1/1 192.168.1.2/24
167
172
```
168
173
169
174
To start the example, simply type:
175
+
170
176
```
171
177
root$ ./icmp-responder
172
178
```
173
179
174
- * icmp-responder * needs to be run as root so that it can access the socket
180
+ _ icmp-responder _ needs to be run as root so that it can access the socket
175
181
created by VPP.
176
182
177
183
Normally, the memif interface is in the master mode. Pass CLI flag ` --slave `
178
184
to create memif in the slave mode:
185
+
179
186
```
180
187
root$ ./icmp-responder --slave
181
188
```
182
189
183
190
Don't forget to put the opposite memif into the master mode in that case.
184
191
185
192
To verify the connection, run:
193
+
186
194
```
187
195
vpp$ ping 192.168.1.1
188
196
64 bytes from 192.168.1.1: icmp_seq=2 ttl=255 time=.6974 ms
@@ -195,20 +203,22 @@ vpp$ sh ip arp
195
203
Time IP4 Flags Ethernet Interface
196
204
68.5648 192.168.1.1 D aa:aa:aa:aa:aa:aa memif0/1
197
205
```
198
- * Note* : it is expected that the first ping is shown as lost.
199
- It was actually converted to an ARP request. This is a VPP
200
- specific feature common to all interface types.
206
+
207
+ _ Note_ : it is expected that the first ping is shown as lost.
208
+ It was actually converted to an ARP request. This is a VPP
209
+ specific feature common to all interface types.
201
210
202
211
Stop the example with an interrupt signal (^C).
203
212
204
213
#### GoPacket ICMP Responder
205
214
206
- * gopacket * is a simple example showing how to answer APR and ICMP echo
215
+ _ gopacket _ is a simple example showing how to answer APR and ICMP echo
207
216
requests through a memif interface. This example is mostly identical
208
217
to icmp-responder example, but it is using MemifPacketHandle API to
209
218
read and write packets using gopacket API.
210
219
211
220
The appropriate VPP configuration for the opposite memif is:
221
+
212
222
```
213
223
vpp$ create memif socket id 1 filename /tmp/gopacket-example
214
224
vpp$ create interface memif id 1 socket-id 1 slave secret secret no-zero-copy
@@ -217,6 +227,7 @@ vpp$ set int ip address memif1/1 192.168.1.2/24
217
227
```
218
228
219
229
To start the example, simply type:
230
+
220
231
```
221
232
root$ ./gopacket
222
233
```
@@ -226,13 +237,15 @@ created by VPP.
226
237
227
238
Normally, the memif interface is in the master mode. Pass CLI flag "--slave"
228
239
to create memif in the slave mode:
240
+
229
241
```
230
242
root$ ./gopacket --slave
231
243
```
232
244
233
245
Don't forget to put the opposite memif into the master mode in that case.
234
246
235
247
To verify the connection, run:
248
+
236
249
```
237
250
vpp$ ping 192.168.1.1
238
251
64 bytes from 192.168.1.1: icmp_seq=2 ttl=255 time=.6974 ms
@@ -246,8 +259,8 @@ Time IP4 Flags Ethernet Interface
246
259
68.5648 192.168.1.1 D aa:aa:aa:aa:aa:aa memif0/1
247
260
```
248
261
249
- * Note * : it is expected that the first ping is shown as lost.
250
- It was actually converted to an ARP request. This is a VPP
251
- specific feature common to all interface types.
262
+ _ Note _ : it is expected that the first ping is shown as lost.
263
+ It was actually converted to an ARP request. This is a VPP
264
+ specific feature common to all interface types.
252
265
253
266
Stop the example with an interrupt signal (^C).
0 commit comments