cregit-Linux how code gets into the kernel

Release 4.14 samples/bpf/sock_example.h

Directory: samples/bpf
/* SPDX-License-Identifier: GPL-2.0 */
#include <stdlib.h>
#include <stdio.h>
#include <linux/unistd.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <linux/if_ether.h>
#include <net/if.h>
#include <linux/if_packet.h>
#include <arpa/inet.h>
#include "libbpf.h"


static inline int open_raw_sock(const char *name) { struct sockaddr_ll sll; int sock; sock = socket(PF_PACKET, SOCK_RAW | SOCK_NONBLOCK | SOCK_CLOEXEC, htons(ETH_P_ALL)); if (sock < 0) { printf("cannot create raw socket\n"); return -1; } memset(&sll, 0, sizeof(sll)); sll.sll_family = AF_PACKET; sll.sll_ifindex = if_nametoindex(name); sll.sll_protocol = htons(ETH_P_ALL); if (bind(sock, (struct sockaddr *)&sll, sizeof(sll)) < 0) { printf("bind to %s: %s\n", name, strerror(errno)); close(sock); return -1; } return sock; }

Contributors

PersonTokensPropCommitsCommitProp
Alexei Starovoitov13798.56%150.00%
Joe Stringer21.44%150.00%
Total139100.00%2100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Alexei Starovoitov16997.69%240.00%
Joe Stringer21.16%120.00%
Arnaldo Carvalho de Melo10.58%120.00%
Greg Kroah-Hartman10.58%120.00%
Total173100.00%5100.00%
Directory: samples/bpf
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.