/* Copyright (c) 2016 Facebook * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. */ #include #include #include #include #include #include #include #include #include "libbpf.h" static void usage(void) { printf("Usage: test_cgrp2_array_pin [...]\n"); printf(" -F File to pin an BPF cgroup array\n"); printf(" -U Update an already pinned BPF cgroup array\n"); printf(" -v Full path of the cgroup2\n"); printf(" -h Display this help\n"); } int main(int argc, char **argv) { const char *pinned_file = NULL, *cg2 = NULL; int create_array = 1; int array_key = 0; int array_fd = -1; int cg2_fd = -1; int ret = -1; int opt; while ((opt = getopt(argc, argv, "F:U:v:")) != -1) { switch (opt) { /* General args */ case 'F': pinned_file = optarg; break; case 'U': pinned_file = optarg; create_array = 0; break; case 'v': cg2 = optarg; break; default: usage(); goto out; } } if (!cg2 || !pinned_file) { usage(); goto out; } cg2_fd = open(cg2, O_RDONLY); if (cg2_fd < 0) { fprintf(stderr, "open(%s,...): %s(%d)\n", cg2, strerror(errno), errno); goto out; } if (create_array) { array_fd = bpf_create_map(BPF_MAP_TYPE_CGROUP_ARRAY, sizeof(uint32_t), sizeof(uint32_t), 1, 0); if (array_fd < 0) { fprintf(stderr, "bpf_create_map(BPF_MAP_TYPE_CGROUP_ARRAY,...): %s(%d)\n", strerror(errno), errno); goto out; } } else { array_fd = bpf_obj_get(pinned_file); if (array_fd < 0) { fprintf(stderr, "bpf_obj_get(%s): %s(%d)\n", pinned_file, strerror(errno), errno); goto out; } } ret = bpf_map_update_elem(array_fd, &array_key, &cg2_fd, 0); if (ret) { perror("bpf_map_update_elem"); goto out; } if (create_array) { ret = bpf_obj_pin(array_fd, pinned_file); if (ret) { fprintf(stderr, "bpf_obj_pin(..., %s): %s(%d)\n", pinned_file, strerror(errno), errno); goto out; } } out: if (array_fd != -1) close(array_fd); if (cg2_fd != -1) close(cg2_fd); return ret; } ut type='hidden' name='id' value='2c5d9555d6d937966d79d4c6529a5f7b9206e405'/>
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-29 10:56:56 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-29 10:56:56 -0800
commit2c5d9555d6d937966d79d4c6529a5f7b9206e405 (patch)
tree4f3d220ea3aeaadcae0796c5456e0ef9a908071d /drivers/usb/atm/Kconfig
parent53cd1ad1a68fd10f677445e04ed63aa9ce39b36b (diff)
parent2ad5d52d42810bed95100a3d912679d8864421ec (diff)
Merge branch 'parisc-4.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux
Pull two parisc fixes from Helge Deller: "One fix to avoid usage of BITS_PER_LONG in user-space exported swab.h header which breaks compiling qemu, and one trivial fix for printk continuation in the parisc parport driver" * 'parisc-4.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux: parisc: Don't use BITS_PER_LONG in userspace-exported swab.h header parisc, parport_gsc: Fixes for printk continuation lines
Diffstat (limited to 'drivers/usb/atm/Kconfig')