-
Notifications
You must be signed in to change notification settings - Fork 39
/
vrouter-functions.sh
executable file
·596 lines (526 loc) · 19.1 KB
/
vrouter-functions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
#!/bin/bash
source /etc/contrail/agent_param
function pkt_setup () {
for f in /sys/class/net/$1/queues/rx-*
do
q="$(echo $f | cut -d '-' -f2)"
r=$(($q%32))
s=$(($q/32))
((mask=1<<$r))
str=(`printf "%x" $mask`)
if [ $s -gt 0 ]; then
for ((i=0; i < $s; i++))
do
str+=,00000000
done
fi
echo $str > $f/rps_cpus
done
ifconfig $1 up
}
function insert_vrouter() {
if cat $CONFIG | grep '^\s*platform\s*=\s*dpdk\b' &>/dev/null; then
vrouter_dpdk_start
return $?
fi
grep $kmod /proc/modules 1>/dev/null 2>&1
if [ $? != 0 ]; then
modprobe $kmod
if [ $? != 0 ]
then
echo "$(date) : Error inserting vrouter module"
return 1
fi
if [ -f /sys/class/net/pkt1/queues/rx-0/rps_cpus ]; then
pkt_setup pkt1
fi
if [ -f /sys/class/net/pkt2/queues/rx-0/rps_cpus ]; then
pkt_setup pkt2
fi
if [ -f /sys/class/net/pkt3/queues/rx-0/rps_cpus ]; then
pkt_setup pkt3
fi
fi
# check if vhost0 is not present, then create vhost0 and $dev
if [ ! -L /sys/class/net/vhost0 ]; then
echo "$(date): Creating vhost interface: $DEVICE."
# for bonding interfaces
loops=0
while [ ! -f /sys/class/net/$dev/address ]
do
sleep 1
loops=$(($loops + 1))
if [ $loops -ge 60 ]; then
echo "Unable to look at /sys/class/net/$dev/address"
return 1
fi
done
DEV_MAC=$(cat /sys/class/net/$dev/address)
vif --create $DEVICE --mac $DEV_MAC
if [ $? != 0 ]; then
echo "$(date): Error creating interface: $DEVICE"
fi
echo "$(date): Adding $dev to vrouter"
DEV_MAC=$(cat /sys/class/net/$dev/address)
vif --add $dev --mac $DEV_MAC --vrf 0 --vhost-phys --type physical
if [ $? != 0 ]; then
echo "$(date): Error adding $dev to vrouter"
fi
vif --add $DEVICE --mac $DEV_MAC --vrf 0 --type vhost --xconnect $dev
if [ $? != 0 ]; then
echo "$(date): Error adding $DEVICE to vrouter"
fi
fi
return 0
}
############################################################################
## vRouter/DPDK Functions
############################################################################
##
## Read Agent Configuration File and Global vRouter/DPDK Configuration
##
_dpdk_conf_read() {
if [ -n "${_DPDK_CONF_READ}" ]; then
return
fi
_DPDK_CONF_READ=1
## global vRouter/DPDK configuration
DPDK_BINDING_DRIVER_DATA='/var/run/vrouter'
DPDK_BIND="/opt/contrail/bin/dpdk_nic_bind.py"
DPDK_RTE_CONFIG="/run/.rte_config"
VROUTER_SERVICE="supervisor-vrouter"
AGENT_CONF="${CONFIG}"
VROUTER_DPDK_INI=/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini
DPDK_NETLINK_TCP_PORT=20914
DPDK_MEM_PER_SOCKET="1024"
if [ ! -s ${AGENT_CONF} ]; then
echo "$(date): Error reading ${AGENT_CONF}: file does not exist"
exit 1
fi
eval `cat ${AGENT_CONF} | grep '^[a-zA-Z]'`
AGENT_PLATFORM="${platform}"
DPDK_PHY="${physical_interface}"
DPDK_PHY_PCI="${physical_interface_address}"
DPDK_PHY_MAC="${physical_interface_mac}"
DPDK_VHOST="${name}"
if [ -z "${DPDK_PHY}" ]; then
echo "$(date): Error reading ${AGENT_CONF}: no physical device defined"
exit 1
fi
if [ -z "${DPDK_VHOST}" ]; then
echo "$(date): Error reading ${AGENT_CONF}: no vhost device defined"
exit 1
fi
# TODO: Remove this waiting loop as the _dpdk_conf_read() is used also when
# the vRouter is already started. In that case, there is no entry under
# /sys/class/net/${DPDK_PHY} and this code unnecessarily adds 20s of a
# delay, enlarging the start/stop time of the supervisor-vrouter service.
loops=0
# Waiting for interface, we should wait
# for interface in case of rebinding interface from dpdk (igb_uio) driver to kernel driver
while [ ! -e /sys/class/net/${DPDK_PHY} ]
do
sleep 2
loops=$(($loops + 1))
if [ $loops -ge 10 ]; then
echo "$(date): ${DPDK_PHY} interface: Does not exist."
return 1
fi
done
## check for VLANs
_vlan_file="/proc/net/vlan/${DPDK_PHY}"
DPDK_VLAN_IF=""
DPDK_VLAN_ID=""
DPDK_VLAN_DEV=""
if [ -f "${_vlan_file}" ]; then
DPDK_VLAN_IF="${DPDK_PHY}"
DPDK_VLAN_ID=`cat ${_vlan_file} | grep "VID:" | head -1 | awk '{print $3}'`
DPDK_VLAN_DEV=`cat ${_vlan_file} | grep "Device:" | head -1 | awk '{print $2}'`
if [ -n "${DPDK_VLAN_DEV}" ]; then
## use raw device and pass VLAN ID as a parameter
DPDK_PHY="${DPDK_VLAN_DEV}"
fi
fi
}
##
## Check if vRouter/DPDK is Running
##
_is_vrouter_dpdk_running() {
# check for NetLink TCP socket
lsof -ni:${DPDK_NETLINK_TCP_PORT} -sTCP:LISTEN > /dev/null
return $?
}
##
## Start vRouter/DPDK
##
vrouter_dpdk_start() {
echo "$(date): Starting vRouter/DPDK..."
_dpdk_conf_read
# remove rte configuration file if vRouter has crashed
rm -f ${DPDK_RTE_CONFIG}
# set maximum socket buffer size to (max hold flows entries * 9160 bytes)
sysctl -w net.core.wmem_max=9160000
loops=0
# wait for vRouter/DPDK to start
while ! _is_vrouter_dpdk_running
do
sleep 5
loops=$(($loops + 1))
if [ $loops -ge 60 ]; then
echo "$(date): Error starting ${VROUTER_SERVICE} service: vRouter/DPDK is not running"
return 1
fi
done
# Include huge pages in core dump of contrail-vrouter-dpdk process
pid=$(pidof contrail-vrouter-dpdk)
if [ -f /proc/$pid/coredump_filter ]; then
cdump_filter=`cat /proc/$pid/coredump_filter`
cdump_filter=$((0x40 | 0x$cdump_filter))
echo $cdump_filter > /proc/$pid/coredump_filter
else
cdump_filter=0x73
echo $cdump_filter > /proc/$pid/coredump_filter
fi
echo "$(date): Waiting for Agent to configure ${DPDK_VHOST}..."
loops=0
while [ ! -L /sys/class/net/${DPDK_VHOST} ]
do
sleep 2
loops=$(($loops + 1))
if [ $loops -ge 10 ]; then
echo "$(date): Error Agent configuring ${DPDK_VHOST}: interface does not exist"
break
fi
done
# check if vhost0 is not present, then create vhost0 and $dev
if [ ! -L /sys/class/net/${DPDK_VHOST} ]; then
echo "$(date): Creating ${DPDK_VHOST} interface with vif utility..."
if [ -z "${DPDK_PHY_MAC}" ]; then
echo "Error reading ${AGENT_CONF}: physical MAC address is not defined"
return 1
fi
if [ -z "${DPDK_PHY_PCI}" ]; then
echo "Error reading ${AGENT_CONF}: physical PCI address is not defined"
return 1
fi
# TODO: the vhost creation is happening later in vif --add
# vif --create ${DPDK_VHOST} --mac ${DPDK_PHY_MAC}
# if [ $? != 0 ]; then
# echo "$(date): Error creating interface: ${DPDK_VHOST}"
# fi
echo "$(date): Adding ${DPDK_PHY} interface with vif utility..."
# add DPDK ethdev 0 as a physical interface
vif --add 0 --mac ${DPDK_PHY_MAC} --vrf 0 --vhost-phys --type physical --pmd --id 0
if [ $? != 0 ]; then
echo "$(date): Error adding ${DPDK_PHY} interface"
fi
echo "$(date): Adding ${DPDK_VHOST} interface with vif utility..."
# TODO: vif --xconnect seems does not work without --id parameter?
vif --add ${DPDK_VHOST} --mac ${DPDK_PHY_MAC} --vrf 0 --type vhost --xconnect 0 --pmd --id 1
if [ $? != 0 ]; then
echo "$(date): Error adding ${DPDK_VHOST} interface"
fi
fi
echo "$(date): Done starting vRouter/DPDK."
return 0
}
##
## Collect Runtime Bond Device Information
## Returns:
## DPDK_BOND_MODE - non-empty string for bond interface, empty otherwise
## DPDK_BOND_SLAVES - list of bond device members or just one non-bond device
##
_dpdk_system_bond_info_collect() {
if [ -n "${_DPDK_SYSTEM_BOND_INFO_COLLECT}" ]; then
return
fi
_DPDK_SYSTEM_BOND_INFO_COLLECT=1
_dpdk_conf_read
bond_dir="/sys/class/net/${DPDK_PHY}/bonding"
DPDK_BOND_MODE=""
DPDK_BOND_POLICY=""
DPDK_BOND_SLAVES=""
if [ -d ${bond_dir} ]; then
DPDK_BOND_MODE=`cat ${bond_dir}/mode | awk '{print $2}'`
DPDK_BOND_POLICY=`cat ${bond_dir}/xmit_hash_policy | awk '{print $1}'`
DPDK_BOND_SLAVES=`cat ${bond_dir}/slaves | tr ' ' '\n' | sort | tr '\n' ' '`
DPDK_BOND_SLAVES="${DPDK_BOND_SLAVES% }"
else
# put the physical interface into the list, so we can use the
# same code to bind/unbind the interface
DPDK_BOND_SLAVES="${DPDK_PHY}"
fi
## Map Linux values to DPDK
case "${DPDK_BOND_POLICY}" in
"layer2") DPDK_BOND_POLICY="l2";;
"layer3+4") DPDK_BOND_POLICY="l34";;
"layer2+3") DPDK_BOND_POLICY="l23";;
# DPDK 2.0 does not support inner packet hashing
"encap2+3") DPDK_BOND_POLICY="l23";;
"encap3+4") DPDK_BOND_POLICY="l34";;
esac
DPDK_BOND_PCIS=""
DPDK_BOND_NUMA=""
DPDK_BOND_MAC=""
## Bond Members
for slave in ${DPDK_BOND_SLAVES}; do
slave_dir="/sys/class/net/${slave}"
slave_pci=`readlink ${slave_dir}/device`
slave_pci=${slave_pci##*/}
slave_numa=`cat ${slave_dir}/device/numa_node`
slave_mac=`cat ${slave_dir}/address`
if [ -n "${slave_pci}" ]; then
DPDK_BOND_PCIS="${DPDK_BOND_PCIS} ${slave_pci}"
fi
if [ -z "${DPDK_BOND_NUMA}" ]; then
# DPDK EAL for bond interface interprets -1 as 255
if [ "${slave_numa}" -eq -1 ]; then
DPDK_BOND_NUMA=0
else
DPDK_BOND_NUMA="${slave_numa}"
fi
fi
if [ -z "${DPDK_BOND_MAC}" ]; then
DPDK_BOND_MAC="${slave_mac}"
fi
done
DPDK_BOND_PCIS="${DPDK_BOND_PCIS# }"
}
##
## Update vRouter/DPDK INI File
##
_dpdk_vrouter_ini_update() {
_dpdk_system_bond_info_collect
## update virtual device (bond) configuration
dpdk_vdev=""
if [ -n "${DPDK_BOND_MODE}" -a -n "${DPDK_BOND_NUMA}" ]; then
echo "${0##*/}: updating bonding configuration in ${VROUTER_DPDK_INI}..."
dpdk_vdev=" --vdev \"eth_bond_${DPDK_PHY},mode=${DPDK_BOND_MODE}"
dpdk_vdev="${dpdk_vdev},xmit_policy=${DPDK_BOND_POLICY}"
dpdk_vdev="${dpdk_vdev},socket_id=${DPDK_BOND_NUMA},mac=${DPDK_BOND_MAC}"
for SLAVE in ${DPDK_BOND_PCIS}; do
dpdk_vdev="${dpdk_vdev},slave=${SLAVE}"
done
dpdk_vdev="${dpdk_vdev}\""
fi
## always update the ini file, so we remove vdev argument
## whenever Linux configuration has changed
sed -ri.bak \
-e 's/(^ *command *=.*vrouter-dpdk.*) (--vdev +\"[^"]+\"|--vdev +[^ ]+)(.*) *$/\1\3/' \
-e 's/(^ *command *=.*vrouter-dpdk.*) (--vdev +\"[^"]+\"|--vdev +[^ ]+)(.*) *$/\1\3/' \
-e "s/(^ *command *=.*vrouter-dpdk.*)/\\1${dpdk_vdev}/" \
${VROUTER_DPDK_INI}
## update VLAN configuration
dpdk_vlan=""
dpdk_vlan_name=""
if [ -n "${DPDK_VLAN_ID}" ]; then
echo "${0##*/}: updating VLAN configuration in ${VROUTER_DPDK_INI}..."
dpdk_vlan=" --vlan_tci \"${DPDK_VLAN_ID}\""
dpdk_vlan_name=" --vlan_fwd_intf_name \"${DPDK_PHY}\""
fi
sed -ri.bak \
-e 's/(^ *command *=.*vrouter-dpdk.*) (--vlan_tci +\"[^"]+\"|--vlan_tci +[^ ]+)(.*) *$/\1\3/' \
-e 's/(^ *command *=.*vrouter-dpdk.*) (--vlan_tci +\"[^"]+\"|--vlan_tci +[^ ]+)(.*) *$/\1\3/' \
-e "s/(^ *command *=.*vrouter-dpdk.*)/\\1${dpdk_vlan}/" \
${VROUTER_DPDK_INI}
sed -ri.bak \
-e 's/(^ *command *=.*vrouter-dpdk.*) (--vlan_fwd_intf_name +\"[^"]+\"|--vlan_fwd_intf_name +[^ ]+)(.*) *$/\1\3/' \
-e 's/(^ *command *=.*vrouter-dpdk.*) (--vlan_fwd_intf_name +\"[^"]+\"|--vlan_fwd_intf_name +[^ ]+)(.*) *$/\1\3/' \
-e "s/(^ *command *=.*vrouter-dpdk.*)/\\1${dpdk_vlan_name}/" \
${VROUTER_DPDK_INI}
## allocate memory on each NUMA node
dpdk_socket_mem=""
for _numa_node in /sys/devices/system/node/node*/hugepages
do
if [ -z "${dpdk_socket_mem}" ]; then
dpdk_socket_mem="${DPDK_MEM_PER_SOCKET}"
else
dpdk_socket_mem="${dpdk_socket_mem},${DPDK_MEM_PER_SOCKET}"
fi
done
if [ -n "${dpdk_socket_mem}" ]; then
echo "${0##*/}: updating per socket memory allocation in ${VROUTER_DPDK_INI}..."
dpdk_socket_mem=" --socket-mem ${dpdk_socket_mem}"
fi
## update the ini file
sed -ri.bak \
-e 's/(^ *command *=.*vrouter-dpdk.*) (--socket-mem +\"[^"]+\"|--socket-mem +[^ ]+)(.*) *$/\1\3/' \
-e 's/(^ *command *=.*vrouter-dpdk.*) (--socket-mem +\"[^"]+\"|--socket-mem +[^ ]+)(.*) *$/\1\3/' \
-e "s/(^ *command *=.*vrouter-dpdk.*)/\\1${dpdk_socket_mem}/" \
${VROUTER_DPDK_INI}
}
##
## Wait till bond interface is up and all slaves attached
##
_dpdk_wait_for_bond_ready() {
#if DPDK_PHY is a vlan, remove the '.'
bond_name=$(echo ${DPDK_PHY} | cut -d. -f1)
bond_dir="/sys/class/net/${bond_name}/bonding"
for iface in $(ifquery --list); do
ifquery $iface | grep "bond-master" | grep ${bond_name}
if [ $? -eq 0 ];
then
timeout=0
# Wait upto 60 sec till the interface is enslaved
while [ $timeout -lt 60 ];
do
cat ${bond_dir}/slaves | grep $iface
if [ $? -ne 0 ];
then
echo "Waiting for interface $iface to be ready"
sleep 1
else
echo "Slave interface $iface ready"
break
fi
timeout=$(expr $timeout + 1)
done
fi
done
}
##
## Bind vRouter/DPDK Interface(s) to DPDK Drivers
## The function is used in pre/post start scripts
##
vrouter_dpdk_if_bind() {
echo "$(date): Binding interfaces to DPDK drivers..."
# TODO: This is a temporary workaround for the race between vRouter
# start and network interfaces set up. There were observed cases when the
# vRouter had started before the bond0 interface was created, which led to
# an error as DPDK could not bind to the non-existing interface. In
# overall, cleanup of the functions in this file should be done to
# eliminate such workarounds.
DPDK_PHY=$(cat $CONFIG | sed -nr 's/^\s*physical_interface\s*=\s*(\S+)\b/\1/p')
loops=0
while [ ! -e /sys/class/net/${DPDK_PHY} ]; do
sleep 2
#if DPDK_PHY is a vlan on a bond, might need to bring it up explicitly
# after the slaves are added to the bond (especially if slaves are VFs)
ifup ${DPDK_PHY}
loops=$(($loops + 1))
if [ $loops -ge 60 ]; then
echo "$(date): Error binding physical interface ${DPDK_PHY}: device not found"
${DPDK_BIND} --status
return 1
fi
done
_dpdk_conf_read
modprobe igb_uio
# multiple kthreads for port monitoring
modprobe rte_kni kthread_mode=multiple
_dpdk_wait_for_bond_ready
_dpdk_system_bond_info_collect
_dpdk_vrouter_ini_update
mkdir -p ${DPDK_BINDING_DRIVER_DATA}
for slave_pci in ${DPDK_BOND_PCIS}; do
if [ ! -e ${DPDK_BINDING_DRIVER_DATA}/${slave_pci} ]; then
echo "Adding lspci data to ${DPDK_BINDING_DRIVER_DATA}/${slave_pci}"
`lspci -vmmks ${slave_pci} > ${DPDK_BINDING_DRIVER_DATA}/${slave_pci}`
fi
done
# bind physical device(s) to DPDK driver
for slave in ${DPDK_BOND_SLAVES}; do
echo "Binding device ${slave} to DPDK igb_uio driver..."
${DPDK_BIND} --force --bind=igb_uio ${slave}
done
if [ -n "${DPDK_BOND_MODE}" ]; then
echo "${0##*/}: removing bond interface from Linux..."
ifdown "${DPDK_PHY}"
fi
${DPDK_BIND} --status
echo "$(date): Done binding interfaces."
}
##
## Collect Bonding Information from vRouter/DPDK INI File
## Returns:
## DPDK_BOND_PCI_NAMES - list of bond device members or just one non-bond device
##
_dpdk_vrouter_ini_bond_info_collect() {
if [ -n "${_DPDK_VROUTER_INI_BOND_INFO_COLLECT}" ]; then
return
fi
_DPDK_VROUTER_INI_BOND_INFO_COLLECT=1
_dpdk_conf_read
## Look for slave PCI addresses of vRouter --vdev argument
DPDK_BOND_PCIS=`sed -nr \
-e '/^ *command *=/ {
s/slave=/\x1/g
s/[^\x1]+//
s/\x1([0-9:\.]+)[^\x1]+/ \1/g
p
}' \
${VROUTER_DPDK_INI}`
DPDK_BOND_PCIS="${DPDK_BOND_PCIS# }"
if [ -z "${DPDK_BOND_PCIS}" ]; then
# fallback to Agent configuration for a single interface
DPDK_BOND_PCIS="${DPDK_PHY_PCI}"
fi
## Look up a driver name for all the devices
DPDK_BOND_PCI_NAMES=""
for slave_pci in ${DPDK_BOND_PCIS}; do
slave_pci_name=`echo ${slave_pci} | tr ':.' '_'`
if [ -n "${slave_pci_name}" ]; then
DPDK_BOND_PCI_NAMES="${DPDK_BOND_PCI_NAMES} ${slave_pci_name}"
fi
eval DPDK_BOND_${slave_pci_name}_PCI="${slave_pci}"
done
DPDK_BOND_PCI_NAMES="${DPDK_BOND_PCI_NAMES# }"
}
##
## Unbind vRouter/DPDK Interface(s) Back to System Drivers
## The function is used in pre/post start scripts
##
vrouter_dpdk_if_unbind() {
echo "$(date): Unbinding interfaces back to system drivers..."
_dpdk_conf_read
echo "$(date): Waiting for vRouter/DPDK to stop..."
loops=0
while _is_vrouter_dpdk_running
do
sleep 2
loops=$(($loops + 1))
if [ $loops -ge 60 ]; then
echo "$(date): Error stopping ${VROUTER_SERVICE} service: vRouter/DPDK is still running"
return 1
fi
done
_dpdk_vrouter_ini_bond_info_collect
## make sure igb_uio is loaded otherwise DPDK_BIND will not work
modprobe igb_uio
for slave_pci_name in ${DPDK_BOND_PCI_NAMES}; do
eval slave_pci=\${DPDK_BOND_${slave_pci_name}_PCI}
slave_driver=`grep "Driver:" ${DPDK_BINDING_DRIVER_DATA}/${slave_pci} | cut -f 2 | tr -d ['\n\r']`
echo "Binding PCI device ${slave_pci} back to ${slave_driver} driver..."
${DPDK_BIND} --force --bind=${slave_driver} ${slave_pci}
rm ${DPDK_BINDING_DRIVER_DATA}/${slave_pci}
done
${DPDK_BIND} --status
rmmod rte_kni
rmmod igb_uio
echo "$(date): Re-initialize networking."
for iface in $(ifquery --list);
do
if ifquery $iface | grep -i "bond";
then
ifdown $iface
fi
done
# Make the bond slaves up
# Bond slaves with automatically make the bond master up
for iface in $(ifquery --list);
do
if ifquery $iface | grep -i "bond-master:";
then
ifup $iface
fi
done
# Make other interfaces up (which are still down)
for iface in $(ifquery --list);
do
if ! ifquery --state $iface;
then
ifup $iface
fi
done
echo "$(date): Done unbinding interfaces."
}