| .. | .. |
|---|
| 1 | 1 | # bpftool(8) bash completion -*- shell-script -*- |
|---|
| 2 | 2 | # |
|---|
| 3 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) |
|---|
| 3 | 4 | # Copyright (C) 2017-2018 Netronome Systems, Inc. |
|---|
| 4 | | -# |
|---|
| 5 | | -# This software is dual licensed under the GNU General License |
|---|
| 6 | | -# Version 2, June 1991 as shown in the file COPYING in the top-level |
|---|
| 7 | | -# directory of this source tree or the BSD 2-Clause License provided |
|---|
| 8 | | -# below. You have the option to license this software under the |
|---|
| 9 | | -# complete terms of either license. |
|---|
| 10 | | -# |
|---|
| 11 | | -# The BSD 2-Clause License: |
|---|
| 12 | | -# |
|---|
| 13 | | -# Redistribution and use in source and binary forms, with or |
|---|
| 14 | | -# without modification, are permitted provided that the following |
|---|
| 15 | | -# conditions are met: |
|---|
| 16 | | -# |
|---|
| 17 | | -# 1. Redistributions of source code must retain the above |
|---|
| 18 | | -# copyright notice, this list of conditions and the following |
|---|
| 19 | | -# disclaimer. |
|---|
| 20 | | -# |
|---|
| 21 | | -# 2. Redistributions in binary form must reproduce the above |
|---|
| 22 | | -# copyright notice, this list of conditions and the following |
|---|
| 23 | | -# disclaimer in the documentation and/or other materials |
|---|
| 24 | | -# provided with the distribution. |
|---|
| 25 | | -# |
|---|
| 26 | | -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|---|
| 27 | | -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|---|
| 28 | | -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|---|
| 29 | | -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
|---|
| 30 | | -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
|---|
| 31 | | -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|---|
| 32 | | -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|---|
| 33 | | -# SOFTWARE. |
|---|
| 34 | 5 | # |
|---|
| 35 | 6 | # Author: Quentin Monnet <quentin.monnet@netronome.com> |
|---|
| 36 | 7 | |
|---|
| .. | .. |
|---|
| 79 | 50 | command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ) ) |
|---|
| 80 | 51 | } |
|---|
| 81 | 52 | |
|---|
| 82 | | -_bpftool_get_perf_map_ids() |
|---|
| 53 | +# Takes map type and adds matching map ids to the list of suggestions. |
|---|
| 54 | +_bpftool_get_map_ids_for_type() |
|---|
| 83 | 55 | { |
|---|
| 56 | + local type="$1" |
|---|
| 84 | 57 | COMPREPLY+=( $( compgen -W "$( bpftool -jp map 2>&1 | \ |
|---|
| 85 | | - command grep -C2 perf_event_array | \ |
|---|
| 58 | + command grep -C2 "$type" | \ |
|---|
| 86 | 59 | command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ) ) |
|---|
| 87 | 60 | } |
|---|
| 88 | 61 | |
|---|
| 62 | +_bpftool_get_map_names() |
|---|
| 63 | +{ |
|---|
| 64 | + COMPREPLY+=( $( compgen -W "$( bpftool -jp map 2>&1 | \ |
|---|
| 65 | + command sed -n 's/.*"name": \(.*\),$/\1/p' )" -- "$cur" ) ) |
|---|
| 66 | +} |
|---|
| 67 | + |
|---|
| 68 | +# Takes map type and adds matching map names to the list of suggestions. |
|---|
| 69 | +_bpftool_get_map_names_for_type() |
|---|
| 70 | +{ |
|---|
| 71 | + local type="$1" |
|---|
| 72 | + COMPREPLY+=( $( compgen -W "$( bpftool -jp map 2>&1 | \ |
|---|
| 73 | + command grep -C2 "$type" | \ |
|---|
| 74 | + command sed -n 's/.*"name": \(.*\),$/\1/p' )" -- "$cur" ) ) |
|---|
| 75 | +} |
|---|
| 89 | 76 | |
|---|
| 90 | 77 | _bpftool_get_prog_ids() |
|---|
| 91 | 78 | { |
|---|
| .. | .. |
|---|
| 97 | 84 | { |
|---|
| 98 | 85 | COMPREPLY+=( $( compgen -W "$( bpftool -jp prog 2>&1 | \ |
|---|
| 99 | 86 | command sed -n 's/.*"tag": "\(.*\)",$/\1/p' )" -- "$cur" ) ) |
|---|
| 87 | +} |
|---|
| 88 | + |
|---|
| 89 | +_bpftool_get_prog_names() |
|---|
| 90 | +{ |
|---|
| 91 | + COMPREPLY+=( $( compgen -W "$( bpftool -jp prog 2>&1 | \ |
|---|
| 92 | + command sed -n 's/.*"name": "\(.*\)",$/\1/p' )" -- "$cur" ) ) |
|---|
| 93 | +} |
|---|
| 94 | + |
|---|
| 95 | +_bpftool_get_btf_ids() |
|---|
| 96 | +{ |
|---|
| 97 | + COMPREPLY+=( $( compgen -W "$( bpftool -jp btf 2>&1 | \ |
|---|
| 98 | + command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ) ) |
|---|
| 99 | +} |
|---|
| 100 | + |
|---|
| 101 | +_bpftool_get_link_ids() |
|---|
| 102 | +{ |
|---|
| 103 | + COMPREPLY+=( $( compgen -W "$( bpftool -jp link 2>&1 | \ |
|---|
| 104 | + command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ) ) |
|---|
| 100 | 105 | } |
|---|
| 101 | 106 | |
|---|
| 102 | 107 | _bpftool_get_obj_map_names() |
|---|
| .. | .. |
|---|
| 128 | 133 | "$cur" ) ) |
|---|
| 129 | 134 | } |
|---|
| 130 | 135 | |
|---|
| 131 | | -# For bpftool map update: retrieve type of the map to update. |
|---|
| 132 | | -_bpftool_map_update_map_type() |
|---|
| 136 | +# Retrieve type of the map that we are operating on. |
|---|
| 137 | +_bpftool_map_guess_map_type() |
|---|
| 133 | 138 | { |
|---|
| 134 | 139 | local keyword ref |
|---|
| 135 | 140 | for (( idx=3; idx < ${#words[@]}-1; idx++ )); do |
|---|
| 136 | | - if [[ ${words[$((idx-2))]} == "update" ]]; then |
|---|
| 137 | | - keyword=${words[$((idx-1))]} |
|---|
| 138 | | - ref=${words[$((idx))]} |
|---|
| 139 | | - fi |
|---|
| 141 | + case "${words[$((idx-2))]}" in |
|---|
| 142 | + lookup|update) |
|---|
| 143 | + keyword=${words[$((idx-1))]} |
|---|
| 144 | + ref=${words[$((idx))]} |
|---|
| 145 | + ;; |
|---|
| 146 | + push) |
|---|
| 147 | + printf "stack" |
|---|
| 148 | + return 0 |
|---|
| 149 | + ;; |
|---|
| 150 | + enqueue) |
|---|
| 151 | + printf "queue" |
|---|
| 152 | + return 0 |
|---|
| 153 | + ;; |
|---|
| 154 | + esac |
|---|
| 140 | 155 | done |
|---|
| 141 | 156 | [[ -z $ref ]] && return 0 |
|---|
| 142 | 157 | |
|---|
| .. | .. |
|---|
| 148 | 163 | |
|---|
| 149 | 164 | _bpftool_map_update_get_id() |
|---|
| 150 | 165 | { |
|---|
| 166 | + local command="$1" |
|---|
| 167 | + |
|---|
| 151 | 168 | # Is it the map to update, or a map to insert into the map to update? |
|---|
| 152 | 169 | # Search for "value" keyword. |
|---|
| 153 | 170 | local idx value |
|---|
| .. | .. |
|---|
| 157 | 174 | break |
|---|
| 158 | 175 | fi |
|---|
| 159 | 176 | done |
|---|
| 160 | | - [[ $value -eq 0 ]] && _bpftool_get_map_ids && return 0 |
|---|
| 177 | + if [[ $value -eq 0 ]]; then |
|---|
| 178 | + case "$command" in |
|---|
| 179 | + push) |
|---|
| 180 | + _bpftool_get_map_ids_for_type stack |
|---|
| 181 | + ;; |
|---|
| 182 | + enqueue) |
|---|
| 183 | + _bpftool_get_map_ids_for_type queue |
|---|
| 184 | + ;; |
|---|
| 185 | + *) |
|---|
| 186 | + _bpftool_get_map_ids |
|---|
| 187 | + ;; |
|---|
| 188 | + esac |
|---|
| 189 | + return 0 |
|---|
| 190 | + fi |
|---|
| 161 | 191 | |
|---|
| 162 | 192 | # Id to complete is for a value. It can be either prog id or map id. This |
|---|
| 163 | 193 | # depends on the type of the map to update. |
|---|
| 164 | | - local type=$(_bpftool_map_update_map_type) |
|---|
| 194 | + local type=$(_bpftool_map_guess_map_type) |
|---|
| 165 | 195 | case $type in |
|---|
| 166 | 196 | array_of_maps|hash_of_maps) |
|---|
| 167 | 197 | _bpftool_get_map_ids |
|---|
| .. | .. |
|---|
| 177 | 207 | esac |
|---|
| 178 | 208 | } |
|---|
| 179 | 209 | |
|---|
| 210 | +_bpftool_map_update_get_name() |
|---|
| 211 | +{ |
|---|
| 212 | + local command="$1" |
|---|
| 213 | + |
|---|
| 214 | + # Is it the map to update, or a map to insert into the map to update? |
|---|
| 215 | + # Search for "value" keyword. |
|---|
| 216 | + local idx value |
|---|
| 217 | + for (( idx=7; idx < ${#words[@]}-1; idx++ )); do |
|---|
| 218 | + if [[ ${words[idx]} == "value" ]]; then |
|---|
| 219 | + value=1 |
|---|
| 220 | + break |
|---|
| 221 | + fi |
|---|
| 222 | + done |
|---|
| 223 | + if [[ $value -eq 0 ]]; then |
|---|
| 224 | + case "$command" in |
|---|
| 225 | + push) |
|---|
| 226 | + _bpftool_get_map_names_for_type stack |
|---|
| 227 | + ;; |
|---|
| 228 | + enqueue) |
|---|
| 229 | + _bpftool_get_map_names_for_type queue |
|---|
| 230 | + ;; |
|---|
| 231 | + *) |
|---|
| 232 | + _bpftool_get_map_names |
|---|
| 233 | + ;; |
|---|
| 234 | + esac |
|---|
| 235 | + return 0 |
|---|
| 236 | + fi |
|---|
| 237 | + |
|---|
| 238 | + # Name to complete is for a value. It can be either prog name or map name. This |
|---|
| 239 | + # depends on the type of the map to update. |
|---|
| 240 | + local type=$(_bpftool_map_guess_map_type) |
|---|
| 241 | + case $type in |
|---|
| 242 | + array_of_maps|hash_of_maps) |
|---|
| 243 | + _bpftool_get_map_names |
|---|
| 244 | + return 0 |
|---|
| 245 | + ;; |
|---|
| 246 | + prog_array) |
|---|
| 247 | + _bpftool_get_prog_names |
|---|
| 248 | + return 0 |
|---|
| 249 | + ;; |
|---|
| 250 | + *) |
|---|
| 251 | + return 0 |
|---|
| 252 | + ;; |
|---|
| 253 | + esac |
|---|
| 254 | +} |
|---|
| 255 | + |
|---|
| 180 | 256 | _bpftool() |
|---|
| 181 | 257 | { |
|---|
| 182 | 258 | local cur prev words objword |
|---|
| .. | .. |
|---|
| 184 | 260 | |
|---|
| 185 | 261 | # Deal with options |
|---|
| 186 | 262 | if [[ ${words[cword]} == -* ]]; then |
|---|
| 187 | | - local c='--version --json --pretty --bpffs' |
|---|
| 263 | + local c='--version --json --pretty --bpffs --mapcompat --debug' |
|---|
| 188 | 264 | COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) |
|---|
| 189 | 265 | return 0 |
|---|
| 190 | 266 | fi |
|---|
| 191 | 267 | |
|---|
| 192 | 268 | # Deal with simplest keywords |
|---|
| 193 | 269 | case $prev in |
|---|
| 194 | | - help|hex|opcodes|visual) |
|---|
| 270 | + help|hex|opcodes|visual|linum) |
|---|
| 195 | 271 | return 0 |
|---|
| 196 | 272 | ;; |
|---|
| 197 | 273 | tag) |
|---|
| 198 | 274 | _bpftool_get_prog_tags |
|---|
| 275 | + return 0 |
|---|
| 276 | + ;; |
|---|
| 277 | + dev) |
|---|
| 278 | + _sysfs_get_netdevs |
|---|
| 199 | 279 | return 0 |
|---|
| 200 | 280 | ;; |
|---|
| 201 | 281 | file|pinned) |
|---|
| .. | .. |
|---|
| 220 | 300 | done |
|---|
| 221 | 301 | cur=${words[cword]} |
|---|
| 222 | 302 | prev=${words[cword - 1]} |
|---|
| 303 | + pprev=${words[cword - 2]} |
|---|
| 223 | 304 | |
|---|
| 224 | 305 | local object=${words[1]} command=${words[2]} |
|---|
| 225 | 306 | |
|---|
| .. | .. |
|---|
| 243 | 324 | # Completion depends on object and command in use |
|---|
| 244 | 325 | case $object in |
|---|
| 245 | 326 | prog) |
|---|
| 246 | | - if [[ $command != "load" ]]; then |
|---|
| 247 | | - case $prev in |
|---|
| 248 | | - id) |
|---|
| 249 | | - _bpftool_get_prog_ids |
|---|
| 250 | | - return 0 |
|---|
| 251 | | - ;; |
|---|
| 252 | | - esac |
|---|
| 253 | | - fi |
|---|
| 327 | + # Complete id and name, only for subcommands that use prog (but no |
|---|
| 328 | + # map) ids/names. |
|---|
| 329 | + case $command in |
|---|
| 330 | + show|list|dump|pin) |
|---|
| 331 | + case $prev in |
|---|
| 332 | + id) |
|---|
| 333 | + _bpftool_get_prog_ids |
|---|
| 334 | + return 0 |
|---|
| 335 | + ;; |
|---|
| 336 | + name) |
|---|
| 337 | + _bpftool_get_prog_names |
|---|
| 338 | + return 0 |
|---|
| 339 | + ;; |
|---|
| 340 | + esac |
|---|
| 341 | + ;; |
|---|
| 342 | + esac |
|---|
| 254 | 343 | |
|---|
| 255 | | - local PROG_TYPE='id pinned tag' |
|---|
| 344 | + local PROG_TYPE='id pinned tag name' |
|---|
| 345 | + local MAP_TYPE='id pinned name' |
|---|
| 346 | + local METRIC_TYPE='cycles instructions l1d_loads llc_misses' |
|---|
| 256 | 347 | case $command in |
|---|
| 257 | 348 | show|list) |
|---|
| 258 | 349 | [[ $prev != "$command" ]] && return 0 |
|---|
| .. | .. |
|---|
| 271 | 362 | "$cur" ) ) |
|---|
| 272 | 363 | return 0 |
|---|
| 273 | 364 | ;; |
|---|
| 274 | | - *) |
|---|
| 275 | | - _bpftool_once_attr 'file' |
|---|
| 276 | | - if _bpftool_search_list 'xlated'; then |
|---|
| 277 | | - COMPREPLY+=( $( compgen -W 'opcodes visual' -- \ |
|---|
| 278 | | - "$cur" ) ) |
|---|
| 279 | | - else |
|---|
| 280 | | - COMPREPLY+=( $( compgen -W 'opcodes' -- \ |
|---|
| 281 | | - "$cur" ) ) |
|---|
| 282 | | - fi |
|---|
| 283 | | - return 0 |
|---|
| 284 | | - ;; |
|---|
| 365 | + *) |
|---|
| 366 | + _bpftool_once_attr 'file' |
|---|
| 367 | + if _bpftool_search_list 'xlated'; then |
|---|
| 368 | + COMPREPLY+=( $( compgen -W 'opcodes visual linum' -- \ |
|---|
| 369 | + "$cur" ) ) |
|---|
| 370 | + else |
|---|
| 371 | + COMPREPLY+=( $( compgen -W 'opcodes linum' -- \ |
|---|
| 372 | + "$cur" ) ) |
|---|
| 373 | + fi |
|---|
| 374 | + return 0 |
|---|
| 375 | + ;; |
|---|
| 285 | 376 | esac |
|---|
| 286 | 377 | ;; |
|---|
| 287 | 378 | pin) |
|---|
| .. | .. |
|---|
| 292 | 383 | fi |
|---|
| 293 | 384 | return 0 |
|---|
| 294 | 385 | ;; |
|---|
| 295 | | - load) |
|---|
| 386 | + attach|detach) |
|---|
| 387 | + case $cword in |
|---|
| 388 | + 3) |
|---|
| 389 | + COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) ) |
|---|
| 390 | + return 0 |
|---|
| 391 | + ;; |
|---|
| 392 | + 4) |
|---|
| 393 | + case $prev in |
|---|
| 394 | + id) |
|---|
| 395 | + _bpftool_get_prog_ids |
|---|
| 396 | + ;; |
|---|
| 397 | + name) |
|---|
| 398 | + _bpftool_get_prog_names |
|---|
| 399 | + ;; |
|---|
| 400 | + pinned) |
|---|
| 401 | + _filedir |
|---|
| 402 | + ;; |
|---|
| 403 | + esac |
|---|
| 404 | + return 0 |
|---|
| 405 | + ;; |
|---|
| 406 | + 5) |
|---|
| 407 | + COMPREPLY=( $( compgen -W 'msg_verdict stream_verdict \ |
|---|
| 408 | + stream_parser flow_dissector' -- "$cur" ) ) |
|---|
| 409 | + return 0 |
|---|
| 410 | + ;; |
|---|
| 411 | + 6) |
|---|
| 412 | + COMPREPLY=( $( compgen -W "$MAP_TYPE" -- "$cur" ) ) |
|---|
| 413 | + return 0 |
|---|
| 414 | + ;; |
|---|
| 415 | + 7) |
|---|
| 416 | + case $prev in |
|---|
| 417 | + id) |
|---|
| 418 | + _bpftool_get_map_ids |
|---|
| 419 | + ;; |
|---|
| 420 | + name) |
|---|
| 421 | + _bpftool_get_map_names |
|---|
| 422 | + ;; |
|---|
| 423 | + pinned) |
|---|
| 424 | + _filedir |
|---|
| 425 | + ;; |
|---|
| 426 | + esac |
|---|
| 427 | + return 0 |
|---|
| 428 | + ;; |
|---|
| 429 | + esac |
|---|
| 430 | + ;; |
|---|
| 431 | + load|loadall) |
|---|
| 296 | 432 | local obj |
|---|
| 433 | + |
|---|
| 434 | + # Propose "load/loadall" to complete "bpftool prog load", |
|---|
| 435 | + # or bash tries to complete "load" as a filename below. |
|---|
| 436 | + if [[ ${#words[@]} -eq 3 ]]; then |
|---|
| 437 | + COMPREPLY=( $( compgen -W "load loadall" -- "$cur" ) ) |
|---|
| 438 | + return 0 |
|---|
| 439 | + fi |
|---|
| 297 | 440 | |
|---|
| 298 | 441 | if [[ ${#words[@]} -lt 6 ]]; then |
|---|
| 299 | 442 | _filedir |
|---|
| .. | .. |
|---|
| 321 | 464 | |
|---|
| 322 | 465 | case $prev in |
|---|
| 323 | 466 | type) |
|---|
| 324 | | - COMPREPLY=( $( compgen -W "socket kprobe kretprobe classifier action tracepoint raw_tracepoint xdp perf_event cgroup/skb cgroup/sock cgroup/dev lwt_in lwt_out lwt_xmit lwt_seg6local sockops sk_skb sk_msg lirc_mode2 cgroup/bind4 cgroup/bind6 cgroup/connect4 cgroup/connect6 cgroup/sendmsg4 cgroup/sendmsg6 cgroup/post_bind4 cgroup/post_bind6" -- \ |
|---|
| 467 | + COMPREPLY=( $( compgen -W "socket kprobe \ |
|---|
| 468 | + kretprobe classifier flow_dissector \ |
|---|
| 469 | + action tracepoint raw_tracepoint \ |
|---|
| 470 | + xdp perf_event cgroup/skb cgroup/sock \ |
|---|
| 471 | + cgroup/dev lwt_in lwt_out lwt_xmit \ |
|---|
| 472 | + lwt_seg6local sockops sk_skb sk_msg \ |
|---|
| 473 | + lirc_mode2 cgroup/bind4 cgroup/bind6 \ |
|---|
| 474 | + cgroup/connect4 cgroup/connect6 \ |
|---|
| 475 | + cgroup/getpeername4 cgroup/getpeername6 \ |
|---|
| 476 | + cgroup/getsockname4 cgroup/getsockname6 \ |
|---|
| 477 | + cgroup/sendmsg4 cgroup/sendmsg6 \ |
|---|
| 478 | + cgroup/recvmsg4 cgroup/recvmsg6 \ |
|---|
| 479 | + cgroup/post_bind4 cgroup/post_bind6 \ |
|---|
| 480 | + cgroup/sysctl cgroup/getsockopt \ |
|---|
| 481 | + cgroup/setsockopt cgroup/sock_release struct_ops \ |
|---|
| 482 | + fentry fexit freplace sk_lookup" -- \ |
|---|
| 325 | 483 | "$cur" ) ) |
|---|
| 326 | 484 | return 0 |
|---|
| 327 | 485 | ;; |
|---|
| .. | .. |
|---|
| 329 | 487 | _bpftool_get_map_ids |
|---|
| 330 | 488 | return 0 |
|---|
| 331 | 489 | ;; |
|---|
| 332 | | - pinned) |
|---|
| 333 | | - _filedir |
|---|
| 490 | + name) |
|---|
| 491 | + _bpftool_get_map_names |
|---|
| 334 | 492 | return 0 |
|---|
| 335 | 493 | ;; |
|---|
| 336 | | - dev) |
|---|
| 337 | | - _sysfs_get_netdevs |
|---|
| 494 | + pinned|pinmaps) |
|---|
| 495 | + _filedir |
|---|
| 338 | 496 | return 0 |
|---|
| 339 | 497 | ;; |
|---|
| 340 | 498 | *) |
|---|
| 341 | 499 | COMPREPLY=( $( compgen -W "map" -- "$cur" ) ) |
|---|
| 342 | 500 | _bpftool_once_attr 'type' |
|---|
| 343 | 501 | _bpftool_once_attr 'dev' |
|---|
| 502 | + _bpftool_once_attr 'pinmaps' |
|---|
| 503 | + return 0 |
|---|
| 504 | + ;; |
|---|
| 505 | + esac |
|---|
| 506 | + ;; |
|---|
| 507 | + tracelog) |
|---|
| 508 | + return 0 |
|---|
| 509 | + ;; |
|---|
| 510 | + profile) |
|---|
| 511 | + case $cword in |
|---|
| 512 | + 3) |
|---|
| 513 | + COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) ) |
|---|
| 514 | + return 0 |
|---|
| 515 | + ;; |
|---|
| 516 | + 4) |
|---|
| 517 | + case $prev in |
|---|
| 518 | + id) |
|---|
| 519 | + _bpftool_get_prog_ids |
|---|
| 520 | + ;; |
|---|
| 521 | + name) |
|---|
| 522 | + _bpftool_get_prog_names |
|---|
| 523 | + ;; |
|---|
| 524 | + pinned) |
|---|
| 525 | + _filedir |
|---|
| 526 | + ;; |
|---|
| 527 | + esac |
|---|
| 528 | + return 0 |
|---|
| 529 | + ;; |
|---|
| 530 | + 5) |
|---|
| 531 | + COMPREPLY=( $( compgen -W "$METRIC_TYPE duration" -- "$cur" ) ) |
|---|
| 532 | + return 0 |
|---|
| 533 | + ;; |
|---|
| 534 | + 6) |
|---|
| 535 | + case $prev in |
|---|
| 536 | + duration) |
|---|
| 537 | + return 0 |
|---|
| 538 | + ;; |
|---|
| 539 | + *) |
|---|
| 540 | + COMPREPLY=( $( compgen -W "$METRIC_TYPE" -- "$cur" ) ) |
|---|
| 541 | + return 0 |
|---|
| 542 | + ;; |
|---|
| 543 | + esac |
|---|
| 544 | + return 0 |
|---|
| 545 | + ;; |
|---|
| 546 | + *) |
|---|
| 547 | + COMPREPLY=( $( compgen -W "$METRIC_TYPE" -- "$cur" ) ) |
|---|
| 548 | + return 0 |
|---|
| 549 | + ;; |
|---|
| 550 | + esac |
|---|
| 551 | + ;; |
|---|
| 552 | + run) |
|---|
| 553 | + if [[ ${#words[@]} -eq 4 ]]; then |
|---|
| 554 | + COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) ) |
|---|
| 555 | + return 0 |
|---|
| 556 | + fi |
|---|
| 557 | + case $prev in |
|---|
| 558 | + id) |
|---|
| 559 | + _bpftool_get_prog_ids |
|---|
| 560 | + return 0 |
|---|
| 561 | + ;; |
|---|
| 562 | + name) |
|---|
| 563 | + _bpftool_get_prog_names |
|---|
| 564 | + return 0 |
|---|
| 565 | + ;; |
|---|
| 566 | + data_in|data_out|ctx_in|ctx_out) |
|---|
| 567 | + _filedir |
|---|
| 568 | + return 0 |
|---|
| 569 | + ;; |
|---|
| 570 | + repeat|data_size_out|ctx_size_out) |
|---|
| 571 | + return 0 |
|---|
| 572 | + ;; |
|---|
| 573 | + *) |
|---|
| 574 | + _bpftool_once_attr 'data_in data_out data_size_out \ |
|---|
| 575 | + ctx_in ctx_out ctx_size_out repeat' |
|---|
| 344 | 576 | return 0 |
|---|
| 345 | 577 | ;; |
|---|
| 346 | 578 | esac |
|---|
| 347 | 579 | ;; |
|---|
| 348 | 580 | *) |
|---|
| 349 | 581 | [[ $prev == $object ]] && \ |
|---|
| 350 | | - COMPREPLY=( $( compgen -W 'dump help pin load \ |
|---|
| 351 | | - show list' -- "$cur" ) ) |
|---|
| 582 | + COMPREPLY=( $( compgen -W 'dump help pin attach detach \ |
|---|
| 583 | + load loadall show list tracelog run profile' -- "$cur" ) ) |
|---|
| 584 | + ;; |
|---|
| 585 | + esac |
|---|
| 586 | + ;; |
|---|
| 587 | + struct_ops) |
|---|
| 588 | + local STRUCT_OPS_TYPE='id name' |
|---|
| 589 | + case $command in |
|---|
| 590 | + show|list|dump|unregister) |
|---|
| 591 | + case $prev in |
|---|
| 592 | + $command) |
|---|
| 593 | + COMPREPLY=( $( compgen -W "$STRUCT_OPS_TYPE" -- "$cur" ) ) |
|---|
| 594 | + ;; |
|---|
| 595 | + id) |
|---|
| 596 | + _bpftool_get_map_ids_for_type struct_ops |
|---|
| 597 | + ;; |
|---|
| 598 | + name) |
|---|
| 599 | + _bpftool_get_map_names_for_type struct_ops |
|---|
| 600 | + ;; |
|---|
| 601 | + esac |
|---|
| 602 | + return 0 |
|---|
| 603 | + ;; |
|---|
| 604 | + register) |
|---|
| 605 | + _filedir |
|---|
| 606 | + return 0 |
|---|
| 607 | + ;; |
|---|
| 608 | + *) |
|---|
| 609 | + [[ $prev == $object ]] && \ |
|---|
| 610 | + COMPREPLY=( $( compgen -W 'register unregister show list dump help' \ |
|---|
| 611 | + -- "$cur" ) ) |
|---|
| 612 | + ;; |
|---|
| 613 | + esac |
|---|
| 614 | + ;; |
|---|
| 615 | + iter) |
|---|
| 616 | + case $command in |
|---|
| 617 | + pin) |
|---|
| 618 | + case $prev in |
|---|
| 619 | + $command) |
|---|
| 620 | + _filedir |
|---|
| 621 | + ;; |
|---|
| 622 | + id) |
|---|
| 623 | + _bpftool_get_map_ids |
|---|
| 624 | + ;; |
|---|
| 625 | + name) |
|---|
| 626 | + _bpftool_get_map_names |
|---|
| 627 | + ;; |
|---|
| 628 | + pinned) |
|---|
| 629 | + _filedir |
|---|
| 630 | + ;; |
|---|
| 631 | + *) |
|---|
| 632 | + _bpftool_one_of_list $MAP_TYPE |
|---|
| 633 | + ;; |
|---|
| 634 | + esac |
|---|
| 635 | + return 0 |
|---|
| 636 | + ;; |
|---|
| 637 | + *) |
|---|
| 638 | + [[ $prev == $object ]] && \ |
|---|
| 639 | + COMPREPLY=( $( compgen -W 'pin help' \ |
|---|
| 640 | + -- "$cur" ) ) |
|---|
| 352 | 641 | ;; |
|---|
| 353 | 642 | esac |
|---|
| 354 | 643 | ;; |
|---|
| 355 | 644 | map) |
|---|
| 356 | | - local MAP_TYPE='id pinned' |
|---|
| 645 | + local MAP_TYPE='id pinned name' |
|---|
| 357 | 646 | case $command in |
|---|
| 358 | | - show|list|dump) |
|---|
| 647 | + show|list|dump|peek|pop|dequeue|freeze) |
|---|
| 359 | 648 | case $prev in |
|---|
| 360 | 649 | $command) |
|---|
| 361 | 650 | COMPREPLY=( $( compgen -W "$MAP_TYPE" -- "$cur" ) ) |
|---|
| 362 | 651 | return 0 |
|---|
| 363 | 652 | ;; |
|---|
| 364 | 653 | id) |
|---|
| 365 | | - _bpftool_get_map_ids |
|---|
| 654 | + case "$command" in |
|---|
| 655 | + peek) |
|---|
| 656 | + _bpftool_get_map_ids_for_type stack |
|---|
| 657 | + _bpftool_get_map_ids_for_type queue |
|---|
| 658 | + ;; |
|---|
| 659 | + pop) |
|---|
| 660 | + _bpftool_get_map_ids_for_type stack |
|---|
| 661 | + ;; |
|---|
| 662 | + dequeue) |
|---|
| 663 | + _bpftool_get_map_ids_for_type queue |
|---|
| 664 | + ;; |
|---|
| 665 | + *) |
|---|
| 666 | + _bpftool_get_map_ids |
|---|
| 667 | + ;; |
|---|
| 668 | + esac |
|---|
| 669 | + return 0 |
|---|
| 670 | + ;; |
|---|
| 671 | + name) |
|---|
| 672 | + case "$command" in |
|---|
| 673 | + peek) |
|---|
| 674 | + _bpftool_get_map_names_for_type stack |
|---|
| 675 | + _bpftool_get_map_names_for_type queue |
|---|
| 676 | + ;; |
|---|
| 677 | + pop) |
|---|
| 678 | + _bpftool_get_map_names_for_type stack |
|---|
| 679 | + ;; |
|---|
| 680 | + dequeue) |
|---|
| 681 | + _bpftool_get_map_names_for_type queue |
|---|
| 682 | + ;; |
|---|
| 683 | + *) |
|---|
| 684 | + _bpftool_get_map_names |
|---|
| 685 | + ;; |
|---|
| 686 | + esac |
|---|
| 366 | 687 | return 0 |
|---|
| 367 | 688 | ;; |
|---|
| 368 | 689 | *) |
|---|
| 690 | + return 0 |
|---|
| 691 | + ;; |
|---|
| 692 | + esac |
|---|
| 693 | + ;; |
|---|
| 694 | + create) |
|---|
| 695 | + case $prev in |
|---|
| 696 | + $command) |
|---|
| 697 | + _filedir |
|---|
| 698 | + return 0 |
|---|
| 699 | + ;; |
|---|
| 700 | + type) |
|---|
| 701 | + COMPREPLY=( $( compgen -W 'hash array prog_array \ |
|---|
| 702 | + perf_event_array percpu_hash percpu_array \ |
|---|
| 703 | + stack_trace cgroup_array lru_hash \ |
|---|
| 704 | + lru_percpu_hash lpm_trie array_of_maps \ |
|---|
| 705 | + hash_of_maps devmap devmap_hash sockmap cpumap \ |
|---|
| 706 | + xskmap sockhash cgroup_storage reuseport_sockarray \ |
|---|
| 707 | + percpu_cgroup_storage queue stack sk_storage \ |
|---|
| 708 | + struct_ops inode_storage' -- \ |
|---|
| 709 | + "$cur" ) ) |
|---|
| 710 | + return 0 |
|---|
| 711 | + ;; |
|---|
| 712 | + key|value|flags|entries) |
|---|
| 713 | + return 0 |
|---|
| 714 | + ;; |
|---|
| 715 | + inner_map) |
|---|
| 716 | + COMPREPLY=( $( compgen -W "$MAP_TYPE" -- "$cur" ) ) |
|---|
| 717 | + return 0 |
|---|
| 718 | + ;; |
|---|
| 719 | + id) |
|---|
| 720 | + _bpftool_get_map_ids |
|---|
| 721 | + ;; |
|---|
| 722 | + name) |
|---|
| 723 | + case $pprev in |
|---|
| 724 | + inner_map) |
|---|
| 725 | + _bpftool_get_map_names |
|---|
| 726 | + ;; |
|---|
| 727 | + *) |
|---|
| 728 | + return 0 |
|---|
| 729 | + ;; |
|---|
| 730 | + esac |
|---|
| 731 | + ;; |
|---|
| 732 | + *) |
|---|
| 733 | + _bpftool_once_attr 'type' |
|---|
| 734 | + _bpftool_once_attr 'key' |
|---|
| 735 | + _bpftool_once_attr 'value' |
|---|
| 736 | + _bpftool_once_attr 'entries' |
|---|
| 737 | + _bpftool_once_attr 'name' |
|---|
| 738 | + _bpftool_once_attr 'flags' |
|---|
| 739 | + if _bpftool_search_list 'array_of_maps' 'hash_of_maps'; then |
|---|
| 740 | + _bpftool_once_attr 'inner_map' |
|---|
| 741 | + fi |
|---|
| 742 | + _bpftool_once_attr 'dev' |
|---|
| 369 | 743 | return 0 |
|---|
| 370 | 744 | ;; |
|---|
| 371 | 745 | esac |
|---|
| .. | .. |
|---|
| 380 | 754 | _bpftool_get_map_ids |
|---|
| 381 | 755 | return 0 |
|---|
| 382 | 756 | ;; |
|---|
| 757 | + name) |
|---|
| 758 | + _bpftool_get_map_names |
|---|
| 759 | + return 0 |
|---|
| 760 | + ;; |
|---|
| 383 | 761 | key) |
|---|
| 384 | 762 | COMPREPLY+=( $( compgen -W 'hex' -- "$cur" ) ) |
|---|
| 385 | 763 | ;; |
|---|
| 386 | 764 | *) |
|---|
| 765 | + case $(_bpftool_map_guess_map_type) in |
|---|
| 766 | + queue|stack) |
|---|
| 767 | + return 0 |
|---|
| 768 | + ;; |
|---|
| 769 | + esac |
|---|
| 770 | + |
|---|
| 387 | 771 | _bpftool_once_attr 'key' |
|---|
| 388 | 772 | return 0 |
|---|
| 389 | 773 | ;; |
|---|
| 390 | 774 | esac |
|---|
| 391 | 775 | ;; |
|---|
| 392 | | - update) |
|---|
| 776 | + update|push|enqueue) |
|---|
| 393 | 777 | case $prev in |
|---|
| 394 | 778 | $command) |
|---|
| 395 | 779 | COMPREPLY=( $( compgen -W "$MAP_TYPE" -- "$cur" ) ) |
|---|
| 396 | 780 | return 0 |
|---|
| 397 | 781 | ;; |
|---|
| 398 | 782 | id) |
|---|
| 399 | | - _bpftool_map_update_get_id |
|---|
| 783 | + _bpftool_map_update_get_id $command |
|---|
| 784 | + return 0 |
|---|
| 785 | + ;; |
|---|
| 786 | + name) |
|---|
| 787 | + _bpftool_map_update_get_name $command |
|---|
| 400 | 788 | return 0 |
|---|
| 401 | 789 | ;; |
|---|
| 402 | 790 | key) |
|---|
| .. | .. |
|---|
| 405 | 793 | value) |
|---|
| 406 | 794 | # We can have bytes, or references to a prog or a |
|---|
| 407 | 795 | # map, depending on the type of the map to update. |
|---|
| 408 | | - case $(_bpftool_map_update_map_type) in |
|---|
| 796 | + case "$(_bpftool_map_guess_map_type)" in |
|---|
| 409 | 797 | array_of_maps|hash_of_maps) |
|---|
| 410 | | - local MAP_TYPE='id pinned' |
|---|
| 798 | + local MAP_TYPE='id pinned name' |
|---|
| 411 | 799 | COMPREPLY+=( $( compgen -W "$MAP_TYPE" \ |
|---|
| 412 | 800 | -- "$cur" ) ) |
|---|
| 413 | 801 | return 0 |
|---|
| 414 | 802 | ;; |
|---|
| 415 | 803 | prog_array) |
|---|
| 416 | | - local PROG_TYPE='id pinned tag' |
|---|
| 804 | + local PROG_TYPE='id pinned tag name' |
|---|
| 417 | 805 | COMPREPLY+=( $( compgen -W "$PROG_TYPE" \ |
|---|
| 418 | 806 | -- "$cur" ) ) |
|---|
| 419 | 807 | return 0 |
|---|
| .. | .. |
|---|
| 427 | 815 | return 0 |
|---|
| 428 | 816 | ;; |
|---|
| 429 | 817 | *) |
|---|
| 818 | + case $(_bpftool_map_guess_map_type) in |
|---|
| 819 | + queue|stack) |
|---|
| 820 | + _bpftool_once_attr 'value' |
|---|
| 821 | + return 0; |
|---|
| 822 | + ;; |
|---|
| 823 | + esac |
|---|
| 824 | + |
|---|
| 430 | 825 | _bpftool_once_attr 'key' |
|---|
| 431 | 826 | local UPDATE_FLAGS='any exist noexist' |
|---|
| 432 | 827 | for (( idx=3; idx < ${#words[@]}-1; idx++ )); do |
|---|
| .. | .. |
|---|
| 445 | 840 | return 0 |
|---|
| 446 | 841 | fi |
|---|
| 447 | 842 | done |
|---|
| 843 | + |
|---|
| 448 | 844 | return 0 |
|---|
| 449 | 845 | ;; |
|---|
| 450 | 846 | esac |
|---|
| 451 | 847 | ;; |
|---|
| 452 | 848 | pin) |
|---|
| 453 | | - if [[ $prev == "$command" ]]; then |
|---|
| 454 | | - COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) ) |
|---|
| 455 | | - else |
|---|
| 456 | | - _filedir |
|---|
| 457 | | - fi |
|---|
| 849 | + case $prev in |
|---|
| 850 | + $command) |
|---|
| 851 | + COMPREPLY=( $( compgen -W "$MAP_TYPE" -- "$cur" ) ) |
|---|
| 852 | + ;; |
|---|
| 853 | + id) |
|---|
| 854 | + _bpftool_get_map_ids |
|---|
| 855 | + ;; |
|---|
| 856 | + name) |
|---|
| 857 | + _bpftool_get_map_names |
|---|
| 858 | + ;; |
|---|
| 859 | + esac |
|---|
| 458 | 860 | return 0 |
|---|
| 459 | 861 | ;; |
|---|
| 460 | 862 | event_pipe) |
|---|
| .. | .. |
|---|
| 464 | 866 | return 0 |
|---|
| 465 | 867 | ;; |
|---|
| 466 | 868 | id) |
|---|
| 467 | | - _bpftool_get_perf_map_ids |
|---|
| 869 | + _bpftool_get_map_ids_for_type perf_event_array |
|---|
| 870 | + return 0 |
|---|
| 871 | + ;; |
|---|
| 872 | + name) |
|---|
| 873 | + _bpftool_get_map_names_for_type perf_event_array |
|---|
| 468 | 874 | return 0 |
|---|
| 469 | 875 | ;; |
|---|
| 470 | 876 | cpu) |
|---|
| .. | .. |
|---|
| 483 | 889 | *) |
|---|
| 484 | 890 | [[ $prev == $object ]] && \ |
|---|
| 485 | 891 | COMPREPLY=( $( compgen -W 'delete dump getnext help \ |
|---|
| 486 | | - lookup pin event_pipe show list update' -- \ |
|---|
| 892 | + lookup pin event_pipe show list update create \ |
|---|
| 893 | + peek push enqueue pop dequeue freeze' -- \ |
|---|
| 487 | 894 | "$cur" ) ) |
|---|
| 895 | + ;; |
|---|
| 896 | + esac |
|---|
| 897 | + ;; |
|---|
| 898 | + btf) |
|---|
| 899 | + local PROG_TYPE='id pinned tag name' |
|---|
| 900 | + local MAP_TYPE='id pinned name' |
|---|
| 901 | + case $command in |
|---|
| 902 | + dump) |
|---|
| 903 | + case $prev in |
|---|
| 904 | + $command) |
|---|
| 905 | + COMPREPLY+=( $( compgen -W "id map prog file" -- \ |
|---|
| 906 | + "$cur" ) ) |
|---|
| 907 | + return 0 |
|---|
| 908 | + ;; |
|---|
| 909 | + prog) |
|---|
| 910 | + COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) ) |
|---|
| 911 | + return 0 |
|---|
| 912 | + ;; |
|---|
| 913 | + map) |
|---|
| 914 | + COMPREPLY=( $( compgen -W "$MAP_TYPE" -- "$cur" ) ) |
|---|
| 915 | + return 0 |
|---|
| 916 | + ;; |
|---|
| 917 | + id) |
|---|
| 918 | + case $pprev in |
|---|
| 919 | + prog) |
|---|
| 920 | + _bpftool_get_prog_ids |
|---|
| 921 | + ;; |
|---|
| 922 | + map) |
|---|
| 923 | + _bpftool_get_map_ids |
|---|
| 924 | + ;; |
|---|
| 925 | + $command) |
|---|
| 926 | + _bpftool_get_btf_ids |
|---|
| 927 | + ;; |
|---|
| 928 | + esac |
|---|
| 929 | + return 0 |
|---|
| 930 | + ;; |
|---|
| 931 | + name) |
|---|
| 932 | + case $pprev in |
|---|
| 933 | + prog) |
|---|
| 934 | + _bpftool_get_prog_names |
|---|
| 935 | + ;; |
|---|
| 936 | + map) |
|---|
| 937 | + _bpftool_get_map_names |
|---|
| 938 | + ;; |
|---|
| 939 | + esac |
|---|
| 940 | + return 0 |
|---|
| 941 | + ;; |
|---|
| 942 | + format) |
|---|
| 943 | + COMPREPLY=( $( compgen -W "c raw" -- "$cur" ) ) |
|---|
| 944 | + ;; |
|---|
| 945 | + *) |
|---|
| 946 | + # emit extra options |
|---|
| 947 | + case ${words[3]} in |
|---|
| 948 | + id|file) |
|---|
| 949 | + _bpftool_once_attr 'format' |
|---|
| 950 | + ;; |
|---|
| 951 | + map|prog) |
|---|
| 952 | + if [[ ${words[3]} == "map" ]] && [[ $cword == 6 ]]; then |
|---|
| 953 | + COMPREPLY+=( $( compgen -W "key value kv all" -- "$cur" ) ) |
|---|
| 954 | + fi |
|---|
| 955 | + _bpftool_once_attr 'format' |
|---|
| 956 | + ;; |
|---|
| 957 | + *) |
|---|
| 958 | + ;; |
|---|
| 959 | + esac |
|---|
| 960 | + return 0 |
|---|
| 961 | + ;; |
|---|
| 962 | + esac |
|---|
| 963 | + ;; |
|---|
| 964 | + show|list) |
|---|
| 965 | + case $prev in |
|---|
| 966 | + $command) |
|---|
| 967 | + COMPREPLY+=( $( compgen -W "id" -- "$cur" ) ) |
|---|
| 968 | + ;; |
|---|
| 969 | + id) |
|---|
| 970 | + _bpftool_get_btf_ids |
|---|
| 971 | + ;; |
|---|
| 972 | + esac |
|---|
| 973 | + return 0 |
|---|
| 974 | + ;; |
|---|
| 975 | + *) |
|---|
| 976 | + [[ $prev == $object ]] && \ |
|---|
| 977 | + COMPREPLY=( $( compgen -W 'dump help show list' \ |
|---|
| 978 | + -- "$cur" ) ) |
|---|
| 979 | + ;; |
|---|
| 980 | + esac |
|---|
| 981 | + ;; |
|---|
| 982 | + gen) |
|---|
| 983 | + case $command in |
|---|
| 984 | + skeleton) |
|---|
| 985 | + _filedir |
|---|
| 986 | + ;; |
|---|
| 987 | + *) |
|---|
| 988 | + [[ $prev == $object ]] && \ |
|---|
| 989 | + COMPREPLY=( $( compgen -W 'skeleton help' -- "$cur" ) ) |
|---|
| 488 | 990 | ;; |
|---|
| 489 | 991 | esac |
|---|
| 490 | 992 | ;; |
|---|
| 491 | 993 | cgroup) |
|---|
| 492 | 994 | case $command in |
|---|
| 493 | | - show|list) |
|---|
| 494 | | - _filedir |
|---|
| 995 | + show|list|tree) |
|---|
| 996 | + case $cword in |
|---|
| 997 | + 3) |
|---|
| 998 | + _filedir |
|---|
| 999 | + ;; |
|---|
| 1000 | + 4) |
|---|
| 1001 | + COMPREPLY=( $( compgen -W 'effective' -- "$cur" ) ) |
|---|
| 1002 | + ;; |
|---|
| 1003 | + esac |
|---|
| 495 | 1004 | return 0 |
|---|
| 496 | 1005 | ;; |
|---|
| 497 | | - tree) |
|---|
| 498 | | - _filedir |
|---|
| 499 | | - return 0 |
|---|
| 500 | | - ;; |
|---|
| 501 | 1006 | attach|detach) |
|---|
| 502 | 1007 | local ATTACH_TYPES='ingress egress sock_create sock_ops \ |
|---|
| 503 | | - device bind4 bind6 post_bind4 post_bind6 connect4 \ |
|---|
| 504 | | - connect6 sendmsg4 sendmsg6' |
|---|
| 1008 | + device bind4 bind6 post_bind4 post_bind6 connect4 connect6 \ |
|---|
| 1009 | + getpeername4 getpeername6 getsockname4 getsockname6 \ |
|---|
| 1010 | + sendmsg4 sendmsg6 recvmsg4 recvmsg6 sysctl getsockopt \ |
|---|
| 1011 | + setsockopt sock_release' |
|---|
| 505 | 1012 | local ATTACH_FLAGS='multi override' |
|---|
| 506 | | - local PROG_TYPE='id pinned tag' |
|---|
| 1013 | + local PROG_TYPE='id pinned tag name' |
|---|
| 507 | 1014 | case $prev in |
|---|
| 508 | 1015 | $command) |
|---|
| 509 | 1016 | _filedir |
|---|
| 510 | 1017 | return 0 |
|---|
| 511 | 1018 | ;; |
|---|
| 512 | 1019 | ingress|egress|sock_create|sock_ops|device|bind4|bind6|\ |
|---|
| 513 | | - post_bind4|post_bind6|connect4|connect6|sendmsg4|\ |
|---|
| 514 | | - sendmsg6) |
|---|
| 1020 | + post_bind4|post_bind6|connect4|connect6|getpeername4|\ |
|---|
| 1021 | + getpeername6|getsockname4|getsockname6|sendmsg4|sendmsg6|\ |
|---|
| 1022 | + recvmsg4|recvmsg6|sysctl|getsockopt|setsockopt|sock_release) |
|---|
| 515 | 1023 | COMPREPLY=( $( compgen -W "$PROG_TYPE" -- \ |
|---|
| 516 | 1024 | "$cur" ) ) |
|---|
| 517 | 1025 | return 0 |
|---|
| .. | .. |
|---|
| 527 | 1035 | elif [[ "$command" == "attach" ]]; then |
|---|
| 528 | 1036 | # We have an attach type on the command line, |
|---|
| 529 | 1037 | # but it is not the previous word, or |
|---|
| 530 | | - # "id|pinned|tag" (we already checked for |
|---|
| 1038 | + # "id|pinned|tag|name" (we already checked for |
|---|
| 531 | 1039 | # that). This should only leave the case when |
|---|
| 532 | 1040 | # we need attach flags for "attach" commamnd. |
|---|
| 533 | 1041 | _bpftool_one_of_list "$ATTACH_FLAGS" |
|---|
| .. | .. |
|---|
| 552 | 1060 | ;; |
|---|
| 553 | 1061 | esac |
|---|
| 554 | 1062 | ;; |
|---|
| 1063 | + net) |
|---|
| 1064 | + local PROG_TYPE='id pinned tag name' |
|---|
| 1065 | + local ATTACH_TYPES='xdp xdpgeneric xdpdrv xdpoffload' |
|---|
| 1066 | + case $command in |
|---|
| 1067 | + show|list) |
|---|
| 1068 | + [[ $prev != "$command" ]] && return 0 |
|---|
| 1069 | + COMPREPLY=( $( compgen -W 'dev' -- "$cur" ) ) |
|---|
| 1070 | + return 0 |
|---|
| 1071 | + ;; |
|---|
| 1072 | + attach) |
|---|
| 1073 | + case $cword in |
|---|
| 1074 | + 3) |
|---|
| 1075 | + COMPREPLY=( $( compgen -W "$ATTACH_TYPES" -- "$cur" ) ) |
|---|
| 1076 | + return 0 |
|---|
| 1077 | + ;; |
|---|
| 1078 | + 4) |
|---|
| 1079 | + COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) ) |
|---|
| 1080 | + return 0 |
|---|
| 1081 | + ;; |
|---|
| 1082 | + 5) |
|---|
| 1083 | + case $prev in |
|---|
| 1084 | + id) |
|---|
| 1085 | + _bpftool_get_prog_ids |
|---|
| 1086 | + ;; |
|---|
| 1087 | + name) |
|---|
| 1088 | + _bpftool_get_prog_names |
|---|
| 1089 | + ;; |
|---|
| 1090 | + pinned) |
|---|
| 1091 | + _filedir |
|---|
| 1092 | + ;; |
|---|
| 1093 | + esac |
|---|
| 1094 | + return 0 |
|---|
| 1095 | + ;; |
|---|
| 1096 | + 6) |
|---|
| 1097 | + COMPREPLY=( $( compgen -W 'dev' -- "$cur" ) ) |
|---|
| 1098 | + return 0 |
|---|
| 1099 | + ;; |
|---|
| 1100 | + 8) |
|---|
| 1101 | + _bpftool_once_attr 'overwrite' |
|---|
| 1102 | + return 0 |
|---|
| 1103 | + ;; |
|---|
| 1104 | + esac |
|---|
| 1105 | + ;; |
|---|
| 1106 | + detach) |
|---|
| 1107 | + case $cword in |
|---|
| 1108 | + 3) |
|---|
| 1109 | + COMPREPLY=( $( compgen -W "$ATTACH_TYPES" -- "$cur" ) ) |
|---|
| 1110 | + return 0 |
|---|
| 1111 | + ;; |
|---|
| 1112 | + 4) |
|---|
| 1113 | + COMPREPLY=( $( compgen -W 'dev' -- "$cur" ) ) |
|---|
| 1114 | + return 0 |
|---|
| 1115 | + ;; |
|---|
| 1116 | + esac |
|---|
| 1117 | + ;; |
|---|
| 1118 | + *) |
|---|
| 1119 | + [[ $prev == $object ]] && \ |
|---|
| 1120 | + COMPREPLY=( $( compgen -W 'help \ |
|---|
| 1121 | + show list attach detach' -- "$cur" ) ) |
|---|
| 1122 | + ;; |
|---|
| 1123 | + esac |
|---|
| 1124 | + ;; |
|---|
| 1125 | + feature) |
|---|
| 1126 | + case $command in |
|---|
| 1127 | + probe) |
|---|
| 1128 | + [[ $prev == "prefix" ]] && return 0 |
|---|
| 1129 | + if _bpftool_search_list 'macros'; then |
|---|
| 1130 | + _bpftool_once_attr 'prefix' |
|---|
| 1131 | + else |
|---|
| 1132 | + COMPREPLY+=( $( compgen -W 'macros' -- "$cur" ) ) |
|---|
| 1133 | + fi |
|---|
| 1134 | + _bpftool_one_of_list 'kernel dev' |
|---|
| 1135 | + _bpftool_once_attr 'full unprivileged' |
|---|
| 1136 | + return 0 |
|---|
| 1137 | + ;; |
|---|
| 1138 | + *) |
|---|
| 1139 | + [[ $prev == $object ]] && \ |
|---|
| 1140 | + COMPREPLY=( $( compgen -W 'help probe' -- "$cur" ) ) |
|---|
| 1141 | + ;; |
|---|
| 1142 | + esac |
|---|
| 1143 | + ;; |
|---|
| 1144 | + link) |
|---|
| 1145 | + case $command in |
|---|
| 1146 | + show|list|pin|detach) |
|---|
| 1147 | + case $prev in |
|---|
| 1148 | + id) |
|---|
| 1149 | + _bpftool_get_link_ids |
|---|
| 1150 | + return 0 |
|---|
| 1151 | + ;; |
|---|
| 1152 | + esac |
|---|
| 1153 | + ;; |
|---|
| 1154 | + esac |
|---|
| 1155 | + |
|---|
| 1156 | + local LINK_TYPE='id pinned' |
|---|
| 1157 | + case $command in |
|---|
| 1158 | + show|list) |
|---|
| 1159 | + [[ $prev != "$command" ]] && return 0 |
|---|
| 1160 | + COMPREPLY=( $( compgen -W "$LINK_TYPE" -- "$cur" ) ) |
|---|
| 1161 | + return 0 |
|---|
| 1162 | + ;; |
|---|
| 1163 | + pin|detach) |
|---|
| 1164 | + if [[ $prev == "$command" ]]; then |
|---|
| 1165 | + COMPREPLY=( $( compgen -W "$LINK_TYPE" -- "$cur" ) ) |
|---|
| 1166 | + else |
|---|
| 1167 | + _filedir |
|---|
| 1168 | + fi |
|---|
| 1169 | + return 0 |
|---|
| 1170 | + ;; |
|---|
| 1171 | + *) |
|---|
| 1172 | + [[ $prev == $object ]] && \ |
|---|
| 1173 | + COMPREPLY=( $( compgen -W 'help pin show list' -- "$cur" ) ) |
|---|
| 1174 | + ;; |
|---|
| 1175 | + esac |
|---|
| 1176 | + ;; |
|---|
| 555 | 1177 | esac |
|---|
| 556 | 1178 | } && |
|---|
| 557 | 1179 | complete -F _bpftool bpftool |
|---|