Lines Matching defs:sock
101 int sock;
106 sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
107 if (sock < 0)
110 if (setsockopt(sock, SOL_NETLINK, NETLINK_EXT_ACK,
115 if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
121 if (getsockname(sock, (struct sockaddr *)&sa, &addrlen) < 0) {
132 return sock;
135 close(sock);
139 static int netlink_recv(int sock, __u32 nl_pid, __u32 seq,
151 len = recv(sock, buf, sizeof(buf), 0);
213 static int netlink_get_class(int sock, unsigned int nl_pid, int ifindex,
229 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
232 return netlink_recv(sock, nl_pid, seq, __dump_class_nlmsg,
252 static int netlink_get_qdisc(int sock, unsigned int nl_pid, int ifindex,
268 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
271 return netlink_recv(sock, nl_pid, seq, __dump_qdisc_nlmsg,
291 static int netlink_get_filter(int sock, unsigned int nl_pid, int ifindex, int handle,
308 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
311 return netlink_recv(sock, nl_pid, seq, __dump_filter_nlmsg,
330 static int netlink_get_link(int sock, unsigned int nl_pid,
345 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
348 return netlink_recv(sock, nl_pid, seq, __dump_link_nlmsg,
423 static int show_dev_tc_bpf(int sock, unsigned int nl_pid,
435 ret = netlink_get_class(sock, nl_pid, dev->ifindex,
441 ret = netlink_get_qdisc(sock, nl_pid, dev->ifindex,
450 ret = netlink_get_filter(sock, nl_pid, dev->ifindex,
460 ret = netlink_get_filter(sock, nl_pid, dev->ifindex, handle,
467 ret = netlink_get_filter(sock, nl_pid, dev->ifindex, handle,
474 ret = netlink_get_filter(sock, nl_pid, dev->ifindex, handle,
651 int i, sock, ret, filter_idx = -1;
668 sock = netlink_open(&nl_pid);
669 if (sock < 0) {
670 fprintf(stderr, "failed to open netlink sock\n");
683 ret = netlink_get_link(sock, nl_pid, dump_link_nlmsg, &dev_array);
689 ret = show_dev_tc_bpf(sock, nl_pid,
713 close(sock);