]> git.ipfire.org Git - people/ms/network.git/blob - src/functions/functions.device
Make device_set_{up,down} faster and show more debugging information
[people/ms/network.git] / src / functions / functions.device
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 device_list() {
23 local devices
24
25 # Add all interfaces
26 list_append devices $(devices_get_all)
27
28 # Add all PHYs
29 list_append devices $(phy_list)
30
31 # Add all serial devices
32 list_append devices $(serial_list)
33
34 # Return a sorted result
35 list_sort ${devices}
36 }
37
38 # Check if the device exists
39 device_exists() {
40 local device=${1}
41
42 # If device name was not found, exit.
43 [ -n "${device}" ] || return ${EXIT_ERROR}
44
45 # Check for a normal network device.
46 [ -d "${SYS_CLASS_NET}/${device}" ] && return ${EXIT_OK}
47
48 # If the check above did not find a result,
49 # we check for PHYs.
50 phy_exists "${device}" && return ${EXIT_OK}
51
52 # If the check above did not find a result,
53 # we check for serial devices.
54 serial_exists ${device}
55 }
56
57 device_matches_pattern() {
58 local device="${1}"
59 assert isset device
60
61 local pattern="${2}"
62 assert isset pattern
63
64 pattern="^${pattern//N/[[:digit:]]+}$"
65
66 [[ ${device} =~ ${pattern} ]] \
67 && return ${EXIT_TRUE} || return ${EXIT_FALSE}
68 }
69
70 device_delete() {
71 local device=${1}
72 assert isset device
73
74 # Nothing to do, it device does not exist.
75 device_exists ${device} || return ${EXIT_OK}
76
77 # Delete the device.
78 cmd_quiet ip link delete ${device}
79 local ret=$?
80
81 if [ ${ret} -ne ${EXIT_OK} ]; then
82 log ERROR "device: Could not delete device '${device}': ${ret}"
83 return ${EXIT_ERROR}
84 fi
85
86 return ${ret}
87 }
88
89 device_has_flag() {
90 local device=${1}
91 local flag=${2}
92
93 local flags=$(__device_get_file ${device} flags)
94
95 if [[ "$(( ${flags} & ${flag} ))" -eq 0 ]]; then
96 return ${EXIT_FALSE}
97 else
98 return ${EXIT_TRUE}
99 fi
100 }
101
102 # Check if the device is up
103 device_is_up() {
104 local device=${1}
105
106 device_exists ${device} || return ${EXIT_ERROR}
107
108 device_has_flag ${device} 0x1
109 }
110
111 device_ifindex_to_name() {
112 local idx=${1}
113 assert isset idx
114
115 local device device_idx
116 for device in ${SYS_CLASS_NET}/*; do
117 device=$(basename ${device})
118 device_exists ${device} || continue
119
120 device_idx=$(device_get_ifindex ${device})
121
122 if [ "${device_idx}" = "${idx}" ]; then
123 print "${device}"
124 return ${EXIT_OK}
125 fi
126 done
127
128 return ${EXIT_ERROR}
129 }
130
131 device_get_ifindex() {
132 local device=${1}
133 assert isset device
134
135 local path="${SYS_CLASS_NET}/${1}/ifindex"
136
137 # Check if file can be read.
138 [ -r "${path}" ] || return ${EXIT_ERROR}
139
140 print "$(<${path})"
141 }
142
143 # Check if the device is a batman-adv bridge
144 device_is_batman_adv() {
145 [ -d "${SYS_CLASS_NET}/${1}/mesh" ]
146 }
147
148 # Check if the device is a batman-adv slave port
149 device_is_batman_adv_slave() {
150 local device="${1}"
151
152 if [ -d "${SYS_CLASS_NET}/${device}/batman_adv" ]; then
153 local status="$(<${SYS_CLASS_NET}/${device}/batman_adv/iface_status)"
154
155 case "${status}" in
156 "active")
157 return ${EXIT_TRUE}
158 ;;
159 *)
160 return ${EXIT_FALSE}
161 ;;
162 esac
163 fi
164
165 return ${EXIT_FALSE}
166 }
167
168 # Check if the device is a bonding device
169 device_is_bonding() {
170 [ -d "/sys/class/net/${1}/bonding" ]
171 }
172
173 # Check if the device bonded in a bonding device
174 device_is_bonded() {
175 local device=${1}
176
177 [ -d "${SYS_CLASS_NET}/${device}/bonding_slave" ]
178 }
179
180 # Check if the device is a bridge
181 device_is_bridge() {
182 [ -d "/sys/class/net/${1}/bridge" ]
183 }
184
185 device_is_bridge_attached() {
186 local device=${1}
187 [ -d "${SYS_CLASS_NET}/${device}/brport" ]
188 }
189
190 device_is_wireless_monitor() {
191 local device="${1}"
192 assert isset device
193
194 device_is_wireless "${device}" && \
195 device_matches_pattern "${device}" "${PORT_PATTERN_WIRELESS_MONITOR}"
196 }
197
198 device_is_wireless_adhoc() {
199 local device="${1}"
200 assert isset device
201
202 device_is_wireless "${device}" && \
203 device_matches_pattern "${device}" "${PORT_PATTERN_WIRELESS_ADHOC}"
204 }
205
206 device_get_bridge() {
207 local device=${1}
208 assert isset device
209
210 # Check if device is attached to a bridge.
211 device_is_bridge_attached ${device} || return ${EXIT_ERROR}
212
213 local ifindex_path="${SYS_CLASS_NET}/${device}/brport/bridge/ifindex"
214 [ -r "${ifindex_path}" ] || return ${EXIT_ERROR}
215
216 local ifindex=$(<${ifindex_path})
217 assert isset ifindex
218
219 device_ifindex_to_name ${ifindex}
220 }
221
222 # Check if the device is a vlan device
223 device_is_vlan() {
224 local device=${1}
225 assert isset device
226
227 [ -e "${PROC_NET_VLAN}/${device}" ]
228 }
229
230 # Check if the device has vlan devices
231 device_has_vlans() {
232 local device=${1}
233 assert isset device
234
235 if device_is_vlan ${device}; then
236 return ${EXIT_FALSE}
237 fi
238
239 local vlans=$(device_get_vlans ${device})
240 [ -n "${vlans}" ] && return ${EXIT_OK} || return ${EXIT_ERROR}
241 }
242
243 device_get_vlans() {
244 local device=${1}
245 assert isset device
246
247 # If no 8021q module has been loaded into the kernel,
248 # we cannot do anything.
249 [ -r "${PROC_NET_VLAN_CONFIG}" ] || return ${EXIT_OK}
250
251 local dev spacer1 id spacer2 parent
252 while read dev spacer1 id spacer2 parent; do
253 [ "${parent}" = "${device}" ] || continue
254
255 print "${dev}"
256 done < ${PROC_NET_VLAN_CONFIG}
257 }
258
259 # Check if the device is a ppp device
260 device_is_ppp() {
261 local device=${1}
262
263 local type=$(__device_get_file ${device} type)
264
265 [ "${type}" = "512" ] && return ${EXIT_OK} || return ${EXIT_ERROR}
266 }
267
268 # Check if the device is a pointopoint device.
269 device_is_ptp() {
270 local device=${1}
271
272 device_has_flag ${device} 0x10
273 }
274
275 # Check if the device is a loopback device
276 device_is_loopback() {
277 local device=${1}
278
279 [ "${device}" = "lo" ]
280 }
281
282 # Check if the device is a dummy device
283 # This is the worst possible check, but all I could come up with
284 device_is_dummy() {
285 local device="${1}"
286
287 [[ ${device} =~ ^dummy[0-9]+$ ]]
288 }
289
290 # Check if the device is a wireless device
291 device_is_wireless() {
292 local device=${1}
293
294 [ -d "${SYS_CLASS_NET}/${device}/phy80211" ]
295 }
296
297 device_get_phy() {
298 local device="${1}"
299
300 if device_is_wireless "${device}"; then
301 print "$(<${SYS_CLASS_NET}/${device}/phy80211/name)"
302 return ${EXIT_OK}
303 fi
304
305 return ${EXIT_ERROR}
306 }
307
308 device_is_phy() {
309 phy_exists $@
310 }
311
312 device_is_serial() {
313 serial_exists $@
314 }
315
316 # Returns true if a device is a tun device
317 device_is_tun() {
318 local device="${1}"
319
320 [ -e "${SYS_CLASS_NET}/${device}/tun_flags" ]
321 }
322
323 # Check if the device is a physical network interface
324 device_is_ethernet() {
325 local device=${1}
326
327 device_is_ethernet_compatible "${device}" || \
328 return ${EXIT_ERROR}
329
330 device_is_loopback ${device} && \
331 return ${EXIT_ERROR}
332
333 device_is_bonding ${device} && \
334 return ${EXIT_ERROR}
335
336 device_is_bridge ${device} && \
337 return ${EXIT_ERROR}
338
339 device_is_ppp ${device} && \
340 return ${EXIT_ERROR}
341
342 device_is_vlan ${device} && \
343 return ${EXIT_ERROR}
344
345 device_is_dummy ${device} && \
346 return ${EXIT_ERROR}
347
348 device_is_tun ${device} && \
349 return ${EXIT_ERROR}
350
351 return ${EXIT_OK}
352 }
353
354 # Get the device type
355 device_get_type() {
356 local device=${1}
357
358 # If the device does not exist (happens on udev remove events),
359 # we do not bother to run all checks.
360 if ! device_exists "${device}"; then
361 echo "unknown"
362
363 elif device_is_vlan ${device}; then
364 echo "vlan"
365
366 elif device_is_bonding ${device}; then
367 echo "bonding"
368
369 elif device_is_bridge ${device}; then
370 echo "bridge"
371
372 elif device_is_ppp ${device}; then
373 echo "ppp"
374
375 elif device_is_batman_adv ${device}; then
376 echo "batman-adv"
377
378 elif device_is_loopback ${device}; then
379 echo "loopback"
380
381 elif device_is_wireless_adhoc ${device}; then
382 echo "wireless-adhoc"
383
384 elif device_is_wireless ${device}; then
385 echo "wireless"
386
387 elif device_is_dummy ${device}; then
388 echo "dummy"
389
390 elif device_is_tun ${device}; then
391 echo "tun"
392
393 elif device_is_ethernet ${device}; then
394 echo "ethernet"
395
396 elif device_is_serial ${device}; then
397 echo "serial"
398
399 elif device_is_phy ${device}; then
400 echo "phy"
401
402 else
403 echo "unknown"
404 fi
405 }
406
407 device_is_ethernet_compatible() {
408 local device="${1}"
409
410 # /sys/class/net/*/type must equal 1 for ethernet compatible devices
411 local type="$(__device_get_file "${device}" "type")"
412 [[ "${type}" = "1" ]]
413 }
414
415 device_get_status() {
416 local device=${1}
417 assert isset device
418
419 local status=${STATUS_DOWN}
420
421 if device_is_up ${device}; then
422 status=${STATUS_UP}
423
424 if ! device_has_carrier ${device}; then
425 status=${STATUS_NOCARRIER}
426 fi
427 fi
428
429 echo "${status}"
430 }
431
432 device_get_address() {
433 local device=${1}
434
435 cat ${SYS_CLASS_NET}/${device}/address 2>/dev/null
436 }
437
438 device_set_address() {
439 assert [ $# -eq 2 ]
440
441 local device="${1}"
442 local addr="${2}"
443
444 if ! device_exists "${device}"; then
445 error "Device '${device}' does not exist."
446 return ${EXIT_ERROR}
447 fi
448
449 # Do nothing if the address has not changed
450 local old_addr="$(device_get_address "${device}")"
451 if [ -n "${old_addr}" -a "${addr}" = "${old_addr}" ]; then
452 return ${EXIT_OK}
453 fi
454
455 log DEBUG "Setting address of '${device}' from '${old_addr}' to '${addr}'"
456
457 local up
458 if device_is_up "${device}"; then
459 device_set_down "${device}"
460 up=1
461 fi
462
463 ip link set "${device}" address "${addr}"
464 local ret=$?
465
466 if [ "${up}" = "1" ]; then
467 device_set_up "${device}"
468 fi
469
470 if [ "${ret}" != "0" ]; then
471 error_log "Could not set address '${addr}' on device '${device}'"
472 fi
473
474 return ${ret}
475 }
476
477 device_get() {
478 local device
479 local devices
480
481 for device in ${SYS_CLASS_NET}/*; do
482 device=$(basename ${device})
483
484 # bonding_masters is no device
485 [ "${device}" = "bonding_masters" ] && continue
486
487 devices="${devices} ${device}"
488 done
489
490 echo ${devices}
491 return ${EXIT_OK}
492 }
493
494 devices_get_all() {
495 device_get
496 }
497
498 # Check if a device has a cable plugged in
499 device_has_carrier() {
500 local device=${1}
501 assert isset device
502
503 local carrier=$(__device_get_file ${device} carrier)
504 [ "${carrier}" = "1" ]
505 }
506
507 device_is_promisc() {
508 local device=${1}
509
510 device_has_flag ${device} 0x200
511 }
512
513 device_set_promisc() {
514 local device=${1}
515 local state=${2}
516
517 assert device_exists ${device}
518 assert isset state
519 assert isoneof state on off
520
521 ip link set ${device} promisc ${state}
522 }
523
524 # Check if the device is free
525 device_is_free() {
526 ! device_is_used $@
527 }
528
529 # Check if the device is used
530 device_is_used() {
531 local device=${1}
532
533 device_has_vlans ${device} && \
534 return ${EXIT_OK}
535 device_is_bonded ${device} && \
536 return ${EXIT_OK}
537 device_is_bridge_attached ${device} && \
538 return ${EXIT_OK}
539
540 return ${EXIT_ERROR}
541 }
542
543 # Give the device a new name
544 device_set_name() {
545 local source=$1
546 local destination=${2}
547
548 # Check if devices exists
549 if ! device_exists ${source} || device_exists ${destination}; then
550 return 4
551 fi
552
553 local up
554 if device_is_up ${source}; then
555 ip link set ${source} down
556 up=1
557 fi
558
559 ip link set ${source} name ${destination}
560
561 if [ "${up}" = "1" ]; then
562 ip link set ${destination} up
563 fi
564 }
565
566 # Set device up
567 device_set_up() {
568 assert [ $# -eq 1 ]
569
570 local device=${1}
571
572 # Do nothing if device is already up
573 device_is_up ${device} && return ${EXIT_OK}
574
575 device_set_parent_up ${device}
576
577 log DEBUG "Setting up device '${device}'"
578
579 if ! cmd ip link set ${device} up; then
580 return ${EXIT_ERROR}
581 fi
582
583 # Set SMP affinity
584 if interrupt_use_smp_affinity; then
585 device_auto_configure_smp_affinity "${port}"
586 fi
587
588 return ${EXIT_OK}
589 }
590
591 device_set_parent_up() {
592 local device=${1}
593 local parent
594
595 if device_is_vlan ${device}; then
596 parent=$(vlan_get_parent ${device})
597
598 device_is_up ${parent} && return ${EXIT_OK}
599
600 log DEBUG "Setting up parent device '${parent}' of '${device}'"
601
602 device_set_up ${parent}
603 return $?
604 fi
605
606 return ${EXIT_OK}
607 }
608
609 # Set device down
610 device_set_down() {
611 assert [ $# -eq 1 ]
612
613 local device=${1}
614 local ret=${EXIT_OK}
615
616 if device_is_up ${device}; then
617 log DEBUG "Tearing down device '${device}'"
618
619 cmd ip link set ${device} down
620 ret=$?
621 fi
622
623 device_set_parent_down ${device}
624
625 return ${ret}
626 }
627
628 device_set_parent_down() {
629 local device=${1}
630 local parent
631
632 if device_is_vlan ${device}; then
633 parent=$(vlan_get_parent ${device})
634
635 device_is_up ${parent} || return ${EXIT_OK}
636
637 if device_is_free ${parent}; then
638 log DEBUG "Tearing down parent device '${parent}' of '${device}'"
639
640 device_set_down ${parent}
641 fi
642 fi
643
644 return ${EXIT_OK}
645 }
646
647 device_get_mtu() {
648 local device=${1}
649
650 if ! device_exists ${device}; then
651 error "Device '${device}' does not exist."
652 return ${EXIT_ERROR}
653 fi
654
655 echo $(<${SYS_CLASS_NET}/${device}/mtu)
656 }
657
658 # Set mtu to a device
659 device_set_mtu() {
660 local device=${1}
661 local mtu=${2}
662
663 if ! device_exists ${device}; then
664 error "Device '${device}' does not exist."
665 return ${EXIT_ERROR}
666 fi
667
668 local oldmtu=$(device_get_mtu ${device})
669
670 if [ "${oldmtu}" = "${mtu}" ]; then
671 # No need to set mtu.
672 return ${EXIT_OK}
673 fi
674
675 log INFO "Setting mtu of '${device}' to '${mtu}' - was ${oldmtu}."
676
677 local up
678 if device_is_up ${device}; then
679 device_set_down ${device}
680 up=1
681 fi
682
683 ip link set ${device} mtu ${mtu}
684 local ret=$?
685
686 if [ "${up}" = "1" ]; then
687 device_set_up ${device}
688 fi
689
690 if [ "${ret}" != "0" ]; then
691 error_log "Could not set mtu '${mtu}' on device '${device}'."
692 fi
693
694 return ${ret}
695 }
696
697 device_adjust_mtu() {
698 assert [ $# -eq 2 ]
699
700 local device="${1}"
701 local other_device="${2}"
702
703 local mtu="$(device_get_mtu "${other_device}")"
704 device_set_mtu "${device}" "${mtu}"
705 }
706
707 device_discover() {
708 local device=${1}
709
710 log INFO "Running discovery process on device '${device}'."
711
712 local hook
713 for hook in $(hook_zone_get_all); do
714 hook_zone_exec ${hook} discover ${device}
715 done
716 }
717
718 device_identify() {
719 assert [ $# -ge 1 ]
720
721 local device="${1}"
722
723 # Flash for ten seconds by default
724 local seconds="10"
725
726 # Run in background?
727 local background="false"
728
729 local arg
730 while read arg; do
731 case "${arg}" in
732 --background)
733 background="true"
734 ;;
735 --seconds=*)
736 seconds="$(cli_get_val "${arg}")"
737 ;;
738 esac
739 done <<< "$(args $@)"
740
741 assert isinteger seconds
742
743 if ! device_exists "${device}"; then
744 log ERROR "Cannot identify device ${device}: Does not exist"
745 return ${EXIT_ERROR}
746 fi
747
748 if ! device_is_ethernet "${device}"; then
749 log DEBUG "Cannot identify device ${device}: Not an ethernet device"
750 return ${EXIT_NOT_SUPPORTED}
751 fi
752
753 log DEBUG "Identifying device ${device}"
754
755 local command="ethtool --identify ${device} ${seconds}"
756 local ret=0
757
758 if enabled background; then
759 cmd_background "${command}"
760 else
761 cmd_quiet "${command}"
762 ret=$?
763 fi
764
765 return ${ret}
766 }
767
768 device_has_ip() {
769 local device=${1}
770 local addr=${2}
771
772 assert isset addr
773 assert device_exists ${device}
774
775 # IPv6 addresses must be fully imploded
776 local protocol=$(ip_detect_protocol ${addr})
777 case "${protocol}" in
778 ipv6)
779 addr=$(ipv6_format "${addr}")
780 ;;
781 esac
782
783 listmatch ${addr} $(device_get_addresses ${device})
784 }
785
786 device_get_addresses() {
787 local device=${1}
788
789 assert device_exists ${device}
790
791 local prot
792 local addr
793 local line
794 ip addr show ${device} | \
795 while read prot addr line; do
796 [ "${prot:0:4}" = "inet" ] && echo "${addr}"
797 done
798 }
799
800 __device_get_file() {
801 local device=${1}
802 local file=${2}
803
804 assert isset device
805 assert isset file
806
807 local path="${SYS_CLASS_NET}/${device}/${file}"
808 [ -r "${path}" ] || return ${EXIT_ERROR}
809
810 echo "$(<${path})"
811 }
812
813 __device_set_file() {
814 assert [ $# -eq 3 ]
815
816 local device="${1}"
817 local file="${2}"
818 local value="${3}"
819
820 local path="${SYS_CLASS_NET}/${device}/${file}"
821 if [ ! -w "${path}" ]; then
822 log DEBUG "Cannot write to file '${file}' (${value})"
823 return ${EXIT_ERROR}
824 fi
825
826 echo "${value}" > "${path}"
827 }
828
829 device_get_rx_bytes() {
830 local device=${1}
831
832 __device_get_file ${device} statistics/rx_bytes
833 }
834
835 device_get_tx_bytes() {
836 local device=${1}
837
838 __device_get_file ${device} statistics/tx_bytes
839 }
840
841 device_get_rx_packets() {
842 local device=${1}
843
844 __device_get_file ${device} statistics/rx_packets
845 }
846
847 device_get_tx_packets() {
848 local device=${1}
849
850 __device_get_file ${device} statistics/tx_packets
851 }
852
853 device_get_rx_errors() {
854 local device=${1}
855
856 __device_get_file ${device} statistics/rx_errors
857 }
858
859 device_get_tx_errors() {
860 local device=${1}
861
862 __device_get_file ${device} statistics/tx_errors
863 }
864
865 device_get_speed() {
866 local device=${1}
867
868 __device_get_file ${device} speed
869 }
870
871 device_get_duplex() {
872 local device=${1}
873
874 __device_get_file ${device} duplex
875 }
876
877 device_get_link_string() {
878 local device="${1}"
879 assert isset device
880
881 local s
882
883 local speed="$(device_get_speed "${device}")"
884 if isset speed; then
885 list_append s "${speed} MBit/s"
886 fi
887
888 local duplex="$(device_get_duplex "${device}")"
889 if isset duplex; then
890 list_append s "${duplex} duplex"
891 fi
892
893 print "${s}"
894 }
895
896 device_auto_configure_smp_affinity() {
897 assert [ $# -eq 1 ]
898
899 local device=${1}
900
901 if lock_acquire "smp-affinity"; then
902 device_set_smp_affinity "${port}" auto
903
904 lock_release "smp-affinity"
905 fi
906 }
907
908 device_set_smp_affinity() {
909 assert [ $# -eq 2 ]
910
911 local device=${1}
912 local mode=${2}
913
914 # mode can be auto which will automatically try to find
915 # the least busy processor, or an integer for the desired
916 # processor that should handle this device
917
918 local num_processors=$(system_get_processors)
919
920 if [ "${mode}" = "auto" ]; then
921 local processor=$(interrupt_choose_least_busy_processor)
922 else
923 assert isinteger mode
924 local processor=${mode}
925
926 if [ ${processor} -gt ${num_processors} ]; then
927 log ERROR "Processor ${processor} does not exist"
928 return ${EXIT_ERROR}
929 fi
930 fi
931
932 local interrupts=$(interrupts_for_device ${device})
933 if ! isset interrupts; then
934 log DEBUG "${device} has no interrupts. Not changing SMP affinity"
935 return ${EXIT_OK}
936 fi
937
938 # Set SMP affinity
939 local interrupt
940 for interrupt in ${interrupts}; do
941 interrupt_set_smp_affinity ${interrupt} ${processor}
942 done
943
944 # Find all queues and assign them to the next processor
945 local queue
946 for queue in $(device_get_queues ${device}); do
947 case "${queue}" in
948 # Only handle receive queues
949 rx-*)
950 for interrupt in $(interrupts_for_device_queue ${device} ${queue}); do
951 interrupt_set_smp_affinity ${interrupt} ${processor}
952 done
953
954 device_queue_set_smp_affinity ${device} ${queue} ${processor}
955 ;;
956
957 # Ignore the rest
958 *)
959 continue
960 ;;
961 esac
962
963 # Get the next available processor if in auto mode
964 [ "${mode}" = "auto" ] && processor=$(system_get_next_processor ${processor})
965 done
966
967 return ${EXIT_OK}
968 }
969
970 device_get_queues() {
971 assert [ $# -eq 1 ]
972
973 local device=${1}
974
975 local queue
976 for queue in ${SYS_CLASS_NET}/${device}/queues/*; do
977 basename "${queue}"
978 done
979 }
980
981 device_queue_set_smp_affinity() {
982 assert [ $# -eq 3 ]
983
984 local device=${1}
985 local queue=${2}
986 local processor=${3}
987
988 local path="${SYS_CLASS_NET}/${device}/queues/${queue}/rps_cpus"
989 assert [ -w "${path}" ]
990
991 log DEBUG "Setting SMP affinity of ${device} (${queue}) to processor ${processor}"
992
993 __processor_id_to_bitmap ${processor} > ${path}
994 }